I use the given example file RectGrid2.vtk as input file, and I construct a capping cylidner in the input file’s coordinates using a vtkImplicitBoolean as vtkActor’s input.But I find the texture of the cylinder is not clear enough when I move to the cylinder closer.And I want to know how to draw the contour line(represents isovalue of input file’s scalar value) on the vtkActor.
The code(partial) is copyed here:
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(0.0, 0.0, 0.0);
vtkSmartPointer<vtkRenderWindow> renderer = vtkSmartPointer<vtkRenderWindow>::New();
rw->AddRenderer(renderer);
rw->SetSize(640, 480);
rw->SetMultiSamples(1);
vtkSmartPointer<vtkRenderWindowInteractor> rwi = vtkSmartPointer<vtkRenderWindowInteractor>::New();
rwi->SetRenderWindow(rw);
QString fileName = "RectGrid2.vtk";
QFile file(fileName);
file.open(QIODevice::ReadOnly);
if (!file.exists()) return;
vtkSmartPointer<vtkDatasetReader> reader = vtkSmartPointer<vtkDatasetReader>::New();
reader->SetFileName(fileName.toStdString().c_str());
reader->Update();
vtkSmartPointer<vtkDataset> dataset = reader->GetOutput();
if (nullptr == dataset) return ;
vtkSmartPointer<vtkCylinder> cy = vtkSmartPointer<vtkCylinder>::New();
cy->SetCenter(dataset->GetCenter());
cy->SetRadius(0.2);
vtkSmartPointer<vtkPlane> basePlane = vtkSmartPointer<vtkPlane>::New();
basePlane->SetOrigin(datset->GetBounds()[2], 0);
basePlane->SetNormal(0, -1, 0);
vtkSmartPointer<vtkPlane> vertPlane = vtkSmartPointer<vtkPlane>::New();
vertPlane->SetOrigin(datset->GetBounds()[3], 0);
vertPlane->SetNormal(0, 1, 0);
vtkSmartPointer<vtkImplicitBoolean> op = vtkSmartPointer<vtkImplicitBoolean>::New();
op->SetOperationTypeToIntersection();
op->AddFunction(cy);
op->AddFunction(basePlane):
op->AddFunction(vertPlane);
vtkSmartPointer<vtkCutter> cyCut = vtkSmartPointer<vtkCutter>::New();
cyCut->SetInputConnection(reader->GetOutputPort());
cyCut->SetCutFunction(op);
vtkSmartPointer<vtkPolyDataMapper> cutMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
cutMapper->SetInputConnection(cyCut->GetOutputPort());
cutMapper->SetScalarRange(reader->GetOutput()->GetScalarRange());
vtkSmartPointer<vtkActor> cutActor = vtkSmartPointer<vtkActor>::New();
cutActor->SetMapper(cutMapper);
renderer->AddActor(cutActor);
rw->Render();
rwi->Start();