在体中提取曲面
1.绘制曲线
demo:https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/ParametricSpline/
// Create a vtkPoints object and store the points in it
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(origin);
points->InsertNextPoint(p0);
points->InsertNextPoint(p1);
points->InsertNextPoint(p2);
points->InsertNextPoint(p3);
vtkSmartPointer<vtkParametricSpline> spline =
vtkSmartPointer<vtkParametricSpline>::New();
spline->SetPoints(points);
vtkSmartPointer<vtkParametricFunctionSource> functionSource =
vtkSmartPointer<vtkParametricFunctionSource>::New();
functionSource->SetParametricFunction(spline);
functionSource->Update();
2.提取曲面
demo:https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/CurvedReformation/
// Sweep the line to form a surface
double direction[3];
direction[0] = 0.0;
direction[1] = 0.0;
direction[2] = 1.0;
double distance = 164;
spline->Update();
vtkSmartPointer<vtkPolyData> surface =
SweepLine(spline->GetOutput(),
direction,
distance,
atoi(argv[3]));
// Probe the volume with the extruded surface
vtkSmartPointer<vtkProbeFilter> sampleVolume =
vtkSmartPointer<vtkProbeFilter>::New();
sampleVolume->SetInputConnection(1, imageReader->GetOutputPort());
#if VTK_MAJOR_VERSION <= 5
sampleVolume->SetInput(0, surface);
#else
sampleVolume->SetInputData(0, surface);
#endif
// Compute a simple window/level based on scalar range
vtkSmartPointer<vtkWindowLevelLookupTable> wlLut =
vtkSmartPointer<vtkWindowLevelLookupTable>::New();
double range = imageReader->GetOutput()->GetScalarRange()[1] -
imageReader->GetOutput()->GetScalarRange()[0];
double level = (imageReader->GetOutput()->GetScalarRange()[1] +
imageReader->GetOutput()->GetScalarRange()[0]) / 2.0;
wlLut->SetWindow(range);
wlLut->SetLevel(level);
// Create a mapper and actor.
vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputConnection(sampleVolume->GetOutputPort());
mapper->SetLookupTable(wlLut);
mapper->SetScalarRange(0, 255);
3.再polydata表面绘制曲线
PolygonalSurfacePointPlacer
https://kitware.github.io/vtk-examples/site/Cxx/PolyData/PolygonalSurfacePointPlacer/