<div dir="ltr"><div>Dear Peter,</div>
<div> </div>
<div>Yes a ran it in release mode. In debug it took 8(!!!) seconds.</div>
<div>As for the vtkStructuredGrid - can you assist in how exactly to build it? I tried the following code:</div>
<div> </div>
<p><font face="courier new,monospace">   // Create the structured grid.<br>   vtkStructuredGrid *sgrid = vtkStructuredGrid::New();<br>   sgrid-&gt;SetDimensions(dims);</font></p>
<p><font face="courier new,monospace">   vtkPoints *points = vtkPoints::New();<br>   points-&gt;Allocate(dims[0]*dims[1]);</font></p>
<p><font face="courier new,monospace">   // READ POINTS FROM TEXT FILE<br>   string line;<br>   ifstream myfile;<br>   myfile.open(&quot;D:\\RCADIA\\Eyal\\VTK_Learning\\LearnVTK\\StructuredGrid1\\grid1.txt&quot;);<br>   if (myfile.is_open())<br>

   {<br>    //while (!myfile.eof())<br>    for (j=0; j&lt;dims[1]; j++) // Go over Y&#39;s<br>    {<br>     jOffset = j * dims[0];<br>     for (i=0; i&lt;dims[0]; i++) // Go over X&#39;s<br>     {<br>      offset = i + jOffset;<br>

      getline(myfile, line);<br>      x[0] = atof(line.c_str());<br>      getline(myfile, line);<br>      x[1] = atof(line.c_str());<br>      getline(myfile, line);<br>      x[2] = atof(line.c_str());<br>      points-&gt;InsertPoint(offset,x);<br>

     }<br>    }<br>    myfile.close();<br>   }<br>   else<br>    cout &lt;&lt; &quot;Unable to open file&quot;;</font></p>
<p><font face="courier new,monospace">  sgrid-&gt;SetPoints(points);<br>  points-&gt;Delete();</font><br></p>
<div>However I think the grid&#39;s topology is still incorrect since it only has points while what I&#39;m looking for is more of a mesh.</div>
<div> </div>
<div>Thank you,</div>
<div>Eyal.<br><br></div>
<div class="gmail_quote">On Thu, Sep 15, 2011 at 10:55 AM, Peter Maday <span dir="ltr">&lt;<a href="mailto:madapeti@gmail.com">madapeti@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Dear Eyal,<br><br>I believe using vtkStructuredGrid should be applied for the sampling<br>instead of vtkPolyData as it has a regular grid topology, so that<br>

there is a direct correspondence between the cells and the image<br>pixels, while vtkPolyData does not have such a structure. I do not<br>know how to convert the resulting vtkUniformGrid to an image that can<br>be visualized in vtk, but it seems more reasonable for me to approach<br>

this way. I guess you should find some examples about rendering images<br>in general in tutorial examples. To be honest I am currently trying to<br>investigate the same speed issues with vtkProbeFilter (in 3D). Anyway<br>

I don&#39;t think it should take half a second to do the sampling, as<br>there are volume slicer widgets that run at interactive frame rates<br>and do basically the same thing. By the way are you using the release<br>version of the VTK library? For me at least cmake is compiling for<br>

