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?)<div>
<br></div><div><br><br><div class="gmail_quote">On Mon, Nov 3, 2008 at 3:55 PM, Amy Squillacote <span dir="ltr"><<a href="mailto:ahs@cfdrc.com">ahs@cfdrc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi all,<br>
<br>
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.<br>

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

<br>
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.<br>

<br>
Ideas? Suggestions?<br>
<br>
- Amy<br>
<br>
-- <br>
Amy Squillacote                    Phone: (256) 726-4839<br>
Computer Scientist                 Fax: (256) 726-4806<br>
CFD Research Corporation           Web: <a href="http://www.cfdrc.com" target="_blank">http://www.cfdrc.com</a><br>
215 Wynn Drive, Suite 501<br>
Huntsville, AL  35805<br>
<br>
<br>
_______________________________________________<br>
vtk-developers mailing list<br>
<a href="mailto:vtk-developers@vtk.org" target="_blank">vtk-developers@vtk.org</a><br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
</blockquote></div><br></div>