DGtal 2.1.0
Loading...
Searching...
No Matches
DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K > Struct Template Reference

#include <DGtal/geometry/tools/GenericLatticeConvexHull.h>

Inheritance diagram for DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >:
[legend]

Public Types

typedef ConvexHullIntegralKernel< K, TCoordinateInteger, TInternalInteger > Kernel
 
typedef detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K-1 > LowerKernels
 
typedef std::size_t Size
 
typedef Kernel::CoordinatePoint Point
 
typedef Point::Coordinate Integer
 
typedef QuickHull< KernelQHull
 
typedef SpaceND< K, IntegerSpace
 
typedef BoundedLatticePolytope< SpaceLatticePolytope
 
typedef GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger > Computer
 
typedef Computer::OutputPoint OutputPoint
 

Public Member Functions

 GenericLatticeConvexHullComputers (Computer *ptrGenQHull)
 
void clear ()
 Clears the object as if no computations have been made.
 
template<typename TInputPoint >
bool compute (const std::vector< Size > &I, const std::vector< TInputPoint > &X)
 
bool makePolytope ()
 
Integer count ()
 
Integer countInterior ()
 
Integer countBoundary ()
 
Integer countUpTo (Integer max)
 

Data Fields

Computerptr_gen_qhull
 the pointer on the parent computer
 
LowerKernels lower_kernels
 the computers of lower dimension
 
QHull hull
 the quick hull object that computes the convex hull
 
std::vector< Pointproj_points
 the projected points, as points in lower dimension
 
LatticePolytope polytope
 the polytope corresponding to the convex hull
 

Static Public Attributes

static const Dimension dimension = K
 

Detailed Description

template<Dimension dim, typename TCoordinateInteger, typename TInternalInteger, Dimension K>
struct DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >

Definition at line 69 of file GenericLatticeConvexHull.h.

Member Typedef Documentation

◆ Computer

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger > DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Computer

Definition at line 83 of file GenericLatticeConvexHull.h.

◆ Integer

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef Point::Coordinate DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Integer

Definition at line 77 of file GenericLatticeConvexHull.h.

◆ Kernel

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef ConvexHullIntegralKernel< K,TCoordinateInteger,TInternalInteger > DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Kernel

Definition at line 72 of file GenericLatticeConvexHull.h.

◆ LatticePolytope

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef BoundedLatticePolytope< Space > DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::LatticePolytope

Definition at line 80 of file GenericLatticeConvexHull.h.

◆ LowerKernels

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K-1> DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::LowerKernels

Definition at line 74 of file GenericLatticeConvexHull.h.

◆ OutputPoint

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef Computer::OutputPoint DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::OutputPoint

Definition at line 84 of file GenericLatticeConvexHull.h.

◆ Point

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef Kernel::CoordinatePoint DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Point

Definition at line 76 of file GenericLatticeConvexHull.h.

◆ QHull

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef QuickHull< Kernel > DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::QHull

Definition at line 78 of file GenericLatticeConvexHull.h.

◆ Size

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef std::size_t DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Size

Definition at line 75 of file GenericLatticeConvexHull.h.

◆ Space

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
typedef SpaceND< K, Integer > DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::Space

Definition at line 79 of file GenericLatticeConvexHull.h.

Constructor & Destructor Documentation

◆ GenericLatticeConvexHullComputers()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::GenericLatticeConvexHullComputers ( Computer ptrGenQHull)
inline

Constructor.

Parameters
ptrGenQHullthe pointer on the parent computer.

Definition at line 89 of file GenericLatticeConvexHull.h.

90 : ptr_gen_qhull( ptrGenQHull ), lower_kernels( ptrGenQHull ),
91 hull( Kernel(), ptrGenQHull->debug_level )
92 {
93 clear();
94 }
LowerKernels lower_kernels
the computers of lower dimension
void clear()
Clears the object as if no computations have been made.
QHull hull
the quick hull object that computes the convex hull
ConvexHullIntegralKernel< K, TCoordinateInteger, TInternalInteger > Kernel
Computer * ptr_gen_qhull
the pointer on the parent computer

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::clear().

Member Function Documentation

