mirror of https://github.com/CGAL/cgal
Update open_path_homotopy example to use Surface_mesh instead of LCC.
This commit is contained in:
parent
29febf91bc
commit
6b2d9d371f
|
|
@ -1,29 +1,31 @@
|
||||||
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
|
#include <CGAL/Surface_mesh.h>
|
||||||
#include <CGAL/Linear_cell_complex_constructors.h>
|
#include <CGAL/Surface_mesh/IO.h>
|
||||||
#include <CGAL/Surface_mesh_curve_topology.h>
|
#include <CGAL/Surface_mesh_curve_topology.h>
|
||||||
#include <CGAL/Path_on_surface.h>
|
#include <CGAL/Path_on_surface.h>
|
||||||
#include <CGAL/draw_lcc_with_paths.h>
|
#include <CGAL/draw_lcc_with_paths.h>
|
||||||
|
|
||||||
typedef CGAL::Linear_cell_complex_for_combinatorial_map<2,3> LCC_3_cmap;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||||
|
typedef Kernel::Point_3 Point_3;
|
||||||
|
typedef CGAL::Surface_mesh<Point_3> SM;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void create_path_1(CGAL::Path_on_surface<LCC_3_cmap>& p)
|
void create_path_1(CGAL::Path_on_surface<SM>& p)
|
||||||
{
|
{
|
||||||
p.push_back_by_index(56); // Its starting dart
|
p.push_back_by_index(88); // Its starting dart
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
{ p.extend_positive_turn(2); } // Extend the path
|
{ p.extend_positive_turn(2); } // Extend the path
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void create_path_2(CGAL::Path_on_surface<LCC_3_cmap>& p)
|
void create_path_2(CGAL::Path_on_surface<SM>& p)
|
||||||
{
|
{
|
||||||
p.push_back_by_index(202); // Its starting dart
|
p.push_back_by_index(300); // Its starting dart
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
{ p.extend_negative_turn(2); } // Extend the path
|
{ p.extend_negative_turn(2); } // Extend the path
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void create_path_3(CGAL::Path_on_surface<LCC_3_cmap>& p)
|
void create_path_3(CGAL::Path_on_surface<SM>& p)
|
||||||
{
|
{
|
||||||
p.push_back_by_index(411); // Its starting dart
|
p.push_back_by_index(87); // Its starting dart
|
||||||
p.extend_positive_turn(1); // Extend the path
|
p.extend_positive_turn(1); // Extend the path
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
{ p.extend_positive_turn(2); }
|
{ p.extend_positive_turn(2); }
|
||||||
|
|
@ -32,15 +34,17 @@ void create_path_3(CGAL::Path_on_surface<LCC_3_cmap>& p)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
LCC_3_cmap lcc;
|
SM sm;
|
||||||
if (!CGAL::load_off(lcc, "data/double-torus-example.off"))
|
std::ifstream in("data/double-torus-example.off");
|
||||||
|
if (!in.is_open())
|
||||||
{
|
{
|
||||||
std::cout<<"ERROR reading file data/double-torus-example.off"<<std::endl;
|
std::cout<<"ERROR reading file data/double-torus-example.off"<<std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
in>>sm;
|
||||||
|
|
||||||
CGAL::Surface_mesh_curve_topology<LCC_3_cmap> smct(lcc);
|
CGAL::Surface_mesh_curve_topology<SM> smct(sm);
|
||||||
CGAL::Path_on_surface<LCC_3_cmap> p1(lcc), p2(lcc), p3(lcc);
|
CGAL::Path_on_surface<SM> p1(sm), p2(sm), p3(sm);
|
||||||
create_path_1(p1);
|
create_path_1(p1);
|
||||||
create_path_2(p2);
|
create_path_2(p2);
|
||||||
create_path_3(p3);
|
create_path_3(p3);
|
||||||
|
|
@ -49,16 +53,16 @@ int main()
|
||||||
std::cout<<"Path p1 (pink) "<<(res1?"IS":"IS NOT")
|
std::cout<<"Path p1 (pink) "<<(res1?"IS":"IS NOT")
|
||||||
<<" base point homotopic with path p2 (green)."<<std::endl;
|
<<" base point homotopic with path p2 (green)."<<std::endl;
|
||||||
|
|
||||||
bool res2=smct.are_base_point_homotopic(p1, p3);
|
bool res2=smct.are_base_point_homotopic(p2, p3);
|
||||||
std::cout<<"Path p1 (pink) "<<(res2?"IS":"IS NOT")
|
std::cout<<"Path p2 (green) "<<(res2?"IS":"IS NOT")
|
||||||
<<" base point homotopic with path p3 (orange)."<<std::endl;
|
<<" base point homotopic with path p3 (orange)."<<std::endl;
|
||||||
|
|
||||||
#ifdef CGAL_USE_BASIC_VIEWER
|
#ifdef CGAL_USE_BASIC_VIEWER
|
||||||
std::vector<CGAL::Path_on_surface<LCC_3_cmap> > paths;
|
std::vector<CGAL::Path_on_surface<SM> > paths;
|
||||||
paths.push_back(p1);
|
paths.push_back(p1);
|
||||||
paths.push_back(p2);
|
paths.push_back(p2);
|
||||||
paths.push_back(p3);
|
paths.push_back(p3);
|
||||||
CGAL::draw(lcc, paths); // Enable only if CGAL was compiled with Qt5
|
CGAL::draw(sm, paths); // Enable only if CGAL was compiled with Qt5
|
||||||
#endif // CGAL_USE_BASIC_VIEWER
|
#endif // CGAL_USE_BASIC_VIEWER
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ public:
|
||||||
|
|
||||||
/// @return true iff the ith dart can be added at the end of the path.
|
/// @return true iff the ith dart can be added at the end of the path.
|
||||||
bool can_be_pushed_by_index(std::size_t i) const
|
bool can_be_pushed_by_index(std::size_t i) const
|
||||||
{ return can_be_pushed(get_map().darts().iterator_to(get_map().darts()[i])); }
|
{ return can_be_pushed(get_map().dart_handle(i)); }
|
||||||
|
|
||||||
/// Add the given dart at the end of this path.
|
/// Add the given dart at the end of this path.
|
||||||
/// @pre can_be_pushed(dh)
|
/// @pre can_be_pushed(dh)
|
||||||
|
|
@ -200,7 +200,7 @@ public:
|
||||||
|
|
||||||
/// Add the given ith dart at the end of this path.
|
/// Add the given ith dart at the end of this path.
|
||||||
void push_back_by_index(std::size_t i)
|
void push_back_by_index(std::size_t i)
|
||||||
{ push_back(get_map().darts().iterator_to(get_map().darts()[i])); }
|
{ push_back(get_map().dart_handle(i)); }
|
||||||
|
|
||||||
|
|
||||||
Self& operator+=(const Self& other)
|
Self& operator+=(const Self& other)
|
||||||
|
|
|
||||||
|
|
@ -419,11 +419,9 @@ CMap_for_surface_mesh_curve_topology;
|
||||||
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 (p1.is_empty() || p2.is_empty()) { return false; }
|
||||||
|
|
||||||
if (!CGAL::template belong_to_same_cell<Map,0>(m_original_map,
|
if (!m_original_map.template belong_to_same_cell<0>(p1.front(), p2.front()) ||
|
||||||
p1.front(), p2.front()) ||
|
!m_original_map.template belong_to_same_cell<0>(m_original_map.other_extremity(p1.back()),
|
||||||
!CGAL::template belong_to_same_cell<Map,0>(m_original_map,
|
m_original_map.other_extremity(p2.back())))
|
||||||
m_original_map.other_extremity(p1.back()),
|
|
||||||
m_original_map.other_extremity(p2.back())))
|
|
||||||
{
|
{
|
||||||
std::cerr<<"Error: are_base_point_homotopic requires two paths that"
|
std::cerr<<"Error: are_base_point_homotopic requires two paths that"
|
||||||
<<" share the same vertices as extremities."<<std::endl;
|
<<" share the same vertices as extremities."<<std::endl;
|
||||||
|
|
@ -437,8 +435,8 @@ CMap_for_surface_mesh_curve_topology;
|
||||||
if (display_time)
|
if (display_time)
|
||||||
{ t.start(); }
|
{ t.start(); }
|
||||||
|
|
||||||
Path_on_surface<Map> path=p1;
|
Path_on_surface<Mesh> path=p1;
|
||||||
Path_on_surface<Map> path2=p2; path2.reverse();
|
Path_on_surface<Mesh> path2=p2; path2.reverse();
|
||||||
path+=path2;
|
path+=path2;
|
||||||
|
|
||||||
bool res=is_contractible(path);
|
bool res=is_contractible(path);
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ protected:
|
||||||
{
|
{
|
||||||
Point p1 = get_point(dh);
|
Point p1 = get_point(dh);
|
||||||
Dart_const_handle d2 = lcc.other_extremity(dh);
|
Dart_const_handle d2 = lcc.other_extremity(dh);
|
||||||
if (d2!=NULL)
|
if (d2!=LCC::null_handle)
|
||||||
{
|
{
|
||||||
if (m_draw_marked_darts && m_amark!=LCC::INVALID_MARK &&
|
if (m_draw_marked_darts && m_amark!=LCC::INVALID_MARK &&
|
||||||
(lcc.is_marked(dh, m_amark) || lcc.is_marked(lcc.beta(dh, 2), m_amark)))
|
(lcc.is_marked(dh, m_amark) || lcc.is_marked(lcc.beta(dh, 2), m_amark)))
|
||||||
|
|
@ -241,7 +241,7 @@ protected:
|
||||||
{
|
{
|
||||||
Point p1 = get_point(dh);
|
Point p1 = get_point(dh);
|
||||||
Dart_const_handle d2 = lcc.other_extremity(dh);
|
Dart_const_handle d2 = lcc.other_extremity(dh);
|
||||||
if (d2!=NULL)
|
if (d2!=LCC::null_handle)
|
||||||
{ add_segment(p1, get_point(d2), color); }
|
{ add_segment(p1, get_point(d2), color); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue