Bugfix in Simple_polygon_visibility_2.h

Fixed a bug and added an extra testcase.
This commit is contained in:
Andreas Haas 2015-04-25 21:36:57 +02:00
parent 524c5a21fa
commit c21a2da2a1
5 changed files with 59 additions and 20 deletions

View File

@ -27,6 +27,7 @@
#include <CGAL/enum.h>
#include <CGAL/Visibility_2/visibility_utils.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/assertions.h>
#include <stack>
#include <map>
@ -270,13 +271,32 @@ private:
output(const Point_2& q, VARR& out_arr) const {
std::vector<Point_2> points;
while (!s.empty()) {
points.push_back(s.top());
while(!s.empty()) {
const Point_2& top = s.top();
if (top != q) {
points.push_back(top);
}
else if (query_pt_is_vertex) {
points.push_back(top);
}
s.pop();
}
Visibility_2::report_while_handling_needles<Simple_polygon_visibility_2>(
traits, q, points, out_arr);
// Quick fix for now. Can be done faster.
std::vector<Segment_2> segments;
for(typename std::vector<Point_2>::size_type i = 0;
i < points.size() - 1; ++i)
{
segments.push_back(Segment_2(points[i], points[i+1]));
}
CGAL::insert(out_arr, segments.begin(), segments.end());
// Visibility_2::report_while_handling_needles<Simple_polygon_visibility_2>(
// traits, q, points, out_arr);
CGAL_postcondition(out_arr.number_of_isolated_vertices() == 0);
CGAL_postcondition(s.empty());

View File

@ -0,0 +1,19 @@
0.5 2
0.5 2
0
6
0 4 0 0
0 0 3 2
3 2 4 0
4 0 4 4
4 4 1 2
1 2 0 4
0
5
0 4 0 0
0 0 3 2
3 2 4 2
3 2 1 2
1 2 0 4

View File

@ -44,14 +44,14 @@ int main() {
RSV;
CGAL::test_model_methods<RSV,Arrangement_2>();
std::cout << "Running test suite with " << GREEN << "Cartesian" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<RSV,Arrangement_2>(21, 2);
CGAL::run_tests<RSV,Arrangement_2>(22, 2);
}
{
typedef CGAL::Rotational_sweep_visibility_2<Arrangement_2, CGAL::Tag_true>
RSV;
CGAL::test_model_methods<RSV,Arrangement_2>();
std::cout << "Running test suite with " << GREEN << "Cartesian" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<RSV,Arrangement_2>(21, 2);
CGAL::run_tests<RSV,Arrangement_2>(22, 2);
}
}{
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
@ -62,14 +62,14 @@ int main() {
RSV;
CGAL::test_model_methods<RSV,Arrangement_2>();
std::cout << "Running test suite with " << GREEN << "EPECK" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<RSV,Arrangement_2>(21, 2);
CGAL::run_tests<RSV,Arrangement_2>(22, 2);
}
{
typedef CGAL::Rotational_sweep_visibility_2<Arrangement_2, CGAL::Tag_true>
RSV;
CGAL::test_model_methods<RSV,Arrangement_2>();
std::cout << "Running test suite with " << GREEN << "EPECK" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<RSV,Arrangement_2>(21, 2);
CGAL::run_tests<RSV,Arrangement_2>(22, 2);
}
}
{
@ -82,11 +82,11 @@ int main() {
{
typedef CGAL::Rotational_sweep_visibility_2<ARR,CGAL::Tag_true> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}{
typedef CGAL::Rotational_sweep_visibility_2<ARR,CGAL::Tag_false> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}
}
return 0;

View File

@ -47,7 +47,7 @@ int main() {
std::cout << GREEN << "Done!" << RESET << std::endl;
std::cout << "Running test suite with " << GREEN
<< "Cartesian" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<Simple_polygon_visibility_2,Arrangement_2>(21, 0);
CGAL::run_tests<Simple_polygon_visibility_2,Arrangement_2>(22, 0);
}
{
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
@ -60,7 +60,7 @@ int main() {
std::cout << GREEN << "Done!" << RESET << std::endl;
std::cout << "Running test suite with " << GREEN
<< "EPECK" << RESET << " Kernel..." << std::endl;
CGAL::run_tests<Simple_polygon_visibility_2,Arrangement_2>(21, 0);
CGAL::run_tests<Simple_polygon_visibility_2,Arrangement_2>(22, 0);
}
{
// test Visibility_arrangement_type with extended DCEL
@ -72,11 +72,11 @@ int main() {
{
typedef CGAL::Simple_polygon_visibility_2<ARR,CGAL::Tag_true> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}{
typedef CGAL::Simple_polygon_visibility_2<ARR,CGAL::Tag_false> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}
}

View File

@ -43,13 +43,13 @@ int main() {
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2 , CGAL::Tag_true>
Visibility_2;
CGAL::test_model_methods<Visibility_2,Arrangement_2>();
CGAL::run_tests<Visibility_2,Arrangement_2>(21, 2);
CGAL::run_tests<Visibility_2,Arrangement_2>(22, 2);
}
{
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2 , CGAL::Tag_false>
Visibility_2;
CGAL::test_model_methods<Visibility_2,Arrangement_2>();
CGAL::run_tests<Visibility_2,Arrangement_2>(21, 2);
CGAL::run_tests<Visibility_2,Arrangement_2>(22, 2);
}
}
{
@ -60,12 +60,12 @@ int main() {
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2 , CGAL::Tag_true>
Visibility_2;
CGAL::test_model_methods<Visibility_2,Arrangement_2>();
CGAL::run_tests<Visibility_2,Arrangement_2>(21, 2);
CGAL::run_tests<Visibility_2,Arrangement_2>(22, 2);
}{
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2 , CGAL::Tag_false>
Visibility_2;
CGAL::test_model_methods<Visibility_2,Arrangement_2>();
CGAL::run_tests<Visibility_2,Arrangement_2>(21, 2);
CGAL::run_tests<Visibility_2,Arrangement_2>(22, 2);
}
}
@ -79,11 +79,11 @@ int main() {
{
typedef CGAL::Triangular_expansion_visibility_2<ARR,CGAL::Tag_true> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}{
typedef CGAL::Triangular_expansion_visibility_2<ARR,CGAL::Tag_false> Visibility_2;
CGAL::test_model_methods<Visibility_2,EARR>();
CGAL::run_tests<Visibility_2,EARR>(21, 2);
CGAL::run_tests<Visibility_2,EARR>(22, 2);
}
}