In the end of the mail I put the utilities functions I made to use vtkCellArray and vtkIdTypeArray simplier in Java. You can see in setValue and getValue I make a copy of the int[] java array in a vtkIntArray and
make a deep copy of that. Why I do that ? Because the change into java &quot;world&quot; and native &quot;world&quot; is very slow so if I make that :<br><br>int[] array=...;<br>vtkIntArray intArray = new vtkIntArray();<br>
for(int i = 0 ; i &lt; array.length ; ++i)<br>&nbsp;&nbsp;&nbsp; intArray.SetValue(i, array[i]); // We go to native world array.length time<br><br>It will be very much slower than :<br><br>int[] array=...;<br>
vtkIntArray intArray = new vtkIntArray();<br>
intArray.SetJavaArray(array); // We go to native world one time<br>
<br>So it is better to make a temporary copy of the array and send id to the native world than not making copy and going to the native world for each element.<br><br>But I agree with you it would have been simplifier if the SetJavaArray method for vtkIdTypeArray existed... but it&#39;s not the case :).<br>
<br>/** Create a vtkPoints array from doubles */<br>&nbsp;&nbsp;&nbsp; public static vtkPoints createPoints(double[] points)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkPoints vtkPoints = new vtkPoints();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkDoubleArray d = new vtkDoubleArray();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; d.SetJavaArray(points);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; d.SetNumberOfComponents(3);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkPoints.SetData(d);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return vtkPoints;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp; &nbsp;* Create an index array for beams to be used as input from createCells<br>
&nbsp;&nbsp;&nbsp; &nbsp;* change {a, b, c, d} to {2, a, b, 2, c, d}<br>&nbsp;&nbsp;&nbsp; &nbsp;*/<br>&nbsp;&nbsp;&nbsp; public static int[] createBeamCells(int[] beams)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int numberOfBeam = beams.length / 2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int k = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int j = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int[] fCells = new int[3 * numberOfBeam];<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; numberOfBeam; i++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = 2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = beams[j++];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = beams[j++];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return fCells;<br>&nbsp;&nbsp;&nbsp; }<br>
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; /** Create an index array for triangles to be used as input from createCells */<br>&nbsp;&nbsp;&nbsp; public static int[] createTriangleCells(int[] cells, int offSetID)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int k = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int nCell = cells.length / 3;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int[] fCells = new int[nCell * 4];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; nCell * 3; i += 3)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = 3;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = cells[i] + offSetID;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = cells[i + 1] + offSetID;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fCells[k++] = cells[i + 2] + offSetID;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return fCells;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; /** Create a vtkCellArray from indexes */<br>&nbsp;&nbsp;&nbsp; public static vtkCellArray createCells(int cellNumber, int[] cells)<br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkCellArray vtkCells = new vtkCellArray();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkIdTypeArray array = new vtkIdTypeArray();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkIntArray intArray = new vtkIntArray();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; intArray.SetJavaArray(cells);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; array.DeepCopy(intArray);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkCells.SetCells(cellNumber, array);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return vtkCells;<br>&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp;&nbsp;&nbsp; public static int[] getValues(vtkIdTypeArray idarray)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkIntArray iarray = new vtkIntArray();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; iarray.DeepCopy(idarray);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return iarray.GetJavaArray();<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public static vtkIdTypeArray setValues(int[] values)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkIntArray iarray = new vtkIntArray();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; iarray.SetJavaArray(values);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkIdTypeArray array = new vtkIdTypeArray();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; array.DeepCopy(iarray);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(&quot;values : &quot; + values.length);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(&quot;iarray : &quot; + array.GetNumberOfTuples());<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return array;<br>&nbsp;&nbsp;&nbsp; }<br>
<br>Example of use :<br><br>int[] indicesBeams = ...;<br>int[] indicesTriangles = ...;<br>vtkPolyData data = new vtkPolyData();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; data.SetPoints(Utils.createPoints(dataProvider.getNodes()));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; data.SetLines(Utils.createCells(indiceBeams.length / 2, Utils.createBeamCells(indiceBeams));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data.SetPolys(Utils.createCells(indicesTriangles.length / 3, Utils.createTriangleCells(indicesTriangles, 0)));<br><div class="gmail_quote">2008/6/17 Phil Goddard &lt;<a href="mailto:philgoddard@telus.net">philgoddard@telus.net</a>&gt;:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I&#39;m trying to visualize some planes in 3D space (e.g. 8 such planes<br>
appropriately oriented would look like a cube) and had been planning on<br>
using the InsertNextCell method of vtkCellArray in conjunction with<br>
vtkStructuredGrid.<br>
However it seems that the java wrappers do no implement this method (which<br>
requires a vtkTypeId as the input data type).<br>
<br>
Can anyone confirm the non implementation of this method for me (or perhaps<br>
I&#39;m just misusing it).<br>
And if so, recommend another approach?<br>
<br>
Much appreciated.<br>
Phil.<br>
<br>
<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Julian Ibarz