DGtal 2.1.0
Loading...
Searching...
No Matches
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  is_double_nested_container
 
struct  is_double_nested_container< C< D< T > > >
 
struct  SCellReader
 
struct  SCellWriter
 
struct  ValueReader
 
struct  ValueWriter
 

Public Types

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

Public Member Functions

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

Static Public Member Functions

static Parameters defaultParameters ()
 
static std::map< std::string, std::string > getPolynomialList ()
 
static Parameters parametersImplicitShape3D ()
 
static CountedPtr< ImplicitShape3DmakeImplicitShape3D (const Parameters &params=parametersImplicitShape3D())
 
static Parameters parametersKSpace ()
 
static KSpace getKSpace (const Point &low, const Point &up, Parameters params=parametersKSpace())
 
static KSpace getKSpace (CountedPtr< BinaryImage > bimage, Parameters params=parametersKSpace())
 
static KSpace getKSpace (CountedPtr< GrayScaleImage > gimage, Parameters params=parametersKSpace())
 
template<typename TDigitalSurfaceContainer >
static KSpace getKSpace (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static KSpace getKSpace (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static const KSpacerefKSpace (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static const KSpacerefKSpace (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
static CanonicCellEmbedder< KSpacegetCellEmbedder (const KSpace &K)
 
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (const KSpace &K)
 
static Parameters parametersDigitizedImplicitShape3D ()
 
static KSpace getKSpace (Parameters params=parametersKSpace()|parametersDigitizedImplicitShape3D())
 
static CountedPtr< DigitizedImplicitShape3DmakeDigitizedImplicitShape3D (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static Parameters parametersBinaryImage ()
 
static CountedPtr< BinaryImagemakeBinaryImage (Domain shapeDomain)
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< DigitizedImplicitShape3D > shape_digitization, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< DigitizedImplicitShape3D > shape_digitization, Domain shapeDomain, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (CountedPtr< BinaryImage > bimage, Parameters params=parametersBinaryImage())
 
static CountedPtr< BinaryImagemakeBinaryImage (std::string input, Parameters params=parametersBinaryImage())
 
template<typename T , typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
static CountedPtr< BinaryImagemakeBinaryImage (const std::vector< T > &values, const Domain &d)
 
template<typename T , template< class... > class C1, template< class... > class C2, template< class... > class C3>
static CountedPtr< BinaryImagemakeBinaryImage (const C1< C2< C3< T > > > &values, std::optional< Domain > override_domain=std::nullopt)
 
template<typename T , std::enable_if_t<!is_double_nested_container< T >::value, int > = 0>
static CountedPtr< BinaryImagemakeBinaryImage (const std::vector< T > &positions, std::optional< Domain > override_domain=std::nullopt)
 
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())
 
template<typename T , typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
static CountedPtr< GrayScaleImagemakeGrayScaleImage (const std::vector< T > &values, const Domain &d)
 
template<typename T , template< class... > class C1, template< class... > class C2, template< class... > class C3>
static CountedPtr< GrayScaleImagemakeGrayScaleImage (const C1< C2< C3< T > > > &values, std::optional< Domain > override_domain=std::nullopt)
 
template<typename T , typename U , std::enable_if_t<!is_double_nested_container< T >::value, int > = 0>
static CountedPtr< GrayScaleImagemakeGrayScaleImage (const std::vector< T > &positions, const std::vector< U > &values, std::optional< Domain > override_domain=std::nullopt)
 
static CountedPtr< FloatImagemakeFloatImage (Domain aDomain)
 
static CountedPtr< FloatImagemakeFloatImage (std::string input)
 
static CountedPtr< FloatImagemakeFloatImage (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static CountedPtr< DoubleImagemakeDoubleImage (Domain aDomain)
 
static CountedPtr< DoubleImagemakeDoubleImage (std::string input)
 
static CountedPtr< DoubleImagemakeDoubleImage (CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
 
static Parameters parametersDigitalSurface ()
 
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder< KSpacegetCellEmbedder (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicCellEmbedder< KSpacegetCellEmbedder (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static CanonicSCellEmbedder< KSpacegetSCellEmbedder (CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
 
static CountedPtr< LightDigitalSurfacemakeLightDigitalSurface (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces (SurfelRange &surfel_reps, CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
template<typename TPointPredicate >
static CountedPtr< DigitalSurfacemakeDigitalSurface (CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< DigitalSurfacemakeDigitalSurface (CountedPtr< IdxDigitalSurface > idx_surface, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
 
template<typename TSurfelRange >
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (const TSurfelRange &surfels, ConstAlias< KSpace > K, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
 
static CountedPtr< IdxDigitalSurfacemakeIdxDigitalSurface (const std::vector< CountedPtr< LightDigitalSurface > > &surfaces, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static CellRange getCellRange (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getCellRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getPointelRange (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
template<typename TDigitalSurfaceContainer >
static PointelRange getPointelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
 
static PointelRange getPointelRange (const KSpace &K, const SCell &surfel)
 
template<typename TDigitalSurfaceContainer >
static SurfelRange getSurfelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer >
static SurfelRange getSurfelRange (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Surfel &start_surfel, const Parameters &params=parametersDigitalSurface())
 
static IdxSurfelRange getIdxSurfelRange (CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
 
static IdxSurfelRange getIdxSurfelRange (CountedPtr< IdxDigitalSurface > surface, const IdxSurfel &start_surfel, const Parameters &params=parametersDigitalSurface())
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool saveOFF (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TDigitalSurfaceContainer >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TDigitalSurfaceContainer >
static bool saveOFF (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string off_file, const Color &face_color=Color(32, 32, 32))
 
template<typename TDigitalSurfaceContainer >
static bool saveOBJ (CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
static bool saveVectorFieldOBJ (const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
static Parameters parametersMesh ()
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< Mesh > aMesh)
 
static CountedPtr< MeshmakeMesh (CountedPtr< TriangulatedSurface > triSurf, const Color &aColor=Color::White)
 
static CountedPtr< MeshmakeMesh (CountedPtr< PolygonalSurface > polySurf, const Color &aColor=Color::White)
 
template<typename TContainer >
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< PolygonalSurface > polySurf, const Parameters &params=parametersMesh())
 
static CountedPtr< PolygonalSurfacemakePolygonalSurface (CountedPtr< Mesh > aMesh)
 
static CountedPtr< PolygonalSurfacemakePolygonalSurface (CountedPtr< GrayScaleImage > gray_scale_image, const Parameters &params=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
 
static CountedPtr< TriangulatedSurfacemakeTriangulatedSurface (CountedPtr< GrayScaleImage > gray_scale_image, const Parameters &params=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakeDualPolygonalSurface (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< PolygonalSurfacemakePrimalPolygonalSurface (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
 
template<typename TContainer >
static CountedPtr< SurfaceMeshmakePrimalSurfaceMesh (CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
 
static CountedPtr< SurfaceMeshmakeSurfaceMesh (const std::string &path)
 
template<typename TPoint , typename TVector >
static bool saveOBJ (CountedPtr< ::DGtal::SurfaceMesh< TPoint, TVector > > surf, const std::string &objfile)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const std::string &objfile)
 
template<typename TPoint >
static bool saveOFF (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, std::string off_file, const Color &face_color=DGtal::Color::None)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const std::string &objfile)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TPoint >
static bool saveOBJ (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TPoint , typename TVector >
static bool saveOBJ (CountedPtr< ::DGtal::SurfaceMesh< TPoint, TVector > > surf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
 
template<typename TPoint >
static bool saveOFF (CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, std::string off_file, const Color &face_color=DGtal::Color::None)
 
static Parameters parametersUtilities ()
 
template<typename TValue >
static IdxRange getRangeMatch (const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
 
template<typename TValue >
static std::vector< TValue > getMatchedRange (const std::vector< TValue > &range, const IdxRange &match)
 
static ColorMap getColorMap (Scalar min, Scalar max, const Parameters &params=parametersUtilities())
 
static ZeroTickedColorMap getZeroTickedColorMap (Scalar min, Scalar max, const Parameters &params=parametersUtilities())
 
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputSurfelsAsObj (std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
 
template<typename TAnyDigitalSurface >
static bool outputPrimalDigitalSurfaceAsObj (std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
 
template<typename TAnyDigitalSurface , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputPrimalDigitalSurfaceAsObj (std::ostream &output, CountedPtr< TAnyDigitalSurface > surface, const TCellEmbedder &embedder)
 
static bool outputPrimalIdxDigitalSurfaceAsObj (std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
 
template<typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputPrimalIdxDigitalSurfaceAsObj (std::ostream &output, CountedPtr< IdxDigitalSurface > surface, const TCellEmbedder &embedder)
 
template<typename TDigitalSurfaceContainer >
static bool outputDualDigitalSurfaceAsObj (std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersMesh())
 
template<typename TDigitalSurfaceContainer , typename TCellEmbedder = CanonicCellEmbedder< KSpace >>
static bool outputDualDigitalSurfaceAsObj (std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const TCellEmbedder &embedder, const Parameters &params=parametersMesh())
 
template<typename TSCellMap , typename TValueWriter >
static bool outputSCellMapAsCSV (std::ostream &output, const KSpace &K, const TSCellMap &anyMap, const TValueWriter &writer)
 
template<typename TCellMap , typename TValueWriter >
static bool outputCellMapAsCSV (std::ostream &output, const KSpace &K, const TCellMap &anyMap, const TValueWriter &writer)
 
static CellRange getPrimalCells (const KSpace &K, const SCell &s, const Dimension k)
 
static CellRange getPrimalVertices (const KSpace &K, const SCell &s)
 
static CellRange getPrimalVertices (const KSpace &K, const Surfel &s, bool ccw)
 

Private Member Functions

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

Detailed Description

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

◆ ColorMap

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

Definition at line 190 of file Shortcuts.h.

◆ Colors

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

Definition at line 189 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.

◆ SurfaceMesh

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

Definition at line 184 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 185 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 191 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 200 of file Shortcuts.h.

201 {
210 }
static Parameters parametersUtilities()
Definition Shortcuts.h:2936
static Parameters parametersImplicitShape3D()
Definition Shortcuts.h:262
static Parameters parametersKSpace()
Definition Shortcuts.h:308
static Parameters parametersMesh()
Definition Shortcuts.h:2297
static Parameters parametersDigitalSurface()
Definition Shortcuts.h:1257
static Parameters parametersBinaryImage()
Definition Shortcuts.h:544
static Parameters parametersDigitizedImplicitShape3D()
Definition Shortcuts.h:458
static Parameters parametersGrayScaleImage()
Definition Shortcuts.h:856

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

Referenced by main(), and precompute().

◆ getCellEmbedder() [1/3]

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

1273 {
1274 return getCellEmbedder( refKSpace( surface ) );
1275 }
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition Shortcuts.h:416
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition Shortcuts.h:435
CountedPtr< SH3::DigitalSurface > surface

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

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

1295 {
1296 return getCellEmbedder( refKSpace( surface ) );
1297 }

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

◆ getCellRange() [1/2]

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

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

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

Definition at line 1659 of file Shortcuts.h.

1663 {
1664 CellRange result;
1665 // Approximate number of pointels given the number of 2-cells (valid for 2d surfaces in nD).
1666 result.reserve( 2 * surface->size() + 100 );
1667 const KSpace& K = refKSpace( surface );
1668 Idx n = 0;
1669 for ( auto&& surfel : *surface )
1670 {
1671 CellRange primal_cells = getPrimalCells( K, surfel, k );
1672 for ( auto&& primal_cell : primal_cells )
1673 {
1674 if ( ! c2i.count( primal_cell ) )
1675 {
1676 result.push_back( primal_cell );
1677 c2i[ primal_cell ] = n++;
1678 }
1679 }
1680 }
1681 return result;
1682 }
static CellRange getPrimalCells(const KSpace &K, const SCell &s, const Dimension k)
Definition Shortcuts.h:3507
std::vector< Cell > CellRange
Definition Shortcuts.h:171
IdxVertex Idx
Definition Shortcuts.h:178

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

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

◆ getCellRange() [2/2]

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

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

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

Definition at line 1698 of file Shortcuts.h.

1702 {
1703 Cell2Index c2i;
1704 return getCellRange( c2i, surface, k );
1705 }
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
Definition Shortcuts.h:1660
std::map< Cell, IdxVertex > Cell2Index
Definition Shortcuts.h:186

References DGtal::Shortcuts< TKSpace >::getCellRange(), and surface.

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

3014 {
3015 std::string cmap = params[ "colormap" ].as<std::string>();
3016 if ( cmap == "Cool" ) return ColorMap( min, max, CMAP_COOL );
3017 else if ( cmap == "Copper" ) return ColorMap( min, max, CMAP_COPPER );
3018 else if ( cmap == "Hot" ) return ColorMap( min, max, CMAP_HOT );
3019 else if ( cmap == "Jet" ) return ColorMap( min, max, CMAP_JET );
3020 else if ( cmap == "Spring" ) return ColorMap( min, max, CMAP_SPRING );
3021 else if ( cmap == "Summer" ) return ColorMap( min, max, CMAP_SUMMER );
3022 else if ( cmap == "Autumn" ) return ColorMap( min, max, CMAP_AUTUMN );
3023 else if ( cmap == "Winter" ) return ColorMap( min, max, CMAP_WINTER );
3024 else if ( cmap == "Error" )
3025 {
3026 ColorMap gradcmap( min, max );
3027 gradcmap.addColor( Color( 255, 255, 255 ) );
3028 gradcmap.addColor( Color( 255, 0, 0 ) );
3029 gradcmap.addColor( Color( 0, 0, 0 ) );
3030 return gradcmap;
3031 }
3032 // Custom colormap
3033 ColorMap gradcmap( min, max );
3034 gradcmap.addColor( Color( 0, 0, 255 ) );
3035 gradcmap.addColor( Color( 0, 255, 255 ) );
3036 gradcmap.addColor( Color( 255, 255, 255 ) );
3037 gradcmap.addColor( Color( 255, 255, 0 ) );
3038 gradcmap.addColor( Color( 255, 0, 0 ) );
3039 return gradcmap;
3040 }
GradientColorMap< Scalar > ColorMap
Definition Shortcuts.h:190
::DGtal::Color Color
Definition Shortcuts.h:188
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().

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

◆ getIdxSurfelRange() [1/2]

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

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

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

Definition at line 1892 of file Shortcuts.h.

1896 {
1897 IdxSurfelRange result;
1898 std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1899 if ( traversal == "DepthFirst" )
1900 {
1901 typedef DepthFirstVisitor< IdxDigitalSurface > Visitor;
1902 typedef GraphVisitorRange< Visitor > VisitorRange;
1903 VisitorRange range( new Visitor( *surface, start_surfel ) );
1904 std::for_each( range.begin(), range.end(),
1905 [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1906 }
1907 else if ( traversal == "BreadthFirst" )
1908 {
1909 typedef BreadthFirstVisitor< IdxDigitalSurface > Visitor;
1910 typedef GraphVisitorRange< Visitor > VisitorRange;
1911 VisitorRange range( new Visitor( *surface, start_surfel ) );
1912 std::for_each( range.begin(), range.end(),
1913 [&result] ( IdxSurfel s ) { result.push_back( s ); } );
1914 }
1915 else return surface->allVertices();
1916 return result;
1917 }
IdxDigitalSurface::Vertex IdxSurfel
Definition Shortcuts.h:165
std::vector< IdxSurfel > IdxSurfelRange
Definition Shortcuts.h:174
BreadthFirstVisitor< MyDigitalSurface > Visitor

References surface.

◆ getIdxSurfelRange() [2/2]

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

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

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

Definition at line 1872 of file Shortcuts.h.

1875 {
1876 return getIdxSurfelRange( surface, (IdxSurfel) 0, params );
1877 }
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1873

References DGtal::Shortcuts< TKSpace >::getIdxSurfelRange(), and surface.

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

◆ getKSpace() [1/6]

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

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

Parameters
[in]lowthe lowest point in the space
[in]upthe highest point in the space
[in]paramsthe parameters:
  • closed [1]: specifies if the Khalimsky space is closed (!=0) or not (==0).
Returns
the Khalimsky space.

Definition at line 329 of file Shortcuts.h.

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

References DGtal::Trace::error(), K, and DGtal::trace.

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

◆ getKSpace() [2/6]

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

Definition at line 393 of file Shortcuts.h.

395 {
396 return surface->container().space();
397 }

References surface.

◆ getKSpace() [3/6]

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

Definition at line 404 of file Shortcuts.h.

406 {
407 return surface->container().space();
408 }

References surface.

◆ getKSpace() [4/6]

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

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

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

Definition at line 351 of file Shortcuts.h.

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

References DGtal::Trace::error(), K, and DGtal::trace.

◆ getKSpace() [5/6]

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

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

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

Definition at line 375 of file Shortcuts.h.

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

References DGtal::Trace::error(), K, and DGtal::trace.

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

485 {
486 Scalar min_x = params[ "minAABB" ].as<Scalar>();
487 Scalar max_x = params[ "maxAABB" ].as<Scalar>();
488 Scalar h = params[ "gridstep" ].as<Scalar>();
489 Scalar offset = params[ "offset" ].as<Scalar>();
490 bool closed = params[ "closed" ].as<int>();
491 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
492 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
493 CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
494 dshape->init( p1, p2, h );
495 Domain domain = dshape->getDomain();
496 KSpace K;
497 if ( ! K.init( domain.lowerBound(), domain.upperBound(), closed ) )
498 trace.error() << "[Shortcuts::getKSpace]"
499 << " Error building Khalimsky space K=" << K << std::endl
500 << "Note: if you use decimal values, check your locale for decimal point '.' or ','."
501 << std::endl;
502 return K;
503 }
const Point & lowerBound() const
const Point & upperBound() const
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
Definition Shortcuts.h:136
Domain domain
HyperRectDomain< Space > Domain

References domain, DGtal::Trace::error(), 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 2996 of file Shortcuts.h.

2997 {
2998 std::vector< TValue > result( match.size() );
2999 for ( Idx i = 0; i < result.size(); i++ )
3000 result[ i ] = range[ match[ i ] ];
3001 return result;
3002 }

◆ getPointelRange() [1/3]

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

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

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

Definition at line 1729 of file Shortcuts.h.

1732 {
1733 PointelRange result;
1734 result.reserve( surface->size() );
1735 const KSpace& K = refKSpace( surface );
1736 Idx n = 0;
1737 for ( auto&& surfel : *surface )
1738 {
1739 CellRange primal_vtcs = getPointelRange( K, surfel );
1740 for ( auto&& primal_vtx : primal_vtcs )
1741 {
1742 if ( ! c2i.count( primal_vtx ) )
1743 {
1744 result.push_back( primal_vtx );
1745 c2i[ primal_vtx ] = n++;
1746 }
1747 }
1748 }
1749 return result;
1750 }
CellRange PointelRange
Definition Shortcuts.h:172
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition Shortcuts.h:1730

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

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

◆ getPointelRange() [2/3]

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

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

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

Definition at line 1786 of file Shortcuts.h.

1788 {
1789 return KSpace::dimension == 3
1790 ? getPrimalVertices( K, surfel, true )
1791 : getPrimalVertices( K, surfel );
1792 }
static const constexpr Dimension dimension
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition Shortcuts.h:3523

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

◆ getPointelRange() [3/3]

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

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

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

Definition at line 1770 of file Shortcuts.h.

1772 {
1773 Cell2Index c2i;
1774 return getPointelRange( c2i, surface );
1775 }

References DGtal::Shortcuts< TKSpace >::getPointelRange(), and surface.

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

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

References DGtal::L.

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

◆ getPrimalCells()

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

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

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

Definition at line 3507 of file Shortcuts.h.

3508 {
3509 auto faces = K.uFaces( K.unsigns( s ) );
3510 CellRange primal_cells;
3511 for ( auto&& f : faces )
3512 {
3513 if ( K.uDim( f ) == k ) primal_cells.push_back( f );
3514 }
3515 return primal_cells;
3516 }

References K.

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

◆ getPrimalVertices() [1/2]

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

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

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

Definition at line 3523 of file Shortcuts.h.

3524 {
3525 return getPrimalCells( K, s, 0 );
3526 }

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

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

◆ getPrimalVertices() [2/2]

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

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

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

Definition at line 3535 of file Shortcuts.h.

3536 {
3537 BOOST_STATIC_ASSERT(( KSpace::dimension == 3 ));
3538 CellRange vtcs = getPrimalVertices( K, s );
3539 std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3540 auto orth_dir = K.sOrthDir( s );
3541 auto direct = K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3542 Vector s0s1 = K.uCoords( vtcs[ 1 ] ) - K.uCoords( vtcs[ 0 ] );
3543 Vector s0s2 = K.uCoords( vtcs[ 2 ] ) - K.uCoords( vtcs[ 0 ] );
3544 Vector t = s0s1.crossProduct( s0s2 );
3545 if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3546 || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3547 std::reverse( vtcs.begin(), vtcs.end() );
3548 return vtcs;
3549 }
DigitalPlane::Point Vector

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

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

2963 {
2964 if ( perfect && ( s1.size() != s2.size() ) ) return IdxRange();
2965 std::map<TValue, Idx> M;
2966 Idx idx = 0;
2967 for ( auto val : s2 ) M[ val ] = idx++;
2968 IdxRange V( s1.size() );
2969 idx = 0;
2970 for ( auto val : s1 )
2971 {
2972 auto it = M.find( val );
2973 if ( it != M.end() ) V[ idx++ ] = it->second;
2974 else
2975 {
2976 if ( perfect ) return IdxRange();
2977 V[ idx++ ] = s2.size();
2978 }
2979 }
2980 return V;
2981 }
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 443 of file Shortcuts.h.

444 {
445 return CanonicSCellEmbedder<KSpace>( K );
446 }

References K.

Referenced by DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), and 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 1282 of file Shortcuts.h.

1284 {
1285 return getSCellEmbedder( refKSpace( surface ) );
1286 }
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Definition Shortcuts.h:443

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

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

1306 {
1307 return getSCellEmbedder( refKSpace( surface ) );
1308 }

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

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

1810 {
1811 return getSurfelRange( surface, *( surface->begin() ), params );
1812 }
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1808

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

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

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

1834 {
1835 typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1836 SurfelRange result;
1837 std::string traversal = params[ "surfaceTraversal" ].as<std::string>();
1838 if ( traversal == "DepthFirst" )
1839 {
1840 typedef DepthFirstVisitor< AnyDigitalSurface > Visitor;
1841 typedef GraphVisitorRange< Visitor > VisitorRange;
1842 VisitorRange range( new Visitor( *surface, start_surfel ) );
1843 std::for_each( range.begin(), range.end(),
1844 [&result] ( Surfel s ) { result.push_back( s ); } );
1845 }
1846 else if ( traversal == "BreadthFirst" )
1847 {
1848 typedef BreadthFirstVisitor< AnyDigitalSurface > Visitor;
1849 typedef GraphVisitorRange< Visitor > VisitorRange;
1850 VisitorRange range( new Visitor( *surface, start_surfel ) );
1851 std::for_each( range.begin(), range.end(),
1852 [&result] ( Surfel s ) { result.push_back( s ); } );
1853 }
1854 else
1855 {
1856 std::for_each( surface->begin(), surface->end(),
1857 [&result] ( Surfel s ) { result.push_back( s ); } );
1858 }
1859 return result;
1860 }
SCellRange SurfelRange
Definition Shortcuts.h:173
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.

References surface.

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

3052 {
3053 auto cmap = getColorMap( min, max, params );
3054 auto ztic = params[ "zero-tic" ].as<double>();
3055 ZeroTickedColorMap ztic_cmap( cmap, Color::Black );
3056 if ( ztic <= 0.0 ) return ztic_cmap;
3057 if ( min <= 0.0 && 0.0 <= max )
3058 ztic_cmap.addTick( 0.0, ztic );
3059 ztic_cmap.finalize();
3060 return ztic_cmap;
3061 }
static const Color Black
Definition Color.h:422
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters &params=parametersUtilities())
Definition Shortcuts.h:3011
TickedColorMap< Scalar, ColorMap > ZeroTickedColorMap
Definition Shortcuts.h:191

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

◆ isValid()

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

Checks the validity/consistency of the object.

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

Definition at line 3607 of file Shortcuts.h.

3608 {
3609 return true;
3610 }

◆ makeBinaryImage() [1/9]

template<typename TKSpace >
template<typename T , template< class... > class C1, template< class... > class C2, template< class... > class C3>
static CountedPtr< BinaryImage > DGtal::Shortcuts< TKSpace >::makeBinaryImage ( const C1< C2< C3< T > > > &  values,
std::optional< Domain override_domain = std::nullopt 
)
inlinestatic

Create an arbitrary image from a vector where non zero values indicates voxels

Note
This overloads expect consistent size of subarrays. This is not checked.
Parameters
[in]valuesA vector (of vector of vector) where non-zero values indicates a voxel
[in]override_domainOverrides computed domain if needed
Returns
a smart pointer on a binary image

Definition at line 720 of file Shortcuts.h.

723 {
724 Domain d;
725 if (override_domain.has_value())
726 {
727 d = override_domain.value();
728 }
729 else if (values.size() != 0)
730 {
731 if (values[0].size() != 0)
732 {
733 if (values[0][0].size() != 0)
734 {
735 d = Domain(Point(0, 0, 0), Point(values.size(), values[0].size(), values[0][0].size()));
736 }
737 }
738 }
739
740 CountedPtr<BinaryImage> image(new BinaryImage(d));
741 Point begin = d.lowerBound();
742 for (size_t i = 0; i < values.size(); ++i)
743 {
744 for (size_t j = 0; j < values[i].size(); ++j)
745 {
746 for (size_t k = 0; k < values[i][j].size(); ++k)
747 {
748 Point p = begin + Point(i, j, k);
749 image->setValue(p, static_cast<bool>(values[i][j][k]));
750 }
751 }
752 }
753
754 return image;
755 }
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Definition Shortcuts.h:138
Space::Point Point
Point with integer coordinates.
Definition Shortcuts.h:114
HyperRectDomain< Space > Domain
An (hyper-)rectangular domain.
Definition Shortcuts.h:124
Image image(domain)

References image(), and DGtal::HyperRectDomain< TSpace >::lowerBound().

◆ makeBinaryImage() [2/9]

template<typename TKSpace >
template<typename T , std::enable_if_t<!is_double_nested_container< T >::value, int > = 0>
static CountedPtr< BinaryImage > DGtal::Shortcuts< TKSpace >::makeBinaryImage ( const std::vector< T > &  positions,
std::optional< Domain override_domain = std::nullopt 
)
inlinestatic

Create an arbitrary image from a vector of positions

Note
This overloads expect consistent size of subarrays. This is not checked.
Parameters
[in]positionsA vector of positions to indicates locations of voxels
[in]override_domainOverrides computed domain if needed
Returns
a smart pointer on a binary image

Definition at line 767 of file Shortcuts.h.

770 {
771 Domain d;
772 if (override_domain.has_value())
773 {
774 d = override_domain.value();
775 }
776 else if (positions.size() != 0)
777 {
778 Point lb(positions[0][0], positions[0][1], positions[0][2]);
779 Point ub(positions[0][0], positions[0][1], positions[0][2]);
780
781 for (size_t i = 0; i < positions.size(); ++i)
782 {
783 lb[0] = std::min(lb[0], static_cast<typename Point::Component>(positions[i][0]));
784 lb[1] = std::min(lb[1], static_cast<typename Point::Component>(positions[i][1]));
785 lb[2] = std::min(lb[2], static_cast<typename Point::Component>(positions[i][2]));
786
787 ub[0] = std::max(ub[0], static_cast<typename Point::Component>(positions[i][0]));
788 ub[1] = std::max(ub[1], static_cast<typename Point::Component>(positions[i][1]));
789 ub[2] = std::max(ub[2], static_cast<typename Point::Component>(positions[i][2]));
790 }
791
792 d = Domain(lb, ub);
793 }
794
795 CountedPtr<BinaryImage> image(new BinaryImage(d));
796 for (size_t i = 0; i < positions.size(); ++i)
797 {
798 // Builds a points for generality, T may not be a PointVector instance
799 Point p({positions[i][0], positions[i][1], positions[i][2]});
800 image->setValue(p, true);
801 }
802 return image;
803 }
Integer Component
Type for Vector elements.

References image().

◆ makeBinaryImage() [3/9]

template<typename TKSpace >
template<typename T , typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
static CountedPtr< BinaryImage > DGtal::Shortcuts< TKSpace >::makeBinaryImage ( const std::vector< T > &  values,
const Domain d 
)
inlinestatic

Create an arbitrary image from a vector where non zero values indicates voxels

Note
This overload expects a linearized array. Positions are infered from the domain. The order must be the same
Parameters
[in]valuesA vector where non-zero values indicates voxels
[in]dThe domain of the image
Returns
a smart pointer on a binary image

Definition at line 690 of file Shortcuts.h.

693 {
694 CountedPtr<BinaryImage> image(new BinaryImage(d));
695
696 size_t i = 0;
697 for (auto it = d.begin(); it != d.end(); ++i, ++it)
698 {
699 image->setValue(*it, static_cast<bool>(values[i]));
700 }
701
702 return image;
703 }

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

◆ makeBinaryImage() [4/9]

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

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

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

◆ makeBinaryImage() [5/9]

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

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

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

◆ makeBinaryImage() [6/9]

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

575 {
576 return makeBinaryImage( shape_digitization,
577 shape_digitization->getDomain(),
578 params );
579 }
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition Shortcuts.h:558

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

◆ makeBinaryImage() [7/9]

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

820 {
821 int thresholdMin = params["thresholdMin"].as<int>();
822 int thresholdMax = params["thresholdMax"].as<int>();
823 Domain domain = gray_scale_image->domain();
824 typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
825 ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
826 CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
827 std::transform( domain.begin(), domain.end(),
828 img->begin(),
829 [tImage] ( const Point& p ) { return tImage(p); } );
830 return makeBinaryImage( img, params );
831 }
const ConstIterator & begin() const
const ConstIterator & end() const

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

◆ makeBinaryImage() [8/9]

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

559 {
560 return CountedPtr<BinaryImage>( new BinaryImage( shapeDomain ) );
561 }

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

◆ makeBinaryImage() [9/9]

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

655 {
656 int thresholdMin = params["thresholdMin"].as<int>();
657 int thresholdMax = params["thresholdMax"].as<int>();
659 Domain domain = image.domain();
660 typedef functors::IntervalForegroundPredicate<GrayScaleImage> ThresholdedImage;
661 ThresholdedImage tImage( image, thresholdMin, thresholdMax );
662 CountedPtr<BinaryImage> img ( new BinaryImage( domain ) );
663 std::transform( domain.begin(), domain.end(),
664 img->begin(),
665 [tImage] ( const Point& p ) { return tImage(p); } );
666 return makeBinaryImage( img, params );
667 }
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::HyperRectDomain< TSpace >::begin(), domain, DGtal::HyperRectDomain< TSpace >::end(), image(), DGtal::GenericReader< TContainer, Tdim, TValue >::import(), and DGtal::Shortcuts< TKSpace >::makeBinaryImage().

◆ makeDigitalSurface() [1/2]

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

Builds a explicit digital surface from an indexed digital surface.

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

Definition at line 1500 of file Shortcuts.h.

1503 {
1504 bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1505 const KSpace& K = refKSpace( idx_surface );
1506 SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1507 auto all_idx_surfels
1508 = getIdxSurfelRange( idx_surface, Parameters( "surfaceTraversal", "Default" ) );
1509 auto idx2surfel = idx_surface->surfels();
1510 SurfelSet all_surfels;
1511 for ( auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1512 ExplicitSurfaceContainer* surfContainer
1513 = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1514 return CountedPtr<DigitalSurface>
1515 ( new DigitalSurface( surfContainer ) ); // acquired
1516 }
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
Definition Shortcuts.h:153
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
Definition Shortcuts.h:155
MyDigitalSurface::SurfelSet SurfelSet
void insert(VContainer1 &c1, LContainer2 &c2, unsigned int idx, double v)

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

◆ makeDigitalSurface() [2/2]

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

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

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

Definition at line 1469 of file Shortcuts.h.

1473 {
1474 SurfelSet all_surfels;
1475 bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1476 SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1477 // Extracts all boundary surfels
1478 Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1479 K.lowerBound(), K.upperBound() );
1480 ExplicitSurfaceContainer* surfContainer
1481 = new ExplicitSurfaceContainer( K, surfAdj, all_surfels );
1482 return CountedPtr< DigitalSurface >
1483 ( new DigitalSurface( surfContainer ) ); // acquired
1484 }
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)

References K, and DGtal::Surfaces< TKSpace >::sMakeBoundary().

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

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

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

Referenced by main().

◆ makeDoubleImage() [1/3]

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

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

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

Definition at line 1224 of file Shortcuts.h.

1227 {
1228 Scalar min_x = params[ "minAABB" ].as<Scalar>();
1229 Scalar max_x = params[ "maxAABB" ].as<Scalar>();
1230 Scalar h = params[ "gridstep" ].as<Scalar>();
1231 Scalar offset = params[ "offset" ].as<Scalar>();
1232 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
1233 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
1234 CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
1235 dshape->attach( shape );
1236 dshape->init( p1, p2, h );
1237 Domain domain = dshape->getDomain();
1238 auto fimage = makeDoubleImage( domain );
1239 auto it = fimage->begin();
1240 for ( auto p : domain )
1241 {
1242 double val = (double) (*shape)( p );
1243 *it++ = val;
1244 }
1245 return fimage;
1246 }
static CountedPtr< DoubleImage > makeDoubleImage(Domain aDomain)
Definition Shortcuts.h:1191

References domain, and DGtal::Shortcuts< TKSpace >::makeDoubleImage().

◆ makeDoubleImage() [2/3]

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

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

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

Definition at line 1191 of file Shortcuts.h.

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

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

◆ makeDoubleImage() [3/3]

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

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

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

Definition at line 1203 of file Shortcuts.h.

1205 {
1207 return CountedPtr<DoubleImage>( new DoubleImage( image ) );
1208 }

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

◆ makeDualPolygonalSurface() [1/3]

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

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

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

Definition at line 2549 of file Shortcuts.h.

2550 {
2551 Surfel2Index s2i;
2552 return makeDualPolygonalSurface( s2i, aSurface );
2553 }
std::map< Surfel, IdxSurfel > Surfel2Index
Definition Shortcuts.h:185
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition Shortcuts.h:2529

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

◆ makeDualPolygonalSurface() [2/3]

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

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

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

Definition at line 2563 of file Shortcuts.h.

2565 {
2566 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2567 auto pPolySurf = CountedPtr<PolygonalSurface>
2568 ( new PolygonalSurface( aSurface->heds(),
2569 aSurface->positions().storage() ) );
2570 return pPolySurf;
2571 }
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
Definition Shortcuts.h:183

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

◆ makeDualPolygonalSurface() [3/3]

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

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

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

Definition at line 2529 of file Shortcuts.h.

2531 {
2532 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2533 auto embedder = getCellEmbedder( aSurface );
2534 auto pPolySurf = CountedPtr<PolygonalSurface>
2535 ( new PolygonalSurface ); // acquired
2537 ( *aSurface, embedder, *pPolySurf, s2i );
2538 return pPolySurf;
2539 }
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)

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

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

◆ makeFloatImage() [1/3]

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

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

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

Definition at line 1158 of file Shortcuts.h.

1161 {
1162 Scalar min_x = params[ "minAABB" ].as<Scalar>();
1163 Scalar max_x = params[ "maxAABB" ].as<Scalar>();
1164 Scalar h = params[ "gridstep" ].as<Scalar>();
1165 Scalar offset = params[ "offset" ].as<Scalar>();
1166 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
1167 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
1168 CountedPtr<DigitizedImplicitShape3D> dshape( new DigitizedImplicitShape3D() );
1169 dshape->attach( shape );
1170 dshape->init( p1, p2, h );
1171 Domain domain = dshape->getDomain();
1172 auto fimage = makeFloatImage( domain );
1173 auto it = fimage->begin();
1174 for ( auto p : domain )
1175 {
1176 float val = (float) (*shape)( p );
1177 *it++ = val;
1178 }
1179 return fimage;
1180 }
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
Definition Shortcuts.h:1125

References domain, and DGtal::Shortcuts< TKSpace >::makeFloatImage().

◆ makeFloatImage() [2/3]

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

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

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

Definition at line 1125 of file Shortcuts.h.

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

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

◆ makeFloatImage() [3/3]

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

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

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

Definition at line 1137 of file Shortcuts.h.

1139 {
1141 return CountedPtr<FloatImage>( new FloatImage( image ) );
1142 }

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

◆ makeGrayScaleImage() [1/8]

template<typename TKSpace >
template<typename T , template< class... > class C1, template< class... > class C2, template< class... > class C3>
static CountedPtr< GrayScaleImage > DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( const C1< C2< C3< T > > > &  values,
std::optional< Domain override_domain = std::nullopt 
)
inlinestatic

Create an arbitrary image from a vector

Note
This overloads expect consistent size of subarrays. This is not checked.
Parameters
[in]valuesA vector (of vector of vector) where non-zero values indicates a voxel
[in]override_domainOverrides infered domain if needed
Returns
a smart pointer on a gray scale image

Definition at line 1028 of file Shortcuts.h.

1031 {
1032 Domain d;
1033 if (override_domain.has_value())
1034 {
1035 d = override_domain.value();
1036 }
1037 else if (values.size() != 0)
1038 {
1039 if (values[0].size() != 0)
1040 {
1041 if (values[0][0].size() != 0)
1042 {
1043 d = Domain(Point(0, 0, 0), Point(values.size(), values[0].size(), values[0][0].size()));
1044 }
1045 }
1046 }
1047
1048 CountedPtr<GrayScaleImage> image(new GrayScaleImage(d));
1049 Point begin = d.lowerBound();
1050 for (size_t i = 0; i < values.size(); ++i)
1051 {
1052 for (size_t j = 0; j < values[i].size(); ++j)
1053 {
1054 for (size_t k = 0; k < values[i][j].size(); ++k)
1055 {
1056 Point p = begin + Point(i, j, k);
1057 image->setValue(p, static_cast<GrayScale>(values[i][j][k]));
1058 }
1059 }
1060 }
1061
1062 return image;
1063 }
unsigned char GrayScale
The type for 8-bits gray-scale elements.
Definition Shortcuts.h:126

References image(), and DGtal::HyperRectDomain< TSpace >::lowerBound().

◆ makeGrayScaleImage() [2/8]

template<typename TKSpace >
template<typename T , typename U , std::enable_if_t<!is_double_nested_container< T >::value, int > = 0>
static CountedPtr< GrayScaleImage > DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( const std::vector< T > &  positions,
const std::vector< U > &  values,
std::optional< Domain override_domain = std::nullopt 
)
inlinestatic

Create an arbitrary image from a vector of positions

Note
This overloads expect consistent size of subarrays. This is not checked.
Parameters
[in]positionsA vector of positions to indicates locations of voxels
[in]valuesA vector of values for each voxel
[in]override_domainOverrides infered domain if needed
Returns
a smart pointer on a gray scale image

Definition at line 1076 of file Shortcuts.h.

1080 {
1081 Domain d;
1082 if (override_domain.has_value())
1083 {
1084 d = override_domain.value();
1085 }
1086 else if (positions.size() != 0)
1087 {
1088 Point lb(positions[0][0], positions[0][1], positions[0][2]);
1089 Point ub(positions[0][0], positions[0][1], positions[0][2]);
1090
1091 for (size_t i = 0; i < positions.size(); ++i)
1092 {
1093 lb[0] = std::min(lb[0], static_cast<typename Point::Component>(positions[i][0]));
1094 lb[1] = std::min(lb[1], static_cast<typename Point::Component>(positions[i][1]));
1095 lb[2] = std::min(lb[2], static_cast<typename Point::Component>(positions[i][2]));
1096
1097 ub[0] = std::max(ub[0], static_cast<typename Point::Component>(positions[i][0]));
1098 ub[1] = std::max(ub[1], static_cast<typename Point::Component>(positions[i][1]));
1099 ub[2] = std::max(ub[2], static_cast<typename Point::Component>(positions[i][2]));
1100 }
1101
1102 d = Domain(lb, ub);
1103 }
1104
1105 CountedPtr<GrayScaleImage> image(new GrayScaleImage(d));
1106 for (size_t i = 0; i < positions.size(); ++i)
1107 {
1108 // Builds a points for generality, T may not be a PointVector instance
1109 Point p({positions[i][0], positions[i][1], positions[i][2]});
1110 image->setValue(p, static_cast<GrayScale>(values[i]));
1111 }
1112 return image;
1113 }

References image().

◆ makeGrayScaleImage() [3/8]

template<typename TKSpace >
template<typename T , typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
static CountedPtr< GrayScaleImage > DGtal::Shortcuts< TKSpace >::makeGrayScaleImage ( const std::vector< T > &  values,
const Domain d 
)
inlinestatic

Create an arbitrary image from a vector

Note
This overload expects a linearized array. Positions are infered from the domain. The order must be the same
Parameters
[in]valuesA vector where non-zero values indicates voxels
[in]dThe domain of the image
Returns
a smart pointer on a gray scale image

Definition at line 999 of file Shortcuts.h.

1002 {
1003 CountedPtr<GrayScaleImage> image(new GrayScaleImage(d));
1004
1005 size_t i = 0;
1006 for (auto it = d.begin(); it != d.end(); ++i, ++it)
1007 {
1008 image->setValue(*it, static_cast<GrayScale>(values[i]));
1009 }
1010
1011 return image;
1012 }

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

◆ makeGrayScaleImage() [4/8]

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

898 { return v ? (unsigned char) 255 : (unsigned char) 0; }
899 // JOL: (GrayScale) was not working with visual C++: error C2065
900 )
901 {
902 const Domain domain = binary_image->domain();
903 CountedPtr<GrayScaleImage> gray_scale_image( new GrayScaleImage( domain ) );
904 std::transform( binary_image->begin(), binary_image->end(),
905 gray_scale_image->begin(),
906 bool2grayscale );
907 return gray_scale_image;
908 }
CountedPtr< SH3::BinaryImage > binary_image

◆ makeGrayScaleImage() [5/8]

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

971 {
972 double qShift = params[ "qShift" ].as<double>();
973 double qSlope = params[ "qSlope" ].as<double>();
974 std::function< unsigned char( double ) > f
975 = [qShift,qSlope] (double v)
976 { return (unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
977 Domain domain = fimage->domain();
978 auto gimage = makeGrayScaleImage( domain );
979 auto it = gimage->begin();
980 for ( auto p : domain )
981 {
982 double val = (*fimage)( p );
983 *it++ = f( val );
984 }
985 return gimage;
986 }
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
Definition Shortcuts.h:869

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

◆ makeGrayScaleImage() [6/8]

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

939 {
940 float qShift = params[ "qShift" ].as<float>();
941 float qSlope = params[ "qSlope" ].as<float>();
942 std::function< unsigned char( float ) > f
943 = [qShift,qSlope] (float v)
944 { return (unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
945 Domain domain = fimage->domain();
946 auto gimage = makeGrayScaleImage( domain );
947 auto it = gimage->begin();
948 for ( auto p : domain )
949 {
950 float val = (*fimage)( p );
951 *it++ = f( val );
952 }
953 return gimage;
954 }

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

◆ makeGrayScaleImage() [7/8]

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

870 {
871 return CountedPtr<GrayScaleImage>( new GrayScaleImage( aDomain ) );
872 }

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

◆ makeGrayScaleImage() [8/8]

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

883 {
885 return CountedPtr<GrayScaleImage>( new GrayScaleImage( image ) );
886 }

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

◆ makeIdxDigitalSurface() [1/4]

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

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

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

Definition at line 1624 of file Shortcuts.h.

1627 {
1628 if ( surfaces.empty() ) return CountedPtr<IdxDigitalSurface>( 0 );
1629 const KSpace& K = surfaces[ 0 ]->container().space();
1630 SurfelSet surfels;
1631 for ( std::size_t i = 0; i < surfaces.size(); ++i )
1632 {
1633 const KSpace& Ki = surfaces[ i ]->container().space();
1634 if ( ( Ki.lowerBound() != K.lowerBound() )
1635 || ( Ki.upperBound() != K.upperBound() ) )
1636 trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1637 << " Incompatible digital spaces for surface " << i << std::endl;
1638 surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1639 }
1640 return makeIdxDigitalSurface( surfels, K, params );
1641 }
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1536
std::ostream & warning()

References K, DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::trace, and DGtal::Trace::warning().

◆ makeIdxDigitalSurface() [2/4]

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

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

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

Definition at line 1568 of file Shortcuts.h.

1572 {
1573 bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1574 SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1575 // Build indexed digital surface.
1576 CountedPtr<ExplicitSurfaceContainer> ptrSurfContainer
1577 ( new ExplicitSurfaceContainer( K, surfAdj, surfels ) );
1578 CountedPtr<IdxDigitalSurface> ptrSurface
1579 ( new IdxDigitalSurface() );
1580 bool ok = ptrSurface->build( ptrSurfContainer );
1581 if ( !ok )
1582 trace.warning() << "[Shortcuts::makeIdxDigitalSurface]"
1583 << " Error building indexed digital surface." << std::endl;
1584 return ptrSurface;
1585 }
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
Definition Shortcuts.h:157

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

1604 {
1605 const KSpace& K = refKSpace( surface );
1606 SurfelSet surfels;
1607 surfels.insert( surface->begin(), surface->end() );
1608 return makeIdxDigitalSurface( surfels, K, params );
1609 }

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

◆ makeIdxDigitalSurface() [4/4]

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

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

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

Definition at line 1535 of file Shortcuts.h.

1539 {
1540 std::string component = params[ "surfaceComponents" ].as<std::string>();
1541 SurfelSet surfels;
1542 if ( component == "AnyBig" )
1543 {
1544 auto light_surface = makeLightDigitalSurface( bimage, K, params );
1545 surfels.insert( light_surface->begin(), light_surface->end() );
1546 }
1547 else if ( component == "All" )
1548 {
1549 Surfaces<KSpace>::sMakeBoundary( surfels, K, *bimage,
1550 K.lowerBound(), K.upperBound() );
1551 }
1552 return makeIdxDigitalSurface( surfels, K, params );
1553 }
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1323

References K, DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), and DGtal::Surfaces< TKSpace >::sMakeBoundary().

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

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

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

References DGtal::Trace::error(), DGtal::Shortcuts< TKSpace >::getPolynomialList(), and DGtal::trace.

Referenced by main().

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

1326 {
1327 bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1328 int nb_tries_to_find_a_bel = params[ "nbTriesToFindABel" ].as<int>();
1329 SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1330
1331 // We have to search for a surfel that belongs to a big connected component.
1332 CountedPtr<LightDigitalSurface> ptrSurface;
1333 Surfel bel;
1334 Scalar minsize = bimage->extent().norm();
1335 unsigned int nb_surfels = 0;
1336 unsigned int tries = 0;
1337 do
1338 {
1339 try { // Search initial bel
1340 bel = Surfaces<KSpace>::findABel( K, *bimage, nb_tries_to_find_a_bel );
1341 } catch (DGtal::InputException& e) {
1342 trace.error() << "[Shortcuts::makeLightDigitalSurface]"
1343 << " ERROR Unable to find bel. " << e << std::endl;
1344 return ptrSurface;
1345 }
1346 // this pointer will be acquired by the surface.
1347 LightSurfaceContainer* surfContainer
1348 = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1349 ptrSurface = CountedPtr<LightDigitalSurface>
1350 ( new LightDigitalSurface( surfContainer ) ); // acquired
1351 nb_surfels = ptrSurface->size();
1352 }
1353 while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1354 if( tries >= 150 )
1355 trace.warning() << "[Shortcuts::makeLightDigitalSurface]"
1356 << "ERROR cannot find a proper bel in a big enough component."
1357 << std::endl;
1358 return ptrSurface;
1359 }
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
Definition Shortcuts.h:149
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
Definition Shortcuts.h:151
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)

References DGtal::Trace::error(), DGtal::Surfaces< TKSpace >::findABel(), K, 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 1379 of file Shortcuts.h.

1383 {
1384 SurfelRange surfel_reps;
1385 return makeLightDigitalSurfaces( surfel_reps, bimage, K, params );
1386 }
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1380

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

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

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

1414 {
1415 std::vector< CountedPtr<LightDigitalSurface> > result;
1416 std::string component = params[ "surfaceComponents" ].as<std::string>();
1417 if ( component == "AnyBig" )
1418 {
1419 result.push_back( makeLightDigitalSurface( bimage, K, params ) );
1420 surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1421 return result;
1422 }
1423 bool surfel_adjacency = params[ "surfelAdjacency" ].as<int>();
1424 SurfelAdjacency< KSpace::dimension > surfAdj( surfel_adjacency );
1425 // Extracts all boundary surfels
1426 SurfelSet all_surfels;
1427 Surfaces<KSpace>::sMakeBoundary( all_surfels, K, *bimage,
1428 K.lowerBound(), K.upperBound() );
1429 // Builds all connected components of surfels.
1430 SurfelSet marked_surfels;
1431 CountedPtr<LightDigitalSurface> ptrSurface;
1432 for ( auto bel : all_surfels )
1433 {
1434 if ( marked_surfels.count( bel ) != 0 ) continue;
1435 surfel_reps.push_back( bel );
1436 LightSurfaceContainer* surfContainer
1437 = new LightSurfaceContainer( K, *bimage, surfAdj, bel );
1438 ptrSurface = CountedPtr<LightDigitalSurface>
1439 ( new LightDigitalSurface( surfContainer ) ); // acquired
1440 // mark all surfels of the surface component.
1441 marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1442 // add surface component to result.
1443 result.push_back( ptrSurface );
1444 }
1445 return result;
1446 }

References K, DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), and DGtal::Surfaces< TKSpace >::sMakeBoundary().

◆ makeMesh() [1/2]

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

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

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

Definition at line 2349 of file Shortcuts.h.

2351 {
2352 auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
2353 MeshHelpers::polygonalSurface2Mesh( *polySurf, *pMesh );
2354 return pMesh;
2355 }
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
::DGtal::Mesh< RealPoint > Mesh
Definition Shortcuts.h:181

References DGtal::MeshHelpers::polygonalSurface2Mesh().

◆ makeMesh() [2/2]

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

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

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

Definition at line 2332 of file Shortcuts.h.

2334 {
2335 auto pMesh = CountedPtr<Mesh>( new Mesh( aColor ) ); // acquired
2336 MeshHelpers::triangulatedSurface2Mesh( *triSurf, *pMesh );
2337 return pMesh;
2338 }
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)

References DGtal::MeshHelpers::triangulatedSurface2Mesh().

◆ makePolygonalSurface() [1/2]

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

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

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

Definition at line 2449 of file Shortcuts.h.

2454 {
2455 auto K = getKSpace( gray_scale_image );
2456 auto bimage = makeBinaryImage( gray_scale_image, params );
2457 auto digSurf = makeDigitalSurface( bimage, K, params );
2458 RealVector gh = { params[ "gridsizex" ].as<double>(),
2459 params[ "gridsizey" ].as<double>(),
2460 params[ "gridsizez" ].as<double>() };
2461 double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
2462 typedef RegularPointEmbedder<Space> PointEmbedder;
2463 typedef ImageLinearCellEmbedder
2464 < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
2465 PointEmbedder pembedder;
2466 pembedder.init( gh );
2467 ImageCellEmbedder cembedder;
2468 cembedder.init( K, *gray_scale_image, pembedder, threshold );
2469 auto pPolySurf = CountedPtr<PolygonalSurface>
2470 ( new PolygonalSurface ); // acquired
2471 Surfel2Index s2i;
2473 ( *digSurf, cembedder, *pPolySurf, s2i );
2474 return pPolySurf;
2475 }
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition Shortcuts.h:329
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1470
TKSpace KSpace
Digital cellular space.
Definition Shortcuts.h:108

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

◆ makePolygonalSurface() [2/2]

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

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

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

Definition at line 2427 of file Shortcuts.h.

2428 {
2429 auto pPolySurf = CountedPtr<PolygonalSurface>
2430 ( new PolygonalSurface ); // acquired
2431 bool ok = MeshHelpers::mesh2PolygonalSurface( *aMesh, *pPolySurf );
2432 return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
2433 }
static bool mesh2PolygonalSurface(const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)

References DGtal::MeshHelpers::mesh2PolygonalSurface().

◆ makePrimalPolygonalSurface() [1/3]

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

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

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

Definition at line 2582 of file Shortcuts.h.

2584 {
2585 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2586 auto embedder = getCellEmbedder( aSurface );
2587 auto pPolySurf = CountedPtr<PolygonalSurface>
2588 ( new PolygonalSurface ); // acquired
2590 ( *aSurface, embedder, *pPolySurf, c2i );
2591 return ok ? pPolySurf : CountedPtr< PolygonalSurface >( nullptr );
2592 }
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)

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

Referenced by DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface(), and 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 2602 of file Shortcuts.h.

2603 {
2604 Cell2Index c2i;
2605 return makePrimalPolygonalSurface( c2i, aSurface );
2606 }
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition Shortcuts.h:2582

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

2618 {
2619 auto dsurf = makeDigitalSurface( aSurface );
2620 Cell2Index c2i;
2621 return makePrimalPolygonalSurface( c2i, dsurf );
2622 }

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

◆ makePrimalSurfaceMesh() [1/3]

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

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

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

Definition at line 2633 of file Shortcuts.h.

2635 {
2636 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2637 auto embedder = getCellEmbedder( aSurface );
2638 auto pPolySurf = CountedPtr<SurfaceMesh>( new SurfaceMesh ); // acquired
2639 bool ok = MeshHelpers::digitalSurface2PrimalSurfaceMesh( *aSurface, embedder, *pPolySurf, c2i );
2640 return ok ? pPolySurf : CountedPtr< SurfaceMesh >( nullptr );
2641 }
static bool digitalSurface2PrimalSurfaceMesh(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
::DGtal::SurfaceMesh< RealPoint, RealPoint > SurfaceMesh
Definition Shortcuts.h:184

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

Referenced by DGtal::ShortcutsGeometry< TKSpace >::getCNCGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getCNCMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getCNCPrincipalCurvaturesAndDirections(), main(), DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh(), and DGtal::Shortcuts< TKSpace >::makePrimalSurfaceMesh().

◆ makePrimalSurfaceMesh() [2/3]

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

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

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

Definition at line 2651 of file Shortcuts.h.

2652 {
2653 Cell2Index c2i;
2654 return makePrimalSurfaceMesh( c2i, aSurface );
2655 }
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition Shortcuts.h:2633

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

◆ makePrimalSurfaceMesh() [3/3]

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

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

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

Definition at line 2665 of file Shortcuts.h.

2666 {
2667 auto dsurf = makeDigitalSurface( aSurface );
2668 Cell2Index c2i;
2669 return makePrimalSurfaceMesh( c2i, dsurf );
2670 }

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

◆ makeSurfaceMesh()

template<typename TKSpace >
static CountedPtr< SurfaceMesh > DGtal::Shortcuts< TKSpace >::makeSurfaceMesh ( const std::string &  path)
inlinestatic

Loads a surface mesh

Parameters
[in]pathPath to file
Returns
A smart pointer to the loaded polygonal surface, that holds nullptr if loading failed.

Definition at line 2677 of file Shortcuts.h.

2678 {
2679 std::ifstream file(path);
2680 if (file.is_open())
2681 {
2682 auto surf = CountedPtr<SurfaceMesh>( new SurfaceMesh );
2684
2685 return ok ? surf : CountedPtr<SurfaceMesh>( nullptr );
2686 }
2687
2688 return CountedPtr<SurfaceMesh>( nullptr );
2689 }
static bool readOBJ(std::istream &input, SurfaceMesh &smesh)

References DGtal::SurfaceMeshReader< TRealPoint, TRealVector >::readOBJ().

◆ makeTriangulatedSurface() [1/5]

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

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

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

Definition at line 2383 of file Shortcuts.h.

2384 {
2385 Surfel2Index s2i;
2386 return makeTriangulatedSurface( s2i, aSurface );
2387 }
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< Mesh > aMesh)
Definition Shortcuts.h:2315

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

◆ makeTriangulatedSurface() [2/5]

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

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

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

Definition at line 2492 of file Shortcuts.h.

2497 {
2498 auto K = getKSpace( gray_scale_image );
2499 auto bimage = makeBinaryImage( gray_scale_image, params );
2500 auto digSurf = makeDigitalSurface( bimage, K, params );
2501 RealVector gh = { params[ "gridsizex" ].as<double>(),
2502 params[ "gridsizey" ].as<double>(),
2503 params[ "gridsizez" ].as<double>() };
2504 double threshold = params[ "thresholdMin" ].as<double>() + 0.5;
2505 typedef RegularPointEmbedder<Space> PointEmbedder;
2506 typedef ImageLinearCellEmbedder
2507 < KSpace, GrayScaleImage, PointEmbedder > ImageCellEmbedder;
2508 PointEmbedder pembedder;
2509 pembedder.init( gh );
2510 ImageCellEmbedder cembedder;
2511 cembedder.init( K, *gray_scale_image, pembedder, threshold );
2512 auto pPolySurf = CountedPtr<TriangulatedSurface>
2513 ( new TriangulatedSurface ); // acquired
2514 Surfel2Index s2i;
2516 ( *digSurf, cembedder, *pPolySurf, s2i );
2517 return pPolySurf;
2518 }
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
Definition Shortcuts.h:182

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

◆ makeTriangulatedSurface() [3/5]

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

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

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

Definition at line 2315 of file Shortcuts.h.

2316 {
2317 auto pTriSurf = CountedPtr<TriangulatedSurface>
2318 ( new TriangulatedSurface ); // acquired
2319 bool ok = MeshHelpers::mesh2TriangulatedSurface( *aMesh, *pTriSurf );
2320 return ok ? pTriSurf : CountedPtr< TriangulatedSurface >( nullptr );
2321 }
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)

References DGtal::MeshHelpers::mesh2TriangulatedSurface().

Referenced by 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 2407 of file Shortcuts.h.

2409 {
2410 std::string faceSubdivision = params[ "faceSubdivision" ].as<std::string>();
2411 bool centroid = ( faceSubdivision == "Centroid" );
2412 auto pTriSurf = CountedPtr<TriangulatedSurface>
2413 ( new TriangulatedSurface ); // acquired
2414 MeshHelpers::polygonalSurface2TriangulatedSurface( *polySurf, *pTriSurf, centroid );
2415 return pTriSurf;
2416 }
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)

References DGtal::MeshHelpers::polygonalSurface2TriangulatedSurface().

◆ makeTriangulatedSurface() [5/5]

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

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

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

Definition at line 2365 of file Shortcuts.h.

2367 {
2368 auto embedder = getCellEmbedder( aSurface );
2369 auto pTriSurf = CountedPtr<TriangulatedSurface>
2370 ( new TriangulatedSurface ); // acquired
2372 ( *aSurface, embedder, *pTriSurf, s2i );
2373 return pTriSurf;
2374 }

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

◆ operator=() [1/2]

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

Copy assignment operator.

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

◆ operator=() [2/2]

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

Move assignment operator.

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

◆ outputCellMapAsCSV()

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

Definition at line 3485 of file Shortcuts.h.

3490 {
3491 CellWriter w;
3492 for ( auto&& v : anyMap )
3493 {
3494 w( output, K, v.first );
3495 writer( output, v.second );
3496 output << std::endl;
3497 }
3498 return output.good();
3499 }

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

3229 {
3230 auto embedder = getCellEmbedder( surface );
3231 return outputDualDigitalSurfaceAsObj( output, surface, embedder, params );
3232 }
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersMesh())
Definition Shortcuts.h:3226

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

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

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

3264 {
3265 typedef unsigned long Size;
3266 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
3267 BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
3268 std::string dualFaceSubdivision = params[ "faceSubdivision" ].as<std::string>();
3269 const int subdivide
3270 = dualFaceSubdivision == "Naive" ? 1
3271 : dualFaceSubdivision == "Centroid" ? 2
3272 : 0;
3273 const KSpace& K = embedder.space();
3274 // Number and ouput vertices.
3275 std::map< Vertex, Size > vtx_numbering;
3276 std::map< Face, Size > sub_numbering;
3277 Size n = 1; // OBJ vertex numbering start at 1
3278 for ( auto && s : *surface )
3279 {
3280 if ( ! vtx_numbering.count( s ) )
3281 {
3282 vtx_numbering[ s ] = n++;
3283 // Output vertex positions
3284 RealPoint p = embedder( K.unsigns( s ) );
3285 output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
3286 }
3287 }
3288 auto faces = surface->allClosedFaces();
3289 // Prepare centroids if necessary
3290 if ( subdivide == 2 )
3291 {
3292 for ( auto&& f : faces )
3293 {
3294 auto vtcs = surface->verticesAroundFace( f );
3295 Size nv = vtcs.size();
3296 if ( nv > 3 )
3297 {
3298 sub_numbering[ f ] = n++;
3300 for ( auto&& s : vtcs ) p += embedder( K.unsigns( s ) );
3301 p /= nv;
3302 output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
3303 }
3304 }
3305 }
3306 // Outputs closed faces.
3307 if ( subdivide == 0 )
3308 { // No subdivision
3309 for ( auto&& f : faces )
3310 {
3311 output << "f";
3312 auto vtcs = surface->verticesAroundFace( f );
3313 std::reverse( vtcs.begin(), vtcs.end() );
3314 for ( auto&& s : vtcs )
3315 output << " " << vtx_numbering[ s ];
3316 output << std::endl;
3317 }
3318 }
3319 else if ( subdivide == 1 )
3320 { // naive subdivision
3321 for ( auto&& f : faces )
3322 {
3323 auto vtcs = surface->verticesAroundFace( f );
3324 Size nv = vtcs.size();
3325 for ( Size i = 1; i < nv - 1; ++i )
3326 output << "f " << vtx_numbering[ vtcs[ 0 ] ]
3327 << " " << vtx_numbering[ vtcs[ i+1 ] ]
3328 << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3329 }
3330 }
3331 else if ( subdivide == 2 )
3332 { // centroid subdivision
3333 for ( auto&& f : faces )
3334 {
3335 auto vtcs = surface->verticesAroundFace( f );
3336 Size nv = vtcs.size();
3337 if ( nv == 3 )
3338 output << "f " << vtx_numbering[ vtcs[ 0 ] ]
3339 << " " << vtx_numbering[ vtcs[ 2 ] ]
3340 << " " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
3341 else {
3342 Size c = sub_numbering[ f ];
3343 for ( Size i = 0; i < nv; ++i )
3344 {
3345 output << "f " << c
3346 << " " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
3347 << " " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3348 }
3349 }
3350 }
3351 }
3352 return output.good();
3353 }
static Self zero
Static const for zero PointVector.
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
HalfEdgeDataStructure::Size Size

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

◆ outputPrimalDigitalSurfaceAsObj() [1/2]

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

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

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

Definition at line 3125 of file Shortcuts.h.

3128 {
3129 auto embedder = getCellEmbedder( surface );
3130 return outputPrimalDigitalSurfaceAsObj( output, surface, embedder );
3131 }
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
Definition Shortcuts.h:3126

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

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

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

3157 {
3158 auto surfels = getSurfelRange( surface, Parameters( "Traversal", "Default" ) );
3159 return outputSurfelsAsObj( output, surfels, embedder );
3160 }
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
Definition Shortcuts.h:3075

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

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

3174 {
3175 auto embedder = getCellEmbedder( surface );
3176 return outputPrimalIdxDigitalSurfaceAsObj( output, surface, embedder );
3177 }
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
Definition Shortcuts.h:3172

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

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

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

3198 {
3199 auto idxsurfels = getIdxSurfelRange( surface, Parameters( "Traversal", "Default" ) );
3200 auto surfelmap = surface->surfels();
3201 SurfelRange surfels;
3202 for ( auto&& idx : idxsurfels )
3203 surfels.push_back( surfelmap[ idx ] );
3204 return outputSurfelsAsObj( output, surfels, embedder );
3205 }

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

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

3460 {
3461 SCellWriter w;
3462 for ( auto&& v : anyMap )
3463 {
3464 w( output, K, v.first );
3465 writer( output, v.second );
3466 output << std::endl;
3467 }
3468 return output.good();
3469 }

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

3078 {
3079 typedef unsigned long Size;
3080 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
3081 BOOST_CONCEPT_ASSERT(( concepts::CCellEmbedder< TCellEmbedder > ));
3082 const KSpace& K = embedder.space();
3083 // Number and output vertices.
3084 std::map< Cell, Size > vtx_numbering;
3085 Size n = 1; // OBJ vertex numbering start at 1
3086 for ( auto&& s : surfels )
3087 {
3088 auto primal_vtcs = getPointelRange( K, s, true );
3089 for ( auto&& primal_vtx : primal_vtcs )
3090 {
3091 if ( ! vtx_numbering.count( primal_vtx ) )
3092 {
3093 vtx_numbering[ primal_vtx ] = n++;
3094 // Output vertex positions
3095 RealPoint p = embedder( primal_vtx );
3096 output << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
3097 }
3098 }
3099 }
3100 // Outputs all faces
3101 for ( auto&& s : surfels )
3102 {
3103 output << "f";
3104 auto primal_vtcs = getPointelRange( K, s, true );
3105 for ( auto&& primal_vtx : primal_vtcs )
3106 output << " " << vtx_numbering[ primal_vtx ];
3107 output << std::endl;
3108 }
3109 return output.good();
3110 }

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

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

◆ parametersBinaryImage()

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

Definition at line 544 of file Shortcuts.h.

545 {
546 return Parameters
547 ( "noise", 0.0 )
548 ( "thresholdMin", 0 )
549 ( "thresholdMax", 255 );
550 }

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

1258 {
1259 return Parameters
1260 ( "surfelAdjacency", 0 )
1261 ( "nbTriesToFindABel", 100000 )
1262 ( "surfaceComponents", "AnyBig" )
1263 ( "surfaceTraversal", "Default" );
1264 }

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

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

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

857 {
858 return Parameters
859 ( "qShift", 128.0 )
860 ( "qSlope", 1.0 );
861 }

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

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

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

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

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

2298 {
2299 return Parameters
2300 ( "faceSubdivision", "Centroid" );
2301 }

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

2937 {
2938 return Parameters
2939 ( "colormap", "Custom" )
2940 ( "zero-tic", 0.0 );
2941 }

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

417 {
418 return surface->container().space();
419 }

References surface.

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

◆ refKSpace() [2/2]

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

Definition at line 426 of file Shortcuts.h.

428 {
429 return surface->container().space();
430 }

References surface.

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

842 {
843 auto gray_scale_image = makeGrayScaleImage( bimage );
844 return saveGrayScaleImage( gray_scale_image, output );
845 }
static bool saveGrayScaleImage(CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
Definition Shortcuts.h:917

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

918 {
919 return GenericWriter< GrayScaleImage >
920 ::exportFile( output, *gray_scale_image );
921 }

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

◆ saveOBJ() [1/9]

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

2127 {
2128 auto embedder = getCellEmbedder( digsurf );
2129 return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
2130 ambient_color, diffuse_color, specular_color );
2131 }
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:2000

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

◆ saveOBJ() [2/9]

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

2008 {
2009 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2010 std::string mtlfile;
2011 auto lastindex = objfile.find_last_of(".");
2012 if ( lastindex == std::string::npos )
2013 {
2014 mtlfile = objfile + ".mtl";
2015 objfile = objfile + ".obj";
2016 }
2017 else
2018 {
2019 mtlfile = objfile.substr(0, lastindex) + ".mtl";
2020 }
2021
2022 std::ofstream output_obj( objfile.c_str() );
2023 output_obj << "# OBJ format" << std::endl;
2024 output_obj << "# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
2025 output_obj << "o anObject" << std::endl;
2026 //remove directory to write material
2027 auto indexpath = objfile.find_last_of("/");
2028 output_obj << "mtllib " << mtlfile.substr(indexpath+1) << std::endl;
2029 std::ofstream output_mtl( mtlfile.c_str() );
2030 output_mtl << "# MTL format"<< std::endl;
2031 output_mtl << "# generated from MeshWriter from the DGTal library"<< std::endl;
2032 // Number and output vertices.
2033 const KSpace& K = refKSpace( digsurf );
2034 Cell2Index c2i;
2035 auto pointels = getPointelRange( c2i, digsurf );
2036 for ( auto&& pointel : pointels )
2037 {
2038 RealPoint p = embedder( pointel );
2039 output_obj << "v " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2040 }
2041 // Taking care of normals
2042 Idx nbfaces = digsurf->size();
2043 bool has_normals = ( nbfaces == normals.size() );
2044 if ( has_normals )
2045 {
2046 for ( Idx f = 0; f < nbfaces; ++f )
2047 {
2048 const auto& p = normals[ f ];
2049 output_obj << "vn " << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
2050 }
2051 }
2052 // Taking care of materials
2053 bool has_material = ( nbfaces == diffuse_colors.size() );
2054 Idx idxMaterial = 0;
2055 std::map<Color, Idx > mapMaterial;
2056 if ( has_material )
2057 {
2058 for ( Idx f = 0; f < nbfaces; ++f )
2059 {
2060 Color c = diffuse_colors[ f ];
2061 if ( mapMaterial.count( c ) == 0 )
2062 {
2064 ( output_mtl, idxMaterial, ambient_color, c, specular_color );
2065 mapMaterial[ c ] = idxMaterial++;
2066 }
2067 }
2068 }
2069 else
2070 {
2072 ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
2073 }
2074
2075 // Taking care of faces
2076 Idx f = 0;
2077 for ( auto&& surfel : *digsurf )
2078 {
2079 output_obj << "usemtl material_"
2080 << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
2081 << std::endl;
2082 output_obj << "f";
2083 auto primal_vtcs = getPointelRange( K, surfel );
2084 // The +1 in lines below is because indexing starts at 1 in OBJ file format.
2085 if ( has_normals )
2086 {
2087 for ( auto&& primal_vtx : primal_vtcs )
2088 output_obj << " " << (c2i[ primal_vtx ]+1) << "//" << (f+1);
2089 }
2090 else
2091 {
2092 for ( auto&& primal_vtx : primal_vtcs )
2093 output_obj << " " << (c2i[ primal_vtx ]+1);
2094 }
2095 output_obj << std::endl;
2096 f += 1;
2097 }
2098 output_mtl.close();
2099 return output_obj.good();
2100 }
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned long idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
static Dimension size()

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

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

◆ saveOBJ() [3/9]

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

2176 {
2177 auto embedder = getCellEmbedder( digsurf );
2178 return saveOBJ( digsurf, embedder, RealVectors(), Colors(), objfile,
2179 ambient_color, diffuse_color, specular_color );
2180 }
std::vector< Color > Colors
Definition Shortcuts.h:189
std::vector< RealVector > RealVectors
Definition Shortcuts.h:176

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

◆ saveOBJ() [4/9]

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

2796 {
2797 std::string mtlfile;
2798 auto lastindex = objfile.find_last_of(".");
2799 if ( lastindex == std::string::npos )
2800 {
2801 mtlfile = objfile + ".mtl";
2802 objfile = objfile + ".obj";
2803 }
2804 else
2805 {
2806 mtlfile = objfile.substr(0, lastindex) + ".mtl";
2807 }
2808 std::ofstream output( objfile.c_str() );
2810 ( output, mtlfile, *polysurf, normals, diffuse_colors,
2811 ambient_color, diffuse_color, specular_color );
2812 output.close();
2813 return ok;
2814 }
static bool exportOBJwithFaceNormalAndColor(std::ostream &output_obj, const std::string &mtl_filename, const SurfaceMesh &surf, const std::vector< typename SurfaceMesh::RealPoint > &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() [5/9]

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

2722 {
2723 std::ofstream output( objfile.c_str() );
2724 bool ok = MeshHelpers::exportOBJ( output, *polysurf );
2725 output.close();
2726 return ok;
2727 }
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)

References DGtal::MeshHelpers::exportOBJ().

◆ saveOBJ() [6/9]

template<typename TKSpace >
template<typename TPoint , typename TVector >
static bool DGtal::Shortcuts< TKSpace >::saveOBJ ( CountedPtr< ::DGtal::SurfaceMesh< TPoint, TVector > >  surf,
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 SurfaceMesh as an OBJ file (with its topology) (and a material MTL file).

Template Parameters
TPointany model of point
TVectorany model of vector
Parameters
[in]surfthe 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 2873 of file Shortcuts.h.

2881 {
2882 std::string mtlfile;
2883 auto lastindex = objfile.find_last_of(".");
2884 if ( lastindex == std::string::npos )
2885 {
2886 mtlfile = objfile + ".mtl";
2887 objfile = objfile + ".obj";
2888 }
2889 else
2890 {
2891 mtlfile = objfile.substr(0, lastindex) + ".mtl";
2892 }
2893 std::ofstream output( objfile.c_str() );
2895 ( output, mtlfile, *surf, normals, diffuse_colors,
2896 ambient_color, diffuse_color, specular_color );
2897 output.close();
2898 return ok;
2899 }

References DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor().

◆ saveOBJ() [7/9]

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

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

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

Definition at line 2701 of file Shortcuts.h.

2704 {
2705 std::ofstream output( objfile.c_str() );
2706 bool ok = MeshHelpers::exportOBJ( output, *surf );
2707 output.close();
2708 return ok;
2709 }

References DGtal::MeshHelpers::exportOBJ().

◆ saveOBJ() [8/9]

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

2838 {
2839 std::string mtlfile;
2840 auto lastindex = objfile.find_last_of(".");
2841 if ( lastindex == std::string::npos )
2842 {
2843 mtlfile = objfile + ".mtl";
2844 objfile = objfile + ".obj";
2845 }
2846 else
2847 {
2848 mtlfile = objfile.substr(0, lastindex) + ".mtl";
2849 }
2850 std::ofstream output( objfile.c_str() );
2852 ( output, mtlfile, *trisurf, normals, diffuse_colors,
2853 ambient_color, diffuse_color, specular_color );
2854 output.close();
2855 return ok;
2856 }

References DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor().

◆ saveOBJ() [9/9]

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

2767 {
2768 std::ofstream output( objfile.c_str() );
2769 bool ok = MeshHelpers::exportOBJ( output, *trisurf );
2770 output.close();
2771 return ok;
2772 }

References DGtal::MeshHelpers::exportOBJ().

◆ saveOFF() [1/4]

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

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

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

Definition at line 1933 of file Shortcuts.h.

1939 {
1940 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1941
1942 std::ofstream output_off( off_file.c_str() );
1943 output_off << "OFF" << std::endl;
1944 output_off << "# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1945 Cell2Index c2i;
1946 auto pointels = getPointelRange( c2i, digsurf );
1947 output_off << pointels.size() << " " << digsurf->size() << " " << 0 << " " << std::endl;
1948
1949
1950 // Number and output vertices.
1951 const KSpace& K = refKSpace( digsurf );
1952 for ( auto&& pointel : pointels )
1953 {
1954 RealPoint p = embedder( pointel );
1955 output_off << p[ 0 ] << " " << p[ 1 ] << " " << p[ 2 ] << std::endl;
1956 }
1957
1958 // Taking care of faces
1959 for ( auto&& surfel : *digsurf )
1960 {
1961 auto primal_vtcs = getPointelRange( K, surfel );
1962 output_off << primal_vtcs.size();
1963 {
1964 for ( auto&& primal_vtx : primal_vtcs )
1965 output_off << " " << (c2i[ primal_vtx ]);
1966 }
1967 if(face_color != DGtal::Color::None)
1968 {
1969 output_off << " ";
1970 output_off << face_color.r() << " " << face_color.g()
1971 << " " << face_color.b() << " " << face_color.a();
1972 }
1973 output_off << std::endl;
1974 }
1975 return output_off.good();
1976 }
static const Color None
Definition Color.h:421

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

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

◆ saveOFF() [2/4]

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

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

Outputs a digital surface as an OFF.

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

Definition at line 2148 of file Shortcuts.h.

2152 {
2153 auto embedder = getCellEmbedder( digsurf );
2154 return saveOFF( digsurf, embedder, off_file, face_color);
2155 }
static bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
Definition Shortcuts.h:1934

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

◆ saveOFF() [3/4]

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

Outputs a triangulated surface as an OFF file.

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

Definition at line 2739 of file Shortcuts.h.

2743 {
2746 std::ofstream output( off_file.c_str() );
2747 for (unsigned int i=0; i< m.nbFaces(); i++)
2748 {
2749 m.setFaceColor(i, face_color);
2750 }
2751 bool ok = MeshWriter< TPoint >::export2OFF( output, m, true );
2752 output.close();
2753 return ok;
2754 }
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition Mesh.h:92
Size nbFaces() const
void setFaceColor(Index i, const DGtal::Color &aColor)
static bool export2OFF(std::ostream &out, const Mesh< TPoint > &aMesh, bool exportColor=true)

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

◆ saveOFF() [4/4]

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

Outputs a triangulated surface as an OFF file.

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

Definition at line 2911 of file Shortcuts.h.

2915 {
2918 std::ofstream output( off_file.c_str() );
2919 for (unsigned int i=0; i< m.nbFaces(); i++)
2920 {
2921 m.setFaceColor(i, face_color);
2922 }
2923 bool ok = MeshWriter< TPoint >::export2OFF( output, m, true );
2924 output.close();
2925 return ok;
2926 }

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

◆ saveVectorFieldOBJ()

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

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

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

Definition at line 2199 of file Shortcuts.h.

2208 {
2209 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2210 std::string mtlfile;
2211 auto lastindex = objfile.find_last_of(".");
2212 if ( lastindex == std::string::npos )
2213 {
2214 mtlfile = objfile + ".mtl";
2215 objfile = objfile + ".obj";
2216 }
2217 else
2218 {
2219 mtlfile = objfile.substr(0, lastindex) + ".mtl";
2220 }
2221 std::ofstream output_obj( objfile.c_str() );
2222 output_obj << "# OBJ format" << std::endl;
2223 output_obj << "# DGtal::saveOBJ" << std::endl;
2224 output_obj << "o vectors" << std::endl;
2225 output_obj << "mtllib " << mtlfile << std::endl;
2226 std::ofstream output_mtl( mtlfile.c_str() );
2227 output_mtl << "# MTL format"<< std::endl;
2228 output_mtl << "# generated from MeshWriter from the DGTal library"<< std::endl;
2229 // Output vertices
2230 auto n = std::min( positions.size(), vf.size() );
2231 for ( unsigned int i = 0; i < n; ++i )
2232 {
2233 RealPoint p0 = positions[ i ];
2234 RealPoint p1 = p0 + vf[ i ];
2235 RealVector v = vf[ i ];
2236 RealVector absv = RealVector( fabs( v[ 0 ] ), fabs( v[ 1 ] ), fabs( v[ 2 ] ) );
2237 auto mc = std::max_element( absv.begin(), absv.end() ) - absv.begin();
2238 RealVector b =
2239 mc == 2 ? RealVector( 1, 0, 0 ) :
2240 mc == 1 ? RealVector( 0, 0, 1 ) : RealVector( 0, 1, 0 );
2241 RealVector e0 = v.crossProduct( b ).getNormalized();
2242 RealVector e1 = v.crossProduct( e0 ).getNormalized();
2243 RealPoint t[4] = { thickness * e0, thickness * e1,
2244 -thickness * e0, -thickness * e1 };
2245 for ( unsigned int j = 0; j < 4; ++j ) {
2246 RealPoint pt0 = p0 + t[ j ];
2247 RealPoint pt1 = p1 + t[ j ];
2248 output_obj << "v " << pt0[ 0 ] << " " << pt0[ 1 ] << " " << pt0[ 2 ]
2249 << std::endl;
2250 output_obj << "v " << pt1[ 0 ] << " " << pt1[ 1 ] << " " << pt1[ 2 ]
2251 << std::endl;
2252 }
2253 }
2254 // Simplify materials (very useful for blender).
2255 std::map<Color,Idx> map_colors;
2256 {
2257 Idx j = 0;
2258 for ( auto && c : diffuse_colors )
2259 if ( ! map_colors.count( c ) )
2260 map_colors[ c ] = j++;
2261 }
2262
2263 // Output materials
2264 bool has_material = ! diffuse_colors.empty();
2265 if ( has_material )
2266 for ( auto&& pair : map_colors )
2267 MeshHelpers::exportMTLNewMaterial
2268 ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2269 else
2271 ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2272 // Output faces
2273 for ( Idx i = 0; i < n; ++i )
2274 {
2275 output_obj << "usemtl material_" // << ( has_material ? i : 0 )
2276 << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2277 << std::endl;
2278 Idx b = 8*i+1;
2279 for ( Idx j = 0; j < 8; j += 2 )
2280 output_obj << "f " << (b+j) << " " << (b+j+1)
2281 << " " << (b+(j+3)%8) << " " << (b+(j+2)%8) << std::endl;
2282 output_obj << "f " << b << " " << (b+2)
2283 << " " << (b+4) << " " << (b+6) << std::endl;
2284 output_obj << "f " << (b+1) << " " << (b+7)
2285 << " " << (b+5) << " " << (b+3) << std::endl;
2286 }
2287 output_mtl.close();
2288 return output_obj.good();
2289 }
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
Space::RealVector RealVector
Vector with floating-point coordinates.
Definition Shortcuts.h:118

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

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

3599 {
3600 out << "[Shortcuts]";
3601 }

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