Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Test for General_polygon_with_holes_2 containment of a Point_2

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Test for General_polygon_with_holes_2 containment of a Point_2


Chronological Thread 
  • From: Efi Fogel <>
  • To:
  • Subject: Re: [cgal-discuss] Test for General_polygon_with_holes_2 containment of a Point_2
  • Date: Mon, 21 Mar 2016 22:14:44 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:mxByfx1KyeAWuILMsmDT+DRfVm0co7zxezQtwd8ZsegfKvad9pjvdHbS+e9qxAeQG96Lu7Qd0qGP6PqocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC34LujqvroMebSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/NGSrjwKqQkUaRDXnNhKHEw/MSttB/ZTALJ6GFbSXQTihMPAg7L61bxUZ719yf7reFgwzLJAcqjRr89XXGu7rxgVQTzoCYBLT8wtm/N2eJqi6cOjRyg7zJ4zIPQKNWYOvtweazQefsVQGNAWoBaUCkXUdD0VJcGE+dUZbUQlIL6vVZb9RY=

The information is recorded in the face.
Call the face.contained() member function.

You can see the implementation of oriented_side(const Point_2& q) in Gps_on_surface_base_2.h

   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/



On Mon, Mar 21, 2016 at 9:21 PM, KHartmann <> wrote:
Hi Efi,

Thanks!  My code compiles and runs now!

But there is one problem.  The point containment test doesn't work as I had
hoped.  When I test a point that is inside a hole of a
Gen_Polygon_with_holes_2,
 the result is "yes, it hits a face".  I would like to be able to test if
that face is a hole, so I can say "no, it does not hit a face."  Is there a
way for me to know (in constant time) that the face is actually a hole in
the original
polygon?

I got the gist of the code below from an example int the documentation.

Thanks,
Kevin

void ContainmentTest( Gen_Polygon_with_holes_2* currPWHC,
                      bool strict,
                      std::vector< std::pair< Point*, bool > >& containments
)
{
  Gen_Polygon_set_2 gps( *currPWHC );

  Arrangement_2& arr = gps.arrangement();

  std::vector<Arr_Point_2> points;
  for ( size_t pCount = 0; pCount < containments.size(); pCount++ )
  {
    Point* currPoint = containments[ pCount ].first;
    points.push_back( Arr_Point_2( currPoint->GetX(), currPoint->GetY() ) );
  }

  std::vector<Query_result> results;
  CGAL::locate( arr, points.begin(), points.end(), std::back_inserter(
results ));

  for (size_t pCount = 0; pCount < points.size(); pCount++)
  {
    Query_result result = results[ pCount ];
    std::pair< Point*, bool >& containment = containments[ pCount ];

    Point* currPoint = containment.first;

    bool _onFace_ = false;
    bool _onEdge_ = false;
    bool _onVertex_ = false;

    if (const Arrangement_2::Face_const_handle* f =
      boost::get<Arrangement_2::Face_const_handle>(&(result.second)))
      if (!(*f)->is_unbounded())
        _onFace_ = true;

    if (const Arrangement_2::Halfedge_const_handle* e =
      boost::get<Arrangement_2::Halfedge_const_handle>(&(result.second)))
      _onEdge_ = true;

    if (const Arrangement_2::Vertex_const_handle*   v =
      boost::get<Arrangement_2::Vertex_const_handle>(&(result.second)))
      _onVertex_ = true;

    if (strict)
      containment.second = onFace;
    else
      containment.second = onFace || onEdge || onVertex;
  }
}




--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Test-for-General-polygon-with-holes-2-containment-of-a-Point-2-tp4661702p4661711.html
Sent from the cgal-discuss mailing list archive at Nabble.com.

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss






Archive powered by MHonArc 2.6.18.

Top of Page