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