DGtal  1.0.0
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 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 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 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 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 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 TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const std::string &objfile)
 
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)
 
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 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.

Definition at line 101 of file Shortcuts.h.

Member Typedef Documentation

◆ Arc

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

Definition at line 162 of file Shortcuts.h.

◆ ArcRange

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

Definition at line 164 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 138 of file Shortcuts.h.

◆ Cell

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

Definition at line 159 of file Shortcuts.h.

◆ Cell2Index

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

Definition at line 185 of file Shortcuts.h.

◆ CellRange

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

Definition at line 171 of file Shortcuts.h.

◆ Color

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

Definition at line 187 of file Shortcuts.h.

◆ ColorMap

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

Definition at line 189 of file Shortcuts.h.

◆ Colors

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

Definition at line 188 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 155 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 136 of file Shortcuts.h.

◆ Domain

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

An (hyper-)rectangular domain.

Definition at line 124 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 144 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 153 of file Shortcuts.h.

◆ Face

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

Definition at line 163 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 142 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 126 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 140 of file Shortcuts.h.

◆ Idx

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

Definition at line 178 of file Shortcuts.h.

◆ IdxArc

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

Definition at line 167 of file Shortcuts.h.

◆ IdxArcRange

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

Definition at line 168 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 157 of file Shortcuts.h.

◆ IdxRange

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

Definition at line 179 of file Shortcuts.h.

◆ IdxSurfel

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

Definition at line 165 of file Shortcuts.h.

◆ IdxSurfelRange

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

Definition at line 174 of file Shortcuts.h.

◆ IdxSurfelSet

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

Definition at line 169 of file Shortcuts.h.

◆ IdxVertex

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

Definition at line 166 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 134 of file Shortcuts.h.

◆ Integer

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

Integer numbers.

Definition at line 112 of file Shortcuts.h.

◆ KSpace

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

Digital cellular space.

Definition at line 108 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 151 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 149 of file Shortcuts.h.

◆ Mesh

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

Definition at line 181 of file Shortcuts.h.

◆ Point

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

Point with integer coordinates.

Definition at line 114 of file Shortcuts.h.

◆ PointelRange

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

Definition at line 172 of file Shortcuts.h.

◆ PolygonalSurface

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

Definition at line 183 of file Shortcuts.h.

◆ RealPoint

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

Point with floating-point coordinates.

Definition at line 120 of file Shortcuts.h.

◆ RealPoints

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

Definition at line 177 of file Shortcuts.h.

◆ RealVector

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

Vector with floating-point coordinates.

Definition at line 118 of file Shortcuts.h.

◆ RealVectors

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

Definition at line 176 of file Shortcuts.h.

◆ Scalar

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

Floating-point numbers.

Definition at line 122 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 131 of file Shortcuts.h.

◆ Scalars

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

Definition at line 175 of file Shortcuts.h.

◆ SCell

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

Definition at line 160 of file Shortcuts.h.

◆ SCellRange

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

Definition at line 170 of file Shortcuts.h.

◆ Space

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

Digital space.

Definition at line 110 of file Shortcuts.h.

◆ Surfel

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

Definition at line 158 of file Shortcuts.h.

◆ Surfel2Index

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

Definition at line 184 of file Shortcuts.h.

◆ SurfelRange

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

Definition at line 173 of file Shortcuts.h.

◆ SurfelSet

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

defines a set of surfels

Definition at line 146 of file Shortcuts.h.

◆ TriangulatedSurface

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

Definition at line 182 of file Shortcuts.h.

◆ Vector

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

Vector with integer coordinates.

Definition at line 116 of file Shortcuts.h.

◆ Vertex

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

Definition at line 161 of file Shortcuts.h.

◆ ZeroTickedColorMap

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

Definition at line 190 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
Returns
the parameters and their default values used in shortcuts.

Definition at line 199 of file Shortcuts.h.

200  {
202  | parametersKSpace()
207  | parametersMesh()
209  }
static Parameters parametersMesh()
Definition: Shortcuts.h:1770
static Parameters parametersGrayScaleImage()
Definition: Shortcuts.h:716
static Parameters parametersImplicitShape3D()
Definition: Shortcuts.h:260
static Parameters parametersBinaryImage()
Definition: Shortcuts.h:540
static Parameters parametersDigitalSurface()
Definition: Shortcuts.h:989
static Parameters parametersUtilities()
Definition: Shortcuts.h:2226
static Parameters parametersKSpace()
Definition: Shortcuts.h:306
static Parameters parametersDigitizedImplicitShape3D()
Definition: Shortcuts.h:456

References DGtal::Shortcuts< TKSpace >::parametersBinaryImage(), DGtal::Shortcuts< TKSpace >::parametersDigitalSurface(), DGtal::Shortcuts< TKSpace >::parametersDigitizedImplicitShape3D(), DGtal::Shortcuts< TKSpace >::parametersGrayScaleImage(), DGtal::Shortcuts< TKSpace >::parametersImplicitShape3D(), DGtal::Shortcuts< TKSpace >::parametersKSpace(), DGtal::Shortcuts< TKSpace >::parametersMesh(), and DGtal::Shortcuts< TKSpace >::parametersUtilities().

◆ getCellEmbedder() [1/3]

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

Definition at line 433 of file Shortcuts.h.

434  {
435  return CanonicCellEmbedder<KSpace>( K );
436  }
KSpace K

References K.

Referenced by DGtal::Shortcuts< TKSpace >::getCellEmbedder(), DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface(), DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface(), DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), and DGtal::Shortcuts< TKSpace >::saveOBJ().

◆ 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 1004 of file Shortcuts.h.

1005  {
1006  return getCellEmbedder( refKSpace( surface ) );
1007  }
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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 1026 of file Shortcuts.h.

1027  {
1028  return getCellEmbedder( refKSpace( surface ) );
1029  }
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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

◆ 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 2301 of file Shortcuts.h.

2304  {
2305  std::string cmap = params[ "colormap" ].as<std::string>();
2306  if ( cmap == "Cool" ) return ColorMap( min, max, CMAP_COOL );
2307  else if ( cmap == "Copper" ) return ColorMap( min, max, CMAP_COPPER );
2308  else if ( cmap == "Hot" ) return ColorMap( min, max, CMAP_HOT );
2309  else if ( cmap == "Jet" ) return ColorMap( min, max, CMAP_JET );
2310  else if ( cmap == "Spring" ) return ColorMap( min, max, CMAP_SPRING );
2311  else if ( cmap == "Summer" ) return ColorMap( min, max, CMAP_SUMMER );
2312  else if ( cmap == "Autumn" ) return ColorMap( min, max, CMAP_AUTUMN );
2313  else if ( cmap == "Winter" ) return ColorMap( min, max, CMAP_WINTER );
2314  else if ( cmap == "Error" )
2315  {
2316  ColorMap gradcmap( min, max );
2317  gradcmap.addColor( Color( 255, 255, 255 ) );
2318  gradcmap.addColor( Color( 255, 0, 0 ) );
2319  gradcmap.addColor( Color( 0, 0, 0 ) );
2320  return gradcmap;
2321  }
2322  // Custom colormap
2323  ColorMap gradcmap( min, max );
2324  gradcmap.addColor( Color( 0, 0, 255 ) );
2325  gradcmap.addColor( Color( 0, 255, 255 ) );
2326  gradcmap.addColor( Color( 255, 255, 255 ) );
2327  gradcmap.addColor( Color( 255, 255, 0 ) );
2328  gradcmap.addColor( Color( 255, 0, 0 ) );
2329  return gradcmap;
2330  }
GradientColorMap< Scalar > ColorMap
Definition: Shortcuts.h:189
::DGtal::Color Color
Definition: Shortcuts.h:187
int max(int a, int b)

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().

