Blender  V2.93
Bezier.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 <vector>
25 
26 #include "Geom.h"
27 
28 #include "../system/FreestyleConfig.h"
29 
30 #ifdef WITH_CXX_GUARDEDALLOC
31 # include "MEM_guardedalloc.h"
32 #endif
33 
34 namespace Freestyle {
35 
36 using namespace Geometry;
37 
39  private:
40  std::vector<Vec2d> _ControlPolygon;
41  std::vector<Vec2d> _Vertices;
42 
43  public:
45 
46  void AddControlPoint(const Vec2d &iPoint);
47  void Build();
48 
49  inline int size() const
50  {
51  return _ControlPolygon.size();
52  }
53 
54  inline std::vector<Vec2d> &vertices()
55  {
56  return _Vertices;
57  }
58 
59 #ifdef WITH_CXX_GUARDEDALLOC
60  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BezierCurveSegment")
61 #endif
62 };
63 
64 class BezierCurve {
65  private:
66  std::vector<Vec2d> _ControlPolygon;
67  std::vector<BezierCurveSegment *> _Segments;
68  BezierCurveSegment *_currentSegment;
69 
70  public:
71  BezierCurve();
72  BezierCurve(std::vector<Vec2d> &iPoints, double error = 4.0);
73  virtual ~BezierCurve();
74 
75  void AddControlPoint(const Vec2d &iPoint);
76 
77  std::vector<Vec2d> &controlPolygon()
78  {
79  return _ControlPolygon;
80  }
81 
82  std::vector<BezierCurveSegment *> &segments()
83  {
84  return _Segments;
85  }
86 
87 #ifdef WITH_CXX_GUARDEDALLOC
88  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BezierCurve")
89 #endif
90 };
91 
92 } /* namespace Freestyle */
Vectors and Matrices (useful type definitions)
Read Guarded memory(de)allocation.
std::vector< Vec2d > & vertices()
Definition: Bezier.h:54
std::vector< Vec2d > & controlPolygon()
Definition: Bezier.h:77
std::vector< BezierCurveSegment * > & segments()
Definition: Bezier.h:82
static void error(const char *str)
Definition: meshlaplacian.c:65
inherits from class Rep
Definition: AppCanvas.cpp:32
Vector2 * BezierCurve
Definition: FitCurve.cpp:33