Hi Bill,<br><br>Thanks again for the detailed reply! Unfortunately, none can help me in my problem. I was sending a simplified version of my problem. My whole problem is that I have multiple 2D contours in parallel to each others in one vtkpolydata. I want to cut the contours with a plane. If the plane is exactly the plane of one of these 2D contours, the cut should return this exact 2D contour. Else, it should return the intersection points between the plane and the lines that connects the 2D contours. I was hoping vtkCutter will do the job and I won't need to divide the problem into two steps (one for the in-plane and one for the intersection). <br>
<br><br>Also, I'm not expert, but I don't think it's the float imprecision problem here! When I debug the code inside the vtk classes, it all stops in vtkTriangle::Contour. The vtkpolydata points are evaluated with the Evalute function of the plane (this works nicely as expected, with scalar value = 0 for the three points) then the points are passed to vtkTriangle::Contour. <br>
<br>The first thing this function does is to build a case table with the following for loop<br><span style="color: rgb(0, 0, 153);"><br>static int CASE_MASK[3] = {1,2,4};<br></span><span style="color: rgb(0, 0, 153);">// Build the case table</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);"> for ( i=0, index = 0; i < 3; i++)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"> {</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"> if (cellScalars->GetComponent(i,0) >= value)</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);"> {</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"> index |= CASE_MASK[i];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"> }</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);"> }</span><br><br>Basically, if the index is 7 it ignore this cell at all. However, if the three points are evaluated to be on the plane (i.e. value=0), index will be essentially 7!! So, I believe this is done intentionally, maybe for reasons related to contouring the intersected points.<br>
<br>what do you think?<br><br>Thanks!<br><br><br><div class="gmail_quote">On Fri, Sep 17, 2010 at 8:10 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Dan,<br>
<br>
I misunderstood your question. The cutting plane is infinitesimally<br>
thin so it would be difficult to extract those points via clipping.<br>
Also, both clipping and cutting introduce new points. I can think of 3<br>
ways to do this (there may be more):<br>
<br>
1) Define a thin hexahedral cell that contains the plane. Then use<br>
vtkSelectEnclosedPoints.<br>
2) Use vtkPlaneSource to define the plane. Then loop through all of<br>
the points and use the quad's EvaluatePosition to determine<br>
inside/outside. This will probably be slow.<br>
3) Loop over all points and compute the distance to the plane using<br>
the plane equation. Retain those points that are within a tolerance of<br>
0.<br>
<br>
<br>
Bill<br>
.<br>
<div><div></div><div class="h5">On Thu, Sep 16, 2010 at 4:47 PM, Dan Asimov <<a href="mailto:dan.asimov@gmail.com">dan.asimov@gmail.com</a>> wrote:<br>
> Hi Bill,<br>
><br>
> Thanks for the reply!<br>
><br>
> I already tried this but vtkClipPolydata will return all the points on one<br>
> side of the cutting plane. I need the points inside the cutting plane only.<br>
><br>
> For ex: if I move the origin of the cutting plane to<br>
><br>
> pPlane->SetOrigin(0,0,-0.1);<br>
><br>
> then vtkClipPolydata will return five points (the two cutting points and the<br>
> three points in the x-y plane). However, vtkCutter will return only the two<br>
> cutting points.<br>
><br>
> what do you think?<br>
><br>
> Thanks!<br>
><br>
><br>
> On Thu, Sep 16, 2010 at 2:33 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
> wrote:<br>
>><br>
>> You want vtkClipPolydata rather than vtkCutter.<br>
>><br>
>> On Thu, Sep 16, 2010 at 11:29 AM, Dan Asimov <<a href="mailto:dan.asimov@gmail.com">dan.asimov@gmail.com</a>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > I'm new to vtk. So, forgive me for my simple question!<br>
>> ><br>
>> > I'm trying to use vtkCutter on a vtkPolydata to get all the points<br>
>> > inside a<br>
>> > specific plane. However, it seems vtkCutter doesn't return any cell that<br>
>> > lies completely inside the cutting plane!<br>
>> ><br>
>> > Here is a very simple example in C++:<br>
>> ><br>
>> > //Adding some points (3 of them in the x-y plane)<br>
>> > vtkPoints *pPoints = vtkPoints::New();<br>
>> > pPoints->InsertNextPoint(1,0,-0.5);<br>
>> > pPoints->InsertNextPoint(0,1,0);<br>
>> > pPoints->InsertNextPoint(-1,0,0);<br>
>> > pPoints->InsertNextPoint(0,-1,0);<br>
>> ><br>
>> > vtkPolyData *pPolydata = vtkPolyData::New();<br>
>> > pPolydata->SetPoints(pPoints);<br>
>> ><br>
>> > vtkPolygon *pPolygon = vtkPolygon::New();<br>
>> > pPolygon->GetPointIds()->SetNumberOfIds(4);<br>
>> > for (int i=0;i<4;i++)<br>
>> > {<br>
>> > pPolygon->GetPointIds()->SetId(i,i);<br>
>> > }<br>
>> > pPolydata->Allocate(1,1);<br>
>> ><br>
>> > pPolydata->InsertNextCell(pPolygon->GetCellType(),pPolygon->GetPointIds());<br>
>> ><br>
>> > // The cutting plane is the x-y plane<br>
>> > vtkPlane *pPlane = vtkPlane::New();<br>
>> > pPlane->SetOrigin(0,0,0);<br>
>> > pPlane->SetNormal(0,0,1);<br>
>> ><br>
>> > // Cut<br>
>> > vtkCutter *pCutter = vtkCutter::New();<br>
>> > pCutter->SetCutFunction(pPlane);<br>
>> > pCutter->SetInput(pPolydata);<br>
>> > pCutter->Update();<br>
>> > vtkPolyData *pCutterOutput = pCutter->GetOutput();<br>
>> ><br>
>> > vtkPoints *Pts = pCutterOutput->GetPoints();<br>
>> > int nPts = Pts->GetNumberOfPoints();<br>
>> ><br>
>> > now, the pCutterOutput contains only two points (0,1,0) & (0,-1,0). I<br>
>> > was<br>
>> > expecting it will contain also (-1,0,0) since it's in the same plane<br>
>> > (x-y<br>
>> > plane). Am I missing something??<br>
>> ><br>
>> > Thanks for your help!<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the VTK FAQ at:<br>
>> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>