◆ getIdxSurfelRange() [1/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 1537 of file Shortcuts.h.

1539  {
1540  return getIdxSurfelRange( surface, (IdxSurfel) 0, params );
1541  }
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1537
IdxDigitalSurface::Vertex IdxSurfel
Definition: Shortcuts.h:165

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

◆ getIdxSurfelRange() [2/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 1557 of file Shortcuts.h.

1560  {
1561  IdxSurfelRange result;
1562  std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1563  if ( traversal == "DepthFirst" )
1564  {
1565  typedef DepthFirstVisitor< IdxDigitalSurface > Visitor;
1566  typedef GraphVisitorRange< Visitor > VisitorRange;
1567  VisitorRange range( new Visitor( *surface, start_surfel ) );
1568  std::for_each( range.begin(), range.end(),
1569  [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1570  }
1571  else if ( traversal == "BreadthFirst" )
1572  {
1573  typedef BreadthFirstVisitor< IdxDigitalSurface > Visitor;
1574  typedef GraphVisitorRange< Visitor > VisitorRange;
1575  VisitorRange range( new Visitor( *surface, start_surfel ) );
1576  std::for_each( range.begin(), range.end(),
1577  [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1578  }
1579  else return surface->allVertices();
1580  return result;
1581  }
std::vector< IdxSurfel > IdxSurfelRange
Definition: Shortcuts.h:174
BreadthFirstVisitor< MyDigitalSurface > Visitor
IdxDigitalSurface::Vertex IdxSurfel
Definition: Shortcuts.h:165

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

◆ 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.

Definition at line 327 of file Shortcuts.h.

329  {
330  int closed = params[ "closed" ].as<int>();
331  KSpace K;
332  if ( ! K.init( low, up, closed ) )
333  trace.error() << "[Shortcuts::getKSpace]"
334  << " Error building Khalimsky space K=" << K << std::endl;
335  return K;
336  }
Trace trace
Definition: Common.h:144
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
KSpace K
std::ostream & error()
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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

Referenced by DGtal::ShortcutsGeometry< TKSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), and DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface().

◆ getKSpace() [2/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 349 of file Shortcuts.h.

351  {
352  int closed = params[ "closed" ].as<int>();
353  KSpace K;
354  if ( ! K.init( bimage->domain().lowerBound(),
355  bimage->domain().upperBound(),
356  closed ) )
357  trace.error() << "[Shortcuts::getKSpace]"
358  << " Error building Khalimsky space K=" << K << std::endl;
359  return K;
360  }
Trace trace
Definition: Common.h:144
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
KSpace K
std::ostream & error()
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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() [3/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 373 of file Shortcuts.h.

375  {
376  int closed = params[ "closed" ].as<int>();
377  KSpace K;
378  if ( ! K.init( gimage->domain().lowerBound(),
379  gimage->domain().upperBound(),
380  closed ) )
381  trace.error() << "[Shortcuts::getKSpace]"
382  << " Error building Khalimsky space K=" << K << std::endl;
383  return K;
384  }
Trace trace
Definition: Common.h:144
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
KSpace K
std::ostream & error()
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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() [4/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 392 of file Shortcuts.h.

393  {
394  return surface->container().space();
395  }

◆ getKSpace() [5/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 403 of file Shortcuts.h.

404  {
405  return surface->container().space();
406  }

◆ 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 481 of file Shortcuts.h.

483  {
484  Scalar min_x = params[ "minAABB" ].as<Scalar>();
485  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
486  Scalar h = params[ "gridstep" ].as<Scalar>();
487  Scalar offset = params[ "offset" ].as<Scalar>();
488  bool closed = params[ "closed" ].as<int>();
489  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
490  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
491  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
492  dshape->init( p1, p2, h );
493  Domain domain = dshape->getDomain();
494  KSpace K;
495  if ( ! K.init( domain.lowerBound(), domain.upperBound(), closed ) )
496  trace.error() << "[Shortcuts::getKSpace]"
497  << " Error building Khalimsky space K=" << K << std::endl;
498  return K;
499  }
HyperRectDomain< Space > Domain
Trace trace
Definition: Common.h:144
const Point & upperBound() const
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition: Shortcuts.h:136
Domain domain
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122
const Point & lowerBound() const
KSpace K
std::ostream & error()
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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 2286 of file Shortcuts.h.

2287  {
2288  std::vector< TValue > result( match.size() );
2289  for ( Idx i = 0; i < result.size(); i++ )
2290  result[ i ] = range[ match[ i ] ];
2291  return result;
2292  }
IdxVertex Idx
Definition: Shortcuts.h:178

◆ 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.
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 1396 of file Shortcuts.h.

1398  {
1399  PointelRange result;
1400  result.reserve( surface->size() );
1401  const KSpace& K = refKSpace( surface );
1402  Idx n = 0;
1403  for ( auto&& surfel : *surface )
1404  {
1405  CellRange primal_vtcs = getPointelRange( K, surfel );
1406  for ( auto&& primal_vtx : primal_vtcs )
1407  {
1408  if ( ! c2i.count( primal_vtx ) )
1409  {
1410  result.push_back( primal_vtx );
1411  c2i[ primal_vtx ] = n++;
1412  }
1413  }
1414  }
1415  return result;
1416  }
CellRange PointelRange
Definition: Shortcuts.h:172
IdxVertex Idx
Definition: Shortcuts.h:178
std::vector< Cell > CellRange
Definition: Shortcuts.h:171
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1396
KSpace K
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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

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

◆ getPointelRange() [2/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 1437 of file Shortcuts.h.

1438  {
1439  Cell2Index c2i;
1440  return getPointelRange( c2i, surface );
1441  }
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:185
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1396

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

◆ getPointelRange() [3/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 1453 of file Shortcuts.h.

1454  {
1455  return getPrimalVertices( K, surfel, true );
1456  }
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition: Shortcuts.h:2796
KSpace K

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

◆ 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 232 of file Shortcuts.h.

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

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

◆ 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 2796 of file Shortcuts.h.

2797  {
2798  auto faces = K.uFaces( K.unsigns( s ) );
2799  CellRange primal_vtcs;
2800  for ( auto&& f : faces )
2801  {
2802  if ( K.uDim( f ) == 0 ) primal_vtcs.push_back( f );
2803  }
2804  return primal_vtcs;
2805  }
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
std::vector< Cell > CellRange
Definition: Shortcuts.h:171
Dimension uDim(const Cell &p) const
Return the dimension of the cell [p].
Cells uFaces(const Cell &c) const
Return the proper faces of [c] (chain of lower incidence) that belong to the space.
KSpace K

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

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

◆ 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 2814 of file Shortcuts.h.

2815  {
2816  BOOST_STATIC_ASSERT(( KSpace::dimension == 3 ));
2817  CellRange vtcs = getPrimalVertices( K, s );
2818  std::swap( vtcs[ 2 ], vtcs[ 3 ] );
2819  auto orth_dir = K.sOrthDir( s );
2820  auto direct = K.sDirect( s, orth_dir ) ? ccw : ! ccw;
2821  Vector s0s1 = K.uCoords( vtcs[ 1 ] ) - K.uCoords( vtcs[ 0 ] );
2822  Vector s0s2 = K.uCoords( vtcs[ 2 ] ) - K.uCoords( vtcs[ 0 ] );
2823  Vector t = s0s1.crossProduct( s0s2 );
2824  if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
2825  || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
2826  std::reverse( vtcs.begin(), vtcs.end() );
2827  return vtcs;
2828  }
bool sDirect(const SCell &p, Dimension k) const
Return 'true' if the direct orientation of [p] along [k] is in the positive coordinate direction.
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
Dimension sOrthDir(const SCell &s) const
Given a signed surfel [s], returns its orthogonal direction (ie, the coordinate where the surfel is c...
ch reverse()
std::vector< Cell > CellRange
Definition: Shortcuts.h:171
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition: Shortcuts.h:2796
Point uCoords(const Cell &c) const
Return its digital coordinates.
FreemanChain< int >::Vector Vector
KSpace K
static const constexpr Dimension dimension

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::crossProduct(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, 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 2251 of file Shortcuts.h.

2253  {
2254  if ( perfect && ( s1.size() != s2.size() ) ) return IdxRange();
2255  std::map<TValue, Idx> M;
2256  Idx idx = 0;
2257  for ( auto val : s2 ) M[ val ] = idx++;
2258  IdxRange V( s1.size() );
2259  idx = 0;
2260  for ( auto val : s1 )
2261  {
2262  auto it = M.find( val );
2263  if ( it != M.end() ) V[ idx++ ] = it->second;
2264  else
2265  {
2266  if ( perfect ) return IdxRange();
2267  V[ idx++ ] = s2.size();
2268  }
2269  }
2270  return V;
2271  }
IdxVertex Idx
Definition: Shortcuts.h:178
std::vector< IdxVertex > IdxRange
Definition: Shortcuts.h:179

◆ 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 441 of file Shortcuts.h.

442  {
443  return CanonicSCellEmbedder<KSpace>( K );
444  }
KSpace K

References K.

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

◆ 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 1015 of file Shortcuts.h.

1016  {
1017  return getSCellEmbedder( refKSpace( surface ) );
1018  }
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:441
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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 1037 of file Shortcuts.h.

1038  {
1039  return getSCellEmbedder( refKSpace( surface ) );
1040  }
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:441
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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.

Definition at line 1472 of file Shortcuts.h.

1474  {
1475  return getSurfelRange( surface, *( surface->begin() ), params );
1476  }
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1472

◆ 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 1495 of file Shortcuts.h.

1498  {
1499  typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1500  SurfelRange result;
1501  std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1502  if ( traversal == "DepthFirst" )
1503  {
1504  typedef DepthFirstVisitor< AnyDigitalSurface > Visitor;
1505  typedef GraphVisitorRange< Visitor > VisitorRange;
1506  VisitorRange range( new Visitor( *surface, start_surfel ) );
1507  std::for_each( range.begin(), range.end(),
1508  [&result] ( Surfel s ) { result.push_back( s ); } );
1509  }
1510  else if ( traversal == "BreadthFirst" )
1511  {
1512  typedef BreadthFirstVisitor< AnyDigitalSurface > Visitor;
1513  typedef GraphVisitorRange< Visitor > VisitorRange;
1514  VisitorRange range( new Visitor( *surface, start_surfel ) );
1515  std::for_each( range.begin(), range.end(),
1516  [&result] ( Surfel s ) { result.push_back( s ); } );
1517  }
1518  else
1519  {
1520  std::for_each( surface->begin(), surface->end(),
1521  [&result] ( Surfel s ) { result.push_back( s ); } );
1522  }
1523  return result;
1524  }
BreadthFirstVisitor< MyDigitalSurface > Visitor
SCellRange SurfelRange
Definition: Shortcuts.h:173
LightDigitalSurface::Surfel Surfel
Definition: Shortcuts.h:158

◆ 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 2339 of file Shortcuts.h.

2342  {
2343  auto cmap = getColorMap( min, max, params );
2344  auto ztic = params[ "zero-tic" ].as<double>();
2345  ZeroTickedColorMap ztic_cmap( cmap, Color::Black );
2346  if ( ztic <= 0.0 ) return ztic_cmap;
2347  if ( min <= 0.0 && 0.0 <= max )
2348  ztic_cmap.addTick( 0.0, ztic );
2349  ztic_cmap.finalize();
2350  return ztic_cmap;
2351  }
static const Color Black
Definition: Color.h:388
TickedColorMap< Scalar, ColorMap > ZeroTickedColorMap
Definition: Shortcuts.h:190
int max(int a, int b)
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters &params=parametersUtilities())
Definition: Shortcuts.h:2301

References DGtal::Color::Black, 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 2886 of file Shortcuts.h.

2887  {
2888  return true;
2889  }

◆ makeBinaryImage() [1/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.

Definition at line 554 of file Shortcuts.h.

555  {
556  return CountedPtr<BinaryImage>( new BinaryImage( shapeDomain ) );
557  }
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:138

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

◆ makeBinaryImage() [2/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 569 of file Shortcuts.h.

571  {
572  return makeBinaryImage( shape_digitization,
573  shape_digitization->getDomain(),
574  params );
575  }
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:554

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

◆ makeBinaryImage() [3/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 589 of file Shortcuts.h.

592  {
593  const Scalar noise = params[ "noise" ].as<Scalar>();
594  CountedPtr<BinaryImage> img ( new BinaryImage( shapeDomain ) );
595  if ( noise <= 0.0 )
596  {
597  std::transform( shapeDomain.begin(), shapeDomain.end(),
598  img->begin(),
599  [&shape_digitization]
600  ( const Point& p ) { return (*shape_digitization)(p); } );
601  }
602  else
603  {
604  typedef KanungoNoise< DigitizedImplicitShape3D, Domain > KanungoPredicate;
605  KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
606  std::transform( shapeDomain.begin(), shapeDomain.end(),
607  img->begin(),
608  [&noisy_dshape] ( const Point& p ) { return noisy_dshape(p); } );
609  }
610  return img;
611  }
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:138
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122
MyPointD Point
Definition: testClone2.cpp:383

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

◆ makeBinaryImage() [4/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 621 of file Shortcuts.h.

623  {
624  const Scalar noise = params[ "noise" ].as<Scalar>();
625  if ( noise <= 0.0 ) return bimage;
626  typedef KanungoNoise< BinaryImage, Domain > KanungoPredicate;
627  const Domain shapeDomain = bimage->domain();
628  CountedPtr<BinaryImage> img ( new BinaryImage( shapeDomain ) );
629  KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
630  std::transform( shapeDomain.begin(), shapeDomain.end(),
631  img->begin(),
632  [&noisy_dshape] ( const Point& p ) { return noisy_dshape(p); } );
633  return img;
634  }
HyperRectDomain< Space > Domain
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:138
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122
MyPointD Point
Definition: testClone2.cpp:383

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

◆ makeBinaryImage() [5/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 649 of file Shortcuts.h.

651  {
652  int thresholdMin = params["thresholdMin"].as<int>();
653  int thresholdMax = params["thresholdMax"].as<int>();
655  Domain domain = image.domain();
656  typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
657  ThresholdedImage tImage( image, thresholdMin, thresholdMax );
658  CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
659  std::transform( domain.begin(), domain.end(),
660  img->begin(),
661  [tImage] ( const Point& p ) { return tImage(p); } );
662  return makeBinaryImage( img, params );
663  }
const ConstIterator & end() const
HyperRectDomain< Space > Domain
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:554
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140
Domain domain
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:138
const ConstIterator & begin() const
MyPointD Point
Definition: testClone2.cpp:383

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

◆ makeBinaryImage() [6/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 678 of file Shortcuts.h.

680  {
681  int thresholdMin = params["thresholdMin"].as<int>();
682  int thresholdMax = params["thresholdMax"].as<int>();
683  Domain domain = gray_scale_image->domain();
684  typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
685  ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
686  CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
687  std::transform( domain.begin(), domain.end(),
688  img->begin(),
689  [tImage] ( const Point& p ) { return tImage(p); } );
690  return makeBinaryImage( img, params );
691  }
const ConstIterator & end() const
HyperRectDomain< Space > Domain
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:554
Domain domain
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition: Shortcuts.h:138
const ConstIterator & begin() const
MyPointD Point
Definition: testClone2.cpp:383

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

◆ makeDigitalSurface() [1/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.

Definition at line 1202 of file Shortcuts.h.

1205  {
1206  SurfelSet all_surfels;
1207  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1208  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1209  // Extracts all boundary surfels
1210  Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1211  K.lowerBound(), K.upperBound() );
1212  ExplicitSurfaceContainer* surfContainer
1213  = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1214  return CountedPtr< DigitalSurface >
1215  ( new DigitalSurface( surfContainer ) ); // acquired
1216  }
MyDigitalSurface::SurfelSet SurfelSet
const Point & upperBound() const
Return the upper bound for digital points in this space.
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
Definition: Shortcuts.h:155
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
Definition: Shortcuts.h:153
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
const Point & lowerBound() const
Return the lower bound for digital points in this space.
KSpace K

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

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

◆ makeDigitalSurface() [2/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 1233 of file Shortcuts.h.

1235  {
1236  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1237  const KSpace& K = refKSpace( idx_surface );
1238  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1239  auto all_idx_surfels
1240  = getIdxSurfelRange( idx_surface, Parameters( "surfaceTraversal", "Default" ) );
1241  auto idx2surfel = idx_surface->surfels();
1242  SurfelSet all_surfels;
1243  for ( auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1244  ExplicitSurfaceContainer* surfContainer
1245  = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1246  return CountedPtr<DigitalSurface>
1247  ( new DigitalSurface( surfContainer ) ); // acquired
1248  }
MyDigitalSurface::SurfelSet SurfelSet
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
Definition: Shortcuts.h:155
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
Definition: Shortcuts.h:153
KSpace K
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1537
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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

◆ 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 516 of file Shortcuts.h.

518  {
519  Scalar min_x = params[ "minAABB" ].as<Scalar>();
520  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
521  Scalar h = params[ "gridstep" ].as<Scalar>();
522  Scalar offset = params[ "offset" ].as<Scalar>();
523  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
524  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
525  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
526  dshape->attach( shape );
527  dshape->init( p1, p2, h );
528  return dshape;
529  }
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition: Shortcuts.h:136
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122

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

◆ makeDoubleImage() [1/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 923 of file Shortcuts.h.

924  {
925  return CountedPtr<DoubleImage>( new DoubleImage( aDomain ) );
926  }
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
Definition: Shortcuts.h:144

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

◆ makeDoubleImage() [2/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 936 of file Shortcuts.h.

937  {
939  return CountedPtr<DoubleImage>( new DoubleImage( image ) );
940  }
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
Definition: Shortcuts.h:144
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())

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

◆ makeDoubleImage() [3/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 957 of file Shortcuts.h.

959  {
960  Scalar min_x = params[ "minAABB" ].as<Scalar>();
961  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
962  Scalar h = params[ "gridstep" ].as<Scalar>();
963  Scalar offset = params[ "offset" ].as<Scalar>();
964  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
965  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
966  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
967  dshape->attach( shape );
968  dshape->init( p1, p2, h );
969  Domain domain = dshape->getDomain();
970  auto fimage = makeDoubleImage( domain );
971  auto it = fimage->begin();
972  for ( auto p : domain )
973  {
974  double val = (double) (*shape)( p );
975  *it++ = val;
976  }
977  return fimage;
978  }
HyperRectDomain< Space > Domain
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition: Shortcuts.h:136
static CountedPtr< DoubleImage > makeDoubleImage(Domain aDomain)
Definition: Shortcuts.h:923
Domain domain
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122

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

◆ makeDualPolygonalSurface() [1/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 2002 of file Shortcuts.h.

2004  {
2005  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2006  auto embedder = getCellEmbedder( aSurface );
2007  auto pPolySurf = CountedPtr<PolygonalSurface>
2008  ( new PolygonalSurface ); // acquired
2010  ( *aSurface, embedder, *pPolySurf, s2i );
2011  return pPolySurf;
2012  }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:183
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
static const constexpr Dimension dimension

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

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

◆ makeDualPolygonalSurface() [2/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 2022 of file Shortcuts.h.

2023  {
2024  Surfel2Index s2i;
2025  return makeDualPolygonalSurface( s2i, aSurface );
2026  }
std::map< Surfel, IdxSurfel > Surfel2Index
Definition: Shortcuts.h:184
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2002

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

◆ makeDualPolygonalSurface() [3/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 2037 of file Shortcuts.h.

2038  {
2039  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2040  auto pPolySurf = CountedPtr<PolygonalSurface>
2041  ( new PolygonalSurface( aSurface->heds(),
2042  aSurface->positions().storage() ) );
2043  return pPolySurf;
2044  }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:183
static const constexpr Dimension dimension

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

◆ makeFloatImage() [1/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 857 of file Shortcuts.h.

858  {
859  return CountedPtr<FloatImage>( new FloatImage( aDomain ) );
860  }
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
Definition: Shortcuts.h:142

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

◆ makeFloatImage() [2/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 870 of file Shortcuts.h.

871  {
873  return CountedPtr<FloatImage>( new FloatImage( image ) );
874  }
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
Definition: Shortcuts.h:142

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

◆ makeFloatImage() [3/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 891 of file Shortcuts.h.

893  {
894  Scalar min_x = params[ "minAABB" ].as<Scalar>();
895  Scalar max_x = params[ "maxAABB" ].as<Scalar>();
896  Scalar h = params[ "gridstep" ].as<Scalar>();
897  Scalar offset = params[ "offset" ].as<Scalar>();
898  RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
899  RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
900  CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
901  dshape->attach( shape );
902  dshape->init( p1, p2, h );
903  Domain domain = dshape->getDomain();
904  auto fimage = makeFloatImage( domain );
905  auto it = fimage->begin();
906  for ( auto p : domain )
907  {
908  float val = (float) (*shape)( p );
909  *it++ = val;
910  }
911  return fimage;
912  }
HyperRectDomain< Space > Domain
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition: Shortcuts.h:136
Domain domain
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
Definition: Shortcuts.h:857
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122

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

◆ makeGrayScaleImage() [1/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 729 of file Shortcuts.h.

730  {
731  return CountedPtr<GrayScaleImage>( new GrayScaleImage( aDomain ) );
732  }
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140

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

◆ makeGrayScaleImage() [2/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 742 of file Shortcuts.h.

743  {
745  return CountedPtr<GrayScaleImage>( new GrayScaleImage( image ) );
746  }
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())

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

◆ makeGrayScaleImage() [3/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 756 of file Shortcuts.h.

758  { return v ? (unsigned char) 255 : (unsigned char) 0; }
759  // JOL: (GrayScale) was not working with visual C++: error C2065
760  )
761  {
762  const Domain domain = binary_image->domain();
763  CountedPtr<GrayScaleImage> gray_scale_image( new GrayScaleImage( domain ) );
764  std::transform( binary_image->begin(), binary_image->end(),
765  gray_scale_image->begin(),
766  bool2grayscale );
767  return gray_scale_image;
768  }
HyperRectDomain< Space > Domain
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140
Domain domain

◆ makeGrayScaleImage() [4/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 797 of file Shortcuts.h.

799  {
800  float qShift = params[ "qShift" ].as<float>();
801  float qSlope = params[ "qSlope" ].as<float>();
802  std::function< unsigned char( float ) > f
803  = [qShift,qSlope] (float v)
804  { return (unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
805  Domain domain = fimage->domain();
806  auto gimage = makeGrayScaleImage( domain );
807  auto it = gimage->begin();
808  for ( auto p : domain )
809  {
810  float val = (*fimage)( p );
811  *it++ = f( val );
812  }
813  return gimage;
814  }
HyperRectDomain< Space > Domain
Domain domain
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
Definition: Shortcuts.h:729
int max(int a, int b)

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

◆ makeGrayScaleImage() [5/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 829 of file Shortcuts.h.

831  {
832  double qShift = params[ "qShift" ].as<double>();
833  double qSlope = params[ "qSlope" ].as<double>();
834  std::function< unsigned char( double ) > f
835  = [qShift,qSlope] (double v)
836  { return (unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
837  Domain domain = fimage->domain();
838  auto gimage = makeGrayScaleImage( domain );
839  auto it = gimage->begin();
840  for ( auto p : domain )
841  {
842  double val = (*fimage)( p );
843  *it++ = f( val );
844  }
845  return gimage;
846  }
HyperRectDomain< Space > Domain
Domain domain
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
Definition: Shortcuts.h:729
int max(int a, int b)

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

◆ makeIdxDigitalSurface() [1/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 1268 of file Shortcuts.h.

1271  {
1272  std::string component = params[ "surfaceComponents" ].as<std::string>();
1273  SurfelSet surfels;
1274  if ( component == "AnyBig" )
1275  {
1276  auto light_surface = makeLightDigitalSurface( bimage, K, params );
1277  surfels.insert( light_surface->begin(), light_surface->end() );
1278  }
1279  else if ( component == "All" )
1280  {
1281  Surfaces<KSpace>::sMakeBoundary( surfels, K, *bimage,
1282  K.lowerBound(), K.upperBound() );
1283  }
1284  return makeIdxDigitalSurface( surfels, K, params );
1285  }
MyDigitalSurface::SurfelSet SurfelSet
const Point & upperBound() const
Return the upper bound for digital points in this space.
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1268
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
const Point & lowerBound() const
Return the lower bound for digital points in this space.
KSpace K
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1055

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

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

◆ 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 1301 of file Shortcuts.h.

1304  {
1305  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1306  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1307  // Build indexed digital surface.
1308  CountedPtr<ExplicitSurfaceContainer> ptrSurfContainer
1309  ( new ExplicitSurfaceContainer( K, surfAdj, surfels ) );
1310  CountedPtr<IdxDigitalSurface> ptrSurface
1311  ( new IdxDigitalSurface() );
1312  bool ok = ptrSurface->build( ptrSurfContainer );
1313  if ( !ok )
1314  trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1315  << " Error building indexed digital surface." << std::endl;
1316  return ptrSurface;
1317  }
Trace trace
Definition: Common.h:144
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
Definition: Shortcuts.h:153
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
Definition: Shortcuts.h:157
std::ostream & warning()
KSpace K

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 1334 of file Shortcuts.h.

1336  {
1337  const KSpace& K = refKSpace( surface );
1338  SurfelSet surfels;
1339  surfels.insert( surface->begin(), surface->end() );
1340  return makeIdxDigitalSurface( surfels, K, params );
1341  }
MyDigitalSurface::SurfelSet SurfelSet
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1268
KSpace K
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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

◆ makeIdxDigitalSurface() [4/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 1357 of file Shortcuts.h.

1359  {
1360  if ( surfaces.empty() ) return CountedPtr<IdxDigitalSurface>( 0 );
1361  const KSpace& K = surfaces[ 0 ]->container().space();
1362  SurfelSet surfels;
1363  for ( std::size_t i = 0; i < surfaces.size(); ++i )
1364  {
1365  const KSpace& Ki = surfaces[ i ]->container().space();
1366  if ( ( Ki.lowerBound() != K.lowerBound() )
1367  || ( Ki.upperBound() != K.upperBound() ) )
1368  trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1369  << " Incompatible digital spaces for surface " << i << std::endl;
1370  surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1371  }
1372  return makeIdxDigitalSurface( surfels, K, params );
1373  }
MyDigitalSurface::SurfelSet SurfelSet
Trace trace
Definition: Common.h:144
const Point & upperBound() const
Return the upper bound for digital points in this space.
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1268
const Point & lowerBound() const
Return the lower bound for digital points in this space.
std::ostream & warning()
KSpace K
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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

◆ 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 277 of file Shortcuts.h.

278  {
279  typedef MPolynomialReader< Space::dimension, Scalar> Polynomial3Reader;
280  std::string poly_str = params[ "polynomial" ].as<std::string>();
281  // Recognizes specific strings as polynomials.
282  auto PL = getPolynomialList();
283  if ( PL[ poly_str ] != "" ) poly_str = PL[ poly_str ];
284  ScalarPolynomial poly;
285  Polynomial3Reader reader;
286  std::string::const_iterator iter
287  = reader.read( poly, poly_str.begin(), poly_str.end() );
288  if ( iter != poly_str.end() )
289  {
290  trace.error() << "[Shortcuts::makeImplicitShape3D]"
291  << " ERROR reading polynomial: I read only <"
292  << poly_str.substr( 0, iter - poly_str.begin() )
293  << ">, and I built P=" << poly << std::endl;
294  }
295  return CountedPtr<ImplicitShape3D>( new ImplicitShape3D( poly ) );
296  }
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Trace trace
Definition: Common.h:144
static std::map< std::string, std::string > getPolynomialList()
Definition: Shortcuts.h:232
Aim: This class converts a string polynomial expression in a multivariate polynomial.
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
Definition: Shortcuts.h:131
std::ostream & error()
ImplicitPolynomial3Shape< Space > ImplicitShape3D
Definition: Shortcuts.h:134

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

◆ 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 1055 of file Shortcuts.h.

1058  {
1059  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1060  int nb_tries_to_find_a_bel = params[ "nbTriesToFindABel" ].as<int>();
1061  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1062 
1063  // We have to search for a surfel that belongs to a big connected component.
1064  CountedPtr<LightDigitalSurface> ptrSurface;
1065  Surfel bel;
1066  Scalar minsize = bimage->extent().norm();
1067  unsigned int nb_surfels = 0;
1068  unsigned int tries = 0;
1069  do
1070  {
1071  try { // Search initial bel
1072  bel = Surfaces<KSpace>::findABel( K, *bimage, nb_tries_to_find_a_bel );
1073  } catch (DGtal::InputException& e) {
1074  trace.error() << "[Shortcuts::makeLightDigitalSurface]"
1075  << " ERROR Unable to find bel." << std::endl;
1076  return ptrSurface;
1077  }
1078  // this pointer will be acquired by the surface.
1079  LightSurfaceContainer* surfContainer
1080  = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1081  ptrSurface = CountedPtr<LightDigitalSurface>
1082  ( new LightDigitalSurface( surfContainer ) ); // acquired
1083  nb_surfels = ptrSurface->size();
1084  }
1085  while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1086  if( tries >= 150 )
1087  trace.warning() << "[Shortcuts::makeLightDigitalSurface]"
1088  << "ERROR cannot find a proper bel in a big enough component."
1089  << std::endl;
1090  return ptrSurface;
1091  }
Trace trace
Definition: Common.h:144
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
Definition: Shortcuts.h:151
RealVector::Component Scalar
Floating-point numbers.
Definition: Shortcuts.h:122
std::ostream & warning()
KSpace K
LightDigitalSurface::Surfel Surfel
Definition: Shortcuts.h:158
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
Definition: Shortcuts.h:149
std::ostream & error()

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 DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), and DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces().

◆ 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 1112 of file Shortcuts.h.

1115  {
1116  SurfelRange surfel_reps;
1117  return makeLightDigitalSurfaces( surfel_reps, bimage, K, params );
1118  }
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1112
SCellRange SurfelRange
Definition: Shortcuts.h:173
KSpace K

References K.

◆ 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 1142 of file Shortcuts.h.

1146  {
1147  std::vector< CountedPtr<LightDigitalSurface> > result;
1148  std::string component = params[ "surfaceComponents" ].as<std::string>();
1149  if ( component == "AnyBig" )
1150  {
1151  result.push_back( makeLightDigitalSurface( bimage, K, params ) );
1152  surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1153  return result;
1154  }
1155  bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1156  SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1157  // Extracts all boundary surfels
1158  SurfelSet all_surfels;
1159  Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1160  K.lowerBound(), K.upperBound() );
1161  // Builds all connected components of surfels.
1162  SurfelSet marked_surfels;
1163  CountedPtr<LightDigitalSurface> ptrSurface;
1164  for ( auto bel : all_surfels )
1165  {
1166  if ( marked_surfels.count( bel ) != 0 ) continue;
1167  surfel_reps.push_back( bel );
1168  LightSurfaceContainer* surfContainer
1169  = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1170  ptrSurface = CountedPtr<LightDigitalSurface>
1171  ( new LightDigitalSurface( surfContainer ) ); // acquired
1172  // mark all surfels of the surface component.
1173  marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1174  // add surface component to result.
1175  result.push_back( ptrSurface );
1176  }
1177  return result;
1178  }
MyDigitalSurface::SurfelSet SurfelSet
const Point & upperBound() const
Return the upper bound for digital points in this space.
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
Definition: Shortcuts.h:151
const Point & lowerBound() const
Return the lower bound for digital points in this space.
KSpace K
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
Definition: Shortcuts.h:149
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1055

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< 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 1805 of file Shortcuts.h.

1807  {
1808  auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
1809  MeshHelpers::triangulatedSurface2Mesh( *triSurf, *pMesh );
1810  return pMesh;
1811  }
::DGtal::Mesh< RealPoint > Mesh
Definition: Shortcuts.h:181
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)

References DGtal::MeshHelpers::triangulatedSurface2Mesh().

◆ makeMesh() [2/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 1822 of file Shortcuts.h.

1824  {
1825  auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
1826  MeshHelpers::polygonalSurface2Mesh( *polySurf, *pMesh );
1827  return pMesh;
1828  }
::DGtal::Mesh< RealPoint > Mesh
Definition: Shortcuts.h:181
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)

References DGtal::MeshHelpers::polygonalSurface2Mesh().

◆ makePolygonalSurface() [1/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 1900 of file Shortcuts.h.

1901  {
1902  auto pPolySurf = CountedPtr<PolygonalSurface>
1903  ( new PolygonalSurface ); // acquired
1904  bool ok = MeshHelpers::mesh2PolygonalSurface( *aMesh, *pPolySurf );
1905  return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
1906  }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:183
static bool mesh2PolygonalSurface(const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)

References DGtal::MeshHelpers::mesh2PolygonalSurface().

◆ makePolygonalSurface() [2/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 1922 of file Shortcuts.h.

1927  {
1928  auto K = getKSpace( gray_scale_image );
1929  auto bimage = makeBinaryImage( gray_scale_image, params );
1930  auto digSurf = makeDigitalSurface( bimage, K, params );
1931  RealVector gh = { params[ "gridsizex" ].as<double>(),
1932  params[ "gridsizey" ].as<double>(),
1933  params[ "gridsizez" ].as<double>() };
1934  double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
1935  typedef RegularPointEmbedder<Space> PointEmbedder;
1936  typedef ImageLinearCellEmbedder
1937  < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
1938  PointEmbedder pembedder;
1939  pembedder.init( gh );
1940  ImageCellEmbedder cembedder;
1941  cembedder.init( K, *gray_scale_image, pembedder, threshold );
1942  auto pPolySurf = CountedPtr<PolygonalSurface>
1943  ( new PolygonalSurface ); // acquired
1944  Surfel2Index s2i;
1946  ( *digSurf, cembedder, *pPolySurf, s2i );
1947  return pPolySurf;
1948  }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:183
std::map< Surfel, IdxSurfel > Surfel2Index
Definition: Shortcuts.h:184
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:554
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1202
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
TKSpace KSpace
Digital cellular space.
Definition: Shortcuts.h:108
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:327
KSpace K

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

◆ 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 2055 of file Shortcuts.h.

2057  {
2058  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2059  auto embedder = getCellEmbedder( aSurface );
2060  auto pPolySurf = CountedPtr<PolygonalSurface>
2061  ( new PolygonalSurface ); // acquired
2063  ( *aSurface, embedder, *pPolySurf, c2i );
2064  return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
2065  }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition: Shortcuts.h:183
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
static const constexpr Dimension dimension

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

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

◆ 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 2075 of file Shortcuts.h.

2076  {
2077  Cell2Index c2i;
2078  return makePrimalPolygonalSurface( c2i, aSurface );
2079  }
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:185
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2055

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 2090 of file Shortcuts.h.

2091  {
2092  auto dsurf = makeDigitalSurface( aSurface );
2093  Cell2Index c2i;
2094  return makePrimalPolygonalSurface( c2i, dsurf );
2095  }
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1202
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:185
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2055

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

◆ makeTriangulatedSurface() [1/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 1788 of file Shortcuts.h.

1789  {
1790  auto pTriSurf = CountedPtr<TriangulatedSurface>
1791  ( new TriangulatedSurface ); // acquired
1792  bool ok = MeshHelpers::mesh2TriangulatedSurface( *aMesh, *pTriSurf );
1793  return ok ? pTriSurf : CountedPtr< TriangulatedSurface >( nullptr );
1794  }
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition: Shortcuts.h:182
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)

References DGtal::MeshHelpers::mesh2TriangulatedSurface().

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

◆ makeTriangulatedSurface() [2/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 1838 of file Shortcuts.h.

1840  {
1841  auto embedder = getCellEmbedder( aSurface );
1842  auto pTriSurf = CountedPtr<TriangulatedSurface>
1843  ( new TriangulatedSurface ); // acquired
1845  ( *aSurface, embedder, *pTriSurf, s2i );
1846  return pTriSurf;
1847  }
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition: Shortcuts.h:182

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

◆ makeTriangulatedSurface() [3/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 1856 of file Shortcuts.h.

1857  {
1858  Surfel2Index s2i;
1859  return makeTriangulatedSurface( s2i, aSurface );
1860  }
std::map< Surfel, IdxSurfel > Surfel2Index
Definition: Shortcuts.h:184
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< Mesh > aMesh)
Definition: Shortcuts.h:1788

References 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 1880 of file Shortcuts.h.

1882  {
1883  std::string faceSubdivision = params[ "faceSubdivision" ].as<std::string>();
1884  bool centroid = ( faceSubdivision == "Centroid" );
1885  auto pTriSurf = CountedPtr<TriangulatedSurface>
1886  ( new TriangulatedSurface ); // acquired
1887  MeshHelpers::polygonalSurface2TriangulatedSurface( *polySurf, *pTriSurf, centroid );
1888  return pTriSurf;
1889  }
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition: Shortcuts.h:182

References DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface().

◆ makeTriangulatedSurface() [5/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 1965 of file Shortcuts.h.

1970  {
1971  auto K = getKSpace( gray_scale_image );
1972  auto bimage = makeBinaryImage( gray_scale_image, params );
1973  auto digSurf = makeDigitalSurface( bimage, K, params );
1974  RealVector gh = { params[ "gridsizex" ].as<double>(),
1975  params[ "gridsizey" ].as<double>(),
1976  params[ "gridsizez" ].as<double>() };
1977  double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
1978  typedef RegularPointEmbedder<Space> PointEmbedder;
1979  typedef ImageLinearCellEmbedder
1980  < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
1981  PointEmbedder pembedder;
1982  pembedder.init( gh );
1983  ImageCellEmbedder cembedder;
1984  cembedder.init( K, *gray_scale_image, pembedder, threshold );
1985  auto pPolySurf = CountedPtr<TriangulatedSurface>
1986  ( new TriangulatedSurface ); // acquired
1987  Surfel2Index s2i;
1989  ( *digSurf, cembedder, *pPolySurf, s2i );
1990  return pPolySurf;
1991  }
std::map< Surfel, IdxSurfel > Surfel2Index
Definition: Shortcuts.h:184
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:554
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1202
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Definition: Shortcuts.h:140
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
TKSpace KSpace
Digital cellular space.
Definition: Shortcuts.h:108
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:327
KSpace K
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition: Shortcuts.h:182

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

◆ 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 2776 of file Shortcuts.h.

2780  {
2781  CellWriter w;
2782  for ( auto&& v : anyMap )
2783  {
2784  w( output, K, v.first );
2785  writer( output, v.second );
2786  output << std::endl;
2787  }
2788  return output.good();
2789  }
KSpace K

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 2516 of file Shortcuts.h.

2519  {
2520  auto embedder = getCellEmbedder( surface );
2521  return outputDualDigitalSurfaceAsObj( output, surface, embedder, params );
2522  }
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersMesh())
Definition: Shortcuts.h:2516
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433

◆ 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 2550 of file Shortcuts.h.

2554  {
2555  typedef unsigned long Size;
2556  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2557  BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
2558  std::string dualFaceSubdivision = params[ "faceSubdivision" ].as<std::string>();
2559  const int subdivide
2560  = dualFaceSubdivision == "Naive" ? 1
2561  : dualFaceSubdivision == "Centroid" ? 2
2562  : 0;
2563  const KSpace& K = embedder.space();
2564  // Number and ouput vertices.
2565  std::map< Vertex, Size > vtx_numbering;
2566  std::map< Face, Size > sub_numbering;
2567  Size n = 1; // OBJ vertex numbering start at 1
2568  for ( auto && s : *surface )
2569  {
2570  if ( ! vtx_numbering.count( s ) )
2571  {
2572  vtx_numbering[ s ] = n++;
2573  // Output vertex positions
2574  RealPoint p = embedder( K.unsigns( s ) );
2575  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2576  }
2577  }
2578  auto faces = surface->allClosedFaces();
2579  // Prepare centroids if necessary
2580  if ( subdivide == 2 )
2581  {
2582  for ( auto&& f : faces )
2583  {
2584  auto vtcs = surface->verticesAroundFace( f );
2585  Size nv = vtcs.size();
2586  if ( nv > 3 )
2587  {
2588  sub_numbering[ f ] = n++;
2590  for ( auto&& s : vtcs ) p += embedder( K.unsigns( s ) );
2591  p /= nv;
2592  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2593  }
2594  }
2595  }
2596  // Outputs closed faces.
2597  if ( subdivide == 0 )
2598  { // No subdivision
2599  for ( auto&& f : faces )
2600  {
2601  output << "f";
2602  auto vtcs = surface->verticesAroundFace( f );
2603  std::reverse( vtcs.begin(), vtcs.end() );
2604  for ( auto&& s : vtcs )
2605  output << " " << vtx_numbering[ s ];
2606  output << std::endl;
2607  }
2608  }
2609  else if ( subdivide == 1 )
2610  { // naive subdivision
2611  for ( auto&& f : faces )
2612  {
2613  auto vtcs = surface->verticesAroundFace( f );
2614  Size nv = vtcs.size();
2615  for ( Size i = 1; i < nv - 1; ++i )
2616  output << "f " << vtx_numbering[ vtcs[ 0 ] ]
2617  << " " << vtx_numbering[ vtcs[ i+1 ] ]
2618  << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2619  }
2620  }
2621  else if ( subdivide == 2 )
2622  { // centroid subdivision
2623  for ( auto&& f : faces )
2624  {
2625  auto vtcs = surface->verticesAroundFace( f );
2626  Size nv = vtcs.size();
2627  if ( nv == 3 )
2628  output << "f " << vtx_numbering[ vtcs[ 0 ] ]
2629  << " " << vtx_numbering[ vtcs[ 2 ] ]
2630  << " " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
2631  else {
2632  Size c = sub_numbering[ f ];
2633  for ( Size i = 0; i < nv; ++i )
2634  {
2635  output << "f " << c
2636  << " " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
2637  << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2638  }
2639  }
2640  }
2641  }
2642  return output.good();
2643  }
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
ch reverse()
static Dimension size()
static Self zero
Static const for zero PointVector.
Definition: PointVector.h:1582
KSpace K
static const constexpr Dimension dimension
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

References DGtal::KhalimskySpaceND< dim, TInteger >::dimension, K, reverse(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::size(), DGtal::KhalimskySpaceND< dim, TInteger >::unsigns(), and DGtal::PointVector< 3, double >::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 2416 of file Shortcuts.h.

2418  {
2419  auto embedder = getCellEmbedder( surface );
2420  return outputPrimalDigitalSurfaceAsObj( output, surface, embedder );
2421  }
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
Definition: Shortcuts.h:2416
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433

◆ 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 2444 of file Shortcuts.h.

2447  {
2448  auto surfels = getSurfelRange( surface, Parameters( "Traversal", "Default" ) );
2449  return outputSurfelsAsObj( output, surfels, embedder );
2450  }
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1472
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
Definition: Shortcuts.h:2365

◆ 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 2462 of file Shortcuts.h.

2464  {
2465  auto embedder = getCellEmbedder( surface );
2466  return outputPrimalIdxDigitalSurfaceAsObj( output, surface, embedder );
2467  }
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
Definition: Shortcuts.h:2462

◆ 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 2485 of file Shortcuts.h.

2488  {
2489  auto idxsurfels = getIdxSurfelRange( surface, Parameters( "Traversal", "Default" ) );
2490  auto surfelmap = surface->surfels();
2491  SurfelRange surfels;
2492  for ( auto&& idx : idxsurfels )
2493  surfels.push_back( surfelmap[ idx ] );
2494  return outputSurfelsAsObj( output, surfels, embedder );
2495  }
SCellRange SurfelRange
Definition: Shortcuts.h:173
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
Definition: Shortcuts.h:2365
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1537

◆ 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 2746 of file Shortcuts.h.

2750  {
2751  SCellWriter w;
2752  for ( auto&& v : anyMap )
2753  {
2754  w( output, K, v.first );
2755  writer( output, v.second );
2756  output << std::endl;
2757  }
2758  return output.good();
2759  }
KSpace K

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 2365 of file Shortcuts.h.

2368  {
2369  typedef unsigned long Size;
2370  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2371  BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
2372  const KSpace& K = embedder.space();
2373  // Number and output vertices.
2374  std::map< Cell, Size > vtx_numbering;
2375  Size n = 1; // OBJ vertex numbering start at 1
2376  for ( auto&& s : surfels )
2377  {
2378  auto primal_vtcs = getPointelRange( K, s );
2379  for ( auto&& primal_vtx : primal_vtcs )
2380  {
2381  if ( ! vtx_numbering.count( primal_vtx ) )
2382  {
2383  vtx_numbering[ primal_vtx ] = n++;
2384  // Output vertex positions
2385  RealPoint p = embedder( primal_vtx );
2386  output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2387  }
2388  }
2389  }
2390  // Outputs all faces
2391  for ( auto&& s : surfels )
2392  {
2393  output << "f";
2394  auto primal_vtcs = getPointelRange( K, s, true );
2395  for ( auto&& primal_vtx : primal_vtcs )
2396  output << " " << vtx_numbering[ primal_vtx ];
2397  output << std::endl;
2398  }
2399  return output.good();
2400  }
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1396
KSpace K
static const constexpr Dimension dimension
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

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

◆ 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 540 of file Shortcuts.h.

541  {
542  return Parameters
543  ( "noise", 0.0 )
544  ( "thresholdMin", 0 )
545  ( "thresholdMax", 255 );
546  }

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 989 of file Shortcuts.h.

990  {
991  return Parameters
992  ( "surfelAdjacency", 0 )
993  ( "nbTriesToFindABel", 100000 )
994  ( "surfaceComponents", "AnyBig" )
995  ( "surfaceTraversal", "Default" );
996  }

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 456 of file Shortcuts.h.

457  {
458  return Parameters
459  ( "minAABB", -10.0 )
460  ( "maxAABB", 10.0 )
461  ( "gridstep", 1.0 )
462  ( "offset", 5.0 );
463  }

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 716 of file Shortcuts.h.

717  {
718  return Parameters
719  ( "qShift", 128.0 )
720  ( "qSlope", 1.0 );
721  }

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 260 of file Shortcuts.h.

261  {
262  return Parameters
263  ( "polynomial", "sphere1" )
264  ( "projectionMaxIter", 20 )
265  ( "projectionAccuracy", 0.0001 )
266  ( "projectionGamma", 0.5 );
267  }

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 306 of file Shortcuts.h.

307  {
308  return Parameters
309  ( "closed", 1 )
310  ( "gridsizex", 1.0 )
311  ( "gridsizey", 1.0 )
312  ( "gridsizez", 1.0 );
313  }

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 1770 of file Shortcuts.h.

1771  {
1772  return Parameters
1773  ( "faceSubdivision", "Centroid" );
1774  }

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 2226 of file Shortcuts.h.

2227  {
2228  return Parameters
2229  ( "colormap", "Custom" )
2230  ( "zero-tic", 0.0 );
2231  }

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 414 of file Shortcuts.h.

415  {
416  return surface->container().space();
417  }

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

◆ 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 425 of file Shortcuts.h.

426  {
427  return surface->container().space();
428  }

◆ 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 701 of file Shortcuts.h.

702  {
703  auto gray_scale_image = makeGrayScaleImage( bimage );
704  return saveGrayScaleImage( gray_scale_image, output );
705  }
static bool saveGrayScaleImage(CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
Definition: Shortcuts.h:777
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
Definition: Shortcuts.h:729

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

◆ 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 777 of file Shortcuts.h.

778  {
780  ::exportFile( output, *gray_scale_image );
781  }
static bool exportFile(const std::string &filename, const TContainer &anImage, const TFunctor &aFunctor=TFunctor())

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

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

◆ saveOBJ() [1/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.

Definition at line 1604 of file Shortcuts.h.

1612  {
1613  BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1614  std::string mtlfile;
1615  auto lastindex = objfile.find_last_of(".");
1616  if ( lastindex == std::string::npos )
1617  {
1618  mtlfile = objfile + ".mtl";
1619  objfile = objfile + ".obj";
1620  }
1621  else
1622  {
1623  mtlfile = objfile.substr(0, lastindex) + ".mtl";
1624  }
1625  std::ofstream output_obj( objfile.c_str() );
1626  output_obj << "# OBJ format" << std::endl;
1627  output_obj << "# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
1628  output_obj << "o anObject" << std::endl;
1629  output_obj << "mtllib " << mtlfile << std::endl;
1630  std::ofstream output_mtl( mtlfile.c_str() );
1631  output_mtl << "# MTL format"<< std::endl;
1632  output_mtl << "# generated from MeshWriter from the DGTal library"<< std::endl;
1633  // Number and output vertices.
1634  const KSpace& K = refKSpace( digsurf );
1635  Cell2Index c2i;
1636  auto pointels = getPointelRange( c2i, digsurf );
1637  for ( auto&& pointel : pointels )
1638  {
1639  RealPoint p = embedder( pointel );
1640  output_obj << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1641  }
1642  // Taking care of normals
1643  Idx nbfaces = digsurf->size();
1644  bool has_normals = ( nbfaces == normals.size() );
1645  if ( has_normals )
1646  {
1647  for ( Idx f = 0; f < nbfaces; ++f )
1648  {
1649  const auto& p = normals[ f ];
1650  output_obj << "vn " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1651  }
1652  }
1653  // Taking care of materials
1654  bool has_material = ( nbfaces == diffuse_colors.size() );
1655  Idx idxMaterial = 0;
1656  std::map<Color, unsigned int > mapMaterial;
1657  // MeshHelpers::exportMTLNewMaterial
1658  // ( output_mtl, idxMaterial, ambient_color, Color::Black, specular_color );
1659  // mapMaterial[ Color::Black ] = idxMaterial++;
1660  if ( has_material )
1661  {
1662  for ( Idx f = 0; f < nbfaces; ++f )
1663  {
1664  Color c = diffuse_colors[ f ];
1665  if ( mapMaterial.count( c ) == 0 )
1666  {
1668  ( output_mtl, idxMaterial, ambient_color, c, specular_color );
1669  mapMaterial[ c ] = idxMaterial++;
1670  }
1671  }
1672  }
1673  else
1674  {
1676  ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
1677  }
1678 
1679  // Taking care of faces
1680  Idx f = 0;
1681  for ( auto&& surfel : *digsurf )
1682  {
1683  output_obj << "usemtl material_"
1684  << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
1685  << std::endl;
1686  output_obj << "f";
1687  auto primal_vtcs = getPointelRange( K, surfel );
1688  // The +1 in lines below is because indexing starts at 1 in OBJ file format.
1689  if ( has_normals )
1690  {
1691  for ( auto&& primal_vtx : primal_vtcs )
1692  output_obj << " " << (c2i[ primal_vtx ]+1) << "//" << (f+1);
1693  }
1694  else
1695  {
1696  for ( auto&& primal_vtx : primal_vtcs )
1697  output_obj << " " << (c2i[ primal_vtx ]+1);
1698  }
1699  output_obj << std::endl;
1700  f += 1;
1701  }
1702  output_mtl.close();
1703  return output_obj.good();
1704  }
::DGtal::Color Color
Definition: Shortcuts.h:187
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:185
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned int idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
IdxVertex Idx
Definition: Shortcuts.h:178
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1396
KSpace K
static const constexpr Dimension dimension
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:414

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

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

◆ saveOBJ() [2/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 1724 of file Shortcuts.h.

1731  {
1732  auto embedder = getCellEmbedder( digsurf );
1733  return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
1734  ambient_color, diffuse_color, specular_color );
1735  }
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
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:1604

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

◆ 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 1752 of file Shortcuts.h.

1757  {
1758  auto embedder = getCellEmbedder( digsurf );
1759  return saveOBJ( digsurf, embedder, RealVectors(), Colors(), objfile,
1760  ambient_color, diffuse_color, specular_color );
1761  }
std::vector< Color > Colors
Definition: Shortcuts.h:188
std::vector< RealVector > RealVectors
Definition: Shortcuts.h:176
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:433
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:1604

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 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 2106 of file Shortcuts.h.

2108  {
2109  std::ofstream output( objfile.c_str() );
2110  bool ok = MeshHelpers::exportOBJ( output, *polysurf );
2111  output.close();
2112  return ok;
2113  }
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)

References DGtal::MeshHelpers::exportOBJ().

◆ saveOBJ() [5/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 2124 of file Shortcuts.h.

2126  {
2127  std::ofstream output( objfile.c_str() );
2128  bool ok = MeshHelpers::exportOBJ( output, *trisurf );
2129  output.close();
2130  return ok;
2131  }
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)

References DGtal::MeshHelpers::exportOBJ().

◆ saveOBJ() [6/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 2148 of file Shortcuts.h.

2155  {
2156  std::string mtlfile;
2157  auto lastindex = objfile.find_last_of(".");
2158  if ( lastindex == std::string::npos )
2159  {
2160  mtlfile = objfile + ".mtl";
2161  objfile = objfile + ".obj";
2162  }
2163  else
2164  {
2165  mtlfile = objfile.substr(0, lastindex) + ".mtl";
2166  }
2167  std::ofstream output( objfile.c_str() );
2169  ( output, mtlfile, *polysurf, normals, diffuse_colors,
2170  ambient_color, diffuse_color, specular_color );
2171  output.close();
2172  return ok;
2173  }
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)

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 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 2190 of file Shortcuts.h.

2197  {
2198  std::string mtlfile;
2199  auto lastindex = objfile.find_last_of(".");
2200  if ( lastindex == std::string::npos )
2201  {
2202  mtlfile = objfile + ".mtl";
2203  objfile = objfile + ".obj";
2204  }
2205  else
2206  {
2207  mtlfile = objfile.substr(0, lastindex) + ".mtl";
2208  }
2209  std::ofstream output( objfile.c_str() );
2211  ( output, mtlfile, *trisurf, normals, diffuse_colors,
2212  ambient_color, diffuse_color, specular_color );
2213  output.close();
2214  return ok;
2215  }
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)

References DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor().

◆ 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 2877 of file Shortcuts.h.

2878  {
2879  out << "[Shortcuts]";
2880  }

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