OGLplus (0.52.0) a C++ wrapper for OpenGL

analyzer.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_SHAPES_ANALYZER_1308151449_HPP
14 #define OGLPLUS_SHAPES_ANALYZER_1308151449_HPP
15 
16 #include <oglplus/config/basic.hpp>
17 #include <oglplus/math/vector.hpp>
18 
20 
21 #include <cstddef>
22 
23 namespace oglplus {
24 namespace shapes {
25 
26 class ShapeAnalyzerVert;
27 class ShapeAnalyzerEdge;
28 class ShapeAnalyzerFace;
29 
31 
37 {
38 private:
39  const ShapeAnalyzerGraphData& _data;
40  GLuint _face_index;
41  GLuint _vert_index;
42 
43  friend class ShapeAnalyzer;
44  friend class ShapeAnalyzerEdge;
45  friend class ShapeAnalyzerFace;
46 
48  const ShapeAnalyzerGraphData& data,
49  GLuint face_index,
50  GLuint vert_index
51  ): _data(data)
52  , _face_index(face_index)
53  , _vert_index(vert_index)
54  {
55  assert(_face_index < data._face_index.size());
56  assert(_vert_index < data._face_arity(_face_index));
57  }
58 public:
60 
63  GLuint Index(void) const
64  {
65  return _vert_index;
66  }
67 
69  ShapeAnalyzerFace Face(void) const;
70 
72 
76  Vec4d MainAttrib(void) const;
77 
79 
83  Vec4d SmoothAttrib(void) const;
84 };
85 
87 
93 {
94 private:
95  const ShapeAnalyzerGraphData& _data;
96  GLuint _face_index;
97  GLuint _edge_index;
98 
99  friend class ShapeAnalyzer;
100  friend class ShapeAnalyzerFace;
101 
103  const ShapeAnalyzerGraphData& data,
104  GLuint face_index,
105  GLuint edge_index
106  ): _data(data)
107  , _face_index(face_index)
108  , _edge_index(edge_index)
109  {
110  assert(_face_index < data._face_index.size());
111  assert(_edge_index < data._face_arity(_face_index));
112  }
113 public:
115 
118  GLuint Index(void) const
119  {
120  return _edge_index;
121  }
122 
124  ShapeAnalyzerFace Face(void) const;
125 
127  bool HasAdjacentEdge(void) const;
128 
130 
133  ShapeAnalyzerEdge AdjacentEdge(void) const;
134 
136  bool HasOppositeVert(void) const;
137 
139 
142  ShapeAnalyzerVert OppositeVert(void) const;
143 
144  bool HasFlag(GLuint flag) const;
145 
147  bool IsContinuousEdge(void) const
148  {
149  return HasFlag(ShapeAnalyzerGraphData::_flg_contin_edge);
150  }
151 
153  bool IsSmoothEdge(void) const
154  {
155  return HasFlag(ShapeAnalyzerGraphData::_flg_smooth_edge);
156  }
157 
159  bool IsStripEdge(void) const
160  {
161  return HasFlag(ShapeAnalyzerGraphData::_flg_strip_edge);
162  }
163 
165  bool IsFanEdge(void) const
166  {
167  return HasFlag(ShapeAnalyzerGraphData::_flg_fan_edge);
168  }
169 };
170 
171 
173 
179 {
180 private:
181  const ShapeAnalyzerGraphData& _data;
182  GLuint _index;
183 
184  friend class ShapeAnalyzer;
185  friend class ShapeAnalyzerVert;
186  friend class ShapeAnalyzerEdge;
187 
188  ShapeAnalyzerFace(const ShapeAnalyzerGraphData& data, GLuint index)
189  : _data(data)
190  , _index(index)
191  {
192  assert(_index < data._face_index.size());
193  }
194 public:
196  GLuint Index(void) const
197  {
198  return _index;
199  }
200 
202 
207  GLuint Arity(void) const
208  {
209  return _data._face_arity(_index);
210  }
211 
213 
219  ShapeAnalyzerVert Vert(GLuint vert_index) const;
220 
222 
228  ShapeAnalyzerEdge Edge(GLuint edge_index) const;
229 
231 
237  bool HasAdjacentFace(GLuint edge_index) const;
238 
240 
246  ShapeAnalyzerFace AdjacentFace(GLuint edge_index) const;
247 };
248 
250 
256 {
257 private:
258  ShapeAnalyzerGraphData _data;
259 public:
261  template <typename ShapeBuilder>
262  ShapeAnalyzer(const ShapeBuilder& builder)
263  : _data(builder)
264  { }
265 
268 
271 
274 
276 
279  GLuint FaceCount(void) const
280  {
281  assert(!_data._face_index.empty());
282  return _data._face_index.size();
283  }
284 
286 
290  ShapeFace Face(GLuint face_index)
291  {
292  assert(face_index<_data._face_index.size());
293  return ShapeFace(_data, face_index);
294  }
295 };
296 
297 } // shapes
298 } // oglplus
299 
300 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
301 #include <oglplus/shapes/analyzer.ipp>
302 #endif
303 
304 #endif // include guard
ShapeFace Face(GLuint face_index)
Returns the face_index-th face.
Definition: analyzer.hpp:290
GLuint Index(void) const
Returns the index of the vertex in its parent face.
Definition: analyzer.hpp:63
bool IsStripEdge(void) const
Returns true if the edge is a connecting edge of a triangle strip.
Definition: analyzer.hpp:159
ShapeAnalyzerEdge ShapeEdge
The class storing information about a single mesh edge.
Definition: analyzer.hpp:270
Class that analyzes vertex attribs generated by shape loaders/generators.
Definition: analyzer.hpp:255
ShapeAnalyzerVert OppositeVert(void) const
Returns the opposite vertex (if any)
ShapeAnalyzer(const ShapeBuilder &builder)
Constructor takes an initialized shape builder.
Definition: analyzer.hpp:262
bool IsSmoothEdge(void) const
Returns true if the edge is smooth.
Definition: analyzer.hpp:153
bool IsContinuousEdge(void) const
Returns true if the edge is continuous.
Definition: analyzer.hpp:147
Vec4d SmoothAttrib(void) const
Returns the value of the 'smooth' vertex attribute at the vertex.
bool HasOppositeVert(void) const
Returns true if this edge has an opposite vertex (triangles only)
ShapeAnalyzerFace Face(void) const
Returns the parent face of the vertex.
ShapeAnalyzerVert ShapeVert
The class storing information about a single mesh vertex.
Definition: analyzer.hpp:267
GLuint Index(void) const
Returns the index of the face in the mesh that it belongs to.
Definition: analyzer.hpp:196
ShapeAnalyzerFace Face(void) const
Returns the parent face of the edge.
bool HasAdjacentEdge(void) const
Returns true if this edge has an adjacent edge (and adjacent face)
ShapeAnalyzerVert Vert(GLuint vert_index) const
Returns the vert_index-th vertex of this face.
bool HasAdjacentFace(GLuint edge_index) const
Returns true if the edge_index-th edge has an adjacent face.
GLuint Index(void) const
Returns the index of the edge in its parent face.
Definition: analyzer.hpp:118
ShapeAnalyzerFace ShapeFace
The class storing information about a single mesh face.
Definition: analyzer.hpp:273
Storage of analyzed mesh/shape properties used for further processing.
ShapeAnalyzerFace AdjacentFace(GLuint edge_index) const
Returns the edge_index-th adjacent face.
Vec4d MainAttrib(void) const
Returns the value of the main vertex attribute at the vertex.
Basic template for vector types.
Definition: fwd.hpp:43
Class storing information about a single edge of a generated/loaded mesh.
Definition: analyzer.hpp:92
GLuint FaceCount(void) const
Return the number of faces generated by the generator.
Definition: analyzer.hpp:279
bool IsFanEdge(void) const
Returns true if the edge is a connecting edge of a triangle fan.
Definition: analyzer.hpp:165
ShapeAnalyzerEdge AdjacentEdge(void) const
Returns the adjacent edge to this edge.
Class storing information about a single vertex of a generated/loaded mesh.
Definition: analyzer.hpp:36
A vector class.
GLuint Arity(void) const
The number of edges (or vertices) of this face.
Definition: analyzer.hpp:207
ShapeAnalyzerEdge Edge(GLuint edge_index) const
Returns the edge_index-th edge of this face.
Class storing information about a single face of a generated/loaded mesh.
Definition: analyzer.hpp:178

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