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

Bill Lorensen bill.lorensen at gmail.com
Fri Sep 17 10:42:01 EDT 2010


You can't clip because it will introduce new points that correspond to
the clipped mesh.

On Fri, Sep 17, 2010 at 8:42 AM, Jim Peterson <jimcp at cox.net> wrote:
> Bill,
>
> Sorry to tag in, but are you saying the reason a point defined as (-1,0,0)
> is not included as on the plane origin (0,0,0) normal (0,0,1) is essentially
> because of the float imprecision, that the eventual representation of the
> point after some other math processing is slightly off the plane? so
> defining a clip with two planes origin1 (0.,0.,0.00001) normal1 (0.,0.,-1.)
> and  origin2 (0.,0.,-0.00001)  normal2(0.,0.,1.) might return the set of
> points "on" the plane? That would minimize the need to make sure your
> hexahedron extends to the edges of the original points.
>
> Thanks,
> Jim
>
> Bill Lorensen wrote:
>>
>> Dan,
>>
>> I misunderstood your question. The cutting plane is infinitesimally
>> thin so it would be difficult to extract those points via clipping.
>> Also, both clipping and cutting introduce new points. I can think of 3
>> ways to do this (there may be more):
>>
>> 1) Define a thin hexahedral cell that contains the plane. Then use
>> vtkSelectEnclosedPoints.
>> 2) Use vtkPlaneSource to define the plane. Then loop through all of
>> the points and use the quad's EvaluatePosition to determine
>> inside/outside. This will probably be slow.
>> 3) Loop over all points and compute the distance to the plane using
>> the plane equation. Retain those points that are within a tolerance of
>> 0.
>>
>>
>> Bill
>> .
>> On Thu, Sep 16, 2010 at 4:47 PM, Dan Asimov <dan.asimov at gmail.com> wrote:
>>
>>>
>>> Hi Bill,
>>>
>>> Thanks for the reply!
>>>
>>> I already tried this but vtkClipPolydata will return all the points on
>>> one
>>> side of the cutting plane. I need the points inside the cutting plane
>>> only.
>>>
>>> For ex: if I move the origin of the cutting plane to
>>>
>>> pPlane->SetOrigin(0,0,-0.1);
>>>
>>> then vtkClipPolydata will return five points (the two cutting points and
>>> the
>>> three points in the x-y plane). However, vtkCutter will return only the
>>> two
>>> cutting points.
>>>
>>> what do you think?
>>>
>>> Thanks!
>>>
>>>
>>> On Thu, Sep 16, 2010 at 2:33 PM, Bill Lorensen <bill.lorensen at gmail.com>
>>> wrote:
>>>
>>>>
>>>> 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
>>>>>
>>>>>
>>>>>
>>>
>>>
>>
>> _______________________________________________
>> 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