mirror of https://github.com/CGAL/cgal
add a function compute_quadrics_from_vertex in GH_policies_base
This commit is contained in:
parent
7063e4e261
commit
3413272070
|
|
@ -32,6 +32,15 @@ class Plane_quadric_calculator
|
||||||
public:
|
public:
|
||||||
Plane_quadric_calculator() { }
|
Plane_quadric_calculator() { }
|
||||||
|
|
||||||
|
template <typename VertexPointMap>
|
||||||
|
Mat_4 construct_quadric_from_vertex(typename boost::graph_traits<TriangleMesh>::vertex_descriptor v,
|
||||||
|
const TriangleMesh& tmesh,
|
||||||
|
const VertexPointMap point_map,
|
||||||
|
const GeomTraits& gt) const
|
||||||
|
{
|
||||||
|
return Mat_4::Zero();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VertexPointMap>
|
template <typename VertexPointMap>
|
||||||
Mat_4 construct_quadric_from_edge(typename boost::graph_traits<TriangleMesh>::halfedge_descriptor he,
|
Mat_4 construct_quadric_from_edge(typename boost::graph_traits<TriangleMesh>::halfedge_descriptor he,
|
||||||
const TriangleMesh& tmesh,
|
const TriangleMesh& tmesh,
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template <typename VertexPointMap>
|
||||||
|
Mat_4 construct_quadric_from_vertex(typename boost::graph_traits<TriangleMesh>::vertex_descriptor v,
|
||||||
|
const TriangleMesh& tmesh,
|
||||||
|
const VertexPointMap point_map,
|
||||||
|
const GeomTraits& gt) const
|
||||||
|
{
|
||||||
|
return Mat_4::Zero();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VertexPointMap>
|
template <typename VertexPointMap>
|
||||||
Mat_4 construct_quadric_from_edge(const halfedge_descriptor he,
|
Mat_4 construct_quadric_from_edge(const halfedge_descriptor he,
|
||||||
const TriangleMesh& tmesh,
|
const TriangleMesh& tmesh,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ private:
|
||||||
|
|
||||||
// this is only used when we fall back to probabilistic planes for the discontinuous edges,
|
// this is only used when we fall back to probabilistic planes for the discontinuous edges,
|
||||||
// the actual triangle quadric calculation only uses the normal variance
|
// the actual triangle quadric calculation only uses the normal variance
|
||||||
static constexpr FT position_variance_factor = 1;
|
static constexpr FT position_variance_factor = 0.1;
|
||||||
|
|
||||||
Face_variance_map m_face_variance_map;
|
Face_variance_map m_face_variance_map;
|
||||||
|
|
||||||
|
|
@ -74,6 +74,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template <typename VertexPointMap>
|
||||||
|
Mat_4 construct_quadric_from_vertex(typename boost::graph_traits<TriangleMesh>::vertex_descriptor v,
|
||||||
|
const TriangleMesh& tmesh,
|
||||||
|
const VertexPointMap point_map,
|
||||||
|
const GeomTraits& gt) const
|
||||||
|
{
|
||||||
|
return Mat_4::Zero();
|
||||||
|
}
|
||||||
|
|
||||||
// we don't have a sensible way to construct a triangle quadric
|
// we don't have a sensible way to construct a triangle quadric
|
||||||
// from an edge, so we fall back to probabilistic plane quadrics here
|
// from an edge, so we fall back to probabilistic plane quadrics here
|
||||||
template<typename VertexPointMap>
|
template<typename VertexPointMap>
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,15 @@ class Triangle_quadric_calculator
|
||||||
public:
|
public:
|
||||||
Triangle_quadric_calculator() { }
|
Triangle_quadric_calculator() { }
|
||||||
|
|
||||||
|
template <typename VertexPointMap>
|
||||||
|
Mat_4 construct_quadric_from_vertex(typename boost::graph_traits<TriangleMesh>::vertex_descriptor v,
|
||||||
|
const TriangleMesh& tmesh,
|
||||||
|
const VertexPointMap point_map,
|
||||||
|
const GeomTraits& gt) const
|
||||||
|
{
|
||||||
|
return Mat_4::Zero();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VertexPointMap>
|
template <typename VertexPointMap>
|
||||||
Mat_4 construct_quadric_from_edge(typename boost::graph_traits<TriangleMesh>::halfedge_descriptor he,
|
Mat_4 construct_quadric_from_edge(typename boost::graph_traits<TriangleMesh>::halfedge_descriptor he,
|
||||||
const TriangleMesh& tmesh,
|
const TriangleMesh& tmesh,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include <CGAL/license/Surface_mesh_simplification.h>
|
#include <CGAL/license/Surface_mesh_simplification.h>
|
||||||
|
|
||||||
|
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
|
||||||
|
|
||||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||||
#include <CGAL/boost/graph/helpers.h>
|
#include <CGAL/boost/graph/helpers.h>
|
||||||
|
|
||||||
|
|
@ -508,6 +510,77 @@ construct_prob_triangle_quadric_from_face(typename boost::graph_traits<TriangleM
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// LINE QUADRICS (Liu et al. 2025)
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <typename GeomTraits>
|
||||||
|
typename GarlandHeckbert_matrix_types<GeomTraits>::Mat_4
|
||||||
|
construct_line_quadric_from_normal(const typename GeomTraits::Vector_3& normal,
|
||||||
|
const typename GeomTraits::Point_3& point,
|
||||||
|
const GeomTraits& gt)
|
||||||
|
{
|
||||||
|
typedef typename GeomTraits::FT FT;
|
||||||
|
typedef typename GeomTraits::Vector_3 Vector_3;
|
||||||
|
|
||||||
|
typedef typename GarlandHeckbert_matrix_types<GeomTraits>::Row_4 Row_4;
|
||||||
|
|
||||||
|
auto cp = gt.construct_cross_product_vector_3_object();
|
||||||
|
auto plane = gt.construct_plane_3_object();
|
||||||
|
auto c_point = gt.construct_point_3_object();
|
||||||
|
auto base= gt.construct_base_vector_3_object();
|
||||||
|
|
||||||
|
Vector_3 x=base(plane(c_point(0,0,0),normal), 1);
|
||||||
|
CGAL::Polygon_mesh_processing::internal::normalize(x, gt);
|
||||||
|
Vector_3 y=cp(x,normal);
|
||||||
|
|
||||||
|
return construct_classic_plane_quadric_from_normal(x, point, gt)+construct_classic_plane_quadric_from_normal(y, point, gt);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename TriangleMesh, typename VertexPointMap, typename GeomTraits>
|
||||||
|
typename GarlandHeckbert_matrix_types<GeomTraits>::Mat_4
|
||||||
|
construct_line_quadric_from_vertex(const typename boost::graph_traits<TriangleMesh>::vertex_descriptor v,
|
||||||
|
const TriangleMesh& mesh,
|
||||||
|
const VertexPointMap vpm,
|
||||||
|
const GeomTraits& gt)
|
||||||
|
{
|
||||||
|
typedef typename GeomTraits::Vector_3 Vector_3;
|
||||||
|
|
||||||
|
const Vector_3 normal = Polygon_mesh_processing::compute_vertex_normal(v, mesh, parameters::geom_traits(gt).vertex_point_map(vpm));
|
||||||
|
return construct_line_quadric_from_normal(normal, get(vpm, v), gt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// template <typename TriangleMesh, typename VertexPointMap, typename GeomTraits>
|
||||||
|
// typename GarlandHeckbert_matrix_types<GeomTraits>::Mat_4
|
||||||
|
// construct_classic_line_quadric_from_edge(typename boost::graph_traits<TriangleMesh>::halfedge_descriptor he,
|
||||||
|
// const TriangleMesh& mesh,
|
||||||
|
// const VertexPointMap vpm,
|
||||||
|
// const GeomTraits& gt)
|
||||||
|
// {
|
||||||
|
// typedef typename GeomTraits::Vector_3 Vector_3;
|
||||||
|
|
||||||
|
// const Vector_3 normal = construct_edge_normal(he, mesh, vpm, gt);
|
||||||
|
|
||||||
|
// // use this normal to construct the quadric analogously to constructing quadric
|
||||||
|
// // from the normal of the face
|
||||||
|
// return construct_classic_line_quadric_from_normal(normal, get(vpm, target(he, mesh)), gt);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <typename TriangleMesh, typename VertexPointMap, typename GeomTraits>
|
||||||
|
// typename GarlandHeckbert_matrix_types<GeomTraits>::Mat_4
|
||||||
|
// construct_classic_line_quadric_from_face(typename boost::graph_traits<TriangleMesh>::face_descriptor f,
|
||||||
|
// const TriangleMesh& mesh,
|
||||||
|
// const VertexPointMap vpm,
|
||||||
|
// const GeomTraits& gt)
|
||||||
|
// {
|
||||||
|
// auto normal = construct_unit_normal_from_face(f, mesh, vpm, gt);
|
||||||
|
|
||||||
|
// // get any point of the face
|
||||||
|
// const auto p = get(vpm, target(halfedge(f, mesh), mesh));
|
||||||
|
|
||||||
|
// return construct_classic_line_quadric_from_normal(normal, p, gt);
|
||||||
|
// }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// PROB VARIANCE
|
/// PROB VARIANCE
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template <typename VertexPointMap>
|
||||||
|
Mat_4 construct_quadric(const vertex_descriptor v,
|
||||||
|
const TriangleMesh& tmesh,
|
||||||
|
const VertexPointMap vpm,
|
||||||
|
const GeomTraits& gt) const
|
||||||
|
{
|
||||||
|
return quadric_calculator().construct_quadric_from_vertex(v, tmesh, vpm, gt);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VertexPointMap>
|
template <typename VertexPointMap>
|
||||||
Mat_4 construct_quadric(const halfedge_descriptor he,
|
Mat_4 construct_quadric(const halfedge_descriptor he,
|
||||||
const TriangleMesh& tmesh,
|
const TriangleMesh& tmesh,
|
||||||
|
|
@ -157,7 +166,7 @@ public:
|
||||||
Mat_4 zero_mat = Mat_4::Zero();
|
Mat_4 zero_mat = Mat_4::Zero();
|
||||||
|
|
||||||
for(vertex_descriptor v : vertices(tmesh))
|
for(vertex_descriptor v : vertices(tmesh))
|
||||||
put(vcm(), v, zero_mat);
|
put(vcm(), v, construct_quadric(v, tmesh, vpm, gt));
|
||||||
|
|
||||||
for(face_descriptor f : faces(tmesh))
|
for(face_descriptor f : faces(tmesh))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue