<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=GB2312" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
InsertNextTuple1 adds another new tuple, but you don't need that.
You've already pre-allocated all the tuples you'll need by calling
AllocateScalars. Call SetTuple1 instead of InsertNextTuple1 and you
should see a dramatic speed up...<br>
<br>
HTH,<br>
David<br>
<br>
<br>
Yixun Liu wrote:
<blockquote cite="mid000601c535ce$54404380$1f64a8c0@YXLIU" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2900.2180" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Hi,</font></div>
<div> </div>
<div><font face="Arial" size="2">I want to convert a java 3D
array(threeDarray) to a vtkImageData object(image).</font></div>
<div> </div>
<div><font face="Arial" size="2">I do it use java as below:</font></div>
<div> </div>
<div><font face="Arial" size="2"> vtkImageData image = new
vtkImageData();<br>
image.SetDimensions(iWidth, iHeight, iNumImg);<br>
image.SetOrigin(0.0, 0.0, 0.0);<br>
image.SetSpacing(spacing[0],spacing[1],spacing[2]);<br>
image.SetScalarType(5);<br>
image.AllocateScalars();<br>
vtkDataArray array = image.GetPointData().GetScalars();<br>
</font></div>
<font size="2"></font>
<div><font size="2"><br>
<font face="Arial"> for(int iZ = 0; iY < iNumImg; iZ++){</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial"> for(int iY= 0; iY
< iHeight; iY++){</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial"> for(int iX = 0; iX
< iWidth; iX++){</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial">
array.InsertNextTuple1(threeDarray[iZ][iY][iX]);<br>
}</font></font></div>
<div><font size="2"><font face="Arial"> }</font></font></div>
<div><font size="2"><font face="Arial">}</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial">However, it is very slow due
to the insertNextTuple(). Anybody tell me a queikly method?</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial">Best regards,</font></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><font face="Arial">Yixun Liu</font></font></div>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
</body>
</html>