Blender  V2.93
Functions1D.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 "Functions0D.h"
25 #include "Interface1D.h"
26 #include "ViewMap.h"
27 
28 #include "../system/FreestyleConfig.h"
29 #include "../system/Precision.h"
30 #include "../system/TimeStamp.h"
31 
32 #include "../python/Director.h"
33 
34 #ifdef WITH_CXX_GUARDEDALLOC
35 # include "MEM_guardedalloc.h"
36 #endif
37 
38 namespace Freestyle {
39 
40 //
41 // UnaryFunction1D (base class for functions in 1D)
42 //
44 
59 template<class T> class UnaryFunction1D {
60  public:
62  void *py_uf1D;
63 
66 
69  {
71  }
72 
80  {
81  _integration = iType;
82  }
83 
85  virtual ~UnaryFunction1D()
86  {
87  }
88 
90  virtual string getName() const
91  {
92  return "UnaryFunction1D";
93  }
94 
100  /* FIXME move the implementation to Functions1D.cpp */
101  virtual int operator()(Interface1D &inter)
102  {
103  return Director_BPy_UnaryFunction1D___call__(this, py_uf1D, inter);
104  }
105 
108  {
109  _integration = integration;
110  }
111 
114  {
115  return _integration;
116  }
117 
118  protected:
120 
121 #ifdef WITH_CXX_GUARDEDALLOC
122  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:UnaryFunction1D")
123 #endif
124 };
125 
127  public:
128  void *py_uf1D;
129 
131  {
132  _integration = MEAN;
133  }
134 
136  {
137  _integration = iType;
138  }
139 
141  {
142  }
143 
144  virtual string getName() const
145  {
146  return "UnaryFunction1D_void";
147  }
148 
149  /* FIXME move the implementation to Functions1D.cpp */
151  {
152  return Director_BPy_UnaryFunction1D___call__(this, py_uf1D, inter);
153  }
154 
156  {
157  _integration = integration;
158  }
159 
161  {
162  return _integration;
163  }
164 
165  protected:
167 
168 #ifdef WITH_CXX_GUARDEDALLOC
169  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:UnaryFunction1D_void")
170 #endif
171 };
172 
173 //
174 // Functions definitions
175 //
177 
178 namespace Functions1D {
179 
180 // GetXF1D
182 class GetXF1D : public UnaryFunction1D<double> {
183  private:
184  Functions0D::GetXF0D _func;
185 
186  public:
192  {
193  }
194 
196  string getName() const
197  {
198  return "GetXF1D";
199  }
200 
202  int operator()(Interface1D &inter);
203 };
204 
205 // GetYF1D
207 class GetYF1D : public UnaryFunction1D<double> {
208  private:
209  Functions0D::GetYF0D _func;
210 
211  public:
217  {
218  }
219 
221  string getName() const
222  {
223  return "GetYF1D";
224  }
225 
227  int operator()(Interface1D &inter);
228 };
229 
230 // GetZF1D
232 class GetZF1D : public UnaryFunction1D<double> {
233  private:
234  Functions0D::GetZF0D _func;
235 
236  public:
242  {
243  }
244 
246  string getName() const
247  {
248  return "GetZF1D";
249  }
250 
252  int operator()(Interface1D &inter);
253 };
254 
255 // GetProjectedXF1D
257 class GetProjectedXF1D : public UnaryFunction1D<double> {
258  private:
260 
261  public:
267  {
268  }
269 
271  string getName() const
272  {
273  return "GetProjectedXF1D";
274  }
275 
277  int operator()(Interface1D &inter);
278 };
279 
280 // GetProjectedYF1D
282 class GetProjectedYF1D : public UnaryFunction1D<double> {
283  private:
285 
286  public:
292  {
293  }
294 
296  string getName() const
297  {
298  return "GetProjectedYF1D";
299  }
300 
302  int operator()(Interface1D &inter);
303 };
304 
305 // GetProjectedZF1D
307 class GetProjectedZF1D : public UnaryFunction1D<double> {
308  private:
310 
311  public:
317  {
318  }
319 
321  string getName() const
322  {
323  return "GetProjectedZF1D";
324  }
325 
327  int operator()(Interface1D &inter);
328 };
329 
330 // Orientation2DF1D
332 class Orientation2DF1D : public UnaryFunction1D<Vec2f> {
333  private:
335 
336  public:
342  {
343  }
344 
346  string getName() const
347  {
348  return "Orientation2DF1D";
349  }
350 
352  int operator()(Interface1D &inter);
353 };
354 
355 // Orientation3DF1D
357 class Orientation3DF1D : public UnaryFunction1D<Vec3f> {
358  private:
360 
361  public:
367  {
368  }
369 
371  string getName() const
372  {
373  return "Orientation3DF1D";
374  }
375 
377  int operator()(Interface1D &inter);
378 };
379 
380 // ZDiscontinuityF1D
386 class ZDiscontinuityF1D : public UnaryFunction1D<double> {
387  private:
389 
390  public:
396  {
397  }
398 
400  string getName() const
401  {
402  return "ZDiscontinuityF1D";
403  }
404 
406  int operator()(Interface1D &inter);
407 };
408 
409 // QuantitativeInvisibilityF1D
416  private:
418 
419  public:
425  {
426  }
427 
429  string getName() const
430  {
431  return "QuantitativeInvisibilityF1D";
432  }
433 
435  int operator()(Interface1D &inter);
436 };
437 
438 // CurveNatureF1D
445 class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature> {
446  private:
448 
449  public:
455  {
456  }
457 
459  string getName() const
460  {
461  return "CurveNatureF1D";
462  }
463 
465  int operator()(Interface1D &inter);
466 };
467 
468 // TimeStampF1D
471  public:
473  string getName() const
474  {
475  return "TimeStampF1D";
476  }
477 
479  int operator()(Interface1D &inter);
480 };
481 
482 // IncrementChainingTimeStampF1D
485  public:
487  string getName() const
488  {
489  return "IncrementChainingTimeStampF1D";
490  }
491 
493  int operator()(Interface1D &inter);
494 };
495 
496 // ChainingTimeStampF1D
499  public:
501  string getName() const
502  {
503  return "ChainingTimeStampF1D";
504  }
505 
507  int operator()(Interface1D &inter);
508 };
509 
510 // Curvature2DAngleF1D
512 class Curvature2DAngleF1D : public UnaryFunction1D<double> {
513  public:
519  {
520  }
521 
523  string getName() const
524  {
525  return "Curvature2DAngleF1D";
526  }
527 
530  {
531  result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
532  return 0;
533  }
534 
535  private:
537 };
538 
539 // Normal2DF1D
541 class Normal2DF1D : public UnaryFunction1D<Vec2f> {
542  public:
548  {
549  }
550 
552  string getName() const
553  {
554  return "Normal2DF1D";
555  }
556 
559  {
560  result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
561  return 0;
562  }
563 
564  private:
566 };
567 
568 // GetShapeF1D
570 class GetShapeF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
571  public:
574  {
575  }
576 
578  string getName() const
579  {
580  return "GetShapeF1D";
581  }
582 
584  int operator()(Interface1D &inter);
585 };
586 
587 // GetOccludersF1D
589 class GetOccludersF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
590  public:
593  {
594  }
595 
597  string getName() const
598  {
599  return "GetOccludersF1D";
600  }
601 
603  int operator()(Interface1D &inter);
604 };
605 
606 // GetOccludeeF1D
608 class GetOccludeeF1D : public UnaryFunction1D<std::vector<ViewShape *>> {
609  public:
612  {
613  }
614 
616  string getName() const
617  {
618  return "GetOccludeeF1D";
619  }
620 
622  int operator()(Interface1D &inter);
623 };
624 
625 // internal
627 
628 // getOccludeeF1D
629 void getOccludeeF1D(Interface1D &inter, set<ViewShape *> &oShapes);
630 
631 // getOccludersF1D
632 void getOccludersF1D(Interface1D &inter, set<ViewShape *> &oShapes);
633 
634 // getShapeF1D
635 void getShapeF1D(Interface1D &inter, set<ViewShape *> &oShapes);
636 
637 } // end of namespace Functions1D
638 
639 } /* namespace Freestyle */
typedef double(DMatrix)[4][4]
int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D &if1D)
Definition: Director.cpp:303
Functions taking 0D input.
Interface 1D and related tools definitions.
Read Guarded memory(de)allocation.
Classes to define a View Map (ViewVertex, ViewEdge, etc.)
Curvature2DAngleF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:518
CurveNatureF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:454
int operator()(Interface1D &inter)
int operator()(Interface1D &inter)
GetProjectedXF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:266
GetProjectedYF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:291
GetProjectedZF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:316
int operator()(Interface1D &inter)
int operator()(Interface1D &inter)
Definition: Functions1D.cpp:28
GetXF1D(IntegrationType iType)
Definition: Functions1D.h:191
int operator()(Interface1D &inter)
Definition: Functions1D.cpp:34
GetYF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:216
int operator()(Interface1D &inter)
Definition: Functions1D.cpp:40
GetZF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:241
Normal2DF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:547
int operator()(Interface1D &inter)
Definition: Functions1D.h:558
Orientation2DF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:341
Orientation3DF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:366
QuantitativeInvisibilityF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:424
int operator()(Interface1D &inter)
ZDiscontinuityF1D(IntegrationType iType=MEAN)
Definition: Functions1D.h:395
virtual Interface0DIterator verticesEnd()
Definition: Interface1D.cpp:35
virtual Interface0DIterator verticesBegin()
Definition: Interface1D.cpp:29
void setIntegrationType(IntegrationType integration)
Definition: Functions1D.h:155
UnaryFunction1D_void(IntegrationType iType)
Definition: Functions1D.h:135
IntegrationType getIntegrationType() const
Definition: Functions1D.h:160
virtual string getName() const
Definition: Functions1D.h:144
int operator()(Interface1D &inter)
Definition: Functions1D.h:150
virtual string getName() const
Definition: Functions1D.h:90
virtual int operator()(Interface1D &inter)
Definition: Functions1D.h:101
IntegrationType getIntegrationType() const
Definition: Functions1D.h:113
void setIntegrationType(IntegrationType integration)
Definition: Functions1D.h:107
IntegrationType _integration
Definition: Functions1D.h:119
UnaryFunction1D(IntegrationType iType)
Definition: Functions1D.h:79
#define T
void getOccludeeF1D(Interface1D &inter, set< ViewShape * > &oShapes)
void getShapeF1D(Interface1D &inter, set< ViewShape * > &oShapes)
void getOccludersF1D(Interface1D &inter, set< ViewShape * > &oShapes)
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
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
Definition: vector.h:39