[vtk-developers] bug in java-wrapping for vtkHyperOctree

Amy Squillacote ahs at cfdrc.com
Mon Nov 3 15:55:14 EST 2008


Hi all,

We are trying to use vtkHyperOctree from java. We have run into problems 
with the NewCellCursor method. In c++, this method returns a 
vtkCompactHyperOctreeCursor, a subclass of vtkHyperOctreeCursor. The 
code below is copied from the NewCellCursor method in the java-wrapped 
version of vtkHyperOctree.

  public vtkHyperOctreeCursor NewCellCursor() {
    long temp = NewCellCursor_22();

    if (temp == 0) return null;
    vtkHyperOctreeCursor obj = null;
    java.lang.ref.WeakReference ref = 
(java.lang.ref.WeakReference)vtkGlobalJavaHash.PointerToReference.get(new 
Long(temp));
    if (ref != null) {
      obj = (vtkHyperOctreeCursor)ref.get();
    }
    if (obj == null) {
      vtkHyperOctreeCursor tempObj = new vtkHyperOctreeCursor(temp);
      String className = tempObj.GetClassName();
      try {
        Class c = Class.forName("vtk." + className);
        java.lang.reflect.Constructor cons = c.getConstructor(new 
Class[] {long.class} );
        obj = (vtkHyperOctreeCursor)cons.newInstance(new Object[] {new 
Long(temp)});
      } catch (Exception e) {
        e.printStackTrace();
      }
      tempObj.Delete();
    }
    return obj;
  }

The problem occurs on the following line: Class c = Class.forName("vtk." 
+ className);. The className variable is set to 
vtkCompactHyperOctreeCursor, but this class is not java-wrapped; it is 
internal to vtkHyperOctree.cxx. Thus this line causes a java  
ClassNotFoundException.

We need to be able to call NewCellCursor() from java in order to use the 
SubdivideLeaf and CollapseTerminalNode methods, both of which take a 
vtkHyperOctreeCursor as an argument. It is not possible to directly 
create an instance of vtkHyperOctreeCursor because it is an abstract class.

Ideas? Suggestions?

- Amy

-- 
Amy Squillacote                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtk-developers mailing list