Rumba C++ SDK
NurbsSurface.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 "NurbsCurve.h"
18 #include "Points.h"
19 #include "Mesh.h"
20 
21  namespace maquina
22  {
23  class NurbsCurve;
25 
27 
31  {
32  public:
34  enum Mode
35  {
36  Open = 0,
37  Closed = 1,
38  Periodic = 2
39  };
40 
42  NurbsSurface();
43 
45 
46  NurbsSurface(const Value &v);
47 
49 
51  const gsl::span<const NurbsCurve> &curves,
52  int degree_v,
53  Mode mode,
54  bool use_u_direction,
55  bool uniform
56  );
57 
59 
61  const gsl::span<const NurbsCurve> &curves,
62  const gsl::span<const float> &parameters,
63  int degree_v,
64  Mode mode,
65  bool use_u_direction
66  );
67 
70  const BufferConstV3f &points,
71  const BufferConstFloat &knots_u,
72  const BufferConstFloat &knots_v,
73  int degree_u,
74  int degree_v,
75  Mode mode_u,
76  Mode mode_v
77  );
78 
86  static NurbsSurface fit_open(const gsl::span<const Imath::V3f>& points, const gsl::span<const float>& parameters_u, const gsl::span<const float>& parameters_v, const gsl::span<const float>& knots_u, const gsl::span<const float>& knots_v, int pu, int pv, int du, int dv);
87 
95  static NurbsSurface fit_close_u(const gsl::span<const Imath::V3f>& points, const gsl::span<const float>& parameters_u, const gsl::span<const float>& parameters_v, const gsl::span<const float>& knots_u, const gsl::span<const float>& knots_v, int pu, int pv, int du, int dv);
96 
104  static NurbsSurface fit_close_v(const gsl::span<const Imath::V3f>& points, const gsl::span<const float>& parameters_u, const gsl::span<const float>& parameters_v, const gsl::span<const float>& knots_u, const gsl::span<const float>& knots_v, int pu, int pv, int du, int dv);
105 
107  const BufferConstFloat read_knots_u() const;
108 
110  BufferFloat write_knots_u();
111 
113  const BufferConstFloat read_knots_v() const;
114 
116  BufferFloat write_knots_v();
117 
119  int control_points_u() const;
120 
122  int control_points_v() const;
123 
125  int degree_u() const;
126 
128  int degree_v() const;
129 
131  Mode mode_u() const;
132 
134  Mode mode_v() const;
135 
137  int span_u() const;
138 
140  int span_v() const;
141 
143  Imath::V2f range_u() const;
144 
146  void set_range_u(const Imath::V2f& r);
147 
149  Imath::V2f range_v() const;
150 
152  void set_range_v(const Imath::V2f& r);
153 
155  Imath::V3f control_point(int u, int v) const;
156 
158  Imath::V3f evaluate(float u, float v) const;
159 
161  Imath::V3d evaluate(double u, double v) const;
162 
164  Imath::M44d matrix_at(double u, double v, double n) const;
165 
167 
168  NurbsCurve iso_curve(float u, bool use_v) const;
169 
171 
172  std::pair<Imath::V3f,Imath::V3f> evaluate_dp(float u, float v, bool previous_u=false, bool previous_v=false) const;
173 
175 
176  Imath::V2f closest(
177  const Imath::V3f& p,
178  Imath::V3f* r = nullptr,
179  float error = 0.001f,
180  int max_try = 10,
181  const std::shared_ptr<const NurbsSurfaceClosestCache>& cache = nullptr
182  ) const;
183 
185 
186  std::shared_ptr<const NurbsSurfaceClosestCache> closest_cache() const;
187 
189  Mesh tessellate(int subdivision_u, int subdivision_v, bool compute_uv_and_normals = false) const;
190 
192  void remap_knots_u(float new_min, float new_max);
193 
195  void remap_knots_v(float new_min, float new_max);
196 
198  void swap_u_v();
199 
201  void refine_knots_u(const gsl::span<const float>& new_knots);
202 
204  void refine_knots_v(const gsl::span<const float>& new_knots);
205 
208 
210  NurbsSurface(std::shared_ptr<Impl> impl) { _impl=impl; }
211  };
212  }
static const NurbsSurface default_value
The default value.
Definition: NurbsSurface.h:207
Definition: ImathFrame.h:42
Definition: ImathFrame.h:43
A nurbs surface value.
Definition: NurbsSurface.h:30
A mesh value.
Definition: Mesh.h:33
Definition: NurbsSurface.h:24
void error(const char *format, const Args &... args)
Log an error message using the Rumba logger.
Definition: Logger.h:50
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
Definition: ImathVec.h:61
A writable buffer for basic types like floats, integers, Imath::V3f, Imath::M44f..
Definition: Buffer.h:111
Mode
The surface curves mode.
Definition: NurbsSurface.h:34
A set of 3d points.
Definition: Points.h:25
Base class of all Rumba values.
Definition: Value.h:34