IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Mesh3dFunctions.h
Go to the documentation of this file.
1 // Mesh3dFunctions.h:
3 // ------------------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_MESH3DFUNCTIONS_H__
16 #define __IPSDKGEOMETRY_MESH3DFUNCTIONS_H__
17 
20 #include <IPSDKUtil/Tools/ProcessingResult.h>
21 #include <boost/filesystem/path.hpp>
22 #include <iostream>
23 #include <vector>
24 
25 namespace ipsdk {
26 namespace geom {
27 
30 
37 template <typename T>
39 saveToStLAscii(const boost::filesystem::path& stlFile,
40  const Mesh3d<T>& mesh,
41  const std::string& solidName = "");
42 
49 template <typename T>
51 saveToStLBinary(const boost::filesystem::path& stlFile,
52  const Mesh3d<T>& mesh);
53 
56 writeStLAsciiHeader(std::ostream& os,
57  const std::string& solidName);
58 
61 writeStLAsciiFooter(std::ostream& os,
62  const std::string& solidName);
63 
65 template <typename T>
67 writeStLAscii(std::ostream& os,
68  const Mesh3d<T>& mesh,
69  const ipReal32 xOffset,
70  const ipReal32 yOffset,
71  const ipReal32 zOffset);
72 
75 writeStLBinaryHeader(std::ostream& os,
76  const ipUInt64 nbTriangles);
77 
79 template <typename T>
81 writeStLBinary(std::ostream& os,
82  const Mesh3d<T>& mesh,
83  const ipReal32 xOffset,
84  const ipReal32 yOffset,
85  const ipReal32 zOffset);
86 
88 //IPSDKGEOMETRY_API Mesh3d<T>
89 template <typename T>
90 IPSDKGEOMETRY_API boost::shared_ptr<Mesh3d<T>>
91 readFromStLFile(const boost::filesystem::path& stlFile);
92 
94 //IPSDKGEOMETRY_API Mesh3d<T>
95 template <typename T>
96 IPSDKGEOMETRY_API boost::shared_ptr<Mesh3d<T>>
97 readStLAscii(const boost::filesystem::path& stlFile);
98 
100 //IPSDKGEOMETRY_API Mesh3d<T>
101 template <typename T>
102 IPSDKGEOMETRY_API boost::shared_ptr<Mesh3d<T>>
103 readStLBinary(const boost::filesystem::path& stlFile);
104 
105 
107  ipReal32 _v[3];
108  ipUInt32 _index;
109 
110  bool operator == (const CoordWithIndex& c) const
111  {
112  return (c._v[0] == _v[0]) && (c._v[1] == _v[1]) && (c._v[2] == _v[2]);
113  }
114 
115  bool operator != (const CoordWithIndex& c) const
116  {
117  return (c._v[0] != _v[0]) || (c._v[1] != _v[1]) || (c._v[2] != _v[2]);
118  }
119 
120  bool operator < (const CoordWithIndex& c) const
121  {
122  return (_v[0] < c._v[0])
123  || (_v[0] == c._v[0] && _v[1] < c._v[1])
124  || (_v[0] == c._v[0] && _v[1] == c._v[1] && _v[2] < c._v[2]);
125  }
126 
127 };
128 
129 //function that checks if a given STL file is binary or Ascii
130 ipBool
131 stlFileHasASCIIFormat(const boost::filesystem::path& stlFile);
132 
133 //function that removes doubles from a list of vertices
134 void
135 removeDoubles(std::vector<ipReal32> &vUniqueCoordsOut , std::vector<ipUInt32> &vTrisOut,
136  std::vector<CoordWithIndex> &vCoordsWithIndexInOut);
137 
138 
141 
142 } // end of namespace geom
143 } // end of namespace ipsdk
144 
145 #endif // __IPSDKGEOMETRY_MESH3DFUNCTIONS_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IPSDKGEOMETRY_API void writeStLBinaryHeader(std::ostream &os, const ipUInt64 nbTriangles)
function allowing to write stl binary header into a stream
Definition: Mesh3dFunctions.cpp:127
IPSDKGEOMETRY_API void writeStLBinary(std::ostream &os, const Mesh3d< T > &mesh, const ipReal32 xOffset, const ipReal32 yOffset, const ipReal32 zOffset)
function allowing to write stl binary mesh data into a stream
IPSDKGEOMETRY_API void writeStLAscii(std::ostream &os, const Mesh3d< T > &mesh, const ipReal32 xOffset, const ipReal32 yOffset, const ipReal32 zOffset)
function allowing to write stl ascii mesh data into a stream
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
IPSDKGEOMETRY_API boost::shared_ptr< Mesh3d< T > > readFromStLFile(const boost::filesystem::path &stlFile)
function allowing to read stl files and return a mesh3d
IPSDKGEOMETRY_API BoolResult saveToStLBinary(const boost::filesystem::path &stlFile, const Mesh3d< T > &mesh)
export the mesh definition to a StL binary file
IPSDKGEOMETRY_API BoolResult saveToStLAscii(const boost::filesystem::path &stlFile, const Mesh3d< T > &mesh, const std::string &solidName="")
export the mesh definition to a StL ascii file
Predefined types for mesh 3d management.
Definition of import/export macro for library.
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Definition: Mesh3dFunctions.h:106
IPSDKGEOMETRY_API void writeStLAsciiHeader(std::ostream &os, const std::string &solidName)
function allowing to write stl ascii header into a stream
bool ipBool
Base types definition.
Definition: BaseTypes.h:47
ProcessingResult< bool > BoolResult
typedef for boolean results associated to a string description
Definition: ProcessingResultTypes.h:29
IPSDKGEOMETRY_API boost::shared_ptr< Mesh3d< T > > readStLBinary(const boost::filesystem::path &stlFile)
function allowing to read stl binary data into a mesh3d
IPSDKGEOMETRY_API boost::shared_ptr< Mesh3d< T > > readStLAscii(const boost::filesystem::path &stlFile)
function allowing to read stl ascii data into a mesh3d
IPSDKGEOMETRY_API void writeStLAsciiFooter(std::ostream &os, const std::string &solidName)
function allowing to write stl ascii footer into a stream
float ipReal32
Base types definition.
Definition: BaseTypes.h:56
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53