mirror of https://github.com/CGAL/cgal
l-push case 4 ok.
This commit is contained in:
parent
b3389488f5
commit
c8cdf75b8b
|
|
@ -29,7 +29,7 @@ template<typename Path>
|
||||||
void generate_one_positive_spur(Path& p)
|
void generate_one_positive_spur(Path& p)
|
||||||
{
|
{
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5]));
|
||||||
extend_straight_positive(p, 6);
|
extend_straight_positive(p, 6);
|
||||||
extend_uturn_positive(p);
|
extend_uturn_positive(p);
|
||||||
extend_uturn_half_turn(p);
|
extend_uturn_half_turn(p);
|
||||||
|
|
@ -40,7 +40,7 @@ template<typename Path>
|
||||||
void generate_one_negative_spur(Path& p)
|
void generate_one_negative_spur(Path& p)
|
||||||
{
|
{
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5]));
|
||||||
extend_straight_negative(p, 6);
|
extend_straight_negative(p, 6);
|
||||||
extend_uturn_negative(p);
|
extend_uturn_negative(p);
|
||||||
extend_uturn_half_turn(p);
|
extend_uturn_half_turn(p);
|
||||||
|
|
@ -51,7 +51,7 @@ template<typename Path>
|
||||||
void generate_cyclic_spur(Path& p)
|
void generate_cyclic_spur(Path& p)
|
||||||
{
|
{
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5]));
|
||||||
extend_uturn_half_turn(p);
|
extend_uturn_half_turn(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ template<typename Path>
|
||||||
void generate_one_positive_bracket(Path& p)
|
void generate_one_positive_bracket(Path& p)
|
||||||
{
|
{
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5]));
|
||||||
extend_straight_positive(p, 3);
|
extend_straight_positive(p, 3);
|
||||||
extend_uturn_positive(p, 3);
|
extend_uturn_positive(p, 3);
|
||||||
extend_uturn_positive(p);
|
extend_uturn_positive(p);
|
||||||
|
|
@ -73,7 +73,7 @@ template<typename Path>
|
||||||
void generate_one_negative_bracket(Path& p)
|
void generate_one_negative_bracket(Path& p)
|
||||||
{
|
{
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[5]));
|
||||||
extend_straight_negative(p, 3);
|
extend_straight_negative(p, 3);
|
||||||
extend_uturn_negative(p);
|
extend_uturn_negative(p);
|
||||||
extend_straight_negative(p, 6);
|
extend_straight_negative(p, 6);
|
||||||
|
|
@ -85,7 +85,7 @@ template<typename Path>
|
||||||
void generate_bracket_special1(Path& p, bool reverse)
|
void generate_bracket_special1(Path& p, bool reverse)
|
||||||
{ // Case (x, 1, 2^r, 1)
|
{ // Case (x, 1, 2^r, 1)
|
||||||
p.clear();
|
p.clear();
|
||||||
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[91])); // 6th dart of the map
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[91]));
|
||||||
extend_uturn_positive(p, 1);
|
extend_uturn_positive(p, 1);
|
||||||
extend_straight_positive(p, 8);
|
extend_straight_positive(p, 8);
|
||||||
extend_uturn_positive(p);
|
extend_uturn_positive(p);
|
||||||
|
|
@ -162,6 +162,27 @@ void generate_l_shape_case3(Path& p)
|
||||||
extend_straight_negative(p, 3);
|
extend_straight_negative(p, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Path>
|
||||||
|
void generate_l_shape_case4(Path& p)
|
||||||
|
{ // (x -2^s -1 -2^t): here (-2^7 -1 -2^3 -4)
|
||||||
|
p.clear();
|
||||||
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[35]));
|
||||||
|
extend_uturn_negative(p, 4);
|
||||||
|
extend_straight_negative(p, 7);
|
||||||
|
extend_uturn_negative(p, 1);
|
||||||
|
extend_straight_negative(p, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Path>
|
||||||
|
void generate_l_shape_case7(Path& p)
|
||||||
|
{ // (-3 -2^s -1 -2^t): here (-2^7 -1 -2^3 -3)
|
||||||
|
p.clear();
|
||||||
|
p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[194]));
|
||||||
|
extend_straight_negative(p, 7);
|
||||||
|
extend_uturn_negative(p, 1);
|
||||||
|
extend_straight_negative(p, 3);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_CREATION_OF_TEST_CASES_FOR_PATHS_H //
|
#endif // CGAL_CREATION_OF_TEST_CASES_FOR_PATHS_H //
|
||||||
|
|
|
||||||
|
|
@ -610,10 +610,13 @@ public:
|
||||||
std::vector<std::size_t> compute_turns(bool positive) const
|
std::vector<std::size_t> compute_turns(bool positive) const
|
||||||
{ return (positive?compute_positive_turns():compute_negative_turns()); }
|
{ return (positive?compute_positive_turns():compute_negative_turns()); }
|
||||||
|
|
||||||
bool same_turns(const char* turns) const
|
bool same_turns_from(const char* turns,
|
||||||
|
const std::vector<std::size_t>& resplus,
|
||||||
|
const std::vector<std::size_t>& resmoins,
|
||||||
|
std::size_t start) const
|
||||||
{
|
{
|
||||||
std::vector<std::size_t> resplus=compute_positive_turns();
|
assert(start==0 || start<resplus.size());
|
||||||
std::vector<std::size_t> resmoins=compute_negative_turns();
|
assert(resplus.size()==resmoins.size());
|
||||||
|
|
||||||
std::string sturns(turns);
|
std::string sturns(turns);
|
||||||
std::istringstream iss(sturns);
|
std::istringstream iss(sturns);
|
||||||
|
|
@ -624,9 +627,13 @@ public:
|
||||||
if (!iss.good())
|
if (!iss.good())
|
||||||
{ return false; }
|
{ return false; }
|
||||||
iss>>nb;
|
iss>>nb;
|
||||||
if ((nb>=0 && resplus[i]!=nb) ||
|
if ((nb>=0 && resplus[start]!=nb) ||
|
||||||
(nb<0 && resmoins[i]!=-nb))
|
(nb<0 && resmoins[start]!=-nb))
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
|
++start;
|
||||||
|
if (start==resplus.size())
|
||||||
|
{ start=0; }
|
||||||
}
|
}
|
||||||
iss>>nb;
|
iss>>nb;
|
||||||
if (iss.good())
|
if (iss.good())
|
||||||
|
|
@ -635,6 +642,23 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool same_turns(const char* turns) const
|
||||||
|
{
|
||||||
|
std::vector<std::size_t> resplus=compute_positive_turns();
|
||||||
|
std::vector<std::size_t> resmoins=compute_negative_turns();
|
||||||
|
|
||||||
|
if (!is_closed())
|
||||||
|
{ return same_turns_from(turns, resplus, resmoins, 0); }
|
||||||
|
|
||||||
|
for (std::size_t start=0; start<resplus.size(); ++start)
|
||||||
|
{
|
||||||
|
if (same_turns_from(turns, resplus, resmoins, start))
|
||||||
|
{ return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void display_positive_turns() const
|
void display_positive_turns() const
|
||||||
{
|
{
|
||||||
std::cout<<"+(";
|
std::cout<<"+(";
|
||||||
|
|
|
||||||
|
|
@ -403,6 +403,26 @@ bool test_all_cases_l_shape()
|
||||||
res=false;
|
res=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcc.clear();
|
||||||
|
if (!CGAL::load_off(lcc, "./data/case4-right-shift-squared.off"))
|
||||||
|
{
|
||||||
|
std::cout<<"PROBLEM reading file ./data/case4-right-shift-squared.off"<<std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
lcc.reverse_orientation();
|
||||||
|
|
||||||
|
generate_l_shape_case4(path);
|
||||||
|
// std::cout<<"Case 4: L-shape (-4 -2^7 -1 -2^3): "<<std::flush;
|
||||||
|
path.display_pos_and_neg_turns();std::cout<<std::endl;
|
||||||
|
push_l_shape(path, true, 1);
|
||||||
|
if (!path.same_turns("4 1 2 2 2 2 2 2 3 2 2 1"))
|
||||||
|
{
|
||||||
|
std::cout<<"[test_all_cases_l_shape case 4] ERROR: ";
|
||||||
|
std::cout<<"we obtained "; path.display_pos_and_neg_turns();
|
||||||
|
std::cout<<" instead of (4 1 2 2 2 2 2 2 3 2 2 1)"<<std::endl;
|
||||||
|
res=false;
|
||||||
|
}
|
||||||
|
|
||||||
// path.display_pos_and_neg_turns();std::cout<<std::endl;
|
// path.display_pos_and_neg_turns();std::cout<<std::endl;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,16 @@ protected:
|
||||||
if (m_current_dart!=lcc.number_of_darts())
|
if (m_current_dart!=lcc.number_of_darts())
|
||||||
{ // We want to draw only one dart
|
{ // We want to draw only one dart
|
||||||
Dart_const_handle selected_dart=lcc.darts().iterator_to(lcc.darts()[m_current_dart]);
|
Dart_const_handle selected_dart=lcc.darts().iterator_to(lcc.darts()[m_current_dart]);
|
||||||
|
if (lcc.is_dart_used(selected_dart))
|
||||||
|
{
|
||||||
compute_edge(selected_dart, CGAL::Color(255,0,0));
|
compute_edge(selected_dart, CGAL::Color(255,0,0));
|
||||||
CGAL::mark_cell<LCC, 1>(lcc, selected_dart, markedges);
|
CGAL::mark_cell<LCC, 1>(lcc, selected_dart, markedges);
|
||||||
compute_vertex(selected_dart);
|
compute_vertex(selected_dart);
|
||||||
|
|
||||||
|
if ( !m_nofaces )
|
||||||
|
{ compute_face(selected_dart); }
|
||||||
|
}
|
||||||
|
|
||||||
for (typename LCC::Dart_range::const_iterator it=lcc.darts().begin(),
|
for (typename LCC::Dart_range::const_iterator it=lcc.darts().begin(),
|
||||||
itend=lcc.darts().end(); it!=itend; ++it )
|
itend=lcc.darts().end(); it!=itend; ++it )
|
||||||
{
|
{
|
||||||
|
|
@ -246,6 +252,22 @@ protected:
|
||||||
compile_shaders();
|
compile_shaders();
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
|
else if ((e->key()==::Qt::Key_P) && (modifiers==::Qt::NoButton))
|
||||||
|
{
|
||||||
|
m_current_dart=(m_current_dart==0?lcc.number_of_darts():m_current_dart-1);
|
||||||
|
if (m_current_dart==lcc.number_of_darts())
|
||||||
|
{
|
||||||
|
displayMessage(QString("Draw all darts."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayMessage(QString("Draw dart=%1.").arg((m_current_dart)));
|
||||||
|
}
|
||||||
|
compute_elements();
|
||||||
|
initialize_buffers();
|
||||||
|
compile_shaders();
|
||||||
|
updateGL();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ Base::keyPressEvent(e); }
|
{ Base::keyPressEvent(e); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue