From 473edff485d7d1134dabe572ae2e537d1c917698 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 8 Nov 2016 15:52:01 +0100 Subject: [PATCH] Fix spheres problems : - give squared radius to the CGAL::Spheres instead of radius. - don't keep a list of Spheres but directly add the values to the buffers when a sphere is added to the item. --- .../Scene_edit_polyhedron_item.cpp | 6 +- .../demo/Polyhedron/Scene_c3t3_item.cpp | 5 +- .../demo/Polyhedron/Scene_polylines_item.cpp | 11 ++- .../demo/Polyhedron/Scene_spheres_item.cpp | 71 ++++++------------- .../demo/Polyhedron/Scene_spheres_item.h | 3 +- 5 files changed, 33 insertions(+), 63 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp index b2bf719fa57..5cf34bfc545 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp @@ -409,8 +409,7 @@ void Scene_edit_polyhedron_item_priv::compute_normals_and_vertices(void) if(spheres) { CGAL::Color c(0,255,0); - Kernel::Sphere_3 *sphere = new Kernel::Sphere_3(vd->point(), length_of_axis/15.0); - spheres->add_sphere(sphere, c); + spheres->add_sphere(Kernel::Sphere_3(vd->point(), length_of_axis/15.0*length_of_axis/15.0), c); } } @@ -446,8 +445,7 @@ void Scene_edit_polyhedron_item_priv::compute_normals_and_vertices(void) if(spheres_ctrl) { CGAL::Color c(255*r,0,255*b); - Kernel::Sphere_3 *sphere = new Kernel::Sphere_3((*hb)->point(), length_of_axis/15.0); - spheres_ctrl->add_sphere(sphere, c); + spheres_ctrl->add_sphere(Kernel::Sphere_3((*hb)->point(), length_of_axis/15.0*length_of_axis/15.0), c); } } } diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 1e2d288518a..96d70a859c2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -1338,9 +1338,8 @@ void Scene_c3t3_item_priv::computeSpheres() Kernel::Point_3 center(vit->point().point().x(), vit->point().point().y(), vit->point().point().z()); - float radius = vit->point().weight(); - Kernel::Sphere_3* sphere = new Kernel::Sphere_3(center, radius); - spheres->add_sphere(sphere, CGAL::Color(c.red(), c.green(), c.blue())); + float radius = vit->point().weight() ; + spheres->add_sphere(Kernel::Sphere_3(center, radius), CGAL::Color(c.red(), c.green(), c.blue())); } spheres->invalidateOpenGLBuffers(); } diff --git a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp index c4503f87cd5..83293052539 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp @@ -14,7 +14,7 @@ struct Scene_polylines_item_private { Scene_polylines_item_private(Scene_polylines_item *parent) : draw_extremities(false), - spheres_drawn_radius(0) + spheres_drawn_square_radius(0) { item = parent; invalidate_stats(); @@ -47,7 +47,7 @@ struct Scene_polylines_item_private { void initializeBuffers(CGAL::Three::Viewer_interface *viewer) const; void computeElements() const; bool draw_extremities; - double spheres_drawn_radius; + double spheres_drawn_square_radius; Scene_polylines_item *item; mutable std::size_t nb_vertices; mutable std::size_t nb_edges; @@ -227,8 +227,7 @@ Scene_polylines_item_private::computeSpheres() CGAL::Color c(colors[0], colors[1], colors[2]); - K::Sphere_3 *sphere = new K::Sphere_3(center, spheres_drawn_radius); - spheres->add_sphere(sphere, c); + spheres->add_sphere(K::Sphere_3(center, spheres_drawn_square_radius), c); } spheres->setToolTip( QString("

Legende of endpoints colors: