DGtal 1.4.2
Loading...
Searching...
No Matches
DGtal::detail::RecursivePConvexity< dim, TInteger > Struct Template Reference

#include <DGtal/geometry/volumes/PConvexity.h>

Inheritance diagram for DGtal::detail::RecursivePConvexity< dim, TInteger >:
[legend]

Public Types

using Integer = TInteger
 
using Point = DGtal::PointVector< dim, Integer >
 
using ProjPoint = DGtal::PointVector< dim-1, Integer >
 
using ProjPConvexity = DGtal::detail::RecursivePConvexity< dim - 1, Integer >
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CInteger< TInteger >))
 Integer must be a model of the concept CInteger.
 
 RecursivePConvexity (Dimension bd=dim)
 
void init (Dimension bd=dim)
 
bool isPConvex (const std::vector< Point > &X, bool safe) const
 
double fullConvexityMeasure (const std::vector< Point > &X, bool safe) const
 

Static Public Member Functions

static bool is0Convex (const std::vector< Point > &X, bool safe)
 
static double convexityMeasure (const std::vector< Point > &X, bool safe)
 
static ProjPoint project (const Point &p, Dimension a)
 
static std::vector< ProjPointproject (const std::vector< Point > &p, Dimension a)
 

Data Fields

std::vector< ProjPConvexityprojp
 The array of lower dimensional P-convexities.
 

Detailed Description

template<Dimension dim, typename TInteger = DGtal::int32_t>
struct DGtal::detail::RecursivePConvexity< dim, TInteger >

Hidden class to represent the P-convexity in a recursive way. Only used to compute P-convexity, but not exposed to users.

Note
This d-dimensional object builds d (d-1)-dimensional similar objects, but the k-th remembers to build only k lower dimensional ones.
Template Parameters
dimthe dimension of the digital space
TIntegerany model of integer (used to represent digital point coordinates).

Definition at line 66 of file PConvexity.h.

Member Typedef Documentation

◆ Integer

template<Dimension dim, typename TInteger = DGtal::int32_t>
using DGtal::detail::RecursivePConvexity< dim, TInteger >::Integer = TInteger

Definition at line 69 of file PConvexity.h.

◆ Point

template<Dimension dim, typename TInteger = DGtal::int32_t>
using DGtal::detail::RecursivePConvexity< dim, TInteger >::Point = DGtal::PointVector< dim, Integer >

Definition at line 70 of file PConvexity.h.

◆ ProjPConvexity

template<Dimension dim, typename TInteger = DGtal::int32_t>
using DGtal::detail::RecursivePConvexity< dim, TInteger >::ProjPConvexity = DGtal::detail::RecursivePConvexity< dim - 1, Integer >

Definition at line 72 of file PConvexity.h.

◆ ProjPoint

template<Dimension dim, typename TInteger = DGtal::int32_t>
using DGtal::detail::RecursivePConvexity< dim, TInteger >::ProjPoint = DGtal::PointVector< dim-1, Integer >

Definition at line 71 of file PConvexity.h.

Constructor & Destructor Documentation

◆ RecursivePConvexity()

template<Dimension dim, typename TInteger = DGtal::int32_t>
DGtal::detail::RecursivePConvexity< dim, TInteger >::RecursivePConvexity ( Dimension bd = dim)
inline

Parameter bd is used to build exactly 2^d - 1 PConvexity objects when starting at dimension d.

Parameters
bdthe maximum axis of projection.

Definition at line 77 of file PConvexity.h.

78 {
79 init( bd );
80 }
void init(Dimension bd=dim)
Definition PConvexity.h:83

References DGtal::detail::RecursivePConvexity< dim, TInteger >::init().

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<Dimension dim, typename TInteger = DGtal::int32_t>
DGtal::detail::RecursivePConvexity< dim, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< TInteger >) )

Integer must be a model of the concept CInteger.

◆ convexityMeasure()

template<Dimension dim, typename TInteger = DGtal::int32_t>
static double DGtal::detail::RecursivePConvexity< dim, TInteger >::convexityMeasure ( const std::vector< Point > & X,
bool safe )
inlinestatic
Parameters
Xany range of lattice points (without duplicates)
safewhen 'true' performs convex hull computations with arbitrary precision integer (if available), otherwise chooses a compromise between speed and precision (int64_t).
Precondition
X must not contain any duplicates.
Returns
a measure that has value 1.0 when X is digitally convex, and less otherwise.

Definition at line 155 of file PConvexity.h.

156 {
157 if ( X.empty() ) return 1.0;
158 // Build polytope according to internal integer type.
159 if ( safe )
160 {
164 computeLatticePolytope( X, false, false );
165 const std::size_t number_lattice_points_in_P = P.count();
166 return double( X.size() ) / double( number_lattice_points_in_P );
167 }
168 else
169 {
173 computeLatticePolytope( X, false, false );
174 const std::size_t number_lattice_points_in_P = P.count();
175 return double( X.size() ) / double( number_lattice_points_in_P );
176 }
177 }
DGtal::int64_t InternalInteger
static LatticePolytope computeLatticePolytope(const PointRange &input_points, bool remove_duplicates=true, bool make_minkowski_summable=false)

References DGtal::ConvexityHelper< dim, TInteger, TInternalInteger >::computeLatticePolytope().

Referenced by DGtal::PConvexity< TSpace >::convexityMeasure(), DGtal::detail::RecursivePConvexity< dim, TInteger >::fullConvexityMeasure(), and DGtal::detail::RecursivePConvexity< 1, TInteger >::fullConvexityMeasure().

◆ fullConvexityMeasure()

template<Dimension dim, typename TInteger = DGtal::int32_t>
double DGtal::detail::RecursivePConvexity< dim, TInteger >::fullConvexityMeasure ( const std::vector< Point > & X,
bool safe ) const
inline
Parameters
Xany range of lattice points (without duplicates)
safewhen 'true' performs convex hull computations with arbitrary precision integer (if available), otherwise chooses a compromise between speed and precision (int64_t).
Precondition
X must not contain any duplicates.
Returns
a measure that has value 1.0 when X is P-convex (or equivalently fully convex), and less otherwise.

Definition at line 189 of file PConvexity.h.

190 {
191 double m = convexityMeasure( X, safe );
192 for ( std::size_t j = 0; j < projp.size(); j++ )
193 {
194 auto pX = project( X, j );
195 m *= projp[ j ].fullConvexityMeasure( pX, safe );
196 }
197 return m;
198 }
static double convexityMeasure(const std::vector< Point > &X, bool safe)
Definition PConvexity.h:155
std::vector< ProjPConvexity > projp
The array of lower dimensional P-convexities.
Definition PConvexity.h:237
static ProjPoint project(const Point &p, Dimension a)
Definition PConvexity.h:206

References DGtal::detail::RecursivePConvexity< dim, TInteger >::convexityMeasure(), DGtal::detail::RecursivePConvexity< dim, TInteger >::project(), and DGtal::detail::RecursivePConvexity< dim, TInteger >::projp.

Referenced by DGtal::PConvexity< TSpace >::fullConvexityMeasure().

◆ init()

template<Dimension dim, typename TInteger = DGtal::int32_t>
void DGtal::detail::RecursivePConvexity< dim, TInteger >::init ( Dimension bd = dim)
inline
Parameters
bdthe maximum axis of projection.

Definition at line 83 of file PConvexity.h.

84 {
85 for ( Dimension j = 0; j < bd; j++ )
86 projp.push_back( ProjPConvexity( j ) );
87 }
DGtal::uint32_t Dimension
Definition Common.h:136
DGtal::detail::RecursivePConvexity< dim - 1, Integer > ProjPConvexity
Definition PConvexity.h:72

References DGtal::detail::RecursivePConvexity< dim, TInteger >::projp.

Referenced by DGtal::detail::RecursivePConvexity< dim, TInteger >::RecursivePConvexity().

◆ is0Convex()

template<Dimension dim, typename TInteger = DGtal::int32_t>
static bool DGtal::detail::RecursivePConvexity< dim, TInteger >::is0Convex ( const std::vector< Point > & X,
bool safe )
inlinestatic
Parameters
Xany range of lattice points (without duplicates)
safewhen 'true' performs convex hull computations with arbitrary precision integer (if available), otherwise chooses a compromise between speed and precision (int64_t).
Returns
'true' if and only if X is a digitally convex set in the classic sense, i.e. \( Conv(X) \cap Z^d = X \).
Precondition
X must not contain any duplicates.

Definition at line 100 of file PConvexity.h.

101 {
102 if ( X.empty() ) return true;
103 // Build polytope according to internal integer type.
104 if ( safe )
105 {
109 computeLatticePolytope( X, false, false );
110 const std::size_t number_lattice_points_in_P = P.count();
111 return number_lattice_points_in_P == X.size();
112 }
113 else
114 {
118 computeLatticePolytope( X, false, false );
119 const std::size_t number_lattice_points_in_P = P.count();
120 return number_lattice_points_in_P == X.size();
121 }
122 }

References DGtal::ConvexityHelper< dim, TInteger, TInternalInteger >::computeLatticePolytope().

Referenced by DGtal::PConvexity< TSpace >::is0Convex(), DGtal::detail::RecursivePConvexity< dim, TInteger >::isPConvex(), and DGtal::detail::RecursivePConvexity< 1, TInteger >::isPConvex().

◆ isPConvex()

template<Dimension dim, typename TInteger = DGtal::int32_t>
bool DGtal::detail::RecursivePConvexity< dim, TInteger >::isPConvex ( const std::vector< Point > & X,
bool safe ) const
inline
Parameters
Xany range of lattice points (without duplicates)
safewhen 'true' performs convex hull computations with arbitrary precision integer (if available), otherwise chooses a compromise between speed and precision (int64_t).
Returns
'true' if and only if X is a P-convex digital set.
Precondition
X must not contain any duplicates.

Definition at line 133 of file PConvexity.h.

134 {
135 if ( ! is0Convex( X, safe ) ) return false;
136 for ( std::size_t j = 0; j < projp.size(); j++ )
137 {
138 const auto pi_j_X = project( X, j );
139 if ( ! projp[ j ].isPConvex( pi_j_X, safe ) ) return false;
140 }
141 return true;
142 }
bool isPConvex(const std::vector< Point > &X, bool safe) const
Definition PConvexity.h:133
static bool is0Convex(const std::vector< Point > &X, bool safe)
Definition PConvexity.h:100

References DGtal::detail::RecursivePConvexity< dim, TInteger >::is0Convex(), DGtal::detail::RecursivePConvexity< dim, TInteger >::isPConvex(), DGtal::detail::RecursivePConvexity< dim, TInteger >::project(), and DGtal::detail::RecursivePConvexity< dim, TInteger >::projp.

Referenced by DGtal::detail::RecursivePConvexity< dim, TInteger >::isPConvex(), and DGtal::PConvexity< TSpace >::isPConvex().

◆ project() [1/2]

template<Dimension dim, typename TInteger = DGtal::int32_t>
static ProjPoint DGtal::detail::RecursivePConvexity< dim, TInteger >::project ( const Point & p,
Dimension a )
inlinestatic

Projects a point p along dimension a.

Parameters
[in]pany digital point
[in]aany dimension
Returns
the digital point of dimension (d-1) with omitted a-th coordinate.

Definition at line 206 of file PConvexity.h.

207 {
208 ProjPoint pp;
209 Dimension j = 0;
210 for ( Dimension i = 0; i < Point::dimension; i++ )
211 if ( i != a ) pp[ j++ ] = p[ i ];
212 return pp;
213 }
static const Dimension dimension
DGtal::PointVector< dim-1, Integer > ProjPoint
Definition PConvexity.h:71

References DGtal::PointVector< dim, Integer >::dimension.

Referenced by DGtal::detail::RecursivePConvexity< dim, TInteger >::fullConvexityMeasure(), DGtal::detail::RecursivePConvexity< dim, TInteger >::isPConvex(), and DGtal::detail::RecursivePConvexity< dim, TInteger >::project().

◆ project() [2/2]

template<Dimension dim, typename TInteger = DGtal::int32_t>
static std::vector< ProjPoint > DGtal::detail::RecursivePConvexity< dim, TInteger >::project ( const std::vector< Point > & p,
Dimension a )
inlinestatic

Projects the range of points p along dimension a.

Parameters
[in]pany range of digital points
[in]aany dimension
Returns
the range of digital points of dimension (d-1) with omitted a-th coordinate.
Postcondition
the returned range has no duplicates.

Definition at line 225 of file PConvexity.h.

226 {
227 std::vector< ProjPoint > pp( p.size() );
228 for ( std::size_t i = 0; i < p.size(); i++ )
229 pp[ i ] = project( p[ i ], a );
230 std::sort( pp.begin(), pp.end() );
231 auto last = std::unique( pp.begin(), pp.end() );
232 pp.erase( last, pp.end() );
233 return pp;
234 }

References DGtal::detail::RecursivePConvexity< dim, TInteger >::project().

Field Documentation

◆ projp

template<Dimension dim, typename TInteger = DGtal::int32_t>
std::vector< ProjPConvexity > DGtal::detail::RecursivePConvexity< dim, TInteger >::projp

The documentation for this struct was generated from the following file: