1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
|
// Copyright (c) 2020 GeometryFactory SARL (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Shape_regularization/include/CGAL/Shape_regularization/regularize_segments.h $
// $Id: include/CGAL/Shape_regularization/regularize_segments.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Dmitry Anisimov
//
#ifndef CGAL_SHAPE_REGULARIZATION_REGULARIZE_SEGMENTS_H
#define CGAL_SHAPE_REGULARIZATION_REGULARIZE_SEGMENTS_H
/// \cond SKIP_IN_MANUAL
#include <CGAL/license/Shape_regularization.h>
/// \endcond
/**
* \ingroup PkgShapeRegularizationRef
* \file CGAL/Shape_regularization/regularize_segments.h
* This header includes all classes for regularizing segments.
* It also includes the corresponding free functions.
*/
// Boost includes.
/// \cond SKIP_IN_MANUAL
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>
/// \endcond
// Internal includes.
/// \cond SKIP_IN_MANUAL
#include <CGAL/Shape_regularization/internal/utils.h>
#include <CGAL/Shape_regularization/internal/Parallel_groups_2.h>
#include <CGAL/Shape_regularization/internal/Orthogonal_groups_2.h>
#include <CGAL/Shape_regularization/internal/Collinear_groups_2.h>
/// \endcond
/// \cond SKIP_IN_MANUAL
#if defined(CGAL_USE_OSQP)
#include <CGAL/OSQP_quadratic_program_traits.h>
#endif // CGAL_USE_OSQP
/// \endcond
#include <CGAL/Shape_regularization/QP_regularization.h>
#include <CGAL/Shape_regularization/Segments/Angle_regularization_2.h>
#include <CGAL/Shape_regularization/Segments/Offset_regularization_2.h>
#include <CGAL/Shape_regularization/Segments/Delaunay_neighbor_query_2.h>
namespace CGAL {
namespace Shape_regularization {
namespace Segments {
/*!
\ingroup PkgShapeRegularizationRefSegments
\brief regularizes a set of 2D segments.
Given a set of unordered 2D segments, this function enables to reinforce
three 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.
- *Collinearity*: parallel segments, which are detected as near collinear, are made exactly collinear.
The user has to provide a `NeighborQuery` model to access local neighbors
of a segment and a `RegularizationType` model to define the type of regularities
that should be addressed. The function is based on the class `QP_regularization`.
Please refer to that class and these concepts for more information.
This class requires a `QPSolver` model which defaults to the \ref thirdpartyOSQP "OSQP"
library, which must be available on the system.
\tparam InputRange
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
\tparam NeighQuery
a model of `NeighborQuery`
\tparam RegType
a model of `RegularizationType`
\tparam QPSolver
a model of `QuadraticProgramTraits`
\tparam NamedParameters
a sequence of \ref bgl_namedparameters "Named Parameters"
\param input_range
a const range of input segments for shape regularization
\param neighbor_query
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 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 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
\sa `regularize_angles()`
\sa `regularize_offsets()`
*/
template<
typename InputRange,
typename NeighQuery,
typename RegType,
typename QPSolver,
typename NamedParameters = parameters::Default_named_parameters>
void regularize_segments(
InputRange& input_range,
NeighQuery& neighbor_query,
RegType& regularization_type,
QPSolver& quadratic_program,
const NamedParameters& np = parameters::default_values()) {
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, np);
regularizer.regularize();
}
#if defined(CGAL_USE_OSQP) || defined(DOXYGEN_RUNNING)
/// \cond SKIP_IN_MANUAL
template<
typename InputRange,
typename NeighQuery,
typename RegType>
void regularize_segments(
InputRange& input_range,
NeighQuery& neighbor_query,
RegType& regularization_type) {
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;
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,
CGAL::parameters::geom_traits(traits));
}
template<typename InputRange>
void regularize_segments(
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>;
using Offset_regularization = Offset_regularization_2<GeomTraits, InputRange>;
// Regularize angles.
Neighbor_query neighbor_query(input_range);
Angle_regularization angle_regularization(input_range);
regularize_segments(
input_range, neighbor_query, angle_regularization);
std::vector<Indices> parallel_groups;
angle_regularization.parallel_groups(
std::back_inserter(parallel_groups));
// Regularize offsets.
Offset_regularization offset_regularization(input_range);
neighbor_query.clear();
for (const auto& parallel_group : parallel_groups) {
neighbor_query.add_group(parallel_group);
offset_regularization.add_group(parallel_group);
}
regularize_segments(
input_range, neighbor_query, offset_regularization);
}
/// \endcond
/*!
\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.
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) {
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 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) {
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 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);
}
#endif // CGAL_USE_OSQP or DOXYGEN_RUNNING
/*!
\ingroup PkgShapeRegularizationRefSegments
\brief finds groups of parallel segments in a set of 2D segments.
This function enables to find groups of near parallel segments
in a set of 2D segments. The groups are returned as vectors of indices.
Note that two segments may be included at the same group even if they are
far away from each other. This algorithm concerns only the angle relationship
among segments, but not the distance.
This function does not regularize input segments, but only groups them.
\tparam InputRange
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
\tparam OutIterator
a model of `OutputIterator` that accepts elements of type `std::vector<std::size_t>`
\tparam NamedParameters
a sequence of \ref bgl_namedparameters "Named Parameters"
\param input_range
a const range of input segments
\param groups
an output iterator with groups of segment indices
\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{maximum_angle}
\cgalParamDescription{maximum allowed angle deviation in degrees between two segments
such that they are considered to be parallel}
\cgalParamType{`GeomTraits::FT`}
\cgalParamDefault{5 degrees}
\cgalParamNEnd
\cgalParamNBegin{preserve_order}
\cgalParamDescription{indicates whether the order of input segments should be
preserved or not}
\cgalParamType{boolean}
\cgalParamDefault{false}
\cgalParamNEnd
\cgalParamNBegin{segment_map}
\cgalParamDescription{a property map that maps an item from `input_range`
to `GeomTraits::Segment_2`}
\cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type of the input
range and value type is `GeomTraits::Segment_2`}
\cgalParamDefault{`CGAL::Identity_property_map`}
\cgalParamNEnd
\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
\return an output iterator to the element in the destination range,
one past the last group stored
\pre input_range.size() >= 1
\pre maximum_angle >= 0 && maximum_angle <= 90
*/
template<
typename InputRange,
typename OutIterator,
typename NamedParameters = parameters::Default_named_parameters>
OutIterator parallel_groups(
const InputRange& input_range,
OutIterator groups,
const NamedParameters& np = parameters::default_values()) {
using SegmentMap = typename internal::GetSegmentMap<InputRange, NamedParameters>::type;
using Segment_2 = typename SegmentMap::value_type;
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
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<
GeomTraits, InputRange, SegmentMap>;
Parallel_groups_2 grouping(
input_range, np, segment_map, traits);
return grouping.groups(groups);
}
/*!
\ingroup PkgShapeRegularizationRefSegments
\brief finds groups of collinear segments in a set of 2D segments.
This function enables to find groups of near collinear segments
in a set of 2D segments. The groups are returned as vectors of indices.
This algorithm first finds the groups of parallel segments using the function
`Segments::parallel_groups()` and then splits these groups into groups of collinear segments.
This function does not regularize input segments, but only groups them.
\tparam InputRange
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
\tparam OutIterator
a model of `OutputIterator` that accepts elements of type `std::vector<std::size_t>`
\tparam NamedParameters
a sequence of \ref bgl_namedparameters "Named Parameters"
\param input_range
a const range of input segments
\param groups
an output iterator with groups of segment indices
\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{maximum_offset}
\cgalParamDescription{maximum allowed orthogonal distance between two parallel segments
such that they are considered to be collinear}
\cgalParamType{`GeomTraits::FT`}
\cgalParamDefault{0.2 unit length}
\cgalParamNEnd
\cgalParamNBegin{preserve_order}
\cgalParamDescription{indicates whether the order of input segments should be
preserved or not}
\cgalParamType{boolean}
\cgalParamDefault{false}
\cgalParamNEnd
\cgalParamNBegin{segment_map}
\cgalParamDescription{a property map that maps an item from `input_range`
to `GeomTraits::Segment_2`}
\cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type of the input
range and value type is `GeomTraits::Segment_2`}
\cgalParamDefault{`CGAL::Identity_property_map`}
\cgalParamNEnd
\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
\return an output iterator to the element in the destination range,
one past the last group stored
\pre input_range.size() >= 1
\pre maximum_offset >= 0
*/
template<
typename InputRange,
typename OutIterator,
typename NamedParameters = parameters::Default_named_parameters>
OutIterator collinear_groups(
const InputRange& input_range,
OutIterator groups,
const NamedParameters& np = parameters::default_values()) {
using SegmentMap = typename internal::GetSegmentMap<InputRange, NamedParameters>::type;
using Segment_2 = typename SegmentMap::value_type;
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
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<
GeomTraits, InputRange, SegmentMap>;
Collinear_groups_2 grouping(
input_range, np, segment_map, traits);
return grouping.groups(groups);
}
/*!
\ingroup PkgShapeRegularizationRefSegments
\brief finds groups of orthogonal segments in a set of 2D segments.
This function enables to find groups of near orthogonal segments
in a set of 2D segments. The groups are returned as vectors of indices.
This algorithm first finds the groups of parallel segments using the function
`Segments::parallel_groups()` and then merges these groups into groups of orthogonal segments.
This function does not regularize input segments, but only groups them.
\tparam InputRange
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
\tparam OutIterator
a model of `OutputIterator` that accepts elements of type `std::vector<std::size_t>`
\tparam NamedParameters
a sequence of \ref bgl_namedparameters "Named Parameters"
\param input_range
a const range of input segments
\param groups
an output iterator with groups of segment indices
\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{maximum_angle}
\cgalParamDescription{maximum allowed angle deviation in degrees between two segments
such that they are considered to be parallel or orthogonal}
\cgalParamType{`GeomTraits::FT`}
\cgalParamDefault{5 degrees}
\cgalParamNEnd
\cgalParamNBegin{preserve_order}
\cgalParamDescription{indicates whether the order of input segments should be
preserved or not}
\cgalParamType{boolean}
\cgalParamDefault{false}
\cgalParamNEnd
\cgalParamNBegin{segment_map}
\cgalParamDescription{a property map that maps an item from `input_range`
to `GeomTraits::Segment_2`}
\cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type of the input
range and value type is `GeomTraits::Segment_2`}
\cgalParamDefault{`CGAL::Identity_property_map`}
\cgalParamNEnd
\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
\return an output iterator to the element in the destination range,
one past the last group stored
\pre input_range.size() >= 1
\pre maximum_angle >= 0 && maximum_angle <= 90
*/
template<
typename InputRange,
typename OutIterator,
typename NamedParameters = parameters::Default_named_parameters>
OutIterator orthogonal_groups(
const InputRange& input_range,
OutIterator groups,
const NamedParameters& np = parameters::default_values()) {
using SegmentMap = typename internal::GetSegmentMap<InputRange, NamedParameters>::type;
using Segment_2 = typename SegmentMap::value_type;
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
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<
GeomTraits, InputRange, SegmentMap>;
Orthogonal_groups_2 grouping(
input_range, np, segment_map, traits);
return grouping.groups(groups);
}
/*!
\ingroup PkgShapeRegularizationRefSegments
\brief substitutes groups of 2D collinear segments by average segments.
This function first calls `Segments::collinear_groups()`
and then substitutes each group of collinear segments by an average segment.
The number of returned segments is the number of detected collinear groups.
This function does not regularize input segments, but only groups and then simplifies them.
\tparam InputRange
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
\tparam OutIterator
a model of `OutputIterator` that accepts segments of type `GeomTraits::Segment_2`
\tparam NamedParameters
a sequence of \ref bgl_namedparameters "Named Parameters"
\param input_range
a const range of input segments
\param segments
an output iterator with the simplified segments
\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{maximum_offset}
\cgalParamDescription{maximum allowed orthogonal distance between two parallel segments
such that they are considered to be collinear}
\cgalParamType{`GeomTraits::FT`}
\cgalParamDefault{0.2 unit length}
\cgalParamNEnd
\cgalParamNBegin{preserve_order}
\cgalParamDescription{indicates whether the order of input segments should be
preserved or not}
\cgalParamType{boolean}
\cgalParamDefault{false}
\cgalParamNEnd
\cgalParamNBegin{segment_map}
\cgalParamDescription{a property map that maps an item from `input_range`
to `GeomTraits::Segment_2`}
\cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type of the input
range and value type is `GeomTraits::Segment_2`}
\cgalParamDefault{`CGAL::Identity_property_map`}
\cgalParamNEnd
\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
\return an output iterator to the element in the destination range,
one past the last segment stored
\pre input_range.size() >= 1
\pre maximum_offset >= 0
*/
template<
typename InputRange,
typename OutIterator,
typename NamedParameters = parameters::Default_named_parameters>
OutIterator unique_segments(
const InputRange& input_range,
OutIterator segments,
const NamedParameters& np = parameters::default_values()) {
using SegmentMap = typename internal::GetSegmentMap<InputRange, NamedParameters>::type;
using Segment_2 = typename SegmentMap::value_type;
using GeomTraits = typename CGAL::Kernel_traits<Segment_2>::Kernel;
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<
GeomTraits, InputRange, SegmentMap>;
const Unique_segments_2 unique(
input_range, np, segment_map, traits);
return unique.segments(segments);
}
} // namespace Segments
} // namespace Shape_regularization
} // namespace CGAL
#endif // CGAL_SHAPE_REGULARIZATION_REGULARIZE_SEGMENTS_H
|