<div dir="ltr"><div>Hi all,</div>
<div> </div>
<div>I have a 3D volume (read using <font size="2">vtkMetaImageReader)</font> <font size="2">and a vtkStructuredGrid object, and I wish to sample the volume according to the grid. The result should be a 2D image, with same dimensions as the grid. I tried using <font size="2">vtkProbeFilter to do so but I&#39;m getting an error (the code is attached below). Can someone please detect what I&#39;m doing wrong here? In addition, it seems like the probing action takes a lot of time (over half a second in release mode), which means it&#39;s not suitable for interactive view. </font></font><font size="2"><font size="2">What&#39;s the fastest way of sampling a volume given a structured grid?</font></font></div>


<div> </div>
<div>Thanks,</div>
<div>Eyal.</div>
<div> </div>
<div><font face="courier new,monospace">int main(int argc, char* argv[])<br>{<br>  // Verify input arguments<br>  if ( argc != 2 )<br>    {<br>    std::cout &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0]<br>              &lt;&lt; &quot; Filename(.xyz)&quot; &lt;&lt; std::endl;<br>

    return EXIT_FAILURE;<br>    }</font></div>
<div><font face="courier new,monospace">    double x, y, z;<br> <br>  // Get all data from the file<br>  std::string filename = argv[1];<br>  std::ifstream fin(filename.c_str());<br> <br>  std::string line;<br>  vtkSmartPointer&lt;vtkPoints&gt; points =<br>

    vtkSmartPointer&lt;vtkPoints&gt;::New();<br> <br>  while(std::getline(fin, line))<br>    {<br>  std::stringstream linestream;<br>  linestream &lt;&lt; line;<br>  linestream &gt;&gt; x &gt;&gt; y &gt;&gt; z;<br>  points-&gt;InsertNextPoint(x, y, z);<br>

    }<br> <br>  // Create a grid<br>  vtkSmartPointer&lt;vtkStructuredGrid&gt; structuredGrid =<br>    vtkSmartPointer&lt;vtkStructuredGrid&gt;::New();<br> <br>  // Specify the dimensions of the grid<br>  structuredGrid-&gt;SetDimensions(701,957,1);<br>

  structuredGrid-&gt;SetPoints(points);<br> <br>  int* dims = structuredGrid-&gt;GetDimensions();<br> <br>  // Load the volume<br></font><font face="courier new,monospace">  std::string inputFilename = &quot;volume.mhd&quot;;</font></div>


<div><font face="courier new,monospace">  vtkSmartPointer&lt;vtkMetaImageReader&gt; reader = vtkSmartPointer&lt;vtkMetaImageReader&gt;::New();<br>  reader-&gt;SetFileName(inputFilename.c_str());<br>  reader-&gt;Update();<br>

</font><font face="courier new,monospace"></font></div>
<div><font face="courier new,monospace">  // Probe<br>  vtkSmartPointer&lt;vtkProbeFilter&gt; probe = <br>    vtkSmartPointer&lt;vtkProbeFilter&gt;::New();<br>  probe-&gt;SetSource(reader-&gt;GetOutput());<br>  probe-&gt;SetInput(structuredGrid);<br>

  probe-&gt;Update();</font></div>
<div><font face="courier new,monospace"></font> </div>
<div><font face="courier new,monospace">  return 0;</font></div></div>