cap a vtkClipPolyData does not work propertly. Weird behaviour

Hi i´d like to cap the parts i clip and i used the code of this example

http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/CapClip

And i also tried this:

		for (int i = 0; i < (int)clipFilters_.size(); i++) {

			clipFilters_[i]->SetClipFunction(boolean_opsEahcPlane[i]);
			clipFilters_[i]->InsideOutOn();
			clipFilters_[i]->Update();
			clipFilters_[i]->Modified();

		}
		

		// Now extract feature edges
		auto boundaryEdges = vtkSmartPointer<vtkFeatureEdges>::New();
		boundaryEdges->SetInputConnection(clipFilters_[clipFilters_.size() - 1]->GetOutputPort());
		boundaryEdges->BoundaryEdgesOn();
		boundaryEdges->FeatureEdgesOff();
		boundaryEdges->NonManifoldEdgesOff();
		boundaryEdges->ManifoldEdgesOff();

		auto boundaryStrips = vtkSmartPointer<vtkStripper>::New();
		boundaryStrips->SetInputConnection(boundaryEdges->GetOutputPort());
		boundaryStrips->Update();

		// Triangulate the polyline contour
		vtkSmartPointer<vtkContourTriangulator> triangulator =
			vtkSmartPointer<vtkContourTriangulator>::New();
		triangulator->SetInputConnection(boundaryStrips->GetOutputPort());
		triangulator->Update();


		vtkSmartPointer<vtkAppendPolyData> appendFilter =
			vtkSmartPointer<vtkAppendPolyData>::New();
		appendFilter->AddInputConnection(triangulator->GetOutputPort());
		appendFilter->AddInputConnection(clipFilters_[clipFilters_.size() - 1]->GetOutputPort());

		// Remove any duplicate points.
		vtkSmartPointer<vtkCleanPolyData> cleanFilter =
			vtkSmartPointer<vtkCleanPolyData>::New();
		cleanFilter->SetInputConnection(appendFilter->GetOutputPort());
		cleanFilter->Update();
		
		 
                    Actor->GetMapper()->SetInputConnection(cleanFilter->GetOutputPort());
		Actor->GetMapper()->Update();

but it does not work for me. I get a weird behaviour. Is there any other fiter to close the gaps or to clip with cap?. Thanks

cap_clipping

Can you reduce de scene complexity? I mean, try to clip a simple triangulated sphere with your code and try to get the same unexpected behavior. The likelyhood of diagnosing bugs is far greater when we reproduce the problem with simpler data.

If you’re using a plane there is something specifically for closing while clipping. “vtkClipClosedSurface”. This requires manifold input (closed/watertight and non intersecting faces). It will also generate an open face if the normals or winding is backward. Use vtkReverseSense to fix that.

1 Like

Sure, but i cannot always guarantee manifold input and I have boolean operations not only planes i also get weird results with vtkClipClosedSurface. I have solved it transforming to volume to close it. But it is slower.

Thanks for the suggestions