[vtk-developers] bug in java-wrapping for vtkHyperOctree
David Cole
david.cole at kitware.com
Mon Nov 3 15:59:03 EST 2008
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> 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
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20081103/f87e05b7/attachment.html>
More information about the vtk-developers
mailing list