[vtkusers] vtkCutter doesn't return cells that are totally inside the cutting vtkPlane

Bill Lorensen bill.lorensen at gmail.com
Thu Sep 16 14:33:54 EDT 2010


You want vtkClipPolydata rather than vtkCutter.

On Thu, Sep 16, 2010 at 11:29 AM, Dan Asimov <dan.asimov at gmail.com> wrote:
> Hi,
>
> I'm new to vtk. So, forgive me for my simple question!
>
> I'm trying to use vtkCutter on a vtkPolydata to get all the points inside a
> specific plane. However, it seems vtkCutter doesn't return any cell that
> lies completely inside the cutting plane!
>
> Here is a very simple example in C++:
>
> //Adding some points (3 of them in the x-y plane)
> vtkPoints *pPoints = vtkPoints::New();
> pPoints->InsertNextPoint(1,0,-0.5);
> pPoints->InsertNextPoint(0,1,0);
> pPoints->InsertNextPoint(-1,0,0);
> pPoints->InsertNextPoint(0,-1,0);
>
> vtkPolyData *pPolydata = vtkPolyData::New();
> pPolydata->SetPoints(pPoints);
>
> vtkPolygon *pPolygon = vtkPolygon::New();
> pPolygon->GetPointIds()->SetNumberOfIds(4);
> for (int i=0;i<4;i++)
> {
>     pPolygon->GetPointIds()->SetId(i,i);
> }
> pPolydata->Allocate(1,1);
> pPolydata->InsertNextCell(pPolygon->GetCellType(),pPolygon->GetPointIds());
>
> // The cutting plane is the x-y plane
> vtkPlane *pPlane = vtkPlane::New();
> pPlane->SetOrigin(0,0,0);
> pPlane->SetNormal(0,0,1);
>
> // Cut
> vtkCutter *pCutter = vtkCutter::New();
> pCutter->SetCutFunction(pPlane);
> pCutter->SetInput(pPolydata);
> pCutter->Update();
> vtkPolyData *pCutterOutput = pCutter->GetOutput();
>
> vtkPoints *Pts = pCutterOutput->GetPoints();
> int nPts = Pts->GetNumberOfPoints();
>
> now, the pCutterOutput contains only two points (0,1,0) & (0,-1,0). I was
> expecting it will contain also (-1,0,0) since it's in the same plane (x-y
> plane). Am I missing something??
>
> Thanks for your help!
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list