diff --git a/GraphicsView/include/CGAL/Qt/constraint_impl.h b/GraphicsView/include/CGAL/Qt/constraint_impl.h index abb97f9d29d..513900a9fbd 100644 --- a/GraphicsView/include/CGAL/Qt/constraint_impl.h +++ b/GraphicsView/include/CGAL/Qt/constraint_impl.h @@ -59,7 +59,7 @@ void AxisPlaneConstraint::setTranslationConstraintDirection( if ((translationConstraintType() != AxisPlaneConstraint::FREE) && (translationConstraintType() != AxisPlaneConstraint::FORBIDDEN)) { const qreal norm = direction.norm(); - if (norm < 1E-8) { + if (norm == 0) { qWarning("AxisPlaneConstraint::setTranslationConstraintDir: null vector " "for translation constraint"); translationConstraintType_ = AxisPlaneConstraint::FREE; diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 77e50a6296b..2107bf7ca62 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -2957,6 +2957,8 @@ void MainWindow::on_actionSa_ve_Scene_as_Script_triggered() last_saved_dir, "Qt Script files (*.js)"); } + if(!filename.endsWith(".js")) + filename.append(".js"); std::ofstream os(filename.toUtf8(), std::ofstream::binary); if(!os) return; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Diff_between_meshes_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Diff_between_meshes_plugin.cpp index 37c8a08a7e6..3147fca83cf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Diff_between_meshes_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Diff_between_meshes_plugin.cpp @@ -175,11 +175,11 @@ void Polyhedron_demo_diff_between_meshes_plugin::diff() Scene_surface_mesh_item* m1_over_m2_item = new Scene_surface_mesh_item(m1_over_m2); m1_over_m2_item->setColor(QColor(Qt::blue)); - m1_over_m2_item->setName(QString("%1 - %2").arg(m1_item->name()).arg(m2_item->name())); + m1_over_m2_item->setName(QString("%2 - %1").arg(m1_item->name()).arg(m2_item->name())); CGAL::Three::Three::scene()->addItem(m1_over_m2_item); Scene_surface_mesh_item* m2_over_m1_item = new Scene_surface_mesh_item(m2_over_m1); m2_over_m1_item->setColor(QColor(Qt::red)); - m2_over_m1_item->setName(QString("%2 - %1").arg(m1_item->name()).arg(m2_item->name())); + m2_over_m1_item->setName(QString("%1 - %2").arg(m1_item->name()).arg(m2_item->name())); CGAL::Three::Three::scene()->addItem(m2_over_m1_item); Scene_surface_mesh_item* common_item = new Scene_surface_mesh_item(common); common_item->setColor(QColor(Qt::green)); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Scene_edit_box_item.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Scene_edit_box_item.cpp index cada4c95506..0cb165c03f6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Scene_edit_box_item.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Scene_edit_box_item.cpp @@ -809,12 +809,14 @@ bool Scene_edit_box_item::eventFilter(QObject *obj, QEvent *event) d->selected_vertices.push_back(d->faces[picked].vertices[i]); Kernel::Point_3 a1(d->faces[picked].vertices[1]->position()), a0(d->faces[picked].vertices[0]->position()) ,a3(d->faces[picked].vertices[3]->position()); - QVector3D a(a1.x()-a0.x(), a1.y()-a0.y(),a1.z()-a0.z()),b(a3.x()-a0.x(), a3.y()-a0.y(),a3.z()-a0.z()); - QVector3D n = QVector3D::crossProduct(a,b); + Kernel::Vector_3 a = a1 - a0, + b = a3 - a0; + Kernel::Vector_3 n = CGAL::cross_product(a,b); d->remodel_frame->setConstraint(&d->constraint); d->constraint.setTranslationConstraintType(CGAL::qglviewer::AxisPlaneConstraint::AXIS); d->constraint.setTranslationConstraintDirection(CGAL::qglviewer::Vec(n.x(), n.y(), n.z())); + } viewer->setManipulatedFrame(d->remodel_frame); diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 3531f76919f..ab972f2653d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -1029,6 +1029,10 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::setinvalidate_aabb_tree(); + setProperty("need_invalidate_aabb_tree", false); + } invalidateOpenGLBuffers(); Q_EMIT updateInstructions("Ctrl+Right-click to move the point. \nHit Ctrl+Z to leave the selection. (2/2)"); } @@ -1953,6 +1957,7 @@ void Scene_polyhedron_selection_item::moveVertex() put(vpm, vh, Point_3(d->manipulated_frame->position().x-offset.x, d->manipulated_frame->position().y-offset.y, d->manipulated_frame->position().z-offset.z)); + setProperty("need_invalidate_aabb_tree", true); invalidateOpenGLBuffers(); poly_item->updateVertex(vh); // poly_item->invalidateOpenGLBuffers(); @@ -1972,6 +1977,10 @@ void Scene_polyhedron_selection_item::validateMoveVertex() set_highlighting(true); setProperty("need_hl_restore", false); } + if(property("need_invalidate_aabb_tree").toBool()){ + polyhedron_item()->invalidate_aabb_tree(); + setProperty("need_invalidate_aabb_tree", false); + } Q_EMIT updateInstructions("Select a vertex. (1/2)"); } diff --git a/Polyhedron/demo/Polyhedron/create_sphere.h b/Polyhedron/demo/Polyhedron/create_sphere.h index a10cdbacc2b..c2fd27266d1 100644 --- a/Polyhedron/demo/Polyhedron/create_sphere.h +++ b/Polyhedron/demo/Polyhedron/create_sphere.h @@ -197,7 +197,7 @@ void create_flat_and_wire_sphere(FLOAT R, const float sectors=float(prec); const float to_rad = static_cast(CGAL_PI / 180.0); - create_flat_sphere(R, positions_spheres, normals_spheres); + create_flat_sphere(R, positions_spheres, normals_spheres, prec); float T, P; float x[4],y[4],z[4]; diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_spheres.vert b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_spheres.vert index 0982b0b69d9..3a54795b4b9 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_spheres.vert +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_spheres.vert @@ -20,12 +20,13 @@ void main(void) for(int i=0; i<6; ++i) dist[i] = 1.0; color = vec4(colors, 1.0); - fP = mv_matrix * vertex; + vec4 transformed_vertex = + vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0); + fP = mv_matrix * transformed_vertex; mat3 norm_matrix_3; norm_matrix_3[0] = norm_matrix[0].xyz; norm_matrix_3[1] = norm_matrix[1].xyz; norm_matrix_3[2] = norm_matrix[2].xyz; fN = norm_matrix_3* normals; - gl_Position = mvp_matrix * f_matrix * - vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0) ; + gl_Position = mvp_matrix * f_matrix * transformed_vertex; } diff --git a/Polyhedron/demo/Polyhedron/resources/shader_spheres.vert b/Polyhedron/demo/Polyhedron/resources/shader_spheres.vert index 64e3097adea..68b0babf8a0 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_spheres.vert +++ b/Polyhedron/demo/Polyhedron/resources/shader_spheres.vert @@ -20,12 +20,13 @@ void main(void) for(int i=0; i<6; ++i) dist[i] = 1.0; color = vec4(colors, 1.0); - fP = mv_matrix * vertex; + vec4 transformed_vertex = + vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0); + fP = mv_matrix * transformed_vertex; mat3 norm_matrix_3; norm_matrix_3[0] = norm_matrix[0].xyz; norm_matrix_3[1] = norm_matrix[1].xyz; norm_matrix_3[2] = norm_matrix[2].xyz; fN = norm_matrix_3* normals; - gl_Position = mvp_matrix * f_matrix * - vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0) ; + gl_Position = mvp_matrix * f_matrix * transformed_vertex; }