From 8459fc6485b14523a690e1b2d650bcf0fdbe0a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 3 Aug 2012 15:22:58 +0000 Subject: [PATCH] update the default polyhedron to have indices in simplices so that plugin can simply attach properties to them. --- Polyhedron/demo/Polyhedron/Polyhedron_type.h | 22 ++++++++++++--- .../demo/Polyhedron/Scene_polyhedron_item.cpp | 28 +++++++++++++++++++ .../demo/Polyhedron/Scene_polyhedron_item.h | 4 +++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_type.h b/Polyhedron/demo/Polyhedron/Polyhedron_type.h index feaf36eda34..c67d6ff227c 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_type.h +++ b/Polyhedron/demo/Polyhedron/Polyhedron_type.h @@ -22,6 +22,7 @@ private: typedef CGAL::HalfedgeDS_vertex_base Pdv_base; Set_of_indices indices; + std::size_t mID; public: int nb_of_feature_edges; @@ -42,8 +43,11 @@ public: return indices; } - Polyhedron_demo_vertex() : Pdv_base(), nb_of_feature_edges(0) {} - Polyhedron_demo_vertex(const Point& p) : Pdv_base(p), nb_of_feature_edges(0) {} + std::size_t& id() { return mID; } + std::size_t id() const { return mID; } + + Polyhedron_demo_vertex() : Pdv_base(), mID(-1), nb_of_feature_edges(0) {} + Polyhedron_demo_vertex(const Point& p) : Pdv_base(p), mID(-1), nb_of_feature_edges(0) {} }; template @@ -52,10 +56,11 @@ class Polyhedron_demo_halfedge : { private: bool feature_edge; + std::size_t mID; public: Polyhedron_demo_halfedge() - : feature_edge(false) {}; + : feature_edge(false), mID(-1) {}; bool is_feature_edge() const { return feature_edge; @@ -65,6 +70,10 @@ public: feature_edge = b; this->opposite()->feature_edge = b; } + + std::size_t& id() { return mID; } + std::size_t id() const { return mID; } + }; template @@ -73,11 +82,12 @@ class Polyhedron_demo_face : { private: Patch_id_ patch_id_; + std::size_t mID; public: typedef Patch_id_ Patch_id; Polyhedron_demo_face() - : patch_id_(1) {} + : patch_id_(1), mID(-1) {} int patch_id() const { return patch_id_; @@ -86,6 +96,10 @@ public: void set_patch_id(const int i) { patch_id_ = i; } + + std::size_t& id() { return mID; } + std::size_t id() const { return mID; } + }; template diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp index c039393b1e4..7009db4a32f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp @@ -397,4 +397,32 @@ Scene_polyhedron_item::select(double orig_x, Base::select(orig_x, orig_y, orig_z, dir_x, dir_y, dir_z); } +void Scene_polyhedron_item::update_vertex_indices() +{ + std::size_t id=0; + for (Polyhedron::Vertex_iterator vit = polyhedron()->vertices_begin(), + vit_end = polyhedron()->vertices_end(); vit != vit_end; ++vit) + { + vit->id()=id++; + } +} +void Scene_polyhedron_item::update_facet_indices() +{ + std::size_t id=0; + for (Polyhedron::Facet_iterator fit = polyhedron()->facets_begin(), + fit_end = polyhedron()->facets_end(); fit != fit_end; ++fit) + { + fit->id()=id++; + } +} +void Scene_polyhedron_item::update_halfedge_indices() +{ + std::size_t id=0; + for (Polyhedron::Halfedge_iterator hit = polyhedron()->halfedges_begin(), + hit_end = polyhedron()->halfedges_end(); hit != hit_end; ++hit) + { + hit->id()=id++; + } +} + #include "Scene_polyhedron_item.moc" diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h index be73578f0e3..50087729254 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h @@ -66,6 +66,10 @@ public slots: double dir_y, double dir_z); + void update_vertex_indices(); + void update_facet_indices(); + void update_halfedge_indices(); + signals: void selected_vertex(void*); void selected_facet(void*);