#include "FITKBoundaryActor.h" #include #include #include #include #include #include #include #include namespace Comp { FITKBoundaryActor::FITKBoundaryActor() { //渲染窗口范围对象创建 _boundaryActor = vtkActor::New(); _boundaryActor->SetMapper(vtkSmartPointer::New()); //边界对象创建 vtkSmartPointer ugrid = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); points->InsertNextPoint(0., 0., 0.); points->InsertNextPoint(0., 0., 0.); //顶点创建 vtkSmartPointer c1 = vtkSmartPointer::New(); c1->InsertNextId(0); vtkSmartPointer c2 = vtkSmartPointer::New(); c2->InsertNextId(1); //添加两个节点单元类型 ugrid->InsertNextCell(VTKCellType::VTK_VERTEX, c1); ugrid->InsertNextCell(VTKCellType::VTK_VERTEX, c2); ugrid->SetPoints(points); _boundaryActor->GetMapper()->SetInputDataObject(ugrid); //设置为透明 _boundaryActor->GetProperty()->SetOpacity(0); } FITKBoundaryActor::~FITKBoundaryActor() { if (_boundaryActor) _boundaryActor->Delete(); } vtkActor* FITKBoundaryActor::getActor() { return _boundaryActor; } void FITKBoundaryActor::updateBoundary(double* bound) { //获取网格 vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast(_boundaryActor->GetMapper()->GetInput()); if (ugrid == nullptr) return; //重置 vtkPoints* pts = ugrid->GetPoints(); pts->Reset(); //重置边界 pts->InsertNextPoint(bound[0], bound[2], bound[4]); pts->InsertNextPoint(bound[1], bound[3], bound[5]); ugrid->Modified(); } }