diff --git a/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp b/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp index 30239fa2be0..7572b9a1ff5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item_rendering_helper.cpp @@ -221,7 +221,7 @@ void Scene_item_rendering_helper::setEdgeContainer(std::size_t id, } void Scene_item_rendering_helper::setPointContainer(std::size_t id, - Point_container* pc) + Point_container* pc) { if(priv->point_containers.size() <= id) { diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index db4de5ef72d..becba57fc67 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -27,29 +27,31 @@ #include #include -#include -#include -#include -#include - -#include - #ifdef CGAL_LINKED_WITH_TBB #include #include #include #endif // CGAL_LINKED_WITH_TBB +#include + +#include +#include +#include + const std::size_t limit_fast_drawing = 300000; //arbitraty large value typedef CGAL::Three::Point_container Pc; typedef CGAL::Three::Edge_container Ec; typedef CGAL::Three::Viewer_interface VI; + typedef Scene_points_with_normal_item_priv Priv; + struct Scene_points_with_normal_item_priv { - enum Point_container_id{ - Points =0, + enum Point_container_id + { + Points = 0, Shaded_points, Selected_points, Selected_shaded_points @@ -68,30 +70,28 @@ struct Scene_points_with_normal_item_priv point_Slider->setMinimum(1); point_Slider->setValue(CGAL::Three::Three::getDefaultPointSize()); point_Slider->setMaximum(25); - item->setPointContainer(Priv::Selected_shaded_points, new Pc(VI::PROGRAM_WITH_LIGHT, - false)); - item->setPointContainer(Priv::Selected_points, new Pc(VI::PROGRAM_NO_SELECTION, - false)); - item->setPointContainer(Priv::Shaded_points, new Pc(VI::PROGRAM_WITH_LIGHT, - false)); - item->setPointContainer(Priv::Points, new Pc(VI::PROGRAM_NO_SELECTION, - false)); - item->setEdgeContainer(0, new Ec(VI::PROGRAM_NO_SELECTION, - false)); - + item->setPointContainer(Priv::Selected_shaded_points, new Pc(VI::PROGRAM_WITH_LIGHT, false)); + item->setPointContainer(Priv::Selected_points, new Pc(VI::PROGRAM_NO_SELECTION, false)); + item->setPointContainer(Priv::Shaded_points, new Pc(VI::PROGRAM_WITH_LIGHT, false)); + item->setPointContainer(Priv::Points, new Pc(VI::PROGRAM_NO_SELECTION, false)); + item->setEdgeContainer(0, new Ec(VI::PROGRAM_NO_SELECTION, false)); } + Scene_points_with_normal_item_priv(Scene_points_with_normal_item* parent) - :m_points(new Point_set) + : m_points(new Point_set) { init_values(parent); } - Scene_points_with_normal_item_priv(const Scene_points_with_normal_item& toCopy, Scene_points_with_normal_item* parent) + + Scene_points_with_normal_item_priv(const Scene_points_with_normal_item& toCopy, + Scene_points_with_normal_item* parent) : m_points(new Point_set(*toCopy.d->m_points)) { init_values(parent); } - Scene_points_with_normal_item_priv(const SMesh& input_mesh, Scene_points_with_normal_item* parent) + Scene_points_with_normal_item_priv(const SMesh& input_mesh, + Scene_points_with_normal_item* parent) : m_points(new Point_set) { init_values(parent); @@ -118,6 +118,7 @@ struct Scene_points_with_normal_item_priv delete normal_Slider; delete point_Slider; } + bool isPointSliderMoving() { return is_point_slider_moving; } void initializeBuffers(CGAL::Three::Viewer_interface *viewer) const; void compute_normals_and_vertices() const; @@ -143,9 +144,10 @@ struct Scene_points_with_normal_item_priv Scene_points_with_normal_item* item; }; -class Fill_buffers { - +class Fill_buffers +{ Point_set* point_set; + std::vector& indices; std::vector& positions_lines; std::vector& positions_normals; @@ -212,19 +214,16 @@ public: } }; - - Scene_points_with_normal_item::Scene_points_with_normal_item() { - setRenderingMode(Points); - is_selected = true; - d = new Scene_points_with_normal_item_priv(this); + setRenderingMode(Points); + is_selected = true; + d = new Scene_points_with_normal_item_priv(this); } // Copy constructor Scene_points_with_normal_item::Scene_points_with_normal_item(const Scene_points_with_normal_item& toCopy) { - d = new Scene_points_with_normal_item_priv(toCopy, this); if (!has_normals()) @@ -232,7 +231,8 @@ Scene_points_with_normal_item::Scene_points_with_normal_item(const Scene_points_ setRenderingMode(Points); is_selected = true; } - else{ + else + { setRenderingMode(CGAL::Three::Three::defaultPointSetRenderingMode()); is_selected = true; } @@ -692,7 +692,6 @@ void Scene_points_with_normal_item::drawEdges(CGAL::Three::Viewer_interface* vie void Scene_points_with_normal_item:: drawPoints(CGAL::Three::Viewer_interface* viewer) const { - GLfloat point_size; viewer->glGetFloatv(GL_POINT_SIZE, &point_size); viewer->setGlPointSize(GLfloat(d->point_Slider->value())); @@ -735,18 +734,16 @@ drawPoints(CGAL::Three::Viewer_interface* viewer) const { if(!d->m_points->has_colors()) getPointContainer(Priv::Points)->setColor(color()); - std::size_t real_size = - getPointContainer(Priv::Points)->getFlatDataSize(); + std::size_t real_size = getPointContainer(Priv::Points)->getFlatDataSize(); getPointContainer(Priv::Points)->setFlatDataSize(ratio_displayed * real_size); getPointContainer(Priv::Points)->setFlatDataSize(real_size); - getPointContainer(Priv::Points)->draw( viewer, !d->m_points->has_colors()); + getPointContainer(Priv::Points)->draw(viewer, !d->m_points->has_colors()); - real_size = - getPointContainer(Priv::Selected_points)->getFlatDataSize(); + real_size = getPointContainer(Priv::Selected_points)->getFlatDataSize(); getPointContainer(Priv::Selected_points)->setColor(QColor(Qt::red)); getPointContainer(Priv::Selected_points)->setFlatDataSize(ratio_displayed * real_size); getPointContainer(Priv::Selected_points)->setFlatDataSize(real_size); - getPointContainer(Priv::Selected_points)->draw( viewer, true); + getPointContainer(Priv::Selected_points)->draw(viewer, true); } viewer->setGlPointSize(point_size); diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index 7594dba0ef4..e306b96dee2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -36,11 +36,11 @@ class SCENE_POINTS_WITH_NORMAL_ITEM_EXPORT Scene_points_with_normal_item public: Scene_points_with_normal_item(); + Scene_points_with_normal_item(const SMesh& input_mesh); Scene_points_with_normal_item(const Scene_points_with_normal_item& toCopy); - Scene_points_with_normal_item(const SMesh& input_mesh); - ~Scene_points_with_normal_item(); + Scene_points_with_normal_item* clone() const Q_DECL_OVERRIDE; // Is selection empty? diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index bf2ceccb0f7..db941e81b65 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -751,7 +751,6 @@ void Scene_surface_mesh_item_priv::initialize_colors() const void Scene_surface_mesh_item_priv::initializeBuffers(CGAL::Three::Viewer_interface* viewer)const { - item->getTriangleContainer(1)->initializeBuffers(viewer); item->getTriangleContainer(0)->initializeBuffers(viewer); item->getEdgeContainer(1)->initializeBuffers(viewer); @@ -2388,7 +2387,7 @@ void Scene_surface_mesh_item::setAlpha(int alpha) QSlider* Scene_surface_mesh_item::alphaSlider() { return d->alphaSlider; } -void Scene_surface_mesh_item::computeElements()const +void Scene_surface_mesh_item::computeElements() const { d->compute_elements(ALL); setBuffersFilled(true); @@ -2396,7 +2395,7 @@ void Scene_surface_mesh_item::computeElements()const } void -Scene_surface_mesh_item::initializeBuffers(CGAL::Three::Viewer_interface* viewer)const +Scene_surface_mesh_item::initializeBuffers(CGAL::Three::Viewer_interface* viewer) const { const_cast(this)->//temporary, until the drawing pipeline is not const anymore. d->initializeBuffers(viewer); @@ -2416,8 +2415,9 @@ void Scene_surface_mesh_item::computeItemColorVectorAutomatically(bool b) this->setProperty("recompute_colors",b); } -void write_in_vbo(Vbo* vbo, cgal_gl_data* data, - std::size_t size) +void write_in_vbo(Vbo* vbo, + cgal_gl_data* data, + std::size_t size) { vbo->bind(); vbo->vbo.write(static_cast((3*size)*sizeof(cgal_gl_data)), diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h index 68ffb958dfb..a87ef8c2a35 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h @@ -28,33 +28,37 @@ #include "properties.h" - class QSlider; + struct Scene_surface_mesh_item_priv; + class SCENE_SURFACE_MESH_ITEM_EXPORT Scene_surface_mesh_item - : public CGAL::Three::Scene_item_rendering_helper, + : public CGAL::Three::Scene_item_rendering_helper, public CGAL::Three::Scene_item_with_properties, public CGAL::Three::Scene_zoomable_item_interface, - public CGAL::Three::Scene_print_item_interface{ + public CGAL::Three::Scene_print_item_interface +{ Q_INTERFACES(CGAL::Three::Scene_print_item_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PrintInterface/1.0") Q_OBJECT Q_INTERFACES(CGAL::Three::Scene_zoomable_item_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.ZoomInterface/1.0") + public: typedef SMesh Face_graph; typedef SMesh::Property_map Vertex_selection_map; typedef SMesh::Property_map Face_selection_map; + + void initialize_priv(); Scene_surface_mesh_item(); // Takes ownership of the argument. Scene_surface_mesh_item(SMesh*); Scene_surface_mesh_item(const SMesh&); - Scene_surface_mesh_item(SMesh&&); + Scene_surface_mesh_item(SMesh&&); Scene_surface_mesh_item(const Scene_surface_mesh_item& other); ~Scene_surface_mesh_item(); - Scene_surface_mesh_item* clone() const Q_DECL_OVERRIDE; void draw(CGAL::Three::Viewer_interface *) const Q_DECL_OVERRIDE; void drawEdges(CGAL::Three::Viewer_interface *) const Q_DECL_OVERRIDE; diff --git a/Three/include/CGAL/Three/Scene_item_rendering_helper.h b/Three/include/CGAL/Three/Scene_item_rendering_helper.h index 8e73d38987c..b636cbb2eb3 100644 --- a/Three/include/CGAL/Three/Scene_item_rendering_helper.h +++ b/Three/include/CGAL/Three/Scene_item_rendering_helper.h @@ -41,7 +41,7 @@ struct Point_container; //! be rendered. //! class DEMO_FRAMEWORK_EXPORT Scene_item_rendering_helper - :public Scene_item + : public Scene_item { Q_OBJECT public: @@ -100,11 +100,11 @@ public: //! //! \brief getEdgeContainer returns the `id`th `Edge_container`. //! - CGAL::Three::Edge_container* getEdgeContainer(std::size_t id)const; + CGAL::Three::Edge_container* getEdgeContainer(std::size_t id) const; //! //! \brief getPointContainer returns the `id`th `Point_container`. //! - CGAL::Three::Point_container* getPointContainer(std::size_t id)const; + CGAL::Three::Point_container* getPointContainer(std::size_t id) const; //! //! \brief setTriangleContainer sets the `id`th `Triangle_container` to `tc`. @@ -134,7 +134,7 @@ public: //! decreasingly. //! void setPointContainer(std::size_t id, - Point_container* tc); + Point_container* tc); //! //! \brief setBuffersFilled specifies if the data should be re-computed. @@ -149,13 +149,13 @@ public: //! \brief getBuffersFilled returns `false` if the item rendering data needs to be re-computed., //! `true` otherwise. //! \see `setBuffersFilled()` - bool getBuffersFilled()const; + bool getBuffersFilled() const; //! //! \brief getBuffersInit returns true if the `Vao`s of `viewer` are ready //! for rendering. //! - bool getBuffersInit(Viewer_interface *viewer)const; + bool getBuffersInit(Viewer_interface *viewer) const; //! //! \brief setBuffersInit specifies if the `Vbo`s need to be initialized. @@ -190,7 +190,7 @@ protected: QSlider* alphaSlider(); //!Returns`true` if `initGL()` was called for `viewer`. - bool isInit(CGAL::Three::Viewer_interface* viewer)const; + bool isInit(CGAL::Three::Viewer_interface* viewer) const; //!Returns the float alpha value of an item. //! This value is between 0.0f and 1.0f. @@ -198,7 +198,7 @@ protected: /*! Fills the `Vbo`s with data. */ - virtual void initializeBuffers(Viewer_interface*)const{} + virtual void initializeBuffers(Viewer_interface*) const {} //!Creates the VAOs and VBOs for viewer. virtual void initGL(CGAL::Three::Viewer_interface* viewer) const; @@ -210,9 +210,10 @@ protected: //! \brief setBbox allows to set the Bbox in compute_bbox(); //! \param b //! - void setBbox(Bbox b)const ; + void setBbox(Bbox b) const; + + virtual void computeElements() const {} - virtual void computeElements()const{} protected: friend struct PRIV; mutable PRIV* priv;