Blender  V3.3
FitCurve.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
11 #include <vector>
12 
13 #include "Geom.h"
14 
15 #include "../system/FreestyleConfig.h"
16 
17 namespace Freestyle {
18 
19 using namespace Geometry;
20 
21 /* 2d point */
22 typedef struct Point2Struct {
23  double coordinates[2];
24 
26  {
27  coordinates[0] = 0;
28  coordinates[1] = 0;
29  }
30 
31  inline double operator[](const int i) const
32  {
33  return coordinates[i];
34  }
35 
36  inline double &operator[](const int i)
37  {
38  return coordinates[i];
39  }
40 
41  inline double x() const
42  {
43  return coordinates[0];
44  }
45 
46  inline double y() const
47  {
48  return coordinates[1];
49  }
51 
52 typedef Point2 Vector2;
53 
55  private:
56  std::vector<Vector2> _vertices;
57 
58  public:
59  ~FitCurveWrapper();
60 
70  void FitCurve(std::vector<Vec2d> &data, std::vector<Vec2d> &oCurve, double error);
71 
72  protected:
73  /* Vec2d *d; Array of digitized points
74  * int nPts; Number of digitized points
75  * double error; User-defined error squared
76  */
77  void FitCurve(Vector2 *d, int nPts, double error);
78 
85  void DrawBezierCurve(int n, Vector2 *curve);
86 
87  /* Vec2d *d; Array of digitized points
88  * int first, last; Indices of first and last pts in region
89  * Vec2d tHat1, tHat2; Unit tangent vectors at endpoints
90  * double error; User-defined error squared
91  */
92  void FitCubic(Vector2 *d, int first, int last, Vector2 tHat1, Vector2 tHat2, double error);
93 };
94 
95 } /* namespace Freestyle */
Vectors and Matrices (useful type definitions)
Curve curve
static void error(const char *str)
Definition: meshlaplacian.c:51
inherits from class Rep
Definition: AppCanvas.cpp:18
struct Freestyle::Point2Struct Point2
Point2 Vector2
Definition: FitCurve.h:52
double x() const
Definition: FitCurve.h:41
double & operator[](const int i)
Definition: FitCurve.h:36
double operator[](const int i) const
Definition: FitCurve.h:31
double y() const
Definition: FitCurve.h:46