DGtal 1.3.0
|
Aim: Represents an nD lattice polytope, i.e. a convex polyhedron bounded with vertices with integer coordinates, as a set of inequalities. Otherwise said, it is a H-representation of a polytope (as an intersection of half-spaces). A limitation is that we model only bounded polytopes, i.e. polytopes that can be included in a finite bounding box. More...
#include <DGtal/geometry/volumes/BoundedLatticePolytope.h>
Data Structures | |
struct | LeftStrictUnitCell |
struct | LeftStrictUnitSegment |
struct | RightStrictUnitCell |
struct | RightStrictUnitSegment |
struct | UnitCell |
struct | UnitSegment |
Public Types | |
typedef BoundedLatticePolytope< TSpace > | Self |
typedef TSpace | Space |
typedef Space::Integer | Integer |
typedef Space::Point | Point |
typedef Space::Vector | Vector |
typedef std::vector< Vector > | InequalityMatrix |
typedef std::vector< Integer > | InequalityVector |
typedef HyperRectDomain< Space > | Domain |
typedef ClosedIntegerHalfPlane< Space > | HalfSpace |
typedef DGtal::BigInteger | BigInteger |
Public Member Functions | |
Standard services (construction, initialization, assignment, interior, closure) | |
~BoundedLatticePolytope ()=default | |
BoundedLatticePolytope ()=default | |
BoundedLatticePolytope (const Self &other)=default | |
BoundedLatticePolytope (std::initializer_list< Point > l) | |
template<typename PointIterator > | |
BoundedLatticePolytope (PointIterator itB, PointIterator itE) | |
template<typename HalfSpaceIterator > | |
BoundedLatticePolytope (const Domain &domain, HalfSpaceIterator itB, HalfSpaceIterator itE, bool valid_edge_constraints=false, bool check_duplicate_constraints=false) | |
template<typename HalfSpaceIterator > | |
void | init (const Domain &domain, HalfSpaceIterator itB, HalfSpaceIterator itE, bool valid_edge_constraints=false, bool check_duplicate_constraints=false) |
template<typename PointIterator > | |
bool | init (PointIterator itB, PointIterator itE) |
Self & | operator= (const Self &other)=default |
void | clear () |
Clears the polytope. More... | |
BoundedLatticePolytope | interiorPolytope () const |
BoundedLatticePolytope | closurePolytope () const |
Accessor services | |
const Domain & | getDomain () const |
unsigned int | nbHalfSpaces () const |
const Vector & | getA (unsigned int i) const |
Integer | getB (unsigned int i) const |
bool | isLarge (unsigned int i) const |
const InequalityMatrix & | getA () const |
const InequalityVector & | getB () const |
const std::vector< bool > & | getI () const |
bool | canBeSummed () const |
Check point services (is inside test) | |
bool | isInside (const Point &p) const |
bool | isDomainPointInside (const Point &p) const |
bool | isInterior (const Point &p) const |
bool | isBoundary (const Point &p) const |
Global modification services (cut, swap, Minkowski sum) | |
unsigned int | cut (Dimension k, bool pos, Integer b, bool large=true) |
unsigned int | cut (const Vector &a, Integer b, bool large=true, bool valid_edge_constraint=false) |
unsigned int | cut (const HalfSpace &hs, bool large=true, bool valid_edge_constraint=false) |
void | swap (BoundedLatticePolytope &other) |
Self & | operator*= (Integer t) |
Self & | operator+= (UnitSegment s) |
Self & | operator+= (UnitCell c) |
Self & | operator+= (RightStrictUnitSegment s) |
Self & | operator+= (RightStrictUnitCell c) |
Self & | operator+= (LeftStrictUnitSegment s) |
Self & | operator+= (LeftStrictUnitCell c) |
Enumeration services (counting, get points in polytope) | |
Integer | count () const |
Integer | countInterior () const |
Integer | countBoundary () const |
Integer | countWithin (Point low, Point hi) const |
Integer | countUpTo (Integer max) const |
void | getPoints (std::vector< Point > &pts) const |
void | getKPoints (std::vector< Point > &pts, const Point &alpha_shift) const |
void | getInteriorPoints (std::vector< Point > &pts) const |
void | getBoundaryPoints (std::vector< Point > &pts) const |
template<typename PointSet > | |
void | insertPoints (PointSet &pts_set) const |
template<typename PointSet > | |
void | insertKPoints (PointSet &pts_set, const Point &alpha_shift) const |
Enumeration services by scanning (counting, get points in polytope) | |
Integer | countByScanning () const |
Integer | countInteriorByScanning () const |
Integer | countBoundaryByScanning () const |
Integer | countWithinByScanning (Point low, Point hi) const |
Integer | countUpToByScanning (Integer max) const |
void | getPointsByScanning (std::vector< Point > &pts) const |
void | getInteriorPointsByScanning (std::vector< Point > &pts) const |
void | getBoundaryPointsByScanning (std::vector< Point > &pts) const |
template<typename PointSet > | |
void | insertPointsByScanning (PointSet &pts_set) const |
Interface services | |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
std::string | className () const |
Static Public Attributes | |
static const Dimension | dimension = Space::dimension |
Protected Attributes | |
InequalityMatrix | A |
The matrix A in the polytope representation \( Ax \le B \). More... | |
InequalityVector | B |
The vector B in the polytope representation \( Ax \le B \). More... | |
Domain | D |
Tight bounded box. More... | |
std::vector< bool > | I |
Are inequalities large ? More... | |
bool | myValidEdgeConstraints |
Indicates if Minkowski sums with segments will be valid. More... | |
Private Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
bool | internalInitFromTriangle3D (Point a, Point b, Point c) |
bool | internalInitFromSegment3D (Point a, Point b) |
bool | internalInitFromSegment2D (Point a, Point b) |
Aim: Represents an nD lattice polytope, i.e. a convex polyhedron bounded with vertices with integer coordinates, as a set of inequalities. Otherwise said, it is a H-representation of a polytope (as an intersection of half-spaces). A limitation is that we model only bounded polytopes, i.e. polytopes that can be included in a finite bounding box.
Description of template class 'BoundedLatticePolytope'
It is a model of boost::CopyConstructible, boost::DefaultConstructible, boost::Assignable.
TSpace | an arbitrary model of CSpace. |
Definition at line 73 of file BoundedLatticePolytope.h.
typedef DGtal::BigInteger DGtal::BoundedLatticePolytope< TSpace >::BigInteger |
Definition at line 88 of file BoundedLatticePolytope.h.
typedef HyperRectDomain< Space > DGtal::BoundedLatticePolytope< TSpace >::Domain |
Definition at line 85 of file BoundedLatticePolytope.h.
typedef ClosedIntegerHalfPlane< Space > DGtal::BoundedLatticePolytope< TSpace >::HalfSpace |
Definition at line 86 of file BoundedLatticePolytope.h.
typedef std::vector<Vector> DGtal::BoundedLatticePolytope< TSpace >::InequalityMatrix |
Definition at line 83 of file BoundedLatticePolytope.h.
typedef std::vector<Integer> DGtal::BoundedLatticePolytope< TSpace >::InequalityVector |
Definition at line 84 of file BoundedLatticePolytope.h.
typedef Space::Integer DGtal::BoundedLatticePolytope< TSpace >::Integer |
Definition at line 80 of file BoundedLatticePolytope.h.
typedef Space::Point DGtal::BoundedLatticePolytope< TSpace >::Point |
Definition at line 81 of file BoundedLatticePolytope.h.
typedef BoundedLatticePolytope<TSpace> DGtal::BoundedLatticePolytope< TSpace >::Self |
Definition at line 78 of file BoundedLatticePolytope.h.
typedef TSpace DGtal::BoundedLatticePolytope< TSpace >::Space |
Definition at line 79 of file BoundedLatticePolytope.h.
typedef Space::Vector DGtal::BoundedLatticePolytope< TSpace >::Vector |
Definition at line 82 of file BoundedLatticePolytope.h.
|
default |
Destructor.
|
default |
Constructor.
|
default |
Copy constructor.
other | the object to clone. |
DGtal::BoundedLatticePolytope< TSpace >::BoundedLatticePolytope | ( | std::initializer_list< Point > | l | ) |
Constructs the polytope from a simplex given as an initializer_list.
l | any list of no more than d+1 points in general positions. |
DGtal::BoundedLatticePolytope< TSpace >::BoundedLatticePolytope | ( | PointIterator | itB, |
PointIterator | itE | ||
) |
Constructs the polytope from a simplex given as a range [itB,itE) of lattice points.
PointIterator | any model of forward iterator on Point. |
itB | the start of the range of no more than n+1 points defining the simplex. |
itE | past the end the range of no more than n+1 points defining the simplex. |
DGtal::BoundedLatticePolytope< TSpace >::BoundedLatticePolytope | ( | const Domain & | domain, |
HalfSpaceIterator | itB, | ||
HalfSpaceIterator | itE, | ||
bool | valid_edge_constraints = false , |
||
bool | check_duplicate_constraints = false |
||
) |
Constructs a polytope from a domain and a collection of half-spaces.
HalfSpaceIterator | any model of forward iterator on HalfSpace. |
domain | a bounded lattice domain. |
itB | the start of the range of half-spaces. |
itE | past the end of the range of half-spaces. |
valid_edge_constraints | when 'true', tells that there are half-spaces that represents th constraints on edges (n-2 cells) lying between two faces (n-1 cells) pointing to different orthants. |
check_duplicate_constraints | when 'true', the initialization checks if the given range of half-spaces contains axis-aligned half-space constraints already defined by the domain and if so it merges the duplicated constraints, otherwise it accepts and stores the constraints as is. |
|
private |
bool DGtal::BoundedLatticePolytope< TSpace >::canBeSummed | ( | ) | const |
std::string DGtal::BoundedLatticePolytope< TSpace >::className | ( | ) | const |
void DGtal::BoundedLatticePolytope< TSpace >::clear | ( | ) |
Clears the polytope.
BoundedLatticePolytope DGtal::BoundedLatticePolytope< TSpace >::closurePolytope | ( | ) | const |
Integer DGtal::BoundedLatticePolytope< TSpace >::count | ( | ) | const |
Computes the number of integer points lying within the polytope.
Referenced by DGtal::EhrhartPolynomial< TSpace, TInteger >::init().
Integer DGtal::BoundedLatticePolytope< TSpace >::countBoundary | ( | ) | const |
Computes the number of integer points lying on the boundary of the polytope.
count() <= countInterior() + countBoundary()
with equality when the polytope is closed. Integer DGtal::BoundedLatticePolytope< TSpace >::countBoundaryByScanning | ( | ) | const |
Computes the number of integer points lying on the boundary of the polytope.
count() <= countInterior() + countBoundary()
with equality when the polytope is closed. Integer DGtal::BoundedLatticePolytope< TSpace >::countByScanning | ( | ) | const |
Computes the number of integer points lying within the polytope.
Integer DGtal::BoundedLatticePolytope< TSpace >::countInterior | ( | ) | const |
Computes the number of integer points lying within the interior of the polytope.
count() <= countInterior() + countBoundary()
with equality when the polytope is closed. Integer DGtal::BoundedLatticePolytope< TSpace >::countInteriorByScanning | ( | ) | const |
Computes the number of integer points lying within the interior of the polytope.
count() <= countInterior() + countBoundary()
with equality when the polytope is closed. Integer DGtal::BoundedLatticePolytope< TSpace >::countUpTo | ( | Integer | max | ) | const |
Computes the number of integer points within the polytope up to some maximum number max.
[in] | max | the maximum number of points that are counted, the method exists when this number of reached. |
Integer DGtal::BoundedLatticePolytope< TSpace >::countUpToByScanning | ( | Integer | max | ) | const |
Computes the number of integer points within the polytope up to some maximum number max.
[in] | max | the maximum number of points that are counted, the method exists when this number of reached. |
Integer DGtal::BoundedLatticePolytope< TSpace >::countWithin | ( | Point | low, |
Point | hi | ||
) | const |
Computes the number of integer points within the polytope and the domain bounded by low and hi.
[in] | low | the lowest point of the domain. |
[in] | hi | the highest point of the domain. |
Integer DGtal::BoundedLatticePolytope< TSpace >::countWithinByScanning | ( | Point | low, |
Point | hi | ||
) | const |
Computes the number of integer points within the polytope and the domain bounded by low and hi.
[in] | low | the lowest point of the domain. |
[in] | hi | the highest point of the domain. |
unsigned int DGtal::BoundedLatticePolytope< TSpace >::cut | ( | const HalfSpace & | hs, |
bool | large = true , |
||
bool | valid_edge_constraint = false |
||
) |
Cuts the lattice polytope with the given half-space constraint.
hs | any half-space constraint. |
large | tells if the inequality is large (true) or strict (false). |
valid_edge_constraint | when 'true', tells that the half-spaces that represents constraints on edges (n-2 cells) lying between two faces (n-1 cells) pointing to different orthants are still valid after this operation. |
unsigned int DGtal::BoundedLatticePolytope< TSpace >::cut | ( | const Vector & | a, |
Integer | b, | ||
bool | large = true , |
||
bool | valid_edge_constraint = false |
||
) |
Cut the polytope by the given half space a.x <= b
or a.x < b
.
a | any integer vector |
b | any integer number |
large | tells if the inequality is large (true) or strict (false). |
valid_edge_constraint | when 'true', tells that the half-spaces that represents constraints on edges (n-2 cells) lying between two faces (n-1 cells) pointing to different orthants are still valid after this operation. |
unsigned int DGtal::BoundedLatticePolytope< TSpace >::cut | ( | Dimension | k, |
bool | pos, | ||
Integer | b, | ||
bool | large = true |
||
) |
Cut the polytope by the given half space a.x <= b
or a.x < b
where a
is some axis vector.
k | the dimension of the axis vector \( +/- e_k \) |
pos | 'true' is positive, 'false' is negative for the axis vector \( +/- e_k \) |
b | any integer number |
large | tells if the inequality is large (true) or strict (false). |
Referenced by DGtal::detail::BoundedLatticePolytopeSpecializer< 3, TInteger >::addEdgeConstraint().
const InequalityMatrix & DGtal::BoundedLatticePolytope< TSpace >::getA | ( | ) | const |
const Vector & DGtal::BoundedLatticePolytope< TSpace >::getA | ( | unsigned int | i | ) | const |
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
A
in constraint Ax <= b
). const InequalityVector & DGtal::BoundedLatticePolytope< TSpace >::getB | ( | ) | const |
Integer DGtal::BoundedLatticePolytope< TSpace >::getB | ( | unsigned int | i | ) | const |
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
b
in constraint Ax <= b
). void DGtal::BoundedLatticePolytope< TSpace >::getBoundaryPoints | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points boundary to the polytope.
[out] | pts | the integer points boundary to the polytope. |
void DGtal::BoundedLatticePolytope< TSpace >::getBoundaryPointsByScanning | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points boundary to the polytope.
[out] | pts | the integer points boundary to the polytope. |
const Domain & DGtal::BoundedLatticePolytope< TSpace >::getDomain | ( | ) | const |
const std::vector< bool > & DGtal::BoundedLatticePolytope< TSpace >::getI | ( | ) | const |
void DGtal::BoundedLatticePolytope< TSpace >::getInteriorPoints | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points interior to the polytope.
[out] | pts | the integer points interior to the polytope. |
void DGtal::BoundedLatticePolytope< TSpace >::getInteriorPointsByScanning | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points interior to the polytope.
[out] | pts | the integer points interior to the polytope. |
void DGtal::BoundedLatticePolytope< TSpace >::getKPoints | ( | std::vector< Point > & | pts, |
const Point & | alpha_shift | ||
) | const |
Computes the integer points within the polytope and converts them to cells represented with their Khalimsky coordinates.
[out] | pts | the integer points within the polytope, with coordinates equal to 2*p - alpha_shift , for p in the polytope. |
[in] | alpha_shift | the translation applied to each point. |
Referenced by SCENARIO().
void DGtal::BoundedLatticePolytope< TSpace >::getPoints | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points within the polytope.
[out] | pts | the integer points within the polytope. |
Referenced by checkCvxHPlusHypercubeFullConvexity(), checkFullConvexityCharacterization(), and SCENARIO().
void DGtal::BoundedLatticePolytope< TSpace >::getPointsByScanning | ( | std::vector< Point > & | pts | ) | const |
Computes the integer points within the polytope.
[out] | pts | the integer points within the polytope. |
void DGtal::BoundedLatticePolytope< TSpace >::init | ( | const Domain & | domain, |
HalfSpaceIterator | itB, | ||
HalfSpaceIterator | itE, | ||
bool | valid_edge_constraints = false , |
||
bool | check_duplicate_constraints = false |
||
) |
Initializes a polytope from a domain and a vector of half-spaces.
HalfSpaceIterator | any model of forward iterator on HalfSpace. |
domain | a bounded lattice domain. |
itB | the start of the range of half-spaces. |
itE | past the end of the range of half-spaces. |
valid_edge_constraints | when 'true', tells that there are half-spaces that represents the constraints on edges (n-2 cells) lying between two faces (n-1 cells) pointing to different orthants. |
check_duplicate_constraints | when 'true', the initialization checks if the given range of half-spaces contains axis-aligned half-space constraints already defined by the domain and if so it merges the duplicated constraints, otherwise it accepts and stores the constraints as is. |
bool DGtal::BoundedLatticePolytope< TSpace >::init | ( | PointIterator | itB, |
PointIterator | itE | ||
) |
Initializes the polytope from a simplex given as a range [itB,itE) of points.
itB | the start of the range of no more than n+1 points defining the simplex. |
itE | past the end the range of no more than n+1 points defining the simplex. |
void DGtal::BoundedLatticePolytope< TSpace >::insertKPoints | ( | PointSet & | pts_set, |
const Point & | alpha_shift | ||
) | const |
Computes the integer points within the polytope and converts them to cells represented with their Khalimsky coordinates.
PointSet | any model of set with a method insert( Point ) . |
[in,out] | pts_set | the set of points where points within this polytope are inserted. Each point is inserted with coordinates equal to 2*p - alpha_shift , for p in the polytope. |
[in] | alpha_shift | the translation applied to each point. |
void DGtal::BoundedLatticePolytope< TSpace >::insertPoints | ( | PointSet & | pts_set | ) | const |
Computes the integer points within the polytope.
PointSet | any model of set with a method insert( Point ) . |
[in,out] | pts_set | the set of points where points within this polytope are inserted. |
void DGtal::BoundedLatticePolytope< TSpace >::insertPointsByScanning | ( | PointSet & | pts_set | ) | const |
Computes the integer points within the polytope.
PointSet | any model of set with a method insert( Point ) . |
[in,out] | pts_set | the set of points where points within this polytope are inserted. |
BoundedLatticePolytope DGtal::BoundedLatticePolytope< TSpace >::interiorPolytope | ( | ) | const |
|
private |
In 2D, builds a valid lattice polytope with empty interior from 2 points.
a | any point |
b | any point |
|
private |
In 3D, builds a valid lattice polytope with empty interior from 2 points.
a | any point |
b | any point |
|
private |
In 3D, builds a valid lattice polytope with empty interior from 3 non-colinear points.
a | any point such that a, b, and c are not colinear. |
b | any point such that a, b, and c are not colinear. |
c | any point such that a, b, and c are not colinear. |
bool DGtal::BoundedLatticePolytope< TSpace >::isBoundary | ( | const Point & | p | ) | const |
p | any point of the space. |
bool DGtal::BoundedLatticePolytope< TSpace >::isDomainPointInside | ( | const Point & | p | ) | const |
p | any point inside the domain of this polytope. |
bool DGtal::BoundedLatticePolytope< TSpace >::isInside | ( | const Point & | p | ) | const |
p | any point of the space. |
bool DGtal::BoundedLatticePolytope< TSpace >::isInterior | ( | const Point & | p | ) | const |
p | any point of the space. |
bool DGtal::BoundedLatticePolytope< TSpace >::isLarge | ( | unsigned int | i | ) | const |
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
Ax <= b
, 'false' if it is of the form Ax < b
. bool DGtal::BoundedLatticePolytope< TSpace >::isValid | ( | ) | const |
Checks the validity/consistency of the object. If the polytope has been default constructed, it is invalid.
unsigned int DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces | ( | ) | const |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator*= | ( | Integer | t | ) |
Dilates this polytope P by t.
t | any integer. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | LeftStrictUnitCell | c | ) |
Minkowski sum of this polytope with an axis-aligned strict unit cell.
c | any strict unit cell. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | LeftStrictUnitSegment | s | ) |
Minkowski sum of this polytope with a strict unit segment aligned with some axis.
s | any strict unit segment. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | RightStrictUnitCell | c | ) |
Minkowski sum of this polytope with an axis-aligned strict unit cell.
c | any strict unit cell. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | RightStrictUnitSegment | s | ) |
Minkowski sum of this polytope with a strict unit segment aligned with some axis.
s | any strict unit segment. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | UnitCell | c | ) |
Minkowski sum of this polytope with an axis-aligned unit cell.
c | any unit cell. |
Self & DGtal::BoundedLatticePolytope< TSpace >::operator+= | ( | UnitSegment | s | ) |
Minkowski sum of this polytope with a unit segment aligned with some axis.
s | any unit segment. |
|
default |
Assignment.
other | the object to copy. |
void DGtal::BoundedLatticePolytope< TSpace >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
void DGtal::BoundedLatticePolytope< TSpace >::swap | ( | BoundedLatticePolytope< TSpace > & | other | ) |
Swaps the content of this object with other. O(1) complexity.
other | any other BoundedLatticePolytope. |
|
protected |
The matrix A in the polytope representation \( Ax \le B \).
Definition at line 836 of file BoundedLatticePolytope.h.
|
protected |
The vector B in the polytope representation \( Ax \le B \).
Definition at line 838 of file BoundedLatticePolytope.h.
|
protected |
Tight bounded box.
Definition at line 840 of file BoundedLatticePolytope.h.
|
static |
Definition at line 92 of file BoundedLatticePolytope.h.
|
protected |
Are inequalities large ?
Definition at line 842 of file BoundedLatticePolytope.h.
|
protected |
Indicates if Minkowski sums with segments will be valid.
Definition at line 844 of file BoundedLatticePolytope.h.