CGAL 5.4.5 - Shape Regularization
CGAL::Shape_regularization::Contours::Multiple_directions_2< GeomTraits, InputRange, PointMap > Class Template Reference

#include <CGAL/Shape_regularization/Contours/Multiple_directions_2.h>

Definition

template<typename GeomTraits, typename InputRange, typename PointMap = CGAL::Identity_property_map<typename GeomTraits::Point_2>>
class CGAL::Shape_regularization::Contours::Multiple_directions_2< GeomTraits, InputRange, PointMap >

Estimates possibly multiple principal directions of the contour based on the user-specified minimum length and maximum angle bounds.

This algorithm finds the best-fit edges of the contour with respect to the user-specified parameters and sets their directions as the principal directions of the contour.

Template Parameters
GeomTraitsa model of Kernel
InputRangea model of ConstRange whose iterator type is RandomAccessIterator
PointMapa model of ReadablePropertyMap whose key type is the value type of the input range and value type is GeomTraits::Point_2. The default is CGAL::Identity_property_map<typename GeomTraits::Point_2>.
Is Model Of:
ContourDirections
Examples:
Shape_regularization/regularize_closed_contour.cpp.

Initialization

template<typename NamedParameters >
 Multiple_directions_2 (const InputRange &input_range, const bool is_closed, const NamedParameters &np)
 initializes all internal data structures. More...
 

Directions

void orient (const std::size_t query_index, Segment_2 &segment) const
 orients a given segment with the index query_index towards the best-fit found principal direction. More...
 

Miscellaneous

std::size_t number_of_directions () const
 returns the number of principal directions of the contour. More...
 

Constructor & Destructor Documentation

◆ Multiple_directions_2()

template<typename GeomTraits , typename InputRange , typename PointMap = CGAL::Identity_property_map<typename GeomTraits::Point_2>>
template<typename NamedParameters >
CGAL::Shape_regularization::Contours::Multiple_directions_2< GeomTraits, InputRange, PointMap >::Multiple_directions_2 ( const InputRange &  input_range,
const bool  is_closed,
const NamedParameters &  np 
)

initializes all internal data structures.

Template Parameters
NamedParametersa sequence of Named Parameters
Parameters
input_rangea const range of ordered 2D points, which form a contour
is_closedindicates whether the contour is closed or open
npan optional sequence of Named Parameters among the ones listed below; this parameter can be omitted, the default values are then used
Optional Named Parameters
  • maximum allowed angle deviation in degrees between a contour edge and a principal direction such that they are considered to be parallel or orthogonal
  • Type: GeomTraits::FT
  • Default: 10 degrees
  • minimum acceptable length of a contour edge whose direction can be taken as a principal direction
  • Type: GeomTraits::FT
  • Default: 3 unit lengths
  • indicates whether the found directions should be better adjusted to the original shape or not
  • Type: boolean
  • Default: true
  • an instance of PointMap that maps an item from input_range to GeomTraits::Point_2
  • Default: PointMap()
Precondition
input_range.size() >= 3 for closed contours
input_range.size() >= 2 for open contours

Member Function Documentation

◆ number_of_directions()

template<typename GeomTraits , typename InputRange , typename PointMap = CGAL::Identity_property_map<typename GeomTraits::Point_2>>
std::size_t CGAL::Shape_regularization::Contours::Multiple_directions_2< GeomTraits, InputRange, PointMap >::number_of_directions ( ) const

returns the number of principal directions of the contour.

The returned number is always greater or equal than one.

◆ orient()

template<typename GeomTraits , typename InputRange , typename PointMap = CGAL::Identity_property_map<typename GeomTraits::Point_2>>
void CGAL::Shape_regularization::Contours::Multiple_directions_2< GeomTraits, InputRange, PointMap >::orient ( const std::size_t  query_index,
Segment_2 segment 
) const

orients a given segment with the index query_index towards the best-fit found principal direction.

Parameters
query_indexan index of the contour vertex that emits the contour edge being segment
segmenta segment to be rotated
Precondition
query_index >= 0 && query_index < input_range.size() for closed contours
query_index >= 0 && query_index < input_range.size() - 1 for open contours