<br><br><div class="gmail_quote">---------- Mensagem encaminhada ----------<br>De: <b class="gmail_sendername">Vinícius da Silva</b> <span dir="ltr">&lt;<a href="mailto:dsilva.vinicius@gmail.com">dsilva.vinicius@gmail.com</a>&gt;</span><br>
Data: 22 de julho de 2010 16:50<br>Assunto: Re: [vtkusers] Marching Cubes Problem<br>Para: David Doria &lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;<br><br><br>Yes, I see the examples earlier. My problem is that I want to generate volumetric data in run-time and apply marching cubes on it. The code in examples always read the data from some file, but I don&#39;t have files because I will apply the marching cubes in scalar fields resulting of CSG trees that I will only know in run-time. I need the resulting vtkPolyData because I have to convert the VTK geometry representation to another library half-edge representation (this is the main objective of the program). There is some way to do that like the code I posted early? What I want to know is if there is some way to fill a vtkImageData with the scalar values of the CSG tree and obtain the resulting polyhedra with vtkMarchingCubes.<br>

<br><div class="gmail_quote">Em 22 de julho de 2010 16:17, David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a>&gt;</span> escreveu:<div><div></div><div class="h5">
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2010/7/22 Vinícius da Silva &lt;<a href="mailto:dsilva.vinicius@gmail.com" target="_blank">dsilva.vinicius@gmail.com</a>&gt;:<br>
<div><div></div><div>&gt; Hello, everybody.<br>
&gt;<br>
&gt; I&#39;m testing VTK marching cubes to know if this algorithm suits my needs. I&#39;m<br>
&gt; trying to make a simple example, using the vtkMarchingCubes in a<br>
&gt; vtkImageData volumetric array, but the resulting vtkPolyData doesn&#39;t make<br>
&gt; much sense for me. Am I doing something wrong? The code is below.<br>
&gt;<br>
&gt; Thanks.<br>
&gt;<br>
&gt; void calcIsoSurface(vtkPolyData *pPolyData){<br>
&gt;     //create an image data<br>
&gt;     vtkSmartPointer&lt;vtkImageData&gt; pImageData =<br>
&gt; vtkSmartPointer&lt;vtkImageData&gt;::New();<br>
&gt;<br>
&gt;     //specify the size of the image data<br>
&gt;     pImageData-&gt;SetDimensions(I_XDIM , I_YDIM , I_ZDIM);<br>
&gt;     pImageData-&gt;SetNumberOfScalarComponents(1);<br>
&gt;     pImageData-&gt;SetScalarTypeToDouble();<br>
&gt;<br>
&gt;     int* piDims = pImageData-&gt;GetDimensions();<br>
&gt;<br>
&gt;     cout &lt;&lt; &quot;Dims: &quot; &lt;&lt; &quot; x: &quot; &lt;&lt; piDims[0] &lt;&lt; &quot; y: &quot; &lt;&lt; piDims[1] &lt;&lt; &quot; z: &quot;<br>
&gt; &lt;&lt; piDims[2] &lt;&lt; endl;<br>
&gt;     cout &lt;&lt; &quot;Number of points: &quot; &lt;&lt; pImageData-&gt;GetNumberOfPoints() &lt;&lt; endl;<br>
&gt;     cout &lt;&lt; &quot;Number of cells: &quot; &lt;&lt; pImageData-&gt;GetNumberOfCells() &lt;&lt; endl;<br>
&gt;<br>
&gt;     for (int iZ = 0; iZ &lt; piDims[2]; iZ++){<br>
&gt;         for (int iY = 0; iY &lt; piDims[1]; iY++){<br>
&gt;             for (int iX = 0; iX &lt; piDims[0]; iX++){<br>
&gt;                 double* pdPixel =<br>
&gt; static_cast&lt;double*&gt;(pImageData-&gt;GetScalarPointer(iX , iY , iZ));<br>
&gt;                 if(iX &lt; 1 || iY &lt; 1 || iZ &lt; 1 || iX &gt; piDims[0] - 2 || iY &gt;<br>
&gt; piDims[1] - 2 || iZ &gt; piDims[2] - 2){<br>
&gt;                     pdPixel[0] = 10.0;<br>
&gt;                 }else if(iX &lt; 2 || iY &lt; 2 || iZ &lt; 2 || iX &gt; piDims[0] - 3 ||<br>
&gt; iY &gt; piDims[1] - 3 || iZ &gt; piDims[2] - 3){<br>
&gt;                     pdPixel[0] = 0.0;<br>
&gt;                 }<br>
&gt;                 else{<br>
&gt;                     pdPixel[0] = -10.0;<br>
&gt;                 }<br>
&gt;             }<br>
&gt;         }<br>
&gt;     }<br>
&gt;<br>
&gt;     pImageData-&gt;Update();<br>
&gt;     vtkMarchingCubes *pIso = vtkMarchingCubes::New();<br>
&gt;     pIso-&gt;SetInput(pImageData);<br>
&gt;     pIso-&gt;SetNumberOfContours(1);<br>
&gt;     pIso-&gt;SetValue(0, 0.0);<br>
&gt;     pIso-&gt;Update();<br>
&gt;<br>
&gt;     vtkIndent indent;<br>
&gt;     pIso-&gt;PrintSelf(cout , indent);<br>
&gt;     g_pPolyData = vtkPolyData::New();<br>
&gt;     g_pPolyData = pIso-&gt;GetOutput();<br>
&gt;     g_pPolyData-&gt;Update();<br>
&gt;<br>
&gt;     //writing the status of PolyData<br>
&gt;     cout &lt;&lt; endl &lt;&lt; &quot;isoSurface: lines: &quot; &lt;&lt; g_pPolyData-&gt;GetNumberOfLines()<br>
&gt; &lt;&lt; &quot; vertices: &quot; &lt;&lt; g_pPolyData-&gt;GetNumberOfVerts() &lt;&lt; endl;<br>
&gt; }<br>
&gt;<br>
&gt; Best Regards,<br>
&gt;<br>
&gt; Vinícius da Silva,<br>
&gt; M. Sc. Student<br>
&gt; Systems Engineering and Computation Program<br>
&gt; PESC/COPPE/UFRJ<br>
&gt; Rio de Janeiro - Brazil<br>
&gt;<br>
<br>
</div></div>Have you seen the wiki examples? <a href="http://www.vtk.org/Wiki/VTK/Examples" target="_blank">http://www.vtk.org/Wiki/VTK/Examples</a><br>
<br>
There is an example of marching cubes there:<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Medical/GenerateModelsFromLabels" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Medical/GenerateModelsFromLabels</a><br>
<br>
Let us know if you still have any problems.<br>
<br>
Thanks,<br>
<font color="#888888"><br>
David<br>
</font></blockquote></div></div></div><br><br clear="all"><br>-- <br><div><div></div><div class="h5">Best Regards,<br><br>Vinícius da Silva,<br>M. Sc. Student<br>Systems Engineering and Computation Program<br>PESC/COPPE/UFRJ<br>
Rio de Janeiro - Brazil<br>
</div></div></div><br><br clear="all"><br>-- <br>Best Regards,<br><br>Vinícius da Silva,<br>M. Sc. Student<br>Systems Engineering and Computation Program<br>PESC/COPPE/UFRJ<br>Rio de Janeiro - Brazil<br>