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>
|
|
| ~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...
|
|
|
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 |
|
|
bool | isInside (const Point &p) const |
|
bool | isDomainPointInside (const Point &p) const |
|
bool | isInterior (const Point &p) const |
|
bool | isBoundary (const Point &p) const |
|
|
BoundedLatticePolytope | interiorPolytope () const |
|
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) |
|
|
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 | getInteriorPoints (std::vector< Point > &pts) const |
|
void | getBoundaryPoints (std::vector< Point > &pts) const |
|
template<typename PointSet > |
void | insertPoints (PointSet &pts_set) const |
|
|
void | selfDisplay (std::ostream &out) const |
|
bool | isValid () const |
|
std::string | className () const |
|
template<typename TSpace>
class DGtal::BoundedLatticePolytope< TSpace >
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.
- Template Parameters
-
TSpace | an arbitrary model of CSpace. |
Definition at line 74 of file BoundedLatticePolytope.h.
◆ BigInteger
template<typename TSpace >
◆ Domain
template<typename TSpace >
◆ HalfSpace
template<typename TSpace >
◆ InequalityMatrix
template<typename TSpace >
◆ InequalityVector
template<typename TSpace >
◆ Integer
template<typename TSpace >
◆ Point
template<typename TSpace >
◆ Self
template<typename TSpace >
◆ Space
template<typename TSpace >
◆ Vector
template<typename TSpace >
◆ ~BoundedLatticePolytope()
template<typename TSpace >
◆ BoundedLatticePolytope() [1/5]
template<typename TSpace >
◆ BoundedLatticePolytope() [2/5]
template<typename TSpace >
Copy constructor.
- Parameters
-
other | the object to clone. |
◆ BoundedLatticePolytope() [3/5]
template<typename TSpace >
Constructs the polytope from a simplex given as an initializer_list.
- Parameters
-
l | any list of no more than d+1 points in general positions. |
◆ BoundedLatticePolytope() [4/5]
template<typename TSpace >
template<typename PointIterator >
Constructs the polytope from a simplex given as a range [itB,itE) of lattice points.
- Template Parameters
-
PointIterator | any model of forward iterator on Point. |
- Parameters
-
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. |
◆ BoundedLatticePolytope() [5/5]
template<typename TSpace >
template<typename HalfSpaceIterator >
Constructs a polytope from a domain and a collection of half-spaces.
- Template Parameters
-
HalfSpaceIterator | any model of forward iterator on HalfSpace. |
- Parameters
-
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. |
◆ BOOST_CONCEPT_ASSERT()
template<typename TSpace >
◆ canBeSummed()
template<typename TSpace >
- Returns
- 'true' if we can perform exact Minkowksi sums on this polytope. This is related to the presence of valid edge constraints (n-k cells for k >= 2) in-between face constraints (n-1 cells) that change orthants.
◆ className()
template<typename TSpace >
- Returns
- the class name. It is notably used for drawing this object.
◆ clear()
template<typename TSpace >
◆ count()
template<typename TSpace >
Computes the number of integer points lying within the polytope.
- Returns
- the number of integer points lying within the polytope.
- Note
- Quite slow: obtained by checking every point of the polytope domain.
◆ countBoundary()
template<typename TSpace >
Computes the number of integer points lying on the boundary of the polytope.
- Returns
- the number of integer points lying on the boundary of the polytope.
- Note
- Quite slow: obtained by checking every point of the polytope domain.
-
count() <= countInterior() + countBoundary()
with equality when the polytope is closed.
◆ countInterior()
template<typename TSpace >
Computes the number of integer points lying within the interior of the polytope.
- Returns
- the number of integer points lying within the interior of the polytope.
- Note
- Quite slow: obtained by checking every point of the polytope domain.
-
count() <= countInterior() + countBoundary()
with equality when the polytope is closed.
◆ countUpTo()
template<typename TSpace >
Computes the number of integer points within the polytope up to some maximum number max.
- Note
- For instance, a d-dimensional simplex that contains no integer points in its interior contains only d+1 points. If there is more, you know that the simplex has a non empty interior.
- Parameters
-
[in] | max | the maximum number of points that are counted, the method exists when this number of reached. |
- Returns
- the number of integer points within the polytope up to .
- Note
- Quite slow: obtained by checking every point of the polytope domain.
◆ countWithin()
template<typename TSpace >
Computes the number of integer points within the polytope and the domain bounded by low and hi.
- Parameters
-
[in] | low | the lowest point of the domain. |
[in] | hi | the highest point of the domain. |
- Returns
- the number of integer points within the polytope.
- Note
- Quite slow: obtained by checking every point of the polytope domain.
◆ cut() [1/3]
template<typename TSpace >
Cuts the lattice polytope with the given half-space constraint.
- Parameters
-
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. |
- Returns
- the index of the constraint in the polytope.
- Note
- For now complexity is O(n) where n=A.rows() because it checks if a parallel closed half-space defines already a face of the polytope.
◆ cut() [2/3]
template<typename TSpace >
Cut the polytope by the given half space a.x <= b
or a.x < b
.
- Parameters
-
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. |
- Returns
- the index of the constraint in the polytope.
- Note
- For now complexity is O(n) where n=A.rows() because it checks if a parallel closed half-space defines already a face of the polytope.
◆ cut() [3/3]
template<typename TSpace >
Cut the polytope by the given half space a.x <= b
or a.x < b
where a
is some axis vector.
- Parameters
-
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). |
- Returns
- the index of the constraint in the polytope.
Referenced by DGtal::detail::BoundedLatticePolytopeSpecializer< 3, TInteger >::addEdgeConstraint().
◆ getA() [1/2]
template<typename TSpace >
- Returns
- the matrix A in the polytope representation \( Ax \le B \).
◆ getA() [2/2]
template<typename TSpace >
- Parameters
-
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
- Returns
- the normal vector of the i-th half space constraint (i.e.
A
in constraint Ax <= b
).
◆ getB() [1/2]
template<typename TSpace >
- Returns
- the vector B in the polytope representation \( Ax \le B \).
◆ getB() [2/2]
template<typename TSpace >
- Parameters
-
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
- Returns
- the offset of the i-th half space constraint (i.e.
b
in constraint Ax <= b
).
◆ getBoundaryPoints()
template<typename TSpace >
Computes the integer points boundary to the polytope.
- Parameters
-
[out] | pts | the integer points boundary to the polytope. |
- Note
- Quite slow: obtained by checking every point of the polytope domain.
-
At output, pts.size() == this->countBoundary()
◆ getDomain()
template<typename TSpace >
- Returns
- the domain of the current polytope.
◆ getI()
template<typename TSpace >
- Returns
- the vector I telling if inequalities are large in the polytope representation \( Ax \prec B \), with \( \prec \in \{ <, \le \} \).
◆ getInteriorPoints()
template<typename TSpace >
Computes the integer points interior to the polytope.
- Parameters
-
[out] | pts | the integer points interior to the polytope. |
- Note
- Quite slow: obtained by checking every point of the polytope domain.
-
At output, pts.size() == this->countInterior()
◆ getPoints()
template<typename TSpace >
Computes the integer points within the polytope.
- Parameters
-
[out] | pts | the integer points within the polytope. |
- Note
- Quite slow: obtained by checking every point of the polytope domain.
-
At output, pts.size() == this->count()
◆ init() [1/2]
template<typename TSpace >
template<typename HalfSpaceIterator >
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.
- Template Parameters
-
HalfSpaceIterator | any model of forward iterator on HalfSpace. |
- Parameters
-
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. |
◆ init() [2/2]
template<typename TSpace >
template<typename PointIterator >
Initializes the polytope from a simplex given as a range [itB,itE) of points.
- Parameters
-
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. |
- Returns
- 'true' if [itB,itE) was a valid simplex, otherwise return 'false' and the polytope is empty.
- Note
- Use DGtal SimpleMatrix::determinant which is not efficient when the dimension is high. Does not use Eigen to avoid dependency.
◆ insertPoints()
template<typename TSpace >
template<typename PointSet >
Computes the integer points within the polytope.
- Template Parameters
-
PointSet | any model of set with a method insert( Point ) . |
- Parameters
-
[in,out] | pts_set | the set of points where points within this polytope are inserted. |
- Note
- Quite slow: obtained by checking every point of the polytope domain.
◆ interiorPolytope()
template<typename TSpace >
- Returns
- the interior (in the topological sense) of this polytope, by making all constraints strict.
◆ internalInitFromSegment2D()
template<typename TSpace >
In 2D, builds a valid lattice polytope with empty interior from 2 points.
- Parameters
-
- Returns
- 'true'
◆ internalInitFromSegment3D()
template<typename TSpace >
In 3D, builds a valid lattice polytope with empty interior from 2 points.
- Parameters
-
- Returns
- 'true'
◆ internalInitFromTriangle3D()
template<typename TSpace >
In 3D, builds a valid lattice polytope with empty interior from 3 non-colinear points.
- Parameters
-
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. |
- Returns
- 'true' if they were not colinear, false otherwise.
◆ isBoundary()
template<typename TSpace >
- Parameters
-
- Returns
- 'true' if and only if p lies on the boundary of this polytope.
◆ isDomainPointInside()
template<typename TSpace >
- Parameters
-
p | any point inside the domain of this polytope. |
- Returns
- 'true' if and only if p is inside this polytope.
- Note
- Slightly faster than isInside.
◆ isInside()
template<typename TSpace >
- Parameters
-
- Returns
- 'true' if and only if p is inside this polytope.
◆ isInterior()
template<typename TSpace >
- Parameters
-
- Returns
- 'true' if and only if p is strictly inside this polytope.
◆ isLarge()
template<typename TSpace >
- Parameters
-
i | the index of the half-space constraint between 0 and nbHalfSpaces() (excluded). |
- Returns
- 'true' if the i-th half space constraint is of the form
Ax <= b
, 'false' if it is of the form Ax < b
.
◆ isValid()
template<typename TSpace >
Checks the validity/consistency of the object. If the polytope has been default constructed, it is invalid.
- Returns
- 'true' if the object is valid, 'false' otherwise.
◆ nbHalfSpaces()
template<typename TSpace >
- Returns
- the number of half-space constraints.
◆ operator*=()
template<typename TSpace >
Dilates this polytope P by t.
- Parameters
-
- Returns
- a reference to 'this', which is now the polytope tP.
◆ operator+=() [1/6]
template<typename TSpace >
Minkowski sum of this polytope with an axis-aligned strict unit cell.
- Parameters
-
- Returns
- a reference to 'this'.
◆ operator+=() [2/6]
template<typename TSpace >
Minkowski sum of this polytope with a strict unit segment aligned with some axis.
- Parameters
-
s | any strict unit segment. |
- Returns
- a reference to 'this'.
◆ operator+=() [3/6]
template<typename TSpace >
Minkowski sum of this polytope with an axis-aligned strict unit cell.
- Parameters
-
- Returns
- a reference to 'this'.
◆ operator+=() [4/6]
template<typename TSpace >
Minkowski sum of this polytope with a strict unit segment aligned with some axis.
- Parameters
-
s | any strict unit segment. |
- Returns
- a reference to 'this'.
◆ operator+=() [5/6]
template<typename TSpace >
Minkowski sum of this polytope with an axis-aligned unit cell.
- Parameters
-
- Returns
- a reference to 'this'.
◆ operator+=() [6/6]
template<typename TSpace >
Minkowski sum of this polytope with a unit segment aligned with some axis.
- Parameters
-
- Returns
- a reference to 'this'.
◆ operator=()
template<typename TSpace >
Assignment.
- Parameters
-
- Returns
- a reference on 'this'.
◆ selfDisplay()
template<typename TSpace >
Writes/Displays the object on an output stream.
- Parameters
-
out | the output stream where the object is written. |
◆ swap()
template<typename TSpace >
Swaps the content of this object with other. O(1) complexity.
- Parameters
-
template<typename TSpace >
template<typename TSpace >
template<typename TSpace >
◆ dimension
template<typename TSpace >
template<typename TSpace >
◆ myValidEdgeConstraints
template<typename TSpace >
The documentation for this class was generated from the following file: