[vtkusers] Fwd: Marching Cubes Problem

Vinícius da Silva dsilva.vinicius at gmail.com
Thu Jul 22 15:51:46 EDT 2010


---------- Mensagem encaminhada ----------
De: Vinícius da Silva <dsilva.vinicius at gmail.com>
Data: 22 de julho de 2010 16:50
Assunto: Re: [vtkusers] Marching Cubes Problem
Para: David Doria <daviddoria+vtk at gmail.com <daviddoria%2Bvtk at gmail.com>>


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.

Em 22 de julho de 2010 16:17, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> escreveu:

2010/7/22 Vinícius da Silva <dsilva.vinicius at gmail.com>:
> > Hello, everybody.
> >
> > I'm testing VTK marching cubes to know if this algorithm suits my needs.
> I'm
> > trying to make a simple example, using the vtkMarchingCubes in a
> > vtkImageData volumetric array, but the resulting vtkPolyData doesn't make
> > much sense for me. Am I doing something wrong? The code is below.
> >
> > Thanks.
> >
> > void calcIsoSurface(vtkPolyData *pPolyData){
> >     //create an image data
> >     vtkSmartPointer<vtkImageData> pImageData =
> > vtkSmartPointer<vtkImageData>::New();
> >
> >     //specify the size of the image data
> >     pImageData->SetDimensions(I_XDIM , I_YDIM , I_ZDIM);
> >     pImageData->SetNumberOfScalarComponents(1);
> >     pImageData->SetScalarTypeToDouble();
> >
> >     int* piDims = pImageData->GetDimensions();
> >
> >     cout << "Dims: " << " x: " << piDims[0] << " y: " << piDims[1] << "
> z: "
> > << piDims[2] << endl;
> >     cout << "Number of points: " << pImageData->GetNumberOfPoints() <<
> endl;
> >     cout << "Number of cells: " << pImageData->GetNumberOfCells() <<
> endl;
> >
> >     for (int iZ = 0; iZ < piDims[2]; iZ++){
> >         for (int iY = 0; iY < piDims[1]; iY++){
> >             for (int iX = 0; iX < piDims[0]; iX++){
> >                 double* pdPixel =
> > static_cast<double*>(pImageData->GetScalarPointer(iX , iY , iZ));
> >                 if(iX < 1 || iY < 1 || iZ < 1 || iX > piDims[0] - 2 || iY
> >
> > piDims[1] - 2 || iZ > piDims[2] - 2){
> >                     pdPixel[0] = 10.0;
> >                 }else if(iX < 2 || iY < 2 || iZ < 2 || iX > piDims[0] - 3
> ||
> > iY > piDims[1] - 3 || iZ > piDims[2] - 3){
> >                     pdPixel[0] = 0.0;
> >                 }
> >                 else{
> >                     pdPixel[0] = -10.0;
> >                 }
> >             }
> >         }
> >     }
> >
> >     pImageData->Update();
> >     vtkMarchingCubes *pIso = vtkMarchingCubes::New();
> >     pIso->SetInput(pImageData);
> >     pIso->SetNumberOfContours(1);
> >     pIso->SetValue(0, 0.0);
> >     pIso->Update();
> >
> >     vtkIndent indent;
> >     pIso->PrintSelf(cout , indent);
> >     g_pPolyData = vtkPolyData::New();
> >     g_pPolyData = pIso->GetOutput();
> >     g_pPolyData->Update();
> >
> >     //writing the status of PolyData
> >     cout << endl << "isoSurface: lines: " <<
> g_pPolyData->GetNumberOfLines()
> > << " vertices: " << g_pPolyData->GetNumberOfVerts() << endl;
> > }
> >
> > Best Regards,
> >
> > Vinícius da Silva,
> > M. Sc. Student
> > Systems Engineering and Computation Program
> > PESC/COPPE/UFRJ
> > Rio de Janeiro - Brazil
> >
>
> Have you seen the wiki examples? http://www.vtk.org/Wiki/VTK/Examples
>
> There is an example of marching cubes there:
> http://www.vtk.org/Wiki/VTK/Examples/Medical/GenerateModelsFromLabels
>
> Let us know if you still have any problems.
>
> Thanks,
>
> David
>



-- 
Best Regards,

Vinícius da Silva,
M. Sc. Student
Systems Engineering and Computation Program
PESC/COPPE/UFRJ
Rio de Janeiro - Brazil



-- 
Best Regards,

Vinícius da Silva,
M. Sc. Student
Systems Engineering and Computation Program
PESC/COPPE/UFRJ
Rio de Janeiro - Brazil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100722/31fb53c2/attachment.htm>


More information about the vtkusers mailing list