BsplineStructs.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 #include <Bentley/RefCounted.h>
10 #ifndef MS_BSPLINE_STRUCTURES_DEFINED
11 #define MS_BSPLINE_STRUCTURES_DEFINED
12 
15 
16 /* B-Spline curve types */
17 #define BSCURVE_GENERAL 0
18 #define BSCURVE_LINE 1
19 #define BSCURVE_CIRCULAR_ARC 2
20 #define BSCURVE_CIRCLE 3
21 #define BSCURVE_ELLIPTICAL_ARC 4
22 #define BSCURVE_ELLIPSE 5
23 #define BSCURVE_PARABOLIC_ARC 6
24 #define BSCURVE_HYPERBOLIC_ARC 7
25 
26 /* B-Spline surface types */
27 #define BSSURF_GENERAL 0
28 #define BSSURF_PLANE 1
29 #define BSSURF_RIGHT_CYLINDER 2
30 #define BSSURF_CONE 3
31 #define BSSURF_SPHERE 4
32 #define BSSURF_TORUS 5
33 #define BSSURF_REVOLUTION 6
34 #define BSSURF_TAB_CYLINDER 7
35 #define BSSURF_RULED_SURFACE 8
36 
37 /* Constants */
38 #define BSSURF_U 0
39 #define BSSURF_V 1
40 
41 /* Miscellaneous Maxima */
42 #define MAX_POLES MAX_VERTICES
43 #define MAX_ORDER 26
44 #define MAX_KNOTS (MAX_POLES + 2*MAX_ORDER - 1)
45 #define MAX_BNDRY_PTS MAX_VERTICES
46 #define MAX_DATA_PTS MAX_VERTICES
47 #define MAX_BSORDER MAX_ORDER
48 /* Tolerances */
49 #define KNOT_TOLERANCE_BASIS 1E-10
50 
51 /* Fit modes */
52 #define FIT_POLES 0
53 #define FIT_POINTS 1
54 #define FIT_LEASTSQUARES 2
55 #define FIT_CATMULLROM 3
56 
57 /* Offset cusp treatments */
58 #define OFFSET_JUMP_CUSP 0
59 #define OFFSET_CHAMFER_CUSP 1
60 #define OFFSET_POINT_CUSP 2
61 #define OFFSET_PARABOLA_CUSP 3
62 #define OFFSET_ARC_CUSP 4
63 
64 /* Continuity degree specifications */
65 #define POSITION_CONTINUITY 0
66 #define TANGENT_CONTINUITY 1
67 #define CURVATURE_CONTINUITY 2
68 #define DERIVATIVE_CONTINUITY 3
69 
70 /* Truncation specifications */
71 #define TRUNCATE_BOTH 0
72 #define TRUNCATE_NONE 1
73 #define TRUNCATE_SINGLE 2
74 
75 /* Iso display for silhouette curves */
76 #define SILHBND_U 0
77 #define SILHBND_V 1
78 #define SILHBND_NONE 2
79 #define SILHBND_BOTH 3
80 
81 /* Surface edge classification */
82 #define NO_EDGE 0x0000
83 #define U0_EDGE 0x0001
84 #define U1_EDGE 0x0002
85 #define V0_EDGE 0x0004
86 #define V1_EDGE 0x0008
87 #define ANY_EDGE 0x000F
88 
89 typedef int MSBsplineStatus;
90 #define MSB_SUCCESS 0
91 #define MSB_ERROR 0x8000
92 
95 
96 struct GEOMDLLIMPEXP bSplineParam
97  {
105  int32_t numKnots; /* # interior knots or zero for uniform */
108 
111  int NumberAllocatedKnots () const;
114  static int NumberAllocatedKnots (int32_t numPoles, int32_t order, int32_t closed);
115 
117  static int NumberInteriorKnots (int32_t numPoles, int32_t order, int32_t closed);
118 
119  };
120 
123 
125  {
126  int32_t order; /* default 4 */
128  int32_t numPoints; /* including duplicate pt if periodic */
129  int32_t numKnots; /* # full knots, never zero */
130  int32_t isChordLenKnots; /* default 1 */
131  int32_t isColinearTangents; /* default 0 */
132  int32_t isChordLenTangents; /* default 1 */
133  int32_t isNaturalTangents; /* default 1 */
134  };
135 
138 
140  {
144  };
145 
146 
151 
153  {
154  private:
155  // Centroid, length integrals with optional centroid.
156  void WireIntegrals (double &length, DPoint3dP centroid,
157  double fractionA, double fractionB);
158  public:
159  enum
160  {
161  MaxOrder = 26,
162  };
163  private:
164  DPoint4d m_poles[MaxOrder];
165  DPoint4d m_workPoles[MaxOrder];
166  double m_knots[2 * MaxOrder];
167  size_t m_order;
168  size_t m_workOrder;
169  size_t m_numKnots;
170 
171  //friend struct MSBsplineCurve;
172  friend bool bspcurv_getSupport (MSBsplineCurveCR curve, BCurveSegmentR segment, size_t bezierSelect);
173  friend GEOMDLLIMPEXP int bspproc_prepareCurve (MSBsplineCurveP, int*, int **, MSBsplineCurveP);
174 
176  size_t m_index;
178  double m_uMin;
180  double m_uMax;
182  bool m_isNullU;
183  public:
184 
185  GEOMDLLIMPEXP BCurveSegment ();
186 
188  GEOMDLLIMPEXP void FractionToPoint (DPoint3dR xyz, double f) const;
189 
191  GEOMDLLIMPEXP DPoint3d FractionToPoint (double f) const;
192 
194  GEOMDLLIMPEXP double FractionToKnot (double f) const;
195 
197  GEOMDLLIMPEXP void FractionToPoint (DPoint3dR xyz, DVec3dR tangent, double f, bool applyKnotScale = true) const;
198 
200  GEOMDLLIMPEXP void CopyFrom (BCurveSegmentCR source, DMatrix4dCP matrix = NULL);
201 
203  GEOMDLLIMPEXP void CopyFrom (BCurveSegmentCR source, RotMatrixCR matrix);
204 
206  GEOMDLLIMPEXP void CopyFrom (BCurveSegmentCR source, TransformCR matrix);
207 
209  GEOMDLLIMPEXP void WireCentroid (double &length, DPoint3dR centroid, double fraction0, double fraction1);
210 
212  GEOMDLLIMPEXP void Length (double &length, double fraction0, double fraction1);
214  GEOMDLLIMPEXP void Length (RotMatrixCP worldToLocal, double &length, double fraction0, double fraction1);
215 
216 
218  GEOMDLLIMPEXP double PolygonLength () const;
219 
221  GEOMDLLIMPEXP DRange1d KnotRange () const;
222 
225  GEOMDLLIMPEXP void SaturateKnots ();
226 
236  GEOMDLLIMPEXP void AddStrokes
237  (
238  bvector <DPoint3d> &points,
239  bvector <DVec3d> *derivatives,
240  bvector<double> *params,
241  IFacetOptionsCR options,
242  double fractionA = 0.0,
243  double fractionB = 1.0,
244  bool useWorkPoles = false,
245  MSBsplineCurveCP curve = NULL
246  ) const;
247 
248  //GEOMDLLIMPEXP void MapBezierFractions (bvector<double> *params, CurveParameterMapping select) const;
249 
250 
252  GEOMDLLIMPEXP bool IsRational (bool useWorkPoles = false) const;
254  GEOMDLLIMPEXP DPoint4dP GetWorkPoleP (size_t index);
256  GEOMDLLIMPEXP size_t GetWorkOrder ();
258  GEOMDLLIMPEXP void Multiply (TransformCR transform);
259 
261  GEOMDLLIMPEXP void BuildWorkPoles (TransformCR transform);
262 
270  GEOMDLLIMPEXP void AddExtrema (bvector<double> &params,
271  DRange3dP range = NULL,
272  bool mapToKnots = false, size_t firstDimension = 0, size_t lastDimension = 2, bool includeStartEnd = true) const;
273 
274 
276  GEOMDLLIMPEXP bool TryGetPoleXYZ (size_t index, DPoint3dR xyz) const;
278  GEOMDLLIMPEXP DPoint4dP GetPoleP (size_t index);
280  GEOMDLLIMPEXP DPoint4dP GetPoleP ();
282  GEOMDLLIMPEXP size_t GetOrder ();
284  GEOMDLLIMPEXP size_t GetNumKnots ();
285 
287  GEOMDLLIMPEXP double *GetKnotP (size_t index);
289  GEOMDLLIMPEXP double *GetKnotP ();
290 
292  GEOMDLLIMPEXP bool IsNullU () const;
294  GEOMDLLIMPEXP double UMin () const;
296  GEOMDLLIMPEXP double UMax () const;
297 
299  GEOMDLLIMPEXP void SetUMin (double u);
301  GEOMDLLIMPEXP void SetUMax (double u);
302 
306  GEOMDLLIMPEXP bool SubdivideToIntersection (DRange1dCR interval);
307 
309  GEOMDLLIMPEXP size_t Index () const;
310 
323  static GEOMDLLIMPEXP bool RefineCloseApproach
324  (
325  BCurveSegmentR curveA,
326  double fractionAin,
327  BCurveSegmentR curveB,
328  double fractionBin,
329  bool useWorkPoles,
330  bool xyOnly,
331  double &fractionAOut,
332  DPoint3dR xyzAOut,
333  double &fractionBOut,
334  DPoint3dR xyzBOut
335  );
336  };
337 
339 #endif
struct RotMatrix const * RotMatrixCP
Definition: msgeomstructs_typedefs.h:135
int32_t order
Curve order (one more than polynomial degree).
Definition: BsplineStructs.h:99
MSBsplineCurve is a "Non uniform, rational Bspline curve".
Definition: MSBsplineCurve.h:46
int32_t numKnots
Knot count. See NumberAllocatedKnots.
Definition: BsplineStructs.h:105
int32_t isColinearTangents
Definition: BsplineStructs.h:131
struct IFacetOptions const & IFacetOptionsCR
Definition: msgeomstructs_typedefs.h:162
Spline order, closure, and count data.
Definition: BsplineStructs.h:96
int32_t numRules
Not used.
Definition: BsplineStructs.h:107
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
int32_t isPeriodic
Definition: BsplineStructs.h:127
struct RotMatrix const & RotMatrixCR
Definition: msgeomstructs_typedefs.h:135
struct DRange1d const & DRange1dCR
Definition: msgeomstructs_typedefs.h:102
int int32_t
Definition: Bentley.r.h:92
#define NULL
Definition: Bentley.h:157
4d point coordinates.
Definition: dpoint4d.h:17
int32_t isChordLenKnots
Definition: BsplineStructs.h:130
int32_t isNaturalTangents
Definition: BsplineStructs.h:133
struct MSBsplineCurve const & MSBsplineCurveCR
Definition: msgeomstructs_typedefs.h:139
int32_t closed
True if the curve uses poles in a periodic sense.
Definition: BsplineStructs.h:101
3d point coordinates.
Definition: dpoint3d.h:19
int32_t numPoles
Number of stored poles.
Definition: BsplineStructs.h:103
int32_t curveDisplay
Definition: BsplineStructs.h:142
A 1d interval with low and high values.
Definition: DRange1d.h:41
int32_t rulesByLength
Definition: BsplineStructs.h:143
struct DMatrix4d const * DMatrix4dCP
Definition: msgeomstructs_typedefs.h:97
struct Transform const & TransformCR
Definition: msgeomstructs_typedefs.h:134
int32_t polygonDisplay
Definition: BsplineStructs.h:141
struct MSBsplineCurve const * MSBsplineCurveCP
Definition: msgeomstructs_typedefs.h:139
int32_t numPoints
Definition: BsplineStructs.h:128
int32_t isChordLenTangents
Definition: BsplineStructs.h:132
int32_t numKnots
Definition: BsplineStructs.h:129
int32_t order
Definition: BsplineStructs.h:126
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
int MSBsplineStatus
Definition: BsplineStructs.h:89
struct BCurveSegment const & BCurveSegmentCR
Definition: msgeomstructs_typedefs.h:161
Vector with x,y,z components.
Definition: dvec3d.h:110
Interpolation controls.
Definition: BsplineStructs.h:124
A 3d low and high corner pair for range boxes.
Definition: drange3d.h:20
spline display controls
Definition: BsplineStructs.h:139
Complete data for a single patch segment extracted from a bspline curve.
Definition: BsplineStructs.h:152

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.