mirror of https://github.com/CGAL/cgal
Case (1 2^r) is now ok.
This commit is contained in:
parent
5521f52d96
commit
1d97d27ba9
|
|
@ -101,11 +101,30 @@ template<typename Path>
|
|||
void generate_positive_bracket_special1(Path& p)
|
||||
{ generate_bracket_special1(p, false); }
|
||||
|
||||
|
||||
template<typename Path>
|
||||
void generate_negative_bracket_special1(Path& p)
|
||||
{ generate_bracket_special1(p, true); }
|
||||
|
||||
template<typename Path>
|
||||
void generate_bracket_special2(Path& p, bool reverse)
|
||||
{ // Case (1, 2^r)
|
||||
p.clear();
|
||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[0]));
|
||||
extend_uturn_positive(p, 1);
|
||||
extend_straight_positive(p, 10);
|
||||
|
||||
if (reverse)
|
||||
{ p.reverse(); }
|
||||
}
|
||||
|
||||
template<typename Path>
|
||||
void generate_positive_bracket_special2(Path& p)
|
||||
{ generate_bracket_special2(p, false); }
|
||||
|
||||
template<typename Path>
|
||||
void generate_negative_bracket_special2(Path& p)
|
||||
{ generate_bracket_special2(p, true); }
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_CREATION_OF_TEST_CASES_FOR_PATHS_H //
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ public:
|
|||
void clear()
|
||||
{ m_path.clear(); }
|
||||
|
||||
std::size_t next_index(std::size_t i) const
|
||||
{ return (i==m_path.size()-1?0:i+1); }
|
||||
|
||||
std::size_t prev_index(std::size_t i) const
|
||||
{ return (i==0?m_path.size()-1:i-1); }
|
||||
|
||||
Dart_const_handle get_ith_dart(std::size_t i) const
|
||||
{
|
||||
assert(i<=m_path.size());
|
||||
|
|
@ -214,22 +220,16 @@ public:
|
|||
assert((positive && next_turn(begin)==1) ||
|
||||
(!positive && next_negative_turn(begin)==1));
|
||||
std::size_t end=begin+1;
|
||||
if (end==m_path.size()-1)
|
||||
if (!is_closed() && end==m_path.size()-1)
|
||||
{ return begin; } // begin is the before last dart
|
||||
|
||||
while ((positive && next_turn(end)==2) ||
|
||||
(!positive && next_negative_turn(end)==2))
|
||||
{
|
||||
++end;
|
||||
if (is_closed() && end==m_path.size()) { end=0; }
|
||||
}
|
||||
{ end=next_index(end); }
|
||||
|
||||
if ((positive && next_turn(end)==1) ||
|
||||
(!positive && next_negative_turn(end)==1)) // We are on the end of a bracket
|
||||
{
|
||||
++end;
|
||||
if (is_closed() && end==m_path.size()) { end=0; }
|
||||
}
|
||||
{ end=next_index(end); }
|
||||
else
|
||||
{ end=begin; }
|
||||
|
||||
|
|
@ -239,8 +239,14 @@ public:
|
|||
void transform_positive_bracket(std::size_t begin, std::size_t end,
|
||||
std::vector<Dart_const_handle>& new_path)
|
||||
{
|
||||
Dart_const_handle d1=m_map.template beta<0>(get_ith_dart(begin));
|
||||
Dart_const_handle d2=m_map.template beta<2,0>(get_ith_dart(end));
|
||||
// There is a special case for (1 2^r). In this case, we need to ignore
|
||||
// the two darts begin and end
|
||||
Dart_const_handle d1=(next_index(begin)!=end?
|
||||
m_map.template beta<0>(get_ith_dart(begin)):
|
||||
m_map.template beta<1,2,0>(get_ith_dart(end)));
|
||||
Dart_const_handle d2=(next_index(begin)!=end?
|
||||
m_map.template beta<2,0>(get_ith_dart(end)):
|
||||
m_map.template beta<0,0>(get_ith_dart(begin)));
|
||||
do
|
||||
{
|
||||
new_path.push_back(m_map.template beta<2>(d1));
|
||||
|
|
@ -252,8 +258,14 @@ public:
|
|||
void transform_negative_bracket(std::size_t begin, std::size_t end,
|
||||
std::vector<Dart_const_handle>& new_path)
|
||||
{
|
||||
Dart_const_handle d1=m_map.template beta<2,1>(get_ith_dart(begin));
|
||||
Dart_const_handle d2=m_map.template beta<1>(get_ith_dart(end));
|
||||
// There is a special case for (-1 -2^r). In this case, we need to ignore
|
||||
// the two darts begin and end
|
||||
Dart_const_handle d1=(next_index(begin)!=end?
|
||||
m_map.template beta<2,1>(get_ith_dart(begin)):
|
||||
m_map.template beta<2,0,2,1>(get_ith_dart(end)));
|
||||
Dart_const_handle d2=(next_index(begin)!=end?
|
||||
m_map.template beta<1>(get_ith_dart(end)):
|
||||
m_map.template beta<2,1,1>(get_ith_dart(begin)));
|
||||
do
|
||||
{
|
||||
new_path.push_back(d1);
|
||||
|
|
@ -300,7 +312,9 @@ public:
|
|||
<<(positive?"+":"-")<<std::endl; */
|
||||
if (end<begin)
|
||||
{ i=m_path.size(); }
|
||||
else
|
||||
else if (next_index(begin)==end) // Special case of (1 2^r)
|
||||
{ i=m_path.size(); }
|
||||
else // Normal case
|
||||
{ i=end+1; }
|
||||
transform_bracket(begin, end, new_path, positive);
|
||||
res=true;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ void simplify_path(CGAL::Path_on_surface<LCC_3_cmap>& path,
|
|||
delete curp;
|
||||
curp=NULL;
|
||||
}
|
||||
// if (nbtest==1)
|
||||
// display(lcc, v);
|
||||
if (draw /* && nbtest==1*/)
|
||||
display(path.get_map(), v);
|
||||
}
|
||||
while(curp!=NULL);
|
||||
|
||||
|
|
@ -58,9 +58,10 @@ void simplify_path(CGAL::Path_on_surface<LCC_3_cmap>& path,
|
|||
curp=NULL;
|
||||
}
|
||||
|
||||
path.swap(*prevp);
|
||||
if (draw)
|
||||
{ display(path.get_map(), v); }
|
||||
|
||||
path.swap(*prevp);
|
||||
}
|
||||
|
||||
void test_file(int argc, char** argv)
|
||||
|
|
@ -162,72 +163,92 @@ void test_some_random_paths_on_cube()
|
|||
|
||||
void test_all_cases_spurs_and_bracket()
|
||||
{
|
||||
LCC_3_cmap lcc1;
|
||||
if (!CGAL::load_off(lcc1, "./data/cube-mesh-5-5.off"))
|
||||
LCC_3_cmap lcc;
|
||||
if (!CGAL::load_off(lcc, "./data/cube-mesh-5-5.off"))
|
||||
{
|
||||
std::cout<<"PROBLEM reading file ./data/cube-mesh-5-5.off"<<std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
LCC_3_cmap lcc2;
|
||||
if (!CGAL::load_off(lcc2, "./data/spiral-squared.off"))
|
||||
{
|
||||
std::cout<<"PROBLEM reading file ./data/spiral-squared.off"<<std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// lcc2.reverse_orientation();
|
||||
/* std::cout<<"Initial map 1: ";
|
||||
lcc.display_characteristics(std::cout) << ", valid="
|
||||
<< lcc.is_valid() << std::endl;
|
||||
*/
|
||||
|
||||
CGAL::Path_on_surface<LCC_3_cmap> path1(lcc1);
|
||||
CGAL::Path_on_surface<LCC_3_cmap> path(lcc);
|
||||
|
||||
generate_one_positive_spur(path1);
|
||||
generate_one_positive_spur(path);
|
||||
std::cout<<"Posivite spur (2^6 1 0 2^4): "<<std::flush;
|
||||
path1.display_positive_turns();
|
||||
simplify_path(path1, false);
|
||||
std::cout<<" -> "; path1.display_positive_turns(); std::cout<<std::endl;
|
||||
path.display_positive_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> "; path.display_positive_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_one_negative_spur(path1);
|
||||
generate_one_negative_spur(path);
|
||||
std::cout<<"Negative spur (-2^6 -1 0 -2^4): "<<std::flush;
|
||||
path1.display_negative_turns();
|
||||
simplify_path(path1, false);
|
||||
std::cout<<" -> "; path1.display_negative_turns(); std::cout<<std::endl;
|
||||
path.display_negative_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> "; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_cyclic_spur(path1);
|
||||
generate_cyclic_spur(path);
|
||||
std::cout<<"Cyclic spur (0 0): "<<std::flush;
|
||||
path1.display_positive_turns();
|
||||
simplify_path(path1, false);
|
||||
std::cout<<" -> "; path1.display_positive_turns(); std::cout<<std::endl;
|
||||
path.display_positive_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> "; path.display_positive_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_one_positive_bracket(path1);
|
||||
generate_one_positive_bracket(path);
|
||||
std::cout<<"Positive bracket (2^3 3 1 2^6 1 3 2^2): "<<std::flush;
|
||||
path1.display_positive_turns();
|
||||
simplify_path(path1, false);
|
||||
std::cout<<" -> "; path1.display_positive_turns(); std::cout<<std::endl;
|
||||
path.display_positive_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> "; path.display_positive_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_one_negative_bracket(path1);
|
||||
generate_one_negative_bracket(path);
|
||||
std::cout<<"Negative bracket (-2^3 -3 -1 -2^6 -1 -3 -2^2): "<<std::flush;
|
||||
path1.display_negative_turns();
|
||||
simplify_path(path1, false);
|
||||
std::cout<<" -> "; path1.display_negative_turns(); std::cout<<std::endl;
|
||||
path.display_negative_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> "; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
CGAL::Path_on_surface<LCC_3_cmap> path2(lcc2);
|
||||
lcc.clear();
|
||||
if (!CGAL::load_off(lcc, "./data/spiral-squared.off"))
|
||||
{
|
||||
std::cout<<"PROBLEM reading file ./data/spiral-squared.off"<<std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
generate_positive_bracket_special1(path2);
|
||||
generate_positive_bracket_special1(path);
|
||||
std::cout<<"Positive special case 1 (3 1 2^8 1): "<<std::flush;
|
||||
path2.display_positive_turns();
|
||||
simplify_path(path2, false);
|
||||
std::cout<<" -> +"; path2.display_positive_turns();
|
||||
std::cout<<" -"; path2.display_negative_turns(); std::cout<<std::endl;
|
||||
path.display_positive_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> +"; path.display_positive_turns();
|
||||
std::cout<<" -"; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_negative_bracket_special1(path2);
|
||||
generate_negative_bracket_special1(path);
|
||||
std::cout<<"Negative special case 1 (-3 -1 -2^8 -1): "<<std::flush;
|
||||
path2.display_negative_turns();
|
||||
simplify_path(path2, true);
|
||||
std::cout<<" -> +"; path2.display_positive_turns();
|
||||
std::cout<<" -"; path2.display_negative_turns(); std::cout<<std::endl;
|
||||
path.display_negative_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> +"; path.display_positive_turns();
|
||||
std::cout<<" -"; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
lcc.clear();
|
||||
if (!CGAL::load_off(lcc, "./data/loop-squared.off"))
|
||||
{
|
||||
std::cout<<"PROBLEM reading file ./data/spiral-squared.off"<<std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
generate_positive_bracket_special2(path);
|
||||
std::cout<<"Positive special case 1 (1 2^10): "<<std::flush;
|
||||
path.display_positive_turns();
|
||||
simplify_path(path, false);
|
||||
std::cout<<" -> +"; path.display_positive_turns();
|
||||
std::cout<<" -"; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
generate_negative_bracket_special2(path);
|
||||
std::cout<<"Negative special case 1 (-1 -2^10): "<<std::flush;
|
||||
path.display_negative_turns();
|
||||
simplify_path(path, true);
|
||||
std::cout<<" -> +"; path.display_positive_turns();
|
||||
std::cout<<" -"; path.display_negative_turns(); std::cout<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ protected:
|
|||
|
||||
void compute_path(unsigned int i, unsigned int amark)
|
||||
{
|
||||
if (m_paths[i]->is_empty())
|
||||
{ return; }
|
||||
|
||||
CGAL::Random random(i);
|
||||
CGAL::Color color=get_random_color(random);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue