mirror of https://github.com/CGAL/cgal
Cleanup; plus avoid some path copy.
This commit is contained in:
parent
359b3e2d69
commit
0a7c9bc6d9
|
|
@ -36,7 +36,9 @@ namespace CGAL {
|
|||
template<typename Map_>
|
||||
class Path_on_surface;
|
||||
|
||||
// In this version, each flat (even those with length 0) have begin and end darts
|
||||
// A flat is a sequence of darts given by its two extremities: begin and end,
|
||||
// with +2 turns (if length>0) or -2 turns (if length<0).
|
||||
// length==0 => begin==end.
|
||||
template<typename Map_>
|
||||
class CFlat
|
||||
{
|
||||
|
|
@ -92,7 +94,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
typedef boost::unordered_set<List_iterator, List_iterator_hash> Set_of_it;
|
||||
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
|
|
@ -144,7 +145,7 @@ public:
|
|||
|
||||
std::size_t i=0, j=0, starti=0, length=0;
|
||||
bool positive_flat=false;
|
||||
bool negative_flat=false;
|
||||
bool negative_flat=false;
|
||||
|
||||
if (apath.is_closed())
|
||||
{
|
||||
|
|
@ -177,36 +178,8 @@ public:
|
|||
do
|
||||
{
|
||||
// Here dart i is the beginning of a flat part (maybe of length 0)
|
||||
positive_flat=false; negative_flat=false;
|
||||
if (apath.next_index_exists(i))
|
||||
{
|
||||
if (!use_only_negative && apath.next_positive_turn(i)==2)
|
||||
{ positive_flat=true; }
|
||||
else if (!use_only_positive && apath.next_negative_turn(i)==2)
|
||||
{ negative_flat=true; }
|
||||
}
|
||||
|
||||
if (!positive_flat && !negative_flat)
|
||||
{
|
||||
m_path.push_back(Flat(apath[i]));
|
||||
push_back(apath[i]);
|
||||
i=apath.next_index(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
j=i;
|
||||
length=0;
|
||||
while (apath.next_index_exists(j) &&
|
||||
((positive_flat && apath.next_positive_turn(j)==2) ||
|
||||
(negative_flat && apath.next_negative_turn(j)==2)))
|
||||
{
|
||||
j=apath.next_index(j);
|
||||
++length;
|
||||
}
|
||||
CGAL_assertion(length>0);
|
||||
m_path.push_back(Flat(apath[i], apath[j],
|
||||
(positive_flat?length:-length)));
|
||||
i=apath.next_index(j);
|
||||
}
|
||||
}
|
||||
while(i<apath.length() && i!=starti);
|
||||
CGAL_assertion(is_valid());
|
||||
|
|
@ -318,6 +291,7 @@ public:
|
|||
/// @return true if the given flat is valid
|
||||
bool is_flat_valid(const List_iterator& flat) const
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(flat));
|
||||
Dart_const_handle dhend=flat->begin;
|
||||
int nb=0;
|
||||
while(nb!=flat->length)
|
||||
|
|
@ -331,8 +305,10 @@ public:
|
|||
return dhend==flat->end;
|
||||
}
|
||||
|
||||
/// Display the given flat
|
||||
void display_flat(std::ostream& os, const List_iterator& flat)
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(flat));
|
||||
os<<"["<<m_map.darts().index(flat->begin)<<", "
|
||||
<<m_map.darts().index(flat->end)<<" (l="<<flat->length<<")]";
|
||||
}
|
||||
|
|
@ -373,8 +349,8 @@ public:
|
|||
/* std::cout<<"************* ERROR ************"<<std::endl;
|
||||
display();
|
||||
Path_on_surface<Map>(*this).display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
display_pos_and_neg_turns(); std::cout<<std::endl; */
|
||||
std::cout<<"FLAT ERROR "<<*it<<std::endl;
|
||||
display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
std::cout<<"FLAT ERROR "<<*it<<std::endl; */
|
||||
|
||||
std::cout<<"ERROR: The path is not valid: flat at position "<<i
|
||||
<<" with length "<<flat_length(it)<<" is not correct: it can be merged "
|
||||
|
|
@ -409,7 +385,7 @@ public:
|
|||
}
|
||||
|
||||
/// For debugging purpose, test if 'it' is a valid iterator.
|
||||
bool is_valid_iterator(const List_iterator& ittotest)
|
||||
bool is_valid_iterator(const List_iterator& ittotest) const
|
||||
{
|
||||
if (ittotest==m_path.end()) { return false; }
|
||||
return true;
|
||||
|
|
@ -421,31 +397,58 @@ public:
|
|||
return false; */
|
||||
}
|
||||
|
||||
/// @return the first dart of the path
|
||||
/// @pre !is_empty()
|
||||
Dart_const_handle front()
|
||||
{
|
||||
CGAL_assertion(!is_empty());
|
||||
return begin_of_flat(m_path.begin());
|
||||
}
|
||||
|
||||
/// @return the last dart of the path
|
||||
/// @pre !is_empty()
|
||||
Dart_const_handle back()
|
||||
{
|
||||
CGAL_assertion(!is_empty());
|
||||
return end_of_flat(std::prev(m_path.end()));
|
||||
}
|
||||
|
||||
/* TODO REMOVE OR DO A CORRECT METHOD
|
||||
void push_back(Dart_const_handle dh, bool update_isclosed=true)
|
||||
/// @return true iff df can be added at the end of the path.
|
||||
bool can_be_pushed(Dart_const_handle dh)
|
||||
{
|
||||
CGAL_assertion(dh!=NULL && dh!=m_map.null_dart_handle);
|
||||
// This assert is too long...
|
||||
// CGAL_assertion((is_empty() ||
|
||||
// CGAL::template belong_to_same_cell<Map, 0>
|
||||
// (m_map, m_map.other_extremity(back()), dh)));
|
||||
// This assert is too long CGAL_assertion(m_map.darts().owns(dh));
|
||||
|
||||
m_path.push_back(dh);
|
||||
if (is_empty()) return true;
|
||||
|
||||
return CGAL::template belong_to_same_cell<Map, 0>
|
||||
(m_map, m_map.other_extremity(back()), dh);
|
||||
}
|
||||
|
||||
/// Add the given dart at the end of this path.
|
||||
/// @pre can_be_pushed(dh)
|
||||
void push_back(Dart_const_handle dh, bool update_isclosed=true)
|
||||
{
|
||||
CGAL_assertion(dh!=Map::null_handle);
|
||||
// This assert is too long, it is tested in the is_valid method.
|
||||
CGAL_assertion(can_be_pushed(dh));
|
||||
|
||||
List_iterator itlast=m_path.end();
|
||||
|
||||
bool positive_flat, negative_flat;
|
||||
if (is_empty() ||
|
||||
!is_prev_flat_can_be_extended_at_end(itlast, dh,
|
||||
positive_flat, negative_flat))
|
||||
{ m_path.push_back(Flat(dh)); } // Create a new flat
|
||||
else
|
||||
{
|
||||
--itlast;
|
||||
set_end_of_flat(itlast, dh); // Move the last dart of the last flat
|
||||
set_flat_length(itlast, flat_length(itlast)+(positive_flat?+1:-1)); // Increment the length of the flat
|
||||
}
|
||||
|
||||
++m_length;
|
||||
if (update_isclosed) { update_is_closed(); }
|
||||
}
|
||||
*/
|
||||
|
||||
// Update m_is_closed to true iff the path is closed (i.e. the second
|
||||
// extremity of the last dart of the path is the same vertex than the one
|
||||
|
|
@ -816,27 +819,6 @@ public:
|
|||
return m_path.begin();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* WRONG ASSERT
|
||||
* TODO either compute the real minimum ? or ?
|
||||
* {
|
||||
// The sequence of modified flats should be consecutive
|
||||
List_iterator it=smallest_it;
|
||||
unsigned int nb=modified_flats.size();
|
||||
while(nb>0)
|
||||
{
|
||||
if (modified_flats.count(it)==1) { --nb; }
|
||||
else if (next_flat_exist(it) && modified_flats.count(next_iterator(it))==0)
|
||||
{
|
||||
std::cerr<<"ERROR in merge_modified_flats_when_possible: modified flats"
|
||||
<<" are not consecutives."<<std::endl;
|
||||
CGAL_assertion(false);
|
||||
}
|
||||
advance_iterator(it);
|
||||
}
|
||||
} */
|
||||
#endif // NDEBUG
|
||||
|
||||
for (auto it=modified_flats.begin(); it!=modified_flats.end(); ++it)
|
||||
{
|
||||
itcur=*it;
|
||||
|
|
@ -846,10 +828,6 @@ public:
|
|||
|
||||
// Note that smallest is not necessarily the smallest, this is a flat
|
||||
// such that the previous flat is not modified.
|
||||
/* if (!is_valid_iterator(smallest_it))
|
||||
{
|
||||
std::cout<<"PROBLEM merge_modified_flats_when_possible"<<std::endl;
|
||||
} */
|
||||
return smallest_it;
|
||||
}
|
||||
|
||||
|
|
@ -1009,6 +987,22 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Merge flat 'it' with its next flat if it is possible.
|
||||
/// @return true if a merging was done.
|
||||
bool merge_with_next_flat_if_possible(const List_iterator& it)
|
||||
{
|
||||
Set_of_it dummy;
|
||||
return merge_with_next_flat_if_possible(it, dummy);
|
||||
}
|
||||
|
||||
/// Merge the last flat of this path with its next flat if it is possible.
|
||||
/// @return true if a merging was done.
|
||||
bool merge_last_flat_with_next_if_possible()
|
||||
{
|
||||
List_iterator lastit=m_path.end(); --lastit;
|
||||
return merge_with_next_flat_if_possible(lastit);
|
||||
}
|
||||
|
||||
/// Return true if it is the beginning of a spur.
|
||||
bool is_spur(const List_iterator& it)
|
||||
{
|
||||
|
|
@ -1059,13 +1053,12 @@ public:
|
|||
<<*it<<std::endl<<*it2<<std::endl<<*next_iterator(it2)<<std::endl;*/
|
||||
|
||||
it=merge_modified_flats_when_possible(modified_flats);
|
||||
//CGAL_assertion(is_valid_iterator(it));
|
||||
// TODO REMOVE ?? OR DO THAT IF m_path.size()==1 ?? else { it=m_path.begin(); }
|
||||
|
||||
// CGAL_assertion(is_valid_iterator(it));
|
||||
// CGAL_assertion(is_valid());
|
||||
}
|
||||
|
||||
/// Move it to the next spur after it. Go to m_path.end() if there is no
|
||||
/// Move 'it' to the next spur after it. Go to m_path.end() if there is no
|
||||
/// spur in the path.
|
||||
void move_to_next_spur(List_iterator& it)
|
||||
{
|
||||
|
|
@ -1095,9 +1088,8 @@ public:
|
|||
// CGAL_assertion(is_valid_iterator(it));
|
||||
// CGAL_assertion(is_valid());
|
||||
if (!all) { return true; }
|
||||
// it=m_path.begin();
|
||||
}
|
||||
else { move_to_next_spur(it); } // ++it; }
|
||||
else { move_to_next_spur(it); }
|
||||
}
|
||||
CGAL_assertion(is_valid());
|
||||
return res;
|
||||
|
|
@ -1109,7 +1101,8 @@ public:
|
|||
List_iterator& itend)
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(it));
|
||||
if (m_use_only_negative || !next_flat_exist(it) || next_positive_turn(it)!=1)
|
||||
if (m_use_only_negative || !next_flat_exist(it) ||
|
||||
next_positive_turn(it)!=1)
|
||||
{ return false; }
|
||||
// Here first positive turn is 1
|
||||
|
||||
|
|
@ -1132,7 +1125,8 @@ public:
|
|||
List_iterator& itend)
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(it));
|
||||
if (m_use_only_positive || !next_flat_exist(it) || next_negative_turn(it)!=1)
|
||||
if (m_use_only_positive || !next_flat_exist(it) ||
|
||||
next_negative_turn(it)!=1)
|
||||
{ return false; }
|
||||
// Here first negative turn is 1
|
||||
|
||||
|
|
@ -1149,8 +1143,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Move 'it' to the next bracket after 'it'. Go to m_path.end() if there is no
|
||||
/// bracket in the path.
|
||||
/// Move 'it' to the next bracket after 'it'. Go to m_path.end() if there
|
||||
/// is no bracket in the path.
|
||||
void move_to_next_bracket(List_iterator& it)
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(it));
|
||||
|
|
@ -1186,8 +1180,8 @@ public:
|
|||
{ // Case of cyclic bracket
|
||||
CGAL_assertion(size_of_list()==1);
|
||||
CGAL_assertion(flat_length(it1)<0);
|
||||
set_begin_of_flat(it1, m_map.template beta<2,0,2,1>(begin_of_flat(it1))); // TODO CHECK
|
||||
set_end_of_flat(it1, m_map.template beta<2,1,2,0>(end_of_flat(it1))); // TODO CHECK
|
||||
set_begin_of_flat(it1, m_map.template beta<2,0,2,1>(begin_of_flat(it1)));
|
||||
set_end_of_flat(it1, m_map.template beta<2,1,2,0>(end_of_flat(it1)));
|
||||
set_flat_length(it1, (-flat_length(it1))-2);
|
||||
flat_modified(it1, modified_flats);
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
|
|
@ -1211,12 +1205,6 @@ public:
|
|||
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
|
||||
/* if (!is_valid())
|
||||
{
|
||||
std::cout<<*next_iterator(it1)<<std::endl
|
||||
<<*it1<<std::endl
|
||||
<<*prev_iterator(it1)<<std::endl;
|
||||
} */
|
||||
// CGAL_assertion(is_valid());
|
||||
}
|
||||
|
||||
|
|
@ -1240,12 +1228,13 @@ public:
|
|||
{ // Case of cyclic bracket
|
||||
CGAL_assertion(size_of_list()==1);
|
||||
CGAL_assertion(flat_length(it1)>0);
|
||||
set_begin_of_flat(it1, m_map.template beta<1,2,0,2>(begin_of_flat(it1))); // TODO CHECK
|
||||
set_end_of_flat(it1, m_map.template beta<0,2,1,2>(end_of_flat(it1))); // TODO CHECK
|
||||
set_begin_of_flat(it1, m_map.template beta<1,2,0,2>(begin_of_flat(it1)));
|
||||
set_end_of_flat(it1, m_map.template beta<0,2,1,2>(end_of_flat(it1)));
|
||||
set_flat_length(it1, -(flat_length(it1)-2));
|
||||
m_length-=2;
|
||||
flat_modified(it1, modified_flats);
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
CGAL_assertion(m_length>1);
|
||||
m_length-=2;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1264,14 +1253,6 @@ public:
|
|||
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
|
||||
// if (is_beginning_of_non_null_flat(it1)) { advance_iterator(it1); }
|
||||
/* if (!is_valid())
|
||||
{
|
||||
std::cout<<*next_iterator(it1)<<std::endl
|
||||
<<*it1<<std::endl
|
||||
<<*prev_iterator(it1)<<std::endl;
|
||||
} */
|
||||
|
||||
// CGAL_assertion(is_valid());
|
||||
}
|
||||
|
||||
|
|
@ -1300,7 +1281,7 @@ public:
|
|||
// CGAL_assertion(is_valid());
|
||||
}
|
||||
else { move_to_next_bracket(it1); }
|
||||
if (!all && res) { return true; }
|
||||
if (!all && res) { return true; }
|
||||
}
|
||||
// CGAL_assertion(is_valid());
|
||||
return res;
|
||||
|
|
@ -1339,8 +1320,6 @@ public:
|
|||
bool& positive_flat,
|
||||
bool& negative_flat)
|
||||
{
|
||||
CGAL_assertion(is_valid_iterator(it));
|
||||
|
||||
positive_flat=false; negative_flat=false;
|
||||
if (!prev_flat_exist(it)) { return false; }
|
||||
List_iterator ittemp=prev_iterator(it);
|
||||
|
|
@ -1356,6 +1335,8 @@ public:
|
|||
(flat_length(ittemp)<0 && negative_flat);
|
||||
}
|
||||
|
||||
/// @return true iff the flat before flat 'it' can be extended by adding
|
||||
/// dart 'dh' to its end.
|
||||
bool is_prev_flat_can_be_extended_at_end(const List_iterator& it,
|
||||
Dart_const_handle dh)
|
||||
{
|
||||
|
|
@ -1387,6 +1368,8 @@ public:
|
|||
(flat_length(ittemp)<0 && negative_flat);
|
||||
}
|
||||
|
||||
/// @return true iff the flat after flat 'it' can be extended by adding
|
||||
/// dart 'dh' to its beginning.
|
||||
bool is_next_flat_can_be_extended_at_beginning(const List_iterator& it,
|
||||
Dart_const_handle dh)
|
||||
{
|
||||
|
|
@ -1547,12 +1530,7 @@ public:
|
|||
if (first_flat_zero)
|
||||
{
|
||||
if (second_flat_zero)
|
||||
{
|
||||
/* display();
|
||||
Path_on_surface<Map>(*this).display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
std::cout<<"############################"<<std::endl; */
|
||||
// Special case of a l-shape with only 2 darts
|
||||
{ // Special case of a l-shape with only 2 darts
|
||||
set_begin_of_flat(it1, dh1);
|
||||
set_end_of_flat(it1, dh1);
|
||||
set_begin_of_flat(it2, dh6);
|
||||
|
|
@ -1563,13 +1541,6 @@ public:
|
|||
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
|
||||
/* if (!is_valid())
|
||||
{
|
||||
std::cout<<*next_iterator(it1)<<std::endl
|
||||
<<*it1<<std::endl
|
||||
<<*prev_iterator(it1)<<std::endl;
|
||||
} */
|
||||
|
||||
// CGAL_assertion(is_valid());
|
||||
return;
|
||||
}
|
||||
|
|
@ -1582,9 +1553,6 @@ public:
|
|||
set_flat_length(it1, -flat_length(it2));
|
||||
set_flat_length(it2, 0);
|
||||
|
||||
// CGAL_assertion(is_flat_valid(it1));
|
||||
// CGAL_assertion(is_flat_valid(it2));
|
||||
|
||||
flat_modified(it1, modified_flats);
|
||||
flat_modified(it2, modified_flats);
|
||||
|
||||
|
|
@ -1601,29 +1569,10 @@ public:
|
|||
set_begin_of_flat(it1, dh1);
|
||||
set_end_of_flat(it1, dh1);
|
||||
set_begin_of_flat(it2, dh2);
|
||||
// set_end_of_flat(it2, dh6); // TODO WHY THIS DOES NOT WORK ????
|
||||
set_end_of_flat(it2, m_map.template beta<1, 2, 1>(dh3));
|
||||
set_end_of_flat(it2, dh6); // TODO WHY THIS DOES NOT WORK ????
|
||||
//set_end_of_flat(it2, m_map.template beta<1, 2, 1>(dh3)); // TODO VERY STRANGE
|
||||
set_flat_length(it2, -flat_length(it1));
|
||||
set_flat_length(it1, 0);
|
||||
/*
|
||||
{ // TEMPO DEBUG
|
||||
unsigned int NBTOTO=0;
|
||||
Dart_const_handle dhtoto=dh2;
|
||||
while (dhtoto!=dh3)
|
||||
{
|
||||
dhtoto=m_map.template beta<1, 2, 1>(dhtoto);
|
||||
++NBTOTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Dart_const_handle dhtoto2=m_map.template beta<1, 2, 1>(dh3);
|
||||
Dart_const_handle dhtoto4=m_map.template beta<1, 2, 1>(dh5);
|
||||
|
||||
CGAL_assertion((m_map.template beta<1, 2, 1>(dh3)==dh6));*/
|
||||
|
||||
// CGAL_assertion(is_flat_valid(it1));
|
||||
// CGAL_assertion(is_flat_valid(it2));
|
||||
|
||||
flat_modified(it1, modified_flats);
|
||||
flat_modified(it2, modified_flats);
|
||||
|
|
@ -1660,56 +1609,28 @@ public:
|
|||
m_length+=2;
|
||||
flat_modified(it1, modified_flats);
|
||||
flat_modified(it2, modified_flats);
|
||||
|
||||
}
|
||||
|
||||
// 3) Move the first flat
|
||||
/* if (first_flat_zero)
|
||||
{
|
||||
m_path.erase(it1);
|
||||
it1=prev_iterator(it3);
|
||||
}
|
||||
else */
|
||||
{
|
||||
CGAL_assertion(flat_length(it1)<0);
|
||||
set_begin_of_flat(it1, dh2);
|
||||
set_flat_length(it1, -(flat_length(it1))-1);
|
||||
if (flat_length(it1)==0) { set_end_of_flat(it1, dh2); }
|
||||
else { set_end_of_flat(it1, dh3); } // End of the moved flat
|
||||
flat_modified(it1, modified_flats);
|
||||
|
||||
// merge_with_next_flat_if_possible(prev_iterator(it1));
|
||||
}
|
||||
CGAL_assertion(flat_length(it1)<0);
|
||||
set_begin_of_flat(it1, dh2);
|
||||
set_flat_length(it1, -(flat_length(it1))-1);
|
||||
if (flat_length(it1)==0) { set_end_of_flat(it1, dh2); }
|
||||
else { set_end_of_flat(it1, dh3); } // End of the moved flat
|
||||
flat_modified(it1, modified_flats);
|
||||
|
||||
// 4) Move the second flat
|
||||
/* if (second_flat_zero)
|
||||
{
|
||||
CGAL_assertion(it3!=it1);
|
||||
m_path.erase(it3);
|
||||
}
|
||||
else */
|
||||
{
|
||||
CGAL_assertion(flat_length(it2)<0);
|
||||
set_begin_of_flat(it2, dh4);
|
||||
set_flat_length(it2, -(flat_length(it2))-1);
|
||||
if (flat_length(it2)==0) { set_end_of_flat(it2, dh4); }
|
||||
else { set_end_of_flat(it2, dh5); } // End of the moved flat
|
||||
flat_modified(it2, modified_flats);
|
||||
|
||||
// merge_with_next_flat_if_possible(prev_iterator(it3));
|
||||
}
|
||||
CGAL_assertion(flat_length(it2)<0);
|
||||
set_begin_of_flat(it2, dh4);
|
||||
set_flat_length(it2, -(flat_length(it2))-1);
|
||||
if (flat_length(it2)==0) { set_end_of_flat(it2, dh4); }
|
||||
else { set_end_of_flat(it2, dh5); } // End of the moved flat
|
||||
flat_modified(it2, modified_flats);
|
||||
|
||||
CGAL_assertion(m_length>1);
|
||||
m_length-=2;
|
||||
|
||||
it1=merge_modified_flats_when_possible(modified_flats);
|
||||
|
||||
// CGAL_assertion(is_valid());
|
||||
/*it2=next_flat(it1);
|
||||
if (merge_with_next_flat_if_possible(prev_iterator(it1)))
|
||||
{ it1=prev_iterator(it2); }
|
||||
merge_with_next_flat_if_possible(it1); */
|
||||
|
||||
/*if (it==m_path.end() && !is_empty())
|
||||
{ it=m_path.begin(); } */
|
||||
}
|
||||
|
||||
/// Right push the path, if all all l-shape are pushed, otherwise only one.
|
||||
|
|
@ -1726,9 +1647,8 @@ public:
|
|||
// CGAL_assertion(is_valid_iterator(it));
|
||||
// CGAL_assertion(is_valid());
|
||||
if (!all) { return true; }
|
||||
// it=m_path.begin();
|
||||
}
|
||||
else { move_to_next_l_shape(it); } // ++it; }
|
||||
else { move_to_next_l_shape(it); }
|
||||
}
|
||||
CGAL_assertion(is_valid());
|
||||
return res;
|
||||
|
|
@ -1739,34 +1659,24 @@ public:
|
|||
{
|
||||
CGAL_assertion(is_valid());
|
||||
|
||||
// ?? if (!is_closed()) { return; }
|
||||
if (is_empty()) { return; }
|
||||
|
||||
CGAL_assertion(is_closed());
|
||||
|
||||
bool modified=false;
|
||||
remove_spurs();
|
||||
|
||||
//do
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
modified=remove_brackets();
|
||||
modified=modified || remove_spurs();
|
||||
}
|
||||
while(modified);
|
||||
|
||||
// std::cout<<"path="<<Path_on_surface<Map>(*this)<<std::endl;
|
||||
// Path_on_surface<Map>(*this).display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
|
||||
modified=right_push();
|
||||
modified=remove_brackets();
|
||||
modified=modified || remove_spurs();
|
||||
}
|
||||
//while(modified);
|
||||
while(modified);
|
||||
|
||||
// std::cout<<"path="<<Path_on_surface<Map>(*this)<<std::endl;
|
||||
// Path_on_surface<Map>(*this).display_pos_and_neg_turns(); std::cout<<std::endl;
|
||||
right_push();
|
||||
|
||||
CGAL_assertion(remove_brackets()==false);
|
||||
CGAL_assertion(remove_spurs()==false);
|
||||
|
||||
// right_push(); // Not needed
|
||||
CGAL_assertion(is_valid());
|
||||
}
|
||||
|
||||
|
|
@ -1808,7 +1718,7 @@ public:
|
|||
<<"("<<flat_length(it)<<") ] ";
|
||||
}
|
||||
if (is_closed())
|
||||
{ std::cout<<" c "; } //<<m_map.darts().index(get_ith_dart(0)); }
|
||||
{ std::cout<<" c "; }
|
||||
std::cout<<" length("<<length()<<")";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,10 @@ namespace CGAL {
|
|||
CMap_for_surface_mesh_curve_topology;
|
||||
|
||||
public:
|
||||
typedef typename CMap_for_surface_mesh_curve_topology::Dart_handle Dart_handle;
|
||||
typedef typename CMap_for_surface_mesh_curve_topology::Dart_const_handle Dart_const_handle;
|
||||
typedef typename CMap_for_surface_mesh_curve_topology::Dart_handle
|
||||
Dart_handle;
|
||||
typedef typename CMap_for_surface_mesh_curve_topology::Dart_const_handle
|
||||
Dart_const_handle;
|
||||
typedef CGAL::Union_find<Dart_handle> UFTree;
|
||||
typedef typename UFTree::handle UFTree_handle;
|
||||
|
||||
|
|
@ -97,13 +99,15 @@ namespace CGAL {
|
|||
{ t.start(); t2.start(); }
|
||||
|
||||
// The mapping between darts of the original map into the copied map.
|
||||
boost::unordered_map<typename Map::Dart_const_handle, Dart_handle> origin_to_copy;
|
||||
boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>
|
||||
origin_to_copy;
|
||||
|
||||
// We copy the original map, while keeping a mapping between darts.
|
||||
m_map.copy(m_original_map, &origin_to_copy);
|
||||
|
||||
// The mapping between darts of the copy into darts of the original map.
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle> copy_to_origin;
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>
|
||||
copy_to_origin;
|
||||
for (auto it=origin_to_copy.begin(); it!=origin_to_copy.end(); ++it)
|
||||
{ copy_to_origin[it->second]=it->first; }
|
||||
|
||||
|
|
@ -289,93 +293,44 @@ namespace CGAL {
|
|||
m_original_map.free_mark(m_mark_L);
|
||||
}
|
||||
|
||||
const CMap_for_surface_mesh_curve_topology& get_map() const
|
||||
{ return m_map; }
|
||||
|
||||
/// Canonize the path
|
||||
/* void canonize(Path_on_surface<Map>& path, bool display_time=false) const
|
||||
{
|
||||
if (!path.is_closed())
|
||||
{
|
||||
std::cerr<<"Error: a non closed path cannot be canonized."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
CGAL::Timer t;
|
||||
if (display_time)
|
||||
{ t.start(); }
|
||||
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology> path2(path);
|
||||
path2.canonize();
|
||||
path=path2;
|
||||
|
||||
if (display_time)
|
||||
{
|
||||
t.stop();
|
||||
std::cout<<"[TIME] Canonize path: "<<t.time()<<" seconds"<<std::endl;
|
||||
}
|
||||
|
||||
CGAL_assertion(path.is_valid());
|
||||
} */
|
||||
|
||||
void count_edges_of_path_on_torus(const Path_on_surface<CMap_for_surface_mesh_curve_topology>& path,
|
||||
std::size_t& a,
|
||||
std::size_t& b)
|
||||
{
|
||||
Dart_const_handle dha=m_map.darts().begin();
|
||||
if (dha>m_map.template beta<2>(dha)) { dha=m_map.template beta<2>(dha); }
|
||||
|
||||
Dart_const_handle dhb=NULL;
|
||||
auto it=m_map.darts().begin();
|
||||
while(dhb==NULL)
|
||||
{
|
||||
if (it!=dha && it!=m_map.template beta<2>(dha)) { dhb=it; }
|
||||
else { ++it; }
|
||||
}
|
||||
|
||||
if (dhb>m_map.template beta<2>(dhb)) { dhb=m_map.template beta<2>(dhb); }
|
||||
|
||||
if (dha<dhb) { std::swap(dha, dhb); }
|
||||
|
||||
a=0; b=0;
|
||||
|
||||
for (int i=0; i<path.length(); ++i)
|
||||
{
|
||||
if (path[i]==dha) { ++a; }
|
||||
else if (path[i]==m_map.template beta<2>(dha)) { --a; }
|
||||
else if (path[i]==dhb) { ++b; }
|
||||
else if (path[i]==m_map.template beta<2>(dhb)) { --b; }
|
||||
}
|
||||
}
|
||||
|
||||
/// @return true iff 'path' is contractible.
|
||||
bool is_contractible(const Path_on_surface<Map>& p,
|
||||
bool display_time=false)
|
||||
{
|
||||
if (p.is_empty())
|
||||
{ return true; }
|
||||
|
||||
if (!p.is_closed())
|
||||
{
|
||||
std::cerr<<"Error: is_contractible requires a closed path."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_map.is_empty())
|
||||
{ return true; } // A closed path on a sphere is always contractible.
|
||||
|
||||
CGAL::Timer t;
|
||||
if (display_time)
|
||||
{ t.start(); }
|
||||
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt=transform_original_path_into_quad_surface(p);
|
||||
|
||||
bool res=false;
|
||||
if (m_map.number_of_darts()==4)
|
||||
{ // Case of torus
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt=transform_original_path_into_quad_surface(p);
|
||||
|
||||
std::size_t a, b;
|
||||
count_edges_of_path_on_torus(pt, a, b);
|
||||
res=(a==0 && b==0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology> path(pt
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
, m_dart_ids
|
||||
#endif //CGAL_PWRLE_TURN_V2
|
||||
);
|
||||
path.canonize();
|
||||
res=path.is_empty();
|
||||
std::cout<<"Length of reduced paths: "<<path.length()<<std::endl;
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology>
|
||||
pt=transform_original_path_into_quad_surface_with_rle(p);
|
||||
|
||||
pt.canonize();
|
||||
res=pt.is_empty();
|
||||
std::cout<<"Length of reduced paths: "<<pt.length()<<std::endl;
|
||||
}
|
||||
|
||||
if (display_time)
|
||||
|
|
@ -393,18 +348,32 @@ namespace CGAL {
|
|||
const Path_on_surface<Map>& p2,
|
||||
bool display_time=false)
|
||||
{
|
||||
if (p1.is_empty() && p2.is_empty()) { return true; }
|
||||
|
||||
if ((!p1.is_empty() && !p1.is_closed()) ||
|
||||
(!p2.is_empty() && !p2.is_closed()))
|
||||
{
|
||||
std::cerr<<"Error: are_freely_homotopic requires two closed paths."
|
||||
<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here we have two non empty closed paths.
|
||||
if (m_map.is_empty())
|
||||
{ return true; } // Two closed paths on a sphere are always homotopic.
|
||||
|
||||
CGAL::Timer t;
|
||||
if (display_time)
|
||||
{ t.start(); }
|
||||
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt1=transform_original_path_into_quad_surface(p1);
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt2=transform_original_path_into_quad_surface(p2);
|
||||
|
||||
bool res=false;
|
||||
if (m_map.number_of_darts()==4)
|
||||
{ // Case of torus
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt1=transform_original_path_into_quad_surface(p1);
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
pt2=transform_original_path_into_quad_surface(p2);
|
||||
|
||||
std::size_t a1, a2, b1, b2;
|
||||
count_edges_of_path_on_torus(pt1, a1, b1);
|
||||
count_edges_of_path_on_torus(pt2, a2, b2);
|
||||
|
|
@ -413,25 +382,16 @@ namespace CGAL {
|
|||
else
|
||||
{
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology>
|
||||
path1(pt1
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
, m_dart_ids
|
||||
#endif //CGAL_PWRLE_TURN_V2
|
||||
);
|
||||
pt1=transform_original_path_into_quad_surface_with_rle(p1);
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology>
|
||||
path2(pt2
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
, m_dart_ids
|
||||
#endif //CGAL_PWRLE_TURN_V2
|
||||
);
|
||||
|
||||
path1.canonize();
|
||||
path2.canonize();
|
||||
res=(path1==path2); // Do here to be counted in the computation time
|
||||
pt2=transform_original_path_into_quad_surface_with_rle(p2);
|
||||
pt1.canonize();
|
||||
pt2.canonize();
|
||||
res=(pt1==pt2); // Do here to be counted in the computation time
|
||||
|
||||
#ifdef CGAL_TRACE_PATH_TESTS
|
||||
std::cout<<"Length of reduced paths: "<<path1.length()<<" and "
|
||||
<<path2.length()<<std::endl;
|
||||
std::cout<<"Length of reduced paths: "<<pt1.length()<<" and "
|
||||
<<pt2.length()<<std::endl;
|
||||
#endif
|
||||
|
||||
/* std::cout<<"path1="<<Path_on_surface<CMap_for_surface_mesh_curve_topology>(path1)<<std::endl
|
||||
|
|
@ -459,16 +419,21 @@ namespace CGAL {
|
|||
bool display_time=false) const
|
||||
{
|
||||
if (p1.is_empty() && p2.is_empty()) { return true; }
|
||||
if (p1.is_empty() || p2.is_empty()) { return true; }
|
||||
if (p1.is_empty() || p2.is_empty()) { return false; }
|
||||
|
||||
if (!CGAL::belong_to_same_cell<Map,0>(m_map,
|
||||
p1.front(), p2.front()))
|
||||
p1.front(), p2.front()) ||
|
||||
!CGAL::belong_to_same_cell<Map,0>(m_map,
|
||||
p1.back(), p2.back()))
|
||||
{
|
||||
std::cerr<<"Error: are_base_point_homotopic requires two paths that"
|
||||
<<" share the same first vertex."<<std::endl;
|
||||
<<" share the same vertices as extremities."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_map.is_empty())
|
||||
{ return true; } // Two paths on a sphere are always base_point_homotopic.
|
||||
|
||||
CGAL::Timer t;
|
||||
if (display_time)
|
||||
{ t.start(); }
|
||||
|
|
@ -489,10 +454,47 @@ namespace CGAL {
|
|||
return res;
|
||||
}
|
||||
|
||||
const CMap_for_surface_mesh_curve_topology& get_map() const
|
||||
{ return m_map; }
|
||||
|
||||
protected:
|
||||
void count_edges_of_path_on_torus
|
||||
(const Path_on_surface<CMap_for_surface_mesh_curve_topology>& path,
|
||||
std::size_t& a, std::size_t& b)
|
||||
{
|
||||
Dart_const_handle dha=m_map.darts().begin();
|
||||
if (dha>m_map.template beta<2>(dha)) { dha=m_map.template beta<2>(dha); }
|
||||
|
||||
Dart_const_handle dhb=NULL;
|
||||
auto it=m_map.darts().begin();
|
||||
while(dhb==NULL)
|
||||
{
|
||||
if (it!=dha && it!=m_map.template beta<2>(dha)) { dhb=it; }
|
||||
else { ++it; }
|
||||
}
|
||||
|
||||
if (dhb>m_map.template beta<2>(dhb)) { dhb=m_map.template beta<2>(dhb); }
|
||||
|
||||
if (dha<dhb) { std::swap(dha, dhb); }
|
||||
|
||||
a=0; b=0;
|
||||
|
||||
for (int i=0; i<path.length(); ++i)
|
||||
{
|
||||
if (path[i]==dha) { ++a; }
|
||||
else if (path[i]==m_map.template beta<2>(dha)) { --a; }
|
||||
else if (path[i]==dhb) { ++b; }
|
||||
else if (path[i]==m_map.template beta<2>(dhb)) { --b; }
|
||||
}
|
||||
}
|
||||
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology>
|
||||
transform_original_path_into_quad_surface
|
||||
(const Path_on_surface<Map>& path) // TODO return directly a Path_on_durface_with_rle
|
||||
(const Path_on_surface<Map>& path
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
, m_dart_ids
|
||||
#endif //CGAL_PWRLE_TURN_V2
|
||||
)
|
||||
{
|
||||
Path_on_surface<CMap_for_surface_mesh_curve_topology> res(m_map);
|
||||
if (path.is_empty()) return res;
|
||||
|
|
@ -511,6 +513,36 @@ namespace CGAL {
|
|||
return res;
|
||||
}
|
||||
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology>
|
||||
transform_original_path_into_quad_surface_with_rle
|
||||
(const Path_on_surface<Map>& path)
|
||||
{
|
||||
Path_on_surface_with_rle<CMap_for_surface_mesh_curve_topology>
|
||||
res(m_map
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
, m_dart_ids
|
||||
#endif //CGAL_PWRLE_TURN_V2
|
||||
);
|
||||
|
||||
if (path.is_empty()) return res;
|
||||
CGAL_assertion(path.is_closed());
|
||||
|
||||
for (std::size_t i=0; i<path.length(); ++i)
|
||||
{
|
||||
if (!m_original_map.is_marked(path[i], m_mark_T))
|
||||
{
|
||||
res.push_back(get_first_dart_of_the_path(path[i]), false);
|
||||
res.push_back(get_second_dart_of_the_path(path[i]), false);
|
||||
}
|
||||
}
|
||||
res.update_is_closed();
|
||||
res.merge_last_flat_with_next_if_possible();
|
||||
|
||||
CGAL_assertion(res.is_closed());
|
||||
CGAL_assertion(res.is_valid());
|
||||
return res;
|
||||
}
|
||||
|
||||
void initialize_vertices(UFTree& uftrees,
|
||||
boost::unordered_map<Dart_const_handle, UFTree_handle>&
|
||||
vertices)
|
||||
|
|
@ -580,7 +612,8 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
/// Mark the edge containing adart in the original map.
|
||||
void mark_edge(const Map& amap, typename Map::Dart_const_handle adart, std::size_t amark)
|
||||
void mark_edge(const Map& amap, typename Map::Dart_const_handle adart,
|
||||
std::size_t amark)
|
||||
{
|
||||
amap.mark(amap.template beta<2>(adart), amark);
|
||||
amap.mark(adart, amark);
|
||||
|
|
@ -591,10 +624,13 @@ namespace CGAL {
|
|||
/// (which belongs to the map m_original_map) from the array origin_to_copy
|
||||
void erase_edge_from_associative_arrays
|
||||
(Dart_handle adart,
|
||||
boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>& origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>& copy_to_origin)
|
||||
boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>&
|
||||
origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>&
|
||||
copy_to_origin)
|
||||
{
|
||||
origin_to_copy.erase(m_original_map.template beta<2>(copy_to_origin[adart]));
|
||||
origin_to_copy.erase(m_original_map.template beta<2>
|
||||
(copy_to_origin[adart]));
|
||||
origin_to_copy.erase(copy_to_origin[adart]);
|
||||
|
||||
copy_to_origin.erase(m_map.template beta<2>(adart));
|
||||
|
|
@ -605,8 +641,10 @@ namespace CGAL {
|
|||
/// vertex. All edges contracted during this step belong to the spanning
|
||||
/// tree T, and thus corresponding edges in m_original_map are marked.
|
||||
void surface_simplification_in_one_vertex
|
||||
(boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>& origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>& copy_to_origin)
|
||||
(boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>&
|
||||
origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>&
|
||||
copy_to_origin)
|
||||
{
|
||||
UFTree uftrees; // uftree of vertices; one tree for each vertex,
|
||||
// contains one dart of the vertex
|
||||
|
|
@ -627,11 +665,14 @@ namespace CGAL {
|
|||
erase_edge_from_associative_arrays(it, origin_to_copy, copy_to_origin);
|
||||
|
||||
uftrees.unify_sets(get_uftree(uftrees, vertices, it),
|
||||
get_uftree(uftrees, vertices, m_map.template beta<2>(it)));
|
||||
get_uftree(uftrees, vertices,
|
||||
m_map.template beta<2>(it)));
|
||||
//m_map.template contract_cell<1>(it);
|
||||
Dart_handle d1=it, d2=m_map.template beta<2>(it);
|
||||
m_map.template link_beta<1>(m_map.template beta<0>(d1), m_map.template beta<1>(d1));
|
||||
m_map.template link_beta<1>(m_map.template beta<0>(d2), m_map.template beta<1>(d2));
|
||||
m_map.template link_beta<1>(m_map.template beta<0>(d1),
|
||||
m_map.template beta<1>(d1));
|
||||
m_map.template link_beta<1>(m_map.template beta<0>(d2),
|
||||
m_map.template beta<1>(d2));
|
||||
m_map.erase_dart(d1);
|
||||
m_map.erase_dart(d2);
|
||||
}
|
||||
|
|
@ -645,7 +686,8 @@ namespace CGAL {
|
|||
/// will be updated later (in surface_simplification_in_one_face() and in
|
||||
/// surface_quadrangulate() )
|
||||
void compute_length_two_paths
|
||||
(const boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>& origin_to_copy)
|
||||
(const boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>&
|
||||
origin_to_copy)
|
||||
{
|
||||
paths.clear();
|
||||
|
||||
|
|
@ -669,7 +711,8 @@ namespace CGAL {
|
|||
|
||||
#ifdef CGAL_TRACE_CMAP_TOOLS
|
||||
std::cout<<"Number of darts in paths: "<<paths.size()
|
||||
<<"; number of darts in m_map: "<<m_map.number_of_darts()<<std::endl;
|
||||
<<"; number of darts in m_map: "<<m_map.number_of_darts()
|
||||
<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -677,8 +720,10 @@ namespace CGAL {
|
|||
/// one face. All edges removed during this step belong to the
|
||||
/// dual spanning tree L (spanning tree of the dual 2-map).
|
||||
void surface_simplification_in_one_face
|
||||
(boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>& origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>& copy_to_origin)
|
||||
(boost::unordered_map<typename Map::Dart_const_handle, Dart_handle>&
|
||||
origin_to_copy,
|
||||
boost::unordered_map<Dart_handle, typename Map::Dart_const_handle>&
|
||||
copy_to_origin)
|
||||
{
|
||||
UFTree uftrees; // uftree of faces; one tree for each face,
|
||||
// contains one dart of the face
|
||||
|
|
@ -732,8 +777,7 @@ namespace CGAL {
|
|||
}
|
||||
else
|
||||
{
|
||||
// update_length_two_paths_before_edge_removals_v1(toremove);
|
||||
update_length_two_paths_before_edge_removals_v2(toremove, copy_to_origin);
|
||||
update_length_two_paths_before_edge_removals(toremove, copy_to_origin);
|
||||
|
||||
// We remove all the edges to remove.
|
||||
for (typename CMap_for_surface_mesh_curve_topology::Dart_range::iterator
|
||||
|
|
@ -779,8 +823,6 @@ namespace CGAL {
|
|||
p.second=m_map.template beta<0>(p.second);
|
||||
//std::cout<<" -> "<<m_map.darts().index(p.first)<<", "
|
||||
// <<m_map.darts().index(p.second)<<std::endl;
|
||||
// WRONG ASSERTS assert(p.first!=p.second);
|
||||
// assert(p.first!=m_map.template beta<2>(p.second));
|
||||
}
|
||||
|
||||
// 3) We remove all the old edges.
|
||||
|
|
@ -795,63 +837,16 @@ namespace CGAL {
|
|||
m_map.free_mark(oldedges);
|
||||
}
|
||||
|
||||
/// Version1: quadratic in number of darts in the paths
|
||||
void update_length_two_paths_before_edge_removals_v1(typename Map::size_type toremove)
|
||||
/// Update all length two paths, before edge removal. Edges that will be
|
||||
/// removed are marked with toremove mark.
|
||||
void update_length_two_paths_before_edge_removals
|
||||
(typename Map::size_type toremove,
|
||||
const boost::unordered_map<Dart_handle,
|
||||
typename Map::Dart_const_handle>& copy_to_origin)
|
||||
{
|
||||
// std::cout<<"************************************************"<<std::endl;
|
||||
// We update the pair of darts
|
||||
for (typename TPaths::iterator itp=paths.begin(), itpend=paths.end();
|
||||
itp!=itpend; ++itp)
|
||||
{
|
||||
std::pair<Dart_const_handle, Dart_const_handle>& p=itp->second;
|
||||
//std::cout<<"Pair: "<<m_map.darts().index(p.first)<<", "
|
||||
// <<m_map.darts().index(p.second)<<": "<<std::flush;
|
||||
|
||||
//std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush;
|
||||
// p.first=m_map.template beta<0>(p.first);
|
||||
Dart_const_handle initdart=p.first;
|
||||
|
||||
if (!m_map.is_marked(p.first, toremove))
|
||||
{
|
||||
p.second=m_map.template beta<1>(p.first);
|
||||
initdart=p.second;
|
||||
while (m_map.is_marked(p.second, toremove))
|
||||
{
|
||||
p.second=m_map.template beta<2, 1>(p.second);
|
||||
assert(p.second!=initdart);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_map.is_marked(p.first, toremove))
|
||||
{
|
||||
p.first=m_map.template beta<2, 1>(p.first);
|
||||
//std::cout<<m_map.darts().index(p.first)<<"; "<<std::flush;
|
||||
assert(p.first!=initdart);
|
||||
}
|
||||
//std::cout<<std::endl;
|
||||
// p.second=m_map.template beta<0>(p.second);
|
||||
initdart=p.second;
|
||||
while (m_map.is_marked(p.second, toremove))
|
||||
{
|
||||
p.second=m_map.template beta<2, 1>(p.second);
|
||||
//std::cout<<m_map.darts().index(p.second)<<"; "<<std::flush;
|
||||
assert(p.second!=initdart);
|
||||
}
|
||||
//std::cout<<std::endl;
|
||||
//std::cout<<" -> "<<m_map.darts().index(p.first)<<", "
|
||||
// <<m_map.darts().index(p.second)<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Version2: linear in number of darts in the paths
|
||||
void update_length_two_paths_before_edge_removals_v2(typename Map::size_type toremove,
|
||||
const boost::unordered_map<Dart_handle,
|
||||
typename Map::Dart_const_handle>& copy_to_origin)
|
||||
{
|
||||
// std::cout<<"************************************************"<<std::endl;
|
||||
for (auto it=m_original_map.darts().begin(); it!=m_original_map.darts().end(); ++it)
|
||||
for (auto it=m_original_map.darts().begin();
|
||||
it!=m_original_map.darts().end(); ++it)
|
||||
{
|
||||
if (!m_original_map.is_marked(it, m_mark_T) &&
|
||||
!m_original_map.is_marked(it, m_mark_L) &&
|
||||
|
|
@ -860,7 +855,8 @@ namespace CGAL {
|
|||
std::pair<Dart_const_handle, Dart_const_handle>& p=paths[it];
|
||||
|
||||
Dart_handle initdart=m_map.darts().iterator_to
|
||||
(const_cast<typename CMap_for_surface_mesh_curve_topology::Dart &>(*(p.first)));
|
||||
(const_cast<typename CMap_for_surface_mesh_curve_topology::Dart &>
|
||||
(*(p.first)));
|
||||
Dart_handle initdart2=m_map.template beta<2>(initdart);
|
||||
CGAL_assertion(initdart2==p.second);
|
||||
CGAL_assertion(!m_map.is_marked(initdart, toremove));
|
||||
|
|
@ -876,8 +872,10 @@ namespace CGAL {
|
|||
while (m_map.is_marked(initdart, toremove))
|
||||
{
|
||||
assert(copy_to_origin.count(initdart)==1);
|
||||
typename Map::Dart_const_handle d1=copy_to_origin.find(initdart)->second;
|
||||
typename Map::Dart_const_handle d2=m_original_map.template beta<2>(d1);
|
||||
typename Map::Dart_const_handle
|
||||
d1=copy_to_origin.find(initdart)->second;
|
||||
typename Map::Dart_const_handle
|
||||
d2=m_original_map.template beta<2>(d1);
|
||||
if (d1<d2) { paths[d1].first=p.second; }
|
||||
else { paths[d2].second=p.second; }
|
||||
initdart=m_map.template beta<2, 1>(initdart);
|
||||
|
|
@ -892,8 +890,10 @@ namespace CGAL {
|
|||
while (m_map.is_marked(initdart2, toremove))
|
||||
{
|
||||
assert(copy_to_origin.count(initdart2)==1);
|
||||
typename Map::Dart_const_handle d1=copy_to_origin.find(initdart2)->second;
|
||||
typename Map::Dart_const_handle d2=m_original_map.template beta<2>(d1);
|
||||
typename Map::Dart_const_handle
|
||||
d1=copy_to_origin.find(initdart2)->second;
|
||||
typename Map::Dart_const_handle
|
||||
d2=m_original_map.template beta<2>(d1);
|
||||
if (d1<d2) {
|
||||
assert(paths.count(d1)==1);
|
||||
paths[d1].first=enddart2;
|
||||
|
|
@ -913,7 +913,8 @@ namespace CGAL {
|
|||
/// test this by using directly the mark m_mark_T).
|
||||
bool is_edge_has_path(typename Map::Dart_const_handle adart) const
|
||||
{
|
||||
typename Map::Dart_const_handle opposite=m_original_map.template beta<2>(adart);
|
||||
typename Map::Dart_const_handle
|
||||
opposite=m_original_map.template beta<2>(adart);
|
||||
if (adart<opposite)
|
||||
{
|
||||
return paths.find(adart)!=paths.end();
|
||||
|
|
@ -930,19 +931,22 @@ namespace CGAL {
|
|||
assert(!m_original_map.is_marked(adart, m_mark_T));
|
||||
assert(is_edge_has_path(adart));
|
||||
|
||||
typename Map::Dart_const_handle opposite=m_original_map.template beta<2>(adart);
|
||||
typename Map::Dart_const_handle
|
||||
opposite=m_original_map.template beta<2>(adart);
|
||||
if (adart<opposite)
|
||||
{ return paths.find(adart)->second; }
|
||||
|
||||
return paths.find(opposite)->second;
|
||||
}
|
||||
|
||||
Dart_const_handle get_first_dart_of_the_path(typename Map::Dart_const_handle adart) const
|
||||
Dart_const_handle get_first_dart_of_the_path
|
||||
(typename Map::Dart_const_handle adart) const
|
||||
{
|
||||
assert(!m_original_map.is_marked(adart, m_mark_T));
|
||||
assert(is_edge_has_path(adart));
|
||||
|
||||
typename Map::Dart_const_handle opposite=m_original_map.template beta<2>(adart);
|
||||
typename Map::Dart_const_handle
|
||||
opposite=m_original_map.template beta<2>(adart);
|
||||
if (adart<opposite)
|
||||
{
|
||||
const std::pair<Dart_const_handle, Dart_const_handle>&
|
||||
|
|
@ -955,12 +959,14 @@ namespace CGAL {
|
|||
return m_map.template beta<2>(p.second);
|
||||
}
|
||||
|
||||
Dart_const_handle get_second_dart_of_the_path(typename Map::Dart_const_handle adart) const
|
||||
Dart_const_handle get_second_dart_of_the_path
|
||||
(typename Map::Dart_const_handle adart) const
|
||||
{
|
||||
assert(!m_original_map.is_marked(adart, m_mark_T));
|
||||
assert(is_edge_has_path(adart));
|
||||
|
||||
typename Map::Dart_const_handle opposite=m_original_map.template beta<2>(adart);
|
||||
typename Map::Dart_const_handle
|
||||
opposite=m_original_map.template beta<2>(adart);
|
||||
if (adart<opposite)
|
||||
{
|
||||
const std::pair<Dart_const_handle, Dart_const_handle>&
|
||||
|
|
@ -991,8 +997,8 @@ namespace CGAL {
|
|||
{
|
||||
if (!is_edge_has_path(it))
|
||||
{
|
||||
std::cout<<"ERROR: an edge that does not belong to the spanning tree"
|
||||
<<" T has no associated path."<<std::endl;
|
||||
std::cout<<"ERROR: an edge that does not belong to the spanning "
|
||||
<<"tree T has no associated path."<<std::endl;
|
||||
res=false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1095,6 +1101,7 @@ namespace CGAL {
|
|||
/// (except the edges that belong to the spanning tree T).
|
||||
std::size_t m_mark_T; /// mark each edge of m_original_map that belong to the spanning tree T
|
||||
std::size_t m_mark_L; /// mark each edge of m_original_map that belong to the dual spanning tree L
|
||||
|
||||
#ifdef CGAL_PWRLE_TURN_V2
|
||||
TDartIds m_dart_ids; /// Ids of each dart of the transformed map, between 0 and n-1 (n being the number of darts)
|
||||
/// so that darts between 0...(n/2)-1 belong to the same vertex and
|
||||
|
|
|
|||
Loading…
Reference in New Issue