mirror of https://github.com/CGAL/cgal
Update lcc viewer with path to deal with Surface mesh and Polyhedron
This commit is contained in:
parent
260b3e54e3
commit
afa2417c16
|
|
@ -68,6 +68,7 @@ public:
|
||||||
|
|
||||||
/// The dimension of the combinatorial map.
|
/// The dimension of the combinatorial map.
|
||||||
static const unsigned int dimension=2;
|
static const unsigned int dimension=2;
|
||||||
|
static const unsigned int ambient_dimension=3;
|
||||||
|
|
||||||
typedef typename boost::graph_traits<HEG>::vertex_descriptor vertex_descriptor;
|
typedef typename boost::graph_traits<HEG>::vertex_descriptor vertex_descriptor;
|
||||||
typedef typename boost::graph_traits<HEG>::edge_descriptor edge_descriptor;
|
typedef typename boost::graph_traits<HEG>::edge_descriptor edge_descriptor;
|
||||||
|
|
@ -826,6 +827,49 @@ protected:
|
||||||
storage_type m_map;
|
storage_type m_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class Mesh_>
|
||||||
|
struct Get_traits
|
||||||
|
{
|
||||||
|
typedef Mesh_ Mesh;
|
||||||
|
typedef typename Mesh::Traits Kernel;
|
||||||
|
typedef typename Mesh::Point Point;
|
||||||
|
typedef typename Mesh::Vector Vector;
|
||||||
|
|
||||||
|
template<class Dart_handle>
|
||||||
|
static const Point& get_point(const Mesh& m, Dart_handle dh)
|
||||||
|
{ return m.point(dh); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class P>
|
||||||
|
struct Get_traits<CGAL::Surface_mesh<P> >
|
||||||
|
{
|
||||||
|
typedef CGAL::Surface_mesh<P> Mesh;
|
||||||
|
typedef typename CGAL::Kernel_traits<P>::Kernel Kernel;
|
||||||
|
typedef typename Kernel::Point_3 Point;
|
||||||
|
typedef typename Kernel::Vector_3 Vector;
|
||||||
|
|
||||||
|
template<class Dart_handle>
|
||||||
|
static const Point& get_point(const Mesh& m, Dart_handle dh)
|
||||||
|
{ return m.point(m.source(dh)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class PolyhedronTraits_3,
|
||||||
|
class PolyhedronItems_3,
|
||||||
|
template<class T, class I, class A> class T_HDS,
|
||||||
|
class Alloc>
|
||||||
|
struct Get_traits<CGAL::Polyhedron_3<PolyhedronTraits_3,
|
||||||
|
PolyhedronItems_3, T_HDS, Alloc> >
|
||||||
|
{
|
||||||
|
typedef CGAL::Polyhedron_3<PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc> Mesh;
|
||||||
|
typedef PolyhedronTraits_3 Kernel;
|
||||||
|
typedef typename Kernel::Point_3 Point;
|
||||||
|
typedef typename Kernel::Vector_3 Vector;
|
||||||
|
|
||||||
|
template<class Dart_handle>
|
||||||
|
static const Point& get_point(const Mesh& /*m*/, Dart_handle dh)
|
||||||
|
{ return dh->vertex()->point(); }
|
||||||
|
};
|
||||||
|
|
||||||
} // Namespace CGAL
|
} // Namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_FACE_GRAPH_WRAPPER_H //
|
#endif // CGAL_FACE_GRAPH_WRAPPER_H //
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2017 CNRS and LIRIS' Establishments (France).
|
// Copyright (c) 2017 CNRS and LIRIS' Establishments (France).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||||
|
|
@ -30,6 +30,24 @@
|
||||||
namespace CGAL
|
namespace CGAL
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<class Mesh, class Kernel>
|
||||||
|
struct LCC_geom_utils<CGAL::Face_graph_wrapper<Mesh>, Kernel, 3>
|
||||||
|
{
|
||||||
|
static typename Kernel::Vector_3
|
||||||
|
get_vertex_normal(const CGAL::Face_graph_wrapper<Mesh>& mesh,
|
||||||
|
typename CGAL::Face_graph_wrapper<Mesh>::Dart_const_handle dh)
|
||||||
|
{
|
||||||
|
typename Kernel::Vector_3 n; // TODO =
|
||||||
|
// we can use mesh.get_fg() to retreine the initial mesh
|
||||||
|
//internal::Geom_utils<typename LCC::Traits>::
|
||||||
|
//get_local_vector(CGAL::compute_normal_of_cell_0<LCC>(lcc,dh));
|
||||||
|
n = n/(CGAL::sqrt(n*n));
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Viewer class for LCC with paths.
|
// Viewer class for LCC with paths.
|
||||||
template<class Mesh, class DrawingFunctorLCC>
|
template<class Mesh, class DrawingFunctorLCC>
|
||||||
class LCC_with_path_viewer : public Basic_viewer_qt
|
class LCC_with_path_viewer : public Basic_viewer_qt
|
||||||
|
|
@ -37,9 +55,9 @@ class LCC_with_path_viewer : public Basic_viewer_qt
|
||||||
typedef Basic_viewer_qt Base;
|
typedef Basic_viewer_qt Base;
|
||||||
typedef typename Get_map<Mesh, Mesh>::type LCC;
|
typedef typename Get_map<Mesh, Mesh>::type LCC;
|
||||||
typedef typename LCC::Dart_const_handle Dart_const_handle;
|
typedef typename LCC::Dart_const_handle Dart_const_handle;
|
||||||
typedef typename CGAL::Kernel_traits<typename LCC::Point_3>::Kernel Kernel;
|
typedef typename CGAL::Get_traits<Mesh>::Kernel Kernel;
|
||||||
typedef typename Kernel::Point_3 Point;
|
typedef typename CGAL::Get_traits<Mesh>::Point Point;
|
||||||
typedef typename Kernel::Vector_3 Vector;
|
typedef typename CGAL::Get_traits<Mesh>::Vector Vector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Construct the viewer.
|
/// Construct the viewer.
|
||||||
|
|
@ -49,11 +67,12 @@ public:
|
||||||
/// usefull for very big object where this time could be long)
|
/// usefull for very big object where this time could be long)
|
||||||
LCC_with_path_viewer(QWidget* parent,
|
LCC_with_path_viewer(QWidget* parent,
|
||||||
const Mesh& amesh,
|
const Mesh& amesh,
|
||||||
const std::vector<Path_on_surface<LCC> >* paths=NULL,
|
const std::vector<Path_on_surface<Mesh> >* paths=NULL,
|
||||||
std::size_t amark=LCC::INVALID_MARK,
|
std::size_t amark=LCC::INVALID_MARK,
|
||||||
const char* title="", bool anofaces=false,
|
const char* title="", bool anofaces=false,
|
||||||
const DrawingFunctorLCC& drawing_functor=DrawingFunctorLCC()) :
|
const DrawingFunctorLCC& drawing_functor=DrawingFunctorLCC()) :
|
||||||
Base(parent, title, true, true, true, false, true),
|
Base(parent, title, true, true, true, false, true),
|
||||||
|
mesh(amesh),
|
||||||
lcc(amesh),
|
lcc(amesh),
|
||||||
m_nofaces(anofaces),
|
m_nofaces(anofaces),
|
||||||
m_drawing_functor(drawing_functor),
|
m_drawing_functor(drawing_functor),
|
||||||
|
|
@ -68,6 +87,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
const Point& get_point(Dart_const_handle dh) const
|
||||||
|
{ return CGAL::Get_traits<Mesh>::get_point(mesh, dh); }
|
||||||
|
|
||||||
void compute_elements()
|
void compute_elements()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
@ -78,9 +100,9 @@ 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]);
|
if (lcc.darts().is_used(m_current_dart))
|
||||||
if (lcc.is_dart_used(selected_dart))
|
|
||||||
{
|
{
|
||||||
|
Dart_const_handle selected_dart=lcc.dart_handle(m_current_dart);
|
||||||
compute_edge(selected_dart, CGAL::Color(255,0,0));
|
compute_edge(selected_dart, CGAL::Color(255,0,0));
|
||||||
lcc.template mark_cell<1>(selected_dart, markedges);
|
lcc.template mark_cell<1>(selected_dart, markedges);
|
||||||
compute_vertex(selected_dart);
|
compute_vertex(selected_dart);
|
||||||
|
|
@ -156,7 +178,7 @@ protected:
|
||||||
cur=dh;
|
cur=dh;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
add_point_in_face(lcc.point(cur),
|
add_point_in_face(get_point(cur),
|
||||||
LCC_geom_utils<LCC, Local_kernel>::
|
LCC_geom_utils<LCC, Local_kernel>::
|
||||||
get_vertex_normal(lcc, cur));
|
get_vertex_normal(lcc, cur));
|
||||||
cur=lcc.next(cur);
|
cur=lcc.next(cur);
|
||||||
|
|
@ -168,28 +190,28 @@ protected:
|
||||||
|
|
||||||
void compute_edge(Dart_const_handle dh)
|
void compute_edge(Dart_const_handle dh)
|
||||||
{
|
{
|
||||||
Point p1 = lcc.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!=NULL)
|
||||||
{
|
{
|
||||||
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)))
|
||||||
{ add_segment(p1, lcc.point(d2), CGAL::Color(0, 0, 255)); }
|
{ add_segment(p1, get_point(d2), CGAL::Color(0, 0, 255)); }
|
||||||
else
|
else
|
||||||
{ add_segment(p1, lcc.point(d2)); }
|
{ add_segment(p1, get_point(d2)); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void compute_edge(Dart_const_handle dh, const CGAL::Color& color)
|
void compute_edge(Dart_const_handle dh, const CGAL::Color& color)
|
||||||
{
|
{
|
||||||
Point p1 = lcc.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!=NULL)
|
||||||
{ add_segment(p1, lcc.point(d2), color); }
|
{ add_segment(p1, get_point(d2), color); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void compute_vertex(Dart_const_handle dh)
|
void compute_vertex(Dart_const_handle dh)
|
||||||
{ add_point(lcc.point(dh)); }
|
{ add_point(get_point(dh)); }
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *e)
|
virtual void keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
|
|
@ -262,7 +284,7 @@ protected:
|
||||||
CGAL::Random random(i);
|
CGAL::Random random(i);
|
||||||
CGAL::Color color=get_random_color(random);
|
CGAL::Color color=get_random_color(random);
|
||||||
|
|
||||||
add_point(lcc.point((*m_paths)[i].get_ith_dart(0)), color);
|
add_point(get_point((*m_paths)[i].get_ith_dart(0)), color);
|
||||||
for (unsigned int j=0; j<(*m_paths)[i].length(); ++j)
|
for (unsigned int j=0; j<(*m_paths)[i].length(); ++j)
|
||||||
{
|
{
|
||||||
if ( !lcc.is_marked( (*m_paths)[i].get_ith_dart(j), amark) )
|
if ( !lcc.is_marked( (*m_paths)[i].get_ith_dart(j), amark) )
|
||||||
|
|
@ -274,20 +296,21 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const typename Get_map<LCC, LCC>::storage_type lcc;
|
const Mesh& mesh;
|
||||||
|
const typename Get_map<Mesh, Mesh>::storage_type lcc;
|
||||||
bool m_nofaces;
|
bool m_nofaces;
|
||||||
const DrawingFunctorLCC& m_drawing_functor;
|
const DrawingFunctorLCC& m_drawing_functor;
|
||||||
const std::vector<Path_on_surface<LCC> >* m_paths;
|
const std::vector<Path_on_surface<Mesh> >* m_paths;
|
||||||
unsigned int m_current_path;
|
unsigned int m_current_path;
|
||||||
unsigned int m_current_dart;
|
unsigned int m_current_dart;
|
||||||
bool m_draw_marked_darts;
|
bool m_draw_marked_darts;
|
||||||
std::size_t m_amark; // If !=INVALID_MARK, show darts marked with this mark
|
std::size_t m_amark; // If !=INVALID_MARK, show darts marked with this mark
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class LCC, class DrawingFunctor>
|
template<class Mesh, class DrawingFunctor>
|
||||||
void draw(const LCC& alcc,
|
void draw(const Mesh& alcc,
|
||||||
const std::vector<Path_on_surface<LCC> >& paths,
|
const std::vector<Path_on_surface<Mesh> >& paths,
|
||||||
const char* title="LCC Viewer",
|
const char* title="Mesh Viewer",
|
||||||
std::size_t amark=-1,
|
std::size_t amark=-1,
|
||||||
bool nofill=false,
|
bool nofill=false,
|
||||||
const DrawingFunctor& drawing_functor=DrawingFunctor())
|
const DrawingFunctor& drawing_functor=DrawingFunctor())
|
||||||
|
|
@ -303,7 +326,7 @@ void draw(const LCC& alcc,
|
||||||
int argc=1;
|
int argc=1;
|
||||||
const char* argv[2]={"lccviewer","\0"};
|
const char* argv[2]={"lccviewer","\0"};
|
||||||
QApplication app(argc,const_cast<char**>(argv));
|
QApplication app(argc,const_cast<char**>(argv));
|
||||||
LCC_with_path_viewer<LCC, DrawingFunctor> mainwindow(app.activeWindow(),
|
LCC_with_path_viewer<Mesh, DrawingFunctor> mainwindow(app.activeWindow(),
|
||||||
alcc, &paths, amark,
|
alcc, &paths, amark,
|
||||||
title, nofill,
|
title, nofill,
|
||||||
drawing_functor);
|
drawing_functor);
|
||||||
|
|
@ -312,15 +335,15 @@ void draw(const LCC& alcc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class LCC>
|
template<class Mesh>
|
||||||
void draw(const LCC& alcc,
|
void draw(const Mesh& alcc,
|
||||||
const std::vector<Path_on_surface<LCC> >& paths,
|
const std::vector<Path_on_surface<Mesh> >& paths,
|
||||||
const char* title="LCC Viewer",
|
const char* title="LCC Viewer",
|
||||||
std::size_t amark=-1,
|
std::size_t amark=-1,
|
||||||
bool nofill=false)
|
bool nofill=false)
|
||||||
{
|
{
|
||||||
DefaultDrawingFunctorLCC f;
|
DefaultDrawingFunctorLCC f;
|
||||||
return draw<LCC, DefaultDrawingFunctorLCC>(alcc, paths, title,
|
return draw<Mesh, DefaultDrawingFunctorLCC>(alcc, paths, title,
|
||||||
amark, nofill, f);
|
amark, nofill, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue