CGAL 5.1.3 - Shape Detection
CGAL::Shape_detection::Point_set::Least_squares_line_fit_region< GeomTraits, InputRange, PointMap, NormalMap > Class Template Reference

#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_region.h>

Definition

Region type based on the quality of the least squares line fit applied to 2D points.

This class fits a line, using PCA, to chunks of points in a 2D point set and controls the quality of this fit. If all quality conditions are satisfied, the chunk is accepted as a valid region, otherwise rejected.

Template Parameters
GeomTraitsmust be a model of Kernel.
InputRangemust be a model of ConstRange whose iterator type is RandomAccessIterator.
PointMapmust be an LvaluePropertyMap whose key type is the value type of the input range and value type is Kernel::Point_2.
NormalMapmust be an LvaluePropertyMap whose key type is the value type of the input range and value type is Kernel::Vector_2.
Is Model Of:
RegionType
Examples:
Shape_detection/region_growing_on_point_set_2.cpp.

Types

typedef GeomTraits::FT FT
 Number type.
 

Initialization

 Least_squares_line_fit_region (const InputRange &input_range, const FT distance_threshold=FT(1), const FT angle_threshold=FT(25), const std::size_t min_region_size=2, const PointMap point_map=PointMap(), const NormalMap normal_map=NormalMap(), const GeomTraits traits=GeomTraits())
 initializes all internal data structures. More...
 

Access

bool is_part_of_region (const std::size_t, const std::size_t query_index, const std::vector< std::size_t > &) const
 implements RegionType::is_part_of_region(). More...
 
bool is_valid_region (const std::vector< std::size_t > &region) const
 implements RegionType::is_valid_region(). More...
 
void update (const std::vector< std::size_t > &region)
 implements RegionType::update(). More...
 

Constructor & Destructor Documentation

◆ Least_squares_line_fit_region()

template<typename GeomTraits , typename InputRange , typename PointMap , typename NormalMap >
CGAL::Shape_detection::Point_set::Least_squares_line_fit_region< GeomTraits, InputRange, PointMap, NormalMap >::Least_squares_line_fit_region ( const InputRange &  input_range,
const FT  distance_threshold = FT(1),
const FT  angle_threshold = FT(25),
const std::size_t  min_region_size = 2,
const PointMap  point_map = PointMap(),
const NormalMap  normal_map = NormalMap(),
const GeomTraits  traits = GeomTraits() 
)

initializes all internal data structures.

Parameters
input_rangean instance of InputRange with 2D points and corresponding 2D normal vectors
distance_thresholdthe maximum distance from a point to a line. Default is 1.
angle_thresholdthe maximum accepted angle in degrees between the normal of a point and the normal of a line. Default is 25 degrees.
min_region_sizethe minimum number of 2D points a region must have. Default is 2.
point_mapan instance of PointMap that maps an item from input_range to Kernel::Point_2
normal_mapan instance of NormalMap that maps an item from input_range to Kernel::Vector_2
traitsan instance of GeomTraits
Precondition
input_range.size() > 0
distance_threshold >= 0
angle_threshold >= 0 && angle_threshold <= 90
min_region_size > 0

Member Function Documentation

◆ is_part_of_region()

template<typename GeomTraits , typename InputRange , typename PointMap , typename NormalMap >
bool CGAL::Shape_detection::Point_set::Least_squares_line_fit_region< GeomTraits, InputRange, PointMap, NormalMap >::is_part_of_region ( const std::size_t  ,
const std::size_t  query_index,
const std::vector< std::size_t > &   
) const

implements RegionType::is_part_of_region().

This function controls if a point with the index query_index is within the distance_threshold from the corresponding line and if the angle between its normal and the line's normal is within the angle_threshold. If both conditions are satisfied, it returns true, otherwise false.

Parameters
query_indexindex of the query point

The first and third parameters are not used in this implementation.

Returns
Boolean true or false
Precondition
query_index >= 0 && query_index < input_range.size()

◆ is_valid_region()

template<typename GeomTraits , typename InputRange , typename PointMap , typename NormalMap >
bool CGAL::Shape_detection::Point_set::Least_squares_line_fit_region< GeomTraits, InputRange, PointMap, NormalMap >::is_valid_region ( const std::vector< std::size_t > &  region) const

implements RegionType::is_valid_region().

This function controls if the region contains at least min_region_size points.

Parameters
regionindices of points included in the region
Returns
Boolean true or false

◆ update()

template<typename GeomTraits , typename InputRange , typename PointMap , typename NormalMap >
void CGAL::Shape_detection::Point_set::Least_squares_line_fit_region< GeomTraits, InputRange, PointMap, NormalMap >::update ( const std::vector< std::size_t > &  region)

implements RegionType::update().

This function fits the least squares line to all points from the region.

Parameters
regionindices of points included in the region
Precondition
region.size() > 0