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

David Cole david.cole at kitware.com
Mon Nov 3 16:02:47 EST 2008


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> 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> 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/e4294970/attachment.html>


More information about the vtk-developers mailing list