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: KHartmann <>
  • To:
  • Subject: Re: [cgal-discuss] Test for General_polygon_with_holes_2 containment of a Point_2
  • Date: Mon, 21 Mar 2016 12:21:40 -0700 (PDT)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
  • Ironport-phdr: 9a23:P64m8xQCet/J3YjKPm2SouvNOdpsv+yvbD5Q0YIujvd0So/mwa64ZxKN2/xhgRfzUJnB7Loc0qyN4/CmADVLuMzf+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq82VOlwD3WDjKZpJbzyI7izp/vEMhoVjLqtjgjDomVBvP9ps+GVzOFiIlAz97MrjtLRq8iBXpu5zv5UYCfayLOwESulTAz0idmw0/8b2rgLrTA2V53JaXH9FvABPBl3mzBjgQpL4tC2y4ul90TOGOMTwS5g9UjHk6L1kHky7wBwbPiI0pTmEwvd7i7hW9Uqs

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.



Archive powered by MHonArc 2.6.18.

Top of Page