<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'm getting an error (the code is attached below). Can someone please detect what I'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's not suitable for interactive view. </font></font><font size="2"><font size="2">What'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 << "Usage: " << argv[0]<br> << " Filename(.xyz)" << 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<vtkPoints> points =<br>
vtkSmartPointer<vtkPoints>::New();<br> <br> while(std::getline(fin, line))<br> {<br> std::stringstream linestream;<br> linestream << line;<br> linestream >> x >> y >> z;<br> points->InsertNextPoint(x, y, z);<br>
}<br> <br> // Create a grid<br> vtkSmartPointer<vtkStructuredGrid> structuredGrid =<br> vtkSmartPointer<vtkStructuredGrid>::New();<br> <br> // Specify the dimensions of the grid<br> structuredGrid->SetDimensions(701,957,1);<br>
structuredGrid->SetPoints(points);<br> <br> int* dims = structuredGrid->GetDimensions();<br> <br> // Load the volume<br></font><font face="courier new,monospace"> std::string inputFilename = "volume.mhd";</font></div>
<div><font face="courier new,monospace"> vtkSmartPointer<vtkMetaImageReader> reader = vtkSmartPointer<vtkMetaImageReader>::New();<br> reader->SetFileName(inputFilename.c_str());<br> reader->Update();<br>
</font><font face="courier new,monospace"></font></div>
<div><font face="courier new,monospace"> // Probe<br> vtkSmartPointer<vtkProbeFilter> probe = <br> vtkSmartPointer<vtkProbeFilter>::New();<br> probe->SetSource(reader->GetOutput());<br> probe->SetInput(structuredGrid);<br>
probe->Update();</font></div>
<div><font face="courier new,monospace"></font> </div>
<div><font face="courier new,monospace"> return 0;</font></div></div>