Update drawing functor and lcc demo

This commit is contained in:
Guillaume Damiand 2022-09-12 15:42:07 +02:00
parent 6076849ea5
commit 974a4accf1
4 changed files with 238 additions and 423 deletions

View File

@ -17,26 +17,37 @@
Viewer::Viewer(QWidget *parent)
: Base(parent, m_graphic_buffer, ""),
m_nofaces_(false), m_random_face_color_(false),
m_previous_scene_empty(true) {}
m_previous_scene_empty(true)
{
m_drawing_functor.volume_color=[](const LCC & alcc,
Dart_const_handle dh)->CGAL::IO::Color
{ return alcc.template info<3>(dh).color(); };
void Viewer::setScene(Scene *scene_, bool doredraw) {
m_drawing_functor.colored_volume=[](const LCC &, Dart_const_handle)->bool
{ return true; };
m_drawing_functor.draw_volume=[](const LCC & alcc, Dart_const_handle dh)->bool
{ return alcc.template info<3>(dh).is_visible(); };
m_drawing_functor.volume_wireframe=[](const LCC& alcc, Dart_const_handle dh)->bool
{ return !(alcc.template info<3>(dh).is_filled()); };
}
void Viewer::setScene(Scene *scene_, bool doredraw)
{
scene = scene_;
if (scene->lcc != nullptr) {
CGAL::add_in_graphic_buffer_lcc(gBuffer, m_drawing_functor_, scene->lcc, m_nofaces_,
m_random_face_color_);
if (scene->lcc!=nullptr)
{ CGAL::add_in_graphic_buffer_lcc(gBuffer, m_drawing_functor, scene->lcc); }
if (doredraw)
{ Base::redraw(); }
}
if (doredraw) {
Base::redraw();
}
}
void Viewer::sceneChanged() {
void Viewer::sceneChanged()
{
gBuffer.clear();
CGAL::add_in_graphic_buffer_lcc(gBuffer, m_drawing_functor_, scene->lcc,
m_nofaces_, m_random_face_color_);
CGAL::add_in_graphic_buffer_lcc(gBuffer, m_drawing_functor, scene->lcc);
this->camera()->setSceneBoundingBox(
CGAL::qglviewer::Vec(gBuffer.get_bounding_box().xmin(),
@ -46,15 +57,14 @@ void Viewer::sceneChanged() {
gBuffer.get_bounding_box().ymax(),
gBuffer.get_bounding_box().zmax()));
Base::redraw();
if (m_previous_scene_empty) {
this->showEntireScene();
if (m_previous_scene_empty)
{ this->showEntireScene(); }
m_previous_scene_empty=scene->lcc->is_empty(); // for the next call to sceneChanged
}
m_previous_scene_empty =
scene->lcc->is_empty(); // for the next call to sceneChanged
}
void Viewer::keyPressEvent(QKeyEvent *e) {
void Viewer::keyPressEvent(QKeyEvent *e)
{
// const Qt::KeyboardModifiers modifiers = e->modifiers();
Base::keyPressEvent(e);
}

View File

@ -21,93 +21,6 @@
#include <CGAL/draw_linear_cell_complex.h>
#include <CGAL/Qt/Basic_viewer_qt.h>
// Functor used by SimpleLCCViewerQt to colorize of not elements.
struct MyDrawingFunctorLCC
{
/// @return true iff the volume containing dh is drawn.
template<typename LCC>
bool draw_volume(const LCC& alcc,
typename LCC::Dart_const_handle dh) const
{ return alcc.template info<3>(dh).is_visible(); }
/// @return true iff the face containing dh is drawn.
template<typename LCC>
bool draw_face(const LCC&,
typename LCC::Dart_const_handle) const
{ return true; }
/// @return true iff the edge containing dh is drawn.
template<typename LCC>
bool draw_edge(const LCC&,
typename LCC::Dart_const_handle) const
{ return true; }
/// @return true iff the vertex containing dh is drawn.
template<typename LCC>
bool draw_vertex(const LCC&,
typename LCC::Dart_const_handle) const
{ return true; }
/// @return true iff the volume containing dh is drawn in wireframe.
template<typename LCC>
bool volume_wireframe(const LCC& alcc,
typename LCC::Dart_const_handle dh) const
{ return !(alcc.template info<3>(dh).is_filled()); }
/// @return true iff the face containing dh is drawn in wireframe.
template<typename LCC>
bool face_wireframe(const LCC&,
typename LCC::Dart_const_handle) const
{ return false; }
/// @return true iff the volume containing dh is colored.
template<typename LCC>
bool colored_volume(const LCC&,
typename LCC::Dart_const_handle) const
{ return true; }
/// @return true iff the face containing dh is colored.
/// if we have also colored_volume(alcc, dh), the volume color is
/// ignored and only the face color is considered.
template<typename LCC>
bool colored_face(const LCC&,
typename LCC::Dart_const_handle) const
{ return false; }
/// @return true iff the edge containing dh is colored.
template<typename LCC>
bool colored_edge(const LCC&,
typename LCC::Dart_const_handle) const
{ return false; }
/// @return true iff the vertex containing dh is colored.
template<typename LCC>
bool colored_vertex(const LCC&,
typename LCC::Dart_const_handle) const
{ return false; }
/// @return the color of the volume containing dh
/// used only if colored_volume(alcc, dh) and !colored_face(alcc, dh)
template<typename LCC>
CGAL::IO::Color volume_color(const LCC& alcc,
typename LCC::Dart_const_handle dh) const
{ return alcc.template info<3>(dh).color(); }
/// @return the color of the face containing dh
/// used only if colored_face(alcc, dh)
template<typename LCC>
CGAL::IO::Color face_color(const LCC& alcc,
typename LCC::Dart_const_handle dh) const
{
CGAL::Random random((unsigned int)(alcc.darts().index(dh)));
return get_random_color(random);
}
/// @return the color of the edge containing dh
/// used only if colored_edge(alcc, dh)
template<typename LCC>
CGAL::IO::Color edge_color(const LCC&,
typename LCC::Dart_const_handle) const
{ return CGAL::IO::Color(0, 0, 0); }
/// @return the color of the vertex containing dh
/// used only if colored_vertex(alcc, dh)
template<typename LCC>
CGAL::IO::Color vertex_color(const LCC&,
typename LCC::Dart_const_handle) const
{ return CGAL::IO::Color(0, 0, 0); }
};
class Viewer : public CGAL::Basic_viewer_qt<float>
{
Q_OBJECT
@ -124,9 +37,12 @@ public Q_SLOTS:
void sceneChanged();
private:
MyDrawingFunctorLCC m_drawing_functor_;
CGAL::DefaultDrawingFunctorXWithVolume<LCC,
Dart_const_handle,
Dart_const_handle,
Dart_const_handle,
Dart_const_handle> m_drawing_functor;
CGAL::GraphicBuffer<float> m_graphic_buffer;
bool m_nofaces_, m_random_face_color_;
Scene* scene;
bool m_previous_scene_empty;
};

View File

@ -159,6 +159,7 @@ typedef CGAL::Linear_cell_complex_traits
typedef CGAL::Linear_cell_complex_for_combinatorial_map<3,3,Mytraits,Myitems> LCC;
typedef LCC::Dart_handle Dart_handle;
typedef LCC::Dart_const_handle Dart_const_handle;
typedef LCC::Vertex_attribute Vertex;
typedef LCC::Point Point_3;

View File

@ -15,6 +15,7 @@
#include <CGAL/GraphicBuffer.h>
#include <CGAL/Qt/Basic_viewer_qt.h>
#include <functional>
#ifdef CGAL_USE_BASIC_VIEWER
@ -23,195 +24,94 @@
namespace CGAL {
// This functor draws all faces, edges, and vertices.
// Default color functor; user can change it to have its own face color
struct DefaultDrawingFunctorLCC {
/// @return true iff the volume containing dh is drawn.
template <typename LCC>
bool draw_volume(const LCC &, typename LCC::Dart_const_handle) const {
return true;
}
/// @return true iff the face containing dh is drawn.
template <typename LCC>
bool draw_face(const LCC &, typename LCC::Dart_const_handle) const {
return true;
}
/// @return true iff the edge containing dh is drawn.
template <typename LCC>
bool draw_edge(const LCC &, typename LCC::Dart_const_handle) const {
return true;
}
/// @return true iff the vertex containing dh is drawn.
template <typename LCC>
bool draw_vertex(const LCC &, typename LCC::Dart_const_handle) const {
return true;
// CGAL::IO::Color face_color(const DS &aVal, face_handle dh) const {
// CGAL::Random random((unsigned int)(aVal.darts().index(dh)));
// return get_random_color(random);
// }
template <typename DS,
typename vertex_handle,
typename edge_handle,
typename face_handle>
struct DefaultDrawingFunctorX
{
DefaultDrawingFunctorX(): m_enabled_vertices(true),
m_enabled_edges(true),
m_enabled_faces(true)
{
draw_vertex=[](const DS &, vertex_handle)->bool { return true; };
draw_edge=[](const DS &, edge_handle)->bool { return true; };
draw_face=[](const DS &, face_handle)->bool { return true; };
colored_vertex=[](const DS &, vertex_handle)->bool { return false; };
colored_edge=[](const DS &, edge_handle)->bool { return false; };
colored_face=[](const DS &, face_handle)->bool { return false; };
face_wireframe=[](const DS &, face_handle)->bool { return false; };
}
/// @return true iff the volume containing dh is drawn in wireframe.
template <typename LCC>
bool volume_wireframe(const LCC &, typename LCC::Dart_const_handle) const {
return false;
}
/// @return true iff the face containing dh is drawn in wireframe.
template <typename LCC>
bool face_wireframe(const LCC &, typename LCC::Dart_const_handle) const {
return false;
}
std::function<bool(const DS &, vertex_handle)> draw_vertex;
std::function<bool(const DS &, edge_handle)> draw_edge;
std::function<bool(const DS &, face_handle)> draw_face;
/// @return true iff the volume containing dh is colored.
template <typename LCC>
bool colored_volume(const LCC &, typename LCC::Dart_const_handle) const {
return true;
}
/// @return true iff the face containing dh is colored.
/// if we have also colored_volume(alcc, dh), the volume color is
/// ignored and only the face color is considered.
template <typename LCC>
bool colored_face(const LCC &, typename LCC::Dart_const_handle) const {
return false;
}
/// @return true iff the edge containing dh is colored.
template <typename LCC>
bool colored_edge(const LCC &, typename LCC::Dart_const_handle) const {
return false;
}
/// @return true iff the vertex containing dh is colored.
template <typename LCC>
bool colored_vertex(const LCC &, typename LCC::Dart_const_handle) const {
return false;
}
std::function<bool(const DS &, vertex_handle)> colored_vertex;
std::function<bool(const DS &, edge_handle)> colored_edge;
std::function<bool(const DS &, face_handle)> colored_face;
/// @return the color of the volume containing dh
/// used only if colored_volume(alcc, dh) and !colored_face(alcc, dh)
template <typename LCC>
CGAL::IO::Color volume_color(const LCC &alcc,
typename LCC::Dart_const_handle dh) const {
CGAL::Random random((unsigned int)(alcc.darts().index(dh)));
return get_random_color(random);
}
/// @return the color of the face containing dh
/// used only if colored_face(alcc, dh)
template <typename LCC>
CGAL::IO::Color face_color(const LCC &alcc,
typename LCC::Dart_const_handle dh) const {
CGAL::Random random((unsigned int)(alcc.darts().index(dh)));
return get_random_color(random);
}
/// @return the color of the edge containing dh
/// used only if colored_edge(alcc, dh)
template <typename LCC>
CGAL::IO::Color edge_color(const LCC &alcc,
typename LCC::Dart_const_handle dh) const {
CGAL::Random random((unsigned int)(alcc.darts().index(dh)));
return get_random_color(random);
}
/// @return the color of the vertex containing dh
/// used only if colored_vertex(alcc, dh)
template <typename LCC>
CGAL::IO::Color vertex_color(const LCC &alcc,
typename LCC::Dart_const_handle dh) const {
CGAL::Random random((unsigned int)(alcc.darts().index(dh)));
return get_random_color(random);
}
std::function<bool(const DS &, face_handle)> face_wireframe;
std::function<CGAL::IO::Color(const DS &, vertex_handle)> vertex_color;
std::function<CGAL::IO::Color(const DS &, edge_handle)> edge_color;
std::function<CGAL::IO::Color(const DS &, face_handle)> face_color;
void disable_vertices() { m_enabled_vertices=false; }
void enable_vertices() { m_enabled_vertices=true; }
bool are_vertices_enabled() const { return m_enabled_vertices; }
void disable_edges() { m_enabled_edges=false; }
void enable_edges() { m_enabled_edges=true; }
bool are_edges_enabled() const { return m_enabled_edges; }
void disable_faces() { m_enabled_faces=false; }
void enable_faces() { m_enabled_faces=true; }
bool are_faces_enabled() const { return m_enabled_faces; }
protected:
bool m_enabled_vertices, m_enabled_edges, m_enabled_faces;
};
// TODO: these functors will modify a specific face, edge, and vertex.
struct DefaultDrawingFunctorX {
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool draw_face(const DS &, face_handle handle) const {
return true;
template <typename DS,
typename vertex_handle,
typename edge_handle,
typename face_handle,
typename volume_handle>
struct DefaultDrawingFunctorXWithVolume :
public DefaultDrawingFunctorX<DS, vertex_handle, edge_handle, face_handle>
{
DefaultDrawingFunctorXWithVolume() : m_enabled_volumes(true)
{
draw_volume=[](const DS &, volume_handle)->bool { return true; };
colored_volume=[](const DS &, volume_handle)->bool { return false; };
volume_wireframe=[](const DS &, volume_handle)->bool { return false; };
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool draw_edge(const DS &, edge_handle handle) const {
return true;
}
std::function<bool(const DS &, volume_handle)> draw_volume;
std::function<bool(const DS &, volume_handle)> colored_volume;
std::function<bool(const DS &, volume_handle)> volume_wireframe;
std::function<CGAL::IO::Color(const DS &, volume_handle)> volume_color;
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool draw_vertex(const DS &, vertex_handle handle) const {
return true;
}
void disable_volumes() { m_enabled_volumes=false; }
void enable_volumes() { m_enabled_volumes=true; }
bool are_volumes_enabled() const { return m_enabled_volumes; }
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool face_wireframe(const DS &, typename DS::Dart_const_handle) const {
return false;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool colored_face(const DS &, face_handle handle) const {
return false;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool colored_edge(const DS &, edge_handle handle) const {
return false;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
bool colored_vertex(const DS &, vertex_handle handle) const {
return false;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
CGAL::IO::Color face_color(const DS &aVal, face_handle dh) const {
CGAL::Random random((unsigned int)(aVal.darts().index(dh)));
return get_random_color(random);
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
CGAL::IO::Color edge_color(const DS &aVal, edge_handle dh) const {
CGAL::Random random((unsigned int)(aVal.darts().index(dh)));
return get_random_color(random);
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle>
CGAL::IO::Color vertex_color(const DS &aVal, vertex_handle dh) const {
CGAL::Random random((unsigned int)(aVal.darts().index(dh)));
return get_random_color(random);
}
protected:
bool m_enabled_volumes;
};
struct DefaultDrawingFunctorXWithVoulume : public DefaultDrawingFunctorX {
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle, typename volume_handle>
bool draw_volume(const DS &, volume_handle) const {
return true;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle, typename volume_handle>
CGAL::IO::Color volume_color(const DS &aVal,
volume_handle dh) const {
CGAL::Random random((unsigned int)(aVal.darts().index(dh)));
return get_random_color(random);
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle, typename volume_handle>
bool volume_wireframe(const DS &, volume_handle) const {
return false;
}
template <typename DS, typename face_handle, typename edge_handle,
typename vertex_handle, typename volume_handle>
bool colored_volume(const DS &, volume_handle) const {
return true;
}
};
namespace draw_function {
namespace draw_function_for_lcc
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel;
typedef Local_kernel::Point_3 Local_point;
@ -221,9 +121,11 @@ template <class LCC, class Local_kernel, int dim = LCC::ambient_dimension>
struct LCC_geom_utils;
template <class LCC, class Local_kernel>
struct LCC_geom_utils<LCC, Local_kernel, 3> {
struct LCC_geom_utils<LCC, Local_kernel, 3>
{
static typename Local_kernel::Vector_3
get_vertex_normal(const LCC &lcc, typename LCC::Dart_const_handle dh) {
get_vertex_normal(const LCC &lcc, typename LCC::Dart_const_handle dh)
{
typename Local_kernel::Vector_3 n =
internal::Geom_utils<typename LCC::Traits, Local_kernel>::
get_local_vector(CGAL::compute_normal_of_cell_0<LCC>(lcc, dh));
@ -233,9 +135,11 @@ struct LCC_geom_utils<LCC, Local_kernel, 3> {
};
template <class LCC, class Local_kernel>
struct LCC_geom_utils<LCC, Local_kernel, 2> {
struct LCC_geom_utils<LCC, Local_kernel, 2>
{
static typename Local_kernel::Vector_3
get_vertex_normal(const LCC &, typename LCC::Dart_const_handle) {
get_vertex_normal(const LCC &, typename LCC::Dart_const_handle)
{
typename Local_kernel::Vector_3 n=CGAL::NULL_VECTOR;
return n;
}
@ -244,99 +148,96 @@ struct LCC_geom_utils<LCC, Local_kernel, 2> {
template <typename BufferType=float, class LCC, class DrawingFunctorLCC>
void compute_face(typename LCC::Dart_const_handle dh,
typename LCC::Dart_const_handle voldh, const LCC *lcc,
bool m_nofaces, bool m_random_face_color,
const DrawingFunctorLCC &m_drawing_functor,
GraphicBuffer<BufferType> &graphic_buffer) {
typedef typename LCC::Dart_const_handle Dart_const_handle;
typedef typename LCC::Traits Kernel;
typedef typename Kernel::Point Point;
typedef typename Kernel::Vector Vector;
if (m_nofaces || !m_drawing_functor.draw_face(*lcc, dh))
return;
GraphicBuffer<BufferType> &graphic_buffer)
{
if (!m_drawing_functor.are_faces_enabled() ||
!m_drawing_functor.draw_face(*lcc, dh))
{ return; }
// We fill only closed faces.
Dart_const_handle cur = dh;
Dart_const_handle min = dh;
do {
typename LCC::Dart_const_handle cur=dh;
do
{
if (!lcc->is_next_exist(cur))
return; // open face=>not filled
if (cur < min)
min = cur;
{ return; } // open face=>not filled
cur = lcc->next(cur);
} while (cur != dh);
}
while (cur!=dh);
if (m_random_face_color) {
CGAL::Random random((unsigned int)(lcc->darts().index(dh)));
CGAL::IO::Color c = get_random_color(random);
graphic_buffer.face_begin(c);
} else if (m_drawing_functor.colored_face(*lcc, dh)) {
CGAL::IO::Color c = m_drawing_functor.face_color(*lcc, dh);
graphic_buffer.face_begin(c);
} else if (m_drawing_functor.colored_volume(*lcc, voldh)) {
if (m_drawing_functor.colored_volume(*lcc, voldh))
{
CGAL::IO::Color c=m_drawing_functor.volume_color(*lcc, voldh);
graphic_buffer.face_begin(c);
} else {
graphic_buffer.face_begin();
}
else if (m_drawing_functor.colored_face(*lcc, dh))
{
CGAL::IO::Color c=m_drawing_functor.face_color(*lcc, dh);
graphic_buffer.face_begin(c);
}
else
{ graphic_buffer.face_begin(); }
cur=dh;
do {
graphic_buffer.add_point_in_face(
lcc->point(cur),
do
{
graphic_buffer.add_point_in_face
(lcc->point(cur),
LCC_geom_utils<LCC, Local_kernel>::get_vertex_normal(*lcc, cur));
cur=lcc->next(cur);
} while (cur != dh);
}
while (cur!=dh);
graphic_buffer.face_end();
}
template <typename BufferType = float, class LCC, class DrawingFunctorLCC>
template <typename BufferType=float, class LCC, class DrawingFunctor>
void compute_edge(typename LCC::Dart_const_handle dh, const LCC *lcc,
const DrawingFunctorLCC &m_drawing_functor,
GraphicBuffer<BufferType> &graphic_buffer) {
typedef typename LCC::Dart_const_handle Dart_const_handle;
typedef typename LCC::Traits Kernel;
typedef typename Kernel::Point Point;
const DrawingFunctor &m_drawing_functor,
GraphicBuffer<BufferType> &graphic_buffer)
{
if (!m_drawing_functor.are_edges_enabled() ||
!m_drawing_functor.draw_edge(*lcc, dh))
{ return; }
if (!m_drawing_functor.draw_edge(*lcc, dh))
return;
Point p1 = lcc->point(dh);
Dart_const_handle d2 = lcc->other_extremity(dh);
if (d2 != nullptr) {
if (m_drawing_functor.colored_edge(*lcc, dh)) {
const typename LCC::Point& p1=lcc->point(dh);
typename LCC::Dart_const_handle d2=lcc->other_extremity(dh);
if (d2!=nullptr)
{
if (m_drawing_functor.colored_edge(*lcc, dh))
{
graphic_buffer.add_segment(p1, lcc->point(d2),
m_drawing_functor.edge_color(*lcc, dh));
} else {
graphic_buffer.add_segment(p1, lcc->point(d2));
}
else
{ graphic_buffer.add_segment(p1, lcc->point(d2)); }
}
}
template <typename BufferType = float, class LCC, class DrawingFunctorLCC>
void compute_vertex(typename LCC::Dart_const_handle dh, const LCC *lcc,
const DrawingFunctorLCC &m_drawing_functor,
GraphicBuffer<BufferType> &graphic_buffer) {
if (!m_drawing_functor.draw_vertex(*lcc, dh))
return;
GraphicBuffer<BufferType> &graphic_buffer)
{
if (!m_drawing_functor.are_vertices_enabled() ||
!m_drawing_functor.draw_vertex(*lcc, dh))
{ return; }
if (m_drawing_functor.colored_vertex(*lcc, dh)) {
if (m_drawing_functor.colored_vertex(*lcc, dh))
{
graphic_buffer.add_point(lcc->point(dh),
m_drawing_functor.vertex_color(*lcc, dh));
} else {
graphic_buffer.add_point(lcc->point(dh));
}
else
{ graphic_buffer.add_point(lcc->point(dh)); }
}
template <typename BufferType = float, class LCC, class DrawingFunctorLCC>
template <typename BufferType = float, class LCC, class DrawingFunctor>
void compute_elements(GraphicBuffer<BufferType> &graphic_buffer, const LCC *lcc,
const DrawingFunctorLCC &m_drawing_functor,
bool m_nofaces, bool m_random_face_color) {
const DrawingFunctor &m_drawing_functor)
{
if (lcc==nullptr)
return;
{ return; }
typename LCC::size_type markvolumes = lcc->get_new_mark();
typename LCC::size_type markfaces = lcc->get_new_mark();
@ -347,53 +248,43 @@ void compute_elements(GraphicBuffer<BufferType> &graphic_buffer, const LCC *lcc,
lcc->orient(oriented_mark);
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)
{
if (!lcc->is_marked(it, markvolumes) &&
m_drawing_functor.draw_volume(*lcc, it)) {
m_drawing_functor.draw_volume(*lcc, it))
{
for(typename LCC::template Dart_of_cell_basic_range<3>::const_iterator
itv = lcc->template darts_of_cell_basic<3>(it, markvolumes)
.begin(),
itvend =
lcc->template darts_of_cell_basic<3>(it, markvolumes).end();
itv != itvend; ++itv) {
lcc->mark(itv, markvolumes); // To be sure that all darts of the basic
// iterator will be marked
itv=lcc->template darts_of_cell_basic<3>(it, markvolumes).begin(),
itvend=lcc->template darts_of_cell_basic<3>(it, markvolumes).end();
itv!=itvend; ++itv)
{
lcc->mark(itv, markvolumes);
if (!lcc->is_marked(itv, markfaces) &&
lcc->is_marked(itv, oriented_mark) &&
m_drawing_functor.draw_face(*lcc, itv)) {
m_drawing_functor.draw_face(*lcc, itv))
{
if (!m_drawing_functor.volume_wireframe(*lcc, itv) &&
!m_drawing_functor.face_wireframe(*lcc, itv)) {
compute_face(itv, it, lcc, m_nofaces, m_random_face_color,
m_drawing_functor, graphic_buffer);
}
for (typename LCC::template Dart_of_cell_basic_range<
2>::const_iterator
itf = lcc->template darts_of_cell_basic<2>(itv, markfaces)
.begin(),
itfend = lcc->template darts_of_cell_basic<2>(itv, markfaces)
.end();
itf != itfend; ++itf) {
if (!m_drawing_functor.volume_wireframe(*lcc, itv) &&
!m_drawing_functor.face_wireframe(*lcc, itv)) {
!m_drawing_functor.face_wireframe(*lcc, itv))
{ compute_face(itv, it, lcc, m_drawing_functor, graphic_buffer); }
for(typename LCC::template Dart_of_cell_basic_range<2>::const_iterator
itf=lcc->template darts_of_cell_basic<2>(itv, markfaces).begin(),
itfend=lcc->template darts_of_cell_basic<2>(itv, markfaces).end();
itf!=itfend; ++itf)
{
lcc->mark(itf, markfaces);
} // To be sure that all darts of the basic iterator will be marked
if (!lcc->is_marked(itf, markedges) &&
m_drawing_functor.draw_edge(*lcc, itf)) {
m_drawing_functor.draw_edge(*lcc, itf))
{
compute_edge(itf, lcc, m_drawing_functor, graphic_buffer);
for (typename LCC::template Dart_of_cell_basic_range<
1>::const_iterator
ite =
lcc->template darts_of_cell_basic<1>(itf, markedges)
.begin(),
iteend =
lcc->template darts_of_cell_basic<1>(itf, markedges)
.end();
ite != iteend; ++ite) {
lcc->mark(ite, markedges); // To be sure that all darts of the
// basic iterator will be marked
for(typename LCC::template Dart_of_cell_basic_range<1>::const_iterator
ite=lcc->template darts_of_cell_basic<1>(itf, markedges).begin(),
iteend=lcc->template darts_of_cell_basic<1>(itf, markedges).end();
ite!=iteend; ++ite)
{
lcc->mark(ite, markedges);
if (!lcc->is_marked(ite, markvertices) &&
m_drawing_functor.draw_vertex(*lcc, ite)) {
m_drawing_functor.draw_vertex(*lcc, ite))
{
compute_vertex(ite, lcc, m_drawing_functor, graphic_buffer);
CGAL::mark_cell<LCC, 0>(*lcc, ite, markvertices);
}
@ -406,8 +297,8 @@ void compute_elements(GraphicBuffer<BufferType> &graphic_buffer, const LCC *lcc,
}
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)
{
lcc->unmark(it, markvertices);
lcc->unmark(it, markedges);
lcc->unmark(it, markfaces);
@ -431,17 +322,15 @@ void compute_elements(GraphicBuffer<BufferType> &graphic_buffer, const LCC *lcc,
* @param graphic_buffer
* @param m_drawing_functor
* @param alcc
* @param anofaces if true, do not draw faces.
*/
template <typename BufferType = float, class LCC, class DrawingFunctorLCC>
template <typename BufferType = float, class LCC, class DrawingFunctor>
void add_in_graphic_buffer_lcc(GraphicBuffer<BufferType> &graphic_buffer,
const DrawingFunctorLCC &m_drawing_functor,
const LCC *alcc = nullptr, bool nofaces = false,
bool m_random_face_color = false) {
if (alcc != nullptr) {
draw_function::compute_elements(graphic_buffer, alcc, m_drawing_functor,
nofaces, m_random_face_color);
const DrawingFunctor &m_drawing_functor,
const LCC *alcc = nullptr)
{
if (alcc!=nullptr)
{
draw_function_for_lcc::compute_elements(graphic_buffer, alcc, m_drawing_functor);
}
}
@ -454,21 +343,20 @@ template <unsigned int d_, unsigned int ambient_dim, class Traits_,
class Items_, class Alloc_,
template <unsigned int, class, class, class, class> class Map,
class Refs, class Storage_,
class DrawingFunctorLCC = DefaultDrawingFunctorLCC>
// TODO: I'll add it again after done LCC demo.
// class DrawingFunctorLCC = DefaultDrawingFunctorXWithVoulume>
class DrawingFunctor=DefaultDrawingFunctorXWithVolume<CGAL_LCC_TYPE,
typename CGAL_LCC_TYPE::Dart_const_handle,
typename CGAL_LCC_TYPE::Dart_const_handle,
typename CGAL_LCC_TYPE::Dart_const_handle,
typename CGAL_LCC_TYPE::Dart_const_handle>>
void draw(const CGAL_LCC_TYPE &alcc,
const char *title = "LCC for CMap Basic Viewer",
const DrawingFunctorLCC &drawing_functor = DrawingFunctorLCC()) {
// TODO: I'll add it again after done LCC demo.
// const DrawingFunctorLCC &drawing_functor = DefaultDrawingFunctorXWithVoulume()) {
const DrawingFunctor &drawing_functor=DrawingFunctor())
{
GraphicBuffer<float> buffer;
add_in_graphic_buffer_lcc(buffer, drawing_functor, &alcc, false);
add_in_graphic_buffer_lcc(buffer, drawing_functor, &alcc);
draw_buffer(buffer);
}
// Todo a function taking a const DrawingFunctorLCC& drawing_functor as
// parameter
#undef CGAL_LCC_TYPE
} // End namespace CGAL