mirror of https://github.com/CGAL/cgal
metric reference with groups
This commit is contained in:
parent
4bbda56a37
commit
11bcd9fa1e
|
|
@ -11,18 +11,16 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/// \ingroup PkgTSMA
|
||||||
* \ingroup PkgTSMA
|
/// @brief Approximation L21 metric.
|
||||||
* @brief Approximation L21 metric.
|
///
|
||||||
*
|
/// \cgalModels `ErrorMetric`
|
||||||
* \cgalModels`ErrorMetric`
|
///
|
||||||
*
|
/// @tparam TriangleMesh a triangle `FaceListGraph`
|
||||||
* @tparam TriangleMesh a triangle `FaceListGraph`
|
/// @tparam VertexPointMap a property map with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
||||||
* @tparam VertexPointMap a property map with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
/// as key type, GeomTraits::Point_3 as value type
|
||||||
as key type, GeomTraits::Point_3 as value type
|
/// @tparam with_area_weighing set `true` to activate area weighing
|
||||||
* @tparam with_area_weighing set `true` to activate area weighing
|
/// @tparam GeomTraits geometric traits
|
||||||
* @tparam GeomTraits geometric traits
|
|
||||||
*/
|
|
||||||
template <typename TriangleMesh,
|
template <typename TriangleMesh,
|
||||||
typename VertexPointMap
|
typename VertexPointMap
|
||||||
= typename boost::property_map<TriangleMesh, boost::vertex_point_t>::type,
|
= typename boost::property_map<TriangleMesh, boost::vertex_point_t>::type,
|
||||||
|
|
@ -46,10 +44,18 @@ class L21_metric {
|
||||||
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// type required by the `ErrorMetric` concept
|
/// \name Types
|
||||||
|
/// @{
|
||||||
typedef typename GeomTraits::Vector_3 Proxy;
|
typedef typename GeomTraits::Vector_3 Proxy;
|
||||||
|
/// @}
|
||||||
|
|
||||||
// constructor
|
/// \name Constructor
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
* @brief Constructor
|
||||||
|
* @param tm a triangle mesh
|
||||||
|
* @param vpmap vertex point map
|
||||||
|
*/
|
||||||
L21_metric(const TriangleMesh &tm, const VertexPointMap &vpmap) {
|
L21_metric(const TriangleMesh &tm, const VertexPointMap &vpmap) {
|
||||||
GeomTraits traits;
|
GeomTraits traits;
|
||||||
m_scalar_product_functor = traits.compute_scalar_product_3_object();
|
m_scalar_product_functor = traits.compute_scalar_product_3_object();
|
||||||
|
|
@ -70,16 +76,26 @@ public:
|
||||||
put(m_famap, f, std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))));
|
put(m_famap, f, std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
/// \name Operations
|
||||||
// It is a function that takes a facet and a proxy, returns the L21 error between them.
|
/*!
|
||||||
|
* @brief Computes the L21 error between a facet and a proxy.
|
||||||
|
* @param f face_descriptor of a face
|
||||||
|
* @param px proxy
|
||||||
|
* @return computed error
|
||||||
|
*/
|
||||||
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
||||||
Vector_3 v = m_sum_functor(get(m_fnmap, f), m_scale_functor(px, FT(-1.0)));
|
Vector_3 v = m_sum_functor(get(m_fnmap, f), m_scale_functor(px, FT(-1.0)));
|
||||||
return get(m_famap, f) * m_scalar_product_functor(v, v);
|
return get(m_famap, f) * m_scalar_product_functor(v, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
/*!
|
||||||
// It returns the proxy fitted from the facets from beg to end.
|
* @brief Fits a proxy from a face range.
|
||||||
|
* @param beg face range begin
|
||||||
|
* @param end face range end
|
||||||
|
* @return fitted proxy
|
||||||
|
*/
|
||||||
template <typename FacetIterator>
|
template <typename FacetIterator>
|
||||||
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
||||||
CGAL_assertion(beg != end);
|
CGAL_assertion(beg != end);
|
||||||
|
|
@ -95,6 +111,7 @@ public:
|
||||||
|
|
||||||
return norm;
|
return norm;
|
||||||
}
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Face_normal_map m_fnmap;
|
Face_normal_map m_fnmap;
|
||||||
|
|
@ -128,10 +145,10 @@ class L21_metric<TriangleMesh,
|
||||||
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// type required by the `ErrorMetric` concept
|
// Public types
|
||||||
typedef typename GeomTraits::Vector_3 Proxy;
|
typedef typename GeomTraits::Vector_3 Proxy;
|
||||||
|
|
||||||
// constructor
|
// Constructor.
|
||||||
L21_metric(const TriangleMesh &tm, const VertexPointMap &vpmap) {
|
L21_metric(const TriangleMesh &tm, const VertexPointMap &vpmap) {
|
||||||
GeomTraits traits;
|
GeomTraits traits;
|
||||||
m_scalar_product_functor = traits.compute_scalar_product_3_object();
|
m_scalar_product_functor = traits.compute_scalar_product_3_object();
|
||||||
|
|
@ -151,15 +168,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
// Computes the L21 error between a facet and a proxy.
|
||||||
// It is a function that takes a facet and a proxy, returns the L21 error between them.
|
|
||||||
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
||||||
Vector_3 v = m_sum_functor(get(m_fnmap, f), m_scale_functor(px, FT(-1.0)));
|
Vector_3 v = m_sum_functor(get(m_fnmap, f), m_scale_functor(px, FT(-1.0)));
|
||||||
return m_scalar_product_functor(v, v);
|
return m_scalar_product_functor(v, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
// Fits a proxy from a face range.
|
||||||
// It returns the proxy fitted from the facets from beg to end.
|
|
||||||
template <typename FacetIterator>
|
template <typename FacetIterator>
|
||||||
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
||||||
CGAL_assertion(beg != end);
|
CGAL_assertion(beg != end);
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,15 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/// \ingroup PkgTSMA
|
||||||
* \ingroup PkgTSMA
|
/// @brief Approximation L2 metric.
|
||||||
* @brief Approximation L2 metric.
|
///
|
||||||
*
|
/// \cgalModels `ErrorMetric`
|
||||||
* \cgalModels`ErrorMetric`
|
///
|
||||||
*
|
/// @tparam TriangleMesh a triangle `FaceListGraph`
|
||||||
* @tparam TriangleMesh a triangle `FaceListGraph`
|
/// @tparam VertexPointMap a property map with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
||||||
* @tparam VertexPointMap a property map with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
/// as key type, GeomTraits::Point_3 as value type
|
||||||
as key type, GeomTraits::Point_3 as value type
|
/// @tparam GeomTraits geometric traits
|
||||||
* @tparam GeomTraits geometric traits
|
|
||||||
*/
|
|
||||||
template <typename TriangleMesh,
|
template <typename TriangleMesh,
|
||||||
typename VertexPointMap
|
typename VertexPointMap
|
||||||
= typename boost::property_map<TriangleMesh, boost::vertex_point_t>::type,
|
= typename boost::property_map<TriangleMesh, boost::vertex_point_t>::type,
|
||||||
|
|
@ -42,10 +40,18 @@ class L2_metric {
|
||||||
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
typedef typename CGAL::internal::dynamic_property_map<TriangleMesh, Face_area_tag >::type Face_area_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// type required by the `ErrorMetric` concept
|
/// \name Types
|
||||||
|
/// @{
|
||||||
typedef typename GeomTraits::Plane_3 Proxy;
|
typedef typename GeomTraits::Plane_3 Proxy;
|
||||||
|
/// @}
|
||||||
|
|
||||||
// constructor
|
/// \name Constructor
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
* @brief Constructor
|
||||||
|
* @param tm a triangle mesh
|
||||||
|
* @param vpmap vertex point map
|
||||||
|
*/
|
||||||
L2_metric(const TriangleMesh &tm, const VertexPointMap &vpmap)
|
L2_metric(const TriangleMesh &tm, const VertexPointMap &vpmap)
|
||||||
: m_tm(&tm), m_vpmap(vpmap){
|
: m_tm(&tm), m_vpmap(vpmap){
|
||||||
m_famap = CGAL::internal::add_property(
|
m_famap = CGAL::internal::add_property(
|
||||||
|
|
@ -59,9 +65,15 @@ public:
|
||||||
put(m_famap, f, std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))));
|
put(m_famap, f, std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
/// \name Operations
|
||||||
// It is a function that takes a facet and a proxy, returns the L21 error between them.
|
/*!
|
||||||
|
* @brief Computes the L21 error between a facet and a proxy.
|
||||||
|
* @param f face_descriptor of a face
|
||||||
|
* @param px proxy
|
||||||
|
* @return computed error
|
||||||
|
*/
|
||||||
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
FT compute_error(const face_descriptor &f, const Proxy &px) const {
|
||||||
halfedge_descriptor he = halfedge(f, *m_tm);
|
halfedge_descriptor he = halfedge(f, *m_tm);
|
||||||
const Point_3 &p0 = m_vpmap[source(he, *m_tm)];
|
const Point_3 &p0 = m_vpmap[source(he, *m_tm)];
|
||||||
|
|
@ -77,8 +89,12 @@ public:
|
||||||
return (sq_d0 + sq_d1 + sq_d2 + d0 * d1 + d1 * d2 + d2 * d0) * get(m_famap, f) / FT(6.0);
|
return (sq_d0 + sq_d1 + sq_d2 + d0 * d1 + d1 * d2 + d2 * d0) * get(m_famap, f) / FT(6.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// member function required by the `ErrorMetric` concept
|
/*!
|
||||||
// It returns the proxy fitted from the facets from beg to end.
|
* @brief Fits a proxy from a face range.
|
||||||
|
* @param beg face range begin
|
||||||
|
* @param end face range end
|
||||||
|
* @return fitted proxy
|
||||||
|
*/
|
||||||
template <typename FacetIterator>
|
template <typename FacetIterator>
|
||||||
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
Proxy fit_proxy(const FacetIterator beg, const FacetIterator end) const {
|
||||||
CGAL_assertion(beg != end);
|
CGAL_assertion(beg != end);
|
||||||
|
|
@ -104,6 +120,7 @@ public:
|
||||||
|
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const TriangleMesh *m_tm;
|
const TriangleMesh *m_tm;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue