GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GeometryLoader.hpp
Go to the documentation of this file.
1 /* ************************************************************************************************************* */
2 /* */
3 /* GLIP-LIB */
4 /* OpenGL Image Processing LIBrary */
5 /* */
6 /* Author : R. Kerviche */
7 /* LICENSE : MIT License */
8 /* Website : glip-lib.net */
9 /* */
10 /* File : GeometryLoader.hpp */
11 /* Original Date : May 29th 2015 */
12 /* */
13 /* Description : Geometry loaders for Wavefront Object (OBJ) and STL file formats. */
14 /* */
15 /* ************************************************************************************************************* */
16 
24 #ifndef __GEOMETRY_LOADER_INCLUDE__
25 #define __GEOMETRY_LOADER_INCLUDE__
26 
27  // Includes
28  #include "Core/LibTools.hpp"
29  #include "Core/OglInclude.hpp"
30  #include "Core/Geometry.hpp"
32 
33 namespace Glip
34 {
35  using namespace Glip::CoreGL;
36  using namespace Glip::CorePipeline;
38 
39  namespace Modules
40  {
46  {
47  private :
48  struct UnshapedData
49  {
50  std::vector<GLfloat> x,
51  y,
52  z,
53  nx,
54  ny,
55  nz,
56  u,
57  v;
58  std::vector<GLuint> av,
59  an,
60  at,
61  bv,
62  bn,
63  bt,
64  cv,
65  cn,
66  ct;
67  bool hasNormals,
68  hasTexCoords;
69  };
70 
71  static GLfloat readNextNumber(const std::string& line, size_t& p, const int lineNumber, const std::string& sourceName);
72  static void readFaceComponent(const std::string& line, size_t& p, std::vector<GLuint>& v, std::vector<GLuint>& n, std::vector<GLuint>& t, const int lineNumber, const std::string& sourceName);
73  static void processLine(const std::string& line, UnshapedData& data, const bool strict, const int lineNumber, const std::string& sourceName, std::vector<GLuint>& vertexIndicesBuffer, std::vector<GLuint>& normalIndicesBuffer, std::vector<GLuint>& textureIndicesBuffer);
74  static void completeModelData(UnshapedData& data);
75  static bool testIndices(const UnshapedData& data);
76  static void reorderData(UnshapedData& data);
77 
78  public :
79  OBJLoader(void);
80 
81  void apply(LAYOUT_LOADER_ARGUMENTS_LIST);
82 
83  static CustomModel load(const std::string& filename, const bool strict=false);
84  };
85 
91  {
92  private :
93 
94  public :
95  STLLoader(void);
96 
97  void apply(LAYOUT_LOADER_ARGUMENTS_LIST);
98 
99  static CustomModel load(const std::string& filename);
100  };
101  }
102 }
103 
104 #endif
105 
Specific defines for the API structure.
Module description for the LayoutLoader class.
Definition: LayoutLoaderModules.hpp:746
Definition: Component.hpp:32
Definition: Component.hpp:41
Geometry : build a model.
Definition: Geometry.hpp:240
Geometry objects and memory management.
Wavefront Object file loader (OBJ).
Definition: GeometryLoader.hpp:45
Definition: Geometry.hpp:181
#define LAYOUT_LOADER_ARGUMENTS_LIST
Definition: LayoutLoaderModules.hpp:848
StereoLithography file loader (STL, binary).
Definition: GeometryLoader.hpp:90
OpenGL includes and tools.
Definition: Component.hpp:34
Layout Loader Modules.