mirror of https://github.com/CGAL/cgal
Rework default value implementation
This commit is contained in:
parent
ce4c6d574e
commit
6c9b99defd
|
|
@ -81,6 +81,9 @@ enum class Slope
|
||||||
VERTICAL
|
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
|
// @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
|
// is not perfectly above the input contour edge (it generally cannot be anyway if the kernel is not exact except for some
|
||||||
// specific cases)?
|
// specific cases)?
|
||||||
|
|
@ -318,9 +321,6 @@ class Extrusion_builder
|
||||||
private:
|
private:
|
||||||
Geom_traits m_gt;
|
Geom_traits m_gt;
|
||||||
|
|
||||||
public:
|
|
||||||
static constexpr FT default_height = FT((std::numeric_limits<double>::max)());
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Extrusion_builder(const Geom_traits& gt) : m_gt(gt) { }
|
Extrusion_builder(const Geom_traits& gt) : m_gt(gt) { }
|
||||||
|
|
||||||
|
|
@ -500,7 +500,7 @@ public:
|
||||||
const bool ignore_frame_faces = false,
|
const bool ignore_frame_faces = false,
|
||||||
const bool invert_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 bool extrude_upwards = is_positive(height);
|
||||||
const FT abs_height = CGAL::abs(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
|
// @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
|
// The current postprocessing is in the function EnforceSimpleConnectedness, but it has not yet
|
||||||
// been made compatible with partial skeletons.
|
// 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(
|
ss_ptr = CGAL::create_interior_weighted_straight_skeleton_2(
|
||||||
CGAL_SS_i::vertices_begin(pwh.outer_boundary()),
|
CGAL_SS_i::vertices_begin(pwh.outer_boundary()),
|
||||||
|
|
@ -657,7 +657,7 @@ public:
|
||||||
CGAL::draw(*ss_ptr);
|
CGAL::draw(*ss_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(height == default_height)
|
if(height == default_extrusion_height<FT>)
|
||||||
{
|
{
|
||||||
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
|
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
|
||||||
construct_lateral_faces(*ss_ptr, points, faces, vertical_weight, snapped_positions);
|
construct_lateral_faces(*ss_ptr, points, faces, vertical_weight, snapped_positions);
|
||||||
|
|
@ -665,7 +665,7 @@ public:
|
||||||
construct_lateral_faces(*ss_ptr, points, faces);
|
construct_lateral_faces(*ss_ptr, points, faces);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else // height != default_height
|
else // height != default_extrusion_height<FT>
|
||||||
{
|
{
|
||||||
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
|
#ifdef CGAL_SLS_SNAP_TO_VERTICAL_SLABS
|
||||||
Visitor visitor(*ss_ptr, offset_points, vertical_weight, snapped_positions);
|
Visitor visitor(*ss_ptr, offset_points, vertical_weight, snapped_positions);
|
||||||
|
|
@ -710,7 +710,7 @@ public:
|
||||||
FaceRange& faces)
|
FaceRange& faces)
|
||||||
{
|
{
|
||||||
CGAL_precondition(!is_zero(height));
|
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);
|
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);
|
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));
|
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),
|
const FT height = choose_parameter(get_parameter(np, internal_np::maximum_height), default_extrusion_height<FT>);
|
||||||
Extrusion_builder<Geom_traits>::default_height);
|
|
||||||
|
|
||||||
Slope slope;
|
Slope slope;
|
||||||
bool valid_input;
|
bool valid_input;
|
||||||
|
|
@ -1004,9 +1003,7 @@ bool extrude_skeleton(const PolygonWithHoles& pwh,
|
||||||
|
|
||||||
// End of preprocessing, start the actual skeleton computation
|
// End of preprocessing, start the actual skeleton computation
|
||||||
|
|
||||||
Extrusion_builder<Geom_traits> builder(gt);
|
if(slope != Slope::INWARD && height == default_extrusion_height<FT>)
|
||||||
|
|
||||||
if(slope != Slope::INWARD && height == builder.default_height)
|
|
||||||
{
|
{
|
||||||
if(verbose)
|
if(verbose)
|
||||||
std::cerr << "Error: height must be specified when using an outward (or vertical) slope" << std::endl;
|
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
|
points.reserve(2 * pwh.outer_boundary().size()); // just a reasonnable guess
|
||||||
faces.reserve(2 * pwh.outer_boundary().size() + 2*pwh.number_of_holes());
|
faces.reserve(2 * pwh.outer_boundary().size() + 2*pwh.number_of_holes());
|
||||||
|
|
||||||
|
Extrusion_builder<Geom_traits> builder(gt);
|
||||||
bool res;
|
bool res;
|
||||||
if(slope != Slope::OUTWARD) // INWARD or VERTICAL
|
if(slope != Slope::OUTWARD) // INWARD or VERTICAL
|
||||||
res = builder.inward_construction(pwh, weights, vertical_weight, height, points, faces);
|
res = builder.inward_construction(pwh, weights, vertical_weight, height, points, faces);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue