[vtkusers] vtkPoints, vtkIdsList, JNI memory errors and Jeff Lee!

Jeff Lee jeff at cdnorthamerica.com
Tue Mar 28 10:15:31 EST 2006



Eugene Kim wrote:

> Hi Jeff,
>
>      Here is some test code that should illustrate my problem...  i've 
> basically reproduced the offending lines of code and inserted it in to 
> the Cone example for ease.  I also have some code which shows that the 
> cell arrays in vtkPolyData do not work.  I've have had this happen on 
> both vtk 4.4 and 5.0, 5.0 being the version i currently use.  Also, 
> don't mind the code that's commented out.  Some of it will produce 
> more errors, (like vtkPoints), and some of it is harmless.
>
forgot to ask which jdk and what platform?
-J

>
>
>
>
> /* This test evaluates the feasability of accessing the data 
> structures of a large number of objects */
>
> import vtk.*;
>
> public class Cone {
>
>    static {
>      System.loadLibrary("vtkCommonJava");
>      System.loadLibrary("vtkFilteringJava");
>      System.loadLibrary("vtkIOJava");
>      System.loadLibrary("vtkImagingJava");
>      System.loadLibrary("vtkGraphicsJava");
>      System.loadLibrary("vtkRenderingJava");
>    }
>
>    public static void main (String []args) {
>      System.out.println ( "Beginning test..." );
>
>      /* The number of data sets we'd like to test, and it's path */
>      int numObjects = 1;
>      String fileName = "/spin/snl/data/mcell/eugene/pjm_13.reduce.vtk";
>
>      vtkPolyData[] dataArray = new vtkPolyData[numObjects];
>      vtkPolyDataReader[] readerArray = new vtkPolyDataReader[numObjects];
>
>      for ( int i=0; i<numObjects; i++ ) {
>          readerArray[i] = new vtkPolyDataReader();
>          readerArray[i].SetFileName ( fileName );
>          readerArray[i].Update();
>          dataArray[i] = readerArray[i].GetOutput();
>          dataArray[i].Update();
>          System.out.println ( "Dataset "+i+" initialized" );
>      }
>
>      vtkCell theCell = null;
>      int numCells = dataArray[0].GetNumberOfCells(); //Because they're 
> all the same data set
>      vtkIdList pointList = null;
>      vtkPoints points = null;
>      int numPoints;
>      //vtkPoints finalPoints = new vtkPoints();
>      //finalPoints.SetDataTypeToDouble();
>      int theId;
>
>      /* Just to illustrate that the convenience methods do not do 
> anything */
>      System.out.println ( "Num verts: 
> "+dataArray[0].GetNumberOfVerts() );
>      System.out.println ( "Num polys: 
> "+dataArray[0].GetNumberOfPolys() );
>      System.out.println ( "Vert array: "+dataArray[0].GetVerts() );
>      System.out.println ( "Poly array: "+dataArray[0].GetPolys() );
>
>      double[] ids = new double[3];
>
>      /* Typically here, the value i would represent the objects in the
>       * array, but to illustrate the error that is not necessary.  At the
>       * very least, we can get it to break by having an insane amount
>       * of print statements below.  In this case 10000*10 statements,
>       * while pointList is being assigned dataArray's pointId lists.
>       * */
>      for ( int i=0; i<10000; i++ ) {
>
>        for ( int j=0; j<numCells; j++ ) {
>      theCell = dataArray[0].GetCell(j);
>      if ( j%10000 == 0 )
>          System.out.println ( "Dataset "+i+", cell "+j );
>      pointList = dataArray[0].GetCell(j).GetPointIds();
>      //points = dataArray[0].GetCell(j).GetPoints();
>      //numPoints = points.GetNumberOfPoints();
>
>      for ( int k=0; k<10; k++ ) {
>        //points.GetPoint(k,ids);
>        //points.GetPoint(k);
>        //pointList.GetId(k);
>
>        System.out.println ( i+" "+ids[0]+" "+ids[1]+" "+ids[2] );
>        /*
>        theId = pointList.GetId ( k );
>        tempPoint = new Point3d ( points.GetPoint(k) );
>        if ( theId+1 > finalPoints.size() )
>          finalPoints.setSize ( theId+1 );
>        if ( finalPoints.get ( theId ) == null )
>          finalPoints.add ( theId, tempPoint );
>        */
>          }
>
>        }
>      }
>
>      //System.out.println ( finalPoints.size() );
>
>    }
> }
>
> Thanks again,
> Eugene
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list