mirror of https://github.com/CGAL/cgal
Update documents
This commit is contained in:
parent
b1439c5622
commit
8c1f806a24
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 19 KiB |
|
|
@ -123,6 +123,9 @@ if only one (or very little) queries are required, using one of the algorithms t
|
||||||
|
|
||||||
\section simple_polygon_visibility_example Example of Visibility in a Simple Polygon
|
\section simple_polygon_visibility_example Example of Visibility in a Simple Polygon
|
||||||
The following example shows how to obtain the regularized and non-regularized visibility regions.
|
The following example shows how to obtain the regularized and non-regularized visibility regions.
|
||||||
|
\cgalFigureBegin{simple_example, simple_example.png}
|
||||||
|
The visibility region of \f$ q \f$ in a simple polygon: (1) non-regularized visibility; and (2) regularized visibility.
|
||||||
|
\cgalFigureEnd
|
||||||
\cgalExample{Visibility_2/simple_polygon_visibility_2.cpp}
|
\cgalExample{Visibility_2/simple_polygon_visibility_2.cpp}
|
||||||
|
|
||||||
\section general_polygon_example Example of Visibility in a Polygon with Holes
|
\section general_polygon_example Example of Visibility in a Polygon with Holes
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ int main() {
|
||||||
<< " edges." << std::endl;
|
<< " edges." << std::endl;
|
||||||
Arrangement_2::Ccb_halfedge_circulator curr = fh->outer_ccb();
|
Arrangement_2::Ccb_halfedge_circulator curr = fh->outer_ccb();
|
||||||
std::cout << "Traverse the face of the visibility region." << std::endl;
|
std::cout << "Traverse the face of the visibility region." << std::endl;
|
||||||
std::cout << "[" << curr->curve() << "]"<< std::endl;
|
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]"<< std::endl;
|
||||||
while (++curr != fh->outer_ccb())
|
while (++curr != fh->outer_ccb())
|
||||||
std::cout << "[" << curr->curve() << "]" << std::endl;
|
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]"<< std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,35 +31,36 @@ int main() {
|
||||||
Arrangement_2 env;
|
Arrangement_2 env;
|
||||||
CGAL::insert_non_intersecting_curves(env, &s[0], &s[6]);
|
CGAL::insert_non_intersecting_curves(env, &s[0], &s[6]);
|
||||||
//locate the query point in the arrangement
|
//locate the query point in the arrangement
|
||||||
Point_2 query_point(0.5, 2);
|
Point_2 q(0.5, 2);
|
||||||
Arrangement_2::Face_const_handle face;
|
Arrangement_2::Face_const_handle * face;
|
||||||
CGAL::Arr_naive_point_location<Arrangement_2> pl(env);
|
CGAL::Arr_naive_point_location<Arrangement_2> pl(env);
|
||||||
CGAL::Object obj = pl.locate(query_point);
|
typename CGAL::Arr_point_location_result<Arrangement_2>::Type obj = pl.locate(q);
|
||||||
CGAL::assign(face, obj);
|
// The query point locates in the interior of a face
|
||||||
|
face = boost::get<Arrangement_2::Face_const_handle> (&obj);
|
||||||
//visibility query
|
//visibility query
|
||||||
Arrangement_2 non_regular_output;
|
Arrangement_2 non_regular_output;
|
||||||
NSPV non_regular_visibility(env);
|
NSPV non_regular_visibility(env);
|
||||||
Face_handle non_regular_fh = non_regular_visibility.compute_visibility(query_point, face, non_regular_output);
|
Face_handle non_regular_fh = non_regular_visibility.compute_visibility(q, *face, non_regular_output);
|
||||||
std::cout << "Non-regularized visibility region of q has "
|
std::cout << "Non-regularized visibility region of q has "
|
||||||
<< non_regular_output.number_of_edges()
|
<< non_regular_output.number_of_edges()
|
||||||
<< " edges:" << std::endl;
|
<< " edges:" << std::endl;
|
||||||
for (Edge_const_iterator eit = non_regular_output.edges_begin(); eit != non_regular_output.edges_end(); ++eit)
|
for (Edge_const_iterator eit = non_regular_output.edges_begin(); eit != non_regular_output.edges_end(); ++eit)
|
||||||
std::cout << "[" << eit->curve() << "]" << std::endl;
|
std::cout << "[" << eit->source()->point() << " -> " << eit->target()->point() << "]" << std::endl;
|
||||||
Arrangement_2 regular_output;
|
Arrangement_2 regular_output;
|
||||||
RSPV regular_visibility(env);
|
RSPV regular_visibility(env);
|
||||||
Face_handle regular_fh = regular_visibility.compute_visibility(query_point, face, regular_output);
|
Face_handle regular_fh = regular_visibility.compute_visibility(q, *face, regular_output);
|
||||||
Ccb_halfedge_circulator curr = regular_fh->outer_ccb();
|
Ccb_halfedge_circulator curr = regular_fh->outer_ccb();
|
||||||
std::cout << "Regularized visibility region of q has "
|
std::cout << "Regularized visibility region of q has "
|
||||||
<< regular_output.number_of_edges()
|
<< regular_output.number_of_edges()
|
||||||
<< " edges:" << std::endl;
|
<< " edges:" << std::endl;
|
||||||
for (Edge_const_iterator eit = regular_output.edges_begin(); eit != regular_output.edges_end(); ++eit)
|
for (Edge_const_iterator eit = regular_output.edges_begin(); eit != regular_output.edges_end(); ++eit)
|
||||||
std::cout << "[" << eit->curve() << "]" << std::endl;
|
std::cout << "[" << eit->source()->point() << " -> " << eit->target()->point() << "]" << std::endl;
|
||||||
|
|
||||||
//For a regular face, we can also get its whole boundary by traversing its outer CCB.
|
//For a regular face, we can also get its whole boundary by traversing its outer CCB.
|
||||||
std::cout << "Traverse the face of the regularized visibility region:" << std::endl;
|
std::cout << "Traverse the face of the regularized visibility region:" << std::endl;
|
||||||
std::cout << "[" << curr->curve() << "]"<< std::endl;
|
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]" << std::endl;
|
||||||
while (++curr != regular_fh->outer_ccb())
|
while (++curr != regular_fh->outer_ccb())
|
||||||
std::cout << "[" << curr->curve() << "]" << std::endl;
|
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue