[vtkusers] Intersection of a plane and a mesh

David Doria daviddoria+vtk at gmail.com
Tue Dec 29 18:23:35 EST 2009


On Tue, Dec 29, 2009 at 12:53 PM, Zein Salah <zeinsalah at gmail.com> wrote:
> David,
>
> I disconvered my error and it worked.  Thanks a lot!
>
> Now I have a nother issue. I need to read the generated lines from
> the output of the vtkcutter, in order to render then with openGL (I don't
> use vtkrenderer fot the current application). I could read the points
> using this peice of code, but it did not work for lines.
>
>  vtkPoints* points = cutter->GetOutput()->GetPoints();
>
>   double p[3];
>   int i;
>   for(i = 0; i < points->GetNumberOfPoints(); i++) {
>           points->GetPoint(i, p);
>           printf("Point# %d: %f %f %f \n", i, p[0], p[1], p[2]);  // this
> stuff works well
>
>   }
>
>
> // the following stuff did not work
>   vtkCellArray* lines = cutter->GetOutput()->GetLines();
>
>  int l[2];
>  for(i = 0; i < cutter->GetOutput()->GetNumberOfLines(); i++) {
>       lines->GetCell(i, 2, l);
>       printf("Line# %d: %d - %d  \n", i, l[0], l[1]);
>
>   }
>
>
> Any hint?
>
> Zein
>
>
>
>
>
>
>
>
>
>
> On Tue, Dec 29, 2009 at 4:36 PM, Zein Salah <zeinsalah at gmail.com> wrote:
>> Hello David,
>>
>> Thanks for your answer. I did it and it seem not to be working. I am
>> testing results
>> by writing the output of the cutter to file, using the vtkwriter. The
>> result is always
>>
>> # vtk DataFile Version 3.0
>> vtk output
>> ASCII
>> DATASET POLYDATA
>> POINTS 0 float
>>
>> I changed the center and normal of the cutting plane, but the result
>> remains unchanged.
>> BTW, the polydata I provide to the cutter is one that I create by
>> defining the points and
>> the triangles. Maybe the cutter is missing other information?
>>
>> Thanks,
>> Zein
>>
>> On Mon, Dec 28, 2009 at 5:17 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>>> On Sun, Dec 27, 2009 at 5:43 AM, Karthik Krishnan
>>> <karthik.krishnan at kitware.com> wrote:
>>>> Use a vtkCutter with a plane as the implicit function. There are ample
>>>> examples in the book and in VTK source tree.
>>>>
>>>> On 12/26/09, Zein Salah <zeinsalah at gmail.com> wrote:
>>>>> Hello,
>>>>>
>>>>> is there an efficient way in VTK to computer the intersection of a mesh and
>>>>> a cutting plane? The resulting contour might be represented as a vtk mesh.
>>>>>
>>>>> thanks,
>>>>>
>>>>> zein
>>>>> _______________________________________________
>>>>> 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
>>>>>
>>>>
>>>>
>>>> --
>>>> _________________________________
>>>
>>>
>>> This example cuts through a cube:
>>> http://www.cmake.org/Wiki/VTK_Examples_vtkCutter
>>>
>>> Simply replace the cube polydata with your mesh and you are done :)
>>>
>>> Thanks,
>>>
>>> David
>>> _______________________________________________
>>> 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
>>>
>>
>

Zein,

Please keep the discussion on the mailing list so others can
help/benefit from the discussion.

1) What was your error? It may be helpful for someone else to see the solution.
2) What do you mean by "doesn't work"? Are there 0 lines? Are you
having a compiler error or a run time error? Maybe you can make the
smallest compilable example of the problem along with a tiny demo data
set so someone else can run it?

Thanks,

David



More information about the vtkusers mailing list