Clipping an stl with a cylinder

Hi !!

I have a doubt i try to make a hole to a polydata (stl) given a cylinder but the resulting hole is not smooth.
Screenshot_1|552x500

I have also tried vtkBooleanOperationPolyDataFilter but it is very very slow. It can be hours so i cannot use it.

There is a faster way to make holes in an stl (polydata) with smooth results? Or i have to use stencils to transform it into volume, make the boolean operation with images and transform it back to surface?

Thanks

       vtkSmartPointer<vtkDelaunay3D> tri = vtkSmartPointer<vtkDelaunay3D>::New();
	tri->SetInputData(PolyData);
	tri->BoundingTriangulationOff();
	tri->Update();



	//vtkImplicitDataSet needs some scalars to interpolate to find inside / outside
	vtkSmartPointer<vtkElevationFilter>	elev = vtkSmartPointer<vtkElevationFilter>::New();
	elev->SetInputConnection(tri->GetOutputPort());
	elev->Update();
	vtkSmartPointer<vtkImplicitDataSet> implicit = vtkSmartPointer<vtkImplicitDataSet>::New();
	implicit->SetDataSet(elev->GetOutput());




	vtkSmartPointer<vtkClipPolyData> clipper = vtkSmartPointer<vtkClipPolyData>::New();
	clipper->SetClipFunction(implicit);
	clipper->SetInputData(extrude_dental);
	clipper->InsideOutOn();
	clipper->Update();

Boolean operation on meshes is one of the hardest problems problems in computational geometry. Considering that, the result you got on your first try is quite good. If you increase your mesh resolution then you may get acceptable results. You can also try Roemer’s Boolean filter implementation (Adding Roemer's Boolean Filter as a Remote Module) and you may find a few other relevant discussions on this forum (search for words like Boolean, intersection).

Thank you very much for your quick respose. I will follow this post. By now, i will use stencils. The results are a bit better and faster. And i will check novelties in this topic.

Please try it: https://github.com/zippy84/vtkbool

If you want to clip all the way through your polydata with a cylinder, then the fastest way is to use vtkClipPolyData with vtkCylinder. The vtkCylinder defines an implicit function for the cylinder, instead of defining the cylinder with polygons. Clipping polydata with a function is hundreds of times faster than clipping polydata with another polydata.

For example, see this example (unfortunately, it’s not a good example, since the example is much more complicated than what you need).

Edit: Note that if you use vtkImplicitDataSet to create the implicit function, you lose all of the speed benefits of implicit functions. The fast implicit functions are the simple ones: vtkPlane, vtkCylinder, vtkSphere and vtkImplicitVolume.

1 Like