diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index b842b379f2d..c13815c1c79 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1512,8 +1512,10 @@ void MainWindow::on_actionLoad_triggered() scene->redraw_model(); this->addToRecentFiles(filename); } else { + int scene_size = scene->numberOfEntries(); open(filename); - scene->item(scene->numberOfEntries()-1)->setColor(colors_[++nb_item]); + if(scene->numberOfEntries() != scene_size) + scene->item(scene->numberOfEntries()-1)->setColor(colors_[++nb_item]); } } } @@ -2083,4 +2085,4 @@ void MainWindow::exportStatistics() QTextStream outStream(&output); outStream << str; output.close(); -} \ No newline at end of file +} diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_3.qrc b/Polyhedron/demo/Polyhedron/Polyhedron_3.qrc index 1b9c1ba644b..561f59d65a0 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_3.qrc +++ b/Polyhedron/demo/Polyhedron/Polyhedron_3.qrc @@ -49,7 +49,6 @@ resources/euler_facet.png resources/euler_vertex.png javascript/lib.js - resources/shader_c3t3_tets.v resources/shader_flat.f resources/hexahedron.png resources/icosphere.png diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index a1e4ca7c79f..740f3f59326 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -75,7 +75,7 @@ public : { //vao containing the data for the facets { - program = getShaderProgram(PROGRAM_C3T3_TETS, viewer); + program = getShaderProgram(PROGRAM_C3T3, viewer); program->bind(); vaos[Facets]->bind(); @@ -133,11 +133,14 @@ public : { if(is_fast) return; + const Kernel::Plane_3& plane = qobject_cast(this->parent())->plane(); vaos[Facets]->bind(); - program = getShaderProgram(PROGRAM_C3T3_TETS); - attribBuffers(viewer, PROGRAM_C3T3_TETS); + program = getShaderProgram(PROGRAM_C3T3); + attribBuffers(viewer, PROGRAM_C3T3); program->bind(); float shrink_factor = qobject_cast(this->parent())->getShrinkFactor(); + QVector4D cp(-plane.a(), -plane.b(), -plane.c(), -plane.d()); + program->setUniformValue("cutplane", cp); program->setUniformValue("shrink_factor", shrink_factor); // positions_poly is also used for the faces in the cut plane // and changes when the cut plane is moved @@ -1421,7 +1424,7 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet) Tr::Cell_handle ch = facet.id().first; if(intersected_cells.find(ch) == intersected_cells.end()) { - QColor c = this->colors_subdomains[ch->subdomain_index()].darker(150); + QColor c = this->colors_subdomains[ch->subdomain_index()].light(50); const Tr::Bare_point& pa = wp2p(ch->vertex(0)->point()); const Tr::Bare_point& pb = wp2p(ch->vertex(1)->point()); @@ -1446,9 +1449,10 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet) const Tr::Bare_point& pc = wp2p(nh->vertex(2)->point()); const Tr::Bare_point& pd = wp2p(nh->vertex(3)->point()); - QColor c = this->colors_subdomains[nh->subdomain_index()].darker(150); + QColor c = this->colors_subdomains[nh->subdomain_index()].light(50); CGAL::Color color(c.red(), c.green(), c.blue()); + intersection->addTriangle(pb, pa, pc, color); intersection->addTriangle(pa, pb, pd, color); intersection->addTriangle(pa, pd, pc, color); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index d9384ad2231..e2904ffb239 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -815,7 +815,6 @@ void Viewer::attribBuffers(int program_name) const { case PROGRAM_WITH_TEXTURE: case PROGRAM_CUTPLANE_SPHERES: case PROGRAM_SPHERES: - case PROGRAM_C3T3_TETS: case PROGRAM_OLD_FLAT: case PROGRAM_FLAT: program->setUniformValue("light_pos", position); @@ -834,7 +833,6 @@ void Viewer::attribBuffers(int program_name) const { case PROGRAM_INSTANCED: case PROGRAM_CUTPLANE_SPHERES: case PROGRAM_SPHERES: - case PROGRAM_C3T3_TETS: case PROGRAM_OLD_FLAT: case PROGRAM_FLAT: program->setUniformValue("mv_matrix", mv_mat); @@ -1249,9 +1247,6 @@ QOpenGLShaderProgram* Viewer::getShaderProgram(int name) const case PROGRAM_CUTPLANE_SPHERES: return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_c3t3_spheres.v" , ":/cgal/Polyhedron_3/resources/shader_c3t3.f"); break; - case PROGRAM_C3T3_TETS: - return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_c3t3_tets.v" , ":/cgal/Polyhedron_3/resources/shader_with_light.f"); - break; case PROGRAM_SPHERES: return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_spheres.v" , ":/cgal/Polyhedron_3/resources/shader_with_light.f"); break; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_c3t3_tets.v b/Polyhedron/demo/Polyhedron/resources/shader_c3t3_tets.v deleted file mode 100644 index 89becb1d2b6..00000000000 --- a/Polyhedron/demo/Polyhedron/resources/shader_c3t3_tets.v +++ /dev/null @@ -1,30 +0,0 @@ -#version 120 -attribute highp vec4 vertex; -attribute highp vec3 normals; -attribute highp vec3 colors; -attribute highp vec3 barycenter; -uniform highp mat4 mvp_matrix; -uniform highp mat4 mv_matrix; -uniform highp float shrink_factor; -varying highp vec4 fP; -varying highp vec3 fN; -varying highp vec4 color; -void main(void) -{ - color = vec4(colors, 1.0); - fP = mv_matrix * vertex; - fN = mat3(mv_matrix)* normals; - highp mat4 transOB = mat4(1, 0, 0, 0, // first column - 0, 1, 0, 0, // second column - 0, 0, 1, 0, // third column - barycenter.x, barycenter.y, barycenter.z, 1); // fourth column - highp mat4 transBO = mat4(1, 0, 0, 0, // first column - 0, 1, 0, 0, // second column - 0, 0, 1, 0, // third column - -barycenter.x, -barycenter.y, -barycenter.z, 1); // fourth column - highp mat4 scaling = mat4(shrink_factor, 0, 0, 0, - 0, shrink_factor, 0, 0, - 0, 0, shrink_factor, 0, - 0, 0, 0, 1); - gl_Position = mvp_matrix *transOB * scaling * transBO * vertex; -} diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index c2c5d087d09..1dc19dfef06 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -82,7 +82,6 @@ public: PROGRAM_C3T3_EDGES, /** Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.*/ PROGRAM_CUTPLANE_SPHERES, /** Used to render the spheres of an item with a cut plane.*/ PROGRAM_SPHERES, /** Used to render one or several spheres.*/ - PROGRAM_C3T3_TETS, /** Used to render the tetrahedra of the intersection of a c3t3_item.*/ PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/ PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/ NB_OF_PROGRAMS /** Holds the number of different programs in this enum.*/ diff --git a/Three/include/CGAL/Three/Viewer_interface.h b/Three/include/CGAL/Three/Viewer_interface.h index 28f7ad3d43e..efd93f0f722 100644 --- a/Three/include/CGAL/Three/Viewer_interface.h +++ b/Three/include/CGAL/Three/Viewer_interface.h @@ -71,7 +71,6 @@ public: PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light. PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane. PROGRAM_SPHERES, //! Used to render one or several spheres. - PROGRAM_C3T3_TETS, //! Used to render the tetrahedra of the intersection of a c3t3_item. PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/ PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/ NB_OF_PROGRAMS //! Holds the number of different programs in this enum.