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  {};
23 
25 
27  {
28  public:
30  enum Mode
31  {
32  Open = 0,
33  Closed = 1,
34  Periodic = 2
35  };
36 
39 
42  NurbsCurve();
43 
45  NurbsCurve(const BufferConstV3f &points, const BufferConstFloat &knots, int degree, Mode mode);
46  NurbsCurve(const BufferConstV3f &points, const BufferConstFloat &knots, const BufferConstFloat &weights, int degree, Mode mode);
47 
49 
50  NurbsCurve(const Value &v);
51 
53 
59  static NurbsCurve fit_closed(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
60 
62 
67  static NurbsCurve fit_open(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
68 
70 
77  static NurbsCurve fit_open2(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, int degree);
78 
80 
87  static NurbsCurve fit_open(const BufferConstV3f& points, const BufferConstFloat& points_parameter, const BufferConstFloat& knots, const Imath::V3f& d0, const Imath::V3f& dn, int degree);
88 
90 
93 
96  const BufferConstFloat read_knots() const;
97 
99  BufferFloat write_knots();
100 
102  const BufferConstFloat read_weights() const;
103 
105  BufferFloat write_weights();
106 
108  int degree() const;
109 
111  Mode mode() const;
112 
114  int span() const;
115 
117 
118  Imath::V2f range() const;
120 
123 
126  Imath::V3f evaluate(float u) const;
127 
129  Imath::V3d evaluate(double u) const;
130 
132 
133  Imath::V3f evaluate_dp(float u) const;
134 
136 
140  void derivatives(float u, const gsl::span<Imath::V3f>& derivatives) const;
141 
143  float length(
144  float error = 0.001f
145  ) const;
146 
148  float length(
149  float start,
150  float end,
151  float error = 0.001f
152  ) const;
153 
155  float param_from_length(
156  float length,
157  bool relative = false,
158  float error = 0.001f,
159  int max_try = 100,
160  const std::shared_ptr<const NurbsCurveParamFromLengthCache>& cache = nullptr
161  ) const;
162 
164 
165  std::shared_ptr<const NurbsCurveParamFromLengthCache> param_from_length_cache(float error = 0.001f, int n=100) const;
166 
168 
172  float closest(
173  const Imath::V3f& p,
174  Imath::V3f* r = nullptr,
175  float error = 0.001f,
176  int max_try = 10,
177  const gsl::span<const Imath::V3f>& cache = {}
178  ) const;
179 
181 
184 
187 
188  void resample( const gsl::span<const float> &knots, int degree);
189 
191 
192  void set_range(const Imath::V2f& range);
193 
195  void reverse();
196 
198  void split(float u, NurbsCurve& lower, NurbsCurve& upper) const;
199 
201 
203  static const NurbsCurve default_value;
204 
206  NurbsCurve(std::shared_ptr<Impl> impl) { _impl=impl; }
207  };
208  }
Definition: ImathFrame.h:42
void error(const char *format, const Args &... args)
Log an error message using the Rumba logger.
Definition: Logger.h:50
Definition: NurbsCurve.h:21
Mode
The surface curves mode.
Definition: NurbsCurve.h:30
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:26
#define MAQUINA_EXPORT
Definition: Export.h:31
MAQUINA_EXPORT std::vector< std::string > split(const StringView &s, const StringView &sep)
Return a list of the words in the string, using the sep string as delimiter.
Definition: ImathVec.h:61
static const NurbsCurve default_value
The default value.
Definition: NurbsCurve.h:203
A writable buffer for basic types like floats, integers, Imath::V3f, Imath::M44f..
Definition: Buffer.h:111
A set of 3d points.
Definition: Points.h:25
Base class of all Rumba values.
Definition: Value.h:34