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 "Points.h"
18 #include "SpanSpan.h"
19 #include "Mesh.h"
20 
21  namespace maquina
22  {
24 
28  {
29  public:
31  enum Mode
32  {
33  Open = 0,
34  Closed = 1,
35  Periodic = 2
36  };
37 
39  NurbsSurface();
40 
42 
43  NurbsSurface(const Value &v);
44 
46 
48  const gsl::span<const NurbsCurve> &curves,
49  int degree_v,
50  Mode mode,
51  bool use_u_direction,
52  bool uniform
53  );
54 
56 
58  const gsl::span<const NurbsCurve> &curves,
59  const gsl::span<const float> &parameters,
60  int degree_v,
61  Mode mode,
62  bool use_u_direction
63  );
64 
67  const BufferConstV3f &points,
68  const BufferConstFloat &knots_u,
69  const BufferConstFloat &knots_v,
70  int degree_u,
71  int degree_v,
72  Mode mode_u,
73  Mode mode_v
74  );
75 
83  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);
84 
92  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);
93 
101  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);
102 
104  const BufferConstFloat read_knots_u() const;
105 
107  BufferFloat write_knots_u();
108 
110  const BufferConstFloat read_knots_v() const;
111 
113  BufferFloat write_knots_v();
114 
116  int control_points_u() const;
117 
119  int control_points_v() const;
120 
122  int degree_u() const;
123 
125  int degree_v() const;
126 
128  Mode mode_u() const;
129 
131  Mode mode_v() const;
132 
134  int span_u() const;
135 
137  int span_v() const;
138 
140  Imath::V2f range_u() const;
141 
143  void set_range_u(const Imath::V2f& r);
144 
146  Imath::V2f range_v() const;
147 
149  void set_range_v(const Imath::V2f& r);
150 
152  Imath::V3f control_point(int u, int v) const;
153 
155  Imath::V3f evaluate(float u, float v) const;
156 
158  Imath::V3d evaluate(double u, double v) const;
159 
161 
162  NurbsCurve iso_curve(float u, bool use_v) const;
163 
165 
166  std::pair<Imath::V3f,Imath::V3f> evaluate_dp(float u, float v, bool previous_u=false, bool previous_v=false) const;
167 
169 
170  Imath::V2f closest(
171  const Imath::V3f& p,
172  Imath::V3f* r = nullptr,
173  float error = 0.001f,
174  int max_try = 10
175  ) const;
176 
178  Mesh tessellate(int subdivision_u, int subdivision_v, bool compute_uv_and_normals = false) const;
179 
181  void remap_knots_u(float new_min, float new_max);
182 
184  void remap_knots_v(float new_min, float new_max);
185 
187  void swap_u_v();
188 
190  void refine_knots_v(const gsl::span<const float>& new_knots);
191 
194 
196  NurbsSurface(std::shared_ptr<Impl> impl) { _impl=impl; }
197  };
198  }
static const NurbsSurface default_value
The default value.
Definition: NurbsSurface.h:193
Definition: ImathFrame.h:42
A nurbs surface value.
Definition: NurbsSurface.h:27
A mesh value.
Definition: Mesh.h:33
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:23
#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:106
Mode
The surface curves mode.
Definition: NurbsSurface.h:31
A set of 3d points.
Definition: Points.h:26
Base class of all Rumba values.
Definition: Value.h:34