Blender V5.0
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
11
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#include "MEM_guardedalloc.h"
24
25using namespace std;
26
27namespace Freestyle {
28
29// Integration method
60
72template<class T>
76 IntegrationType integration_type = MEAN)
77{
78 T res;
79 uint size;
80 switch (integration_type) {
81 case MIN:
82 fun(it);
83 res = fun.result;
84 ++it;
85 for (; !it.isEnd(); ++it) {
86 fun(it);
87 if (fun.result < res) {
88 res = fun.result;
89 }
90 }
91 break;
92 case MAX:
93 fun(it);
94 res = fun.result;
95 ++it;
96 for (; !it.isEnd(); ++it) {
97 fun(it);
98 if (fun.result > res) {
99 res = fun.result;
100 }
101 }
102 break;
103 case FIRST:
104 fun(it);
105 res = fun.result;
106 break;
107 case LAST:
108 fun(--it_end);
109 res = fun.result;
110 break;
111 case MEAN:
112 default:
113 fun(it);
114 res = fun.result;
115 ++it;
116 for (size = 1; !it.isEnd(); ++it, ++size) {
117 fun(it);
118 res += fun.result;
119 }
120 res /= (size ? size : 1);
121 break;
122 }
123 return res;
124}
125
126//
127// Interface1D
128//
130
133 public:
136 {
137 _timeStamp = 0;
138 }
139
141 virtual ~Interface1D() {};
142
144 virtual string getExactTypeName() const
145 {
146 return "Interface1D";
147 }
148
149 // Iterator access
150
153
156
163 virtual Interface0DIterator pointsBegin(float t = 0.0f);
164
171 virtual Interface0DIterator pointsEnd(float t = 0.0f);
172
173 // Data access methods
174
176 virtual real getLength2D() const;
177
179 virtual Id getId() const;
180
181 // FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
183 virtual Nature::EdgeNature getNature() const;
184
186 virtual uint getTimeStamp() const
187 {
188 return _timeStamp;
189 }
190
192 inline void setTimeStamp(uint iTimeStamp)
193 {
194 _timeStamp = iTimeStamp;
195 }
196
197 protected:
199
200 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Interface1D")
201};
202
203} /* 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 bool isEnd() const
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:73
double real
Definition Precision.h:14