Blender  V2.93
WingedEdgeBuilder.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
25 #include "WEdge.h"
26 
27 #include "../scene_graph/IndexedFaceSet.h"
28 #include "../scene_graph/NodeTransform.h"
29 #include "../scene_graph/SceneVisitor.h"
30 
31 #include "../system/FreestyleConfig.h"
32 #include "../system/RenderMonitor.h"
33 
34 namespace Freestyle {
35 
37  public:
39  {
40  _current_wshape = NULL;
41  _current_frs_material = NULL;
42  _current_matrix = NULL;
43  _winged_edge = new WingedEdge; // Not deleted by the destructor
45  }
46 
48  {
49  for (vector<Matrix44r *>::iterator it = _matrices_stack.begin(); it != _matrices_stack.end();
50  ++it) {
51  delete *it;
52  }
53  _matrices_stack.clear();
54  }
55 
59 
60  virtual void visitNodeTransformAfter(NodeTransform &);
61 
62  //
63  // Accessors
64  //
66 
68  {
69  return _winged_edge;
70  }
71 
73  {
74  return _current_wshape;
75  }
76 
78  {
79  return _current_frs_material;
80  }
81 
83  {
84  return _current_matrix;
85  }
86 
87  //
88  // Modifiers
89  //
91 
92  inline void setCurrentWShape(WShape *wshape)
93  {
94  _current_wshape = wshape;
95  }
96 
98  {
99  _current_frs_material = mat;
100  }
101 
102 #if 0
103  inline void setCurrentMatrix(Matrix44r *matrix)
104  {
105  _current_matrix = matrix;
106  }
107 #endif
108 
109  inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
110  {
111  _pRenderMonitor = iRenderMonitor;
112  }
113 
114  protected:
115  virtual bool buildWShape(WShape &shape, IndexedFaceSet &ifs);
116  virtual void buildWVertices(WShape &shape, const float *vertices, unsigned vsize);
117 
119 
120  private:
121  void buildTriangleStrip(const float *vertices,
122  const float *normals,
123  vector<FrsMaterial> &iMaterials,
124  const float *texCoords,
125  const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
126  const unsigned *vindices,
127  const unsigned *nindices,
128  const unsigned *mindices,
129  const unsigned *tindices,
130  const unsigned nvertices);
131 
132  void buildTriangleFan(const float *vertices,
133  const float *normals,
134  vector<FrsMaterial> &iMaterials,
135  const float *texCoords,
136  const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
137  const unsigned *vindices,
138  const unsigned *nindices,
139  const unsigned *mindices,
140  const unsigned *tindices,
141  const unsigned nvertices);
142 
143  void buildTriangles(const float *vertices,
144  const float *normals,
145  vector<FrsMaterial> &iMaterials,
146  const float *texCoords,
147  const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
148  const unsigned *vindices,
149  const unsigned *nindices,
150  const unsigned *mindices,
151  const unsigned *tindices,
152  const unsigned nvertices);
153 
154  void transformVertices(const float *vertices,
155  unsigned vsize,
156  const Matrix44r &transform,
157  float *res);
158 
159  void transformNormals(const float *normals,
160  unsigned nsize,
161  const Matrix44r &transform,
162  float *res);
163 
164  WShape *_current_wshape;
165  FrsMaterial *_current_frs_material;
166  WingedEdge *_winged_edge;
167  Matrix44r *_current_matrix;
168  vector<Matrix44r *> _matrices_stack;
169 
170 #ifdef WITH_CXX_GUARDEDALLOC
171  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WingedEdgeBuilder")
172 #endif
173 };
174 
175 } /* namespace Freestyle */
Classes to define a Winged Edge data structure.
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
void setCurrentFrsMaterial(FrsMaterial *mat)
virtual void buildWVertices(WShape &shape, const float *vertices, unsigned vsize)
void setCurrentWShape(WShape *wshape)
virtual void visitNodeTransformAfter(NodeTransform &)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
virtual bool buildWShape(WShape &shape, IndexedFaceSet &ifs)
FrsMaterial * getCurrentFrsMaterial()
static float normals[][3]
inherits from class Rep
Definition: AppCanvas.cpp:32