mirror of https://github.com/CGAL/cgal
* Better drawing when scene was empty.
* Bug fix in triangulate all faces
This commit is contained in:
parent
af01f3820c
commit
37b0d2256c
|
|
@ -251,7 +251,6 @@ void MainWindow::on_actionLoad_triggered ()
|
|||
if (!fileName.isEmpty ())
|
||||
{
|
||||
load(fileName, true);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +264,6 @@ void MainWindow::on_actionImportOFF_triggered ()
|
|||
if (!fileName.isEmpty ())
|
||||
{
|
||||
load_off (fileName, true);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +277,6 @@ void MainWindow::on_actionImportMoka_triggered()
|
|||
if (!fileName.isEmpty ())
|
||||
{
|
||||
load_moka(fileName, true);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +290,6 @@ void MainWindow::on_actionImport3DTDS_triggered ()
|
|||
if (!fileName.isEmpty ())
|
||||
{
|
||||
load_3DTDS (fileName, true);
|
||||
viewer->showEntireScene();
|
||||
statusBar ()->showMessage (QString ("Import 3DTDS file") + fileName,
|
||||
DELAY_STATUSMSG);
|
||||
}
|
||||
|
|
@ -309,7 +305,6 @@ void MainWindow::on_actionAddOFF_triggered()
|
|||
if (!fileName.isEmpty ())
|
||||
{
|
||||
load_off (fileName, false);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,17 +314,14 @@ void MainWindow::load_depend_on_extension(const QString & fileName, bool clear)
|
|||
if ( ext=="3map")
|
||||
{
|
||||
load(fileName, clear);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
else if (ext=="off")
|
||||
{
|
||||
load_off(fileName, clear);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
else if (ext=="moka")
|
||||
{
|
||||
load_moka(fileName, clear);
|
||||
viewer->showEntireScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -998,6 +990,8 @@ void MainWindow::on_actionMerge_coplanar_faces_triggered()
|
|||
CGAL::Timer timer;
|
||||
timer.start();
|
||||
#endif
|
||||
|
||||
scene.lcc->set_update_attributes(false);
|
||||
|
||||
std::vector<Dart_handle> edges;
|
||||
int treated = scene.lcc->get_new_mark();
|
||||
|
|
@ -1005,21 +999,24 @@ void MainWindow::on_actionMerge_coplanar_faces_triggered()
|
|||
for ( typename LCC::Dart_range::iterator it= scene.lcc->darts().begin(),
|
||||
itend = scene.lcc->darts().end(); it!=itend; ++it )
|
||||
{
|
||||
if (!scene.lcc->is_marked(it, treated) &&
|
||||
CGAL::is_removable<LCC, 1>(*scene.lcc, it) )
|
||||
if (!scene.lcc->is_marked(it, treated) )
|
||||
{
|
||||
LCC::Vector normal1 = CGAL::compute_normal_of_cell_2(*scene.lcc,it);
|
||||
LCC::Vector normal2 = CGAL::compute_normal_of_cell_2(*scene.lcc, scene.lcc->beta<2>(it) );
|
||||
double angle = compute_angle3d(normal1, normal2);
|
||||
|
||||
if ( ((angle<5.0 or angle>355.0) or (angle<185.0 and angle>175.0)) )
|
||||
if ( CGAL::is_removable<LCC, 1>(*scene.lcc, it) )
|
||||
{
|
||||
CGAL::mark_cell<LCC, 1>(*scene.lcc, it, treated);
|
||||
edges.push_back(it);
|
||||
LCC::Vector normal1 = CGAL::compute_normal_of_cell_2(*scene.lcc,it);
|
||||
LCC::Vector normal2 = CGAL::compute_normal_of_cell_2(*scene.lcc, scene.lcc->beta<2>(it) );
|
||||
double angle = compute_angle3d(normal1, normal2);
|
||||
|
||||
if ( ((angle<5.0 or angle>355.0) or (angle<185.0 and angle>175.0)) )
|
||||
{
|
||||
edges.push_back(it);
|
||||
}
|
||||
}
|
||||
CGAL::mark_cell<LCC, 1>(*scene.lcc, it, treated);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (std::vector<Dart_handle>::iterator it=edges.begin(),
|
||||
itend=edges.end(); it!=itend; ++it)
|
||||
{
|
||||
|
|
@ -1034,19 +1031,20 @@ void MainWindow::on_actionMerge_coplanar_faces_triggered()
|
|||
|
||||
CGAL::remove_cell<LCC, 1>(*scene.lcc, actu);
|
||||
actu = prev;
|
||||
std::cout<<&(*actu)<<std::endl;
|
||||
}
|
||||
while (scene.lcc->beta<0, 2>(actu)==actu || scene.lcc->beta<1, 2>(actu)==actu);
|
||||
}
|
||||
else if ( !CGAL::belong_to_same_cell<LCC, 2>(*scene.lcc, *it,
|
||||
scene.lcc->beta<2>(*it)) )
|
||||
CGAL::remove_cell<LCC, 1>(*scene.lcc, *it);
|
||||
else
|
||||
CGAL::unmark_cell<LCC, 1>(*scene.lcc, *it, treated);
|
||||
}
|
||||
|
||||
assert(scene.lcc->is_whole_map_unmarked(treated));
|
||||
assert(scene.lcc->is_whole_map_marked(treated));
|
||||
scene.lcc->free_mark(treated);
|
||||
|
||||
scene.lcc->set_update_attributes(true);
|
||||
|
||||
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||
timer.stop();
|
||||
std::cout<<"Time to merge all coplanar faces: "
|
||||
|
|
@ -1271,7 +1269,9 @@ void MainWindow::on_actionTriangulate_all_facets_triggered()
|
|||
for (LCC::One_dart_per_cell_range<2>::iterator
|
||||
it(scene.lcc->one_dart_per_cell<2>().begin()); it.cont(); ++it)
|
||||
{
|
||||
if ( scene.lcc->info<3>(it).is_filled_and_visible() )
|
||||
if ( scene.lcc->info<3>(it).is_filled_and_visible() ||
|
||||
(!scene.lcc->is_free<3>(it) &&
|
||||
scene.lcc->info<3>(scene.lcc->beta<3>(it)).is_filled_and_visible()) )
|
||||
v.push_back(it);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,14 @@ Viewer::sceneChanged()
|
|||
qglviewer::Vec(bb.xmax(),
|
||||
bb.ymax(),
|
||||
bb.zmax()));
|
||||
// this->showEntireScene();
|
||||
this->updateGL();}
|
||||
|
||||
if (m_previous_scene_empty)
|
||||
this->showEntireScene();
|
||||
else
|
||||
this->updateGL();
|
||||
|
||||
m_previous_scene_empty = scene->lcc->is_empty(); // for the next call to sceneChanged
|
||||
}
|
||||
|
||||
void Viewer::drawOneFaceWireframe(Dart_handle dh)
|
||||
{
|
||||
|
|
@ -55,7 +61,7 @@ void Viewer::drawOneFaceWireframe(Dart_handle dh)
|
|||
::glEnd();
|
||||
}
|
||||
|
||||
void Viewer::drawOneFilledFace(Dart_handle dh)
|
||||
void Viewer::drawOneFilledFace(Dart_handle dh, bool flat)
|
||||
{
|
||||
LCC &lcc = *scene->lcc;
|
||||
|
||||
|
|
@ -73,7 +79,7 @@ void Viewer::drawOneFilledFace(Dart_handle dh)
|
|||
|
||||
::glColor3f(r,g,b);
|
||||
|
||||
if(flatShading)
|
||||
if(flat)
|
||||
{
|
||||
LCC::Vector normal = CGAL::compute_normal_of_cell_2(lcc,dh);
|
||||
normal = normal/(CGAL::sqrt(normal*normal));
|
||||
|
|
@ -97,7 +103,7 @@ void Viewer::drawOneFilledFace(Dart_handle dh)
|
|||
data[1+(i*3)] = p.y();
|
||||
data[2+(i*3)] = p.z();
|
||||
|
||||
if(!flatShading)
|
||||
if(!flat)
|
||||
{
|
||||
// If Gouraud shading: 1 normal per vertex
|
||||
LCC::Vector normal = CGAL::compute_normal_of_cell_0(lcc,it);
|
||||
|
|
@ -114,7 +120,7 @@ void Viewer::drawOneFilledFace(Dart_handle dh)
|
|||
data[2+(i*3)] = p.z();
|
||||
|
||||
// If Gouraud shading: 1 normal per vertex
|
||||
if(!flatShading)
|
||||
if(!flat)
|
||||
{
|
||||
LCC::Vector normal = CGAL::compute_normal_of_cell_0(lcc,dh);
|
||||
normal = normal/(CGAL::sqrt(normal*normal));
|
||||
|
|
@ -146,7 +152,7 @@ void Viewer::drawAllFaces(bool flat)
|
|||
// We draw the polygon
|
||||
if ( it->info().is_filled() )
|
||||
{
|
||||
drawOneFilledFace(dartIter);
|
||||
drawOneFilledFace(dartIter, flat);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -238,12 +244,6 @@ void Viewer::drawAllVertices()
|
|||
}
|
||||
|
||||
::glEnd();
|
||||
|
||||
if ( lcc.is_empty() )
|
||||
{
|
||||
bb = LCC::Point(CGAL::ORIGIN).bbox();
|
||||
bb = bb + LCC::Point(1,1,1).bbox(); // To avoid a warning from Qglviewer
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::initDraw()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QKeyEvent>
|
||||
|
||||
static void monCombine(GLdouble c[3], void *d[4], GLfloat w[4], void **out)
|
||||
static void monCombine(GLdouble c[3], void */*d*/[4], GLfloat /*w*/[4], void **out)
|
||||
{
|
||||
GLdouble *nv = (GLdouble *) malloc(sizeof(GLdouble)*3);
|
||||
nv[0] = c[0];
|
||||
|
|
@ -51,7 +51,8 @@ class Viewer : public QGLViewer
|
|||
GLuint m_dlEdges;
|
||||
GLuint m_dlVertices;
|
||||
bool m_displayListCreated;
|
||||
|
||||
bool m_previous_scene_empty;
|
||||
|
||||
GLUtesselator* FTess;
|
||||
|
||||
typedef LCC::Dart_handle Dart_handle;
|
||||
|
|
@ -60,7 +61,8 @@ class Viewer : public QGLViewer
|
|||
public:
|
||||
Viewer(QWidget* parent)
|
||||
: QGLViewer(parent), wireframe(false), flatShading(true),
|
||||
edges(true), vertices(true), m_displayListCreated(false)
|
||||
edges(true), vertices(true), m_displayListCreated(false),
|
||||
m_previous_scene_empty(true)
|
||||
{
|
||||
QGLFormat newFormat = this->format();
|
||||
newFormat.setSampleBuffers(true);
|
||||
|
|
@ -103,7 +105,7 @@ protected:
|
|||
void drawAllEdges();
|
||||
void drawAllVertices();
|
||||
void drawOneFaceWireframe(Dart_handle);
|
||||
void drawOneFilledFace(Dart_handle);
|
||||
void drawOneFilledFace(Dart_handle, bool flat);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue