31 #if defined(PConvexity_RECURSES)
32 #error Recursive header files inclusion detected in PConvexity.h
35 #define PConvexity_RECURSES
37 #if !defined PConvexity_h
45 #include "DGtal/base/Common.h"
46 #include "DGtal/kernel/CInteger.h"
47 #include "DGtal/kernel/CSpace.h"
48 #include "DGtal/geometry/volumes/ConvexityHelper.h"
100 bool is0Convex(
const std::vector< Point >& X,
bool safe )
102 if ( X.empty() )
return true;
110 const std::size_t number_lattice_points_in_P = P.count();
111 return number_lattice_points_in_P == X.size();
119 const std::size_t number_lattice_points_in_P = P.count();
120 return number_lattice_points_in_P == X.size();
133 bool isPConvex(
const std::vector< Point >& X,
bool safe )
const
135 if ( !
is0Convex( X, safe ) )
return false;
136 for ( std::size_t j = 0; j <
projp.size(); j++ )
138 const auto pi_j_X =
project( X, j );
157 if ( X.empty() )
return 1.0;
165 const std::size_t number_lattice_points_in_P = P.count();
166 return double( X.size() ) / double( number_lattice_points_in_P );
174 const std::size_t number_lattice_points_in_P = P.count();
175 return double( X.size() ) / double( number_lattice_points_in_P );
192 for ( std::size_t j = 0; j <
projp.size(); j++ )
195 m *=
projp[ j ].fullConvexityMeasure( pX, safe );
211 if ( i != a ) pp[ j++ ] = p[ i ];
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() );
237 std::vector< ProjPConvexity >
projp;
250 template <
typename TInteger >
275 std::sort( X.begin(), X.end() );
291 bool isPConvex(
const std::vector< Point >& X,
bool safe )
310 if ( X.empty() )
return 1.0;
311 std::sort( X.begin(), X.end() );
313 return double( X.size() ) / double( nb );
353 template <
typename TSpace >
455 <<
" safe=" << (
mySafe ?
"True" :
"False" )
456 <<
" #bits<int>=" << (
sizeof(
Integer ) * 8 ) <<
"]";
499 template <
typename TKSpace>
504 object.selfDisplay( out );
521 #undef PConvexity_RECURSES
Aim: A class to check if digital sets are P-convex. The P-convexity is defined as follows: A digital ...
static const Dimension dimension
bool isPConvex(const std::vector< Point > &X) const
void selfDisplay(std::ostream &out) const
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
double fullConvexityMeasure(const std::vector< Point > &X) const
double convexityMeasure(const std::vector< Point > &X) const
PConvexity< TSpace > Self
bool is0Convex(const std::vector< Point > &X) const
~PConvexity()=default
Destructor.
PConvexity(bool safe=false)
RPConvexity myRPC
The recursive PConvexity object used to determine P-convexity.
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
DGtal::int64_t InternalInteger
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::uint32_t Dimension
boost::int32_t int32_t
signed 32-bit integer.
static LatticePolytope computeLatticePolytope(const PointRange &input_points, bool remove_duplicates=true, bool make_minkowski_summable=false)
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
static double convexityMeasure(std::vector< Point > X, bool safe)
static bool is0Convex(std::vector< Point > X, bool safe)
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInteger >))
Integer must be a model of the concept CInteger.
static double fullConvexityMeasure(const std::vector< Point > &X, bool safe)
RecursivePConvexity(Dimension)
Default constructor. Nothing to do.
static bool isPConvex(const std::vector< Point > &X, bool safe)
static std::vector< ProjPoint > project(const std::vector< Point > &p, Dimension a)
bool isPConvex(const std::vector< Point > &X, bool safe) const
static double convexityMeasure(const std::vector< Point > &X, bool safe)
std::vector< ProjPConvexity > projp
The array of lower dimensional P-convexities.
double fullConvexityMeasure(const std::vector< Point > &X, bool safe) const
RecursivePConvexity(Dimension bd=dim)
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInteger >))
Integer must be a model of the concept CInteger.
void init(Dimension bd=dim)
static bool is0Convex(const std::vector< Point > &X, bool safe)
static ProjPoint project(const Point &p, Dimension a)
unsigned int dim(const Vector &z)