vtkPolyDataAppend of circles make holes in intersections

Hello,

I want to delete some areas of a polydata transformed to image. It works well but it is very slow.

clippin_polydata

For every circle, I make an extrusion towards the normal and I convert it into image, and substract it to the volume. And I do this for every circle. The problem is that going from polydata to image takes time and as I do it for every circle then it becomes a bit slow.

I wonder if I can make an union of the circles. I have tried all the ways to use the vtkbooleanoperationfilter with union. with triangles and clean as input from the circle and nothing. Sometimes it says no interseccion found and returns an empty polydata or that the cells are not supported. I made a subdivision of points just in case but it did not work. If I use vtkPolyDataAppend the problem is that the intersected parts are considered empty areas so when i convert into image I get gaps. I wonder If I can make an union of this circles as a whole object and the extrusion of the normal once to substract to the image of the polydata to speed up the process instead of looping for every single circle.thanks !! I have also tried the contour filter but no help.
The circle is created with vtkRegularPolygonSource.

vtkSmartPointer<vtkRegularPolygonSource> brushCircle =
	vtkSmartPointer<vtkRegularPolygonSource>::New();
brushCircle->SetNumberOfSides(50);
brushCircle->SetRadius(2);
brushCircle->SetCenter(worldMouse_click);

vtkSmartPointer<vtkPolyData> prev_polydata;
	for (brushCircleActors_->InitTraversal();
		auto brushActor = brushCircleActors_->
               GetNextActor();) {
		vtkSmartPointer<vtkPolyData>  
             brushPolyDataTransformed = vtkPolyData::SafeDownCast
             (scene_.lock()->getStlWithTranform(brushActor));
		
		vtkSmartPointer<vtkPolyData>            
            brushPolyDataTransformedExtrudedInside =   
                computeLinearExtrusion
                  (brushPolyDataTransformed, -5000);

		vtkSmartPointer<vtkPolyData>
         brushPolyDataTransformedExtrudedOutside =                
      computeLinearExtrusion
          (brushPolyDataTransformed, 5000);

		vtkNew<vtkAppendPolyData> appendPolyData;
		appendPolyData->AddInputData
       (brushPolyDataTransformedExtrudedInside);
		appendPolyData->AddInputData
         (brushPolyDataTransformedExtrudedOutside);
		appendPolyData->Update();

		vtkSmartPointer<vtkImageData> sphere_brush_img =
               getFromPolydataToImage
          (appendPolyData->GetOutput(),     
         splint_image_data_->GetBounds(), 
          spacing_resol);

		
		splint_image_data_clipped_ = booleanSubstraction
      TwoPolyDatas(splint_image_data_clipped_,
    sphere_brush_img);
		splint_image_data_without_holes_ =     
      booleanSubstractionTwo
         PolyDatas(splint_image_data_without_holes_,
  sphere_brush_img);
		brushActor->VisibilityOff();
	}
1 Like