Rumba C++ SDK
NurbsCurve.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Points.h"
18 
19  namespace maquina
20  {
22 
24  {
25  public:
27  enum Mode
28  {
29  Open = 0,
30  Closed = 1,
31  Periodic = 2
32  };
33 
36 
39  NurbsCurve();
40 
42  NurbsCurve(const BufferConstV3f &points, const BufferConstFloat &knots, int degree, Mode mode);
43  NurbsCurve(const BufferConstV3f &points, const BufferConstFloat &knots, const BufferConstFloat &weights, int degree, Mode mode);
44 
46 
47  NurbsCurve(const Value &v);
48 
50 
56  static NurbsCurve fit_closed(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
57 
59 
64  static NurbsCurve fit_open(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
65 
67 
74  static NurbsCurve fit_open2(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
75 
77 
84  static NurbsCurve fit_open(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, const Imath::V3f& d0, const Imath::V3f& dn, int degree);
85 
87 
90 
93  const BufferConstFloat read_knots() const;
94 
96  BufferFloat write_knots();
97 
99  const BufferConstFloat read_weights() const;
100 
102  BufferFloat write_weights();
103 
105  int degree() const;
106 
108  Mode mode() const;
109 
111  int span() const;
112 
114 
115  Imath::V2f range() const;
117 
120 
123  Imath::V3f evaluate(float u) const;
124 
126  Imath::V3d evaluate(double u) const;
127 
129 
130  Imath::V3f evaluate_dp(float u) const;
131 
133 
137  void derivatives(float u, int n, std::vector<Imath::V3f>& derivatives) const;
138 
140  float length(
141  float start,
142  float end,
143  float error = 0.001f
144  ) const;
145 
147  float param_from_length(
148  float length,
149  bool relative = false,
150  float error = 0.001f,
151  int max_try = 100
152  ) const;
153 
155 
159  float closest(
160  const Imath::V3f& p,
161  Imath::V3f* r = nullptr,
162  float error = 0.001f,
163  int max_try = 10,
164  const gsl::span<const Imath::V3f>& cache = {}
165  ) const;
166 
168 
171 
174 
175  void resample( const gsl::span<const float> &knots, int degree);
176 
178 
179  void set_range(const Imath::V2f& range);
180 
182  void reverse();
183 
185 
186  bool split(float u, NurbsCurve& lower, NurbsCurve& upper) const;
187 
189 
191  static const NurbsCurve default_value;
192 
194  NurbsCurve(std::shared_ptr<Impl> impl) { _impl=impl; }
195  };
196  }
Definition: ImathFrame.h:42
void error(const char *format, const Args &... args)
Log an error message using the Rumba logger.
Definition: Logger.h:50
Mode
The surface curves mode.
Definition: NurbsCurve.h:27
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
A nurbs curve value.
Definition: NurbsCurve.h:23
#define MAQUINA_EXPORT
Definition: Export.h:31
Definition: ImathVec.h:61
static const NurbsCurve default_value
The default value.
Definition: NurbsCurve.h:191
A writable buffer for basic types like floats, integers, Imath::V3f, Imath::M44f..
Definition: Buffer.h:106
A set of 3d points.
Definition: Points.h:26
Base class of all Rumba values.
Definition: Value.h:34