OGLplus (0.52.0) a C++ wrapper for OpenGL

analyzer_data.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_SHAPES_ANALYZER_GRAPH_1308151449_HPP
14 #define OGLPLUS_SHAPES_ANALYZER_GRAPH_1308151449_HPP
15 
16 #include <oglplus/config/basic.hpp>
17 #include <oglplus/shapes/draw.hpp>
18 
19 #include <vector>
20 
21 namespace oglplus {
22 namespace shapes {
23 
24 class ShapeAnalyzerGraphData
25 {
26 private:
27  template <typename Index>
28  static std::vector<GLuint> _adapt(const Index& index)
29  {
30  return std::vector<GLuint>(
31  index.begin(),
32  index.end()
33  );
34  }
35 
36  static std::vector<GLuint>&& _adapt(std::vector<GLuint>&& index)
37  {
38  return static_cast<std::vector<GLuint>&&>(index);
39  }
40 
41  GLuint _guess_face_count(void);
42  GLuint _guess_vertex_count(GLuint);
43 
44  void _initialize(void);
45 
46  void _init_draw_arrays(const DrawOperation& draw_op);
47 
48  void _init_dr_ar_triangles(const DrawOperation& draw_op);
49  void _init_dr_ar_triangle_strip(const DrawOperation& draw_op);
50  void _init_dr_ar_triangle_fan(const DrawOperation& draw_op);
51 
52  void _init_draw_elements(const DrawOperation& draw_op);
53 
54  void _init_dr_el_triangles(const DrawOperation& draw_op);
55  void _init_dr_el_triangle_strip(const DrawOperation& draw_op);
56  void _init_dr_el_triangle_fan(const DrawOperation& draw_op);
57 
58  void _detect_adjacent(void);
59  bool _same_va_values(
60  GLuint fa,
61  GLuint ea,
62  GLuint fb,
63  GLuint eb,
64  GLuint attr_vpv,
65  const std::vector<GLdouble>& vert_attr
66  );
67  bool _adjacent_faces(GLuint fa, GLuint ea, GLuint fb, GLuint eb);
68  bool _smooth_faces(GLuint fa, GLuint ea, GLuint fb, GLuint eb);
69  bool _contin_faces(GLuint fa, GLuint ea, GLuint fb, GLuint eb);
70 public:
71  DrawingInstructions _instr;
72  std::vector<GLuint> _index;
73 
74  // main vertex attribute (usually position)
75  std::vector<GLdouble> _main_va;
76  // number of values per vertex for the main attribute
77  GLuint _main_vpv;
78 
79  // vertex attribute used to detect smoothing (usually normal)
80  std::vector<GLdouble> _smooth_va;
81  // number of values per vertex for the smooting attribute
82  GLuint _smooth_vpv;
83 
84  // other vertex attributes
85  std::vector<std::vector<GLdouble> > _other_vas;
86  // number of values per vertex for the other attributes
87  std::vector<GLuint> _other_vpvs;
88 
89  // epsilon value for comparisons
90  GLdouble _eps;
91 
92  // index pointing to the start of face vertices
93  std::vector<GLuint> _face_index;
94  std::vector<GLuint> _face_phase;
95 
96  std::vector<GLuint> _face_verts;
97  std::vector<GLuint> _face_adj_f;
98  std::vector<GLuint> _face_adj_e;
99  std::vector<GLuint> _face_edge_flags;
100 
101  static const GLuint _flg_contin_edge = 0x0001;
102  static const GLuint _flg_smooth_edge = 0x0002;
103  static const GLuint _flg_strip_edge =
104  _flg_smooth_edge|
105  _flg_contin_edge|
106  0x0004;
107  static const GLuint _flg_fan_edge =
108  _flg_smooth_edge|
109  _flg_contin_edge|
110  0x0008;
111 
112  static GLuint _face_arity(GLuint /*face*/)
113  {
114  // TODO Arity or triangles only?
115  return 3;
116  }
117 
118  typedef oglplus::ShapeDrawOperationMethod Method;
119  typedef oglplus::PrimitiveType Mode;
120 
121  template <typename ShapeBuilder>
122  ShapeAnalyzerGraphData(const ShapeBuilder& builder)
123  : _instr(builder.Instructions())
124  , _index(_adapt(builder.Indices()))
125  , _main_va()
126  , _main_vpv(builder.Positions(_main_va))
127  , _smooth_va()
128  , _smooth_vpv(builder.Normals(_smooth_va))
129  , _eps(1.0e-9)
130  {
131  _initialize();
132  }
133 
134  static GLuint _nil_face(void) { return ~GLuint(0); }
135 };
136 
137 } // shapes
138 } // oglplus
139 
140 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
141 #include <oglplus/shapes/analyzer_data.ipp>
142 #endif
143 
144 #endif // include guard
Implementation of shape draw instructions.
PrimitiveType
Primitive type enumeration.
Definition: primitive_type.hpp:29
ShapeDrawOperationMethod
Enumeration of drawing methods.
Definition: draw.hpp:86

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).