DGtal  1.5.beta
DGtal::Board3D< Space, KSpace > Class Template Reference

The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling the method saveOBJ. More...

#include <DGtal/io/boards/Board3D.h>

Inheritance diagram for DGtal::Board3D< Space, KSpace >:
[legend]

Public Member Functions

 Board3D ()
 
 Board3D (const KSpace &KSEmb)
 
 ~Board3D ()
 
std::string className () const
 
void saveOBJ (const std::string &filename, const bool isNormalized=false)
 
Board3Doperator<< (const DGtal::Color &aColor)
 
template<typename TDrawableWithDisplay3D >
Board3Doperator<< (const TDrawableWithDisplay3D &object)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
unsigned int getMaterialIndex (const DGtal::Color &aColor)
 
- Public Member Functions inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
 BOOST_CONCEPT_ASSERT ((concepts::CSpace< Z3i::Space >))
 
virtual ~Display3D ()
 
 Display3D (const Z3i::KSpace &KSEmb)
 
 Display3D ()
 
 Display3D (const Display3D &)=delete
 Copy constructor. Deleted. More...
 
 Display3D (Display3D &&)=delete
 Move constructor. Deleted. More...
 
Display3Doperator= (const Display3D &)=delete
 Assignment operator. Deleted. More...
 
Display3Doperator= (Display3D &&)=delete
 Move operator. Deleted. More...
 
const Embedderembedder () const
 
const CellEmbeddercellEmbedder () const
 
const SCellEmbeddersCellEmbedder () const
 
const Z3i::KSpacespace () const
 
virtual void setFillColor (DGtal::Color aColor)
 
virtual void setFillTransparency (unsigned char alpha)
 
virtual void setLineColor (DGtal::Color aColor)
 
virtual DGtal::Color getFillColor ()
 
virtual DGtal::Color getLineColor ()
 
virtual void setKSpace (const Z3i::KSpace &aKSpace)
 
void setName3d (DGtal::int32_t name=-1)
 
DGtal::int32_t name3d () const
 
void setSelectCallback3D (SelectCallbackFct fct, void *data, DGtal::int32_t min_name, DGtal::int32_t max_name)
 
SelectCallbackFct getSelectCallback3D (DGtal::int32_t aName, void *&data) const
 
void addClippingPlane (double a, double b, double c, double d, bool drawPlane)
 
std::string getMode (const std::string &objectName) const
 
void createNewLineList (std::string s="")
 
void createNewBallList (std::string s="")
 
DGtal::int32_t createNewCubeList ()
 
bool deleteCubeList (const DGtal::int32_t name)
 
DGtal::int32_t createNewQuadList ()
 
bool deleteQuadList (const DGtal::int32_t name)
 
void createNewTriangleList (std::string s="")
 
void createNewPolygonList (std::string s="")
 
void addQuad (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3, const RealPoint &p4)
 
void addQuadWithNormal (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3, const RealPoint &p4, const RealPoint &n, const bool enableReorientation, const bool enableDoubleFace=false)
 
void addQuadFromSurfelCenter (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel)
 
void addQuadFromSurfelCenterWithNormal (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel, const RealVector &aNormal, const bool enableReorientation, const bool sign, const bool enableDoubleFace=false)
 
void addTriangle (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3)
 
void addPolygon (const std::vector< RealPoint > &vertices)
 
void addLine (const RealPoint &p1, const RealPoint &p2, const double width=0.03)
 
void addCube (const RealPoint &center, double width=1.0)
 
void addBall (const RealPoint &center, const double radius=0.5, const unsigned int resolution=30)
 
void addPrism (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel, double sizeShiftFactor, double sizeFactor=1.0, bool isSigned=false, bool aSign=true)
 
void addBasicSurfel (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel)
 
void addCone (const RealPoint &p1, const RealPoint &p2, double width=0.08)
 
void addCylinder (const RealPoint &p1, const RealPoint &p2, const double width=0.02)
 
void updateBoundingBox (const RealPoint &point)
 
void exportToMesh (Mesh< RealPoint > &aMesh) const
 
Display3Doperator<< (const TDrawableWithDisplay3D &object)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
void clear ()
 
RealPoint embed (const typename Space::Point &dp) const
 
RealPoint embedKS (const typename KSpace::SCell &cell) const
 
RealPoint embedKS (const DGtal::TransformedPrism &aTrans) const
 
RealPoint embedK (const typename KSpace::Cell &cell) const
 

Data Fields

DGtal::Color myDefaultColor
 default color More...
 
- Data Fields inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
ModeMapping myModes
 
StyleMapping myStyles
 
bool myBoundingPtEmptyTag
 True if the bounding box is empty (no objects added) More...
 
double myBoundingPtUp [3]
 upper point of the bounding box More...
 
double myBoundingPtLow [3]
 lower point of the bouding box More...
 

Protected Member Functions

void init ()
 

Private Attributes

std::map< DGtal::Color, unsigned int > myMaterialMap
 Material Map. More...
 
unsigned int myMaterialIndex
 Last Material index. More...
 
std::stringstream myMTLBuffer
 Material buffer. More...
 

Additional Inherited Members

- Public Types inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
enum  StreamKey
 
typedef Display3D< Z3i::Space, Z3i::KSpaceSelf
 
typedef Space::RealPoint RealPoint
 RealPoint type. More...
 
typedef Space::RealVector RealVector
 RealVector type. More...
 
typedef CanonicEmbedder< Z3i::SpaceEmbedder
 
typedef CanonicCellEmbedder< Z3i::KSpaceCellEmbedder
 
typedef CanonicSCellEmbedder< Z3i::KSpaceSCellEmbedder
 
typedef int(* SelectCallbackFct) (void *viewer, DGtal::int32_t name, void *data)
 Select callback function type. More...
 
typedef std::map< DGtal::int32_t, std::vector< QuadD3D > > QuadsMap
 The type that maps identifier name -> vector of QuadD3D. More...
 
typedef std::map< DGtal::int32_t, std::vector< CubeD3D > > CubesMap
 The type that maps identifier name -> vector of CubeD3D. More...
 
typedef std::map< std::string, std::string > ModeMapping
 
typedef std::map< std::string, CountedPtr< DrawableWithDisplay3D > > StyleMapping
 
- Static Protected Member Functions inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
static void cross (double dst[3], double srcA[3], double srcB[3])
 
static void normalize (double vec[3])
 
- Protected Attributes inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
Z3i::KSpace myKSpace
 The Khalimsky space. More...
 
EmbeddermyEmbedder
 an embeder from a dgtal space point to a real space point More...
 
CellEmbeddermyCellEmbedder
 an embeder from a unsigned khalimsky space point to a real space point More...
 
SCellEmbeddermySCellEmbedder
 an embeder from a signed khalimsky space point to a real space point More...
 
DGtal::Color myCurrentFillColor
 
DGtal::Color myCurrentLineColor
 
double myCurrentfShiftVisuPrisms
 
std::vector< std::vector< LineD3D > > myLineSetList
 
std::vector< std::vector< BallD3D > > myBallSetList
 
std::vector< ClippingPlaneD3D > myClippingPlaneList
 
std::vector< QuadD3D > myPrismList
 
QuadsMap myQuadsMap
 
std::vector< std::vector< TriangleD3D > > myTriangleSetList
 Represents all the triangles drawn in the Display3D. More...
 
std::vector< std::vector< PolygonD3D > > myPolygonSetList
 Represents all the polygon drawn in the Display3D. More...
 
CubesMap myCubesMap
 
std::vector< std::string > myCubeSetNameList
 
std::vector< std::string > myLineSetNameList
 
std::vector< std::string > myBallSetNameList
 
std::vector< std::string > myClippingPlaneNameList
 
std::vector< std::string > myPrismNameList
 
std::vector< std::string > myQuadSetNameList
 
std::vector< std::string > myTriangleSetNameList
 
std::vector< std::string > myPolygonSetNameList
 
DGtal::int32_t myName3d
 
std::set< SelectCallbackFctStore > mySelectCallBackFcts
 
bool myBoundingPtChangedTag
 

Detailed Description

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
class DGtal::Board3D< Space, KSpace >

The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling the method saveOBJ.

