Foreword: This blog post mainly records the creation of various Source data in VTK, mainly introduces the settable parameters and variables contained in each Source data, and hopes to bring help to all friends!
Tip: This blog post will be updated continuously, and the order of source data may change.
1. vtkPolyLineSource
vtkPoints* plPts = vtkPoints::New();
for (vtkIdType i = 0; i < numPts; i++)
{
double* ptCoord = ...;
plPts->InsertNextPoint(ptCoord);
}
vtkPolyLineSource* polyLine = vtkPolyLineSource::New();
polyLine->SetPoints(plPts);
polyLine->Update();
vtkPolyDataMapper* mpper = vtkPolyDataMapper::New();
mpper->SetInputConnection(polyLine->GetOutputPort());
vtkActor* actor = vtkActor::New();
actor->SetMapper(mpper);
actor->GetProperty()->SetColor(0.0,1.0,0.0);
vtkRenderer* render = vtkRenderer::New();
render->AddActor(actor);
2. vtkPlaneSource
vtkPlaneSource* planeSource = vtkPlaneSource::New();
planeSource->SetOrigin(origin);
planeSource->SetPoint1(vect1);
planeSource->SetPoint2(vect2);
planeSource->Update();
Note: Do not use SetCenter to set the origin when vtkPlaneSource is created, it will make an error