Rework default value implementation

This commit is contained in:
Mael Rouxel-Labbé 2023-03-27 13:14:53 +02:00
parent ce4c6d574e
commit 6c9b99defd
1 changed files with 11 additions and 13 deletions

View File

@ -81,6 +81,9 @@ enum class Slope
VERTICAL
};
template <typename FT>
const FT default_extrusion_height = { (std::numeric_limits<double>::max)() };
// @todo Maybe this postprocessing is not really necessary? Do users really care if the point
// is not perfectly above the input contour edge (it generally cannot be anyway if the kernel is not exact except for some
// specific cases)?
@ -318,9 +321,6 @@ class Extrusion_builder
private:
Geom_traits m_gt;
public:
static constexpr FT default_height = FT((std::numeric_limits<double>::max)());
public:
Extrusion_builder(const Geom_traits& gt) : m_gt(gt) { }
@ -500,7 +500,7 @@ public:
const bool ignore_frame_faces = false,
const bool invert_faces = false)
{
CGAL_precondition(height != default_height);
CGAL_precondition(height != default_extrusion_height<FT>);
const bool extrude_upwards = is_positive(height);
const FT abs_height = CGAL::abs(height);
@ -624,7 +624,7 @@ public:
// @partial_wsls_pwh interior SLS of weighted polygons with holes can have skeleton faces with holes
// The current postprocessing is in the function EnforceSimpleConnectedness, but it has not yet
// been made compatible with partial skeletons.
if(height == default_height || pwh.number_of_holes() != 0)
if(height == default_extrusion_height<FT> || pwh.number_of_holes() != 0)
{
ss_ptr = CGAL::create_interior_weighted_straight_skeleton_2(
CGAL_SS_i::vertices_begin(pwh.outer_boundary()),
@ -657,7 +657,7 @@ public:
CGAL::draw(*ss_ptr);
#endif
if(height == default_height)
if(height == default_extrusion_height<FT>)
{
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
construct_lateral_faces(*ss_ptr, points, faces, vertical_weight, snapped_positions);
@ -665,7 +665,7 @@ public:
construct_lateral_faces(*ss_ptr, points, faces);
#endif
}
else // height != default_height
else // height != default_extrusion_height<FT>
{
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
Visitor visitor(*ss_ptr, offset_points, vertical_weight, snapped_positions);
@ -710,7 +710,7 @@ public:
FaceRange& faces)
{
CGAL_precondition(!is_zero(height));
CGAL_precondition(height != default_height); // was checked before, this is just a reminder
CGAL_precondition(height != default_extrusion_height<FT>); // was checked before, this is just a reminder
const FT abs_height = abs(height);
@ -976,8 +976,7 @@ bool extrude_skeleton(const PolygonWithHoles& pwh,
const bool verbose = choose_parameter(get_parameter(np, internal_np::verbose), false);
Geom_traits gt = choose_parameter<Geom_traits>(get_parameter(np, CGAL::internal_np::geom_traits));
const FT height = choose_parameter(get_parameter(np, internal_np::maximum_height),
Extrusion_builder<Geom_traits>::default_height);
const FT height = choose_parameter(get_parameter(np, internal_np::maximum_height), default_extrusion_height<FT>);
Slope slope;
bool valid_input;
@ -1004,9 +1003,7 @@ bool extrude_skeleton(const PolygonWithHoles& pwh,
// End of preprocessing, start the actual skeleton computation
Extrusion_builder<Geom_traits> builder(gt);
if(slope != Slope::INWARD && height == builder.default_height)
if(slope != Slope::INWARD && height == default_extrusion_height<FT>)
{
if(verbose)
std::cerr << "Error: height must be specified when using an outward (or vertical) slope" << std::endl;
@ -1019,6 +1016,7 @@ bool extrude_skeleton(const PolygonWithHoles& pwh,
points.reserve(2 * pwh.outer_boundary().size()); // just a reasonnable guess
faces.reserve(2 * pwh.outer_boundary().size() + 2*pwh.number_of_holes());
Extrusion_builder<Geom_traits> builder(gt);
bool res;
if(slope != Slope::OUTWARD) // INWARD or VERTICAL
res = builder.inward_construction(pwh, weights, vertical_weight, height, points, faces);