DGtal  1.3.beta
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions
DGtal::Shortcuts< TKSpace > Class Template Reference

Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes and surface with few lines of code. The drawback is that you use specific types or objects, which could lead to faster code or more compact data structures. More...

#include <DGtal/helpers/Shortcuts.h>

Inheritance diagram for DGtal::Shortcuts< TKSpace >:
[legend]

Data Structures

struct  CellReader
 
struct  CellWriter
 
struct  SCellReader
 
struct  SCellWriter
 
struct  ValueReader
 
struct  ValueWriter
 

Public Types

typedef TKSpace KSpace
 Digital cellular space. More...
 
typedef KSpace::Space Space
 Digital space. More...
 
typedef Space::Integer Integer
 Integer numbers. More...
 
typedef Space::Point Point
 Point with integer coordinates. More...
 
typedef Space::Vector Vector
 Vector with integer coordinates. More...
 
typedef Space::RealVector RealVector
 Vector with floating-point coordinates. More...
 
typedef Space::RealPoint RealPoint
 Point with floating-point coordinates. More...
 
typedef RealVector::Component Scalar
 Floating-point numbers. More...
 
typedef HyperRectDomain< SpaceDomain
 An (hyper-)rectangular domain. More...
 
typedef unsigned char GrayScale
 The type for 8-bits gray-scale elements. More...
 
typedef MPolynomial< Space::dimension, ScalarScalarPolynomial
 defines a multi-variate polynomial : RealPoint -> Scalar More...
 
typedef ImplicitPolynomial3Shape< SpaceImplicitShape3D
 
typedef GaussDigitizer< Space, ImplicitShape3DDigitizedImplicitShape3D
 defines the digitization of an implicit shape. More...
 
typedef ImageContainerBySTLVector< Domain, bool > BinaryImage
 defines a black and white image with (hyper-)rectangular domain. More...
 
typedef ImageContainerBySTLVector< Domain, GrayScaleGrayScaleImage
 defines a grey-level image with (hyper-)rectangular domain. More...
 
typedef ImageContainerBySTLVector< Domain, float > FloatImage
 defines a float image with (hyper-)rectangular domain. More...
 
typedef ImageContainerBySTLVector< Domain, double > DoubleImage
 defines a double image with (hyper-)rectangular domain. More...
 
typedef KSpace::SurfelSet SurfelSet
 defines a set of surfels More...
 
typedef LightImplicitDigitalSurface< KSpace, BinaryImageLightSurfaceContainer
 
typedef ::DGtal::DigitalSurface< LightSurfaceContainerLightDigitalSurface
 defines a connected digital surface over a binary image. More...
 
typedef SetOfSurfels< KSpace, SurfelSetExplicitSurfaceContainer
 defines a heavy container that represents any digital surface. More...
 
typedef ::DGtal::DigitalSurface< ExplicitSurfaceContainerDigitalSurface
 defines an arbitrary digital surface over a binary image. More...
 
typedef IndexedDigitalSurface< ExplicitSurfaceContainerIdxDigitalSurface
 defines a connected or not indexed digital surface. More...
 
typedef LightDigitalSurface::Surfel Surfel
 
typedef LightDigitalSurface::Cell Cell
 
typedef LightDigitalSurface::SCell SCell
 
typedef LightDigitalSurface::Vertex Vertex
 
typedef LightDigitalSurface::Arc Arc
 
typedef LightDigitalSurface::Face Face
 
typedef LightDigitalSurface::ArcRange ArcRange
 
typedef IdxDigitalSurface::Vertex IdxSurfel
 
typedef IdxDigitalSurface::Vertex IdxVertex
 
typedef IdxDigitalSurface::Arc IdxArc
 
typedef IdxDigitalSurface::ArcRange IdxArcRange
 
typedef std::set< IdxSurfelIdxSurfelSet
 
typedef std::vector< SCellSCellRange
 
typedef std::vector< CellCellRange
 
typedef CellRange PointelRange
 
typedef SCellRange SurfelRange
 
typedef std::vector< IdxSurfelIdxSurfelRange
 
typedef std::vector< ScalarScalars
 
typedef std::vector< RealVectorRealVectors
 
typedef std::vector< RealPointRealPoints
 
typedef IdxVertex Idx
 
typedef std::vector< IdxVertexIdxRange
 
typedef ::DGtal::Mesh< RealPointMesh
 
typedef ::DGtal::TriangulatedSurface< RealPointTriangulatedSurface
 
typedef ::DGtal::PolygonalSurface< RealPointPolygonalSurface
 
typedef ::DGtal::SurfaceMesh< RealPoint, RealPointSurfaceMesh
 
typedef std::map< Surfel, IdxSurfelSurfel2Index
 
typedef std::map< Cell, IdxVertexCell2Index
 
typedef ::DGtal::Color Color
 
typedef std::vector< ColorColors
 
typedef GradientColorMap< ScalarColorMap
 
typedef TickedColorMap< Scalar, ColorMapZeroTickedColorMap
 

Public Member Functions

 Shortcuts ()=delete
 
 ~Shortcuts ()=delete
 
 Shortcuts (const Shortcuts &other)=delete
 
 Shortcuts (Shortcuts &&other)=delete
 
Shortcutsoperator= (const Shortcuts &other)=delete
 
Shortcutsoperator= (Shortcuts &&other)=delete
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Static Public Member Functions

static Parameters defaultParameters ()
 
static std::map< std::string, std::string > getPolynomialList ()
 
static Parameters parametersImplicitShape3D ()
 
static CountedPtr< ImplicitShape3DmakeImplicitShape3D (const Parameters &params=parametersImplicitShape3D())
 
static Parameters parametersKSpace ()
 
static KSpace getKSpace (const Point &low, const Point &up, Parameters params=parametersKSpace())
 
static KSpace getKSpace (CountedPtr< BinaryImage > bimage, Parameters params=parametersKSpace())
 
static KSpace getKSpace (CountedPtr< GrayScaleImage > gimage, Parameters params=parametersKSpace())
 
template<typename TDigitalSurfaceContainer >
static KSpace getKSpace (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static KSpace getKSpace (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static const KSpacerefKSpace (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static const KSpacerefKSpace (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
static CanonicCellEmbedder< KSpacegetCellEmbedder (const KSpace &K)
 
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (const KSpace &K)
 
static Parameters parametersDigitizedImplicitShape3D ()
 
static KSpace getKSpace (Parameters params=parametersKSpace()|parametersDigitizedImplicitShape3D())
 
static CountedPtr< DigitizedImplicitShape3DmakeDigitizedImplicitShape3D (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static Parameters parametersBinaryImage ()
 
static CountedPtr< BinaryImagemakeBinaryImage (Domain shapeDomain)
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< DigitizedImplicitShape3D > shape_digitization, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< DigitizedImplicitShape3D > shape_digitization, Domain shapeDomain, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< BinaryImage > bimage, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (std::string input, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< GrayScaleImage > gray_scale_image, Parameters params=parametersBinaryImage())
 
static bool saveBinaryImage (CountedPtr< BinaryImage > bimage, std::string output)
 
static Parameters parametersGrayScaleImage ()
 
static CountedPtr< GrayScaleImagemakeGrayScaleImage (Domain aDomain)
 
static CountedPtr< GrayScaleImagemakeGrayScaleImage (std::string input)
 
static CountedPtr< GrayScaleImagemakeGrayScaleImage (CountedPtr< BinaryImage > binary_image, std::function< GrayScale(bool) > const &bool2grayscale=[](bool v) { return v ?(unsigned char) 255 :(unsigned char) 0;})
 
static bool saveGrayScaleImage (CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
 
static CountedPtr< GrayScaleImagemakeGrayScaleImage (CountedPtr< FloatImage > fimage, Parameters params=parametersGrayScaleImage())
 
static CountedPtr< GrayScaleImagemakeGrayScaleImage (CountedPtr< DoubleImage > fimage, Parameters params=parametersGrayScaleImage())
 
static CountedPtr< FloatImagemakeFloatImage (Domain aDomain)
 
static CountedPtr< FloatImagemakeFloatImage (std::string input)
 
static CountedPtr< FloatImagemakeFloatImage (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static CountedPtr< DoubleImagemakeDoubleImage (Domain aDomain)
 
static CountedPtr< DoubleImagemakeDoubleImage (std::string input)
 
static CountedPtr< DoubleImagemakeDoubleImage (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static Parameters parametersDigitalSurface ()
 
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder< KSpacegetCellEmbedder (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder< KSpacegetCellEmbedder (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
static CountedPtr< LightDigitalSurfacemakeLightDigitalSurface (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces (SurfelRange &surfel_reps, CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
template<typename TPointPredicate >
static CountedPtr< DigitalSurfacemakeDigitalSurface (CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< DigitalSurfacemakeDigitalSurface (CountedPtr< IdxDigitalSurface > idx_surface, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
template<typename TSurfelRange >
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (const TSurfelRange &surfels, ConstAlias< KSpace > K, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (const std::vector< CountedPtr< LightDigitalSurface > > &surfaces, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static CellRange getCellRange (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getCellRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getPointelRange (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getPointelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
static PointelRange getPointelRange (const KSpace &K, const SCell &surfel)
 
template<typename TDigitalSurfaceContainer >
static SurfelRange getSurfelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static SurfelRange getSurfelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Surfel &start_surfel, const Parameters &params=parametersDigitalSurface())
 
static IdxSurfelRange getIdxSurfelRange (CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
 
static IdxSurfelRange getIdxSurfelRange (CountedPtr< IdxDigitalSurface > surface, const IdxSurfel &start_surfel, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool saveOFF (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TDigitalSurfaceContainer >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TDigitalSurfaceContainer >
static bool saveOFF (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string off_file, const Color &face_color=Color(32, 32, 32))
 
template<typename TDigitalSurfaceContainer >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
static bool saveVectorFieldOBJ (const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
static Parameters parametersMesh ()
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< Mesh > aMesh)
 
static CountedPtr< MeshmakeMesh (CountedPtr< TriangulatedSurface > triSurf, const Color &aColor=Color::White)
 
static CountedPtr< MeshmakeMesh (CountedPtr< PolygonalSurface > polySurf, const Color &aColor=Color::White)
 
template<typename TContainer >
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< PolygonalSurface > polySurf, const Parameters &params=parametersMesh())
 
static CountedPtr< PolygonalSurfacemakePolygonalSurface (CountedPtr< Mesh > aMesh)
 
static CountedPtr< PolygonalSurfacemakePolygonalSurface (CountedPtr< GrayScaleImage > gray_scale_image, const Parameters &params=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< GrayScaleImage > gray_scale_image, const Parameters &params=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const std::string &objfile)
 
template<typename TPoint >
static bool saveOFF (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, std::string off_file, const Color &face_color=DGtal::Color::None)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const std::string &objfile)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TPoint >
static bool saveOFF (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, std::string off_file, const Color &face_color=DGtal::Color::None)
 
static Parameters parametersUtilities ()
 
template<typename TValue >
static IdxRange getRangeMatch (const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
 
template<typename TValue >
static std::vector< TValue > getMatchedRange (const std::vector< TValue > &range, const IdxRange &match)
 
static ColorMap getColorMap (Scalar min, Scalar max, const Parameters &params=parametersUtilities())
 
static ZeroTickedColorMap getZeroTickedColorMap (Scalar min, Scalar max, const Parameters &params=parametersUtilities())
 
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputSurfelsAsObj (std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
 
template<typename TAnyDigitalSurface >
static bool outputPrimalDigitalSurfaceAsObj (std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
 
template<typename TAnyDigitalSurface , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputPrimalDigitalSurfaceAsObj (std::ostream &output, CountedPtr< TAnyDigitalSurface > surface, const TCellEmbedder &embedder)
 
static bool outputPrimalIdxDigitalSurfaceAsObj (std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
 
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputPrimalIdxDigitalSurfaceAsObj (std::ostream &output, CountedPtr< IdxDigitalSurface > surface, const TCellEmbedder &embedder)
 
template<typename TDigitalSurfaceContainer >
static bool outputDualDigitalSurfaceAsObj (std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersMesh())
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputDualDigitalSurfaceAsObj (std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const TCellEmbedder &embedder, const Parameters &params=parametersMesh())
 
template<typename TSCellMap , typename TValueWriter >
static bool outputSCellMapAsCSV (std::ostream &output, const KSpace &K, const TSCellMap &anyMap, const TValueWriter &writer)
 
template<typename TCellMap , typename TValueWriter >
static bool outputCellMapAsCSV (std::ostream &output, const KSpace &K, const TCellMap &anyMap, const TValueWriter &writer)
 
static CellRange getPrimalCells (const KSpace &K, const SCell &s, const Dimension k)
 
static CellRange getPrimalVertices (const KSpace &K, const SCell &s)
 
static CellRange getPrimalVertices (const KSpace &K, const Surfel &s, bool ccw)
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CCellularGridSpaceND< TKSpace >))
 

Detailed Description

template<typename TKSpace>
class DGtal::Shortcuts< TKSpace >

Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes and surface with few lines of code. The drawback is that you use specific types or objects, which could lead to faster code or more compact data structures.

Description of template class 'Shortcuts'

Template Parameters
TKSpaceany cellular grid space, a model of concepts::CCellularGridSpaceND like KhalimskySpaceND.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityCollapsiblePoints2D.cpp, geometry/volumes/fullConvexityLUT2D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 104 of file Shortcuts.h.

Member Typedef Documentation

◆ Arc

template<typename TKSpace >
typedef LightDigitalSurface::Arc DGtal::Shortcuts< TKSpace >::Arc

Definition at line 165 of file Shortcuts.h.

◆ ArcRange

template<typename TKSpace >
typedef LightDigitalSurface::ArcRange DGtal::Shortcuts< TKSpace >::ArcRange

Definition at line 167 of file Shortcuts.h.

◆ BinaryImage

template<typename TKSpace >
typedef ImageContainerBySTLVector<Domain, bool> DGtal::Shortcuts< TKSpace >::BinaryImage

defines a black and white image with (hyper-)rectangular domain.

Definition at line 141 of file Shortcuts.h.

◆ Cell

template<typename TKSpace >
typedef LightDigitalSurface::Cell DGtal::Shortcuts< TKSpace >::Cell

Definition at line 162 of file Shortcuts.h.

◆ Cell2Index

template<typename TKSpace >
typedef std::map<Cell, IdxVertex> DGtal::Shortcuts< TKSpace >::Cell2Index

Definition at line 189 of file Shortcuts.h.

◆ CellRange

template<typename TKSpace >
typedef std::vector< Cell > DGtal::Shortcuts< TKSpace >::CellRange

Definition at line 174 of file Shortcuts.h.

◆ Color

template<typename TKSpace >
typedef ::DGtal::Color DGtal::Shortcuts< TKSpace >::Color

Definition at line 191 of file Shortcuts.h.

◆ ColorMap

template<typename TKSpace >
typedef GradientColorMap<Scalar> DGtal::Shortcuts< TKSpace >::ColorMap

Definition at line 193 of file Shortcuts.h.

◆ Colors

template<typename TKSpace >
typedef std::vector< Color > DGtal::Shortcuts< TKSpace >::Colors

Definition at line 192 of file Shortcuts.h.

◆ DigitalSurface

template<typename TKSpace >
typedef ::DGtal::DigitalSurface< ExplicitSurfaceContainer > DGtal::Shortcuts< TKSpace >::DigitalSurface

defines an arbitrary digital surface over a binary image.

Definition at line 158 of file Shortcuts.h.

◆ DigitizedImplicitShape3D

template<typename TKSpace >
typedef GaussDigitizer< Space, ImplicitShape3D > DGtal::Shortcuts< TKSpace >::DigitizedImplicitShape3D

defines the digitization of an implicit shape.

Definition at line 139 of file Shortcuts.h.

◆ Domain

template<typename TKSpace >
typedef HyperRectDomain<Space> DGtal::Shortcuts< TKSpace >::Domain

An (hyper-)rectangular domain.

Definition at line 127 of file Shortcuts.h.

◆ DoubleImage

template<typename TKSpace >
typedef ImageContainerBySTLVector<Domain, double> DGtal::Shortcuts< TKSpace >::DoubleImage

defines a double image with (hyper-)rectangular domain.

Definition at line 147 of file Shortcuts.h.

◆ ExplicitSurfaceContainer

template<typename TKSpace >
typedef SetOfSurfels< KSpace, SurfelSet > DGtal::Shortcuts< TKSpace >::ExplicitSurfaceContainer

defines a heavy container that represents any digital surface.

Definition at line 156 of file Shortcuts.h.

◆ Face

template<typename TKSpace >
typedef LightDigitalSurface::Face DGtal::Shortcuts< TKSpace >::Face

Definition at line 166 of file Shortcuts.h.

◆ FloatImage

template<typename TKSpace >
typedef ImageContainerBySTLVector<Domain, float> DGtal::Shortcuts< TKSpace >::FloatImage

defines a float image with (hyper-)rectangular domain.

Definition at line 145 of file Shortcuts.h.

◆ GrayScale

template<typename TKSpace >
typedef unsigned char DGtal::Shortcuts< TKSpace >::GrayScale

The type for 8-bits gray-scale elements.

Definition at line 129 of file Shortcuts.h.

◆ GrayScaleImage

template<typename TKSpace >
typedef ImageContainerBySTLVector<Domain, GrayScale> DGtal::Shortcuts< TKSpace >::GrayScaleImage

defines a grey-level image with (hyper-)rectangular domain.

Definition at line 143 of file Shortcuts.h.

◆ Idx

template<typename TKSpace >
typedef IdxVertex DGtal::Shortcuts< TKSpace >::Idx

Definition at line 181 of file Shortcuts.h.

◆ IdxArc

template<typename TKSpace >
typedef IdxDigitalSurface::Arc DGtal::Shortcuts< TKSpace >::IdxArc

Definition at line 170 of file Shortcuts.h.

◆ IdxArcRange

template<typename TKSpace >
typedef IdxDigitalSurface::ArcRange DGtal::Shortcuts< TKSpace >::IdxArcRange

Definition at line 171 of file Shortcuts.h.

◆ IdxDigitalSurface

template<typename TKSpace >
typedef IndexedDigitalSurface< ExplicitSurfaceContainer > DGtal::Shortcuts< TKSpace >::IdxDigitalSurface

defines a connected or not indexed digital surface.

Definition at line 160 of file Shortcuts.h.

◆ IdxRange

template<typename TKSpace >
typedef std::vector< IdxVertex > DGtal::Shortcuts< TKSpace >::IdxRange

Definition at line 182 of file Shortcuts.h.

◆ IdxSurfel

template<typename TKSpace >
typedef IdxDigitalSurface::Vertex DGtal::Shortcuts< TKSpace >::IdxSurfel

Definition at line 168 of file Shortcuts.h.

◆ IdxSurfelRange

template<typename TKSpace >
typedef std::vector< IdxSurfel > DGtal::Shortcuts< TKSpace >::IdxSurfelRange

Definition at line 177 of file Shortcuts.h.

◆ IdxSurfelSet

template<typename TKSpace >
typedef std::set< IdxSurfel > DGtal::Shortcuts< TKSpace >::IdxSurfelSet

Definition at line 172 of file Shortcuts.h.

◆ IdxVertex

template<typename TKSpace >
typedef IdxDigitalSurface::Vertex DGtal::Shortcuts< TKSpace >::IdxVertex

Definition at line 169 of file Shortcuts.h.

◆ ImplicitShape3D

template<typename TKSpace >
typedef ImplicitPolynomial3Shape<Space> DGtal::Shortcuts< TKSpace >::ImplicitShape3D

defines an implicit shape of the space, which is the zero-level set of a ScalarPolynomial.

Definition at line 137 of file Shortcuts.h.

◆ Integer

template<typename TKSpace >
typedef Space::Integer DGtal::Shortcuts< TKSpace >::Integer

Integer numbers.

Definition at line 115 of file Shortcuts.h.

◆ KSpace

template<typename TKSpace >
typedef TKSpace DGtal::Shortcuts< TKSpace >::KSpace

Digital cellular space.

Definition at line 111 of file Shortcuts.h.

◆ LightDigitalSurface

template<typename TKSpace >
typedef ::DGtal::DigitalSurface< LightSurfaceContainer > DGtal::Shortcuts< TKSpace >::LightDigitalSurface

defines a connected digital surface over a binary image.

Definition at line 154 of file Shortcuts.h.

◆ LightSurfaceContainer

template<typename TKSpace >
typedef LightImplicitDigitalSurface< KSpace, BinaryImage > DGtal::Shortcuts< TKSpace >::LightSurfaceContainer

defines a light container that represents a connected digital surface over a binary image.

Definition at line 152 of file Shortcuts.h.

◆ Mesh

template<typename TKSpace >
typedef ::DGtal::Mesh<RealPoint> DGtal::Shortcuts< TKSpace >::Mesh

Definition at line 184 of file Shortcuts.h.

◆ Point

template<typename TKSpace >
typedef Space::Point DGtal::Shortcuts< TKSpace >::Point

Point with integer coordinates.

Definition at line 117 of file Shortcuts.h.

◆ PointelRange

template<typename TKSpace >
typedef CellRange DGtal::Shortcuts< TKSpace >::PointelRange

Definition at line 175 of file Shortcuts.h.

◆ PolygonalSurface

template<typename TKSpace >
typedef ::DGtal::PolygonalSurface<RealPoint> DGtal::Shortcuts< TKSpace >::PolygonalSurface

Definition at line 186 of file Shortcuts.h.

◆ RealPoint

template<typename TKSpace >
typedef Space::RealPoint DGtal::Shortcuts< TKSpace >::RealPoint

Point with floating-point coordinates.

Definition at line 123 of file Shortcuts.h.

◆ RealPoints

template<typename TKSpace >
typedef std::vector< RealPoint > DGtal::Shortcuts< TKSpace >::RealPoints

Definition at line 180 of file Shortcuts.h.

◆ RealVector

template<typename TKSpace >
typedef Space::RealVector DGtal::Shortcuts< TKSpace >::RealVector

Vector with floating-point coordinates.

Definition at line 121 of file Shortcuts.h.

◆ RealVectors

template<typename TKSpace >
typedef std::vector< RealVector > DGtal::Shortcuts< TKSpace >::RealVectors

Definition at line 179 of file Shortcuts.h.

◆ Scalar

template<typename TKSpace >
typedef RealVector::Component DGtal::Shortcuts< TKSpace >::Scalar

Floating-point numbers.

Definition at line 125 of file Shortcuts.h.

◆ ScalarPolynomial

template<typename TKSpace >
typedef MPolynomial< Space::dimension, Scalar > DGtal::Shortcuts< TKSpace >::ScalarPolynomial

defines a multi-variate polynomial : RealPoint -> Scalar

Definition at line 134 of file Shortcuts.h.

◆ Scalars

template<typename TKSpace >
typedef std::vector< Scalar > DGtal::Shortcuts< TKSpace >::Scalars

Definition at line 178 of file Shortcuts.h.

◆ SCell

template<typename TKSpace >
typedef LightDigitalSurface::SCell DGtal::Shortcuts< TKSpace >::SCell

Definition at line 163 of file Shortcuts.h.

◆ SCellRange

template<typename TKSpace >
typedef std::vector< SCell > DGtal::Shortcuts< TKSpace >::SCellRange

Definition at line 173 of file Shortcuts.h.

◆ Space

template<typename TKSpace >
typedef KSpace::Space DGtal::Shortcuts< TKSpace >::Space

Digital space.

Definition at line 113 of file Shortcuts.h.

◆ SurfaceMesh

template<typename TKSpace >
typedef ::DGtal::SurfaceMesh<RealPoint,RealPoint> DGtal::Shortcuts< TKSpace >::SurfaceMesh

Definition at line 187 of file Shortcuts.h.

◆ Surfel

template<typename TKSpace >
typedef LightDigitalSurface::Surfel DGtal::Shortcuts< TKSpace >::Surfel

Definition at line 161 of file Shortcuts.h.

◆ Surfel2Index

template<typename TKSpace >
typedef std::map<Surfel, IdxSurfel> DGtal::Shortcuts< TKSpace >::Surfel2Index

Definition at line 188 of file Shortcuts.h.

◆ SurfelRange

template<typename TKSpace >
typedef SCellRange DGtal::Shortcuts< TKSpace >::SurfelRange

Definition at line 176 of file Shortcuts.h.

◆ SurfelSet

template<typename TKSpace >
typedef KSpace::SurfelSet DGtal::Shortcuts< TKSpace >::SurfelSet

defines a set of surfels

Definition at line 149 of file Shortcuts.h.

◆ TriangulatedSurface

template<typename TKSpace >
typedef ::DGtal::TriangulatedSurface<RealPoint> DGtal::Shortcuts< TKSpace >::TriangulatedSurface

Definition at line 185 of file Shortcuts.h.

◆ Vector

template<typename TKSpace >
typedef Space::Vector DGtal::Shortcuts< TKSpace >::Vector

Vector with integer coordinates.

Definition at line 119 of file Shortcuts.h.

◆ Vertex

template<typename TKSpace >
typedef LightDigitalSurface::Vertex DGtal::Shortcuts< TKSpace >::Vertex

Definition at line 164 of file Shortcuts.h.

◆ ZeroTickedColorMap

template<typename TKSpace >
typedef TickedColorMap<Scalar,ColorMap> DGtal::Shortcuts< TKSpace >::ZeroTickedColorMap

Definition at line 194 of file Shortcuts.h.

Constructor & Destructor Documentation

◆ Shortcuts() [1/3]

template<typename TKSpace >
DGtal::Shortcuts< TKSpace >::Shortcuts ( )
delete

Default constructor.

◆ ~Shortcuts()

template<typename TKSpace >
DGtal::Shortcuts< TKSpace >::~Shortcuts ( )
delete

Destructor.

◆ Shortcuts() [2/3]

template<typename TKSpace >
DGtal::Shortcuts< TKSpace >::Shortcuts ( const Shortcuts< TKSpace > &  other)
delete

Copy constructor.

Parameters
otherthe object to clone.

◆ Shortcuts() [3/3]

template<typename TKSpace >
DGtal::Shortcuts< TKSpace >::Shortcuts ( Shortcuts< TKSpace > &&  other)
delete

Move constructor.

Parameters
otherthe object to move.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TKSpace >
DGtal::Shortcuts< TKSpace >::BOOST_CONCEPT_ASSERT ( (concepts::CCellularGridSpaceND< TKSpace >)  )
private

◆ defaultParameters()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::defaultParameters ( )
inlinestatic

◆ getCellEmbedder() [1/3]

template<typename TKSpace >
static CanonicCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getCellEmbedder ( const KSpace K)
inlinestatic

◆ getCellEmbedder() [2/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getCellEmbedder ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
the canonic cell embedder associated to the given digital surface.

Definition at line 1011 of file Shortcuts.h.

1012  {
1013  return getCellEmbedder( refKSpace( surface ) );
1014  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder(), and DGtal::Shortcuts< TKSpace >::refKSpace().

◆ getCellEmbedder() [3/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getCellEmbedder ( CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on any indexed digital surface.
Returns
the canonic cell embedder associated to the given indexed digital surface.

Definition at line 1033 of file Shortcuts.h.

1034  {
1035  return getCellEmbedder( refKSpace( surface ) );
1036  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder(), and DGtal::Shortcuts< TKSpace >::refKSpace().

◆ getCellRange() [1/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CellRange DGtal::Shortcuts< TKSpace >::getCellRange ( Cell2Index c2i,
CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Dimension  k 
)
inlinestatic

Given any digital surface, returns the vector of its k-dimensional cells.

Note
The order of cells is given by the default traversal of the surfels of the surface, where the cells of each surfel are visited in no specific order.
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[out]c2ithe map Cell -> Cell index in the cell range.
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
[in]kthe dimension of the output cells
Returns
a range of cells as a vector.

Definition at line 1399 of file Shortcuts.h.

1402  {
1403  CellRange result;
1404  // Approximate number of pointels given the number of 2-cells (valid for 2d surfaces in nD).
1405  result.reserve( 2 * surface->size() + 100 );
1406  const KSpace& K = refKSpace( surface );
1407  Idx n = 0;
1408  for ( auto&& surfel : *surface )
1409  {
1410  CellRange primal_cells = getPrimalCells( K, surfel, k );
1411  for ( auto&& primal_cell : primal_cells )
1412  {
1413  if ( ! c2i.count( primal_cell ) )
1414  {
1415  result.push_back( primal_cell );
1416  c2i[ primal_cell ] = n++;
1417  }
1418  }
1419  }
1420  return result;
1421  }

References DGtal::Shortcuts< TKSpace >::getPrimalCells(), K, and DGtal::Shortcuts< TKSpace >::refKSpace().

Referenced by DGtal::Shortcuts< TKSpace >::getCellRange(), and main().

◆ getCellRange() [2/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static PointelRange DGtal::Shortcuts< TKSpace >::getCellRange ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Dimension  k 
)
inlinestatic

Given any digital surface, returns the vector of its k-dimensional cells.

Note
The order of cells is given by the default traversal of the surfels of the surface, where the cells of each surfel are visited in no specific order.
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
[in]kthe dimension of the output cells
Returns
a range of cells as a vector.

Definition at line 1438 of file Shortcuts.h.

1441  {
1442  Cell2Index c2i;
1443  return getCellRange( c2i, surface, k );
1444  }

References DGtal::Shortcuts< TKSpace >::getCellRange().

◆ getColorMap()

template<typename TKSpace >
static ColorMap DGtal::Shortcuts< TKSpace >::getColorMap ( Scalar  min,
Scalar  max,
const Parameters params = parametersUtilities() 
)
inlinestatic
Parameters
[in]minthe minimum considered value for the colormap.
[in]maxthe maximum considered value for the colormap.
[in]paramsthe parameters:
  • colormap [ "Custom" ]: "Cool"|"Copper"|"Hot"|"Jet"|"Spring"|"Summer"|"Autumn"|"Winter"|"Error"|"Custom" specifies standard colormaps (if invalid, falls back to "Custom").
Returns
a colormap according to the specified parameters

Definition at line 2668 of file Shortcuts.h.

2671  {
2672  std::string cmap = params[ "colormap" ].as<std::string>();
2673  if ( cmap == "Cool" ) return ColorMap( min, max, CMAP_COOL );
2674  else if ( cmap == "Copper" ) return ColorMap( min, max, CMAP_COPPER );
2675  else if ( cmap == "Hot" ) return ColorMap( min, max, CMAP_HOT );
2676  else if ( cmap == "Jet" ) return ColorMap( min, max, CMAP_JET );
2677  else if ( cmap == "Spring" ) return ColorMap( min, max, CMAP_SPRING );
2678  else if ( cmap == "Summer" ) return ColorMap( min, max, CMAP_SUMMER );
2679  else if ( cmap == "Autumn" ) return ColorMap( min, max, CMAP_AUTUMN );
2680  else if ( cmap == "Winter" ) return ColorMap( min, max, CMAP_WINTER );
2681  else if ( cmap == "Error" )
2682  {
2683  ColorMap gradcmap( min, max );
2684  gradcmap.addColor( Color( 255, 255, 255 ) );
2685  gradcmap.addColor( Color( 255, 0, 0 ) );
2686  gradcmap.addColor( Color( 0, 0, 0 ) );
2687  return gradcmap;
2688  }
2689  // Custom colormap
2690  ColorMap gradcmap( min, max );
2691  gradcmap.addColor( Color( 0, 0, 255 ) );
2692  gradcmap.addColor( Color( 0, 255, 255 ) );
2693  gradcmap.addColor( Color( 255, 255, 255 ) );
2694  gradcmap.addColor( Color( 255, 255, 0 ) );
2695  gradcmap.addColor( Color( 255, 0, 0 ) );
2696  return gradcmap;
2697  }

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::CMAP_AUTUMN, DGtal::CMAP_COOL, DGtal::CMAP_COPPER, DGtal::CMAP_HOT, DGtal::CMAP_JET, DGtal::CMAP_SPRING, DGtal::CMAP_SUMMER, DGtal::CMAP_WINTER, and max().

Referenced by DGtal::Shortcuts< TKSpace >::getZeroTickedColorMap(), and main().

◆ getIdxSurfelRange() [1/2]

template<typename TKSpace >
static IdxSurfelRange DGtal::Shortcuts< TKSpace >::getIdxSurfelRange ( CountedPtr< IdxDigitalSurface surface,
const IdxSurfel start_surfel,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Given an indexed digital surface, returns a vector of surfels in some specified order.

Parameters
[in]surfacea smart pointer on a digital surface.
[in]start_surfelthe surfel where the traversal starts in case of depth-first/breadth-first traversal.
[in]paramsthe parameters:
  • surfaceTraversal ["Default"]: "Default"|"DepthFirst"|"BreadthFirst": "Default" default surface traversal, "DepthFirst": depth-first surface traversal, "BreadthFirst": breadth-first surface traversal.
Returns
a range of indexed surfels as a vector.

Definition at line 1632 of file Shortcuts.h.

1635  {
1636  IdxSurfelRange result;
1637  std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1638  if ( traversal == "DepthFirst" )
1639  {
1640  typedef DepthFirstVisitor< IdxDigitalSurface > Visitor;
1641  typedef GraphVisitorRange< Visitor > VisitorRange;
1642  VisitorRange range( new Visitor( *surface, start_surfel ) );
1643  std::for_each( range.begin(), range.end(),
1644  [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1645  }
1646  else if ( traversal == "BreadthFirst" )
1647  {
1648  typedef BreadthFirstVisitor< IdxDigitalSurface > Visitor;
1649  typedef GraphVisitorRange< Visitor > VisitorRange;
1650  VisitorRange range( new Visitor( *surface, start_surfel ) );
1651  std::for_each( range.begin(), range.end(),
1652  [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1653  }
1654  else return surface->allVertices();
1655  return result;
1656  }

References DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer >::allVertices().

◆ getIdxSurfelRange() [2/2]

template<typename TKSpace >
static IdxSurfelRange DGtal::Shortcuts< TKSpace >::getIdxSurfelRange ( CountedPtr< IdxDigitalSurface surface,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Given an indexed digital surface, returns a vector of surfels in some specified order.

Parameters
[in]surfacea smart pointer on a digital surface.
[in]paramsthe parameters:
  • surfaceTraversal ["Default"]: "Default"|"DepthFirst"|"BreadthFirst": "Default" default surface traversal, "DepthFirst": depth-first surface traversal, "BreadthFirst": breadth-first surface traversal.
Returns
a range of indexed surfels as a vector.

Definition at line 1612 of file Shortcuts.h.

1614  {
1615  return getIdxSurfelRange( surface, (IdxSurfel) 0, params );
1616  }

Referenced by DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), and DGtal::Shortcuts< TKSpace >::outputPrimalIdxDigitalSurfaceAsObj().

◆ getKSpace() [1/6]

template<typename TKSpace >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( const Point low,
const Point up,
Parameters  params = parametersKSpace() 
)
inlinestatic

Builds a Khalimsky space that encompasses the lower and upper digital points. Note that digital points are cells of the Khalimsky space with maximal dimensions. A closed Khalimsky space adds lower dimensional cells all around its boundary to define a closed complex.

Parameters
[in]lowthe lowest point in the space
[in]upthe highest point in the space
[in]paramsthe parameters:
  • closed [1]: specifies if the Khalimsky space is closed (!=0) or not (==0).
Returns
the Khalimsky space.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 332 of file Shortcuts.h.

334  {
335  int closed = params[ "closed" ].as<int>();
336  KSpace K;
337  if ( ! K.init( low, up, closed ) )
338  trace.error() << "[Shortcuts::getKSpace]"
339  << " Error building Khalimsky space K=" << K << std::endl;
340  return K;
341  }

References DGtal::Trace::error(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, and DGtal::trace.

Referenced by DGtal::DigitalSurfaceRegularization< TDigitalSurface >::DigitalSurfaceRegularization(), DGtal::ShortcutsGeometry< TKSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::ShortcutsGeometry< TKSpace >::getIIPrincipalCurvaturesAndDirections(), getSlice(), main(), DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), SCENARIO(), and TEST_CASE().

◆ getKSpace() [2/6]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
the Khalimsky space associated to the given surface.

Definition at line 397 of file Shortcuts.h.

398  {
399  return surface->container().space();
400  }

◆ getKSpace() [3/6]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on any indexed digital surface.
Returns
the Khalimsky space associated to the given surface.

Definition at line 408 of file Shortcuts.h.

409  {
410  return surface->container().space();
411  }

◆ getKSpace() [4/6]

template<typename TKSpace >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( CountedPtr< BinaryImage bimage,
Parameters  params = parametersKSpace() 
)
inlinestatic

Builds a Khalimsky space that encompasses the domain of the given image. Note that digital points are cells of the Khalimsky space with maximal dimensions. A closed Khalimsky space adds lower dimensional cells all around its boundary to define a closed complex.

Parameters
[in]bimageany binary image
[in]paramsthe parameters:
  • closed [1]: specifies if the Khalimsky space is closed (!=0) or not (==0).
Returns
the Khalimsky space.

Definition at line 354 of file Shortcuts.h.

356  {
357  int closed = params[ "closed" ].as<int>();
358  KSpace K;
359  if ( ! K.init( bimage->domain().lowerBound(),
360  bimage->domain().upperBound(),
361  closed ) )
362  trace.error() << "[Shortcuts::getKSpace]"
363  << " Error building Khalimsky space K=" << K << std::endl;
364  return K;
365  }

References DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), DGtal::Trace::error(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().

◆ getKSpace() [5/6]

template<typename TKSpace >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( CountedPtr< GrayScaleImage gimage,
Parameters  params = parametersKSpace() 
)
inlinestatic

Builds a Khalimsky space that encompasses the domain of the given image. Note that digital points are cells of the Khalimsky space with maximal dimensions. A closed Khalimsky space adds lower dimensional cells all around its boundary to define a closed complex.

Parameters
[in]gimageany gray-scale image
[in]paramsthe parameters:
  • closed [1]: specifies if the Khalimsky space is closed (!=0) or not (==0).
Returns
the Khalimsky space.

Definition at line 378 of file Shortcuts.h.

380  {
381  int closed = params[ "closed" ].as<int>();
382  KSpace K;
383  if ( ! K.init( gimage->domain().lowerBound(),
384  gimage->domain().upperBound(),
385  closed ) )
386  trace.error() << "[Shortcuts::getKSpace]"
387  << " Error building Khalimsky space K=" << K << std::endl;
388  return K;
389  }

References DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), DGtal::Trace::error(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().

◆ getKSpace() [6/6]

template<typename TKSpace >
static KSpace DGtal::Shortcuts< TKSpace >::getKSpace ( Parameters  params = parametersKSpace() | parametersDigitizedImplicitShape3D())
inlinestatic

Builds a Khalimsky space that encompasses the bounding box specified by a digitization in params. It is useful when digitizing an implicit shape.

Parameters
[in]paramsthe parameters:
  • minAABB [-10.0]: the min value of the AABB bounding box (domain)
  • maxAABB [ 10.0]: the max value of the AABB bounding box (domain)
  • gridstep [ 1.0]: the gridstep that defines the digitization (often called h).
  • offset [ 5.0]: the digital dilation of the digital space, useful when you process shapes and that you add noise.
  • closed [1] : specifies if the Khalimsky space is closed (!=0) or not (==0).
Returns
the Khalimsky space.
See also
makeDigitizedImplicitShape3D

Definition at line 486 of file Shortcuts.h.

488  {
489  Scalar min_x = params[ "minAABB" ].as<Scalar>();
490  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
491  Scalar h = params[ "gridstep" ].as<Scalar>();
492  Scalar offset = params[ "offset" ].as<Scalar>();
493  bool closed = params[ "closed" ].as<int>();
494  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
495  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
496  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
497  dshape->init( p1, p2, h );
498  Domain domain = dshape->getDomain();
499  KSpace K;
500  if ( ! K.init( domain.lowerBound(), domain.upperBound(), closed ) )
501  trace.error() << "[Shortcuts::getKSpace]"
502  << " Error building Khalimsky space K=" << K << std::endl
503  << "Note: if you use decimal values, check your locale for decimal point '.' or ','."
504  << std::endl;
505  return K;
506  }

References domain, DGtal::Trace::error(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().

◆ getMatchedRange()

template<typename TKSpace >
template<typename TValue >
static std::vector< TValue > DGtal::Shortcuts< TKSpace >::getMatchedRange ( const std::vector< TValue > &  range,
const IdxRange match 
)
inlinestatic

Given a perfect or approximate match, returns the corresponding reordered/rematched range.

Parameters
[in]rangeany range.
[in]matcha function V: Idx -> Idx such that result[ i ] = range[ match[ i ] ].
Returns
the the corresponding reordered/rematched range.
See also
getRangeMatch

Definition at line 2653 of file Shortcuts.h.

2654  {
2655  std::vector< TValue > result( match.size() );
2656  for ( Idx i = 0; i < result.size(); i++ )
2657  result[ i ] = range[ match[ i ] ];
2658  return result;
2659  }

Referenced by main().

◆ getPointelRange() [1/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static PointelRange DGtal::Shortcuts< TKSpace >::getPointelRange ( Cell2Index c2i,
CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface 
)
inlinestatic

Given any digital surface, returns the vector of its pointels.

Note
The order of pointels is given by the default traversal of the surfels of the surface, where the 4 pointels of each surfel are visited in order.
Since
1.1 The pointel ordering is now the same as the one given by makePrimalPolygonalSurface (for 3D only of course).
Note
If you wish to consider the primal digital surface, and visits pointels as vertices of this graph in breadth-first/depth-first order, the best is to build first a PolygonalSurface and then use specialized visitors.
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[out]c2ithe map Cell -> Vertex index in the pointel range.
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
a range of pointels as a vector.

Definition at line 1469 of file Shortcuts.h.

1471  {
1472  PointelRange result;
1473  result.reserve( surface->size() );
1474  const KSpace& K = refKSpace( surface );
1475  Idx n = 0;
1476  for ( auto&& surfel : *surface )
1477  {
1478  CellRange primal_vtcs = getPointelRange( K, surfel );
1479  for ( auto&& primal_vtx : primal_vtcs )
1480  {
1481  if ( ! c2i.count( primal_vtx ) )
1482  {
1483  result.push_back( primal_vtx );
1484  c2i[ primal_vtx ] = n++;
1485  }
1486  }
1487  }
1488  return result;
1489  }

References K, and DGtal::Shortcuts< TKSpace >::refKSpace().

Referenced by DGtal::Shortcuts< TKSpace >::getPointelRange(), main(), DGtal::Shortcuts< TKSpace >::outputSurfelsAsObj(), DGtal::Shortcuts< TKSpace >::saveOBJ(), DGtal::Shortcuts< TKSpace >::saveOFF(), and SCENARIO().

◆ getPointelRange() [2/3]

template<typename TKSpace >
static PointelRange DGtal::Shortcuts< TKSpace >::getPointelRange ( const KSpace K,
const SCell surfel 
)
inlinestatic

Given any surfel, returns its 4 pointels in ccw order.

See also
getPrimalVertices
Parameters
[in]Kthe Khalimsky space
[in]surfelany surfel that lives in the Khalimsky space
Returns
a range of pointels as a vector.

Definition at line 1526 of file Shortcuts.h.

1527  {
1528  return KSpace::dimension == 3
1529  ? getPrimalVertices( K, surfel, true )
1530  : getPrimalVertices( K, surfel );
1531  }

References DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::Shortcuts< TKSpace >::getPrimalVertices(), and K.

◆ getPointelRange() [3/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static PointelRange DGtal::Shortcuts< TKSpace >::getPointelRange ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic

Given any digital surface, returns the vector of its pointels.

Note
The order of pointels is given by the default traversal of the surfels of the surface, where the 4 pointels of each surfel are visited in order.
If you wish to consider the primal digital surface, and visits pointels as vertices of this graph in breadth-first/depth-first order, the best is to build first a PolygonalSurface and then use specialized visitors.
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
a range of pointels as a vector.

Definition at line 1510 of file Shortcuts.h.

1511  {
1512  Cell2Index c2i;
1513  return getPointelRange( c2i, surface );
1514  }

References DGtal::Shortcuts< TKSpace >::getPointelRange().

◆ getPolynomialList()

template<typename TKSpace >
static std::map< std::string, std::string > DGtal::Shortcuts< TKSpace >::getPolynomialList ( )
inlinestatic

Returns a map associating a name and a polynomial, e.g. "sphere1", "x^2+y^2+z^2-1".

{ "sphere1", "x^2+y^2+z^2-1" }, { "sphere9", "x^2+y^2+z^2-81" }, { "ellipsoid", "3*x^2+2*y^2+z^2-90" }, { "cylinder", "x^2+2*z^2-90" }, { "torus", "(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" }, { "rcube", "x^4+y^4+z^4-6561" }, { "goursat", "-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" }, { "distel", "10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"}, { "leopold", "(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" }, { "diabolo", "x^2-(y^2+z^2)^2" }, { "heart", "-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" }, { "crixxi", "-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" }

Returns
the map associating a polynomial to a name.

Definition at line 236 of file Shortcuts.h.

237  {
238  std::vector< std::pair< std::string, std::string > >
239  Ps = { { "sphere1", "x^2+y^2+z^2-1" },
240  { "sphere9", "x^2+y^2+z^2-81" },
241  { "ellipsoid", "3*x^2+2*y^2+z^2-90" },
242  { "cylinder", "x^2+2*z^2-90" },
243  { "torus", "(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" },
244  { "rcube", "x^4+y^4+z^4-6561" },
245  { "goursat", "-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" },
246  { "goursat-hole", "x^4+y^4+z^4-2*4*(x^2+y^2+z^2)+2*4*4-2" },
247  { "distel", "10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"},
248  { "leopold", "(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" },
249  { "diabolo", "x^2-(y^2+z^2)^2" },
250  { "heart", "-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" },
251  { "crixxi", "-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" } };
252  std::map< std::string, std::string > L;
253  for ( auto p : Ps )
254  L[ p.first ] = p.second;
255  return L;
256  }

Referenced by DGtal::Shortcuts< TKSpace >::makeImplicitShape3D().

◆ getPrimalCells()

template<typename TKSpace >
static CellRange DGtal::Shortcuts< TKSpace >::getPrimalCells ( const KSpace K,
const SCell s,
const Dimension  k 
)
inlinestatic

Given a space K and an oriented cell s, returns its vertices.

Parameters
Kany cellular grid space.
sany signed cell.
kany dimension between 0 and K.sdim(s).
Returns
the vector of the faces of dimension k of s, as unsigned cells.

Definition at line 3164 of file Shortcuts.h.

3165  {
3166  auto faces = K.uFaces( K.unsigns( s ) );
3167  CellRange primal_cells;
3168  for ( auto&& f : faces )
3169  {
3170  if ( K.uDim( f ) == k ) primal_cells.push_back( f );
3171  }
3172  return primal_cells;
3173  }

References K, DGtal::KhalimskySpaceND< dim, TInteger >::uDim(), DGtal::KhalimskySpaceND< dim, TInteger >::uFaces(), and DGtal::KhalimskySpaceND< dim, TInteger >::unsigns().

Referenced by DGtal::Shortcuts< TKSpace >::getCellRange(), and DGtal::Shortcuts< TKSpace >::getPrimalVertices().

◆ getPrimalVertices() [1/2]

template<typename TKSpace >
static CellRange DGtal::Shortcuts< TKSpace >::getPrimalVertices ( const KSpace K,
const SCell s 
)
inlinestatic

Given a space K and an oriented cell s, returns its vertices.

Parameters
Kany cellular grid space.
sany signed cell.
Returns
the vector of the vertices of s, as unsigned cells of dimension 0.

Definition at line 3180 of file Shortcuts.h.

3181  {
3182  return getPrimalCells( K, s, 0 );
3183  }

References DGtal::Shortcuts< TKSpace >::getPrimalCells(), and K.

Referenced by centerSurfel(), DGtal::Shortcuts< TKSpace >::getPointelRange(), and DGtal::Shortcuts< TKSpace >::getPrimalVertices().

◆ getPrimalVertices() [2/2]

template<typename TKSpace >
static CellRange DGtal::Shortcuts< TKSpace >::getPrimalVertices ( const KSpace K,
const Surfel s,
bool  ccw 
)
inlinestatic

Given a space K and a surfel s, returns its vertices in ccw or cw order.

Parameters
Kany cellular grid space of dimension 3.
sany surfel, a signed cell of dimension 2.
ccwwhen 'true', the order corresponds to a ccw orientation seen from the exterior normal to the surfel, otherwise it is a cw order.
Returns
the vector of the vertices of s, as unsigned cells of dimension 0.
Note
useful when exporting faces to OBJ format.

Definition at line 3192 of file Shortcuts.h.

3193  {
3194  BOOST_STATIC_ASSERT(( KSpace::dimension == 3 ));
3195  CellRange vtcs = getPrimalVertices( K, s );
3196  std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3197  auto orth_dir = K.sOrthDir( s );
3198  auto direct = K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3199  Vector s0s1 = K.uCoords( vtcs[ 1 ] ) - K.uCoords( vtcs[ 0 ] );
3200  Vector s0s2 = K.uCoords( vtcs[ 2 ] ) - K.uCoords( vtcs[ 0 ] );
3201  Vector t = s0s1.crossProduct( s0s2 );
3202  if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3203  || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3204  std::reverse( vtcs.begin(), vtcs.end() );
3205  return vtcs;
3206  }

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::crossProduct(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::Shortcuts< TKSpace >::getPrimalVertices(), K, reverse(), DGtal::KhalimskySpaceND< dim, TInteger >::sDirect(), DGtal::KhalimskySpaceND< dim, TInteger >::sOrthDir(), and DGtal::KhalimskySpaceND< dim, TInteger >::uCoords().

◆ getRangeMatch()

template<typename TKSpace >
template<typename TValue >
static IdxRange DGtal::Shortcuts< TKSpace >::getRangeMatch ( const std::vector< TValue > &  s1,
const std::vector< TValue > &  s2,
bool  perfect = false 
)
inlinestatic

Given two ranges with same elements but not necessarily in the same order, returns a vector V: index -> index such that s1[ i ] == s2[ V[ i ] ].

Template Parameters
TValuea model of boost::Assignable, boost::CopyConstructible, boost::LessThanComparable
Parameters
[in]s1a range of values
[in]s2another range of values which contains the same values as s1 but in any order.
[in]perfectif 'true' ask for a perfect match, otherwise extracts correspondences.
Returns
the vector V: index -> index such that s1[ i ] == s2[ V[ i ] ]. If perfect is true, then an empty range is returned in case of mismatch.
Note
if perfect==false and s1[ i ] is not in s2, then V[ i ] = s2.size().

Definition at line 2618 of file Shortcuts.h.

2620  {
2621  if ( perfect && ( s1.size() != s2.size() ) ) return IdxRange();
2622  std::map<TValue, Idx> M;
2623  Idx idx = 0;
2624  for ( auto val : s2 ) M[ val ] = idx++;
2625  IdxRange V( s1.size() );
2626  idx = 0;
2627  for ( auto val : s1 )
2628  {
2629  auto it = M.find( val );
2630  if ( it != M.end() ) V[ idx++ ] = it->second;
2631  else
2632  {
2633  if ( perfect ) return IdxRange();
2634  V[ idx++ ] = s2.size();
2635  }
2636  }
2637  return V;
2638  }

Referenced by main().

◆ getSCellEmbedder() [1/3]

template<typename TKSpace >
static CanonicSCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getSCellEmbedder ( const KSpace K)
inlinestatic
Parameters
[in]Kany Khalimsky space.
Returns
the canonic signed cell embedder associated to the given Khalimsky space.

Definition at line 446 of file Shortcuts.h.

447  {
448  return CanonicSCellEmbedder<KSpace>( K );
449  }

References K.

Referenced by DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), and main().

◆ getSCellEmbedder() [2/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getSCellEmbedder ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
the canonic signed cell embedder associated to the given digital surface.

Definition at line 1022 of file Shortcuts.h.

1023  {
1024  return getSCellEmbedder( refKSpace( surface ) );
1025  }

References DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), and DGtal::Shortcuts< TKSpace >::refKSpace().

◆ getSCellEmbedder() [3/3]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder<KSpace> DGtal::Shortcuts< TKSpace >::getSCellEmbedder ( CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on any indexed digital surface.
Returns
the canonic signed cell embedder associated to the given indexed digital surface.

Definition at line 1044 of file Shortcuts.h.

1045  {
1046  return getSCellEmbedder( refKSpace( surface ) );
1047  }

References DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), and DGtal::Shortcuts< TKSpace >::refKSpace().

◆ getSurfelRange() [1/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static SurfelRange DGtal::Shortcuts< TKSpace >::getSurfelRange ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Given any digital surface, returns a vector of surfels in some specified order.

Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
[in]paramsthe parameters:
  • surfaceTraversal ["Default"]: "Default"|"DepthFirst"|"BreadthFirst": "Default" default surface traversal, "DepthFirst": depth-first surface traversal, "BreadthFirst": breadth-first surface traversal.
Returns
a range of surfels as a vector.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, and geometry/volumes/fullConvexityShortestPaths3D.cpp.

Definition at line 1547 of file Shortcuts.h.

1549  {
1550  return getSurfelRange( surface, *( surface->begin() ), params );
1551  }

Referenced by main(), DGtal::Shortcuts< TKSpace >::outputPrimalDigitalSurfaceAsObj(), and TEST_CASE().

◆ getSurfelRange() [2/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static SurfelRange DGtal::Shortcuts< TKSpace >::getSurfelRange ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Surfel start_surfel,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Given a light digital surface, returns a vector of surfels in some specified order.

Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
[in]start_surfelthe surfel where the traversal starts in case of depth-first/breadth-first traversal.
[in]paramsthe parameters:
  • surfaceTraversal ["Default"]: "Default"|"DepthFirst"|"BreadthFirst": "Default" default surface traversal, "DepthFirst": depth-first surface traversal, "BreadthFirst": breadth-first surface traversal.
Returns
a range of surfels as a vector.

Definition at line 1570 of file Shortcuts.h.

1573  {
1574  typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1575  SurfelRange result;
1576  std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1577  if ( traversal == "DepthFirst" )
1578  {
1579  typedef DepthFirstVisitor< AnyDigitalSurface > Visitor;
1580  typedef GraphVisitorRange< Visitor > VisitorRange;
1581  VisitorRange range( new Visitor( *surface, start_surfel ) );
1582  std::for_each( range.begin(), range.end(),
1583  [&result] ( Surfel s ) { result.push_back( s ); } );
1584  }
1585  else if ( traversal == "BreadthFirst" )
1586  {
1587  typedef BreadthFirstVisitor< AnyDigitalSurface > Visitor;
1588  typedef GraphVisitorRange< Visitor > VisitorRange;
1589  VisitorRange range( new Visitor( *surface, start_surfel ) );
1590  std::for_each( range.begin(), range.end(),
1591  [&result] ( Surfel s ) { result.push_back( s ); } );
1592  }
1593  else
1594  {
1595  std::for_each( surface->begin(), surface->end(),
1596  [&result] ( Surfel s ) { result.push_back( s ); } );
1597  }
1598  return result;
1599  }

◆ getZeroTickedColorMap()

template<typename TKSpace >
static ZeroTickedColorMap DGtal::Shortcuts< TKSpace >::getZeroTickedColorMap ( Scalar  min,
Scalar  max,
const Parameters params = parametersUtilities() 
)
inlinestatic
Parameters
[in]minthe minimum considered value for the colormap.
[in]maxthe maximum considered value for the colormap.
[in]paramsthe parameters:
  • colormap [ "Custom" ]: "Cool"|"Copper"|"Hot"|"Jet"|"Spring"|"Summer"|"Autumn"|"Winter"|"Error"|"Custom" specifies standard colormaps (if invalid, falls back to "Custom").
  • zero-tic [ 0.0 ]: if positive defines a black zone ]-zt,zt[ in the colormap.
Returns
a colormap according to the specified parameters adapted to make darker tics for a background "Tics" colormap.

Definition at line 2706 of file Shortcuts.h.

2709  {
2710  auto cmap = getColorMap( min, max, params );
2711  auto ztic = params[ "zero-tic" ].as<double>();
2712  ZeroTickedColorMap ztic_cmap( cmap, Color::Black );
2713  if ( ztic <= 0.0 ) return ztic_cmap;
2714  if ( min <= 0.0 && 0.0 <= max )
2715  ztic_cmap.addTick( 0.0, ztic );
2716  ztic_cmap.finalize();
2717  return ztic_cmap;
2718  }

References DGtal::Color::Black, DGtal::Shortcuts< TKSpace >::getColorMap(), and max().

◆ isValid()

template<typename TKSpace >
bool DGtal::Shortcuts< TKSpace >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 3264 of file Shortcuts.h.

3265  {
3266  return true;
3267  }

◆ makeBinaryImage() [1/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( CountedPtr< BinaryImage bimage,
Parameters  params = parametersBinaryImage() 
)
inlinestatic

Adds Kanungo noise to a binary image and returns the resulting new image.

Parameters
[in]bimagea smart pointer on a binary image.
[in]paramsthe parameters:
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
Returns
a smart pointer on the noisified binary image.

Definition at line 628 of file Shortcuts.h.

630  {
631  const Scalar noise = params[ "noise" ].as<Scalar>();
632  if ( noise <= 0.0 ) return bimage;
633  typedef KanungoNoise< BinaryImage, Domain > KanungoPredicate;
634  const Domain shapeDomain = bimage->domain();
635  CountedPtr<BinaryImage> img ( new BinaryImage( shapeDomain ) );
636  KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
637  std::transform( shapeDomain.begin(), shapeDomain.end(),
638  img->begin(),
639  [&noisy_dshape] ( const Point& p ) { return noisy_dshape(p); } );
640  return img;
641  }

References DGtal::HyperRectDomain< TSpace >::begin(), DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), and DGtal::HyperRectDomain< TSpace >::end().

◆ makeBinaryImage() [2/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( CountedPtr< DigitizedImplicitShape3D shape_digitization,
Domain  shapeDomain,
Parameters  params = parametersBinaryImage() 
)
inlinestatic

Vectorizes an implicitly defined digital shape into a binary image, in the specified (hyper-)rectangular domain, and possibly add Kanungo noise to the result depending on parameters given in params.

Parameters
[in]shape_digitizationa smart pointer on an implicit digital shape.
[in]shapeDomainany domain.
[in]paramsthe parameters:
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
Returns
a smart pointer on a binary image that samples the digital shape.

Definition at line 596 of file Shortcuts.h.

599  {
600  const Scalar noise = params[ "noise" ].as<Scalar>();
601  CountedPtr<BinaryImage> img ( new BinaryImage( shapeDomain ) );
602  if ( noise <= 0.0 )
603  {
604  std::transform( shapeDomain.begin(), shapeDomain.end(),
605  img->begin(),
606  [&shape_digitization]
607  ( const Point& p ) { return (*shape_digitization)(p); } );
608  }
609  else
610  {
611  typedef KanungoNoise< DigitizedImplicitShape3D, Domain > KanungoPredicate;
612  KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
613  std::transform( shapeDomain.begin(), shapeDomain.end(),
614  img->begin(),
615  [&noisy_dshape] ( const Point& p ) { return noisy_dshape(p); } );
616  }
617  return img;
618  }

References DGtal::HyperRectDomain< TSpace >::begin(), and DGtal::HyperRectDomain< TSpace >::end().

◆ makeBinaryImage() [3/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( CountedPtr< DigitizedImplicitShape3D shape_digitization,
Parameters  params = parametersBinaryImage() 
)
inlinestatic

Vectorizes an implicitly defined digital shape into a binary image, and possibly add Kanungo noise to the result depending on parameters given in params.

Parameters
[in]shape_digitizationa smart pointer on an implicit digital shape.
[in]paramsthe parameters:
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
Returns
a smart pointer on a binary image that samples the digital shape.

Definition at line 576 of file Shortcuts.h.

578  {
579  return makeBinaryImage( shape_digitization,
580  shape_digitization->getDomain(),
581  params );
582  }

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), and DGtal::Shortcuts< TKSpace >::makeBinaryImage().

◆ makeBinaryImage() [4/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( CountedPtr< GrayScaleImage gray_scale_image,
Parameters  params = parametersBinaryImage() 
)
inlinestatic

Binarizes an arbitrary gray scale image file and returns the binary image corresponding to the threshold/noise parameters.

Parameters
[in]gray_scale_imagethe input gray scale image.
[in]paramsthe parameters:
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
  • thresholdMin [ 0]: specifies the threshold min (excluded) to define binary shape
  • thresholdMax [255]: specifies the threshold max (included) to define binary shape
Returns
a smart pointer on a binary image that represents the (thresholded/noisified) gray scale image.

Definition at line 685 of file Shortcuts.h.

687  {
688  int thresholdMin = params["thresholdMin"].as<int>();
689  int thresholdMax = params["thresholdMax"].as<int>();
690  Domain domain = gray_scale_image->domain();
691  typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
692  ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
693  CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
694  std::transform( domain.begin(), domain.end(),
695  img->begin(),
696  [tImage] ( const Point& p ) { return tImage(p); } );
697  return makeBinaryImage( img, params );
698  }

References DGtal::HyperRectDomain< TSpace >::begin(), domain, DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), DGtal::HyperRectDomain< TSpace >::end(), and DGtal::Shortcuts< TKSpace >::makeBinaryImage().

◆ makeBinaryImage() [5/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( Domain  shapeDomain)
inlinestatic

Makes an empty binary image within a given domain.

Parameters
[in]shapeDomainany domain.
Returns
a smart pointer on a binary image that fits the given domain.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 561 of file Shortcuts.h.

562  {
563  return CountedPtr<BinaryImage>( new BinaryImage( shapeDomain ) );
564  }

Referenced by getSlice(), main(), DGtal::Shortcuts< TKSpace >::makeBinaryImage(), DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), SCENARIO(), and TEST_CASE().

◆ makeBinaryImage() [6/6]

template<typename TKSpace >
static CountedPtr<BinaryImage> DGtal::Shortcuts< TKSpace >::makeBinaryImage ( std::string  input,
Parameters  params = parametersBinaryImage() 
)
inlinestatic

Loads an arbitrary image file (e.g. vol file in 3D) and returns the binary image corresponding to the threshold/noise parameters.

Parameters
[in]inputthe input filename.
[in]paramsthe parameters:
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
  • thresholdMin [ 0]: specifies the threshold min (excluded) to define binary shape
  • thresholdMax [255]: specifies the threshold max (included) to define binary shape
Returns
a smart pointer on a binary image that represents the (thresholded/noisified) image file.

Definition at line 656 of file Shortcuts.h.

658  {
659  int thresholdMin = params["thresholdMin"].as<int>();
660  int thresholdMax = params["thresholdMax"].as<int>();
662  Domain domain = image.domain();
663  typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
664  ThresholdedImage tImage( image, thresholdMin, thresholdMax );
665  CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
666  std::transform( domain.begin(), domain.end(),
667  img->begin(),
668  [tImage] ( const Point& p ) { return tImage(p); } );
669  return makeBinaryImage( img, params );
670  }

References DGtal::HyperRectDomain< TSpace >::begin(), domain, DGtal::HyperRectDomain< TSpace >::end(), DGtal::GenericReader< TContainer, Tdim, TValue >::import(), and DGtal::Shortcuts< TKSpace >::makeBinaryImage().

◆ makeDigitalSurface() [1/2]

template<typename TKSpace >
static CountedPtr< DigitalSurface > DGtal::Shortcuts< TKSpace >::makeDigitalSurface ( CountedPtr< IdxDigitalSurface idx_surface,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds a explicit digital surface from an indexed digital surface.

Note
if the given surfel adjacency is not the same as the one chosen for the input indexed digital surface, the number of connected components may change in the process.
Parameters
[in]idx_surfaceany indexed digital surface.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
Returns
a smart pointer on a explicit digital surface.

Definition at line 1240 of file Shortcuts.h.

1242  {
1243  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1244  const KSpace& K = refKSpace( idx_surface );
1245  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1246  auto all_idx_surfels
1247  = getIdxSurfelRange( idx_surface, Parameters( "surfaceTraversal", "Default" ) );
1248  auto idx2surfel = idx_surface->surfels();
1249  SurfelSet all_surfels;
1250  for ( auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1251  ExplicitSurfaceContainer* surfContainer
1252  = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1253  return CountedPtr<DigitalSurface>
1254  ( new DigitalSurface( surfContainer ) ); // acquired
1255  }

References DGtal::Shortcuts< TKSpace >::getIdxSurfelRange(), K, DGtal::Shortcuts< TKSpace >::refKSpace(), and DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer >::surfels().

◆ makeDigitalSurface() [2/2]

template<typename TKSpace >
template<typename TPointPredicate >
static CountedPtr< DigitalSurface > DGtal::Shortcuts< TKSpace >::makeDigitalSurface ( CountedPtr< TPointPredicate >  bimage,
const KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Creates a explicit digital surface representing the boundaries in the binary image bimage, or any one of its big components according to parameters.

Template Parameters
TPointPredicateany type representing a point predicate (e.g. a BinaryImage or a DigitizedImplicitShape3D).
Parameters
[in]bimageany point predicate: Point -> boolean that represents the characteristic function of a digital shape
[in]Kthe Khalimsky space whose domain encompasses the digital shape.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
Returns
a smart pointer on the explicit digital surface representing the boundaries in the binary image.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 1209 of file Shortcuts.h.

1212  {
1213  SurfelSet all_surfels;
1214  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1215  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1216  // Extracts all boundary surfels
1217  Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1218  K.lowerBound(), K.upperBound() );
1219  ExplicitSurfaceContainer* surfContainer
1220  = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1221  return CountedPtr< DigitalSurface >
1222  ( new DigitalSurface( surfContainer ) ); // acquired
1223  }

References K, DGtal::KhalimskySpaceND< dim, TInteger >::lowerBound(), DGtal::Surfaces< TKSpace >::sMakeBoundary(), and DGtal::KhalimskySpaceND< dim, TInteger >::upperBound().

Referenced by getSlice(), main(), DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface(), DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh(), DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), and TEST_CASE().

◆ makeDigitizedImplicitShape3D()

template<typename TKSpace >
static CountedPtr<DigitizedImplicitShape3D> DGtal::Shortcuts< TKSpace >::makeDigitizedImplicitShape3D ( CountedPtr< ImplicitShape3D shape,
Parameters  params = parametersDigitizedImplicitShape3D() 
)
inlinestatic

Makes the Gauss digitization of the given implicit shape according to parameters. Use getKSpace to build the associated digital space.

Parameters
[in]shapea smart pointer on the implicit shape.
[in]paramsthe parameters:
  • minAABB [-10.0]: the min value of the AABB bounding box (domain)
  • maxAABB [ 10.0]: the max value of the AABB bounding box (domain)
  • gridstep [ 1.0]: the gridstep that defines the digitization (often called h).
  • offset [ 5.0]: the digital dilation of the digital space, useful when you process shapes and that you add noise.
Returns
a smart pointer on the created implicit digital shape.
See also
getKSpaceDigitizedImplicitShape3D

Definition at line 523 of file Shortcuts.h.

525  {
526  Scalar min_x = params[ "minAABB" ].as<Scalar>();
527  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
528  Scalar h = params[ "gridstep" ].as<Scalar>();
529  Scalar offset = params[ "offset" ].as<Scalar>();
530  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
531  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
532  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
533  dshape->attach( shape );
534  dshape->init( p1, p2, h );
535  return dshape;
536  }

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), and DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init().

Referenced by getSlice(), main(), SCENARIO(), and TEST_CASE().

◆ makeDoubleImage() [1/3]

template<typename TKSpace >
static CountedPtr<DoubleImage> DGtal::Shortcuts< TKSpace >::makeDoubleImage ( CountedPtr< ImplicitShape3D shape,
Parameters  params = parametersDigitizedImplicitShape3D() 
)
inlinestatic

Makes a double image from the given implicit shape according to parameters. Use getKSpace to build the associated digital space.

Parameters
[in]shapea smart pointer on the implicit shape.
[in]paramsthe parameters:
  • minAABB [-10.0]: the min value of the AABB bounding box (domain)
  • maxAABB [ 10.0]: the max value of the AABB bounding box (domain)
  • gridstep [ 1.0]: the gridstep that defines the digitization (often called h).
  • offset [ 5.0]: the digital dilation of the digital space, useful when you process shapes and that you add noise.
Returns
a smart pointer on the created image.

Definition at line 964 of file Shortcuts.h.

966  {
967  Scalar min_x = params[ "minAABB" ].as<Scalar>();
968  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
969  Scalar h = params[ "gridstep" ].as<Scalar>();
970  Scalar offset = params[ "offset" ].as<Scalar>();
971  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
972  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
973  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
974  dshape->attach( shape );
975  dshape->init( p1, p2, h );
976  Domain domain = dshape->getDomain();
977  auto fimage = makeDoubleImage( domain );
978  auto it = fimage->begin();
979  for ( auto p : domain )
980  {
981  double val = (double) (*shape)( p );
982  *it++ = val;
983  }
984  return fimage;
985  }

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), domain, DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), and DGtal::Shortcuts< TKSpace >::makeDoubleImage().

◆ makeDoubleImage() [2/3]

template<typename TKSpace >
static CountedPtr<DoubleImage> DGtal::Shortcuts< TKSpace >::makeDoubleImage ( Domain  aDomain)
inlinestatic

Makes an empty double image within a given domain (values are unsigned char).

Parameters
[in]aDomainany domain.
Returns
a smart pointer on a double image that fits the given domain.

Definition at line 930 of file Shortcuts.h.

931  {
932  return CountedPtr<DoubleImage>( new DoubleImage( aDomain ) );
933  }

Referenced by DGtal::Shortcuts< TKSpace >::makeDoubleImage().

◆ makeDoubleImage() [3/3]

template<typename TKSpace >
static CountedPtr<DoubleImage> DGtal::Shortcuts< TKSpace >::makeDoubleImage ( std::string  input)
inlinestatic

Loads an arbitrary image file (e.g. vol file in 3D) and returns the corresponding double image.

Parameters
[in]inputthe input filename.
Returns
a smart pointer on the loaded double image.

Definition at line 943 of file Shortcuts.h.

944  {
946  return CountedPtr<DoubleImage>( new DoubleImage( image ) );
947  }

References DGtal::GenericReader< TContainer, Tdim, TValue >::import().

◆ makeDualPolygonalSurface() [1/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface ( CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the dual polygonal surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface.

Definition at line 2288 of file Shortcuts.h.

2289  {
2290  Surfel2Index s2i;
2291  return makeDualPolygonalSurface( s2i, aSurface );
2292  }

References DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface().

◆ makeDualPolygonalSurface() [2/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface ( CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the dual polygonal surface associated to the given indexed digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany indexed digital surface (e.g. IdxDigitalSurface)
Returns
a smart pointer on the built polygonal surface.

Definition at line 2303 of file Shortcuts.h.

2304  {
2305  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2306  auto pPolySurf = CountedPtr<PolygonalSurface>
2307  ( new PolygonalSurface( aSurface->heds(),
2308  aSurface->positions().storage() ) );
2309  return pPolySurf;
2310  }

References DGtal::KhalimskySpaceND< dim, TInteger >::dimension.

◆ makeDualPolygonalSurface() [3/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface ( Surfel2Index s2i,
CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface 
)
inlinestatic

Builds the dual polygonal surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[out]s2ithe map Surfel -> Vertex index in the polygonal surface.
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface.

Definition at line 2268 of file Shortcuts.h.

2270  {
2271  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2272  auto embedder = getCellEmbedder( aSurface );
2273  auto pPolySurf = CountedPtr<PolygonalSurface>
2274  ( new PolygonalSurface ); // acquired
2276  ( *aSurface, embedder, *pPolySurf, s2i );
2277  return pPolySurf;
2278  }

References DGtal::MeshHelpers::digitalSurface2DualPolygonalSurface(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, and DGtal::Shortcuts< TKSpace >::getCellEmbedder().

Referenced by DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface(), and TEST_CASE().

◆ makeFloatImage() [1/3]

template<typename TKSpace >
static CountedPtr<FloatImage> DGtal::Shortcuts< TKSpace >::makeFloatImage ( CountedPtr< ImplicitShape3D shape,
Parameters  params = parametersDigitizedImplicitShape3D() 
)
inlinestatic

Makes a float image from the given implicit shape according to parameters. Use getKSpace to build the associated digital space.

Parameters
[in]shapea smart pointer on the implicit shape.
[in]paramsthe parameters:
  • minAABB [-10.0]: the min value of the AABB bounding box (domain)
  • maxAABB [ 10.0]: the max value of the AABB bounding box (domain)
  • gridstep [ 1.0]: the gridstep that defines the digitization (often called h).
  • offset [ 5.0]: the digital dilation of the digital space, useful when you process shapes and that you add noise.
Returns
a smart pointer on the created image.

Definition at line 898 of file Shortcuts.h.

900  {
901  Scalar min_x = params[ "minAABB" ].as<Scalar>();
902  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
903  Scalar h = params[ "gridstep" ].as<Scalar>();
904  Scalar offset = params[ "offset" ].as<Scalar>();
905  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
906  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
907  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
908  dshape->attach( shape );
909  dshape->init( p1, p2, h );
910  Domain domain = dshape->getDomain();
911  auto fimage = makeFloatImage( domain );
912  auto it = fimage->begin();
913  for ( auto p : domain )
914  {
915  float val = (float) (*shape)( p );
916  *it++ = val;
917  }
918  return fimage;
919  }

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), domain, DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), and DGtal::Shortcuts< TKSpace >::makeFloatImage().

◆ makeFloatImage() [2/3]

template<typename TKSpace >
static CountedPtr<FloatImage> DGtal::Shortcuts< TKSpace >::makeFloatImage ( Domain  aDomain)
inlinestatic

Makes an empty float image within a given domain (values are unsigned char).

Parameters
[in]aDomainany domain.
Returns
a smart pointer on a float image that fits the given domain.

Definition at line 864 of file Shortcuts.h.

865  {
866  return CountedPtr<FloatImage>( new FloatImage( aDomain ) );
867  }

Referenced by DGtal::Shortcuts< TKSpace >::makeFloatImage().

◆ makeFloatImage() [3/3]

template<typename TKSpace >
static CountedPtr<FloatImage> DGtal::Shortcuts< TKSpace >::makeFloatImage ( std::string  input)
inlinestatic

Loads an arbitrary image file (e.g. vol file in 3D) and returns the corresponding float image.

Parameters
[in]inputthe input filename.
Returns
a smart pointer on the loaded float image.

Definition at line 877 of file Shortcuts.h.

878  {
880  return CountedPtr<FloatImage>( new FloatImage( image ) );
881  }

References DGtal::GenericReader< TContainer, Tdim, TValue >::import().

◆ makeGrayScaleImage() [1/5]

template<typename TKSpace >
static CountedPtr<GrayScaleImage> DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( CountedPtr< BinaryImage binary_image,
std::function< GrayScale(bool) > const &  bool2grayscale = [] ( bool v ) { return v ? (unsigned char) 255 : (unsigned char) 0; } 
)
inlinestatic

Makes a gray-scale image from a binary image using the given transformation

Parameters
[in]binary_imagethe input binary image.
[in]bool2grayscalethe binarizing function.
Returns
a smart pointer on the resulting gray-scale image.

Definition at line 763 of file Shortcuts.h.

765  { return v ? (unsigned char) 255 : (unsigned char) 0; }
766  // JOL: (GrayScale) was not working with visual C++: error C2065
767  )
768  {
769  const Domain domain = binary_image->domain();
770  CountedPtr<GrayScaleImage> gray_scale_image( new GrayScaleImage( domain ) );
771  std::transform( binary_image->begin(), binary_image->end(),
772  gray_scale_image->begin(),
773  bool2grayscale );
774  return gray_scale_image;
775  }

◆ makeGrayScaleImage() [2/5]

template<typename TKSpace >
static CountedPtr<GrayScaleImage> DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( CountedPtr< DoubleImage fimage,
Parameters  params = parametersGrayScaleImage() 
)
inlinestatic

Makes a gray-scale image from the given double image. (i.e. quantify the given image)..

Parameters
[in]fimagea smart pointer on the double image.
[in]paramsthe parameters:
  • qShift [128.0]: the shift used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).
  • qSlope [ 1.0]: the slope used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).
Returns
a smart pointer on the created image

Definition at line 836 of file Shortcuts.h.

838  {
839  double qShift = params[ "qShift" ].as<double>();
840  double qSlope = params[ "qSlope" ].as<double>();
841  std::function< unsigned char( double ) > f
842  = [qShift,qSlope] (double v)
843  { return (unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
844  Domain domain = fimage->domain();
845  auto gimage = makeGrayScaleImage( domain );
846  auto it = gimage->begin();
847  for ( auto p : domain )
848  {
849  double val = (*fimage)( p );
850  *it++ = f( val );
851  }
852  return gimage;
853  }

References domain, DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), DGtal::Shortcuts< TKSpace >::makeGrayScaleImage(), and max().

◆ makeGrayScaleImage() [3/5]

template<typename TKSpace >
static CountedPtr<GrayScaleImage> DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( CountedPtr< FloatImage fimage,
Parameters  params = parametersGrayScaleImage() 
)
inlinestatic

Makes a gray-scale image from the given float image (i.e. quantify the given image)..

Parameters
[in]fimagea smart pointer on the float image.
[in]paramsthe parameters:
  • qShift [128.0]: the shift used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).
  • qSlope [ 1.0]: the slope used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).
Returns
a smart pointer on the created image

Definition at line 804 of file Shortcuts.h.

806  {
807  float qShift = params[ "qShift" ].as<float>();
808  float qSlope = params[ "qSlope" ].as<float>();
809  std::function< unsigned char( float ) > f
810  = [qShift,qSlope] (float v)
811  { return (unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
812  Domain domain = fimage->domain();
813  auto gimage = makeGrayScaleImage( domain );
814  auto it = gimage->begin();
815  for ( auto p : domain )
816  {
817  float val = (*fimage)( p );
818  *it++ = f( val );
819  }
820  return gimage;
821  }

References domain, DGtal::ImageContainerBySTLVector< TDomain, TValue >::domain(), DGtal::Shortcuts< TKSpace >::makeGrayScaleImage(), and max().

◆ makeGrayScaleImage() [4/5]

template<typename TKSpace >
static CountedPtr<GrayScaleImage> DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( Domain  aDomain)
inlinestatic

Makes an empty gray scale image within a given domain (values are unsigned char).

Parameters
[in]aDomainany domain.
Returns
a smart pointer on a gray scale image that fits the given domain.

Definition at line 736 of file Shortcuts.h.

737  {
738  return CountedPtr<GrayScaleImage>( new GrayScaleImage( aDomain ) );
739  }

Referenced by main(), DGtal::Shortcuts< TKSpace >::makeGrayScaleImage(), and DGtal::Shortcuts< TKSpace >::saveBinaryImage().

◆ makeGrayScaleImage() [5/5]

template<typename TKSpace >
static CountedPtr<GrayScaleImage> DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( std::string  input)
inlinestatic

Loads an arbitrary binary image file (e.g. vol file in 3D) and returns the corresponding gray-scale image.

Parameters
[in]inputthe input filename.
Returns
a smart pointer on the loaded gray-scale image.

Definition at line 749 of file Shortcuts.h.

750  {
752  return CountedPtr<GrayScaleImage>( new GrayScaleImage( image ) );
753  }

References DGtal::GenericReader< TContainer, Tdim, TValue >::import().

◆ makeIdxDigitalSurface() [1/4]

template<typename TKSpace >
static CountedPtr<IdxDigitalSurface> DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface ( const std::vector< CountedPtr< LightDigitalSurface > > &  surfaces,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds an indexed digital surface from a vector of light digital surfaces. Note that the surfel adjacency may be changed and a connected light digital surface could be disconnected in the process.

Note
the surfaces must live in the same digital spaces.
Parameters
[in]surfacesa vector of smart pointers on light digital surfaces.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
Returns
a smart pointer on the required indexed digital surface.

Definition at line 1364 of file Shortcuts.h.

1366  {
1367  if ( surfaces.empty() ) return CountedPtr<IdxDigitalSurface>( 0 );
1368  const KSpace& K = surfaces[ 0 ]->container().space();
1369  SurfelSet surfels;
1370  for ( std::size_t i = 0; i < surfaces.size(); ++i )
1371  {
1372  const KSpace& Ki = surfaces[ i ]->container().space();
1373  if ( ( Ki.lowerBound() != K.lowerBound() )
1374  || ( Ki.upperBound() != K.upperBound() ) )
1375  trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1376  << " Incompatible digital spaces for surface " << i << std::endl;
1377  surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1378  }
1379  return makeIdxDigitalSurface( surfels, K, params );
1380  }

References K, DGtal::KhalimskySpaceND< dim, TInteger >::lowerBound(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::upperBound(), and DGtal::Trace::warning().

◆ makeIdxDigitalSurface() [2/4]

template<typename TKSpace >
template<typename TSurfelRange >
static CountedPtr<IdxDigitalSurface> DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface ( const TSurfelRange &  surfels,
ConstAlias< KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds an indexed digital surface from a space K and an arbitrary range of surfels.

Parameters
[in]surfelsan arbitrary range of surfels.
[in]Kthe Khalimsky space whose domain encompasses the given surfels.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
Returns
a smart pointer on the indexed digital surface built over the surfels.

Definition at line 1308 of file Shortcuts.h.

1311  {
1312  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1313  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1314  // Build indexed digital surface.
1315  CountedPtr<ExplicitSurfaceContainer> ptrSurfContainer
1316  ( new ExplicitSurfaceContainer( K, surfAdj, surfels ) );
1317  CountedPtr<IdxDigitalSurface> ptrSurface
1318  ( new IdxDigitalSurface() );
1319  bool ok = ptrSurface->build( ptrSurfContainer );
1320  if ( !ok )
1321  trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1322  << " Error building indexed digital surface." << std::endl;
1323  return ptrSurface;
1324  }

References DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer >::build(), K, DGtal::trace, and DGtal::Trace::warning().

◆ makeIdxDigitalSurface() [3/4]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static CountedPtr<IdxDigitalSurface> DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds an indexed digital surface from a light digital surface. Note that the surfel adjacency may be changed and a connected light digital surface could be disconnected in the process.

Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
Returns
a smart pointer on the required indexed digital surface.

Definition at line 1341 of file Shortcuts.h.

1343  {
1344  const KSpace& K = refKSpace( surface );
1345  SurfelSet surfels;
1346  surfels.insert( surface->begin(), surface->end() );
1347  return makeIdxDigitalSurface( surfels, K, params );
1348  }

References K, DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), and DGtal::Shortcuts< TKSpace >::refKSpace().

◆ makeIdxDigitalSurface() [4/4]

template<typename TKSpace >
static CountedPtr<IdxDigitalSurface> DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface ( CountedPtr< BinaryImage bimage,
const KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds an indexed digital surface from a space K and a binary image bimage. Note that it may connected or not depending on parameters.

Parameters
[in]bimagea binary image representing the characteristic function of a digital shape.
[in]Kthe Khalimsky space whose domain encompasses the digital shape.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
  • nbTriesToFindABel [100000]: number of tries in method Surfaces::findABel
  • surfaceComponents ["AnyBig"]: "AnyBig"|"All", "AnyBig": any big-enough component (> twice space width), "All": all components
Returns
a smart pointer on the required indexed digital surface.

Definition at line 1275 of file Shortcuts.h.

1278  {
1279  std::string component = params[ "surfaceComponents" ].as<std::string>();
1280  SurfelSet surfels;
1281  if ( component == "AnyBig" )
1282  {
1283  auto light_surface = makeLightDigitalSurface( bimage, K, params );
1284  surfels.insert( light_surface->begin(), light_surface->end() );
1285  }
1286  else if ( component == "All" )
1287  {
1288  Surfaces<KSpace>::sMakeBoundary( surfels, K, *bimage,
1289  K.lowerBound(), K.upperBound() );
1290  }
1291  return makeIdxDigitalSurface( surfels, K, params );
1292  }

References K, DGtal::KhalimskySpaceND< dim, TInteger >::lowerBound(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), DGtal::Surfaces< TKSpace >::sMakeBoundary(), and DGtal::KhalimskySpaceND< dim, TInteger >::upperBound().

Referenced by main(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), and TEST_CASE().

◆ makeImplicitShape3D()

template<typename TKSpace >
static CountedPtr<ImplicitShape3D> DGtal::Shortcuts< TKSpace >::makeImplicitShape3D ( const Parameters params = parametersImplicitShape3D())
inlinestatic

Builds a 3D implicit shape from parameters

Parameters
[in]paramsthe parameters:
  • polynomial["sphere1"]: the implicit polynomial whose zero-level set defines the shape of interest.
Returns
a smart pointer on the created implicit shape.

Definition at line 282 of file Shortcuts.h.

283  {
284  typedef MPolynomialReader< Space::dimension, Scalar> Polynomial3Reader;
285  std::string poly_str = params[ "polynomial" ].as<std::string>();
286  // Recognizes specific strings as polynomials.
287  auto PL = getPolynomialList();
288  if ( PL[ poly_str ] != "" ) poly_str = PL[ poly_str ];
289  ScalarPolynomial poly;
290  Polynomial3Reader reader;
291  std::string::const_iterator iter
292  = reader.read( poly, poly_str.begin(), poly_str.end() );
293  if ( iter != poly_str.end() )
294  {
295  trace.error() << "[Shortcuts::makeImplicitShape3D]"
296  << " ERROR reading polynomial: I read only <"
297  << poly_str.substr( 0, iter - poly_str.begin() )
298  << ">, and I built P=" << poly << std::endl;
299  }
300  return CountedPtr<ImplicitShape3D>( new ImplicitShape3D( poly ) );
301  }

References DGtal::Trace::error(), DGtal::Shortcuts< TKSpace >::getPolynomialList(), DGtal::MPolynomialReader< n, TRing, TAlloc, TIterator >::read(), and DGtal::trace.

Referenced by getSlice(), main(), SCENARIO(), and TEST_CASE().

◆ makeLightDigitalSurface()

template<typename TKSpace >
static CountedPtr<LightDigitalSurface> DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface ( CountedPtr< BinaryImage bimage,
const KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Builds a light digital surface from a space K and a binary image bimage.

Parameters
[in]bimagea binary image representing the characteristic function of a digital shape.
[in]Kthe Khalimsky space whose domain encompasses the digital shape.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
  • nbTriesToFindABel [100000]: number of tries in method Surfaces::findABel
Returns
a smart pointer on a (light) digital surface that represents the boundary of any big component of the digital shape.

Definition at line 1062 of file Shortcuts.h.

1065  {
1066  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1067  int nb_tries_to_find_a_bel = params[ "nbTriesToFindABel" ].as<int>();
1068  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1069 
1070  // We have to search for a surfel that belongs to a big connected component.
1071  CountedPtr<LightDigitalSurface> ptrSurface;
1072  Surfel bel;
1073  Scalar minsize = bimage->extent().norm();
1074  unsigned int nb_surfels = 0;
1075  unsigned int tries = 0;
1076  do
1077  {
1078  try { // Search initial bel
1079  bel = Surfaces<KSpace>::findABel( K, *bimage, nb_tries_to_find_a_bel );
1080  } catch (DGtal::InputException& e) {
1081  trace.error() << "[Shortcuts::makeLightDigitalSurface]"
1082  << " ERROR Unable to find bel. " << e << std::endl;
1083  return ptrSurface;
1084  }
1085  // this pointer will be acquired by the surface.
1086  LightSurfaceContainer* surfContainer
1087  = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1088  ptrSurface = CountedPtr<LightDigitalSurface>
1089  ( new LightDigitalSurface( surfContainer ) ); // acquired
1090  nb_surfels = ptrSurface->size();
1091  }
1092  while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1093  if( tries >= 150 )
1094  trace.warning() << "[Shortcuts::makeLightDigitalSurface]"
1095  << "ERROR cannot find a proper bel in a big enough component."
1096  << std::endl;
1097  return ptrSurface;
1098  }

References DGtal::Trace::error(), DGtal::ImageContainerBySTLVector< TDomain, TValue >::extent(), DGtal::Surfaces< TKSpace >::findABel(), K, DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::size(), DGtal::trace, and DGtal::Trace::warning().

Referenced by main(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces(), SCENARIO(), and TEST_CASE().

◆ makeLightDigitalSurfaces() [1/2]

template<typename TKSpace >
static std::vector< CountedPtr<LightDigitalSurface> > DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces ( CountedPtr< BinaryImage bimage,
const KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Returns a vector containing either all the light digital surfaces in the binary image bimage, or any one of its big components according to parameters.

Parameters
[in]bimagea binary image representing the characteristic function of a digital shape.
[in]Kthe Khalimsky space whose domain encompasses the digital shape.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
  • nbTriesToFindABel [ 100000]: number of tries in method Surfaces::findABel
  • surfaceComponents ["AnyBig"]: "AnyBig"|"All", "AnyBig": any big-enough component (> twice space width), "All": all components
Returns
a vector of smart pointers to the connected (light) digital surfaces present in the binary image.

Definition at line 1119 of file Shortcuts.h.

1122  {
1123  SurfelRange surfel_reps;
1124  return makeLightDigitalSurfaces( surfel_reps, bimage, K, params );
1125  }

References K.

Referenced by main().

◆ makeLightDigitalSurfaces() [2/2]

template<typename TKSpace >
static std::vector< CountedPtr<LightDigitalSurface> > DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces ( SurfelRange surfel_reps,
CountedPtr< BinaryImage bimage,
const KSpace K,
const Parameters params = parametersDigitalSurface() 
)
inlinestatic

Returns a vector containing either all the light digital surfaces in the binary image bimage, or any one of its big components according to parameters.

Parameters
[out]surfel_repsa vector of surfels, one surfel per digital surface component.
[in]bimagea binary image representing the characteristic function of a digital shape.
[in]Kthe Khalimsky space whose domain encompasses the digital shape.
[in]paramsthe parameters:
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
  • nbTriesToFindABel [ 100000]: number of tries in method Surfaces::findABel
  • surfaceComponents ["AnyBig"]: "AnyBig"|"All", "AnyBig": any big-enough component (> twice space width), "All": all components
Returns
a vector of smart pointers to the connected (light) digital surfaces present in the binary image.

Definition at line 1149 of file Shortcuts.h.

1153  {
1154  std::vector< CountedPtr<LightDigitalSurface> > result;
1155  std::string component = params[ "surfaceComponents" ].as<std::string>();
1156  if ( component == "AnyBig" )
1157  {
1158  result.push_back( makeLightDigitalSurface( bimage, K, params ) );
1159  surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1160  return result;
1161  }
1162  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1163  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1164  // Extracts all boundary surfels
1165  SurfelSet all_surfels;
1166  Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1167  K.lowerBound(), K.upperBound() );
1168  // Builds all connected components of surfels.
1169  SurfelSet marked_surfels;
1170  CountedPtr<LightDigitalSurface> ptrSurface;
1171  for ( auto bel : all_surfels )
1172  {
1173  if ( marked_surfels.count( bel ) != 0 ) continue;
1174  surfel_reps.push_back( bel );
1175  LightSurfaceContainer* surfContainer
1176  = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1177  ptrSurface = CountedPtr<LightDigitalSurface>
1178  ( new LightDigitalSurface( surfContainer ) ); // acquired
1179  // mark all surfels of the surface component.
1180  marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1181  // add surface component to result.
1182  result.push_back( ptrSurface );
1183  }
1184  return result;
1185  }

References DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), K, DGtal::KhalimskySpaceND< dim, TInteger >::lowerBound(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), DGtal::Surfaces< TKSpace >::sMakeBoundary(), and DGtal::KhalimskySpaceND< dim, TInteger >::upperBound().

◆ makeMesh() [1/2]

template<typename TKSpace >
static CountedPtr< Mesh > DGtal::Shortcuts< TKSpace >::makeMesh ( CountedPtr< PolygonalSurface polySurf,
const Color aColor = Color::White 
)
inlinestatic

Builds a mesh (class Mesh) from a polygonal surface (class PolygonalSurface). Note that the mesh looses the topology of the polygonal surface, since it is essentially a soup of triangles.

Parameters
[in]polySurfthe input polygonal surface mesh.
[in]aColorthe default color of the mesh.
Returns
a smart pointer on the output mesh.

Definition at line 2088 of file Shortcuts.h.

2090  {
2091  auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
2092  MeshHelpers::polygonalSurface2Mesh( *polySurf, *pMesh );
2093  return pMesh;
2094  }

References DGtal::MeshHelpers::polygonalSurface2Mesh().

◆ makeMesh() [2/2]

template<typename TKSpace >
static CountedPtr< Mesh > DGtal::Shortcuts< TKSpace >::makeMesh ( CountedPtr< TriangulatedSurface triSurf,
const Color aColor = Color::White 
)
inlinestatic

Builds a mesh (class Mesh) from a triangulated surface (class TriangulatedSurface). Note that the mesh looses the topology of the triangulated surface, since it is essentially a soup of triangles.

Parameters
[in]triSurfthe input triangulated surface mesh.
[in]aColorthe default color of the mesh.
Returns
a smart pointer on the output mesh.

Definition at line 2071 of file Shortcuts.h.

2073  {
2074  auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
2075  MeshHelpers::triangulatedSurface2Mesh( *triSurf, *pMesh );
2076  return pMesh;
2077  }

References DGtal::MeshHelpers::triangulatedSurface2Mesh().

Referenced by main().

◆ makePolygonalSurface() [1/2]

template<typename TKSpace >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makePolygonalSurface ( CountedPtr< GrayScaleImage gray_scale_image,
const Parameters params = parametersKSpace() | parametersBinaryImage() | parametersDigitalSurface() 
)
inlinestatic

Builds the polygonal marching-cubes surface that approximate an iso-surface of value "thresholdMin+0.5" in the given 3D gray-scale image.

Parameters
[in]gray_scale_imageany gray-scale image.
[in]paramsthe parameters:
  • surfelAdjacency[0]: specifies the surfel adjacency (1:ext, 0:int)
  • thresholdMin [0]: specifies the threshold min (excluded) to define binary shape
  • gridsizex [1.0]: specifies the space between points along x.
  • gridsizey [1.0]: specifies the space between points along y.
  • gridsizez [1.0]: specifies the space between points along z.
Returns
a smart pointer on the built polygonal surface or 0 if the mesh was invalid.

Definition at line 2188 of file Shortcuts.h.

2193  {
2194  auto K = getKSpace( gray_scale_image );
2195  auto bimage = makeBinaryImage( gray_scale_image, params );
2196  auto digSurf = makeDigitalSurface( bimage, K, params );
2197  RealVector gh = { params[ "gridsizex" ].as<double>(),
2198  params[ "gridsizey" ].as<double>(),
2199  params[ "gridsizez" ].as<double>() };
2200  double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
2201  typedef RegularPointEmbedder<Space> PointEmbedder;
2202  typedef ImageLinearCellEmbedder
2203  < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
2204  PointEmbedder pembedder;
2205  pembedder.init( gh );
2206  ImageCellEmbedder cembedder;
2207  cembedder.init( K, *gray_scale_image, pembedder, threshold );
2208  auto pPolySurf = CountedPtr<PolygonalSurface>
2209  ( new PolygonalSurface ); // acquired
2210  Surfel2Index s2i;
2212  ( *digSurf, cembedder, *pPolySurf, s2i );
2213  return pPolySurf;
2214  }

References DGtal::MeshHelpers::digitalSurface2DualPolygonalSurface(), DGtal::Shortcuts< TKSpace >::getKSpace(), K, DGtal::Shortcuts< TKSpace >::makeBinaryImage(), and DGtal::Shortcuts< TKSpace >::makeDigitalSurface().

◆ makePolygonalSurface() [2/2]

template<typename TKSpace >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makePolygonalSurface ( CountedPtr< Mesh aMesh)
inlinestatic

Builds a polygon mesh (class PolygonalSurface) from a mesh (class Mesh). The output polygonal surface rebuilds a topology between faces.

Parameters
[in]aMeshany mesh (which should be a valid combinatorial surface).
Returns
a smart pointer on the built polygonal surface or 0 if the mesh was invalid.

Definition at line 2166 of file Shortcuts.h.

2167  {
2168  auto pPolySurf = CountedPtr<PolygonalSurface>
2169  ( new PolygonalSurface ); // acquired
2170  bool ok = MeshHelpers::mesh2PolygonalSurface( *aMesh, *pPolySurf );
2171  return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
2172  }

References DGtal::MeshHelpers::mesh2PolygonalSurface().

◆ makePrimalPolygonalSurface() [1/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface ( Cell2Index c2i,
CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface 
)
inlinestatic

Builds the primal polygonal surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[out]c2ithe map Cell -> Vertex index in the polygonal surface.
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface or 0 if it fails because aSurface is not a combinatorial 2-manifold.

Definition at line 2321 of file Shortcuts.h.

2323  {
2324  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2325  auto embedder = getCellEmbedder( aSurface );
2326  auto pPolySurf = CountedPtr<PolygonalSurface>
2327  ( new PolygonalSurface ); // acquired
2329  ( *aSurface, embedder, *pPolySurf, c2i );
2330  return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
2331  }

References DGtal::MeshHelpers::digitalSurface2PrimalPolygonalSurface(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, and DGtal::Shortcuts< TKSpace >::getCellEmbedder().

Referenced by DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface(), and SCENARIO().

◆ makePrimalPolygonalSurface() [2/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface ( CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the primal polygonal surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface or 0 if it fails because aSurface is not a combinatorial 2-manifold.

Definition at line 2341 of file Shortcuts.h.

2342  {
2343  Cell2Index c2i;
2344  return makePrimalPolygonalSurface( c2i, aSurface );
2345  }

References DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface().

◆ makePrimalPolygonalSurface() [3/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< PolygonalSurface > DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface ( CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the primal polygonal surface associated to the given indexed digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany indexed digital surface (e.g. IdxDigitalSurface)
Returns
a smart pointer on the built polygonal surface or 0 if it fails because aSurface is not a combinatorial 2-manifold.

Definition at line 2356 of file Shortcuts.h.

2357  {
2358  auto dsurf = makeDigitalSurface( aSurface );
2359  Cell2Index c2i;
2360  return makePrimalPolygonalSurface( c2i, dsurf );
2361  }

References DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), and DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface().

◆ makePrimalSurfaceMesh() [1/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< SurfaceMesh > DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh ( Cell2Index c2i,
CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface 
)
inlinestatic

Builds the primal polygonal surface mesh associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[out]c2ithe map Cell -> Vertex index in the polygonal surface.
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface mesh

Definition at line 2372 of file Shortcuts.h.

2374  {
2375  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2376  auto embedder = getCellEmbedder( aSurface );
2377  auto pPolySurf = CountedPtr<SurfaceMesh>( new SurfaceMesh ); // acquired
2378  bool ok = MeshHelpers::digitalSurface2PrimalSurfaceMesh( *aSurface, embedder, *pPolySurf, c2i );
2379  return ok ? pPolySurf : CountedPtr< SurfaceMesh >( nullptr );
2380  }

References DGtal::MeshHelpers::digitalSurface2PrimalSurfaceMesh(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, and DGtal::Shortcuts< TKSpace >::getCellEmbedder().

Referenced by DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh().

◆ makePrimalSurfaceMesh() [2/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< SurfaceMesh > DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh ( CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the primal polygonal surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany digital surface (e.g. DigitalSurface or LightDigitalSurface)
Returns
a smart pointer on the built polygonal surface or 0 if it fails because aSurface is not a combinatorial 2-manifold.

Definition at line 2390 of file Shortcuts.h.

2391  {
2392  Cell2Index c2i;
2393  return makePrimalSurfaceMesh( c2i, aSurface );
2394  }

References DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh().

◆ makePrimalSurfaceMesh() [3/3]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< SurfaceMesh > DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh ( CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the primal polygonal surface associated to the given indexed digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany indexed digital surface (e.g. IdxDigitalSurface)
Returns
a smart pointer on the built polygonal surface or 0 if it fails because aSurface is not a combinatorial 2-manifold.

Definition at line 2404 of file Shortcuts.h.

2405  {
2406  auto dsurf = makeDigitalSurface( aSurface );
2407  Cell2Index c2i;
2408  return makePrimalSurfaceMesh( c2i, dsurf );
2409  }

References DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), and DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh().

◆ makeTriangulatedSurface() [1/5]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< TriangulatedSurface > DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface ( CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface)
inlinestatic

Builds the dual triangulated surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[in]aSurfaceany digital surface (e.g. LightDigitalSurface or DigitalSurface)
Returns
a smart pointer on the built triangulated surface.

Definition at line 2122 of file Shortcuts.h.

2123  {
2124  Surfel2Index s2i;
2125  return makeTriangulatedSurface( s2i, aSurface );
2126  }

References DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface().

◆ makeTriangulatedSurface() [2/5]

template<typename TKSpace >
static CountedPtr< TriangulatedSurface > DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface ( CountedPtr< GrayScaleImage gray_scale_image,
const Parameters params = parametersKSpace() | parametersBinaryImage() | parametersDigitalSurface() 
)
inlinestatic

Builds the marching-cubes surface that approximate an iso-surface of value "thresholdMin+0.5" in the given 3D gray-scale image. Non triangular faces are triangulated by putting a centroid vertex.

Parameters
[in]gray_scale_imageany gray-scale image.
[in]paramsthe parameters:
  • surfelAdjacency[0]: specifies the surfel adjacency (1:ext, 0:int)
  • thresholdMin [0]: specifies the threshold min (excluded) to define binary shape
  • gridsizex [1.0]: specifies the space between points along x.
  • gridsizey [1.0]: specifies the space between points along y.
  • gridsizez [1.0]: specifies the space between points along z.
Returns
a smart pointer on the built triangulated surface or 0 if the mesh was invalid.

Definition at line 2231 of file Shortcuts.h.

2236  {
2237  auto K = getKSpace( gray_scale_image );
2238  auto bimage = makeBinaryImage( gray_scale_image, params );
2239  auto digSurf = makeDigitalSurface( bimage, K, params );
2240  RealVector gh = { params[ "gridsizex" ].as<double>(),
2241  params[ "gridsizey" ].as<double>(),
2242  params[ "gridsizez" ].as<double>() };
2243  double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
2244  typedef RegularPointEmbedder<Space> PointEmbedder;
2245  typedef ImageLinearCellEmbedder
2246  < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
2247  PointEmbedder pembedder;
2248  pembedder.init( gh );
2249  ImageCellEmbedder cembedder;
2250  cembedder.init( K, *gray_scale_image, pembedder, threshold );
2251  auto pPolySurf = CountedPtr<TriangulatedSurface>
2252  ( new TriangulatedSurface ); // acquired
2253  Surfel2Index s2i;
2255  ( *digSurf, cembedder, *pPolySurf, s2i );
2256  return pPolySurf;
2257  }

References DGtal::MeshHelpers::digitalSurface2DualTriangulatedSurface(), DGtal::Shortcuts< TKSpace >::getKSpace(), K, DGtal::Shortcuts< TKSpace >::makeBinaryImage(), and DGtal::Shortcuts< TKSpace >::makeDigitalSurface().

◆ makeTriangulatedSurface() [3/5]

template<typename TKSpace >
static CountedPtr< TriangulatedSurface > DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface ( CountedPtr< Mesh aMesh)
inlinestatic

Builds a triangulated surface (class TriangulatedSurface) from a mesh (class Mesh). Note that a triangulated surface contains only triangles, so polygonal faces (0,1,2,3,4,...) of the input mesh are (naively) triangulated (triangles (0,1,2), (0,2,3), (0,3,4), etc). Furthermore, the output triangulated surface rebuilds a topology between faces.

Parameters
[in]aMeshany mesh (which should be a valid combinatorial surface).
Returns
a smart pointer on the built triangulated surface or 0 if the mesh was invalid.

Definition at line 2054 of file Shortcuts.h.

2055  {
2056  auto pTriSurf = CountedPtr<TriangulatedSurface>
2057  ( new TriangulatedSurface ); // acquired
2058  bool ok = MeshHelpers::mesh2TriangulatedSurface( *aMesh, *pTriSurf );
2059  return ok ? pTriSurf : CountedPtr< TriangulatedSurface >( nullptr );
2060  }

References DGtal::MeshHelpers::mesh2TriangulatedSurface().

Referenced by main(), and DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface().

◆ makeTriangulatedSurface() [4/5]

template<typename TKSpace >
static CountedPtr< TriangulatedSurface > DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface ( CountedPtr< PolygonalSurface polySurf,
const Parameters params = parametersMesh() 
)
inlinestatic

Builds a triangulated surface from a polygonal surface.

Note
Be very careful with "Naive" subdivision, since it may create non-manifold edges on general polygonal surfaces. Indeed, take the closed surface made of faces (0, 1, 2, 3) and (3, 2, 1, 0). Depending on how faces are triangulated, it is still a valid combinatorial triangulated 2-manifold (e.g. (0,1,2,3) gives (0,1,2) and (2,0,3) and (3,2,1,0) gives (3,2,1) and (1,3,0)) or a non-valid one (e.g. (0,1,2,3) gives (0,1,2) and (2,0,3) and (3,2,1,0) gives (3,2,0) and (0,2,1): then edge {2,0} is shared by four faces).
Parameters
[in]polySurfany polygonal surface.
[in]paramsthe parameters:
  • faceSubdivision ["Centroid"]: "No"|"Naive"|"Centroid" specifies how faces are subdivided, "No" is considered as "Naive" since faces must be triangulated.
Returns
a smart pointer on the built triangulated surface.

Definition at line 2146 of file Shortcuts.h.

2148  {
2149  std::string faceSubdivision = params[ "faceSubdivision" ].as<std::string>();
2150  bool centroid = ( faceSubdivision == "Centroid" );
2151  auto pTriSurf = CountedPtr<TriangulatedSurface>
2152  ( new TriangulatedSurface ); // acquired
2153  MeshHelpers::polygonalSurface2TriangulatedSurface( *polySurf, *pTriSurf, centroid );
2154  return pTriSurf;
2155  }

References DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface().

◆ makeTriangulatedSurface() [5/5]

template<typename TKSpace >
template<typename TContainer >
static CountedPtr< TriangulatedSurface > DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface ( Surfel2Index s2i,
CountedPtr< ::DGtal::DigitalSurface< TContainer > >  aSurface 
)
inlinestatic

Builds the dual triangulated surface associated to the given digital surface.

Template Parameters
TContainerthe digital surface container
Parameters
[out]s2ithe map Surfel -> Vertex index in the triangulated surface.
[in]aSurfaceany digital surface (e.g. LightDigitalSurface or DigitalSurface)
Returns
a smart pointer on the built triangulated surface.

Definition at line 2104 of file Shortcuts.h.

2106  {
2107  auto embedder = getCellEmbedder( aSurface );
2108  auto pTriSurf = CountedPtr<TriangulatedSurface>
2109  ( new TriangulatedSurface ); // acquired
2111  ( *aSurface, embedder, *pTriSurf, s2i );
2112  return pTriSurf;
2113  }

References DGtal::MeshHelpers::digitalSurface2DualTriangulatedSurface(), and DGtal::Shortcuts< TKSpace >::getCellEmbedder().

◆ operator=() [1/2]

template<typename TKSpace >
Shortcuts& DGtal::Shortcuts< TKSpace >::operator= ( const Shortcuts< TKSpace > &  other)
delete

Copy assignment operator.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ operator=() [2/2]

template<typename TKSpace >
Shortcuts& DGtal::Shortcuts< TKSpace >::operator= ( Shortcuts< TKSpace > &&  other)
delete

Move assignment operator.

Parameters
otherthe object to move.
Returns
a reference on 'this'.

◆ outputCellMapAsCSV()

template<typename TKSpace >
template<typename TCellMap , typename TValueWriter >
static bool DGtal::Shortcuts< TKSpace >::outputCellMapAsCSV ( std::ostream &  output,
const KSpace K,
const TCellMap &  anyMap,
const TValueWriter &  writer 
)
inlinestatic

Definition at line 3143 of file Shortcuts.h.

3147  {
3148  CellWriter w;
3149  for ( auto&& v : anyMap )
3150  {
3151  w( output, K, v.first );
3152  writer( output, v.second );
3153  output << std::endl;
3154  }
3155  return output.good();
3156  }

References K.

◆ outputDualDigitalSurfaceAsObj() [1/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static bool DGtal::Shortcuts< TKSpace >::outputDualDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const Parameters params = parametersMesh() 
)
inlinestatic

Outputs a digital surface, seen from the dual point of view (surfels=vertices), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside).

Template Parameters
TDigitalSurfaceContainereither model of concepts::CDigitalSurfaceContainer.
Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on a digital surface (a DigitalSurface or a LightDigitalSurface).
[in]paramsthe parameters:
  • faceSubdivision ["Centroid"]: "No"|"Naive"|"Centroid" specifies how dual faces are subdivided when exported.
Returns
'true' if the output stream is good.

Definition at line 2883 of file Shortcuts.h.

2886  {
2887  auto embedder = getCellEmbedder( surface );
2888  return outputDualDigitalSurfaceAsObj( output, surface, embedder, params );
2889  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder().

◆ outputDualDigitalSurfaceAsObj() [2/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool DGtal::Shortcuts< TKSpace >::outputDualDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface,
const TCellEmbedder &  embedder,
const Parameters params = parametersMesh() 
)
inlinestatic

Outputs a digital surface, seen from the dual point of view (surfels=vertices), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside). Each vertex is mapped to a 3D point using the given cell embedder.

Template Parameters
TDigitalSurfaceContainereither model of concepts::CDigitalSurfaceContainer.
TCellEmbedderany model of CCellEmbedder
Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on a digital surface (either DigitalSurface or LightDigitalSurface).
[in]embedderthe embedder for mapping (unsigned) surfels (cells of dimension 2) to points in space.
[in]paramsthe parameters:
  • faceSubdivision ["Centroid"]: "No"|"Naive"|"Centroid" specifies how dual faces are subdivided when exported.
Returns
'true' if the output stream is good.

Definition at line 2917 of file Shortcuts.h.

2921  {
2922  typedef unsigned long Size;
2923  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2924  BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
2925  std::string dualFaceSubdivision = params[ "faceSubdivision" ].as<std::string>();
2926  const int subdivide
2927  = dualFaceSubdivision == "Naive" ? 1
2928  : dualFaceSubdivision == "Centroid" ? 2
2929  : 0;
2930  const KSpace& K = embedder.space();
2931  // Number and ouput vertices.
2932  std::map< Vertex, Size > vtx_numbering;
2933  std::map< Face, Size > sub_numbering;
2934  Size n = 1; // OBJ vertex numbering start at 1
2935  for ( auto && s : *surface )
2936  {
2937  if ( ! vtx_numbering.count( s ) )
2938  {
2939  vtx_numbering[ s ] = n++;
2940  // Output vertex positions
2941  RealPoint p = embedder( K.unsigns( s ) );
2942  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2943  }
2944  }
2945  auto faces = surface->allClosedFaces();
2946  // Prepare centroids if necessary
2947  if ( subdivide == 2 )
2948  {
2949  for ( auto&& f : faces )
2950  {
2951  auto vtcs = surface->verticesAroundFace( f );
2952  Size nv = vtcs.size();
2953  if ( nv > 3 )
2954  {
2955  sub_numbering[ f ] = n++;
2957  for ( auto&& s : vtcs ) p += embedder( K.unsigns( s ) );
2958  p /= nv;
2959  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2960  }
2961  }
2962  }
2963  // Outputs closed faces.
2964  if ( subdivide == 0 )
2965  { // No subdivision
2966  for ( auto&& f : faces )
2967  {
2968  output << "f";
2969  auto vtcs = surface->verticesAroundFace( f );
2970  std::reverse( vtcs.begin(), vtcs.end() );
2971  for ( auto&& s : vtcs )
2972  output << " " << vtx_numbering[ s ];
2973  output << std::endl;
2974  }
2975  }
2976  else if ( subdivide == 1 )
2977  { // naive subdivision
2978  for ( auto&& f : faces )
2979  {
2980  auto vtcs = surface->verticesAroundFace( f );
2981  Size nv = vtcs.size();
2982  for ( Size i = 1; i < nv - 1; ++i )
2983  output << "f " << vtx_numbering[ vtcs[ 0 ] ]
2984  << " " << vtx_numbering[ vtcs[ i+1 ] ]
2985  << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2986  }
2987  }
2988  else if ( subdivide == 2 )
2989  { // centroid subdivision
2990  for ( auto&& f : faces )
2991  {
2992  auto vtcs = surface->verticesAroundFace( f );
2993  Size nv = vtcs.size();
2994  if ( nv == 3 )
2995  output << "f " << vtx_numbering[ vtcs[ 0 ] ]
2996  << " " << vtx_numbering[ vtcs[ 2 ] ]
2997  << " " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
2998  else {
2999  Size c = sub_numbering[ f ];
3000  for ( Size i = 0; i < nv; ++i )
3001  {
3002  output << "f " << c
3003  << " " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
3004  << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3005  }
3006  }
3007  }
3008  }
3009  return output.good();
3010  }

References DGtal::Shortcuts< TKSpace >::BOOST_CONCEPT_ASSERT(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, K, reverse(), DGtal::KhalimskySpaceND< dim, TInteger >::unsigns(), and DGtal::PointVector< dim, TEuclideanRing, TContainer >::zero.

◆ outputPrimalDigitalSurfaceAsObj() [1/2]

template<typename TKSpace >
template<typename TAnyDigitalSurface >
static bool DGtal::Shortcuts< TKSpace >::outputPrimalDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< TAnyDigitalSurface >  surface 
)
inlinestatic

Outputs a digital surface, seen from the primal point of view (surfels=face), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside).

Template Parameters
TAnyDigitalSurfaceeither kind of DigitalSurface, like Shortcuts::LightDigitalSurface or Shortcuts::DigitalSurface.
Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on a digital surface.
Returns
'true' if the output stream is good.

Definition at line 2783 of file Shortcuts.h.

2785  {
2786  auto embedder = getCellEmbedder( surface );
2787  return outputPrimalDigitalSurfaceAsObj( output, surface, embedder );
2788  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder().

◆ outputPrimalDigitalSurfaceAsObj() [2/2]

template<typename TKSpace >
template<typename TAnyDigitalSurface , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool DGtal::Shortcuts< TKSpace >::outputPrimalDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< TAnyDigitalSurface >  surface,
const TCellEmbedder &  embedder 
)
inlinestatic

Outputs a digital surface, seen from the primal point of view (surfels=face), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside). Each vertex is mapped to a 3D point using the given cell embedder.

Template Parameters
TAnyDigitalSurfaceeither kind of DigitalSurface, like Shortcuts::LightDigitalSurface or Shortcuts::DigitalSurface.
TCellEmbedderany model of CCellEmbedder
Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on a digital surface.
[in]embedderthe embedder for mapping surfel vertices (cells of dimension 0) to points in space.
Returns
'true' if the output stream is good.

Definition at line 2811 of file Shortcuts.h.

2814  {
2815  auto surfels = getSurfelRange( surface, Parameters( "Traversal", "Default" ) );
2816  return outputSurfelsAsObj( output, surfels, embedder );
2817  }

References DGtal::Shortcuts< TKSpace >::getSurfelRange(), and DGtal::Shortcuts< TKSpace >::outputSurfelsAsObj().

◆ outputPrimalIdxDigitalSurfaceAsObj() [1/2]

template<typename TKSpace >
static bool DGtal::Shortcuts< TKSpace >::outputPrimalIdxDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< IdxDigitalSurface surface 
)
inlinestatic

Outputs an indexed digital surface, seen from the primal point of view (surfels=face), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside).

Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on an indexed digital surface.
Returns
'true' if the output stream is good.

Definition at line 2829 of file Shortcuts.h.

2831  {
2832  auto embedder = getCellEmbedder( surface );
2833  return outputPrimalIdxDigitalSurfaceAsObj( output, surface, embedder );
2834  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder().

◆ outputPrimalIdxDigitalSurfaceAsObj() [2/2]

template<typename TKSpace >
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool DGtal::Shortcuts< TKSpace >::outputPrimalIdxDigitalSurfaceAsObj ( std::ostream &  output,
CountedPtr< IdxDigitalSurface surface,
const TCellEmbedder &  embedder 
)
inlinestatic

Outputs an indexed digital surface, seen from the primal point of view (surfels=face), as an OBJ file (3D only). Note that faces are oriented consistently (normals toward outside). Each vertex is mapped to a 3D point using the given cell embedder.

Template Parameters
TCellEmbedderany model of CCellEmbedder
Parameters
[out]outputthe output stream.
[in]surfacea smart pointer on an indexed digital surface.
[in]embedderthe embedder for mapping surfel vertices (cells of dimension 0) to points in space.
Returns
'true' if the output stream is good.

Definition at line 2852 of file Shortcuts.h.

2855  {
2856  auto idxsurfels = getIdxSurfelRange( surface, Parameters( "Traversal", "Default" ) );
2857  auto surfelmap = surface->surfels();
2858  SurfelRange surfels;
2859  for ( auto&& idx : idxsurfels )
2860  surfels.push_back( surfelmap[ idx ] );
2861  return outputSurfelsAsObj( output, surfels, embedder );
2862  }

References DGtal::Shortcuts< TKSpace >::getIdxSurfelRange(), DGtal::Shortcuts< TKSpace >::outputSurfelsAsObj(), and DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer >::surfels().

◆ outputSCellMapAsCSV()

template<typename TKSpace >
template<typename TSCellMap , typename TValueWriter >
static bool DGtal::Shortcuts< TKSpace >::outputSCellMapAsCSV ( std::ostream &  output,
const KSpace K,
const TSCellMap &  anyMap,
const TValueWriter &  writer 
)
inlinestatic

Definition at line 3113 of file Shortcuts.h.

3117  {
3118  SCellWriter w;
3119  for ( auto&& v : anyMap )
3120  {
3121  w( output, K, v.first );
3122  writer( output, v.second );
3123  output << std::endl;
3124  }
3125  return output.good();
3126  }

References K.

◆ outputSurfelsAsObj()

template<typename TKSpace >
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool DGtal::Shortcuts< TKSpace >::outputSurfelsAsObj ( std::ostream &  output,
const SurfelRange surfels,
const TCellEmbedder &  embedder 
)
inlinestatic

Outputs a range of surfels as an OBJ file, embedding each vertex using the given cell embedder (3D only).

Template Parameters
TCellEmbedderany model of CCellEmbedder
Parameters
[out]outputthe output stream.
[in]surfelsthe range of surfels (oriented cells of dimension 2).
[in]embedderthe embedder for mapping surfel vertices (cells of dimension 0) to points in space.
Returns
'true' if the output stream is good.

Definition at line 2732 of file Shortcuts.h.

2735  {
2736  typedef unsigned long Size;
2737  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2738  BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
2739  const KSpace& K = embedder.space();
2740  // Number and output vertices.
2741  std::map< Cell, Size > vtx_numbering;
2742  Size n = 1; // OBJ vertex numbering start at 1
2743  for ( auto&& s : surfels )
2744  {
2745  auto primal_vtcs = getPointelRange( K, s, true );
2746  for ( auto&& primal_vtx : primal_vtcs )
2747  {
2748  if ( ! vtx_numbering.count( primal_vtx ) )
2749  {
2750  vtx_numbering[ primal_vtx ] = n++;
2751  // Output vertex positions
2752  RealPoint p = embedder( primal_vtx );
2753  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2754  }
2755  }
2756  }
2757  // Outputs all faces
2758  for ( auto&& s : surfels )
2759  {
2760  output << "f";
2761  auto primal_vtcs = getPointelRange( K, s, true );
2762  for ( auto&& primal_vtx : primal_vtcs )
2763  output << " " << vtx_numbering[ primal_vtx ];
2764  output << std::endl;
2765  }
2766  return output.good();
2767  }

References DGtal::Shortcuts< TKSpace >::BOOST_CONCEPT_ASSERT(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::Shortcuts< TKSpace >::getPointelRange(), and K.

Referenced by DGtal::Shortcuts< TKSpace >::outputPrimalDigitalSurfaceAsObj(), and DGtal::Shortcuts< TKSpace >::outputPrimalIdxDigitalSurfaceAsObj().

◆ parametersBinaryImage()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersBinaryImage ( )
inlinestatic
Returns
the parameters and their default values which are related to binary images and synthetic noise.
  • noise [0.0]: specifies the Kanungo noise level for binary pictures.
  • thresholdMin [ 0]: specifies the threshold min (excluded) to define binary shape
  • thresholdMax [255]: specifies the threshold max (included) to define binary shape

Definition at line 547 of file Shortcuts.h.

548  {
549  return Parameters
550  ( "noise", 0.0 )
551  ( "thresholdMin", 0 )
552  ( "thresholdMax", 255 );
553  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersDigitalSurface()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersDigitalSurface ( )
inlinestatic
Returns
the parameters and their default values which are related to digital surfaces.
  • surfelAdjacency [ 0]: specifies the surfel adjacency (1:ext, 0:int)
  • nbTriesToFindABel [ 100000]: number of tries in method Surfaces::findABel
  • surfaceComponents [ "AnyBig"]: "AnyBig"|"All", "AnyBig": any big-enough componen
  • surfaceTraversal ["Default"]: "Default"|"DepthFirst"|"BreadthFirst": "Default" default surface traversal, "DepthFirst": depth-first surface traversal, "BreadthFirst": breadth-first surface traversal.

Definition at line 996 of file Shortcuts.h.

997  {
998  return Parameters
999  ( "surfelAdjacency", 0 )
1000  ( "nbTriesToFindABel", 100000 )
1001  ( "surfaceComponents", "AnyBig" )
1002  ( "surfaceTraversal", "Default" );
1003  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersDigitizedImplicitShape3D()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersDigitizedImplicitShape3D ( )
inlinestatic
Returns
the parameters and their default values which are used for digitization.
  • minAABB [-10.0]: the min value of the AABB bounding box (domain)
  • maxAABB [ 10.0]: the max value of the AABB bounding box (domain)
  • gridstep [ 1.0]: the gridstep that defines the digitization (often called h).
  • offset [ 5.0]: the digital dilation of the digital space, useful when you process shapes and that you add noise.

Definition at line 461 of file Shortcuts.h.

462  {
463  return Parameters
464  ( "minAABB", -10.0 )
465  ( "maxAABB", 10.0 )
466  ( "gridstep", 1.0 )
467  ( "offset", 5.0 );
468  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersGrayScaleImage()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersGrayScaleImage ( )
inlinestatic
Returns
the parameters and their default values which are used for quantification.
  • qShift [128.0]: the shift used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).
  • qSlope [ 1.0]: the slope used when quantifying the implicit shape (q(x)=qSlope*x+qShift, e.g. to build a grayscale image).

Definition at line 723 of file Shortcuts.h.

724  {
725  return Parameters
726  ( "qShift", 128.0 )
727  ( "qSlope", 1.0 );
728  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersImplicitShape3D()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersImplicitShape3D ( )
inlinestatic
Returns
the parameters and their default values which are used to define an implicit shape.
  • polynomial ["sphere1"]: the implicit polynomial whose zero-level set defines the shape of interest.
  • projectionMaxIter [ 20]: the maximum number of iteration for the projection.
  • projectionAccuracy[0.0001]: the zero-proximity stop criterion during projection.
  • projectionGamma [ 0.5]: the damping coefficient of the projection.

Definition at line 265 of file Shortcuts.h.

266  {
267  return Parameters
268  ( "polynomial", "sphere1" )
269  ( "projectionMaxIter", 20 )
270  ( "projectionAccuracy", 0.0001 )
271  ( "projectionGamma", 0.5 );
272  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersKSpace()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersKSpace ( )
inlinestatic
Returns
the parameters and their default values which are used for digitization.
  • closed [1 ]: specifies if the Khalimsky space is closed (!=0) or not (==0).
  • gridsizex[1.0]: specifies the space between points along x.
  • gridsizey[1.0]: specifies the space between points along y.
  • gridsizez[1.0]: specifies the space between points along z.

Definition at line 311 of file Shortcuts.h.

312  {
313  return Parameters
314  ( "closed", 1 )
315  ( "gridsizex", 1.0 )
316  ( "gridsizey", 1.0 )
317  ( "gridsizez", 1.0 );
318  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersMesh()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersMesh ( )
inlinestatic
Returns
the parameters and their default values which are related to meshes.
  • faceSubdivision ["Centroid"]: "No"|"Naive"|"Centroid" specifies how polygonal faces should be subdivided when triangulated or when exported.

Definition at line 2036 of file Shortcuts.h.

2037  {
2038  return Parameters
2039  ( "faceSubdivision", "Centroid" );
2040  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ parametersUtilities()

template<typename TKSpace >
static Parameters DGtal::Shortcuts< TKSpace >::parametersUtilities ( )
inlinestatic
Returns
the parameters and their default values which are related to utilities
  • colormap [ "Custom" ]: "Cool"|"Copper"|"Hot"|"Jet"|"Spring"|"Summer"|"Autumn"|"Winter"|"Error"|"Custom" specifies standard colormaps (if invalid, falls back to "Custom").
  • zero-tic [ 0.0 ]: if positive defines a black zone ]-zt,zt[ in the colormap.

Definition at line 2593 of file Shortcuts.h.

2594  {
2595  return Parameters
2596  ( "colormap", "Custom" )
2597  ( "zero-tic", 0.0 );
2598  }

Referenced by DGtal::Shortcuts< TKSpace >::defaultParameters().

◆ refKSpace() [1/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static const KSpace& DGtal::Shortcuts< TKSpace >::refKSpace ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on a (light or not) digital surface (e.g. DigitalSurface or LightDigitalSurface).
Returns
a const reference to the Khalimsky space associated to the given surface.

Definition at line 419 of file Shortcuts.h.

420  {
421  return surface->container().space();
422  }

Referenced by DGtal::Shortcuts< TKSpace >::getCellEmbedder(), DGtal::Shortcuts< TKSpace >::getCellRange(), DGtal::Shortcuts< TKSpace >::getPointelRange(), DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::saveOBJ(), and DGtal::Shortcuts< TKSpace >::saveOFF().

◆ refKSpace() [2/2]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static const KSpace& DGtal::Shortcuts< TKSpace >::refKSpace ( CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > >  surface)
inlinestatic
Template Parameters
TDigitalSurfaceContainereither kind of DigitalSurfaceContainer
Parameters
[in]surfacea smart pointer on any indexed digital surface.
Returns
a const reference to the Khalimsky space associated to the given surface.

Definition at line 430 of file Shortcuts.h.

431  {
432  return surface->container().space();
433  }

◆ saveBinaryImage()

template<typename TKSpace >
static bool DGtal::Shortcuts< TKSpace >::saveBinaryImage ( CountedPtr< BinaryImage bimage,
std::string  output 
)
inlinestatic

Saves an arbitrary binary image file (e.g. vol file in 3D).

Parameters
[in]bimagethe input binary image.
[in]outputthe output filename .
Returns
'true' if everything went well, 'false' if there was an error during save.

Definition at line 708 of file Shortcuts.h.

709  {
710  auto gray_scale_image = makeGrayScaleImage( bimage );
711  return saveGrayScaleImage( gray_scale_image, output );
712  }

References DGtal::Shortcuts< TKSpace >::makeGrayScaleImage(), and DGtal::Shortcuts< TKSpace >::saveGrayScaleImage().

Referenced by main().

◆ saveGrayScaleImage()

template<typename TKSpace >
static bool DGtal::Shortcuts< TKSpace >::saveGrayScaleImage ( CountedPtr< GrayScaleImage gray_scale_image,
std::string  output 
)
inlinestatic

Saves an arbitrary gray-scale image file (e.g. vol file in 3D).

Parameters
[in]gray_scale_imagethe input gray-scale image.
[in]outputthe output filename .
Returns
'true' if everything went well, 'false' if there was an error during save.

Definition at line 784 of file Shortcuts.h.

785  {
787  ::exportFile( output, *gray_scale_image );
788  }

References DGtal::GenericWriter< TContainer, Tdim, TValue, TFunctor >::exportFile().

Referenced by DGtal::Shortcuts< TKSpace >::saveBinaryImage().

◆ saveOBJ() [1/7]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  digsurf,
const RealVectors normals,
const Colors diffuse_colors,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs a digital surface as an OBJ file (with its topology) and a material MTL file. Optionnaly you can specify the surfels normals and diffuse colors. Here surfels are canonically embedded into the space.

Template Parameters
TDigitalSurfaceContainerany model of concepts::CDigitalSurfaceContainer
Parameters
[in]digsurfthe digital surface to output as an OBJ file
[in]normalsthe normal vector per face.
[in]diffuse_colorseither empty or a vector of size trisurf.nbFaces specifying the diffuse color for each face.
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces (if diffuse_colors is empty).
[in]specular_colorthe specular color of all faces.
Returns
'true' if the output stream is good.

Definition at line 1859 of file Shortcuts.h.

1866  {
1867  auto embedder = getCellEmbedder( digsurf );
1868  return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
1869  ambient_color, diffuse_color, specular_color );
1870  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder(), and DGtal::Shortcuts< TKSpace >::saveOBJ().

◆ saveOBJ() [2/7]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  digsurf,
const TCellEmbedder &  embedder,
const RealVectors normals,
const Colors diffuse_colors,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs a digital surface as an OBJ file (with its topology) and a material MTL file. Optionnaly you can specify the surfels normals and diffuse colors, and even specify how 0-cells are embedded into the space.

Template Parameters
TDigitalSurfaceContainerany model of concepts::CDigitalSurfaceContainer
TCellEmbedderany type for maping Cell -> RealPoint.
Parameters
[in]digsurfthe digital surface to output as an OBJ file
[in]embedderany map Cell->RealPoint
[in]normalsthe normal vector per face.
[in]diffuse_colorseither empty or a vector of size trisurf.nbFaces specifying the diffuse color for each face.
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces (if diffuse_colors is empty).
[in]specular_colorthe specular color of all faces.
Returns
'true' if the output stream is good.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 1739 of file Shortcuts.h.

1747  {
1748  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1749  std::string mtlfile;
1750  auto lastindex = objfile.find_last_of(".");
1751  if ( lastindex == std::string::npos )
1752  {
1753  mtlfile = objfile + ".mtl";
1754  objfile = objfile + ".obj";
1755  }
1756  else
1757  {
1758  mtlfile = objfile.substr(0, lastindex) + ".mtl";
1759  }
1760 
1761  std::ofstream output_obj( objfile.c_str() );
1762  output_obj << "# OBJ format" << std::endl;
1763  output_obj << "# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
1764  output_obj << "o anObject" << std::endl;
1765  //remove directory to write material
1766  auto indexpath = objfile.find_last_of("/");
1767  output_obj << "mtllib " << mtlfile.substr(indexpath+1) << std::endl;
1768  std::ofstream output_mtl( mtlfile.c_str() );
1769  output_mtl << "# MTL format"<< std::endl;
1770  output_mtl << "# generated from MeshWriter from the DGTal library"<< std::endl;
1771  // Number and output vertices.
1772  const KSpace& K = refKSpace( digsurf );
1773  Cell2Index c2i;
1774  auto pointels = getPointelRange( c2i, digsurf );
1775  for ( auto&& pointel : pointels )
1776  {
1777  RealPoint p = embedder( pointel );
1778  output_obj << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1779  }
1780  // Taking care of normals
1781  Idx nbfaces = digsurf->size();
1782  bool has_normals = ( nbfaces == normals.size() );
1783  if ( has_normals )
1784  {
1785  for ( Idx f = 0; f < nbfaces; ++f )
1786  {
1787  const auto& p = normals[ f ];
1788  output_obj << "vn " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1789  }
1790  }
1791  // Taking care of materials
1792  bool has_material = ( nbfaces == diffuse_colors.size() );
1793  Idx idxMaterial = 0;
1794  std::map<Color, unsigned int > mapMaterial;
1795  if ( has_material )
1796  {
1797  for ( Idx f = 0; f < nbfaces; ++f )
1798  {
1799  Color c = diffuse_colors[ f ];
1800  if ( mapMaterial.count( c ) == 0 )
1801  {
1803  ( output_mtl, idxMaterial, ambient_color, c, specular_color );
1804  mapMaterial[ c ] = idxMaterial++;
1805  }
1806  }
1807  }
1808  else
1809  {
1811  ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
1812  }
1813 
1814  // Taking care of faces
1815  Idx f = 0;
1816  for ( auto&& surfel : *digsurf )
1817  {
1818  output_obj << "usemtl material_"
1819  << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
1820  << std::endl;
1821  output_obj << "f";
1822  auto primal_vtcs = getPointelRange( K, surfel );
1823  // The +1 in lines below is because indexing starts at 1 in OBJ file format.
1824  if ( has_normals )
1825  {
1826  for ( auto&& primal_vtx : primal_vtcs )
1827  output_obj << " " << (c2i[ primal_vtx ]+1) << "//" << (f+1);
1828  }
1829  else
1830  {
1831  for ( auto&& primal_vtx : primal_vtcs )
1832  output_obj << " " << (c2i[ primal_vtx ]+1);
1833  }
1834  output_obj << std::endl;
1835  f += 1;
1836  }
1837  output_mtl.close();
1838  return output_obj.good();
1839  }

References DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::MeshHelpers::exportMTLNewMaterial(), DGtal::Shortcuts< TKSpace >::getPointelRange(), K, and DGtal::Shortcuts< TKSpace >::refKSpace().

Referenced by main(), DGtal::Shortcuts< TKSpace >::saveOBJ(), and TEST_CASE().

◆ saveOBJ() [3/7]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  digsurf,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs a digital surface as an OBJ file (with its topology) and a simple MTL file. Here surfels are canonically embedded into the space.

Template Parameters
TDigitalSurfaceContainerany model of concepts::CDigitalSurfaceContainer
Parameters
[in]digsurfthe digital surface to output as an OBJ file
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces (if diffuse_colors is empty).
[in]specular_colorthe specular color of all faces.
Returns
'true' if the output stream is good.

Definition at line 1910 of file Shortcuts.h.

1915  {
1916  auto embedder = getCellEmbedder( digsurf );
1917  return saveOBJ( digsurf, embedder, RealVectors(), Colors(), objfile,
1918  ambient_color, diffuse_color, specular_color );
1919  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder(), and DGtal::Shortcuts< TKSpace >::saveOBJ().

◆ saveOBJ() [4/7]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::PolygonalSurface< TPoint > >  polysurf,
const RealVectors normals,
const Colors diffuse_colors,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs a polygonal surface as an OBJ file (with its topology) (and a material MTL file).

Template Parameters
TPointany model of point
Parameters
[in]polysurfthe polygonal surface to output as an OBJ file
[in]normalsthe normal vector per face.
[in]diffuse_colorseither empty or a vector of size polysurf.nbFaces specifying the diffuse color for each face.
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces (if diffuse_colors is empty).
[in]specular_colorthe specular color of all faces.
Returns
'true' if the output stream is good.

Definition at line 2489 of file Shortcuts.h.

2496  {
2497  std::string mtlfile;
2498  auto lastindex = objfile.find_last_of(".");
2499  if ( lastindex == std::string::npos )
2500  {
2501  mtlfile = objfile + ".mtl";
2502  objfile = objfile + ".obj";
2503  }
2504  else
2505  {
2506  mtlfile = objfile.substr(0, lastindex) + ".mtl";
2507  }
2508  std::ofstream output( objfile.c_str() );
2510  ( output, mtlfile, *polysurf, normals, diffuse_colors,
2511  ambient_color, diffuse_color, specular_color );
2512  output.close();
2513  return ok;
2514  }

References DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor().

◆ saveOBJ() [5/7]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::PolygonalSurface< TPoint > >  polysurf,
const std::string &  objfile 
)
inlinestatic

Outputs a polygonal surface as an OBJ file (with its topology).

Template Parameters
TPointany model of point
Parameters
[in]polysurfthe polygonal surface to output as an OBJ file
[in]objfilethe output filename.
Returns
'true' if the output stream is good.

Definition at line 2420 of file Shortcuts.h.

2422  {
2423  std::ofstream output( objfile.c_str() );
2424  bool ok = MeshHelpers::exportOBJ( output, *polysurf );
2425  output.close();
2426  return ok;
2427  }

References DGtal::MeshHelpers::exportOBJ().

◆ saveOBJ() [6/7]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::TriangulatedSurface< TPoint > >  trisurf,
const RealVectors normals,
const Colors diffuse_colors,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs a triangulated surface as an OBJ file (with its topology) (and a material MTL file).

Template Parameters
TPointany model of point
Parameters
[in]trisurfthe triangulated surface to output as an OBJ file
[in]normalsthe normal vector per face.
[in]diffuse_colorseither empty or a vector of size trisurf.nbFaces specifying the diffuse color for each face.
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all faces.
[in]diffuse_colorthe diffuse color of all faces (if diffuse_colors is empty).
[in]specular_colorthe specular color of all faces.
Returns
'true' if the output stream is good.

Definition at line 2531 of file Shortcuts.h.

2538  {
2539  std::string mtlfile;
2540  auto lastindex = objfile.find_last_of(".");
2541  if ( lastindex == std::string::npos )
2542  {
2543  mtlfile = objfile + ".mtl";
2544  objfile = objfile + ".obj";
2545  }
2546  else
2547  {
2548  mtlfile = objfile.substr(0, lastindex) + ".mtl";
2549  }
2550  std::ofstream output( objfile.c_str() );
2552  ( output, mtlfile, *trisurf, normals, diffuse_colors,
2553  ambient_color, diffuse_color, specular_color );
2554  output.close();
2555  return ok;
2556  }

References DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor().

◆ saveOBJ() [7/7]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::TriangulatedSurface< TPoint > >  trisurf,
const std::string &  objfile 
)
inlinestatic

Outputs a triangulated surface as an OBJ file (with its topology).

Template Parameters
TPointany model of point
Parameters
[in]trisurfthe triangulated surface to output as an OBJ file
[in]objfilethe output filename.
Returns
'true' if the output stream is good.

Definition at line 2465 of file Shortcuts.h.

2467  {
2468  std::ofstream output( objfile.c_str() );
2469  bool ok = MeshHelpers::exportOBJ( output, *trisurf );
2470  output.close();
2471  return ok;
2472  }

References DGtal::MeshHelpers::exportOBJ().

◆ saveOFF() [1/4]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool DGtal::Shortcuts< TKSpace >::saveOFF ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  digsurf,
const TCellEmbedder &  embedder,
std::string  off_file,
const Color face_color = DGtal::Color::None 
)
inlinestatic

Outputs a digital surface as an OFF file (with its topology). Optionnaly you can specify the face colors (see saveOBJ for a more advanced export).

Template Parameters
TDigitalSurfaceContainerany model of concepts::CDigitalSurfaceContainer
TCellEmbedderany type for maping Cell -> RealPoint.
Parameters
[in]digsurfthe digital surface to output as an OBJ file
[in]embedderany map Cell->RealPoint
[in]face_colorthe color of every face.
[in]off_filethe output filename.
Returns
'true' if the output stream is good.

Definition at line 1673 of file Shortcuts.h.

1678  {
1679  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1680 
1681  std::ofstream output_off( off_file.c_str() );
1682  output_off << "OFF" << std::endl;
1683  output_off << "# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1684  Cell2Index c2i;
1685  auto pointels = getPointelRange( c2i, digsurf );
1686  output_off << pointels.size() << " " << digsurf->size() << " " << 0 << " " << std::endl;
1687 
1688 
1689  // Number and output vertices.
1690  const KSpace& K = refKSpace( digsurf );
1691  for ( auto&& pointel : pointels )
1692  {
1693  RealPoint p = embedder( pointel );
1694  output_off << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1695  }
1696 
1697  // Taking care of faces
1698  for ( auto&& surfel : *digsurf )
1699  {
1700  auto primal_vtcs = getPointelRange( K, surfel );
1701  output_off << primal_vtcs.size();
1702  {
1703  for ( auto&& primal_vtx : primal_vtcs )
1704  output_off << " " << (c2i[ primal_vtx ]);
1705  }
1706  if(face_color != DGtal::Color::None)
1707  {
1708  output_off << " ";
1709  output_off << face_color.r() << " " << face_color.g()
1710  << " " << face_color.b() << " " << face_color.a();
1711  }
1712  output_off << std::endl;
1713  }
1714  return output_off.good();
1715  }

References DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::Shortcuts< TKSpace >::getPointelRange(), K, DGtal::Color::None, and DGtal::Shortcuts< TKSpace >::refKSpace().

Referenced by DGtal::Shortcuts< TKSpace >::saveOFF().

◆ saveOFF() [2/4]

template<typename TKSpace >
template<typename TDigitalSurfaceContainer >
static bool DGtal::Shortcuts< TKSpace >::saveOFF ( CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > >  digsurf,
std::string  off_file,
const Color face_color = Color( 32, 32, 32 ) 
)
inlinestatic

Outputs a digital surface as an OFF file (with its topology). Here surfels are canonically embedded into the space. Optionnaly you can specify the face colors (see saveOBJ for a more advanced export).

Outputs a digital surface as an OFF.

Template Parameters
TDigitalSurfaceContainerany model of concepts::CDigitalSurfaceContainer
Parameters
[in]digsurfthe digital surface to output as an OBJ file
[in]off_filethe output filename.
[in]face_colorthe color of every face.
Returns
'true' if the output stream is good.

Definition at line 1888 of file Shortcuts.h.

1891  {
1892  auto embedder = getCellEmbedder( digsurf );
1893  return saveOFF( digsurf, embedder, off_file, face_color);
1894  }

References DGtal::Shortcuts< TKSpace >::getCellEmbedder(), and DGtal::Shortcuts< TKSpace >::saveOFF().

◆ saveOFF() [3/4]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOFF ( CountedPtr< ::DGtal::PolygonalSurface< TPoint > >  polysurf,
std::string  off_file,
const Color face_color = DGtal::Color::None 
)
inlinestatic

Outputs a triangulated surface as an OFF file.

Template Parameters
TPointany model of point
Parameters
[in]polysurfthe polygonal surface to output as an OBJ file
[in]off_filethe output filename.
[in]face_colorthe color of every face.
Returns
'true' if the output stream is good.

Definition at line 2439 of file Shortcuts.h.

2443  {
2446  std::ofstream output( off_file.c_str() );
2447  for (unsigned int i=0; i< m.nbFaces(); i++)
2448  {
2449  m.setFaceColor(i, face_color);
2450  }
2451  bool ok = MeshWriter< TPoint >::export2OFF( output, m, true );
2452  output.close();
2453  return ok;
2454  }

References DGtal::MeshWriter< TPoint >::export2OFF(), and DGtal::MeshHelpers::polygonalSurface2Mesh().

◆ saveOFF() [4/4]

template<typename TKSpace >
template<typename TPoint >
static bool DGtal::Shortcuts< TKSpace >::saveOFF ( CountedPtr< ::DGtal::TriangulatedSurface< TPoint > >  trisurf,
std::string  off_file,
const Color face_color = DGtal::Color::None 
)
inlinestatic

Outputs a triangulated surface as an OFF file.

Template Parameters
TPointany model of point
Parameters
[in]trisurfthe triangulated surface to output as an OBJ file
[in]off_filethe output filename.
[in]face_colorthe color of all faces.
Returns
'true' if the output stream is good.

Definition at line 2568 of file Shortcuts.h.

2572  {
2575  std::ofstream output( off_file.c_str() );
2576  for (unsigned int i=0; i< m.nbFaces(); i++)
2577  {
2578  m.setFaceColor(i, face_color);
2579  }
2580  bool ok = MeshWriter< TPoint >::export2OFF( output, m, true );
2581  output.close();
2582  return ok;
2583  }

References DGtal::MeshWriter< TPoint >::export2OFF(), and DGtal::MeshHelpers::triangulatedSurface2Mesh().

◆ saveVectorFieldOBJ()

template<typename TKSpace >
static bool DGtal::Shortcuts< TKSpace >::saveVectorFieldOBJ ( const RealPoints positions,
const RealVectors vf,
double  thickness,
const Colors diffuse_colors,
std::string  objfile,
const Color ambient_color = Color( 32, 32, 32 ),
const Color diffuse_color = Color( 200, 200, 255 ),
const Color specular_color = Color::White 
)
inlinestatic

Outputs any vector field vf anchored at positions as an OBJ file and a material MTL file. Optionnaly you can specify the diffuse colors.

Parameters
[in]positionsthe bases of the vectors of the vector field.
[in]vfthe vector field (an array of real vectors).
[in]thicknessthe thickness of the sticks representing the vector field.
[in]diffuse_colorseither empty or a vector of size normals.size() specifying the diffuse color for each face.
[in]objfilethe output filename.
[in]ambient_colorthe ambient color of all vectors.
[in]diffuse_colorthe diffuse color of all vectors (if diffuse_colors is empty).
[in]specular_colorthe specular color of all vectors.
Returns
'true' if the output stream is good.
Note
It outputs only the vector field, not the surface onto which it is defined (if any).

Definition at line 1939 of file Shortcuts.h.

1947  {
1948  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1949  std::string mtlfile;
1950  auto lastindex = objfile.find_last_of(".");
1951  if ( lastindex == std::string::npos )
1952  {
1953  mtlfile = objfile + ".mtl";
1954  objfile = objfile + ".obj";
1955  }
1956  else
1957  {
1958  mtlfile = objfile.substr(0, lastindex) + ".mtl";
1959  }
1960  std::ofstream output_obj( objfile.c_str() );
1961  output_obj << "# OBJ format" << std::endl;
1962  output_obj << "# DGtal::saveOBJ" << std::endl;
1963  output_obj << "o vectors" << std::endl;
1964  output_obj << "mtllib " << mtlfile << std::endl;
1965  std::ofstream output_mtl( mtlfile.c_str() );
1966  output_mtl << "# MTL format"<< std::endl;
1967  output_mtl << "# generated from MeshWriter from the DGTal library"<< std::endl;
1968  // Output vertices
1969  unsigned int n = std::min( positions.size(), vf.size() );
1970  for ( unsigned int i = 0; i < n; ++i )
1971  {
1972  RealPoint p0 = positions[ i ];
1973  RealPoint p1 = p0 + vf[ i ];
1974  RealVector v = vf[ i ];
1975  RealVector absv = RealVector( fabs( v[ 0 ] ), fabs( v[ 1 ] ), fabs( v[ 2 ] ) );
1976  unsigned int mc = std::max_element( absv.begin(), absv.end() ) - absv.begin();
1977  RealVector b =
1978  mc == 2 ? RealVector( 1, 0, 0 ) :
1979  mc == 1 ? RealVector( 0, 0, 1 ) : RealVector( 0, 1, 0 );
1980  RealVector e0 = v.crossProduct( b ).getNormalized();
1981  RealVector e1 = v.crossProduct( e0 ).getNormalized();
1982  RealPoint t[4] = { thickness * e0, thickness * e1,
1983  -thickness * e0, -thickness * e1 };
1984  for ( unsigned int j = 0; j < 4; ++j ) {
1985  RealPoint pt0 = p0 + t[ j ];
1986  RealPoint pt1 = p1 + t[ j ];
1987  output_obj << "v " << pt0[ 0 ] << " " << pt0[ 1 ] << " " << pt0[ 2 ]
1988  << std::endl;
1989  output_obj << "v " << pt1[ 0 ] << " " << pt1[ 1 ] << " " << pt1[ 2 ]
1990  << std::endl;
1991  }
1992  }
1993  // Simplify materials (very useful for blender).
1994  std::map<Color,Idx> map_colors;
1995  {
1996  Idx j = 0;
1997  for ( auto && c : diffuse_colors )
1998  if ( ! map_colors.count( c ) )
1999  map_colors[ c ] = j++;
2000  }
2001 
2002  // Output materials
2003  bool has_material = ! diffuse_colors.empty();
2004  if ( has_material )
2005  for ( auto&& pair : map_colors )
2007  ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2008  else
2010  ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2011  // Output faces
2012  for ( Idx i = 0; i < n; ++i )
2013  {
2014  output_obj << "usemtl material_" // << ( has_material ? i : 0 )
2015  << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2016  << std::endl;
2017  Idx b = 8*i+1;
2018  for ( Idx j = 0; j < 8; j += 2 )
2019  output_obj << "f " << (b+j) << " " << (b+j+1)
2020  << " " << (b+(j+3)%8) << " " << (b+(j+2)%8) << std::endl;
2021  output_obj << "f " << b << " " << (b+2)
2022  << " " << (b+4) << " " << (b+6) << std::endl;
2023  output_obj << "f " << (b+1) << " " << (b+7)
2024  << " " << (b+5) << " " << (b+3) << std::endl;
2025  }
2026  output_mtl.close();
2027  return output_obj.good();
2028  }

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::begin(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::crossProduct(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, DGtal::PointVector< dim, TEuclideanRing, TContainer >::end(), and DGtal::MeshHelpers::exportMTLNewMaterial().

Referenced by main().

◆ selfDisplay()

template<typename TKSpace >
void DGtal::Shortcuts< TKSpace >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Definition at line 3255 of file Shortcuts.h.

3256  {
3257  out << "[Shortcuts]";
3258  }

The documentation for this class was generated from the following file:
DGtal::Shortcuts::Color
::DGtal::Color Color
Definition: Shortcuts.h:191
DGtal::Shortcuts::makePrimalPolygonalSurface
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2321
DGtal::CMAP_SUMMER
@ CMAP_SUMMER
Definition: GradientColorMap.h:63
DGtal::CMAP_SPRING
@ CMAP_SPRING
Definition: GradientColorMap.h:62
DGtal::Shortcuts::Cell2Index
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:189
DGtal::PointVector::zero
static Self zero
Static const for zero PointVector.
Definition: PointVector.h:1595
DGtal::KhalimskySpaceND::upperBound
const Point & upperBound() const
Return the upper bound for digital points in this space.
DGtal::GenericReader::import
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
DGtal::Shortcuts::PointelRange
CellRange PointelRange
Definition: Shortcuts.h:175
DGtal::KhalimskySpaceND::uDim
Dimension uDim(const Cell &p) const
Return the dimension of the cell [p].
DGtal::Shortcuts::TriangulatedSurface
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition: Shortcuts.h:185
DGtal::Shortcuts::makeGrayScaleImage
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
Definition: Shortcuts.h:736
DGtal::Shortcuts::getCellEmbedder
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:438
max
int max(int a, int b)
Definition: testArithmeticalDSS.cpp:1108
DGtal::MeshHelpers::polygonalSurface2Mesh
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
DGtal::Shortcuts::saveOFF
static bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
Definition: Shortcuts.h:1673
DGtal::Shortcuts::getCellRange
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
Definition: Shortcuts.h:1399
DGtal::SurfelAdjacency< KSpace::dimension >
DGtal::Shortcuts::IdxSurfel
IdxDigitalSurface::Vertex IdxSurfel
Definition: Shortcuts.h:168
DGtal::Trace::error
std::ostream & error()
DGtal::Shortcuts::makeDoubleImage
static CountedPtr< DoubleImage > makeDoubleImage(Domain aDomain)
Definition: Shortcuts.h:930
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::Shortcuts::ExplicitSurfaceContainer
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
Definition: Shortcuts.h:156
DGtal::Shortcuts::ColorMap
GradientColorMap< Scalar > ColorMap
Definition: Shortcuts.h:193
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Shortcuts::Colors
std::vector< Color > Colors
Definition: Shortcuts.h:192
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::Shortcuts::IdxDigitalSurface
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
Definition: Shortcuts.h:160
DGtal::Shortcuts::refKSpace
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:419
DGtal::Shortcuts::makeDigitalSurface
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1209
DGtal::Shortcuts::FloatImage
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
Definition: Shortcuts.h:145
DGtal::Shortcuts::BinaryImage
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:141
DGtal::MeshWriter::export2OFF
static bool export2OFF(std::ostream &out, const Mesh< TPoint > &aMesh, bool exportColor=true)
DGtal::Shortcuts::parametersDigitalSurface
static Parameters parametersDigitalSurface()
Definition: Shortcuts.h:996
DGtal::Shortcuts::makePrimalSurfaceMesh
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2372
DGtal::KhalimskySpaceND::lowerBound
const Point & lowerBound() const
Return the lower bound for digital points in this space.
DGtal::Color::Black
static const Color Black
Definition: Color.h:413
DGtal::Shortcuts::parametersBinaryImage
static Parameters parametersBinaryImage()
Definition: Shortcuts.h:547
DGtal::Shortcuts::Surfel2Index
std::map< Surfel, IdxSurfel > Surfel2Index
Definition: Shortcuts.h:188
Visitor
BreadthFirstVisitor< MyDigitalSurface > Visitor
Definition: greedy-plane-segmentation-ex2.cpp:97
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
DGtal::Shortcuts::RealVectors
std::vector< RealVector > RealVectors
Definition: Shortcuts.h:179
DGtal::Shortcuts::ZeroTickedColorMap
TickedColorMap< Scalar, ColorMap > ZeroTickedColorMap
Definition: Shortcuts.h:194
DGtal::MeshHelpers::exportMTLNewMaterial
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned int idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
DGtal::MeshHelpers::digitalSurface2DualPolygonalSurface
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
DGtal::MeshHelpers::mesh2PolygonalSurface
static bool mesh2PolygonalSurface(const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)
DGtal::MeshHelpers::digitalSurface2PrimalPolygonalSurface
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
DGtal::MeshHelpers::triangulatedSurface2Mesh
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
DGtal::MPolynomialReader::read
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Definition: MPolynomialReader.h:284
Size
HalfEdgeDataStructure::Size Size
Definition: testHalfEdgeDataStructure.cpp:50
DGtal::KhalimskySpaceND::sDirect
bool sDirect(const SCell &p, Dimension k) const
Return 'true' if the direct orientation of [p] along [k] is in the positive coordinate direction.
DGtal::KhalimskySpaceND::uFaces
Cells uFaces(const Cell &c) const
Return the proper faces of [c] (chain of lower incidence) that belong to the space.
DGtal::Shortcuts::DigitizedImplicitShape3D
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition: Shortcuts.h:139
DGtal::Shortcuts::DoubleImage
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
Definition: Shortcuts.h:147
DGtal::MeshHelpers::exportOBJ
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)
DGtal::PointVector::crossProduct
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
DGtal::CMAP_HOT
@ CMAP_HOT
Definition: GradientColorMap.h:68
DGtal::Shortcuts::RealVector
Space::RealVector RealVector
Vector with floating-point coordinates.
Definition: Shortcuts.h:121
DGtal::Shortcuts::makeFloatImage
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
Definition: Shortcuts.h:864
DGtal::KhalimskySpaceND::dimension
static const constexpr Dimension dimension
Definition: KhalimskySpaceND.h:430
DGtal::Surfaces::sMakeBoundary
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor
static bool exportOBJwithFaceNormalAndColor(std::ostream &output_obj, const std::string &mtl_filename, const TTriangulatedOrPolygonalSurface &polysurf, const std::vector< typename TTriangulatedOrPolygonalSurface::Point > &normals, const std::vector< Color > &diffuse_colors, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
DGtal::Shortcuts::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
DGtal::Shortcuts::DigitalSurface
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
Definition: Shortcuts.h:158
DGtal::Shortcuts::parametersMesh
static Parameters parametersMesh()
Definition: Shortcuts.h:2036
DGtal::Shortcuts::parametersKSpace
static Parameters parametersKSpace()
Definition: Shortcuts.h:311
DGtal::Shortcuts::GrayScaleImage
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:143
DGtal::Shortcuts::KSpace
TKSpace KSpace
Digital cellular space.
Definition: Shortcuts.h:111
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
DGtal::Shortcuts::Scalar
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:125
DGtal::Shortcuts::parametersDigitizedImplicitShape3D
static Parameters parametersDigitizedImplicitShape3D()
Definition: Shortcuts.h:461
reverse
ch reverse()
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::Shortcuts::makeIdxDigitalSurface
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1275
DGtal::Shortcuts::ScalarPolynomial
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
Definition: Shortcuts.h:134
DGtal::CMAP_JET
@ CMAP_JET
Definition: GradientColorMap.h:69
DGtal::Shortcuts::outputDualDigitalSurfaceAsObj
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersMesh())
Definition: Shortcuts.h:2883
DGtal::Shortcuts::parametersGrayScaleImage
static Parameters parametersGrayScaleImage()
Definition: Shortcuts.h:723
DGtal::Shortcuts::getSCellEmbedder
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:446
DGtal::PointVector::end
Iterator end()
DGtal::KhalimskySpaceND::uCoords
Point uCoords(const Cell &c) const
Return its digital coordinates.
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition: HyperRectDomain.h:201
DGtal::Shortcuts::LightSurfaceContainer
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
Definition: Shortcuts.h:152
DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
DGtal::Shortcuts::Idx
IdxVertex Idx
Definition: Shortcuts.h:181
DGtal::Shortcuts::getColorMap
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters &params=parametersUtilities())
Definition: Shortcuts.h:2668
DGtal::Shortcuts::SurfelRange
SCellRange SurfelRange
Definition: Shortcuts.h:176
DGtal::PointVector::begin
Iterator begin()
DGtal::CMAP_COOL
@ CMAP_COOL
Definition: GradientColorMap.h:66
DGtal::CMAP_AUTUMN
@ CMAP_AUTUMN
Definition: GradientColorMap.h:64
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::Shortcuts::LightDigitalSurface
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
Definition: Shortcuts.h:154
DGtal::Shortcuts::parametersImplicitShape3D
static Parameters parametersImplicitShape3D()
Definition: Shortcuts.h:265
DGtal::Shortcuts::getPrimalCells
static CellRange getPrimalCells(const KSpace &K, const SCell &s, const Dimension k)
Definition: Shortcuts.h:3164
DGtal::KhalimskySpaceND::sOrthDir
Dimension sOrthDir(const SCell &s) const
Given a signed surfel [s], returns its orthogonal direction (ie, the coordinate where the surfel is c...
DGtal::Shortcuts::IdxRange
std::vector< IdxVertex > IdxRange
Definition: Shortcuts.h:182
DGtal::Shortcuts::makeLightDigitalSurface
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1062
DGtal::Shortcuts::getKSpace
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:332
DGtal::MPolynomialReader
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Definition: MPolynomialReader.h:258
DGtal::Shortcuts::getPointelRange
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1469
DGtal::Shortcuts::CellRange
std::vector< Cell > CellRange
Definition: Shortcuts.h:174
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::Shortcuts::ImplicitShape3D
ImplicitPolynomial3Shape< Space > ImplicitShape3D
Definition: Shortcuts.h:137
DGtal::Shortcuts::parametersUtilities
static Parameters parametersUtilities()
Definition: Shortcuts.h:2593
DGtal::MeshHelpers::digitalSurface2PrimalSurfaceMesh
static bool digitalSurface2PrimalSurfaceMesh(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
DGtal::Shortcuts::getIdxSurfelRange
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1612
DGtal::Shortcuts::PolygonalSurface
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:186
DGtal::MeshHelpers::mesh2TriangulatedSurface
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
DGtal::CMAP_COPPER
@ CMAP_COPPER
Definition: GradientColorMap.h:67
DGtal::Shortcuts::getPrimalVertices
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition: Shortcuts.h:3180
DGtal::Color::None
static const Color None
Definition: Color.h:412
DGtal::GenericWriter::exportFile
static bool exportFile(const std::string &filename, const TContainer &anImage, const TFunctor &aFunctor=TFunctor())
DGtal::Shortcuts::saveOBJ
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
Definition: Shortcuts.h:1739
DGtal::Shortcuts::IdxSurfelRange
std::vector< IdxSurfel > IdxSurfelRange
Definition: Shortcuts.h:177
DGtal::Shortcuts::makeLightDigitalSurfaces
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1119
DGtal::KhalimskySpaceND::unsigns
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
DGtal::Shortcuts::makeDualPolygonalSurface
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2268
DGtal::Trace::warning
std::ostream & warning()
DGtal::Shortcuts::getSurfelRange
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1547
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition: HyperRectDomain.h:176
DGtal::Shortcuts::makeBinaryImage
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:561
DGtal::Shortcuts::outputPrimalIdxDigitalSurfaceAsObj
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
Definition: Shortcuts.h:2829
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::Shortcuts::saveGrayScaleImage
static bool saveGrayScaleImage(CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
Definition: Shortcuts.h:784
DGtal::Shortcuts::Mesh
::DGtal::Mesh< RealPoint > Mesh
Definition: Shortcuts.h:184
DGtal::Shortcuts::outputSurfelsAsObj
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
Definition: Shortcuts.h:2732
DGtal::CMAP_WINTER
@ CMAP_WINTER
Definition: GradientColorMap.h:65
DGtal::Shortcuts::SurfaceMesh
::DGtal::SurfaceMesh< RealPoint, RealPoint > SurfaceMesh
Definition: Shortcuts.h:187
DGtal::Shortcuts::makeTriangulatedSurface
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< Mesh > aMesh)
Definition: Shortcuts.h:2054
DGtal::Shortcuts::getPolynomialList
static std::map< std::string, std::string > getPolynomialList()
Definition: Shortcuts.h:236
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
DGtal::MeshHelpers::digitalSurface2DualTriangulatedSurface
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
DGtal::Shortcuts::outputPrimalDigitalSurfaceAsObj
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
Definition: Shortcuts.h:2783
SurfelSet
MyDigitalSurface::SurfelSet SurfelSet
Definition: greedy-plane-segmentation-ex2.cpp:95
DGtal::InputException
Definition: Exceptions.h:63
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64