mirror of https://github.com/CGAL/cgal
Use proper template / variable names for BGL graphs
This commit is contained in:
parent
f9527917c2
commit
7014aa0301
|
|
@ -60,28 +60,28 @@ public:
|
|||
}
|
||||
|
||||
/// Construct the viewer.
|
||||
/// @param amesh the surface mesh to view
|
||||
/// @param g the face graph to view
|
||||
/// @param title the title of the window
|
||||
/// @param anofaces if true, do not draw faces (faces are not computed; this can be
|
||||
/// usefull for very big object where this time could be long)
|
||||
template <typename SM>
|
||||
template <typename Graph>
|
||||
SimpleFaceGraphViewerQt(QWidget* parent,
|
||||
const SM& amesh,
|
||||
const char* title="Basic Surface_mesh Viewer",
|
||||
const Graph& g,
|
||||
const char* title="Basic Face Graph Viewer",
|
||||
bool anofaces=false) :
|
||||
SimpleFaceGraphViewerQt(parent, amesh, title, anofaces, DefaultColorFunctorFaceGraph())
|
||||
SimpleFaceGraphViewerQt(parent, g, title, anofaces, DefaultColorFunctorFaceGraph())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename SM, typename ColorFunctor>
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
SimpleFaceGraphViewerQt(QWidget* parent,
|
||||
const SM& amesh,
|
||||
const Graph& g,
|
||||
const char* title,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor) :
|
||||
// First draw: no vertex; edges, faces; mono-color; inverse normal
|
||||
Base(parent, title, false, true, true, true, false),
|
||||
m_compute_elements_impl(compute_elements_functor(amesh, anofaces, fcolor))
|
||||
m_compute_elements_impl(compute_elements_functor(g, anofaces, fcolor))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -94,43 +94,42 @@ public:
|
|||
m_compute_elements_impl();
|
||||
}
|
||||
|
||||
template <typename SM, typename ColorFunctor>
|
||||
void set_face_graph(const SM& amesh,
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
void set_face_graph(const Graph& g,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor) {
|
||||
m_compute_elements_impl = compute_elements_functor(amesh, anofaces, fcolor);
|
||||
m_compute_elements_impl = compute_elements_functor(g, anofaces, fcolor);
|
||||
}
|
||||
|
||||
template <typename SM, typename ColorFunctor>
|
||||
void set_face_graph(const SM& amesh,
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
void set_face_graph(const Graph& g,
|
||||
bool anofaces=false) {
|
||||
set_mesh(amesh, anofaces, DefaultColorFunctorFaceGraph());
|
||||
set_mesh(g, anofaces, DefaultColorFunctorFaceGraph());
|
||||
}
|
||||
protected:
|
||||
template <typename SM, typename ColorFunctor>
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
std::function<void()>
|
||||
compute_elements_functor(const SM& sm,
|
||||
compute_elements_functor(const Graph& g,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor)
|
||||
{
|
||||
using Point =
|
||||
typename boost::property_map_value<SM, CGAL::vertex_point_t>::type;
|
||||
using Point = typename boost::property_map_value<Graph, CGAL::vertex_point_t>::type;
|
||||
using Kernel = typename CGAL::Kernel_traits<Point>::Kernel;
|
||||
using Vector = typename Kernel::Vector_3;
|
||||
|
||||
auto vnormals = get(CGAL::dynamic_vertex_property_t<Vector>(), sm);
|
||||
auto point_pmap = get(CGAL::vertex_point, sm);
|
||||
for (auto v : vertices(sm))
|
||||
auto vnormals = get(CGAL::dynamic_vertex_property_t<Vector>(), g);
|
||||
auto point_pmap = get(CGAL::vertex_point, g);
|
||||
for (auto v : vertices(g))
|
||||
{
|
||||
Vector n(NULL_VECTOR);
|
||||
int i=0;
|
||||
for (auto h : halfedges_around_target(halfedge(v, sm), sm))
|
||||
for (auto h : halfedges_around_target(halfedge(v, g), g))
|
||||
{
|
||||
if (!is_border(h, sm))
|
||||
if (!is_border(h, g))
|
||||
{
|
||||
Vector ni = CGAL::cross_product(
|
||||
Vector(get(point_pmap, source(h, sm)), get(point_pmap, target(h, sm))),
|
||||
Vector(get(point_pmap, target(h, sm)), get(point_pmap, target(next(h, sm), sm))));
|
||||
Vector(get(point_pmap, source(h, g)), get(point_pmap, target(h, g))),
|
||||
Vector(get(point_pmap, target(h, g)), get(point_pmap, target(next(h, g), g))));
|
||||
if (ni != NULL_VECTOR)
|
||||
{
|
||||
n+=ni;
|
||||
|
|
@ -143,25 +142,25 @@ protected:
|
|||
|
||||
// This function return a lambda expression, type-erased in a
|
||||
// `std::function<void()>` object.
|
||||
return [this, &sm, vnormals, anofaces, fcolor, point_pmap]()
|
||||
return [this, &g, vnormals, anofaces, fcolor, point_pmap]()
|
||||
{
|
||||
this->clear();
|
||||
|
||||
if (!anofaces)
|
||||
{
|
||||
for (auto fh: faces(sm))
|
||||
for (auto fh: faces(g))
|
||||
{
|
||||
if (fh!=boost::graph_traits<SM>::null_face())
|
||||
if (fh!=boost::graph_traits<Graph>::null_face()) // @fixme useless
|
||||
{
|
||||
CGAL::IO::Color c=fcolor(sm, fh);
|
||||
const CGAL::IO::Color& c = fcolor(g, fh);
|
||||
face_begin(c);
|
||||
auto hd=halfedge(fh, sm);
|
||||
auto hd=halfedge(fh, g);
|
||||
const auto first_hd = hd;
|
||||
do
|
||||
{
|
||||
auto v = source(hd, sm);
|
||||
auto v = source(hd, g);
|
||||
add_point_in_face(get(point_pmap, v), get(vnormals, v));
|
||||
hd=next(hd, sm);
|
||||
hd=next(hd, g);
|
||||
}
|
||||
while(hd!=first_hd);
|
||||
face_end();
|
||||
|
|
@ -169,17 +168,17 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
for (auto e: edges(sm))
|
||||
for (auto e: edges(g))
|
||||
{
|
||||
CGAL::IO::Color c=fcolor(sm, e);
|
||||
add_segment(get(point_pmap, source(halfedge(e, sm), sm)),
|
||||
get(point_pmap, target(halfedge(e, sm), sm)),
|
||||
const CGAL::IO::Color& c = fcolor(g, e);
|
||||
add_segment(get(point_pmap, source(halfedge(e, g), g)),
|
||||
get(point_pmap, target(halfedge(e, g), g)),
|
||||
c);
|
||||
}
|
||||
|
||||
for (auto v: vertices(sm))
|
||||
for (auto v: vertices(g))
|
||||
{
|
||||
CGAL::IO::Color c=fcolor(sm, v);
|
||||
const CGAL::IO::Color& c = fcolor(g, v);
|
||||
this->add_point(get(point_pmap, v), c);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue