Avoid cascade with EPECK centroid (#9027)

This commit is contained in:
Sebastien Loriot 2025-08-13 18:01:32 +02:00 committed by GitHub
commit 69dbbae2e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 16 deletions

View File

@ -112,23 +112,19 @@ template<class T>inline std::enable_if_t<std::is_empty<T>::value, int> depth(T){
namespace internal{
template <typename AT, typename ET, typename E2A>
struct Evaluate<Lazy<AT, ET, E2A>>
template <typename ET>
struct Evaluate<Lazy_exact_nt<ET>>
{
template <typename AT, typename ET2, typename E2A>
void operator()(const Lazy<AT, ET2, E2A>& l)
{
void operator()(const Lazy<AT, ET, E2A>& l)
{
exact(l);
}
exact(l);
}
void operator()(const Lazy_exact_nt<ET>& l)
{
exact(l);
}
};
template <typename ET>
struct Evaluate<Lazy_exact_nt<ET>>
{
void operator()(const Lazy_exact_nt<ET>& l)
{
exact(l);
}
};
} // internal namespace
// For an iterator, exact/approx applies to the objects it points to

View File

@ -272,7 +272,8 @@ namespace internal
template <class NT>
struct Evaluate
{
void operator()(const NT&)
template <class T>
void operator()(const T&)
{}
};
} // internal namespace

View File

@ -893,6 +893,8 @@ centroid(const TriangleMesh& tmesh,
Scale scale = k.construct_scaled_vector_3_object();
Sum sum = k.construct_sum_of_vectors_3_object();
::CGAL::internal::Evaluate<FT> evaluate;
for(face_descriptor fd : faces(tmesh))
{
const Point_3_ref p = get(vpm, target(halfedge(fd, tmesh), tmesh));
@ -903,6 +905,7 @@ centroid(const TriangleMesh& tmesh,
vr = vector(ORIGIN, r);
Vector_3 n = normal(p, q, r);
volume += (scalar_product(n,vp))/FT(6);
evaluate(volume);
n = scale(n, FT(1)/FT(24));
Vector_3 v2 = sum(vp, vq);
@ -913,6 +916,7 @@ centroid(const TriangleMesh& tmesh,
v3 = sum(v3, Vector_3(square(v2.x()), square(v2.y()), square(v2.z())));
centroid = sum(centroid, Vector_3(n.x() * v3.x(), n.y() * v3.y(), n.z() * v3.z()));
evaluate(centroid);
}
centroid = scale(centroid, FT(1)/(FT(2)*volume));