mirror of https://github.com/CGAL/cgal
A bug fix: removed antennas in the convolution cycles, so that the
Arr_labeled_traits_2 are still capable of disregarding pair of contiguous curves when computing intersections. Also removed some debug printings.
This commit is contained in:
parent
99e09ad1f8
commit
68b20f93dd
|
|
@ -169,11 +169,6 @@ public:
|
|||
CGAL_precondition (pgn1.is_simple());
|
||||
CGAL_precondition (pgn2.is_simple());
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
CGAL::Timer _timer;
|
||||
_timer.start();
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Prepare the vector of directions for the first polygon.
|
||||
const unsigned int n1 = pgn1.size();
|
||||
const bool forward1 = (pgn1.orientation() == COUNTERCLOCKWISE);
|
||||
|
|
@ -181,17 +176,6 @@ public:
|
|||
Vertex_circulator curr1, next1;
|
||||
unsigned int k1;
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
Vertex_circulator prev1 = pgn1.vertices_circulator();
|
||||
unsigned int ref1 = 0, ref2 = 0;
|
||||
|
||||
if (forward1)
|
||||
--prev1;
|
||||
else
|
||||
++prev1;
|
||||
#endif // RWRW_STATS
|
||||
|
||||
|
||||
next1 = curr1 = pgn1.vertices_circulator();
|
||||
for (k1 = 0; k1 < n1; k1++)
|
||||
{
|
||||
|
|
@ -200,14 +184,6 @@ public:
|
|||
else
|
||||
--next1;
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
if (f_orientation (*prev1, *curr1, *next1) == RIGHT_TURN)
|
||||
{
|
||||
ref1++;
|
||||
}
|
||||
prev1 = curr1;
|
||||
#endif // RWRW_STATS
|
||||
|
||||
dirs1[k1] = f_direction (f_vector (*curr1, *next1));
|
||||
curr1 = next1;
|
||||
}
|
||||
|
|
@ -254,12 +230,6 @@ public:
|
|||
curr2 = next2;
|
||||
}
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
ref2 = reflex_vertices.size();
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Add the bottom-left vertex of the second polygon to the reflex vertices.
|
||||
typename std::list<Vertex_ref>::iterator reflex_it;
|
||||
|
||||
|
|
@ -348,32 +318,12 @@ public:
|
|||
}
|
||||
}
|
||||
cycles++;
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
std::cout << "Cycle no. " << cycles
|
||||
<< " containing " << conv_segments.size()
|
||||
<< " segments (in " << loops << " loops)." << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
}
|
||||
|
||||
curr1 = next1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
std::cout << "|P| = " << n1 << " (" << ref1
|
||||
<< ") |Q| = " << n2 << " (" << ref2 << ")" << std::endl;
|
||||
_timer.stop();
|
||||
std::cout << cycles << " cycles, "
|
||||
<< conv_segments.size() << " segments" << std::endl;
|
||||
std::cout << "Computing the convolution took "
|
||||
<< _timer.time() << " seconds. " << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Compute the union of the cycles that represent the Minkowski sum.
|
||||
Union_2 unite;
|
||||
|
||||
|
|
@ -639,9 +589,63 @@ private:
|
|||
reduced_cycle = true;
|
||||
}
|
||||
|
||||
// Eliminate "antenna"s that occur in the cycle.
|
||||
typename std::list<Labeled_segment_2>::iterator next, after_next;
|
||||
bool found_antenna;
|
||||
|
||||
next = curr = cycle.begin();
|
||||
++next;
|
||||
|
||||
while (curr != cycle.end())
|
||||
{
|
||||
// If the current segment is the last one in the cycle, its next segment
|
||||
// (in cyclic order) is the first one.
|
||||
if (next == cycle.end())
|
||||
{
|
||||
found_antenna = f_equal (curr->source(), cycle.begin()->target());
|
||||
if (found_antenna)
|
||||
{
|
||||
next = cycle.begin();
|
||||
after_next = cycle.end();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
found_antenna = f_equal (curr->source(), next->target());
|
||||
if (found_antenna)
|
||||
{
|
||||
after_next = next;
|
||||
++after_next;
|
||||
}
|
||||
}
|
||||
|
||||
// We know that curr's target and next's source is the same point.
|
||||
// If they also share their other endpoint, then these two segments
|
||||
// form an antenna and should threrefore be removed from the cycle.
|
||||
if (found_antenna)
|
||||
{
|
||||
cycle.erase (curr);
|
||||
cycle.erase (next);
|
||||
curr = after_next;
|
||||
|
||||
if (after_next != cycle.end())
|
||||
{
|
||||
next = curr;
|
||||
++next;
|
||||
}
|
||||
|
||||
reduced_cycle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr = next;
|
||||
++next;
|
||||
}
|
||||
}
|
||||
|
||||
// In case we have reduced the cycle, re-number the segments in it.
|
||||
if (reduced_cycle)
|
||||
{
|
||||
// In case we have reduced the cycle, re-number the segments in it.
|
||||
seg_index = 0;
|
||||
for (curr = cycle.begin(); curr != cycle.end(); ++curr, ++seg_index)
|
||||
cycle.back().label().set_index (seg_index);
|
||||
|
|
|
|||
|
|
@ -124,11 +124,6 @@ public:
|
|||
CGAL_precondition (pgn1.is_simple());
|
||||
CGAL_precondition (pgn2.is_simple());
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
CGAL::Timer _timer;
|
||||
_timer.start();
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Decompose both input polygons to convex sub-polygons.
|
||||
Decomposition_strategy decomp_strat;
|
||||
Polygons_list sub_pgns1;
|
||||
|
|
@ -157,17 +152,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
_timer.stop();
|
||||
std::cout << sub_pgns1.size()*sub_pgns2.size() << " polygons ("
|
||||
<< sub_pgns1.size() << " * " << sub_pgns2.size()
|
||||
<< "), " << boundary_segments.size() << " segments" << std::endl;
|
||||
std::cout << "Computing the decomposition took "
|
||||
<< _timer.time() << " seconds. " << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Compute the union of the polygons that represent the Minkowski sums
|
||||
// of all sub-polygon pairs.
|
||||
Union_2 unite;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
#include <CGAL/Minkowski_sum_2/Union_of_curve_cycles_2.h>
|
||||
#include <list>
|
||||
|
||||
// RWRW:
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
/*! \class
|
||||
|
|
@ -86,11 +83,6 @@ public:
|
|||
{
|
||||
CGAL_precondition (pgn.is_simple());
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
CGAL::Timer _timer;
|
||||
_timer.start();
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Compute the curves that form the single convolution cycle for the
|
||||
// given polygon.
|
||||
Curves_list cycle;
|
||||
|
|
@ -99,17 +91,6 @@ public:
|
|||
1, // The ID of the single cycle.
|
||||
std::back_inserter (cycle));
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
_timer.stop();
|
||||
std::cout << "|P| = " << pgn.size() << std::endl;
|
||||
std::cout << "1 cycle, "
|
||||
<< cycle.size() << " arcs" << std::endl;
|
||||
std::cout << "Computing the convolution took "
|
||||
<< _timer.time() << " seconds. " << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Compute the union of the cycles that represent the offset polygon.
|
||||
Union_2 unite;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
#include <CGAL/Minkowski_sum_2/Union_of_curve_cycles_2.h>
|
||||
#include <list>
|
||||
|
||||
// RWRW:
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
/*! \class
|
||||
|
|
@ -91,11 +88,6 @@ public:
|
|||
{
|
||||
CGAL_precondition (pgn.is_simple());
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
CGAL::Timer _timer;
|
||||
_timer.start();
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Decompose the input polygon into convex sub-polygons.
|
||||
Decomposition_strategy decomp_strat;
|
||||
Polygons_list sub_pgns;
|
||||
|
|
@ -115,16 +107,6 @@ public:
|
|||
pgn_id++;
|
||||
}
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
_timer.stop();
|
||||
std::cout << sub_pgns.size() << " polygons, "
|
||||
<< boundary_curves.size() << " curves." << std::endl;
|
||||
std::cout << "Computing the decomposition took "
|
||||
<< _timer.time() << " seconds. " << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Compute the union of the cycles that represent the offset polygon.
|
||||
Union_2 unite;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,34 +87,6 @@ protected:
|
|||
// Construct the arrangement of the curves.
|
||||
insert_x_monotone_curves (arr, begin, end);
|
||||
|
||||
#ifdef RWRW_STATS
|
||||
|
||||
std::cout << "Arrangement size: "
|
||||
<< " V = " << arr.number_of_vertices()
|
||||
<< " E = " << arr.number_of_edges()
|
||||
<< " F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
unsigned int sum_deg = 0;
|
||||
unsigned int sum_ovl = 0;
|
||||
Vertex_iterator _vit;
|
||||
Edge_iterator _eit;
|
||||
|
||||
for (_vit = arr.vertices_begin(); _vit != arr.vertices_end(); ++_vit)
|
||||
sum_deg += _vit->degree();
|
||||
|
||||
for (_eit = arr.edges_begin(); _eit != arr.edges_end(); ++_eit)
|
||||
sum_ovl += (_eit->curve().label().right_count() +
|
||||
_eit->curve().label().left_count());
|
||||
|
||||
std::cout << "> Average vertex degree: "
|
||||
<< static_cast<double>(sum_deg) /
|
||||
static_cast<double>(arr.number_of_vertices()) << std::endl;
|
||||
std::cout << "> Average edge overlaps: "
|
||||
<< static_cast<double>(sum_ovl) /
|
||||
static_cast<double>(arr.number_of_edges()) << std::endl;
|
||||
|
||||
#endif // RWRW_STATS
|
||||
|
||||
// Go over all faces and mark them as unvisited, by setting their inside
|
||||
// count to (-1).
|
||||
Face_iterator fit;
|
||||
|
|
@ -177,19 +149,18 @@ protected:
|
|||
{
|
||||
he = circ;
|
||||
f_next = he->twin()->face();
|
||||
|
||||
|
||||
if (f_next->data() == UNVISITED)
|
||||
{
|
||||
next_count = curr_count + _boundary_count (he->twin());
|
||||
f_next->set_data (next_count);
|
||||
queue.push_back (f_next);
|
||||
}
|
||||
else
|
||||
else if (f_curr != f_next)
|
||||
{
|
||||
CGAL_assertion (f_next->data() ==
|
||||
curr_count + _boundary_count (he->twin()));
|
||||
}
|
||||
|
||||
++circ;
|
||||
|
||||
} while (circ != first);
|
||||
|
|
|
|||
Loading…
Reference in New Issue