◆ clear()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
void DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::clear ( )
inline

Clears the object as if no computations have been made.

Definition at line 97 of file GenericLatticeConvexHull.h.

98 {
99 hull.clear();
100 proj_points.clear();
101 polytope.clear();
103 }
void clear()
Clears the polytope.
void clear()
Clears the object.
Definition QuickHull.h:271
LatticePolytope polytope
the polytope corresponding to the convex hull
std::vector< Point > proj_points
the projected points, as points in lower dimension

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::clear(), DGtal::QuickHull< TKernel >::clear(), DGtal::BoundedLatticePolytope< TSpace >::clear(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::hull, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::proj_points.

Referenced by DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::clear(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::clear(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::GenericLatticeConvexHullComputers(), and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, 1 >::GenericLatticeConvexHullComputers().

◆ compute()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
template<typename TInputPoint >
bool DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::compute ( const std::vector< Size > &  I,
const std::vector< TInputPoint > &  X 
)
inline
Template Parameters
TInputPointany type of input points.
Parameters
Ia range of indices specifying an affine subset of X.
Xthe range of input points.

Copy back convex hull in initial space.

Definition at line 109 of file GenericLatticeConvexHull.h.

111 {
112 typedef TInputPoint InputPoint;
113 typedef AffineGeometry< InputPoint > Affine;
114 typedef AffineBasis< InputPoint > Basis;
115 hull.clear();
116 polytope.clear();
117 if ( (I.size()-1) != dimension )
118 { // This kernel is not adapted => go to lower dimension
119 return lower_kernels.compute( I, X );
120 }
122 auto& points = ptr_gen_qhull->points;
123 auto& ppoints = ptr_gen_qhull->projected_points;
124 auto& positions = ptr_gen_qhull->positions;
125 auto& v2p = ptr_gen_qhull->vertex2point;
126 auto& facets = ptr_gen_qhull->facets;
127 auto& dilation = ptr_gen_qhull->projected_dilation;
128 auto& aff_basis = ptr_gen_qhull->affine_basis;
129
130 Basis basis;
132 { // Build the affine basis spanning the convex hull affine space.
134 { // codimension 1
135 // builds orthogonal vector
136 InputPoint normal;
137 functions::getOrthogonalVector( normal, X, I );
138 basis = Basis( X[0], normal, Basis::Type::ECHELON_REDUCED );
139 }
140 else
141 { // Generic case
142 basis = Basis( X, Basis::Type::SHORTEST_ECHELON_REDUCED );
143 }
144 }
145 // Build projected points on affine basis
146 dilation = basis.projectPoints( proj_points, X );
147
148 // Compute convex hull using quickhull.
149 bool ok_input = hull.setInput( proj_points, false );
150 bool ok_hull = hull.computeConvexHull( QHull::Status::VerticesCompleted );
151 if ( ! ok_hull || ! ok_input )
152 {
153 trace.error() << "[GenericLatticeConvexHullComputers::compute]"
154 << " Error in quick hull computation.\n"
155 << "qhull=" << hull << "\n";
156 return false;
157 }
159 points.resize( X.size() );
160 for ( Size i = 0; i < points.size(); i++ )
161 points[ i ] = Affine::transform( X[ i ] );
162 hull.getVertex2Point( v2p );
163 hull.getFacetVertices( facets );
164 positions.resize( v2p.size() );
165 for ( Size i = 0; i < positions.size(); i++ )
166 positions[ i ] = X[ v2p[ i ] ];
167 ppoints.resize( proj_points.size() );
168 for ( Size i = 0; i < ppoints.size(); i++ )
169 {
170 ppoints[ i ] = OutputPoint::zero;
171 for ( Dimension j = 0; j < Point::dimension; j++ )
172 ppoints[ i ][ j ] = proj_points[ i ][ j ];
173 }
174 aff_basis = AffineBasis<OutputPoint>( basis.origin(),
175 basis.basis(),
176 Basis::Type::SHORTEST_ECHELON_REDUCED,
177 true );
178 return true;
179 }
static Self zero
Static const for zero PointVector.
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
std::ostream & error()
static void getOrthogonalVector(TPoint &w, const std::vector< TInputPoint > &X, const TIndexRange &I, const double tolerance=1e-12)
DGtal::uint32_t Dimension
Definition Common.h:119
Trace trace
int64_t affine_dimension
The affine dimension of the input set.
AffineBasis< OutputPoint > affine_basis
std::vector< OutputPoint > points
the set of input points, indexed as in the input
std::vector< OutputPoint > positions
The positions of the vertices (a subset of the input points).
IndexRange vertex2point
The indices of the vertices of the convex hull in the original set.
Integer projected_dilation
The factor of dilation d applied on every projected point coordinates.
std::vector< OutputPoint > projected_points
the set of projected input points, indexed as in the input
std::vector< IndexRange > facets
The range giving for each facet the indices of its vertices.
bool setInput(const std::vector< InputPoint > &input_points, bool remove_duplicates=true)
Definition QuickHull.h:383
bool getFacetVertices(std::vector< IndexRange > &facet_vertices) const
Definition QuickHull.h:667
bool getVertex2Point(IndexRange &vertex_to_point)
Definition QuickHull.h:633
bool computeConvexHull(Status target=Status::VerticesCompleted)
Definition QuickHull.h:461
bool compute(const std::vector< Size > &I, const std::vector< TInputPoint > &X)
HalfEdgeDataStructure::Size Size

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_basis, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::QuickHull< TKernel >::clear(), DGtal::BoundedLatticePolytope< TSpace >::clear(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::compute(), DGtal::QuickHull< TKernel >::computeConvexHull(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::dimension, DGtal::PointVector< dim, TEuclideanRing, TContainer >::dimension, DGtal::Trace::error(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::facets, DGtal::QuickHull< TKernel >::getFacetVertices(), DGtal::functions::getOrthogonalVector(), DGtal::QuickHull< TKernel >::getVertex2Point(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::hull, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::points, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::positions, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::proj_points, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_dilation, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_points, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull, DGtal::QuickHull< TKernel >::setInput(), DGtal::trace, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::vertex2point, and DGtal::PointVector< dim, TEuclideanRing, TContainer >::zero.

Referenced by DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::compute(), and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::compute().

◆ count()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
Integer DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::count ( )
inline

Computes the number of integer points lying within the polytope.

Returns
the number of integer points lying within the polytope, or -1 if their was a problem when computing the polytope.
Note
Quite fast: obtained by line intersection, see BoundedLatticePolytopeCounter

Definition at line 233 of file GenericLatticeConvexHull.h.

234 {
236 { // This kernel is not adapted => go to lower dimension
237 return lower_kernels.count();
238 }
239 // If polytope is not initialized returns error.
240 if ( polytope.nbHalfSpaces() == 0 ) return -1;
241 return polytope.count();
242 }
unsigned int nbHalfSpaces() const

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::count(), DGtal::BoundedLatticePolytope< TSpace >::count(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull.

Referenced by DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::count(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::count().

◆ countBoundary()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
Integer DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countBoundary ( )
inline

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 fast: obtained by line intersection, see BoundedLatticePolytopeCounter
count() <= countInterior() + countBoundary() with equality when the polytope is closed.

Definition at line 273 of file GenericLatticeConvexHull.h.

274 {
276 { // This kernel is not adapted => go to lower dimension
278 }
279 // If polytope is not initialized returns error.
280 if ( polytope.nbHalfSpaces() == 0 ) return -1;
281 return polytope.countBoundary();
282 }

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countBoundary(), DGtal::BoundedLatticePolytope< TSpace >::countBoundary(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull.

Referenced by DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countBoundary(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countBoundary().

◆ countInterior()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
Integer DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countInterior ( )
inline

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 fast: obtained by line intersection, see BoundedLatticePolytopeCounter
count() <= countInterior() + countBoundary() with equality when the polytope is closed.

Definition at line 253 of file GenericLatticeConvexHull.h.

254 {
256 { // This kernel is not adapted => go to lower dimension
258 }
259 // If polytope is not initialized returns error.
260 if ( polytope.nbHalfSpaces() == 0 ) return -1;
261 return polytope.countInterior();
262 }

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countInterior(), DGtal::BoundedLatticePolytope< TSpace >::countInterior(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull.

Referenced by DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countInterior(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countInterior().

◆ countUpTo()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
Integer DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countUpTo ( Integer  max)
inline

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]maxthe 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 fast: obtained by line intersection, see BoundedLatticePolytopeCounter

Definition at line 299 of file GenericLatticeConvexHull.h.

300 {
302 { // This kernel is not adapted => go to lower dimension
303 return lower_kernels.countUpTo( max );
304 }
305 // If polytope is not initialized returns error.
306 if ( polytope.nbHalfSpaces() == 0 ) return -1;
307 return polytope.countUpTo( max );
308 }
Integer countUpTo(Integer max) const
int max(int a, int b)

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countUpTo(), DGtal::BoundedLatticePolytope< TSpace >::countUpTo(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, max(), DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull.

Referenced by DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countUpTo(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countUpTo().

◆ makePolytope()

template<Dimension dim, typename TCoordinateInteger , typename TInternalInteger , Dimension K>
bool DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope ( )
inline

Constructs the polytope that is the F-representation of the convex hull.

Returns
'true' iff the constructed polytope is valid.

Definition at line 183 of file GenericLatticeConvexHull.h.

184 {
185 typedef typename LatticePolytope::Domain Domain;
186 typedef typename LatticePolytope::HalfSpace PolytopeHalfSpace;
187 typedef typename QHull::HalfSpace ConvexHullHalfSpace;
188 typedef AffineGeometry< Point > Affine;
190 { // This kernel is not adapted => go to lower dimension
192 }
193 // If polytope is already initialized returns.
194 if ( polytope.nbHalfSpaces() > 0 ) return true;
195 // Compute domain
196 Point l = proj_points[ 0 ];
197 Point u = proj_points[ 0 ];
198 for ( std::size_t i = 1; i < proj_points.size(); i++ )
199 {
200 const auto& p = proj_points[ i ];
201 l = l.inf( p );
202 u = u.sup( p );
203 }
204 Domain domain( l, u );
205
206 // Initialize polytope
207 std::vector< ConvexHullHalfSpace > HS;
208 std::vector< PolytopeHalfSpace > PHS;
210 PHS.reserve( HS.size() );
211 for ( auto& H : HS ) {
212 Point N;
213 Integer nu;
214 for ( Dimension i = 0; i < dimension; ++i )
215 N[ i ] = IntegerConverter< dimension, Integer >
216 ::cast( H.internalNormal()[ i ] );
217 Point Ns = Affine::simplifiedVector( N );
218 Integer g = N.norm1() / Ns.norm1();
219 nu = IntegerConverter< dimension, Integer >::cast( H.internalIntercept() );
220 PHS.emplace_back( Ns, nu / g );
221 }
222 polytope = LatticePolytope( domain, PHS.cbegin(), PHS.cend(), false, true );
223 return polytope.isValid();
224 }
ClosedIntegerHalfPlane< Space > HalfSpace
static Integer cast(Integer i)
bool getFacetHalfSpaces(std::vector< HalfSpace > &facet_halfspaces)
Definition QuickHull.h:691
Kernel::HalfSpace HalfSpace
Definition QuickHull.h:151
std::mt19937 g(rd())
Domain domain
HyperRectDomain< Space > Domain

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::IntegerConverter< dim, TInteger >::cast(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::dimension, domain, g(), DGtal::QuickHull< TKernel >::getFacetHalfSpaces(), DGtal::H, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::hull, DGtal::PointVector< dim, TEuclideanRing, TContainer >::inf(), DGtal::BoundedLatticePolytope< TSpace >::isValid(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::lower_kernels, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope(), DGtal::BoundedLatticePolytope< TSpace >::nbHalfSpaces(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm1(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::polytope, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::proj_points, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::ptr_gen_qhull, and DGtal::PointVector< dim, TEuclideanRing, TContainer >::sup().

Referenced by DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::count(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countBoundary(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countInterior(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countUpTo(), and DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope().

Field Documentation

◆ dimension

◆ hull

◆ lower_kernels

◆ polytope

◆ proj_points

◆ ptr_gen_qhull


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