Open
Description
Currently, labeling operators return either :
- nothing (see e.g.
include/labeling_operators_on_distortion.h straighten_boundary_with_GCO()
- a boolean : failure or success (most of them)
- an unsigned integer : the number of processed components (see e.g.
include/labeling_operators_on_invalidity.h fix_as_much_invalid_corners_as_possible()
But there are many reasons a labeling operator can fail :
- bad type of input mesh
- no facet attribute linked to the
GEO::MeshHalfedges
instance, so no facet regions and no halfedges on border - while tracing a path on the surface, best next edge for the given direction is the last edge (backtracking)
- did not find the optimal label w.r.t. forbidden axes and orthogonality constraints (see
include/labeling.h find_optimal_label()
) - unexpected feature-edges/boundaries configuration
- etc
Each operator could have a set of return codes :
struct my_operator {
enum return_code {
SUCCESS,
BAD_MESH,
NO_LABELING,
TRACE_PATH_BACKTRACKING,
// etc
};
return_code operator()(/* args */) const {
// labeling operator definition here
return SUCCESS;
}
};
Even better, a payload could be attached to each return code, e.g. to know how many components were processed, or if the operator had nothing to do :
struct my_operator {
struct Success {
unsigned int nb_processed {};
};
struct TracePathBacktracking {
index_t vertex_index {};
MeshHalfedges::Halfedge new_halfedge {};
};
// etc
typedef std::variant<Success,InvalidLabel,/* etc */> return_code;
return_code operator()(/* args */) const {
// labeling operator definition here
// return value:
return Success{count_chart_processed};
// or
return TracePathBacktracking{current_vertex,current_halfedge};
}
};