diff --git a/Mesh_3/include/CGAL/Mesh_polyhedron_3.h b/Mesh_3/include/CGAL/Mesh_polyhedron_3.h index 2ac7728f135..7c93102d352 100644 --- a/Mesh_3/include/CGAL/Mesh_polyhedron_3.h +++ b/Mesh_3/include/CGAL/Mesh_polyhedron_3.h @@ -19,7 +19,7 @@ // Author(s) : Stephane Tayeb // //****************************************************************************** -// File Description : +// File Description : //****************************************************************************** #ifndef CGAL_MESH_POLYHEDRON_3_H @@ -35,33 +35,35 @@ #include +#include + namespace CGAL { namespace Mesh_3 { - + template -class Mesh_polyhedron_vertex : +class Mesh_polyhedron_vertex : public CGAL::HalfedgeDS_vertex_base { public: typedef std::set Set_of_indices; - + private: typedef CGAL::HalfedgeDS_vertex_base Pdv_base; - + Set_of_indices indices; std::size_t time_stamp_; public: int nb_of_feature_edges; - + bool is_corner() const { return nb_of_feature_edges > 2; } - + bool is_feature_vertex() const { return nb_of_feature_edges != 0; } - + void add_incident_patch(const Patch_id i) { indices.insert(i); } @@ -77,18 +79,18 @@ public: time_stamp_ = ts; } ///@} - + const Set_of_indices& incident_patches_ids_set() const { return indices; } - + Mesh_polyhedron_vertex() : Pdv_base(), nb_of_feature_edges(0) {} Mesh_polyhedron_vertex(const Point& p) : Pdv_base(p), nb_of_feature_edges(0) {} }; template -class Mesh_polyhedron_halfedge : +class Mesh_polyhedron_halfedge : public CGAL::HalfedgeDS_halfedge_base { private: @@ -96,14 +98,14 @@ private: std::size_t time_stamp_; public: - - Mesh_polyhedron_halfedge() + + Mesh_polyhedron_halfedge() : feature_edge(false) {}; - + bool is_feature_edge() const { return feature_edge; } - + void set_feature_edge(const bool b) { feature_edge = b; this->opposite()->feature_edge = b; @@ -136,7 +138,7 @@ inline Integral patch_id_default_value(Integral) } template -class Mesh_polyhedron_face : +class Mesh_polyhedron_face : public CGAL::HalfedgeDS_face_base { private: @@ -146,14 +148,14 @@ private: public: typedef Patch_id_ Patch_id; - - Mesh_polyhedron_face() + + Mesh_polyhedron_face() : patch_id_(patch_id_default_value(Patch_id())) {} - + const Patch_id& patch_id() const { return patch_id_; } - + void set_patch_id(const Patch_id& i) { patch_id_ = i; } @@ -185,7 +187,7 @@ public: Point, Patch_id> Vertex; }; - + // wrap face template struct Face_wrapper { @@ -194,7 +196,7 @@ public: CGAL::Tag_false, Patch_id> Face; }; - + // wrap halfedge template struct Halfedge_wrapper { @@ -204,7 +206,7 @@ public: CGAL::Tag_true> Halfedge; }; }; - + } // end namespace Mesh_3 @@ -215,4 +217,117 @@ struct Mesh_polyhedron_3 typedef type Type; }; + +template +struct Patch_id_pmap { + + typedef typename Mesh_polyhedron_3::type Polyhedron; + typedef typename Polyhedron::Face_handle key_type; + typedef typename Polyhedron::Facet::Patch_id value_type; + typedef value_type reference; + typedef boost::writable_property_map_tag category; + + friend Patch_id get(const Patch_id_pmap&, key_type h) + { + return h->patch_id(); + } + + friend void put(const Patch_id_pmap&, key_type h, + Patch_id pid) + { + h->set_patch_id(pid); + } + +}; + + +template +inline Patch_id_pmap +get(CGAL::face_patch_id_t, + const Polyhedron_3 >&) +{ + return Patch_id_pmap(); +} + + +template +struct vertex_num_feature_edges_pmap { + + typedef typename Mesh_polyhedron_3::type Polyhedron; + typedef typename Polyhedron::Vertex_handle key_type; + typedef int value_type; + friend int get(const vertex_num_feature_edges_pmap&, key_type h) + { + return h->nb_of_feature_edges; + } + + friend void put(const vertex_num_feature_edges_pmap&, key_type h, int n) + { + h->nb_of_feature_edges = n; + } + +}; + + +template +inline vertex_num_feature_edges_pmap +get(vertex_num_feature_edges_t, + const Polyhedron_3 >&) +{ + return vertex_num_feature_edges_pmap(); +} + + +template +struct Is_feature_pmap { + typedef typename Mesh_polyhedron_3::type Polyhedron; + typedef typename Polyhedron::Halfedge_handle key_type; + typedef bool value_type; + + friend bool get(const Is_feature_pmap&, key_type h) + { + return h->is_feature_edge(); + } + + friend void put(const Is_feature_pmap&, key_type h, bool b) + { + h->set_feature_edge(b); + } + +}; + + +template +inline Is_feature_pmap +get(halfedge_is_feature_t, + const Polyhedron_3 >&) +{ + return Is_feature_pmap (); +} + + +} // end namespace CGAL + +namespace boost { + + template + struct property_map >, CGAL::face_patch_id_t> + { + typedef CGAL::Patch_id_pmap type; + }; + + template + struct property_map >, CGAL::vertex_num_feature_edges_t> + { + typedef CGAL::vertex_num_feature_edges_pmap type; + }; + + template + struct property_map >, CGAL::halfedge_is_feature_t> + { + typedef CGAL::Is_feature_pmap type; + }; + +} // namespace boost + #endif // CGAL_MESH_POLYHEDRON_3_H diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h index 79890e12944..89f66138580 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -219,7 +218,7 @@ public: typedef typename Base::Curve_segment_index Curve_segment_index; typedef typename Base::Surface_patch_index Surface_patch_index; typedef typename Base::Subdomain_index Subdomain_index; - + // Backward compatibility #ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX typedef Surface_patch_index Surface_index; @@ -228,7 +227,7 @@ public: typedef typename Base::R R; typedef typename Base::Point_3 Point_3; typedef typename Base::FT FT; - + typedef CGAL::Tag_true Has_features; typedef std::vector Bare_polyline; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt index 1ee27e72e3e..a88cad71039 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt @@ -51,9 +51,6 @@ if ( Boost_VERSION GREATER 103400 ) message(STATUS "warning: the plugin mesh_3_plugin requires Boost>=1.34.1 and will not be compiled.") endif( Boost_VERSION GREATER 103400 ) - polyhedron_demo_plugin(detect_sharp_edges_plugin Detect_sharp_edges_plugin) - target_link_libraries(detect_sharp_edges_plugin scene_polyhedron_item) - qt5_wrap_ui( ribUI_FILES Rib_dialog.ui) polyhedron_demo_plugin(c3t3_rib_exporter_plugin C3t3_rib_exporter_plugin ${ribUI_FILES}) target_link_libraries(c3t3_rib_exporter_plugin scene_c3t3_item) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index 34859d52171..3c64cd8e90a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -17,7 +17,7 @@ #include using namespace CGAL::Three; -typedef Tr::Point Point_3; +typedef Tr::Point Tr_Point_3; typedef Kernel::Point_3 Bare_point_3; Meshing_thread* cgal_code_mesh_3(const Polyhedron* pMesh, @@ -221,9 +221,9 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, Image_mesh_domain* p_domain = new Image_mesh_domain(*pImage, 1e-6); if(protect_features && polylines.empty()){ - std::vector > polylines_on_bbox; + std::vector > polylines_on_bbox; CGAL::polylines_to_protect< - Point_3, + Tr_Point_3, Image_mesh_domain::Image_word_type>(*pImage, polylines_on_bbox); p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); } @@ -250,8 +250,8 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, { std::cerr << "Warning : Automatic detection of features" << " in Gray images is not implemented yet" << std::endl; - //std::vector > polylines_on_bbox; - //CGAL::polylines_to_protect(*pImage, polylines_on_bbox); + //std::vector > polylines_on_bbox; + //CGAL::polylines_to_protect(*pImage, polylines_on_bbox); //p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); } if(! polylines.empty()){ diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 143fa7378e7..1212692c57b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -89,3 +89,6 @@ target_link_libraries(isotropic_remeshing_plugin scene_polyhedron_item scene_po polyhedron_demo_plugin(distance_plugin Distance_plugin) target_link_libraries(distance_plugin scene_polyhedron_item scene_color_ramp) + +polyhedron_demo_plugin(detect_sharp_edges_plugin Detect_sharp_edges_plugin) +target_link_libraries(detect_sharp_edges_plugin scene_polyhedron_item) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Detect_sharp_edges_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp similarity index 100% rename from Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Detect_sharp_edges_plugin.cpp rename to Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 4832f20a58c..a6a735f93e9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -401,8 +401,8 @@ public Q_SLOTS: Kernel::Point_3 > Edge_graph; Edge_graph edge_graph; - std::map p2vd; - std::map::iterator it_find; + std::map p2vd; + std::map::iterator it_find; bool insert_OK; Face_graph * poly = selection_item->polyhedron(); @@ -410,7 +410,7 @@ public Q_SLOTS: for(Scene_polyhedron_selection_item::Selection_set_edge::iterator begin = selection_item->selected_edges.begin(); begin != selection_item->selected_edges.end(); ++begin) { - vertex_descriptor source = target(opposite(halfedge(*begin,*poly),*poly),*poly); + fg_vertex_descriptor source = target(opposite(halfedge(*begin,*poly),*poly),*poly); boost::tie(it_find, insert_OK) = p2vd.insert(std::make_pair(source, Edge_graph::vertex_descriptor())); if (insert_OK) @@ -420,7 +420,7 @@ public Q_SLOTS: } Edge_graph::vertex_descriptor src=it_find->second; - vertex_descriptor targ = target(halfedge(*begin,*poly),*poly); + fg_vertex_descriptor targ = target(halfedge(*begin,*poly),*poly); boost::tie(it_find, insert_OK) = p2vd.insert(std::make_pair(targ, Edge_graph::vertex_descriptor())); if (insert_OK) @@ -499,7 +499,7 @@ public Q_SLOTS: return; } const Face_graph& poly = *selection_item->polyhedron(); - BOOST_FOREACH(Scene_polyhedron_selection_item::edge_descriptor ed, selection_item->selected_edges) + BOOST_FOREACH(Scene_polyhedron_selection_item::fg_edge_descriptor ed, selection_item->selected_edges) { selection_item->selected_facets.insert(face(halfedge(ed, poly), poly)); selection_item->selected_facets.insert(face(opposite(halfedge(ed, poly), poly), poly)); @@ -522,7 +522,7 @@ public Q_SLOTS: } const Face_graph& poly = *selection_item->polyhedron(); - BOOST_FOREACH(Scene_polyhedron_selection_item::edge_descriptor ed, selection_item->selected_edges) + BOOST_FOREACH(Scene_polyhedron_selection_item::fg_edge_descriptor ed, selection_item->selected_edges) { selection_item->selected_vertices.insert(target(halfedge(ed, poly), poly)); selection_item->selected_vertices.insert(source(halfedge(ed, poly), poly)); @@ -544,9 +544,9 @@ public Q_SLOTS: return; } const Face_graph& poly = *selection_item->polyhedron(); - std::vector boundary_edges; + std::vector boundary_edges; CGAL::Polygon_mesh_processing::border_halfedges(selection_item->selected_facets, poly, std::back_inserter(boundary_edges)); - BOOST_FOREACH(Scene_polyhedron_selection_item::halfedge_descriptor h, boundary_edges) + BOOST_FOREACH(Scene_polyhedron_selection_item::fg_halfedge_descriptor h, boundary_edges) { selection_item->selected_edges.insert(edge(h, poly)); } @@ -567,9 +567,9 @@ public Q_SLOTS: return; } const Face_graph& poly = *selection_item->polyhedron(); - BOOST_FOREACH(Scene_polyhedron_selection_item::face_descriptor fh, selection_item->selected_facets) + BOOST_FOREACH(Scene_polyhedron_selection_item::fg_face_descriptor fh, selection_item->selected_facets) { - BOOST_FOREACH(Scene_polyhedron_selection_item::halfedge_descriptor h, CGAL::halfedges_around_face(halfedge(fh,poly), poly) ) + BOOST_FOREACH(Scene_polyhedron_selection_item::fg_halfedge_descriptor h, CGAL::halfedges_around_face(halfedge(fh,poly), poly) ) { selection_item->selected_vertices.insert(target(h, poly)); } diff --git a/Polyhedron/include/CGAL/boost/graph/PMP_properties_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/PMP_properties_Polyhedron_3.h deleted file mode 100644 index 440a771ca55..00000000000 --- a/Polyhedron/include/CGAL/boost/graph/PMP_properties_Polyhedron_3.h +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (c) 2017 GeometryFactory (France). All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Andreas Fabri - -#ifndef CGAL_PMP_PROPERTIES_POLYHEDRON_3_H -#define CGAL_PMP_PROPERTIES_POLYHEDRON_3_H - -#include - -#include -#include - -#define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS - -namespace CGAL { - -struct Polyhedron_face_time_stamp_pmap -{ - typedef void key_type; - typedef std::size_t value_type; - typedef std::size_t reference; - typedef boost::read_write_property_map_tag category; -}; - -template -std::size_t get(Polyhedron_face_time_stamp_pmap, Handle_type h) -{ - return h->time_stamp(); -} - -template -void put(Polyhedron_face_time_stamp_pmap, Handle_type h, - std::size_t ts) -{ - h->set_time_stamp(ts); -} - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef Polyhedron_face_time_stamp_pmap type; - typedef type const_type; - }; -}; - -template <> -struct Polyhedron_property_map - : public Polyhedron_property_map -{}; - -template <> -struct Polyhedron_property_map - : public Polyhedron_property_map -{}; - - -template -struct Polyhedron_face_patch_id_pmap { - typedef void key_type; - typedef Patch_id value_type; - typedef Patch_id reference; - typedef boost::read_write_property_map_tag category; -}; - -template -Patch_id get(Polyhedron_face_patch_id_pmap, Handle_type h) -{ - return h->patch_id(); -} - -template -void put(Polyhedron_face_patch_id_pmap, Handle_type h, - Patch_id pid) -{ - h->set_patch_id(pid); -} - -template -struct Polyhedron_property_map > -{ - template - struct bind_ - { - typedef Polyhedron_face_patch_id_pmap type; - typedef type const_type; - }; -}; - - - -namespace internal{ -BOOST_MPL_HAS_XXX_TRAIT_DEF(Plane_3) - -template -struct Get_static_property_map { - typedef boost::graph_traits > Graph_traits; - typedef CGAL::static_property_map > type; -}; - -} // end namespace internal - -template -typename boost::lazy_enable_if< - internal::has_Plane_3, - internal::Get_static_property_map - >::type -get(CGAL::face_patch_id_t, const Polyhedron_3&) -{ - typedef typename internal::Get_static_property_map::type Pmap; - return Pmap( std::pair(0,1) ); -} - -template <> -struct Polyhedron_property_map > -{ - template - struct bind_ - { - typedef typename internal::Get_static_property_map::type type; - typedef type const_type; - }; -}; - - - -struct Polyhedron_num_feature_edges_pmap { - typedef void key_type; - typedef int value_type; - typedef int reference; - typedef boost::read_write_property_map_tag category; -}; - -template -int get(Polyhedron_num_feature_edges_pmap, Handle_type h) -{ - return h->nb_of_feature_edges; -} - -template -void put(Polyhedron_num_feature_edges_pmap, Handle_type h, int n) -{ - h->nb_of_feature_edges = n; -} - - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef Polyhedron_num_feature_edges_pmap type; - typedef type const_type; - }; -}; - -struct Polyhedron_is_feature_edge_pmap { - typedef void key_type; - typedef bool value_type; - typedef bool reference; - typedef boost::read_write_property_map_tag category; -}; - -template -bool get(Polyhedron_is_feature_edge_pmap, Handle_type h) -{ - return h->is_feature_edge(); -} - -template -void put(Polyhedron_is_feature_edge_pmap, Handle_type h, bool b) -{ - h->set_feature_edge(b); -} - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef Polyhedron_is_feature_edge_pmap type; - typedef type const_type; - }; -}; - -// template -// inline Is_feature_pmap -// get(halfedge_is_feature_t, -// const Polyhedron_3 >&) -// { -// return Is_feature_pmap (); -// } - - -template -struct Polyhedron_incident_patches_pmap { - typedef void key_type; - typedef std::set value_type; - typedef std::set& reference; - typedef boost::read_write_property_map_tag category; -}; - -template -std::set& get(Polyhedron_incident_patches_pmap, - Handle_type h) -{ - return h->incident_patches_ids_set(); -} - -template -void put(Polyhedron_incident_patches_pmap, - Handle_type h, const std::set& v) -{ - BOOST_FOREACH(Patch_id n, v) - h->add_incident_patch(n); -} - -template -struct Polyhedron_property_map > -{ - template - struct bind_ - { - typedef Polyhedron_incident_patches_pmap type; - typedef type const_type; - }; -}; - -// template -// inline vertex_incident_patches_pmap -// get(CGAL::vertex_incident_patches_t, -// const Polyhedron_3 >&) -// { -// return vertex_incident_patches_pmap(); -// } - -} // end namespace CGAL - -namespace boost { - - // template - // struct property_map, - // CGAL::vertex_time_stamp_t> - // { - // typedef CGAL::Polyhedron_face_time_stamp_pmap type; - // }; - - // template - // struct property_map, - // CGAL::halfedge_time_stamp_t> - // { - // typedef CGAL::Polyhedron_face_time_stamp_pmap type; - // }; - - // template - // struct property_map, - // CGAL::face_time_stamp_t> - // { - // typedef CGAL::Polyhedron_face_time_stamp_pmap type; - // }; - - // template - // struct property_map, - // CGAL::face_patch_id_t > - // { - // typedef CGAL::Polyhedron_face_patch_id_pmap type; - // }; - - // template - // struct property_map, - // CGAL::vertex_num_feature_edges_t> - // { - // typedef CGAL::Polyhedron_num_feature_edges_pmap type; - // }; - - // template - // struct property_map, - // CGAL::halfedge_is_feature_t> - // { - // typedef CGAL::Polyhedron_is_feature_edge_pmap type; - // }; - - // template - // struct property_map, - // CGAL::vertex_incident_patches_t > - // { - // typedef CGAL::Polyhedron_incident_patches_pmap type; - // }; - -} // namespace boost - -#undef CGAL_HDS_PARAM_ - -#endif // CGAL_PMP_PROPERTIES_POLYHEDRON_3_H diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h index 53c69fab28b..8fa5295751d 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h @@ -184,7 +184,7 @@ void put(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key, const put(pmap, key, value); } -} // boost +} // CGAL // specialization needs to be repeated for halfedge, vertex, face #define CGAL_POLYHEDRON_INDEX_PM(ENTITY, TAG, ACCESSOR) \ @@ -199,7 +199,7 @@ void put(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key, const typedef type const_type; \ }; \ }; \ - } + } //CGAL CGAL_POLYHEDRON_INDEX_PM(halfedge, _index_t, Index) CGAL_POLYHEDRON_INDEX_PM(vertex, _index_t, Index)