mirror of https://github.com/CGAL/cgal
The edge_weight must be the lenth, and not the squared length
This commit is contained in:
parent
f940302044
commit
20c97edb12
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
#include <CGAL/Linear_cell_complex.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
|
||||
#define CGAL_LCC_ARGS unsigned int d_, unsigned int ambient_dim, \
|
||||
class Traits_, \
|
||||
|
|
@ -37,18 +38,20 @@ namespace CGAL {
|
|||
template<class LCC>
|
||||
class LCC_edge_weight_map : public boost::put_get_helper<double, LCC>
|
||||
{
|
||||
typedef typename LCC::Point Point;
|
||||
typedef typename Kernel_traits<Point>::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<LCC const>::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())));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
#include <CGAL/squared_distance_2_1.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS
|
||||
|
|
@ -84,23 +85,19 @@ private:
|
|||
boost::shared_ptr<Map> map_;
|
||||
};
|
||||
|
||||
template<typename Handle>
|
||||
template<typename Handle, typename FT>
|
||||
struct Wrap_squared
|
||||
: boost::put_get_helper< double, Wrap_squared<Handle> >
|
||||
: boost::put_get_helper< double, Wrap_squared<Handle,FT> >
|
||||
{
|
||||
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<typename E>
|
||||
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<boost::edge_weight_t>
|
|||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
struct bind_
|
||||
{
|
||||
typedef internal::Wrap_squared<
|
||||
typename boost::graph_traits<
|
||||
CGAL::Polyhedron_3<Gt, I, HDS, A>
|
||||
>::edge_descriptor > type;
|
||||
typedef typename CGAL::Polyhedron_3<Gt, I, HDS, A>::Traits::FT FT;
|
||||
typedef typename boost::graph_traits<CGAL::Polyhedron_3<Gt, I, HDS, A> >::edge_descriptor edge_descriptor;
|
||||
typedef internal::Wrap_squared<edge_descriptor,FT> type;
|
||||
typedef type const_type;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
#include <CGAL/squared_distance_3.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue