VTK中画直线有时候可通过vtkLineSource 或 vtkPolyLine
(二) vtkLineSource画直线
vtkLineSource直接通过设置直线的两个端点(point1和point2)来确定一条直线。
//method 2 vtkLineSource
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkSmartPointer.h>
#include <vtkProperty.h>
#include <vtkLineSource.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyLine.h>
int main(int, char *[]) {
//基于三维空间中两点画直线
double p0[3] = { 100.0, 100.0, 0.0 };
double p1[3] = { 300.0, 300.0, 0.0 };
vtkSmartPointer<vtkLineSource> lineSource =
vtkSmartPointer<vtkLineSource>::New();
lineSource->SetPoint1(p0);
lineSource->SetPoint2(p1);
lineSource->Update();