Blender V4.3
Interface1D.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
12#include <float.h>
13#include <iostream>
14#include <string>
15
16#include "Functions0D.h"
17
18#include "../system/Id.h"
19#include "../system/Precision.h"
20
22
23#ifdef WITH_CXX_GUARDEDALLOC
24# include "MEM_guardedalloc.h"
25#endif
26
27using namespace std;
28
29namespace Freestyle {
30
31// Integration method
62
74template<class T>
78 IntegrationType integration_type = MEAN)
79{
80 T res;
81 uint size;
82 switch (integration_type) {
83 case MIN:
84 fun(it);
85 res = fun.result;
86 ++it;
87 for (; !it.isEnd(); ++it) {
88 fun(it);
89 if (fun.result < res) {
90 res = fun.result;
91 }
92 }
93 break;
94 case MAX:
95 fun(it);
96 res = fun.result;
97 ++it;
98 for (; !it.isEnd(); ++it) {
99 fun(it);
100 if (fun.result > res) {
101 res = fun.result;
102 }
103 }
104 break;
105 case FIRST:
106 fun(it);
107 res = fun.result;
108 break;
109 case LAST:
110 fun(--it_end);
111 res = fun.result;
112 break;
113 case MEAN:
114 default:
115 fun(it);
116 res = fun.result;
117 ++it;
118 for (size = 1; !it.isEnd(); ++it, ++size) {
119 fun(it);
120 res += fun.result;
121 }
122 res /= (size ? size : 1);
123 break;
124 }
125 return res;
126}
127
128//
129// Interface1D
130//
132
135 public:
138 {
139 _timeStamp = 0;
140 }
141
143 virtual ~Interface1D(){};
144
146 virtual string getExactTypeName() const
147 {
148 return "Interface1D";
149 }
150
151 // Iterator access
152
155
158
165 virtual Interface0DIterator pointsBegin(float t = 0.0f);
166
173 virtual Interface0DIterator pointsEnd(float t = 0.0f);
174
175 // Data access methods
176
178 virtual real getLength2D() const;
179
181 virtual Id getId() const;
182
183 // FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
185 virtual Nature::EdgeNature getNature() const;
186
188 virtual uint getTimeStamp() const
189 {
190 return _timeStamp;
191 }
192
194 inline void setTimeStamp(uint iTimeStamp)
195 {
196 _timeStamp = iTimeStamp;
197 }
198
199 protected:
201
202#ifdef WITH_CXX_GUARDEDALLOC
203 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface1D")
204#endif
205};
206
207} /* namespace Freestyle */
unsigned int uint
Functions taking 0D input.
Identification system.
Read Guarded memory(de)allocation.
Different natures for both vertices and edges.
Define the float precision used in the program.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
virtual Interface0DIterator verticesEnd()
virtual Interface0DIterator pointsEnd(float t=0.0f)
virtual Nature::EdgeNature getNature() const
virtual Interface0DIterator verticesBegin()
virtual string getExactTypeName() const
virtual uint getTimeStamp() const
virtual real getLength2D() const
void setTimeStamp(uint iTimeStamp)
virtual Interface0DIterator pointsBegin(float t=0.0f)
virtual Id getId() const
ushort EdgeNature
Definition Nature.h:36
inherits from class Rep
Definition AppCanvas.cpp:20
T integrate(UnaryFunction0D< T > &fun, Interface0DIterator it, Interface0DIterator it_end, IntegrationType integration_type=MEAN)
Definition Interface1D.h:75
double real
Definition Precision.h:14