Update examples

This commit is contained in:
Guillaume Damiand 2020-03-27 13:01:34 +01:00
parent 6e5f8ef934
commit 2fd672f852
6 changed files with 256 additions and 214 deletions

View File

@ -27,17 +27,17 @@ endif()
set(SOURCE_FILES
basic_example_surface_mesh_topology.cpp
basic_example_torus.cpp
edgewidth_surface_mesh.cpp
facewidth_on_unweighted_map.cpp
map_2_constructor.cpp
open_path_homotopy.cpp
path_homotopy.cpp
path_homotopy_with_symbols.cpp
path_homotopy_with_symbols_2.cpp
surface_mesh_topology_with_sm_and_polyhedron.cpp
shortest_noncontractible_cycle_through_a_vertex.cpp
shortest_noncontractible_cycle_using_BFS.cpp
surface_mesh_topology_with_sm_and_polyhedron.cpp
unsew_edgewidth_repeatedly.cpp
edgewidth_surface_mesh.cpp
facewidth_on_unweighted_map.cpp
)
foreach(cppfile ${SOURCE_FILES})
@ -46,11 +46,10 @@ endforeach()
if(CGAL_Qt5_FOUND)
target_link_libraries(basic_example_surface_mesh_topology PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(basic_example_torus PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(basic_example_torus PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(facewidth_on_unweighted_map PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(open_path_homotopy PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(path_homotopy PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(surface_mesh_topology_with_sm_and_polyhedron PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(unsew_edgewidth_repeatedly PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(shortest_noncontractible_cycle_through_a_vertex PUBLIC CGAL::CGAL_Qt5)
target_link_libraries(shortest_noncontractible_cycle_using_BFS PUBLIC CGAL::CGAL_Qt5)
endif()

View File

@ -5,53 +5,58 @@
#include <CGAL/Path_on_surface.h>
#include <CGAL/squared_distance_3.h>
using Kernel = CGAL::Simple_cartesian<double>;
using Point = Kernel::Point_3;
using Mesh = CGAL::Surface_mesh<Point>;
using Path_on_surface = CGAL::Surface_mesh_topology::Path_on_surface<Mesh>;
using CST = CGAL::Surface_mesh_topology::Curves_on_surface_topology<Mesh>;
using Kernel =CGAL::Simple_cartesian<double>;
using Point =Kernel::Point_3;
using Mesh =CGAL::Surface_mesh<Point>;
using Path_on_surface=CGAL::Surface_mesh_topology::Path_on_surface<Mesh>;
using CST =CGAL::Surface_mesh_topology::Curves_on_surface_topology<Mesh>;
struct Weight_functor {
using Weight_t = double;
struct Weight_functor
{
using Weight_t=double;
Weight_functor(const Mesh& mesh) : m_mesh(mesh) {}
double operator()(Mesh::Halfedge_index he) const {
Point A = m_mesh.point(m_mesh.vertex(m_mesh.edge(he), 0));
Point B = m_mesh.point(m_mesh.vertex(m_mesh.edge(he), 1));
double operator()(Mesh::Halfedge_index he) const
{
const Point& A=m_mesh.point(m_mesh.vertex(m_mesh.edge(he), 0));
const Point& B=m_mesh.point(m_mesh.vertex(m_mesh.edge(he), 1));
return CGAL::sqrt(CGAL::squared_distance(A, B));
}
private:
Mesh m_mesh;
const Mesh& m_mesh;
};
int main(int argc, char* argv[]) {
std::cout << "Program edgewidth_surface_mesh started.\n";
Mesh sm;
std::ifstream inp ((argc > 1) ? argv[1] : "data/3torus.off");
if (inp.fail()) {
std::cout << "Cannot read file. Exiting program\n";
int main(int argc, char* argv[])
{
std::cout<<"Program edgewidth_surface_mesh started."<<std::endl;
std::string filename("data/3torus.off");
if (argc>1) { filename=argv[1]; }
std::ifstream inp(filename);
if (inp.fail())
{
std::cout<<"Cannot read file '"<<filename<<"'. Exiting program"<<std::endl;
return EXIT_FAILURE;
}
inp >> sm;
std::cout << "File loaded. Running the main program...\n";
Mesh sm;
inp>>sm;
std::cout<<"File '"<<filename<<"' loaded. Running the main program..."<<std::endl;
Weight_functor wf(sm);
CST cst(sm);
Weight_functor wf(sm);
CST cst(sm);
std::cout << "Finding edge-width of the mesh...\n";
Path_on_surface cycle = cst.compute_edgewidth(wf);
if (cycle.length() == 0) {
std::cout << " Cannot find edge-width. Stop.\n";
return 0;
}
double cycle_length = 0;
for (int i = 0; i < cycle.length(); ++i) {
cycle_length += wf(cycle[i]);
}
std::cout<<"Finding edge-width of the mesh..."<<std::endl;
Path_on_surface cycle=cst.compute_edgewidth(wf);
if (cycle.length()==0)
{ std::cout<<" Cannot find edge-width. Stop."<<std::endl; }
else
{
double cycle_length=0;
for (int i=0; i<cycle.length(); ++i)
{ cycle_length+=wf(cycle[i]); }
std::cout << " Number of edges in cycle: " << cycle.length() << std::endl;
std::cout << " Cycle length: " << cycle_length << std::endl;
std::cout << " Root: " << sm.point(sm.vertex(sm.edge(cycle[0]), 0)) << std::endl;
std::cout<<" Number of edges in cycle: "<<cycle.length()<<std::endl;
std::cout<<" Cycle length: "<<cycle_length<<std::endl;
std::cout<<" Root: "<<sm.point(sm.vertex(sm.edge(cycle[0]), 0))<<std::endl;
}
return EXIT_SUCCESS;
}
}

View File

@ -6,16 +6,16 @@
#include <CGAL/Curves_on_surface_topology.h>
#include <CGAL/Path_on_surface.h>
#include <CGAL/draw_linear_cell_complex.h>
#define CGAL_USE_BASIC_VIEWER 1
using LCC_3 =CGAL::Linear_cell_complex_for_combinatorial_map<2, 3>;
using CST =CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
using Path_on_surface=CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using Dart_handle =LCC_3::Dart_handle;
using LCC_3 = CGAL::Linear_cell_complex_for_combinatorial_map<2, 3>;
using CST = CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
using Path_on_surface = CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using Dart_handle = LCC_3::Dart_handle;
struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC {
Draw_functor(LCC_3::size_type amark1, LCC_3::size_type amark2) : m_vertex_mark(amark1), m_face_mark(amark2)
struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC
{
Draw_functor(LCC_3::size_type amark1, LCC_3::size_type amark2) :
m_vertex_mark(amark1), m_face_mark(amark2)
{}
template<typename LCC>
@ -23,83 +23,84 @@ struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC {
{ return alcc.is_marked(dh, m_vertex_mark); }
template<typename LCC>
CGAL::Color vertex_color(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const
CGAL::Color vertex_color(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const
{ return CGAL::Color(0, 255, 0); }
template<typename LCC>
bool colored_edge(const LCC& alcc, typename LCC::Dart_const_handle dh) const { return false; }
bool colored_edge(const LCC& alcc, typename LCC::Dart_const_handle dh) const
{ return false; }
template<typename LCC>
CGAL::Color edge_color(const LCC& /* alcc*/, typename LCC::Dart_const_handle /* dh */) const
CGAL::Color edge_color(const LCC& /* alcc*/,
typename LCC::Dart_const_handle /* dh */) const
{ return CGAL::Color(0, 0, 255); }
template<typename LCC>
bool colored_face(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const {return true;}
bool colored_face(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const
{return true;}
template<typename LCC>
CGAL::Color face_color(const LCC& alcc, typename LCC::Dart_const_handle dh) const
{ return alcc.is_marked(dh, m_face_mark) ? CGAL::Color(255, 0, 0) : CGAL::Color(211, 211, 211); }
{ return alcc.is_marked(dh, m_face_mark)?CGAL::Color(255, 0, 0)
:CGAL::Color(211, 211, 211); }
template<typename LCC>
bool colored_volume(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const { return false; }
bool colored_volume(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const
{ return false; }
LCC_3::size_type m_vertex_mark, m_face_mark;
};
LCC_3 lcc;
int main(int argc, char* argv[])
{
std::cout << "Program facewidth_on_unweighted_map started.\n";
std::ifstream inp;
if (argc == 1) inp = std::ifstream("data/double-torus.off");
else inp = std::ifstream(argv[1]);
if (inp.fail()) {
std::cout << "Cannot read file. Exiting program\n";
std::cout<<"Program facewidth_on_unweighted_map started."<<std::endl;
std::string filename("data/double-torus.off");
if (argc>1) { filename=argv[1]; }
std::ifstream inp(filename);
if (inp.fail())
{
std::cout<<"Cannot read file '"<<filename<<"'. Exiting program"<<std::endl;
return EXIT_FAILURE;
}
LCC_3 lcc;
CGAL::load_off(lcc, inp);
std::cout << "File loaded. Running the main program...\n";
std::cout<<"File '"<<filename<<"' loaded. Running the main program..."<<std::endl;
CST cst(lcc);
std::cout<<"Finding the facewidth..."<<std::endl;
std::vector<Dart_handle> cycle = cst.compute_facewidth();
std::cout << "Finding the facewidth...\n";
if (cycle.size() == 0) {
std::cout << " Cannot find such cycle. Stop.\n";
return 0;
}
LCC_3::size_type vertex_mark = lcc.get_new_mark();
LCC_3::size_type face_mark = lcc.get_new_mark();
for (int i = 0; i < cycle.size(); ++i)
if (cycle.size()==0)
{ std::cout<<" Cannot find such cycle. Stop."<<std::endl; }
else
{
if (i % 2 == 0)
std::cout<<" Number of faces: "<<cycle.size()/2<<std::endl;
#ifdef CGAL_USE_BASIC_VIEWER
LCC_3::size_type vertex_mark = lcc.get_new_mark();
LCC_3::size_type face_mark = lcc.get_new_mark();
for (int i=0; i<cycle.size(); ++i)
{
// Color the edges of the face
for (auto dh = lcc.darts_of_cell<0>(cycle[i]).begin(),
dhend = lcc.darts_of_cell<0>(cycle[i]).end(); dh != dhend; ++dh)
{
if (!lcc.is_marked(dh, vertex_mark))
lcc.mark(dh, vertex_mark);
}
}
else
{
// Color the face
for (auto dh = lcc.darts_of_cell<2>(cycle[i]).begin(),
dhend = lcc.darts_of_cell<2>(cycle[i]).end(); dh != dhend; ++dh)
{
if (!lcc.is_marked(dh, face_mark))
lcc.mark(dh, face_mark);
if (i%2==0)
{ // Color the vertex
lcc.mark_cell<0>(cycle[i], vertex_mark);
}
else
{ // Color the face
lcc.mark_cell<2>(cycle[i], face_mark);
}
}
Draw_functor df(vertex_mark, face_mark);
CGAL::draw(lcc, "Face width", false, df);
lcc.free_mark(vertex_mark);
lcc.free_mark(face_mark);
#endif // CGAL_USE_BASIC_VIEWER
}
std::cout << " Number of faces: " << cycle.size()/2 << std::endl;
Draw_functor df(vertex_mark, face_mark);
CGAL::draw(lcc, "Hello", false, df);
lcc.free_mark(vertex_mark);
lcc.free_mark(face_mark);
return EXIT_SUCCESS;
}

View File

@ -7,53 +7,62 @@
#include <CGAL/Path_on_surface.h>
#include <CGAL/squared_distance_3.h>
using LCC_3 = CGAL::Linear_cell_complex_for_generalized_map<2, 3>;
using Dart_const_handle = LCC_3::Dart_const_handle;
using Path_on_surface = CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using CST = CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
using LCC_3 =CGAL::Linear_cell_complex_for_generalized_map<2, 3>;
using Dart_const_handle=LCC_3::Dart_const_handle;
using Dart_handle=LCC_3::Dart_handle; // TODO REMOVE
using Path_on_surface =CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using CST =CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
struct Weight_functor {
struct Weight_functor
{
Weight_functor(const LCC_3& lcc) : m_lcc(lcc) { }
using Weight_t = double;
Weight_t operator()(Dart_const_handle dh) const {
auto x = m_lcc.point_of_vertex_attribute(m_lcc.vertex_attribute(dh));
auto y = m_lcc.point_of_vertex_attribute(m_lcc.vertex_attribute(m_lcc.template alpha<0>(dh)));
using Weight_t=double;
Weight_t operator()(Dart_const_handle dh) const
{
const LCC_3::Point& x=m_lcc.point(dh);
const LCC_3::Point& y=m_lcc.point(m_lcc.alpha<0>(dh));
return CGAL::sqrt(CGAL::squared_distance(x, y));
}
private:
const LCC_3& m_lcc;
};
LCC_3 lcc;
int main(int argc, char* argv[])
{
std::cout << "Program shortest_noncontractible_cycle_through_a_vertex started.\n";
std::ifstream inp;
if (argc == 1) inp = std::ifstream("data/3torus.off");
else inp = std::ifstream(argv[1]);
if (inp.fail()) {
std::cout << "Cannot load file. Exiting program...\n";
std::cout<<"Program shortest_noncontractible_cycle_through_a_vertex started."
<<std::endl;
std::string filename("data/3torus.off");
if (argc>1) { filename=argv[1]; }
std::ifstream inp(filename);
if (inp.fail())
{
std::cout<<"Cannot read file '"<<filename<<"'. Exiting program"<<std::endl;
return EXIT_FAILURE;
}
LCC_3 lcc;
CGAL::load_off(lcc, inp);
std::cout << "File loaded. Running the main program...\n";
std::cout<<"File '"<<filename<<"' loaded. Running the main program..."<<std::endl;
CST cst(lcc);
Weight_functor wf(lcc);
CST cst(lcc);
/// Change the value of `root` to test the algorithm at another vertex
auto root = lcc.darts().begin();
std::cout << "Finding the shortest noncontractible cycle...\n";
Path_on_surface cycle = cst.compute_shortest_noncontractible_cycle_with_basepoint(root, wf);
if (cycle.length() == 0) {
std::cout << " Cannot find such cycle. Stop.\n";
return 0;
Dart_handle root=lcc.darts().begin();
std::cout<<"Finding the shortest noncontractible cycle..."<<std::endl;
Path_on_surface cycle=
cst.compute_shortest_noncontractible_cycle_with_basepoint(root, wf);
if (cycle.length()==0)
{ std::cout<<" Cannot find such cycle. Stop."<<std::endl; }
else
{
double cycle_length=0;
for (int i=0; i<cycle.length(); ++i)
{ cycle_length+=wf(cycle[i]); }
std::cout<<" Number of edges in cycle: "<<cycle.length()<<std::endl;
std::cout<<" Cycle length: "<<cycle_length<<std::endl;
std::cout<<" Root: "<<lcc.point(root)<<std::endl;
}
double cycle_length = 0;
for (int i = 0; i < cycle.length(); ++i)
cycle_length += wf(cycle[i]);
std::cout << " Number of edges in cycle: " << cycle.length() << std::endl;
std::cout << " Cycle length: " << cycle_length << std::endl;
std::cout << " Root: " << lcc.point_of_vertex_attribute(lcc.vertex_attribute(root)) << std::endl;
return EXIT_SUCCESS;
}

View File

@ -6,35 +6,40 @@
#include <CGAL/Curves_on_surface_topology.h>
#include <CGAL/Path_on_surface.h>
using LCC_3 = CGAL::Linear_cell_complex_for_combinatorial_map<2, 3>;
using CST = CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
using Path_on_surface = CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
LCC_3 lcc;
using LCC_3 =CGAL::Linear_cell_complex_for_combinatorial_map<2, 3>;
using CST =CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
using Path_on_surface=CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
int main(int argc, char* argv[])
{
std::cout << "Program shortest_noncontractible_cycle_using_BFS started.\n";
std::ifstream inp;
if (argc == 1) inp = std::ifstream("data/3torus.off");
else inp = std::ifstream(argv[1]);
if (inp.fail()) {
std::cout << "Cannot read file. Exiting program\n";
std::cout<<"Program shortest_noncontractible_cycle_using_BFS started."
<<std::endl;
std::string filename("data/3torus.off");
if (argc>1) { filename=argv[1]; }
std::ifstream inp(filename);
if (inp.fail())
{
std::cout<<"Cannot read file '"<<filename<<"'. Exiting program"<<std::endl;
return EXIT_FAILURE;
}
LCC_3 lcc;
CGAL::load_off(lcc, inp);
std::cout << "File loaded. Running the main program...\n";
CST cst(lcc);
std::cout<<"File '"<<filename<<"' loaded. Running the main program..."<<std::endl;
CST cst(lcc);
/// Change the value of `root` to test the algorithm at another vertex
auto root = lcc.darts().begin();
std::cout << "Finding the shortest noncontractible cycle...\n";
Path_on_surface cycle = cst.compute_shortest_noncontractible_cycle_with_basepoint(root);
if (cycle.length() == 0) {
std::cout << " Cannot find such cycle. Stop.\n";
return 0;
LCC_3::Dart_handle root=lcc.darts().begin();
std::cout<<"Finding the shortest noncontractible cycle..."<<std::endl;
Path_on_surface cycle=
cst.compute_shortest_noncontractible_cycle_with_basepoint(root);
if (cycle.length()==0)
{ std::cout<<" Cannot find such cycle. Stop."<<std::endl; }
else
{
std::cout<<" Number of edges in cycle: "<<cycle.length()<<std::endl;
std::cout<<" Root: "<<lcc.point(root)<<std::endl;
}
std::cout << " Number of edges in cycle: " << cycle.length() << std::endl;
std::cout << " Root: " << lcc.point_of_vertex_attribute(lcc.vertex_attribute(root)) << std::endl;
return EXIT_SUCCESS;
}

View File

@ -9,30 +9,31 @@
#include <fstream>
#include <cstdlib>
#include <unordered_set>
#define CGAL_USE_BASIC_VIEWER 1
using LCC_3 = CGAL::Linear_cell_complex_for_generalized_map<2, 3>;
using Dart_handle = LCC_3::Dart_handle;
using Dart_const_handle = LCC_3::Dart_const_handle;
using Dart_container = std::vector<Dart_handle>;
using Point = LCC_3::Point;
using Path_on_surface = CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using LCC_3 =CGAL::Linear_cell_complex_for_generalized_map<2, 3>;
using Dart_handle =LCC_3::Dart_handle;
using Dart_const_handle=LCC_3::Dart_const_handle;
using Dart_container =std::vector<Dart_handle>;
using Point =LCC_3::Point;
using Path_on_surface =CGAL::Surface_mesh_topology::Path_on_surface<LCC_3>;
using CST =CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
struct Weight_functor {
Weight_functor(const LCC_3& lcc) : m_lcc(lcc) { }
using Weight_t = double;
Weight_t operator()(Dart_const_handle dh) const {
const Point& x = m_lcc.point(dh);
const Point& y = m_lcc.point(m_lcc.template alpha<0>(dh));
struct Weight_functor
{
Weight_functor(const LCC_3& lcc) : m_lcc(lcc) {}
using Weight_t=double;
Weight_t operator()(Dart_const_handle dh) const
{
const Point& x=m_lcc.point(dh);
const Point& y=m_lcc.point(m_lcc.template alpha<0>(dh));
return CGAL::sqrt(CGAL::squared_distance(x, y));
}
private:
const LCC_3& m_lcc;
};
using CST = CGAL::Surface_mesh_topology::Curves_on_surface_topology<LCC_3>;
struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC {
struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC
{
Draw_functor(LCC_3::size_type am1, LCC_3::size_type am2) : is_root(am1),
belong_to_cycle(am2)
{}
@ -42,7 +43,8 @@ struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC {
{ return alcc.is_marked(dh, is_root); }
template<typename LCC>
CGAL::Color vertex_color(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const
CGAL::Color vertex_color(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const
{ return CGAL::Color(0,255,0); }
template<typename LCC>
@ -50,30 +52,42 @@ struct Draw_functor : public CGAL::DefaultDrawingFunctorLCC {
{ return alcc.is_marked(dh, belong_to_cycle); }
template<typename LCC>
CGAL::Color edge_color(const LCC& /* alcc*/, typename LCC::Dart_const_handle /* dh */) const
CGAL::Color edge_color(const LCC& /* alcc*/,
typename LCC::Dart_const_handle /* dh */) const
{ return CGAL::Color(0, 0, 255); }
template<typename LCC>
bool colored_face(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const {return true;}
bool colored_face(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const {return true;}
template<typename LCC>
CGAL::Color face_color(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const
CGAL::Color face_color(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const
{return CGAL::Color(211, 211, 211);}
template<typename LCC>
bool colored_volume(const LCC& /* alcc */, typename LCC::Dart_const_handle /* dh */) const { return false; }
bool colored_volume(const LCC& /* alcc */,
typename LCC::Dart_const_handle /* dh */) const { return false; }
LCC_3::size_type is_root;
LCC_3::size_type belong_to_cycle;
};
int main(int argc, char* argv[]) {
std::cout << "Program unsew_edgewidth_repeatedly started.\n";
int main(int argc, char* argv[])
{
std::cout<<"Program unsew_edgewidth_repeatedly started."<<std::endl;
std::string filename("data/double-torus.off");
if (argc>1) { filename=argv[1]; }
std::ifstream inp(filename);
if (inp.fail())
{
std::cout<<"Cannot read file '"<<filename<<"'. Exiting program"<<std::endl;
return EXIT_FAILURE;
}
LCC_3 lccoriginal, lcccopy;
std::ifstream inp;
if (argc == 1) inp = std::ifstream("data/double-torus-example.off");
else inp = std::ifstream(argv[1]);
CGAL::load_off(lccoriginal, inp);
std::cout<<"File '"<<filename<<"' loaded. Running the main program..."<<std::endl;
boost::unordered_map<Dart_handle, Dart_handle> origin_to_copy;
lcccopy.copy(lccoriginal, &origin_to_copy, NULL);
@ -82,50 +96,59 @@ int main(int argc, char* argv[]) {
LCC_3::size_type belong_to_cycle=lccoriginal.get_new_mark();
Draw_functor df(is_root, belong_to_cycle);
std::cout << "File loaded. Running the main program...\n";
for (int loop = 1; ; ++loop) {
std::cout << "Finding #" << loop << " edge-width:\n";
int loop=1;
bool cycle_exist=true;
do
{
std::cout<<"Finding #"<<loop++<<" edge-width:"<<std::endl;
Weight_functor wf(lcccopy);
CST cst(lcccopy);
Path_on_surface cycle = cst.compute_edgewidth(wf);
if (cycle.length() == 0) {
std::cout << " Cannot find edge-width. Stop.\n";
break;
}
CST cst(lcccopy);
Path_on_surface cycle=cst.compute_edgewidth(wf);
if (cycle.length()==0)
{ std::cout << " Cannot find edge-width. Stop.\n"; cycle_exist=false; }
else
{
LCC_3::size_type is_root_copy=lcccopy.get_new_mark();
LCC_3::size_type belong_to_cycle_copy=lcccopy.get_new_mark();
LCC_3::size_type is_root_copy = lcccopy.get_new_mark();
LCC_3::size_type belong_to_cycle_copy = lcccopy.get_new_mark();
lcccopy.mark_cell<0>(cycle[0], is_root_copy);
double cycle_length=0;
for (int i=0; i<cycle.length(); ++i)
{
cycle_length+=wf(cycle[i]);
if (!lcccopy.is_marked(cycle[i], belong_to_cycle_copy))
{ lcccopy.mark_cell<1>(cycle[i], belong_to_cycle_copy); }
}
lcccopy.mark_cell<0>(cycle[0], is_root_copy);
double x = 0;
for (int i = 0; i < cycle.length(); ++i) {
x += wf(cycle[i]);
if (!lcccopy.is_marked(cycle[i], belong_to_cycle_copy))
lcccopy.mark_cell<1>(cycle[i], belong_to_cycle_copy);
}
for (auto dh=lccoriginal.darts().begin(), dhend=lccoriginal.darts().end();
dh!=dhend; ++dh)
{
if (lcccopy.is_marked(origin_to_copy[dh], is_root_copy) &&
!lccoriginal.is_marked(dh, is_root))
{ lccoriginal.mark(dh, is_root); }
if (lcccopy.is_marked(origin_to_copy[dh], belong_to_cycle_copy) &&
!lccoriginal.is_marked(dh, belong_to_cycle))
{ lccoriginal.mark(dh, belong_to_cycle); }
if (lcccopy.is_marked(origin_to_copy[dh], belong_to_cycle_copy) &&
!lcccopy.is_free<2>(origin_to_copy[dh]))
{ lcccopy.unsew<2>(origin_to_copy[dh]); }
}
lcccopy.close<2>();
for (auto dh = lccoriginal.darts().begin(), dhend = lccoriginal.darts().end(); dh != dhend; ++dh) {
if (lcccopy.is_marked(origin_to_copy[dh], is_root_copy) && !lccoriginal.is_marked(dh, is_root))
lccoriginal.mark(dh, is_root);
if (lcccopy.is_marked(origin_to_copy[dh], belong_to_cycle_copy) && !lccoriginal.is_marked(dh, belong_to_cycle))
lccoriginal.mark(dh, belong_to_cycle);
if (lcccopy.is_marked(origin_to_copy[dh], belong_to_cycle_copy) && !lcccopy.is_free<2>(origin_to_copy[dh]))
lcccopy.unsew<2>(origin_to_copy[dh]);
}
lcccopy.close<2>();
lcccopy.free_mark(belong_to_cycle_copy);
lcccopy.free_mark(is_root_copy);
lcccopy.free_mark(belong_to_cycle_copy);
lcccopy.free_mark(is_root_copy);
std::cout << " Number of edges in cycle: " << cycle.length() << std::endl;
std::cout << " Cycle length: " << x << std::endl;
std::cout << " Root: " << lcccopy.point_of_vertex_attribute(lcccopy.vertex_attribute(cycle[0])) << std::endl;
std::cout<<" Number of edges in cycle: "<<cycle.length()<<std::endl;
std::cout<<" Cycle length: "<<cycle_length<<std::endl;
std::cout<<" Root: "<<lcccopy.point(cycle[0])<<std::endl;
}
}
while(cycle_exist);
CGAL::draw(lccoriginal, "Hello", false, df);
CGAL::draw(lccoriginal, "Unsew edge width repeatdly", false, df);
lccoriginal.free_mark(belong_to_cycle);
lccoriginal.free_mark(is_root);
lccoriginal.free_mark(is_root);
return EXIT_SUCCESS;
}