I am running edge collapse on a mesh with 134 million faces. I am using the example code from here:
https://doc.cgal.org/latest/Surface_mesh_simplification/index.html#title20
“Example using Garland-Heckbert policies”
With this particular mesh, I now encounter the following error:
terminate called after throwing an instance of 'CGAL::Precondition_exception'
what(): CGAL ERROR: precondition violation!
Expr: !get(vcm(), profile.v0()).isZero(0)
File: /nix/store/6x9gp50r6njnbb3whhn5d49v01ig016c-cgal-5.5.2/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/internal/GarlandHeckbert_policy_base.h
Line: 227
This is the broader context of the precondition violation:
// class GarlandHeckbert_cost_and_placement
// Cost
template <typename Profile>
boost::optional<typename Profile::FT>
operator()(const Profile& profile,
const boost::optional<typename Profile::Point>& placement) const
{
typedef boost::optional<typename Profile::FT> Optional_FT;
if(!placement)
return boost::optional<typename Profile::FT>();
CGAL_precondition(!get(vcm(), profile.v0()).isZero(0));
CGAL_precondition(!get(vcm(), profile.v1()).isZero(0));
const Mat_4 combined_matrix = combine_matrices(get(vcm(), profile.v0()),
get(vcm(), profile.v1()));
const Col_4 pt = point_to_homogenous_column(*placement);
const Optional_FT cost = (pt.transpose() * combined_matrix * pt)(0, 0);
return cost;
}
in file Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/internal/GarlandHeckbert_policy_base.h
This doesn’t happen on every mesh, but already on a couple meshes.
I can’t provide a sample mesh for easy reproduction yet (client data).
I prefer using Garland-Heckbert over Lindstrom-Turk because of this issue with Lindstrom-Turk.
The way I understand the failed precondition:
profile.v0()
andprofile.v1()
are two vertices of some edge.get
makes a lookup in the “vertex cost map”/vcm
, which probably gives the cost associated with the deletion of each vertex- this cost can’t be exactly zero
Any idea how to go about debugging this? It would be interesting to know if this condition is linked to a certain characteristic in my input mesh.
There is no obvious weirdness in my input mesh by just looking at it.