// Copyright (c) 2014 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) : Philipp Möller #ifndef CGAL_PROPERTIES_SURFACE_MESH_H #define CGAL_PROPERTIES_SURFACE_MESH_H #include #include #include #include #include #include #include namespace CGAL { template class SM_edge_weight_pmap : public boost::put_get_helper::type::FT, SM_edge_weight_pmap > { typedef CGAL::Surface_mesh SM; public: typedef boost::readable_property_map_tag category; typedef typename CGAL::Kernel_traits::type::FT value_type; typedef value_type reference; typedef typename SM::Edge_index key_type; SM_edge_weight_pmap(const CGAL::Surface_mesh& sm) : pm_(sm. template property_map< typename SM::Vertex_index, typename SM::Point >("v:point").first), sm_(sm) {} value_type operator[](const key_type& e) const { return approximate_sqrt(CGAL::squared_distance(pm_[source(e, sm_)], pm_[target(e, sm_)])); } private: typename SM::template Property_map< typename SM::Vertex_index, typename SM::Point > pm_; const SM& sm_; }; template class SM_index_pmap : public boost::put_get_helper > { public: typedef boost::readable_property_map_tag category; typedef boost::uint32_t value_type; typedef boost::uint32_t reference; typedef VEF key_type; value_type operator[](const key_type& vd) const { return vd; } }; } // CGAL // overloads and specializations in the boost namespace namespace boost { #if 1 template struct property_map, boost::vertex_property_t > { typedef CGAL::Surface_mesh SM; typedef typename SM:: template Property_map type; typedef type const_type; }; #endif // // edge_weight // template struct property_map, boost::edge_weight_t > { typedef CGAL::SM_edge_weight_pmap type; typedef CGAL::SM_edge_weight_pmap const_type; }; } namespace CGAL{ template typename boost::property_map, boost::edge_weight_t>::const_type get(boost::edge_weight_t, const CGAL::Surface_mesh& sm) { return CGAL::SM_edge_weight_pmap(sm); } // forward declarations, see class SM_Vertex_index; class SM_Edge_index; class SM_Halfedge_index; class SM_Face_index; template typename CGAL::Kernel_traits::type::FT get(boost::edge_weight_t, const CGAL::Surface_mesh& sm, const SM_Edge_index& e) { return CGAL::SM_edge_weight_pmap(sm)[e]; } } // // vertex_index // namespace boost{ template struct property_map, boost::vertex_index_t > { typedef CGAL::SM_index_pmap >::vertex_descriptor> type; typedef CGAL::SM_index_pmap >::vertex_descriptor> const_type; }; } namespace CGAL{ template CGAL::SM_index_pmap get(const boost::vertex_index_t&, const CGAL::Surface_mesh&) { return CGAL::SM_index_pmap >::vertex_descriptor>(); } } // // face_index // namespace boost{ template struct property_map, boost::face_index_t > { typedef CGAL::SM_index_pmap >::face_descriptor> type; typedef CGAL::SM_index_pmap >::face_descriptor> const_type; }; } namespace CGAL{ template CGAL::SM_index_pmap get(const boost::face_index_t&, const CGAL::Surface_mesh&) { return CGAL::SM_index_pmap >::face_descriptor>(); } } // // edge_index // namespace boost{ template struct property_map, boost::edge_index_t > { typedef CGAL::SM_index_pmap >::edge_descriptor> type; typedef CGAL::SM_index_pmap >::edge_descriptor> const_type; }; } namespace CGAL{ template CGAL::SM_index_pmap get(const boost::edge_index_t&, const CGAL::Surface_mesh&) { return CGAL::SM_index_pmap >::edge_descriptor>(); } } // // halfedge_index // namespace boost{ template struct property_map, boost::halfedge_index_t > { typedef CGAL::SM_index_pmap >::halfedge_descriptor> type; typedef CGAL::SM_index_pmap >::halfedge_descriptor> const_type; }; } namespace CGAL{ template CGAL::SM_index_pmap get(const boost::halfedge_index_t&, const CGAL::Surface_mesh&) { return CGAL::SM_index_pmap >::halfedge_descriptor>(); } } // // vertex_point // namespace boost{ template struct property_map, CGAL::vertex_point_t > { typedef CGAL::Surface_mesh

SM; typedef typename SM::template Property_map< typename SM::Vertex_index, P > type; typedef type const_type; }; } namespace CGAL{ namespace internal { template struct Get_vertex_point_map_for_Surface_mesh_return_type { typedef typename boost::property_map < CGAL::Surface_mesh, CGAL::vertex_point_t >::const_type type; }; } // end namespace internal template typename boost::lazy_disable_if < boost::is_const, internal::Get_vertex_point_map_for_Surface_mesh_return_type >::type get(CGAL::vertex_point_t, const CGAL::Surface_mesh& g) { return g.points(); } namespace internal { template struct Get_graph_traits_of_SM { typedef boost::graph_traits< CGAL::Surface_mesh > type; }; } // end namespace internal // get for intrinsic properties #define CGAL_SM_INTRINSIC_PROPERTY(RET, PROP, TYPE) \ template \ RET \ get(PROP p, const CGAL::Surface_mesh& sm, \ const TYPE& x) \ { return get(get(p, sm), x); } \ CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::vertex_index_t, SM_Vertex_index) CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::edge_index_t, SM_Edge_index) CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::halfedge_index_t, SM_Halfedge_index) CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::face_index_t, SM_Face_index) CGAL_SM_INTRINSIC_PROPERTY(Point&, CGAL::vertex_point_t, SM_Vertex_index) #undef CGAL_SM_INTRINSIC_PROPERTY // put for intrinsic properties // only available for vertex_point template void put(CGAL::vertex_point_t p, const CGAL::Surface_mesh& g, typename boost::graph_traits< CGAL::Surface_mesh >::vertex_descriptor x, const Point& point) { typedef CGAL::Surface_mesh SM; CGAL_assertion(g.is_valid(x)); typename SM::template Property_map< typename boost::graph_traits::vertex_descriptor, Point> prop = get(p, g); prop[x] = point; } } // CGAL #if 0 // namespace CGAL { template typename boost::property_map, boost::vertex_property_t >::const_type get(boost::vertex_property_t vprop, const CGAL::Surface_mesh& sm) { return sm.template get_property_map::Vertex_index, T>(vprop.s).first; } template typename boost::property_map, boost::vertex_property_t >::const_type add(boost::vertex_property_t vprop, CGAL::Surface_mesh& sm) { return sm.template add_property_map::Vertex_index, T>(vprop.s, vprop.t).first; } template void remove(Pmap pm, CGAL::Surface_mesh

& sm) { return sm.remove_property_map(pm); } } // namespace CGAL #endif #endif /* CGAL_PROPERTIES_SURFACE_MESH_H */