[vtkusers] Plane polydata intersection

Cory Quammen cquammen at cs.unc.edu
Mon Jun 24 10:04:14 EDT 2013


On Sun, Jun 23, 2013 at 12:41 PM, Laurent Chauvin
<lchauvin at bwh.harvard.edu> wrote:
> Hi Cory,
>
> Thank you very much for your reply.
> However, I'm not sure to understand what you mean.
> Should I create a new polydata with all points at the same z coordinates ?

Laurent,

You don't need to create a new polydata. Instead, you can add a new
vtkDataArray (likely a vtkFloatArray or vtkDataArray in this case) to
the point data of whatever polydata you already have by using
vtkPolyData::GetPointData()->AddArray(...).

For axis-aligned planes, this new array could simply contain the x, y,
or z coordinate of each of the points in your vtkPolyData. If you want
an intersection of your poly data with a plane spanning x and y, you
would add a point data array storing all the z values. You can then
use the vtkContourFilter to get the polydata consisting of line
segments that represents the intersection of your polydata with the
plane at a given z value by specifying that z value as the isolevel
for the contour filter. You have to make sure you tell the
vtkContourFilter to use your new coordinate array.

For an quick example of this concept, I've attached a simple ParaView
statefile showing how you can do this for a cylinder polydata. In this
example, I've specified my plane as spanning the x and y coordinates
with z value 0.2. In ParaView, I've used the Calculator to compute the
array consisting of the z coordinates of each point in the cylinder.
Forgive me if you don't have ParaView installed, we use it all the
time when prototyping visualizations.

> Does this work with some oblique planes ( not parallel to x,y, or z axis ) ?

For the general case of an arbitrary plane, you would want to compute
the distance from each point your desired plan instead of creating a
new array containing the x, y, or z coordinates of each point. Then
you would set the vtkContourFilter isolevel to 0. The point plane
calculation is pretty simple:
http://mathworld.wolfram.com/Point-PlaneDistance.html

Does that make sense?

> Thank you.
> -Laurent
>
>
> On Sun, Jun 23, 2013 at 12:31 PM, Cory Quammen <cquammen at cs.unc.edu> wrote:
>>
>> Laurent,
>>
>> For this special case of computing the intersection between a polydata
>> and a plane, you can use a little trick. First, you can compute a new
>> point data set for your polydata with,say, the z coordinates of each
>> point in the polydata. Then, to get the intersection with an xy plane,
>> you then use the vtkContourFilter operating on this coordinate point
>> data and specify the z value that corresponds to your plane. The
>> result should be equivalent to the intersection of the polydata with
>> that plane.
>>
>> It should be relatively fast to compute the contour, so you can
>> probably do this interactively.
>>
>> Hope that helps,
>> Cory
>>
>> On Sat, Jun 22, 2013 at 2:46 PM, Laurent Chauvin
>> <lchauvin at bwh.harvard.edu> wrote:
>> > Hello,
>> >
>> > I'm working on Slicer, and I was trying to find a nice way to display
>> > intersection between polydata and a plane.
>> > I read we could use a vtkCutter, but the thing is, I would like to do
>> > this
>> > interactively. I want to be able to move the plane, and update the
>> > intersection while moving the plane.
>> > I'm not sure using vtkCutter for this purpose would work. I think
>> > vtkCutter
>> > will take some times to execute, then moving the plane will be slow.
>> >
>> > I know this question has been asked before, but I would like if there
>> > were
>> > some update since then. New widgets or object that I could use for that
>> > ?
>> >
>> > I was thinking using vtkImageReslice, get polydata of the plane and
>> > compute
>> > the intersection between the 2 polydata, but I think it would also be to
>> > computing intensive to be able to do it smoothly with an interactive
>> > plane.
>> >
>> > Thank you.
>> > -Laurent
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > 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
>> >
>>
>>
>>
>> --
>> Cory Quammen
>> Research Associate
>> Department of Computer Science
>> The University of North Carolina at Chapel Hill
>
>
>
>
> --
> Laurent Chauvin, MS
> Surgical Navigation and Robotics Laboratory, Radiology
> Brigham And Women's Hospital, Harvard Medical School
> http://wiki.ncigt.org/index.php/User:Lchauvin



--
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PlaneIntersectionExample.pvsm
Type: application/octet-stream
Size: 119252 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130624/a4f8c898/attachment.obj>


More information about the vtkusers mailing list