<br><br><div class="gmail_quote">---------- Mensagem encaminhada ----------<br>De: <b class="gmail_sendername">Vinícius da Silva</b> <span dir="ltr"><<a href="mailto:dsilva.vinicius@gmail.com">dsilva.vinicius@gmail.com</a>></span><br>
Data: 22 de julho de 2010 16:50<br>Assunto: Re: [vtkusers] Marching Cubes Problem<br>Para: David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>><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'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"><<a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a>></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 <<a href="mailto:dsilva.vinicius@gmail.com" target="_blank">dsilva.vinicius@gmail.com</a>>:<br>
<div><div></div><div>> Hello, everybody.<br>
><br>
> I'm testing VTK marching cubes to know if this algorithm suits my needs. I'm<br>
> trying to make a simple example, using the vtkMarchingCubes in a<br>
> vtkImageData volumetric array, but the resulting vtkPolyData doesn't make<br>
> much sense for me. Am I doing something wrong? The code is below.<br>
><br>
> Thanks.<br>
><br>
> void calcIsoSurface(vtkPolyData *pPolyData){<br>
> //create an image data<br>
> vtkSmartPointer<vtkImageData> pImageData =<br>
> vtkSmartPointer<vtkImageData>::New();<br>
><br>
> //specify the size of the image data<br>
> pImageData->SetDimensions(I_XDIM , I_YDIM , I_ZDIM);<br>
> pImageData->SetNumberOfScalarComponents(1);<br>
> pImageData->SetScalarTypeToDouble();<br>
><br>
> int* piDims = pImageData->GetDimensions();<br>
><br>
> cout << "Dims: " << " x: " << piDims[0] << " y: " << piDims[1] << " z: "<br>
> << piDims[2] << endl;<br>
> cout << "Number of points: " << pImageData->GetNumberOfPoints() << endl;<br>
> cout << "Number of cells: " << pImageData->GetNumberOfCells() << endl;<br>
><br>
> for (int iZ = 0; iZ < piDims[2]; iZ++){<br>
> for (int iY = 0; iY < piDims[1]; iY++){<br>
> for (int iX = 0; iX < piDims[0]; iX++){<br>
> double* pdPixel =<br>
> static_cast<double*>(pImageData->GetScalarPointer(iX , iY , iZ));<br>
> if(iX < 1 || iY < 1 || iZ < 1 || iX > piDims[0] - 2 || iY ><br>
> piDims[1] - 2 || iZ > piDims[2] - 2){<br>
> pdPixel[0] = 10.0;<br>
> }else if(iX < 2 || iY < 2 || iZ < 2 || iX > piDims[0] - 3 ||<br>
> iY > piDims[1] - 3 || iZ > piDims[2] - 3){<br>
> pdPixel[0] = 0.0;<br>
> }<br>
> else{<br>
> pdPixel[0] = -10.0;<br>
> }<br>
> }<br>
> }<br>
> }<br>
><br>
> pImageData->Update();<br>
> vtkMarchingCubes *pIso = vtkMarchingCubes::New();<br>
> pIso->SetInput(pImageData);<br>
> pIso->SetNumberOfContours(1);<br>
> pIso->SetValue(0, 0.0);<br>
> pIso->Update();<br>
><br>
> vtkIndent indent;<br>
> pIso->PrintSelf(cout , indent);<br>
> g_pPolyData = vtkPolyData::New();<br>
> g_pPolyData = pIso->GetOutput();<br>
> g_pPolyData->Update();<br>
><br>
> //writing the status of PolyData<br>
> cout << endl << "isoSurface: lines: " << g_pPolyData->GetNumberOfLines()<br>
> << " vertices: " << g_pPolyData->GetNumberOfVerts() << endl;<br>
> }<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>
><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>