<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->SetDimensions(dims);</font></p>
<p><font face="courier new,monospace"> vtkPoints *points = vtkPoints::New();<br> points->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("D:\\RCADIA\\Eyal\\VTK_Learning\\LearnVTK\\StructuredGrid1\\grid1.txt");<br> if (myfile.is_open())<br>
{<br> //while (!myfile.eof())<br> for (j=0; j<dims[1]; j++) // Go over Y's<br> {<br> jOffset = j * dims[0];<br> for (i=0; i<dims[0]; i++) // Go over X'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->InsertPoint(offset,x);<br>
}<br> }<br> myfile.close();<br> }<br> else<br> cout << "Unable to open file";</font></p>
<p><font face="courier new,monospace"> sgrid->SetPoints(points);<br> points->Delete();</font><br></p>
<div>However I think the grid's topology is still incorrect since it only has points while what I'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"><<a href="mailto:madapeti@gmail.com">madapeti@gmail.com</a>></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'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 <dll/so name>D.<dll/so> that should be much<br>slower than the release build.<br><br>Peter<br><br>2011/9/15 Eyal Ben-Ishai <<a href="mailto:eyalbi007@gmail.com">eyalbi007@gmail.com</a>>:<br>
<div>
<div></div>
<div class="h5">> Thank you for your reply! Yes I have tried using the vtkProbeFilter, this is<br>> the code:<br>><br>> //Read volume<br>> std::string inputFilename = "volume.mhd";<br>> vtkSmartPointer<vtkMetaImageReader> reader =<br>
> vtkSmartPointer<vtkMetaImageReader>::New();<br>> reader->SetFileName(inputFilename.c_str());<br>> reader->Update();<br>><br>> // Read points<br>> std::string filename = argv[1];<br>
> std::ifstream fin(filename.c_str());<br>><br>> std::string line;<br>> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();<br>> while(std::getline(fin, line))<br>> {<br>
> double x,y,z;<br>> std::stringstream linestream;<br>> linestream << line;<br>> linestream >> x >> y >> z;<br>><br>> points->InsertNextPoint(x, y, z);<br>
> }<br>
><br>> fin.close();<br>><br>> // Polydata<br>> vtkSmartPointer<vtkPolyData> polydata =<br>> vtkSmartPointer<vtkPolyData>::New();<br>> polydata->SetPoints(points);<br>><br>> // Probe Filter<br>
> vtkSmartPointer<vtkProbeFilter> probe =<br>> vtkSmartPointer<vtkProbeFilter>::New();<br>> probe->SetSource(reader->GetOutput());<br>> probe->SetInput(polydata);<br>> probe->Update();<br>
><br>> Regarding this code, I have 3 questions (other than "is it correct?" of<br>> course):<br>><br>> 'points' are the points to sample the volume at. There are 10,000 sampling<br>> points that should output a 100x100 2D image. However, I didn't use this<br>
> information anywhere which is probably incorrect since 10,000 points can<br>> also produce 50x200 2D image. How should it be done?<br>> How can I render the resulted 2D image?<br>> The probing ('probe->Update()') takes quite a lot of time (~400ms), while I<br>
> need this action to be much faster since it's intended to be interactive.<br>> How can I speed things up? Maybe using vtkStructuredGrid will be faster?<br>><br>> Thank you so much,<br>> Eyal.<br>><br>
><br>> On Wed, Sep 14, 2011 at 2:25 PM, peterm <<a href="mailto:madapeti@gmail.com">madapeti@gmail.com</a>> wrote:<br>>><br>>> Hello<br>>><br>>> Did you try using the vtkProbeFilter for sampling from the grayscale<br>
>> volume?<br>>> You can find some examples about probing along lines and planes in the VTK<br>>> example code.<br>>><br>>> --<br>>> View this message in context:<br>>> <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>
>> Sent from the VTK - Users mailing list archive at Nabble.com.<br>>> _______________________________________________<br>>> Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
>><br>>> Visit other Kitware open-source projects at<br>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>>><br>
>> Please keep messages on-topic and check the VTK FAQ at:<br>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>><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>><br>><br></div></div></blockquote></div><br></div>