mirror of https://github.com/CGAL/cgal
better unified NP
This commit is contained in:
parent
918fb882d5
commit
9acece5b28
|
|
@ -72,7 +72,7 @@ int main() {
|
|||
};
|
||||
|
||||
Regularizer regularizer(
|
||||
objects, neighbor_query, regularization_type, quadratic_program, Kernel());
|
||||
objects, neighbor_query, regularization_type, quadratic_program);
|
||||
regularizer.regularize();
|
||||
|
||||
std::cout << "* regularized 2 objects" << std::endl;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#include <CGAL/Shape_regularization/regularize_contours.h>
|
||||
|
||||
// Typedefs.
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using FT = typename Kernel::FT;
|
||||
using Point_2 = typename Kernel::Point_2;
|
||||
using Contour = std::vector<Point_2>;
|
||||
using Point_map = CGAL::Identity_property_map<Point_2>;
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using FT = typename Kernel::FT;
|
||||
using Point_2 = typename Kernel::Point_2;
|
||||
using Contour = std::vector<Point_2>;
|
||||
|
||||
using Contour_directions =
|
||||
CGAL::Shape_regularization::Contours::Longest_direction_2<Kernel, Contour, Point_map>;
|
||||
CGAL::Shape_regularization::Contours::Longest_direction_2<Kernel, Contour>;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
|
@ -35,8 +34,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Regularize.
|
||||
const bool is_closed = false;
|
||||
Contour_directions directions(
|
||||
contour, is_closed, Point_map());
|
||||
Contour_directions directions(contour, is_closed);
|
||||
|
||||
std::vector<Point_2> regularized;
|
||||
CGAL::Shape_regularization::Contours::regularize_open_contour(
|
||||
|
|
|
|||
|
|
@ -53,10 +53,11 @@ int main(int argc, char** argv) {
|
|||
// Regularize detected planes.
|
||||
CGAL::Shape_regularization::Planes::regularize_planes(
|
||||
planes,
|
||||
Plane_map(),
|
||||
points,
|
||||
Point_map(),
|
||||
CGAL::parameters::plane_index_map(
|
||||
CGAL::parameters::
|
||||
plane_map(Plane_map()).
|
||||
point_map(Point_map()).
|
||||
plane_index_map(
|
||||
CGAL::Shape_detection::Point_to_shape_index_map<Traits>(points, planes)).
|
||||
regularize_coplanarity(false). // do not regularize coplanarity
|
||||
maximum_angle(FT(10))); // 10 degrees of tolerance for parallelism / orthogonality
|
||||
|
|
|
|||
|
|
@ -70,25 +70,39 @@ namespace Contours {
|
|||
/*!
|
||||
\brief initializes all internal data structures.
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param input_range
|
||||
a const range of ordered 2D points, which form a contour
|
||||
|
||||
\param is_closed
|
||||
indicates whether the contour is closed or open
|
||||
|
||||
\param point_map
|
||||
an instance of `PointMap` that maps an item from input range to `GeomTraits::Point_2`;
|
||||
this parameter can be omitted, the identity map `CGAL::Identity_property_map` is then used
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{point_map}
|
||||
\cgalParamDescription{an instance of `PointMap` that maps an item from `input_range`
|
||||
to `GeomTraits::Point_2`}
|
||||
\cgalParamDefault{`PointMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre input_range.size() >= 3 for closed contours
|
||||
\pre input_range.size() >= 2 for open contours
|
||||
*/
|
||||
template<typename NamedParameters>
|
||||
Longest_direction_2(
|
||||
const InputRange& input_range,
|
||||
const bool is_closed,
|
||||
const PointMap point_map = PointMap()) :
|
||||
const NamedParameters& np) :
|
||||
m_input_range(input_range),
|
||||
m_point_map(point_map) {
|
||||
m_point_map(parameters::choose_parameter(parameters::get_parameter(
|
||||
np, internal_np::point_map), PointMap())) {
|
||||
|
||||
CGAL_precondition(m_input_range.size() >= 2);
|
||||
|
||||
|
|
@ -107,6 +121,15 @@ namespace Contours {
|
|||
}
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
Longest_direction_2(
|
||||
const InputRange& input_range,
|
||||
const bool is_closed) :
|
||||
Longest_direction_2(
|
||||
input_range, is_closed, CGAL::parameters::all_default())
|
||||
{ }
|
||||
/// \endcond
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Directions
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ namespace Contours {
|
|||
\tparam DirectionRange
|
||||
a model of `ConstRange` whose value type is `GeomTraits::Direction_2`
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param input_range
|
||||
a const range of ordered 2D points, which form a contour
|
||||
|
||||
|
|
@ -83,9 +86,18 @@ namespace Contours {
|
|||
\param direction_range
|
||||
a const range with user-specified principal directions
|
||||
|
||||
\param point_map
|
||||
an instance of `PointMap` that maps an item from input range to `GeomTraits::Point_2`;
|
||||
this parameter can be omitted, the identity map `CGAL::Identity_property_map` is then used
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{point_map}
|
||||
\cgalParamDescription{an instance of `PointMap` that maps an item from `input_range`
|
||||
to `GeomTraits::Point_2`}
|
||||
\cgalParamDefault{`PointMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre direction_range.size() >= 1
|
||||
\pre direction_range.size() == input_range.size() for closed contours
|
||||
|
|
@ -94,14 +106,17 @@ namespace Contours {
|
|||
\pre input_range.size() >= 3 for closed contours
|
||||
\pre input_range.size() >= 2 for open contours
|
||||
*/
|
||||
template<typename DirectionRange>
|
||||
template<
|
||||
typename DirectionRange,
|
||||
typename NamedParameters>
|
||||
User_defined_directions_2(
|
||||
const InputRange& input_range,
|
||||
const bool is_closed,
|
||||
const DirectionRange& direction_range,
|
||||
const PointMap point_map = PointMap()) :
|
||||
const NamedParameters& np) :
|
||||
m_input_range(input_range),
|
||||
m_point_map(point_map),
|
||||
m_point_map(parameters::choose_parameter(parameters::get_parameter(
|
||||
np, internal_np::point_map), PointMap())),
|
||||
m_max_angle_2(FT(5)) {
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
|
|
@ -124,6 +139,17 @@ namespace Contours {
|
|||
}
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<typename DirectionRange>
|
||||
User_defined_directions_2(
|
||||
const InputRange& input_range,
|
||||
const bool is_closed,
|
||||
const DirectionRange& direction_range) :
|
||||
User_defined_directions_2(
|
||||
input_range, is_closed, direction_range, CGAL::parameters::all_default())
|
||||
{ }
|
||||
/// \endcond
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Directions
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ namespace Shape_regularization {
|
|||
/*!
|
||||
\brief initializes all internal data structures.
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param input_range
|
||||
a const range of input objects for shape regularization
|
||||
|
||||
|
|
@ -121,28 +124,51 @@ namespace Shape_regularization {
|
|||
\param quadratic_program
|
||||
an instance of `QPSolver` to solve the quadratic programming problem
|
||||
|
||||
\param traits
|
||||
an instance of `GeomTraits`; this parameter can be omitted if the traits class
|
||||
can be deduced from the input value type
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{geom_traits}
|
||||
\cgalParamDescription{an instance of geometric traits class}
|
||||
\cgalParamType{a model of `Kernel`}
|
||||
\cgalParamDefault{`GeomTraits()`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
*/
|
||||
template<typename NamedParameters>
|
||||
QP_regularization(
|
||||
const InputRange& input_range,
|
||||
NeighQuery& neighbor_query,
|
||||
RegType& regularization_type,
|
||||
QPSolver& quadratic_program,
|
||||
const GeomTraits& traits = GeomTraits()) :
|
||||
const NamedParameters& np) :
|
||||
m_input_range(input_range),
|
||||
m_neighbor_query(neighbor_query),
|
||||
m_regularization_type(regularization_type),
|
||||
m_quadratic_program(quadratic_program),
|
||||
m_traits(traits),
|
||||
m_traits(parameters::choose_parameter(parameters::get_parameter(
|
||||
np, internal_np::geom_traits), GeomTraits())),
|
||||
m_parameters(Parameters()) {
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
QP_regularization(
|
||||
const InputRange& input_range,
|
||||
NeighQuery& neighbor_query,
|
||||
RegType& regularization_type,
|
||||
QPSolver& quadratic_program) :
|
||||
QP_regularization(
|
||||
input_range, neighbor_query, regularization_type, quadratic_program,
|
||||
CGAL::parameters::all_default())
|
||||
{ }
|
||||
/// \endcond
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Regularization
|
||||
|
|
@ -238,7 +264,7 @@ namespace Shape_regularization {
|
|||
|
||||
// The field m_traits is not currently used. We should probably remove the
|
||||
// reference in case it will be used in the future!
|
||||
const Traits& m_traits;
|
||||
const Traits m_traits;
|
||||
const Parameters m_parameters;
|
||||
|
||||
FT m_max_bound;
|
||||
|
|
|
|||
|
|
@ -84,25 +84,47 @@ namespace Segments {
|
|||
/*!
|
||||
\brief initializes all internal data structures.
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param input_range
|
||||
a const range of 2D segments
|
||||
|
||||
\param segment_map
|
||||
an instance of `SegmentMap` that maps an item from input range to `GeomTraits::Segment_2`;
|
||||
this parameter can be omitted, the identity map `CGAL::Identity_property_map` is then used
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{segment_map}
|
||||
\cgalParamDescription{an instance of `SegmentMap` that maps an item from `input_range`
|
||||
to `GeomTraits::Segment_2`}
|
||||
\cgalParamDefault{`SegmentMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
*/
|
||||
template<typename NamedParameters>
|
||||
Delaunay_neighbor_query_2(
|
||||
const InputRange& input_range,
|
||||
const SegmentMap segment_map = SegmentMap()) :
|
||||
const NamedParameters& np) :
|
||||
m_input_range(input_range),
|
||||
m_segment_map(segment_map) {
|
||||
m_segment_map(parameters::choose_parameter(parameters::get_parameter(
|
||||
np, internal_np::segment_map), SegmentMap())) {
|
||||
|
||||
clear();
|
||||
create_unique_group();
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
Delaunay_neighbor_query_2(
|
||||
InputRange& input_range) :
|
||||
Delaunay_neighbor_query_2(
|
||||
input_range, CGAL::parameters::all_default())
|
||||
{ }
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\brief inserts a group of segments from `input_range` and finds their
|
||||
neighbors within the group.
|
||||
|
|
|
|||
|
|
@ -127,8 +127,10 @@ namespace Contours {
|
|||
using Point_2 = typename PointMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Point_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
PointMap point_map;
|
||||
const PointMap point_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::point_map), PointMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 3);
|
||||
using Contour_regularizer =
|
||||
|
|
@ -176,12 +178,13 @@ namespace Contours {
|
|||
CGAL_precondition(input_range.size() >= 3);
|
||||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Point_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using Kernel = typename Kernel_traits<Point_2>::Kernel;
|
||||
using Contour_directions = Longest_direction_2<Kernel, InputRange>;
|
||||
using GeomTraits = typename Kernel_traits<Point_2>::Kernel;
|
||||
using Contour_directions = Longest_direction_2<GeomTraits, InputRange>;
|
||||
GeomTraits traits;
|
||||
|
||||
Contour_directions directions(input_range, true);
|
||||
return regularize_closed_contour(
|
||||
input_range, directions, contour);
|
||||
input_range, directions, contour, CGAL::parameters::geom_traits(traits));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -266,8 +269,10 @@ namespace Contours {
|
|||
using Point_2 = typename PointMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Point_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
PointMap point_map;
|
||||
const PointMap point_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::point_map), PointMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Contour_regularizer =
|
||||
|
|
@ -315,12 +320,13 @@ namespace Contours {
|
|||
CGAL_precondition(input_range.size() >= 3);
|
||||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Point_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using Kernel = typename Kernel_traits<Point_2>::Kernel;
|
||||
using Contour_directions = Longest_direction_2<Kernel, InputRange>;
|
||||
using GeomTraits = typename Kernel_traits<Point_2>::Kernel;
|
||||
using Contour_directions = Longest_direction_2<GeomTraits, InputRange>;
|
||||
GeomTraits traits;
|
||||
|
||||
Contour_directions directions(input_range, false);
|
||||
return regularize_open_contour(
|
||||
input_range, directions, contour);
|
||||
input_range, directions, contour, CGAL::parameters::geom_traits(traits));
|
||||
}
|
||||
|
||||
} // namespace Contours
|
||||
|
|
|
|||
|
|
@ -276,109 +276,7 @@ namespace Planes {
|
|||
#ifdef CGAL_TYPENAME_FOR_MSC
|
||||
#undef CGAL_TYPENAME_FOR_MSC
|
||||
#endif
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefPlanes
|
||||
|
||||
\brief Hierarchical plane regularization.
|
||||
|
||||
Given a set of detected planes with their corresponding inlier sets,
|
||||
this function enables to reinforce four types of regularities among these planes:
|
||||
- *Parallelism*: planes, which are detected as near parallel, are made exactly parallel.
|
||||
- *Orthogonality*: planes, which are detected as near orthogonal, are made exactly orthogonal.
|
||||
- *Coplanarity*: parallel planes, which are detected as near coplanar, are made exactly coplanar.
|
||||
- *Axis-Symmetry*: planes, which are detected as near symmetrical with respect to a user-specified axis,
|
||||
are made exactly symmetrical.
|
||||
|
||||
%Planes are directly modified. Points are left unaltered, as well as their
|
||||
relationship to the planes (no transfer of a point from a primitive plane to another).
|
||||
|
||||
This function infers a traits class `GeomTraits` from the `PointMap` value type.
|
||||
|
||||
The implementation follows \cgalCite{cgal:vla-lod-15}.
|
||||
|
||||
\tparam PlaneRange
|
||||
a model of `Range` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam PlaneMap
|
||||
a model of `WritablePropertyMap` with the value type `CGAL::Plane_3<GeomTraits>`
|
||||
|
||||
\tparam PointRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam PointMap
|
||||
a model of `ReadablePropertyMap` with the value type `CGAL::Point_3<GeomTraits>`
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param planes
|
||||
a range of planes to be regularized
|
||||
|
||||
\param plane_map
|
||||
an instance of `PlaneMap` that maps an item from plane range to `GeomTraits::Plane_3`
|
||||
|
||||
\param points
|
||||
a const range of points assigned to planes, see the `plane_index_map` below
|
||||
for more details
|
||||
|
||||
\param point_map
|
||||
an instance of `PointMap` that maps an item from point range to `GeomTraits::Point_3`
|
||||
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{plane_index_map}
|
||||
\cgalParamDescription{a property map that associates the index of a point
|
||||
in the `points` range to the index of a plane in the `planes` range (-1 if
|
||||
point is not assigned to a plane)}
|
||||
\cgalParamType{a model of `ReadablePropertyMap` with `std::size_t` as key type
|
||||
and `int` as value type}
|
||||
\cgalParamDefault{no default value}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{maximum_angle}
|
||||
\cgalParamDescription{maximum allowed angle in degrees between plane normals used
|
||||
for parallelism, orthogonality, and axis symmetry}
|
||||
\cgalParamType{`GeomTraits::FT`}
|
||||
\cgalParamDefault{25 degrees}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{maximum_offset}
|
||||
\cgalParamDescription{maximum allowed orthogonal distance between two parallel planes
|
||||
such that they are considered to be coplanar}
|
||||
\cgalParamType{`GeomTraits::FT`}
|
||||
\cgalParamDefault{0.01 unit length}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_parallelism}
|
||||
\cgalParamDescription{indicates whether parallelism should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_orthogonality}
|
||||
\cgalParamDescription{indicates whether orthogonality should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_coplanarity}
|
||||
\cgalParamDescription{indicates whether coplanarity should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_axis_symmetry}
|
||||
\cgalParamDescription{indicates whether axis symmetry should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{symmetry_direction}
|
||||
\cgalParamDescription{an axis for symmetry regularization}
|
||||
\cgalParamType{`GeomTraits::Vector_3`}
|
||||
\cgalParamDefault{Z axis that is `GeomTraits::Vector_3(0, 0, 1)`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
*/
|
||||
template<
|
||||
typename PlaneRange,
|
||||
typename PlaneMap,
|
||||
|
|
@ -440,7 +338,6 @@ namespace Planes {
|
|||
tol_angle, tol_copln, sym_dir);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<
|
||||
typename PlaneRange,
|
||||
typename PlaneMap,
|
||||
|
|
@ -457,6 +354,141 @@ namespace Planes {
|
|||
}
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefPlanes
|
||||
|
||||
\brief Hierarchical plane regularization.
|
||||
|
||||
Given a set of detected planes with their corresponding inlier sets,
|
||||
this function enables to reinforce four types of regularities among these planes:
|
||||
- *Parallelism*: planes, which are detected as near parallel, are made exactly parallel.
|
||||
- *Orthogonality*: planes, which are detected as near orthogonal, are made exactly orthogonal.
|
||||
- *Coplanarity*: parallel planes, which are detected as near coplanar, are made exactly coplanar.
|
||||
- *Axis-Symmetry*: planes, which are detected as near symmetrical with respect to a user-specified axis,
|
||||
are made exactly symmetrical.
|
||||
|
||||
%Planes are directly modified. Points are left unaltered, as well as their
|
||||
relationship to the planes (no transfer of a point from a primitive plane to another).
|
||||
|
||||
This function infers a traits class `GeomTraits` from the `PointRange` value type.
|
||||
|
||||
The implementation follows \cgalCite{cgal:vla-lod-15}.
|
||||
|
||||
\tparam PlaneRange
|
||||
a model of `Range` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam PointRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param planes
|
||||
a range of planes to be regularized
|
||||
|
||||
\param points
|
||||
a const range of points assigned to planes, see the `plane_index_map` below
|
||||
for more details
|
||||
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{plane_map}
|
||||
\cgalParamDescription{a property map that maps a plane from `planes` range to `CGAL::Plane_3<GeomTraits>`}
|
||||
\cgalParamType{a model of `WritablePropertyMap` with the value type `CGAL::Plane_3<GeomTraits>`}
|
||||
\cgalParamDefault{`PlaneMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{point_map}
|
||||
\cgalParamDescription{a property map that maps a point from `points` range to `CGAL::Point_3<GeomTraits>`}
|
||||
\cgalParamType{a model of `ReadablePropertyMap` with the value type `CGAL::Point_3<GeomTraits>`}
|
||||
\cgalParamDefault{`PointMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{plane_index_map}
|
||||
\cgalParamDescription{a property map that associates the index of a point
|
||||
in the `points` range to the index of a plane in the `planes` range (-1 if
|
||||
point is not assigned to a plane)}
|
||||
\cgalParamType{a model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type}
|
||||
\cgalParamDefault{`PlaneIndexMap()`}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{maximum_angle}
|
||||
\cgalParamDescription{maximum allowed angle in degrees between plane normals used
|
||||
for parallelism, orthogonality, and axis symmetry}
|
||||
\cgalParamType{`GeomTraits::FT`}
|
||||
\cgalParamDefault{25 degrees}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{maximum_offset}
|
||||
\cgalParamDescription{maximum allowed orthogonal distance between two parallel planes
|
||||
such that they are considered to be coplanar}
|
||||
\cgalParamType{`GeomTraits::FT`}
|
||||
\cgalParamDefault{0.01 unit length}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_parallelism}
|
||||
\cgalParamDescription{indicates whether parallelism should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_orthogonality}
|
||||
\cgalParamDescription{indicates whether orthogonality should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_coplanarity}
|
||||
\cgalParamDescription{indicates whether coplanarity should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{regularize_axis_symmetry}
|
||||
\cgalParamDescription{indicates whether axis symmetry should be regularized or not}
|
||||
\cgalParamType{boolean}
|
||||
\cgalParamDefault{true}
|
||||
\cgalParamNEnd
|
||||
\cgalParamNBegin{symmetry_direction}
|
||||
\cgalParamDescription{an axis for symmetry regularization}
|
||||
\cgalParamType{`GeomTraits::Vector_3`}
|
||||
\cgalParamDefault{Z axis that is `GeomTraits::Vector_3(0, 0, 1)`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
*/
|
||||
template<
|
||||
typename PlaneRange,
|
||||
typename PointRange,
|
||||
typename NamedParameters>
|
||||
void regularize_planes(
|
||||
PlaneRange& planes,
|
||||
const PointRange& points,
|
||||
const NamedParameters& np) {
|
||||
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
using PlaneMap = typename CGAL::Point_set_processing_3::
|
||||
GetPlaneMap<PlaneRange, NamedParameters>::type;
|
||||
const PlaneMap plane_map =
|
||||
choose_parameter(get_parameter(np, internal_np::plane_map), PlaneMap());
|
||||
|
||||
using PointMap = typename CGAL::
|
||||
GetPointMap<PointRange, NamedParameters>::type;
|
||||
const PointMap point_map =
|
||||
choose_parameter(get_parameter(np, internal_np::point_map), PointMap());
|
||||
|
||||
regularize_planes(planes, plane_map, points, point_map, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<
|
||||
typename PlaneRange,
|
||||
typename PointRange>
|
||||
void regularize_planes(
|
||||
PlaneRange& planes, const PointRange& points) {
|
||||
|
||||
regularize_planes(
|
||||
planes, points, CGAL::parameters::all_default());
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
} // namespace Planes
|
||||
} // namespace Shape_regularization
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ namespace Segments {
|
|||
\tparam QPSolver
|
||||
a model of `QuadraticProgramTraits`
|
||||
|
||||
\tparam GeomTraits
|
||||
a model of `Kernel`
|
||||
\tparam NamedParameters
|
||||
a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param input_range
|
||||
a const range of input segments for shape regularization
|
||||
|
|
@ -92,21 +92,32 @@ namespace Segments {
|
|||
an instance of `NeighQuery` that is used internally to
|
||||
access neighbors of a segment; this parameter can be omitted together
|
||||
with the `regularization_type` parameter, in this case, all types of regularities
|
||||
will be reinforced on the whole input range
|
||||
will be reinforced on the whole input range and the default solver will be used (see below)
|
||||
|
||||
\param regularization_type
|
||||
an instance of `RegType` that is used internally to
|
||||
obtain bounds and target values required by the regularization;
|
||||
this parameter can be omitted together with the `neighbor_query` parameter,
|
||||
in this case, all types of regularities will be reinforced on the whole input range
|
||||
and the default solver will be used (see below)
|
||||
|
||||
\param quadratic_program
|
||||
an instance of `QPSolver` to solve the quadratic programming problem;
|
||||
this parameter can be omitted, the default solver is `CGAL::OSQP_quadratic_program_traits`
|
||||
|
||||
\param traits
|
||||
an instance of `GeomTraits`; this parameter can be omitted if the traits class
|
||||
can be deduced from the input value type
|
||||
\param np
|
||||
an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
among the ones listed below; this parameter can be omitted,
|
||||
the default values are then used
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{geom_traits}
|
||||
\cgalParamDescription{an instance of geometric traits class}
|
||||
\cgalParamType{a model of `Kernel`}
|
||||
\cgalParamDefault{a CGAL `Kernel` deduced from the point type,
|
||||
using `CGAL::Kernel_traits`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
|
||||
|
|
@ -118,135 +129,49 @@ namespace Segments {
|
|||
typename NeighQuery,
|
||||
typename RegType,
|
||||
typename QPSolver,
|
||||
typename GeomTraits>
|
||||
typename NamedParameters>
|
||||
void regularize_segments(
|
||||
InputRange& input_range,
|
||||
NeighQuery& neighbor_query,
|
||||
RegType& regularization_type,
|
||||
QPSolver& quadratic_program,
|
||||
const GeomTraits& traits) {
|
||||
const NamedParameters& np) {
|
||||
|
||||
using SegmentMap = typename internal::GetSegmentMap<InputRange, NamedParameters>::type;
|
||||
using Segment_2 = typename SegmentMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Regularizer = QP_regularization<
|
||||
GeomTraits, InputRange, NeighQuery, RegType, QPSolver>;
|
||||
|
||||
Regularizer regularizer(
|
||||
input_range, neighbor_query, regularization_type, quadratic_program, traits);
|
||||
input_range, neighbor_query, regularization_type, quadratic_program, np);
|
||||
regularizer.regularize();
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefSegments
|
||||
|
||||
\brief regularizes angles in a set of 2D segments.
|
||||
|
||||
Given a set of unordered 2D segments, this function enables to reinforce
|
||||
two types of regularities among these segments:
|
||||
- *Parallelism*: segments, which are detected as near parallel, are made exactly parallel.
|
||||
- *Orthogonality*: segments, which are detected as near orthogonal, are made exactly orthogonal.
|
||||
|
||||
\tparam InputRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam GeomTraits
|
||||
a model of `Kernel`
|
||||
|
||||
\param input_range
|
||||
a const range of input segments for angle regularization
|
||||
|
||||
\param traits
|
||||
an instance of `GeomTraits`; this parameter can be omitted if the traits class
|
||||
can be deduced from the input value type
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
|
||||
\sa `regularize_segments()`
|
||||
\sa `regularize_offsets()`
|
||||
*/
|
||||
template<
|
||||
typename InputRange,
|
||||
typename GeomTraits>
|
||||
void regularize_angles(
|
||||
InputRange& input_range,
|
||||
const GeomTraits& traits) {
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Neighbor_query = Delaunay_neighbor_query_2<GeomTraits, InputRange>;
|
||||
using Angle_regularization = Angle_regularization_2<GeomTraits, InputRange>;
|
||||
|
||||
Neighbor_query neighbor_query(input_range);
|
||||
Angle_regularization angle_regularization(input_range);
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, angle_regularization, traits);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefSegments
|
||||
|
||||
\brief regularizes offsets in a set of 2D segments.
|
||||
|
||||
Given a set of parallel 2D segments, this function enables to reinforce
|
||||
the collinearity property among these segments that is all parallel segments,
|
||||
which are detected as near collinear, are made exactly collinear.
|
||||
|
||||
\tparam InputRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\tparam GeomTraits
|
||||
a model of `Kernel`
|
||||
|
||||
\param input_range
|
||||
a const range of input segments for offset regularization
|
||||
|
||||
\param traits
|
||||
an instance of `GeomTraits`; this parameter can be omitted if the traits class
|
||||
can be deduced from the input value type
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
|
||||
\sa `regularize_segments()`
|
||||
\sa `regularize_angles()`
|
||||
*/
|
||||
template<
|
||||
typename InputRange,
|
||||
typename GeomTraits>
|
||||
void regularize_offsets(
|
||||
InputRange& input_range,
|
||||
const GeomTraits& traits) {
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Neighbor_query = Delaunay_neighbor_query_2<GeomTraits, InputRange>;
|
||||
using Offset_regularization = Offset_regularization_2<GeomTraits, InputRange>;
|
||||
|
||||
Neighbor_query neighbor_query(input_range);
|
||||
Offset_regularization offset_regularization(input_range);
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, offset_regularization, traits);
|
||||
}
|
||||
|
||||
#if defined(CGAL_USE_OSQP) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<
|
||||
typename InputRange,
|
||||
typename NeighQuery,
|
||||
typename RegType,
|
||||
typename GeomTraits>
|
||||
typename QPSolver>
|
||||
void regularize_segments(
|
||||
InputRange& input_range,
|
||||
NeighQuery& neighbor_query,
|
||||
RegType& regularization_type,
|
||||
const GeomTraits& traits) {
|
||||
QPSolver& quadratic_program) {
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using FT = typename GeomTraits::FT;
|
||||
using QP = CGAL::OSQP_quadratic_program_traits<FT>;
|
||||
QP quadratic_program;
|
||||
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, regularization_type, quadratic_program, traits);
|
||||
input_range, neighbor_query, regularization_type, quadratic_program,
|
||||
CGAL::parameters::all_default());
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
#if defined(CGAL_USE_OSQP) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<
|
||||
typename InputRange,
|
||||
typename NeighQuery,
|
||||
|
|
@ -267,17 +192,19 @@ namespace Segments {
|
|||
QP quadratic_program;
|
||||
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, regularization_type, quadratic_program, traits);
|
||||
input_range, neighbor_query, regularization_type, quadratic_program,
|
||||
CGAL::parameters::geom_traits(traits));
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputRange,
|
||||
typename GeomTraits>
|
||||
template<typename InputRange>
|
||||
void regularize_segments(
|
||||
InputRange& input_range,
|
||||
const GeomTraits& traits) {
|
||||
InputRange& input_range) {
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Segment_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using GeomTraits = typename Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
using Indices = std::vector<std::size_t>;
|
||||
using Neighbor_query = Delaunay_neighbor_query_2<GeomTraits, InputRange>;
|
||||
using Angle_regularization = Angle_regularization_2<GeomTraits, InputRange>;
|
||||
|
|
@ -287,7 +214,7 @@ namespace Segments {
|
|||
Neighbor_query neighbor_query(input_range);
|
||||
Angle_regularization angle_regularization(input_range);
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, angle_regularization, traits);
|
||||
input_range, neighbor_query, angle_regularization);
|
||||
|
||||
std::vector<Indices> parallel_groups;
|
||||
angle_regularization.parallel_groups(
|
||||
|
|
@ -301,22 +228,33 @@ namespace Segments {
|
|||
offset_regularization.add_group(parallel_group);
|
||||
}
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, offset_regularization, traits);
|
||||
input_range, neighbor_query, offset_regularization);
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
template<typename InputRange>
|
||||
void regularize_segments(
|
||||
InputRange& input_range) {
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefSegments
|
||||
|
||||
CGAL_precondition(input_range.size() >= 2);
|
||||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Segment_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using GeomTraits = typename Kernel_traits<Segment_2>::Kernel;
|
||||
GeomTraits traits;
|
||||
\brief regularizes angles in a set of 2D segments.
|
||||
|
||||
regularize_segments(input_range, traits);
|
||||
}
|
||||
Given a set of unordered 2D segments, this function enables to reinforce
|
||||
two types of regularities among these segments:
|
||||
- *Parallelism*: segments, which are detected as near parallel, are made exactly parallel.
|
||||
- *Orthogonality*: segments, which are detected as near orthogonal, are made exactly orthogonal.
|
||||
|
||||
This is an utility function based on `regularize_segments()` that is using default parameters.
|
||||
|
||||
\tparam InputRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\param input_range
|
||||
a const range of input segments for angle regularization
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
|
||||
\sa `regularize_segments()`
|
||||
\sa `regularize_offsets()`
|
||||
*/
|
||||
template<typename InputRange>
|
||||
void regularize_angles(
|
||||
InputRange& input_range) {
|
||||
|
|
@ -325,11 +263,38 @@ namespace Segments {
|
|||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Segment_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using GeomTraits = typename Kernel_traits<Segment_2>::Kernel;
|
||||
GeomTraits traits;
|
||||
|
||||
regularize_angles(input_range, traits);
|
||||
using Neighbor_query = Delaunay_neighbor_query_2<GeomTraits, InputRange>;
|
||||
using Angle_regularization = Angle_regularization_2<GeomTraits, InputRange>;
|
||||
|
||||
Neighbor_query neighbor_query(input_range);
|
||||
Angle_regularization angle_regularization(input_range);
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, angle_regularization);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgShapeRegularizationRefSegments
|
||||
|
||||
\brief regularizes offsets in a set of 2D segments.
|
||||
|
||||
Given a set of parallel 2D segments, this function enables to reinforce
|
||||
the collinearity property among these segments that is all parallel segments,
|
||||
which are detected as near collinear, are made exactly collinear.
|
||||
|
||||
This is an utility function based on `regularize_segments()` that is using default parameters.
|
||||
|
||||
\tparam InputRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
|
||||
\param input_range
|
||||
a const range of input segments for offset regularization
|
||||
|
||||
\pre input_range.size() >= 2
|
||||
|
||||
\sa `regularize_segments()`
|
||||
\sa `regularize_angles()`
|
||||
*/
|
||||
template<typename InputRange>
|
||||
void regularize_offsets(
|
||||
InputRange& input_range) {
|
||||
|
|
@ -338,11 +303,15 @@ namespace Segments {
|
|||
using Iterator_type = typename InputRange::const_iterator;
|
||||
using Segment_2 = typename std::iterator_traits<Iterator_type>::value_type;
|
||||
using GeomTraits = typename Kernel_traits<Segment_2>::Kernel;
|
||||
GeomTraits traits;
|
||||
|
||||
regularize_offsets(input_range, traits);
|
||||
using Neighbor_query = Delaunay_neighbor_query_2<GeomTraits, InputRange>;
|
||||
using Offset_regularization = Offset_regularization_2<GeomTraits, InputRange>;
|
||||
|
||||
Neighbor_query neighbor_query(input_range);
|
||||
Offset_regularization offset_regularization(input_range);
|
||||
regularize_segments(
|
||||
input_range, neighbor_query, offset_regularization);
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
#endif // CGAL_USE_OSQP or DOXYGEN_RUNNING
|
||||
|
||||
|
|
@ -426,8 +395,10 @@ namespace Segments {
|
|||
using Segment_2 = typename SegmentMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
SegmentMap segment_map;
|
||||
const SegmentMap segment_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::segment_map), SegmentMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 1);
|
||||
using Parallel_groups_2 = internal::Parallel_groups_2<
|
||||
|
|
@ -531,8 +502,10 @@ namespace Segments {
|
|||
using Segment_2 = typename SegmentMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
SegmentMap segment_map;
|
||||
const SegmentMap segment_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::segment_map), SegmentMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 1);
|
||||
using Collinear_groups_2 = internal::Collinear_groups_2<
|
||||
|
|
@ -636,8 +609,10 @@ namespace Segments {
|
|||
using Segment_2 = typename SegmentMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
SegmentMap segment_map;
|
||||
const SegmentMap segment_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::segment_map), SegmentMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 1);
|
||||
using Orthogonal_groups_2 = internal::Orthogonal_groups_2<
|
||||
|
|
@ -740,8 +715,10 @@ namespace Segments {
|
|||
using Segment_2 = typename SegmentMap::value_type;
|
||||
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
|
||||
|
||||
GeomTraits traits;
|
||||
SegmentMap segment_map;
|
||||
const SegmentMap segment_map = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::segment_map), SegmentMap());
|
||||
const GeomTraits traits = parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::geom_traits), GeomTraits());
|
||||
|
||||
CGAL_precondition(input_range.size() >= 1);
|
||||
using Unique_segments_2 = internal::Unique_segments_2<
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ void test_0_segments() {
|
|||
|
||||
// saver.export_eps_segments(segments, "0_input", 100);
|
||||
|
||||
NQ neighbor_query(segments, smap);
|
||||
NQ neighbor_query(
|
||||
segments, CGAL::parameters::segment_map(smap));
|
||||
AR angle_regularization(
|
||||
segments, CGAL::parameters::segment_map(smap));
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ void test_1_segment() {
|
|||
|
||||
// saver.export_segments(segments, "1_input", 100);
|
||||
|
||||
NQ neighbor_query(segments, smap);
|
||||
NQ neighbor_query(
|
||||
segments, CGAL::parameters::segment_map(smap));
|
||||
AR angle_regularization(
|
||||
segments, CGAL::parameters::segment_map(smap));
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ void test_2_segments() {
|
|||
// saver.export_segments(segments, "2_input", 100);
|
||||
|
||||
const FT max_angle_2 = FT(5);
|
||||
NQ neighbor_query(segments, smap);
|
||||
NQ neighbor_query(
|
||||
segments, CGAL::parameters::
|
||||
segment_map(smap));
|
||||
AR angle_regularization(
|
||||
segments, CGAL::parameters::
|
||||
maximum_angle(max_angle_2).
|
||||
|
|
@ -46,7 +48,7 @@ void test_2_segments() {
|
|||
|
||||
QP qp_angles;
|
||||
QP_AR qp_ar(
|
||||
segments, neighbor_query, angle_regularization, qp_angles, Traits());
|
||||
segments, neighbor_query, angle_regularization, qp_angles);
|
||||
qp_ar.regularize();
|
||||
|
||||
std::vector<Indices> parallel_groups;
|
||||
|
|
@ -87,7 +89,7 @@ void test_2_segments() {
|
|||
|
||||
QP qp_offsets;
|
||||
QP_OR qp_or(
|
||||
segments, neighbor_query, offset_regularization, qp_offsets, Traits());
|
||||
segments, neighbor_query, offset_regularization, qp_offsets);
|
||||
qp_or.regularize();
|
||||
|
||||
std::vector<Indices> collinear_groups;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void test_3_segments() {
|
|||
segments, CGAL::parameters::maximum_angle(max_angle_2));
|
||||
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, angle_regularization, Traits());
|
||||
segments, neighbor_query, angle_regularization);
|
||||
|
||||
std::vector<Indices> parallel_groups;
|
||||
angle_regularization.parallel_groups(
|
||||
|
|
@ -75,7 +75,7 @@ void test_3_segments() {
|
|||
}
|
||||
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, offset_regularization, Traits());
|
||||
segments, neighbor_query, offset_regularization);
|
||||
|
||||
std::vector<Indices> collinear_groups;
|
||||
offset_regularization.collinear_groups(
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void test_4_segments() {
|
|||
|
||||
QP qp_angles;
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, angle_regularization, qp_angles, Traits());
|
||||
segments, neighbor_query, angle_regularization, qp_angles);
|
||||
|
||||
std::vector<Indices> parallel_groups;
|
||||
angle_regularization.parallel_groups(
|
||||
|
|
@ -80,7 +80,7 @@ void test_4_segments() {
|
|||
|
||||
QP qp_offsets;
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, offset_regularization, qp_offsets, Traits());
|
||||
segments, neighbor_query, offset_regularization, qp_offsets);
|
||||
|
||||
std::vector<Indices> collinear_groups;
|
||||
offset_regularization.collinear_groups(
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ void test_equal_contours() {
|
|||
// saver.export_open_contour(contour, "op_input", 100);
|
||||
|
||||
const bool is_closed = true;
|
||||
CD closed_directions(contour, is_closed, pmap);
|
||||
OD open_directions(contour, !is_closed, pmap);
|
||||
CD closed_directions(contour, is_closed, CGAL::parameters::point_map(pmap));
|
||||
OD open_directions(contour, !is_closed, CGAL::parameters::point_map(pmap));
|
||||
|
||||
std::vector<Point_2> closed_contour;
|
||||
SR::Contours::regularize_closed_contour(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ void test_neighbor_query() {
|
|||
groups[1] = {4, 5, 6, 7}; // internal square
|
||||
|
||||
Indices neighbors;
|
||||
NQ neighbor_query(segments);
|
||||
NQ neighbor_query(
|
||||
segments, CGAL::parameters::all_default());
|
||||
|
||||
// Check unique group.
|
||||
Segments edges;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Shape_regularization/regularize_segments.h>
|
||||
#include <CGAL/Shape_regularization/regularize_contours.h>
|
||||
|
||||
namespace SR = CGAL::Shape_regularization;
|
||||
|
||||
|
|
@ -13,20 +14,33 @@ void test_overloads() {
|
|||
using FT = typename Traits::FT;
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
using Segment_2 = typename Traits::Segment_2;
|
||||
using Segments = std::vector<Segment_2>;
|
||||
|
||||
using Points = std::vector<Point_2>;
|
||||
using Segments = std::vector<Segment_2>;
|
||||
using Indices = std::vector<std::size_t>;
|
||||
|
||||
using NQ = SR::Segments::Delaunay_neighbor_query_2<Traits, Segments>;
|
||||
using AR = SR::Segments::Angle_regularization_2<Traits, Segments>;
|
||||
using OR = SR::Segments::Offset_regularization_2<Traits, Segments>;
|
||||
using QP = CGAL::OSQP_quadratic_program_traits<FT>;
|
||||
using CD = SR::Contours::Longest_direction_2<Traits, Points>;
|
||||
|
||||
Points points = {
|
||||
Point_2(0, 0), Point_2(1, 0),
|
||||
Point_2(0, 1), Point_2(1, 1),
|
||||
};
|
||||
assert(points.size() == 4);
|
||||
|
||||
Traits traits;
|
||||
Segments segments = {
|
||||
Segment_2(Point_2(0, 0), Point_2(1, 0)),
|
||||
Segment_2(Point_2(0, 1), Point_2(1, 1)),
|
||||
};
|
||||
assert(segments.size() == 2);
|
||||
|
||||
std::vector<Indices> indices;
|
||||
std::vector<Segment_2> unique;
|
||||
std::vector<Point_2> contour;
|
||||
|
||||
// saver.export_segments(segments, "ol_input", 100);
|
||||
|
||||
NQ neighbor_query(segments);
|
||||
|
|
@ -34,26 +48,56 @@ void test_overloads() {
|
|||
OR offset_regularization(segments);
|
||||
QP quadratic_program;
|
||||
|
||||
CD cdirections(points, true);
|
||||
CD odirections(points, false);
|
||||
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, angle_regularization, quadratic_program, traits);
|
||||
segments, neighbor_query, angle_regularization, quadratic_program, CGAL::parameters::all_default());
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, angle_regularization, traits);
|
||||
segments, neighbor_query, angle_regularization, quadratic_program);
|
||||
SR::Segments::regularize_segments(
|
||||
segments, neighbor_query, angle_regularization);
|
||||
SR::Segments::regularize_segments(
|
||||
segments, traits);
|
||||
SR::Segments::regularize_segments(
|
||||
segments);
|
||||
|
||||
SR::Segments::regularize_angles(
|
||||
segments, traits);
|
||||
SR::Segments::regularize_angles(
|
||||
segments);
|
||||
SR::Segments::regularize_offsets(
|
||||
segments);
|
||||
|
||||
SR::Segments::regularize_offsets(
|
||||
segments, traits);
|
||||
SR::Segments::regularize_offsets(
|
||||
segments);
|
||||
SR::Segments::parallel_groups(
|
||||
segments, std::back_inserter(indices), CGAL::parameters::all_default());
|
||||
SR::Segments::parallel_groups(
|
||||
segments, std::back_inserter(indices));
|
||||
|
||||
SR::Segments::collinear_groups(
|
||||
segments, std::back_inserter(indices), CGAL::parameters::all_default());
|
||||
SR::Segments::collinear_groups(
|
||||
segments, std::back_inserter(indices));
|
||||
|
||||
SR::Segments::orthogonal_groups(
|
||||
segments, std::back_inserter(indices), CGAL::parameters::all_default());
|
||||
SR::Segments::orthogonal_groups(
|
||||
segments, std::back_inserter(indices));
|
||||
|
||||
SR::Segments::unique_segments(
|
||||
segments, std::back_inserter(unique), CGAL::parameters::all_default());
|
||||
SR::Segments::unique_segments(
|
||||
segments, std::back_inserter(unique));
|
||||
|
||||
SR::Contours::regularize_closed_contour(
|
||||
points, cdirections, std::back_inserter(contour), CGAL::parameters::all_default());
|
||||
SR::Contours::regularize_closed_contour(
|
||||
points, cdirections, std::back_inserter(contour));
|
||||
SR::Contours::regularize_closed_contour(
|
||||
points, std::back_inserter(contour));
|
||||
|
||||
SR::Contours::regularize_open_contour(
|
||||
points, odirections, std::back_inserter(contour), CGAL::parameters::all_default());
|
||||
SR::Contours::regularize_open_contour(
|
||||
points, odirections, std::back_inserter(contour));
|
||||
SR::Contours::regularize_open_contour(
|
||||
points, std::back_inserter(contour));
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
|
|||
|
|
@ -186,10 +186,11 @@ int main() {
|
|||
|
||||
CGAL::Shape_regularization::Planes::regularize_planes(
|
||||
planes,
|
||||
CGAL::Shape_detection::Plane_map<Traits>(),
|
||||
points,
|
||||
Point_map(),
|
||||
CGAL::parameters::plane_index_map(
|
||||
CGAL::parameters::
|
||||
plane_map(CGAL::Shape_detection::Plane_map<Traits>()).
|
||||
point_map(Point_map()).
|
||||
plane_index_map(
|
||||
CGAL::Shape_detection::Point_to_shape_index_map<Traits>(points, planes)).
|
||||
regularize_parallelism(true).
|
||||
regularize_orthogonality(false).
|
||||
|
|
@ -292,10 +293,11 @@ int main() {
|
|||
|
||||
CGAL::Shape_regularization::Planes::regularize_planes(
|
||||
planes,
|
||||
CGAL::Shape_detection::Plane_map<Traits>(),
|
||||
points,
|
||||
Point_map(),
|
||||
CGAL::parameters::plane_index_map(
|
||||
CGAL::parameters::
|
||||
point_map(Point_map()).
|
||||
plane_map(CGAL::Shape_detection::Plane_map<Traits>()).
|
||||
plane_index_map(
|
||||
CGAL::Shape_detection::Point_to_shape_index_map<Traits>(points, planes)).
|
||||
regularize_parallelism(true).
|
||||
regularize_orthogonality(false).
|
||||
|
|
|
|||
Loading…
Reference in New Issue