Blender  V2.93
FitCurve.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 
25 #include <vector>
26 
27 #include "Geom.h"
28 
29 #include "../system/FreestyleConfig.h"
30 
31 namespace Freestyle {
32 
33 using namespace Geometry;
34 
35 /* 2d point */
36 typedef struct Point2Struct {
37  double coordinates[2];
38 
40  {
41  coordinates[0] = 0;
42  coordinates[1] = 0;
43  }
44 
45  inline double operator[](const int i) const
46  {
47  return coordinates[i];
48  }
49 
50  inline double &operator[](const int i)
51  {
52  return coordinates[i];
53  }
54 
55  inline double x() const
56  {
57  return coordinates[0];
58  }
59 
60  inline double y() const
61  {
62  return coordinates[1];
63  }
65 
66 typedef Point2 Vector2;
67 
69  private:
70  std::vector<Vector2> _vertices;
71 
72  public:
73  ~FitCurveWrapper();
74 
84  void FitCurve(std::vector<Vec2d> &data, std::vector<Vec2d> &oCurve, double error);
85 
86  protected:
87  /* Vec2d *d; Array of digitized points
88  * int nPts; Number of digitized points
89  * double error; User-defined error squared
90  */
91  void FitCurve(Vector2 *d, int nPts, double error);
92 
99  void DrawBezierCurve(int n, Vector2 *curve);
100 
101  /* Vec2d *d; Array of digitized points
102  * int first, last; Indices of first and last pts in region
103  * Vec2d tHat1, tHat2; Unit tangent vectors at endpoints
104  * double error; User-defined error squared
105  */
106  void FitCubic(Vector2 *d, int first, int last, Vector2 tHat1, Vector2 tHat2, double error);
107 };
108 
109 } /* namespace Freestyle */
Vectors and Matrices (useful type definitions)
Curve curve
static void error(const char *str)
Definition: meshlaplacian.c:65
inherits from class Rep
Definition: AppCanvas.cpp:32
struct Freestyle::Point2Struct Point2
Point2 Vector2
Definition: FitCurve.h:66
double x() const
Definition: FitCurve.h:55
double & operator[](const int i)
Definition: FitCurve.h:50
double operator[](const int i) const
Definition: FitCurve.h:45
double y() const
Definition: FitCurve.h:60