[vtkusers] Problem with two polydata clip
minyang
yangmin_hust at 126.com
Wed Oct 28 06:00:33 EDT 2015
This is VTK 5.10.1.
Requirement:
User pick several points on the screen, create a closed polygon, then cut
the below mesh(polydata) with this polygon.
Implement:
Extrude the polygon, triangulate it and clip mesh
Core Codes:
vtkSmartPointer<vtkPolyData> polyData =
vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(polyLinePoints);
polyData->SetPolys(polygons);
vtkSmartPointer<vtkLinearExtrusionFilter> extrude =
vtkSmartPointer<vtkLinearExtrusionFilter>::New();
extrude->SetInput(polyData);
extrude->SetExtrusionTypeToNormalExtrusion();
extrude->CappingOn();
extrude->SetVector(0, 0, -1 );
extrude->SetScaleFactor (50);
extrude->Update();
vtkSmartPointer<vtkTriangleFilter> tria =
vtkSmartPointer<vtkTriangleFilter>::New();
tria->SetInputConnection(extrude->GetOutputPort());
tria->Update();
vtkSmartPointer<vtkPolyDataNormals> norm =
vtkSmartPointer<vtkPolyDataNormals>::New();
norm->SetInput(tria->GetOutput());
vtkSmartPointer<vtkImplicitPolyDataDistance> implicit_data =
vtkSmartPointer<vtkImplicitPolyDataDistance>::New();
implicit_data->SetInput(norm->GetOutput());
vtkSmartPointer<vtkClipPolyData> clipper =
vtkSmartPointer<vtkClipPolyData>::New();
clipper->SetInput(inputMeshPolyData);
clipper->SetClipFunction(implicit_data);
clipper->GenerateClippedOutputOn();
clipper->InsideOutOn();
clipper->Update();
poly_data_copy = vtkPolyData::New();
poly_data_copy->DeepCopy(clipper->GetOutput()/*cutter->GetOutput()*/);
vtkSmartPointer<vtkPolyDataMapper> mapper_cut =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper_cut->SetInput(poly_data_copy);
vtkSmartPointer<vtkActor> actor_copy = vtkSmartPointer<vtkActor>::New();
actor_copy->SetMapper(mapper_cut);
actor_copy->VisibilityOn();
renderer->AddActor(actor_copy);
renderWindow->Render();
<http://vtk.1045678.n5.nabble.com/file/n5734644/clip_issue.png>
Problem: In red circle, there are additional meshes clipped near the acute
angle. These section should not be clipped. Any expert know what wrong of my
codes? or is there any limition of VTK in handle two polygon clip? Thanks
in advance.
--
View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-two-polydata-clip-tp5734644.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list