Blender  V2.93
Interface1D.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 
24 #include <float.h>
25 #include <iostream>
26 #include <string>
27 
28 #include "Functions0D.h"
29 
30 #include "../system/Id.h"
31 #include "../system/Precision.h"
32 
33 #include "../winged_edge/Nature.h"
34 
35 #ifdef WITH_CXX_GUARDEDALLOC
36 # include "MEM_guardedalloc.h"
37 #endif
38 
39 using namespace std;
40 
41 namespace Freestyle {
42 
43 // Integration method
47 typedef enum {
48  MEAN,
50  MIN,
52  MAX,
54  FIRST,
56  LAST,
59 
71 template<class T>
74  Interface0DIterator it_end,
75  IntegrationType integration_type = MEAN)
76 {
77  T res;
78  unsigned size;
79  switch (integration_type) {
80  case MIN:
81  fun(it);
82  res = fun.result;
83  ++it;
84  for (; !it.isEnd(); ++it) {
85  fun(it);
86  if (fun.result < res) {
87  res = fun.result;
88  }
89  }
90  break;
91  case MAX:
92  fun(it);
93  res = fun.result;
94  ++it;
95  for (; !it.isEnd(); ++it) {
96  fun(it);
97  if (fun.result > res) {
98  res = fun.result;
99  }
100  }
101  break;
102  case FIRST:
103  fun(it);
104  res = fun.result;
105  break;
106  case LAST:
107  fun(--it_end);
108  res = fun.result;
109  break;
110  case MEAN:
111  default:
112  fun(it);
113  res = fun.result;
114  ++it;
115  for (size = 1; !it.isEnd(); ++it, ++size) {
116  fun(it);
117  res += fun.result;
118  }
119  res /= (size ? size : 1);
120  break;
121  }
122  return res;
123 }
124 
125 //
126 // Interface1D
127 //
129 
131 class Interface1D {
132  public:
135  {
136  _timeStamp = 0;
137  }
138 
140  virtual ~Interface1D(){};
141 
143  virtual string getExactTypeName() const
144  {
145  return "Interface1D";
146  }
147 
148  // Iterator access
149 
151  virtual Interface0DIterator verticesBegin();
152 
154  virtual Interface0DIterator verticesEnd();
155 
162  virtual Interface0DIterator pointsBegin(float t = 0.0f);
163 
170  virtual Interface0DIterator pointsEnd(float t = 0.0f);
171 
172  // Data access methods
173 
175  virtual real getLength2D() const;
176 
178  virtual Id getId() const;
179 
180  // FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
182  virtual Nature::EdgeNature getNature() const;
183 
185  virtual unsigned getTimeStamp() const
186  {
187  return _timeStamp;
188  }
189 
191  inline void setTimeStamp(unsigned iTimeStamp)
192  {
193  _timeStamp = iTimeStamp;
194  }
195 
196  protected:
197  unsigned _timeStamp;
198 
199 #ifdef WITH_CXX_GUARDEDALLOC
200  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface1D")
201 #endif
202 };
203 
204 } /* namespace Freestyle */
#define MAX(a, b)
Definition: Common.h:27
Functions taking 0D input.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual bool isEnd() const
Definition: Interface0D.h:296
virtual unsigned getTimeStamp() const
Definition: Interface1D.h:185
virtual string getExactTypeName() const
Definition: Interface1D.h:143
void setTimeStamp(unsigned iTimeStamp)
Definition: Interface1D.h:191
@ FIRST
Definition: curve_intern.h:64
@ LAST
Definition: curve_intern.h:65
#define T
unsigned short EdgeNature
Definition: Nature.h:46
inherits from class Rep
Definition: AppCanvas.cpp:32
T integrate(UnaryFunction0D< T > &fun, Interface0DIterator it, Interface0DIterator it_end, IntegrationType integration_type=MEAN)
Definition: Interface1D.h:72
double real
Definition: Precision.h:26