Bug fix in lcc basic viewer when lcc is null

This commit is contained in:
Guillaume Damiand 2021-01-12 18:24:43 +01:00
parent 6f8f790ae9
commit f506515008
2 changed files with 17 additions and 8 deletions

View File

@ -15,7 +15,7 @@
#include <CGAL/Qt/vec.h> #include <CGAL/Qt/vec.h>
Viewer::Viewer(QWidget* parent) : Viewer::Viewer(QWidget* parent) :
Base(parent, NULL, ""), Base(parent, nullptr, ""),
m_previous_scene_empty(true) m_previous_scene_empty(true)
{} {}
@ -50,4 +50,3 @@ void Viewer::keyPressEvent(QKeyEvent *e)
QString Viewer::helpString() const QString Viewer::helpString() const
{ return Base::helpString("LCC Demo"); } { return Base::helpString("LCC Demo"); }

View File

@ -170,13 +170,17 @@ public:
// First draw: vertices; edges, faces; multi-color; inverse normal // First draw: vertices; edges, faces; multi-color; inverse normal
Base(parent, title, true, true, true, false, false), Base(parent, title, true, true, true, false, false),
lcc(alcc), lcc(alcc),
m_oriented_mark(lcc->get_new_mark()), m_oriented_mark(LCC::INVALID_MARK),
m_nofaces(anofaces), m_nofaces(anofaces),
m_random_face_color(false), m_random_face_color(false),
m_drawing_functor(drawing_functor) m_drawing_functor(drawing_functor)
{ {
lcc->orient(m_oriented_mark); if (lcc!=nullptr)
compute_elements(); {
lcc->get_new_mark();
lcc->orient(m_oriented_mark);
compute_elements();
}
} }
~SimpleLCCViewerQt() ~SimpleLCCViewerQt()
@ -185,14 +189,20 @@ public:
protected: protected:
void set_lcc(const LCC* alcc, bool doredraw=true) void set_lcc(const LCC* alcc, bool doredraw=true)
{ {
if (lcc==alcc)
{ return; }
if (lcc!=nullptr) if (lcc!=nullptr)
{ lcc->free_mark(m_oriented_mark); } { lcc->free_mark(m_oriented_mark); }
lcc=alcc; lcc=alcc;
m_oriented_mark=lcc->get_new_mark(); if (lcc!=nullptr)
lcc->orient(m_oriented_mark); {
m_oriented_mark=lcc->get_new_mark();
lcc->orient(m_oriented_mark);
compute_elements();
}
compute_elements();
if (doredraw) { redraw(); } if (doredraw) { redraw(); }
} }