31 #if defined(ConvexCellComplex_RECURSES)
32 #error Recursive header files inclusion detected in ConvexCellComplex.h
35 #define ConvexCellComplex_RECURSES
37 #if !defined ConvexCellComplex_h
39 #define ConvexCellComplex_h
46 #include "DGtal/base/Common.h"
47 #include "DGtal/kernel/PointVector.h"
48 #include "DGtal/math/linalg/SimpleMatrix.h"
49 #include "DGtal/geometry/volumes/BoundedLatticePolytope.h"
84 template <
typename TPo
int >
94 typedef std::pair< Index, bool >
Face;
100 typedef typename Point::Coordinate
Scalar;
157 {
return std::make_pair( f.first, ! f.second ); }
218 std::sort( f_vtcs.begin(), f_vtcs.end() );
219 for (
auto v : c_vtcs )
220 if ( ! std::binary_search( f_vtcs.cbegin(), f_vtcs.cend(), v ) )
221 result.push_back( v );
237 std::vector< Point > pts( vtcs.size() );
238 std::transform( vtcs.cbegin(), vtcs.cend(), pts.begin(),
239 [&] (
Vertex v ) { return this->position( v ); } );
248 std::vector< Point > pts( vtcs.size() );
249 std::transform( vtcs.cbegin(), vtcs.cend(), pts.begin(),
250 [&] (
Vertex v ) { return this->position( v ); } );
267 x[ k ] = (
double) p[ k ];
274 template <
typename LatticePo
int >
279 x[ k ] = (
typename LatticePoint::Coordinate) round( p[ k ] * factor );
291 for (
auto v : vtcs )
293 return b / vtcs.size();
300 template <
typename LatticePolytope >
307 typedef typename LatticePolytope::HalfSpace HalfSpace;
310 std::vector< LatticePoint > pts;
311 for (
auto v : vtcs )
312 pts.push_back( toLattice< LatticePoint >(
position ( v ), factor ) );
313 LatticePoint l = pts[ 0 ];
314 LatticePoint u = pts[ 0 ];
315 for (
const auto& p : pts ) {
320 std::vector< HalfSpace > HS;
324 return LatticePolytope(
domain, HS.cbegin(), HS.cend(),
false );
407 out <<
"[ConvexCellComplex<" <<
dimension <<
">"
434 std::set< Vertex > vertices;
451 trace.
error() <<
"[ConvexCellComplex::computeFaceGeometry]"
452 <<
" null normal vector at face " << f << std::endl;
458 if ( ! f.second )
continue;
460 ASSERT( ! ov.empty() );
464 if ( ( iv - nu ) > 0 ) {
479 std::pair< Vector, Scalar >
488 A.setComponent( i-1, j,
position( v[ i ] )[ j ] -
position( v[ 0 ] )[ j ] );
492 return std::make_pair( N, c );
514 splx[ k ] = result[ k ];
515 std::sort( result.begin()+
dimension-2, result.end(),
518 splx[ dimension-2 ] = i;
519 splx[ dimension-1 ] = j;
520 const auto H = computeHalfSpace( splx );
521 const auto orient = N.dot( H.first );
536 template <
typename TPo
int>
540 object.selfDisplay( out );
548 #undef ConvexCellComplex_RECURSES
Aim: Implements basic operations that will be used in Point and Vector classes.
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
static Self zero
Static const for zero PointVector.
Aim: implements basic MxN Matrix services (M,N>=1).
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
Aim: represents a d-dimensional complex in a d-dimensional space with the following properties and re...
const Vector & faceNormal(const Face f) const
std::vector< Point > cellVertexPositions(const Cell c) const
std::vector< VertexRange > true_face_vertices
Tells if the face geometry has been computed.
Cell faceCell(const Face f) const
void reorderFaceVertices(Index f)
std::vector< Scalar > true_face_intercept
Contains the intercept of each 'true' face.
std::vector< Cell > false_face_cell
Tells if the face geometry has been computed.
LatticePolytope cellLatticePolytope(const Cell c, const double factor=1.0) const
std::vector< Cell > true_face_cell
Tells if the face geometry has been computed.
bool has_face_geometry
Tells if the face geometry has been computed.
bool hasFaceGeometry() const
void selfDisplay(std::ostream &out) const
const VertexRange & cellVertices(const Cell c) const
std::vector< Index > IndexRange
std::pair< Index, bool > Face
static const Index INFINITE_CELL
VertexRange faceComplementVertices(const Face f) const
Face opposite(const Face f) const
Point position(const Vertex v) const
void clear()
Clears the complex (as if it was just default constructed).
Scalar faceIntercept(const Face f) const
std::vector< FaceRange > cell_faces
Tells if the face geometry has been computed.
PointVector< dimension, double > RealPoint
std::vector< Vertex > VertexRange
static const Dimension dimension
std::vector< Face > FaceRange
PointVector< dimension, Scalar > Vector
VertexRange faceVertices(const Face f) const
RealPoint toReal(const Point p) const
std::vector< Point > faceVertexPositions(const Face f) const
RealPoint cellBarycenter(const Cell c) const
std::pair< Vector, Scalar > computeHalfSpace(const VertexRange &v) const
void requireFaceGeometry()
Forces the computation of face geometry.
void computeCellVertices(const Cell c) const
const FaceRange & cellFaces(const Cell c) const
bool isInfinite(const Cell c) const
ConvexCellComplex()
Defaut constructor.
LatticePoint toLattice(const RealPoint p, double factor=1.0) const
Cell infiniteCell() const
std::vector< VertexRange > cell_vertices
Tells if the face geometry has been computed.
std::vector< Vector > true_face_normal
Contains the outward oriented normal of each 'true' face.
std::vector< Point > vertex_position
Tells if the face geometry has been computed.
const std::vector< VertexRange > & allCellVertices() const
void computeFaceGeometry()
Computes for each face its outward oriented normal vector.
void unrequireFaceGeometry()
Release ressources allocated to face geometry.
PointVector< dimension, double > RealVector
HyperRectDomain< Space > Domain