Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AdvancedFunctions1D.h « stroke « intern « freestyle « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 349db393e170ca0f53a7cdf7ba44fbffe445dd2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#pragma once

/** \file
 * \ingroup freestyle
 * \brief Functions taking 1D input
 */

#include "AdvancedFunctions0D.h"

#include "../view_map/Functions1D.h"

//
// Functions definitions
//
///////////////////////////////////////////////////////////

namespace Freestyle {

namespace Functions1D {

// DensityF1D
/*! Returns the density evaluated for an Interface1D.
 *  The density is evaluated for a set of points along the Interface1D (using the DensityF0D
 * functor) with a user-defined sampling and then integrated into a single value using a
 * user-defined integration method.
 */
class DensityF1D : public UnaryFunction1D<double> {
 private:
  float _sampling;

 public:
  /*! Builds the functor.
   *  \param sigma:
   *    Thesigma used in DensityF0D and determining the window size used in each density query.
   *  \param iType:
   *    The integration method used to compute a single value from a set of values.
   *  \param sampling:
   *    The resolution used to sample the chain: the corresponding 0D function is evaluated at each
   * sample point and the result is obtained by combining the resulting values into a single one,
   * following the method specified by iType.
   */
  DensityF1D(double sigma = 2, IntegrationType iType = MEAN, float sampling = 2.0f)
      : UnaryFunction1D<double>(iType), _fun(sigma)
  {
    _sampling = sampling;
  }

  /*! Destructor */
  virtual ~DensityF1D()
  {
  }

  /*! Returns the string "DensityF1D"*/
  string getName() const
  {
    return "DensityF1D";
  }

  /*! the () operator.*/
  int operator()(Interface1D &inter)
  {
    result = integrate(
        _fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
    return 0;
  }

 private:
  Functions0D::DensityF0D _fun;
};

// LocalAverageDepthF1D
/*! Returns the average depth evaluated for an Interface1D.
 *  The average depth is evaluated for a set of points along the Interface1D (using the
 * LocalAverageDepthF0D functor) with a user-defined sampling and then integrated into a single
 * value using a user-defined integration method.
 */
class LocalAverageDepthF1D : public UnaryFunction1D<double> {
 public:
  /*! Builds the functor.
   *  \param sigma:
   *    The sigma used in DensityF0D and determining the window size used in each density query.
   *  \param iType:
   *    The integration method used to compute a single value from a set of values.
   */
  LocalAverageDepthF1D(real sigma, IntegrationType iType = MEAN)
      : UnaryFunction1D<double>(iType), _fun(sigma)
  {
  }

  /*! Returns the string "LocalAverageDepthF1D" */
  string getName() const
  {
    return "LocalAverageDepthF1D";
  }

  /*! the () operator. */
  int operator()(Interface1D &inter)
  {
    result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
    return 0;
  }

 private:
  Functions0D::LocalAverageDepthF0D _fun;
};

// GetCompleteViewMapDensity
/*! Returns the density evaluated for an Interface1D in the complete viewmap image.
 *  The density is evaluated for a set of points along the Interface1D (using the
 * ReadCompleteViewMapPixelF0D functor) and then integrated into a single value using a
 * user-defined integration method.
 */
class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
 public:
  /*! Builds the functor.
   *  \param level:
   *    The level of the pyramid from which
   *    the pixel must be read.
   *  \param iType:
   *    The integration method used to compute
   *    a single value from a set of values.
   *  \param sampling:
   *    The resolution used to sample the chain: the corresponding 0D function
   *    is evaluated at each sample point and the result is obtained by
   *    combining the resulting values into a single one, following the
   *    method specified by iType.
   */
  GetCompleteViewMapDensityF1D(unsigned level, IntegrationType iType = MEAN, float sampling = 2.0f)
      : UnaryFunction1D<double>(iType), _fun(level)
  {
    _sampling = sampling;
  }

  /*! Returns the string "GetCompleteViewMapDensityF1D" */
  string getName() const
  {
    return "GetCompleteViewMapDensityF1D";
  }

  /*! the () operator. */
  int operator()(Interface1D &inter);

 private:
  Functions0D::ReadCompleteViewMapPixelF0D _fun;
  float _sampling;
};

// GetDirectionalViewMapDensity
/*! Returns the density evaluated for an Interface1D in of the steerable viewmaps image.
 *  The direction telling which Directional map to choose is explicitly specified by the user.
 *  The density is evaluated for a set of points along the Interface1D
 *  (using the ReadSteerableViewMapPixelF0D functor)
 *  and then integrated into a single value using a user-defined integration method.
 */
class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
 public:
  /*! Builds the functor.
   *  \param iOrientation:
   *    The number of the directional map we must work with.
   *  \param level:
   *    The level of the pyramid from which the pixel must be read.
   *  \param iType:
   *    The integration method used to compute a single value from a set of values.
   *  \param sampling:
   *    The resolution used to sample the chain: the corresponding 0D function is evaluated at
   *    each sample point and the result is obtained by combining the resulting values into a
   *    single one, following the method specified by iType.
   */
  GetDirectionalViewMapDensityF1D(unsigned iOrientation,
                                  unsigned level,
                                  IntegrationType iType = MEAN,
                                  float sampling = 2.0f)
      : UnaryFunction1D<double>(iType), _fun(iOrientation, level)
  {
    _sampling = sampling;
  }

  /*! Returns the string "GetDirectionalViewMapDensityF1D" */
  string getName() const
  {
    return "GetDirectionalViewMapDensityF1D";
  }

  /*! the () operator. */
  int operator()(Interface1D &inter);

 private:
  Functions0D::ReadSteerableViewMapPixelF0D _fun;
  float _sampling;
};

// GetSteerableViewMapDensityF1D
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
 * evaluated in the proper steerable ViewMap depending on its orientation.
 */
class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
 private:
  int _level;
  float _sampling;

 public:
  /*! Builds the functor from the level of the pyramid from which the pixel must be read.
   *  \param level:
   *    The level of the pyramid from which the pixel must be read.
   *  \param iType:
   *    The integration method used to compute a single value from a set of values.
   *  \param sampling:
   *    The resolution used to sample the chain: the corresponding 0D function is evaluated at each
   * sample point and the result is obtained by combining the resulting values into a single one,
   * following the method specified by iType.
   */
  GetSteerableViewMapDensityF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
      : UnaryFunction1D<double>(iType)
  {
    _level = level;
    _sampling = sampling;
  }

  /*! Destructor */
  virtual ~GetSteerableViewMapDensityF1D()
  {
  }

  /*! Returns the string "GetSteerableViewMapDensityF1D" */
  string getName() const
  {
    return "GetSteerableViewMapDensityF1D";
  }

  /*! the () operator. */
  int operator()(Interface1D &inter);
};

// GetViewMapGradientNormF1D
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
 * evaluated in the proper steerable ViewMap depending on its orientation.
 */
class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
 private:
  int _level;
  float _sampling;
  Functions0D::GetViewMapGradientNormF0D _func;

 public:
  /*! Builds the functor from the level of the pyramid from which the pixel must be read.
   *  \param level:
   *    The level of the pyramid from which the pixel must be read.
   *  \param iType:
   *    The integration method used to compute a single value from a set of values.
   *  \param sampling:
   *    The resolution used to sample the chain: the corresponding 0D function is evaluated at each
   *    sample point and the result is obtained by combining the resulting values into a single
   *    one, following the method specified by iType.
   */
  GetViewMapGradientNormF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
      : UnaryFunction1D<double>(iType), _func(level)
  {
    _level = level;
    _sampling = sampling;
  }

  /*! Returns the string "GetSteerableViewMapDensityF1D" */
  string getName() const
  {
    return "GetViewMapGradientNormF1D";
  }

  /*! the () operator. */
  int operator()(Interface1D &inter);
};

}  // end of namespace Functions1D

} /* namespace Freestyle */