debug as default (yielding &lt;dll/so name&gt;D.&lt;dll/so&gt; that should be much<br>slower than the release build.<br><br>Peter<br><br>2011/9/15 Eyal Ben-Ishai &lt;<a href="mailto:eyalbi007@gmail.com">eyalbi007@gmail.com</a>&gt;:<br>


<div>
<div></div>
<div class="h5">&gt; Thank you for your reply! Yes I have tried using the vtkProbeFilter, this is<br>&gt; the code:<br>&gt;<br>&gt;   //Read volume<br>&gt;   std::string inputFilename = &quot;volume.mhd&quot;;<br>&gt;   vtkSmartPointer&lt;vtkMetaImageReader&gt; reader =<br>

&gt; vtkSmartPointer&lt;vtkMetaImageReader&gt;::New();<br>&gt;   reader-&gt;SetFileName(inputFilename.c_str());<br>&gt;   reader-&gt;Update();<br>&gt;<br>&gt;   // Read points<br>&gt;   std::string filename = argv[1];<br>

&gt;   std::ifstream fin(filename.c_str());<br>&gt;<br>&gt;   std::string line;<br>&gt;   vtkSmartPointer&lt;vtkPoints&gt; points = vtkSmartPointer&lt;vtkPoints&gt;::New();<br>&gt;   while(std::getline(fin, line))<br>&gt;   {<br>

&gt;     double x,y,z;<br>&gt;     std::stringstream linestream;<br>&gt;     linestream &lt;&lt; line;<br>&gt;     linestream &gt;&gt; x &gt;&gt; y &gt;&gt; z;<br>&gt;<br>&gt;     points-&gt;InsertNextPoint(x, y, z);<br>
&gt;   }<br>
&gt;<br>&gt;   fin.close();<br>&gt;<br>&gt;   // Polydata<br>&gt;   vtkSmartPointer&lt;vtkPolyData&gt; polydata =<br>&gt; vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>&gt;   polydata-&gt;SetPoints(points);<br>&gt;<br>&gt;   // Probe Filter<br>

&gt;   vtkSmartPointer&lt;vtkProbeFilter&gt; probe =<br>&gt; vtkSmartPointer&lt;vtkProbeFilter&gt;::New();<br>&gt;   probe-&gt;SetSource(reader-&gt;GetOutput());<br>&gt;   probe-&gt;SetInput(polydata);<br>&gt;   probe-&gt;Update();<br>

&gt;<br>&gt; Regarding this code, I have 3 questions (other than &quot;is it correct?&quot; of<br>&gt; course):<br>&gt;<br>&gt; &#39;points&#39; are the points to sample the volume at. There are 10,000 sampling<br>&gt; points that should output a 100x100 2D image. However, I didn&#39;t use this<br>

&gt; information anywhere which is probably incorrect since 10,000 points can<br>&gt; also produce 50x200 2D image. How should it be done?<br>&gt; How can I render the resulted 2D image?<br>&gt; The probing (&#39;probe-&gt;Update()&#39;) takes quite a lot of time (~400ms), while I<br>

&gt; need this action to be much faster since it&#39;s intended to be interactive.<br>&gt; How can I speed things up? Maybe using vtkStructuredGrid will be faster?<br>&gt;<br>&gt; Thank you so much,<br>&gt; Eyal.<br>&gt;<br>

&gt;<br>&gt; On Wed, Sep 14, 2011 at 2:25 PM, peterm &lt;<a href="mailto:madapeti@gmail.com">madapeti@gmail.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; Hello<br>&gt;&gt;<br>&gt;&gt; Did you try using the vtkProbeFilter for sampling from the grayscale<br>

&gt;&gt; volume?<br>&gt;&gt; You can find some examples about probing along lines and planes in the VTK<br>&gt;&gt; example code.<br>&gt;&gt;<br>&gt;&gt; --<br>&gt;&gt; View this message in context:<br>&gt;&gt; <a href="http://vtk.1045678.n5.nabble.com/Creating-Curved-MPR-Image-tp4802388p4802571.html" target="_blank">http://vtk.1045678.n5.nabble.com/Creating-Curved-MPR-Image-tp4802388p4802571.html</a><br>

&gt;&gt; Sent from the VTK - Users mailing list archive at Nabble.com.<br>&gt;&gt; _______________________________________________<br>&gt;&gt; Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>

&gt;&gt;<br>&gt;&gt; Visit other Kitware open-source projects at<br>&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt;&gt;<br>

&gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt;&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;&gt;<br>&gt;&gt; Follow this link to subscribe/unsubscribe:<br>

&gt;&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;<br>&gt;<br></div></div></blockquote></div><br></div>