From 56976db66563d6da438f87d34c959a34dfe2bbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Aug 2015 10:15:43 +0200 Subject: [PATCH] reduce the number of containers used and simplify a bit the code --- .../Polyhedron/Scene_edit_polyhedron_item.cpp | 50 ++++--------------- .../Polyhedron/Scene_edit_polyhedron_item.h | 5 -- 2 files changed, 11 insertions(+), 44 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp index f4c574b1a49..75e3d322981 100644 --- a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp @@ -200,15 +200,15 @@ void Scene_edit_polyhedron_item::initialize_buffers(Viewer_interface *viewer =0) buffers[6].release(); buffers[7].bind(); - buffers[7].allocate(color_sphere_ROI.data(), - static_cast(color_sphere_ROI.size()*sizeof(double))); + buffers[7].allocate(ROI_color.data(), + static_cast(ROI_color.size()*sizeof(double))); program->enableAttributeArray("colors"); program->setAttributeBuffer("colors",GL_DOUBLE,0,3); buffers[7].release(); buffers[8].bind(); - buffers[8].allocate(centers_ROI.data(), - static_cast(centers_ROI.size()*sizeof(double))); + buffers[8].allocate(ROI_points.data(), + static_cast(ROI_points.size()*sizeof(double))); program->enableAttributeArray("center"); program->setAttributeBuffer("center",GL_DOUBLE,0,3); buffers[8].release(); @@ -278,15 +278,15 @@ void Scene_edit_polyhedron_item::initialize_buffers(Viewer_interface *viewer =0) buffers[14].release(); buffers[15].bind(); - buffers[15].allocate(color_sphere_control.data(), - static_cast(color_sphere_control.size()*sizeof(double))); + buffers[15].allocate(control_color.data(), + static_cast(control_color.size()*sizeof(double))); program->enableAttributeArray("colors"); program->setAttributeBuffer("colors",GL_DOUBLE,0,3); buffers[15].release(); buffers[16].bind(); - buffers[16].allocate(centers_control.data(), - static_cast(centers_control.size()*sizeof(double))); + buffers[16].allocate(control_points.data(), + static_cast(control_points.size()*sizeof(double))); program->enableAttributeArray("center"); program->setAttributeBuffer("center",GL_DOUBLE,0,3); buffers[16].release(); @@ -324,7 +324,6 @@ void Scene_edit_polyhedron_item::compute_normals_and_vertices(void) ROI_points.resize(0); control_points.resize(0); control_color.resize(0); - color_sphere_control.resize(0); BOOST_FOREACH(vertex_descriptor vd, deform_mesh.roi_vertices()) { if(!deform_mesh.is_control_vertex(vd)) @@ -334,27 +333,10 @@ void Scene_edit_polyhedron_item::compute_normals_and_vertices(void) ROI_points.push_back(vd->point().z()); } } - centers_ROI.resize(ROI_points.size()); - ROI_color.resize(ROI_points.size()); - color_sphere_ROI.resize(ROI_points.size()); - for(int i=0; i<(int)centers_ROI.size(); i++) - { - centers_ROI[i] = ROI_points[i]; - } - for(int i=0; i<(int)ROI_color.size(); i++) - { - if(i%3==1) - { - ROI_color[i]=1.0; - color_sphere_ROI[i]=1.0; + ROI_color.assign(ROI_points.size(),0); + for(std::size_t i=0; i edges; std::vector color_lines; std::vector color_bbox; - std::vector color_edges; std::vector ROI_points; std::vector control_points; std::vector ROI_color; @@ -280,10 +279,6 @@ private: std::vector pos_axis; std::vector pos_sphere; std::vector normals_sphere; - std::vector centers_control; - std::vector centers_ROI; - std::vector color_sphere_ROI; - std::vector color_sphere_control; mutable QOpenGLShaderProgram *program; mutable QOpenGLShaderProgram bbox_program;