Hello, everybody.<br><br>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.<br>
<br>Thanks.<br><br>void calcIsoSurface(vtkPolyData *pPolyData){<br> //create an image data<br> vtkSmartPointer<vtkImageData> pImageData = 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: " << 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 = static_cast<double*>(pImageData->GetScalarPointer(iX , iY , iZ));<br> if(iX < 1 || iY < 1 || iZ < 1 || iX > piDims[0] - 2 || iY > 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 || 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() << " vertices: " << g_pPolyData->GetNumberOfVerts() << endl;<br>
}<br clear="all"><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>