The format OBJ/MTL is a geometry definition file format, this format has been adopted by many 3D graphics application vendors (pbrt, blender, etc.). to learn more about OBJ see http://en.wikipedia.org/wiki/Wavefront_.obj_file

When exporting Board3D regroup objects by they list name. If two lists have the same name they will melt in the same mesh eventually. If a list doesn't have a name the program will try to give it an unique name so it will become a separate mesh. Each list have a material description which correspond to its first element color. If two lists have the same name and merge the final mesh will have two materials (one per list).

Template Parameters
Spacea model of digital space (default type=Z3i::Space)
KSpacea model of Khalimsky space (default type=Z3i::KSpace)

Definition at line 81 of file Board3D.h.

Constructor & Destructor Documentation

◆ Board3D() [1/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3D< Space, KSpace >::Board3D ( )

Constructor.

◆ Board3D() [2/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3D< Space, KSpace >::Board3D ( const KSpace KSEmb)
inline

Constructor with a khalimsky space

Parameters
KSEmbthe Khalimsky space

Definition at line 95 of file Board3D.h.

95  :Display3D<Space,KSpace>(KSEmb)
96  {
97  init();
98  }

References DGtal::Board3D< Space, KSpace >::init().

◆ ~Board3D()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3D< Space, KSpace >::~Board3D ( )
inline

Destructor.

Definition at line 104 of file Board3D.h.

104 {};

Member Function Documentation

◆ className()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
std::string DGtal::Board3D< Space, KSpace >::className ( ) const
inline
Returns
the style name used for drawing this object.

Definition at line 109 of file Board3D.h.

110  {
111  return "Board3D";
112  }

◆ getMaterialIndex()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
unsigned int DGtal::Board3D< Space, KSpace >::getMaterialIndex ( const DGtal::Color aColor)

Check if the material associated woth the color exists. If it does, the method returns the material index. Otherwise, the new material is created.

Parameters
aColora color
Returns
the material index associated with the color

◆ init()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3D< Space, KSpace >::init ( )
protected

init function (should be in Constructor).

Referenced by DGtal::Board3D< Space, KSpace >::Board3D().

◆ isValid()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
bool DGtal::Board3D< Space, KSpace >::isValid ( ) const

Checks the validity/consistency of the object.

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

◆ operator<<() [1/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
Board3D& DGtal::Board3D< Space, KSpace >::operator<< ( const DGtal::Color aColor)

Set the default color for future drawing.

Parameters
aColora DGtal::Color (allow to set a trasnparency value).

◆ operator<<() [2/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
template<typename TDrawableWithDisplay3D >
Board3D& DGtal::Board3D< Space, KSpace >::operator<< ( const TDrawableWithDisplay3D &  object)

Draws the drawable [object] in this board. It should satisfy the concept CDrawableWithDisplay3D, which requires for instance a method setStyle( Board3D & ).

Parameters
objectany drawable object.
Returns
a reference on 'this'.

◆ saveOBJ()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3D< Space, KSpace >::saveOBJ ( const std::string &  filename,
const bool  isNormalized = false 
)

Save a OBJ image.

Parameters
filenamefilename of the image to save.
isNormalizedif true, we use the bounding box to scale all objects such that they fit in [-1/2,1/2]^3 domain (default false),

Referenced by main(), TEST_CASE(), testBallQuad(), testBoard3D(), testNormaliation(), testQuadNorm(), and testShapes().

◆ selfDisplay()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3D< Space, KSpace >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

◆ myDefaultColor

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Color DGtal::Board3D< Space, KSpace >::myDefaultColor

default color

Definition at line 125 of file Board3D.h.

◆ myMaterialIndex

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
unsigned int DGtal::Board3D< Space, KSpace >::myMaterialIndex
private

Last Material index.

Definition at line 180 of file Board3D.h.

◆ myMaterialMap

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
std::map<DGtal::Color,unsigned int> DGtal::Board3D< Space, KSpace >::myMaterialMap
private

Material Map.

Definition at line 178 of file Board3D.h.

◆ myMTLBuffer

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
std::stringstream DGtal::Board3D< Space, KSpace >::myMTLBuffer
private

Material buffer.

Definition at line 182 of file Board3D.h.


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