mirror of https://github.com/CGAL/cgal
simplify self-defined metric
This commit is contained in:
parent
261a5ca218
commit
bd3dcc8ebc
|
|
@ -23,12 +23,10 @@ typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPoint
|
|||
typedef boost::associative_property_map<std::map<Facet_handle, FT> > FacetAreaMap;
|
||||
typedef boost::associative_property_map<std::map<Facet_handle, Point> > FacetCenterMap;
|
||||
|
||||
// proxy
|
||||
struct PointProxy {
|
||||
Point center;
|
||||
};
|
||||
// use a point as proxy
|
||||
typedef Point PointProxy;
|
||||
|
||||
// metric functor
|
||||
// user defined point-wise compact metric
|
||||
struct CompactMetric {
|
||||
typedef PointProxy Proxy;
|
||||
|
||||
|
|
@ -38,9 +36,9 @@ struct CompactMetric {
|
|||
|
||||
// calculate the error of a facet to a proxy
|
||||
// here is just the Euclidean distance
|
||||
FT operator()(const Facet_handle &f, const PointProxy &px) const {
|
||||
FT operator()(const Facet_handle &f, const Proxy &px) const {
|
||||
return FT(std::sqrt(CGAL::to_double(
|
||||
CGAL::squared_distance(center_pmap[f], px.center))));
|
||||
CGAL::squared_distance(center_pmap[f], px))));
|
||||
}
|
||||
|
||||
const FacetCenterMap center_pmap;
|
||||
|
|
@ -56,7 +54,7 @@ struct PointProxyFitting {
|
|||
|
||||
// a template functor fit a new proxy from a range of facets
|
||||
template<typename FacetIterator>
|
||||
PointProxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
||||
Proxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
||||
// fitting center
|
||||
Vector center = CGAL::NULL_VECTOR;
|
||||
FT area = FT(0.0);
|
||||
|
|
@ -65,12 +63,7 @@ struct PointProxyFitting {
|
|||
area += area_pmap[*fitr];
|
||||
}
|
||||
center = center / area;
|
||||
|
||||
// construct proxy
|
||||
PointProxy px;
|
||||
px.center = CGAL::ORIGIN + center;
|
||||
|
||||
return px;
|
||||
return CGAL::ORIGIN + center;
|
||||
}
|
||||
|
||||
const FacetCenterMap center_pmap;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public:
|
|||
/*!
|
||||
* Initialize and prepare for the approximation.
|
||||
* @param _mesh `CGAL TriangleMesh` on which approximation operate.
|
||||
* @param _point_map vertex point map of the mesh
|
||||
* @param _point_pmap vertex point map of the mesh
|
||||
*/
|
||||
VSA_approximation(const TriangleMesh &_mesh,
|
||||
const VertexPointMap &_point_pmap) :
|
||||
|
|
@ -267,7 +267,7 @@ public:
|
|||
* Set the mesh for approximation and rebuild the internal data structure.
|
||||
* @pre @a _mesh.is_pure_triangle()
|
||||
* @param _mesh `CGAL TriangleMesh` on which approximation operate.
|
||||
* @param _point_map vertex point map of the mesh
|
||||
* @param _point_pmap vertex point map of the mesh
|
||||
*/
|
||||
void set_mesh(const TriangleMesh &_mesh, const VertexPointMap &_point_pmap) {
|
||||
m_pmesh = &_mesh;
|
||||
|
|
@ -484,9 +484,9 @@ public:
|
|||
|
||||
/*!
|
||||
* @brief Adding proxies. The proxies are not updated via fitting process.
|
||||
* @param num_proxies number of proxies
|
||||
* @param adding_method select one of the adding method: hierarchical or incremental(furthest).
|
||||
* @param inner_iteration the coarse re-fitting iteration before incremental insertion
|
||||
* @param num_proxies number of proxies
|
||||
* @param inner_iteration coarse re-fitting before each insertion if incremental is selected
|
||||
* @return number of proxies successfully added.
|
||||
*/
|
||||
std::size_t add_proxies(const Initialization &adding_method,
|
||||
|
|
|
|||
|
|
@ -22,32 +22,29 @@ typedef boost::associative_property_map<std::map<Facet_handle, FT> > FacetAreaMa
|
|||
typedef boost::associative_property_map<std::map<Facet_handle, Point> > FacetCenterMap;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VertexPointMap;
|
||||
|
||||
struct PointProxy {
|
||||
Point center;
|
||||
};
|
||||
|
||||
// user defined point-wise compact metric
|
||||
struct CompactMetric {
|
||||
typedef PointProxy Proxy;
|
||||
typedef Point Proxy;
|
||||
|
||||
CompactMetric(const FacetCenterMap &_center_pmap)
|
||||
: center_pmap(_center_pmap) {}
|
||||
|
||||
FT operator()(const Facet_handle &f, const PointProxy &px) const {
|
||||
FT operator()(const Facet_handle &f, const Proxy &px) const {
|
||||
return FT(std::sqrt(CGAL::to_double(
|
||||
CGAL::squared_distance(center_pmap[f], px.center))));
|
||||
CGAL::squared_distance(center_pmap[f], px))));
|
||||
}
|
||||
|
||||
const FacetCenterMap center_pmap;
|
||||
};
|
||||
|
||||
struct PointProxyFitting {
|
||||
typedef PointProxy Proxy;
|
||||
typedef Point Proxy;
|
||||
|
||||
PointProxyFitting(const FacetCenterMap &_center_pmap, const FacetAreaMap &_area_pmap)
|
||||
: center_pmap(_center_pmap), area_pmap(_area_pmap) {}
|
||||
|
||||
template<typename FacetIterator>
|
||||
PointProxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
||||
Proxy operator()(const FacetIterator beg, const FacetIterator end) const {
|
||||
// fitting center
|
||||
Vector center = CGAL::NULL_VECTOR;
|
||||
FT area(0);
|
||||
|
|
@ -56,12 +53,7 @@ struct PointProxyFitting {
|
|||
area += area_pmap[*fitr];
|
||||
}
|
||||
center = center / area;
|
||||
|
||||
// construct proxy
|
||||
PointProxy px;
|
||||
px.center = CGAL::ORIGIN + center;
|
||||
|
||||
return px;
|
||||
return CGAL::ORIGIN + center;
|
||||
}
|
||||
|
||||
const FacetCenterMap center_pmap;
|
||||
|
|
|
|||
Loading…
Reference in New Issue