[vtkusers] Line polygon intersection

Jothybasu Selvaraj jothybasu at gmail.com
Tue Feb 14 09:16:07 EST 2012


It required some transformations to both ray and polygon to work correctly.

Jothy

On Mon, Feb 13, 2012 at 5:53 PM, David Doria <daviddoria at gmail.com> wrote:

> On Mon, Feb 13, 2012 at 12:09 PM, Jothybasu Selvaraj
> <jothybasu at gmail.com> wrote:
> > Why my ray(line) never intersects the polygon?
> >
> > I have a ray passing from up to down, and a polygon (like a circle at
> some
> > depth around that line).
> >
> > Here is the code
> >
> > vtkSmartPointer<vtkPolygon> polygon =
> >
> >             vtkSmartPointer<vtkPolygon>::New();
> >
> >     polygon->GetPoints()->InsertNextPoint(-35.0, 91.0,7.5);
> >
> >     polygon->GetPoints()->InsertNextPoint(47.0, 150.0, 7.5);
> >
> >     polygon->GetPoints()->InsertNextPoint(47.0, 150.0,-57.0);
> >
> >     polygon->GetPoints()->InsertNextPoint(-36.0, 92.0, -57.0);
> >
> >     #polygon->GetPoints()->InsertNextPoint(-35.0, 91.0,7.5);//tried even
> > closing the contour
> >
> >     // Inputs
> >
> >     double p1[3] = {-0.0,-884.0,-28.0};
> >
> >     double p2[3] = {-0.0,187.0,-28.0};
> >
> >     double tolerance = 0.001;
> >
> >     // Outputs
> >
> >       double t; // Parametric coordinate of intersection (0
> (corresponding
> > to p1) to 1 (corresponding to p2))
> >
> >       double x[3]; // The coordinate of the intersection
> >
> >       double pcoords[3];
> >
> >       int subId;
> >
> >
> >       vtkIdType iD = polygon->IntersectWithLine(p1, p2, tolerance, t, x,
> > pcoords, subId);
> >
> > //    if(iD!=0)
> >
> > //    {
> >
> >         qDebug() << "iD: ";
> >
> > //    }
>
> There must be something wrong with your coordinates, or something
> different in Python. This works as expected:
>
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/PolygonIntersection
>
> David
>



-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120214/e0d8a50e/attachment.htm>


More information about the vtkusers mailing list