diff --git a/BGL/examples/BGL_polyhedron_3/kruskal.cpp b/BGL/examples/BGL_polyhedron_3/kruskal.cpp index f06179f34b2..1080b250cd4 100644 --- a/BGL/examples/BGL_polyhedron_3/kruskal.cpp +++ b/BGL/examples/BGL_polyhedron_3/kruskal.cpp @@ -42,7 +42,7 @@ kruskal(const Polyhedron& P) } - // We use the default edge weight which is the squared length of the edge + // We use the default edge weight which is the length of the edge // This property map is defined in graph_traits_Polyhedron_3.h // In the function call you can see a named parameter: vertex_index_map diff --git a/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp b/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp index 85207e466ca..5d811882822 100644 --- a/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp +++ b/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp @@ -23,7 +23,7 @@ void kruskal( const Polyhedron& P) { - // We use the default edge weight which is the squared length of the edge + // We use the default edge weight which is the length of the edge // This property map is defined in graph_traits_Polyhedron_3.h // This function call requires a vertex_index_map named parameter which diff --git a/BGL/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h b/BGL/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h index 98ec63d738c..8b36e09112a 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h @@ -273,7 +273,7 @@ namespace CGAL { { } typename Gt::FT operator[](key_type e) const { - return tr.segment(e).squared_length(); + return approximate_sqrt(tr.segment(e).squared_length()); } }; diff --git a/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h b/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h index 695d15d1494..6d5d426bbf0 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h @@ -695,7 +695,7 @@ namespace CGAL { { } value_type operator[](key_type e) const { - return tr.segment(e).squared_length(); + return approximate_sqrt(tr.segment(e).squared_length()); } }; diff --git a/BGL/include/CGAL/boost/graph/properties_CombinatorialMap.h b/BGL/include/CGAL/boost/graph/properties_CombinatorialMap.h index ba6259ee7be..30daae2c0e3 100644 --- a/BGL/include/CGAL/boost/graph/properties_CombinatorialMap.h +++ b/BGL/include/CGAL/boost/graph/properties_CombinatorialMap.h @@ -22,6 +22,7 @@ #include #include #include +#include #define CGAL_LCC_ARGS unsigned int d_, unsigned int ambient_dim, \ class Traits_, \ @@ -37,18 +38,20 @@ namespace CGAL { template class LCC_edge_weight_map : public boost::put_get_helper { + typedef typename LCC::Point Point; + typedef typename Kernel_traits::Kernel::FT FT; public: - typedef boost::readable_property_map_tag category; - typedef double value_type; - typedef double reference; + typedef boost::readable_property_map_tag category; + typedef FT value_type; + typedef FT reference; typedef typename boost::graph_traits::edge_descriptor key_type; LCC_edge_weight_map(LCC const& ) {} reference operator[](key_type const& e) const { - return CGAL::squared_distance(LCC::point(e), LCC::point(e->opposite())); + return approximate_sqrt(CGAL::squared_distance(LCC::point(e), LCC::point(e->opposite()))); } }; diff --git a/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h b/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h index 7db008288df..af3fdc49c32 100644 --- a/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h +++ b/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS @@ -84,23 +85,19 @@ private: boost::shared_ptr map_; }; -template + template struct Wrap_squared - : boost::put_get_helper< double, Wrap_squared > + : boost::put_get_helper< double, Wrap_squared > { - typedef double value_type; - typedef double reference; + typedef FT value_type; + typedef FT reference; typedef Handle key_type; typedef boost::readable_property_map_tag category; template - double - // TODO Kernel::FT, this is as bad as the old code, we need to - // forward the halfedge type in HDS_edge to extract the kernel here. - // Technically, there is also a general implementation for - // HalfedgeGraph to prevent duplication in Surface_mesh. + FT operator[](const E& e) const { - return CGAL::squared_distance(e.halfedge()->vertex()->point(), e.halfedge()->opposite()->vertex()->point()); + return approximate_sqrt(CGAL::squared_distance(e.halfedge()->vertex()->point(), e.halfedge()->opposite()->vertex()->point())); } }; @@ -229,10 +226,9 @@ struct Polyhedron_property_map template struct bind_ { - typedef internal::Wrap_squared< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::edge_descriptor > type; + typedef typename CGAL::Polyhedron_3::Traits::FT FT; + typedef typename boost::graph_traits >::edge_descriptor edge_descriptor; + typedef internal::Wrap_squared type; typedef type const_type; }; }; diff --git a/BGL/include/CGAL/boost/graph/properties_Surface_mesh.h b/BGL/include/CGAL/boost/graph/properties_Surface_mesh.h index 1da0fc360e3..cf91c647c8c 100644 --- a/BGL/include/CGAL/boost/graph/properties_Surface_mesh.h +++ b/BGL/include/CGAL/boost/graph/properties_Surface_mesh.h @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -52,8 +53,8 @@ public: value_type operator[](const key_type& e) const { - return CGAL::sqrt(CGAL::squared_distance(pm_[source(e, sm_)], - pm_[target(e, sm_)])); + return approximate_sqrt(CGAL::squared_distance(pm_[source(e, sm_)], + pm_[target(e, sm_)])); } private: