I used vtkMarchingCubes to generate isosurface, from volume file.
I need to extract data from this surface, which mean print point and index in separate files.
The point set within a model’s poly data is accessible. The output of the vtkMarchingCubes algorithm is a vtkPolyData. I’m doing something similar. Here is how I loop over the point indices and get the position of each point via Python script:
modelNode = slicer.util.getNode(modelNodeID)
modelPolyData = modelNode.GetPolyData()
numPoints = modelPolyData.GetNumberOfPoints()
for ptId in range(numPoints):
pointPos = [0,0,0]
modelPolyData.GetPoint(ptId, pointPos)
GetPoint fills the three-element list with the position of the point corresponding to index ptId. You can then write these values to files.
Oh, you’re working in C++. You can clean this up as necessary, but the next steps after that would be:
surface->SetInputData(<image data input>)
surface->ReleaseDataFlagOn()
surface->Update()
vtkSmartPointer<vtkPolyData> modelPolyData = surface->GetOutput()
int numPoints = modelPolyData->GetNumberOfPoints()
double pointPos[3]
for (ptId=0; ptId<numPoints; ptId++){
modelPolyData->GetPoint(ptId, pointPos)
}
Here is the vtkPolyData class reference, which can give you other options for accessing the point data within the data structure (or cell data, if necessary). https://www.vtk.org/doc/nightly/html/classvtkPolyData
You’re welcome.
I don’t know much about IDEs for Linux, and I don’t know of one that has that functionality for VTK. All of my work with VTK in C++ was in Windows with Visual Studio.
PyCharm works well for me, including documentation, auto-complete, etc. Of course only when the debugger is connected to Slicer, otherwise the IDE cannot figure out what type each variable is.