[vtk-developers] bug in java-wrapping for vtkHyperOctree
Amy Squillacote
ahs at cfdrc.com
Mon Nov 3 16:16:42 EST 2008
As you said, the problem is in VTK-generated code, so I can't just
re-write it.
The possible fixes I had thought of for this are as follows.
* Move vtkCompactHyperOctreeCursor into its own .h/.cxx files. Then
it would be java-wrapped.
* Somehow change the java-wrapping for the NewCellCursor method of
vtkHyperOctree so that it does tempObj.NewInstance() instead of
trying to create a new class from java given the class name. (How
hard would it be to change the wrapping just for that method?)
* Keep the vtkCompactHyperOctreeCursor generated by the
NewCellCursor method internal to vtkHyperOctree (i.e., not return
a pointer to it). Then the SubdivideLeaf and CollapseTerminalNode
could use this internal vtkCompactHyperOctreeCursor* instead of
being passed an instance of it.
- Amy
David Cole wrote:
> Scratch the stupid response. Never mind. I thought that was java code
> you had written, not the generated stuff....
>
> <sheepish_grin />
>
>
> On Mon, Nov 3, 2008 at 3:59 PM, David Cole <david.cole at kitware.com
> <mailto:david.cole at kitware.com>> wrote:
>
> Can you call "tempObj.NewInstance()" from java? (Instead of
> explicitly creating an object of a given class, use the existing
> instance to give you an "empty" new one of the same type... does
> that work?)
>
>
>
> On Mon, Nov 3, 2008 at 3:55 PM, Amy Squillacote <ahs at cfdrc.com
> <mailto:ahs at cfdrc.com>> wrote:
>
> 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
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org <mailto:vtk-developers at vtk.org>
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
--
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