zjf
2023-03-13 881f0da670f20c401c1e1d08b36253abb28f72d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
 
#ifndef ODDB_DBSPLINE_H
#define ODDB_DBSPLINE_H
 
#include "TD_PackPush.h"
 
#include "DbCurve.h"
 
class OdGeKnotVector;
 
/** \details
    This class represents Spline entities in an OdDbDatabase instance.
 
    \sa
    TD_Db
    <group OdDb_Classes> 
*/
class TOOLKIT_EXPORT OdDbSpline : public OdDbCurve
{
public:
  ODDB_DECLARE_MEMBERS(OdDbSpline);
 
  OdDbSpline();
  
  /** \details
     Returns true if and only if this Spline entity is rational (DXF 70, bit 0x04).
  */
  bool isRational() const;
  
  /** \details
    Returns the degree of this Spline entity (DXF 71).
    \remarks
    degree is in the range [1..25].  
  */
  int degree() const;
  
  /** \details
      Increased the degree of this spline to the specified value.
  */
  void elevateDegree(int newDegree);
    
  /** \details
    Returns the number of control points in this Spline entity (DXF 73).
  */
  int numControlPoints() const;
  
  /** \details
    Returns the specified control point of this Spline entity (DXF 10).
 
    \param controlPointIndex [in]  Control point index.
    \param point [out]  Receives the control point.
  */
  void getControlPointAt(
    int controlPointIndex, 
    OdGePoint3d& point) const;
  
  /** \details
      Sets the specified control point of this Spline entity (DXF 10).
 
      \param controlPointIndex [in]  Control point index.
      \param point [in]  Control point.
  */
  void setControlPointAt(
    int controlPointIndex, 
    const OdGePoint3d& point);
  
  /** \details
    Returns the number of fit points in this Spline entity (DXF 74).
  */
  int numFitPoints() const;
  
  /** \details
    Returns the specified fit point of this Spline entity (DXF 11).
 
    \param fitPointIndex [in]  Fit point index.
    \param point [out]  Receives the fit point.
  */
  OdResult getFitPointAt(
    int fitPointIndex, 
    OdGePoint3d& point) const;
  
  /** \details
    Sets the specfied fit point of this Spline entity (DXF 11).
 
    \param fitPointIndex [in]  Fit point index.
    \param point [in]  Fit point.
  */
  void setFitPointAt(
    int fitPointIndex, 
    const OdGePoint3d& point);
  
  /** \details
    Inserts a fit point into this Spline entity after the specified index.
      
    \param fitPointIndex [in]  Fit point index.
    \param point [out]  Receives the fit point.
    
    \remarks
    If fitPointIndex < 0, point is inserted at before the first fit point. 
    
    If fitPointIndex >= numFitPoints(), point is appended to the spline. 
  */
  void insertFitPointAt(
    int fitPointIndex, 
    const OdGePoint3d& point);
  
  /** \details
    Removes the specified fit point from this Spline entity.
 
    \param fitPointIndex [in]  Fit point index.
  */
  void removeFitPointAt(
    int fitPointIndex);
  
  /** \details
    Returns the curve fitting tolerance for this Spline entity (DXF 44).
    
    \remarks
    This is the maximum drawing unit distance by which the Spline curve can deviate
    from a fit points. 
  */
  double fitTolerance() const;
  
  /** \details
    Sets the curve fitting tolerance for this Spline entity (DXF 44).
    
    \remarks
    This is the maximum drawing unit distance by which the Spline curve can deviate
    from a fit points. 
    
    \param fitTolerance [in]  Geometric tolerance.
  */
  void setFitTol(
    double fitTolerance);
  
  /** \details
    Returns the start point and end point WCS fit tangents for this Spline entity (DXF 12, 13).
    \param startTangent [out]  Receives the start point tangent.
    \param endTangent [out]  Receives the end point tangent.
  */
  OdResult getFitTangents(
    OdGeVector3d& startTangent, 
    OdGeVector3d& endTangent) const;
  
  /** \details
    Sets the start point and end point WCS fit tangents for this Spline entity (DXF 12, 13).
    \param startTangent [out]  Start point tangent.
    \param endTangent [out]  End point tangent.
  */
  void setFitTangents(
    const OdGeVector3d& startTangent, 
    const OdGeVector3d& endTangent);
  
  /** \details
    Returns true if and only if this Spline entity is constructed using fit points.
  */
  bool hasFitData() const;
  
  /** \details
    Returns the fit data for this Spline entity.
 
    \param fitPoints [out]  Receives the fit points.
    \param degree [out]  Receives the degree.
    \param fitTolerance [out]  Receives the fit tolerance.
    \param tangentsExist [out]  Receives true if and only if start and end tangents are used.
    \param startTangent [out]  Receives the start point tangent.
    \param endTangent [out]  Receives the end point tangent.
    \param knotParam [out]  Receives the knot parametrization.
  */
  OdResult getFitData(
    OdGePoint3dArray& fitPoints, 
    int& degree, 
    double& fitTolerance, 
    bool& tangentsExist, 
    OdGeVector3d& startTangent, 
    OdGeVector3d& endTangent ) const;
  
  OdResult getFitData(
    OdGePoint3dArray& fitPoints, 
    int& degree, 
    double& fitTolerance, 
    bool& tangentsExist, 
    OdGeVector3d& startTangent, 
    OdGeVector3d& endTangent,
    OdGe::OdGeKnotParameterization& knotParam) const;
  
  /** \details
    Sets the fit data for this Spline entity.
    \param fitPoints [in]  Fit points.
    \param degree [in]  Degree.
    \param fitTolerance [in]  Fit tolerance.
    \param startTangent [in]  Start point tangent.
    \param endTangent [in]  End point tangent.
    \param endTangent [in]  Knot parametrization.
  */
  void setFitData(
    const OdGePoint3dArray& fitPoints, 
    int degree, 
    double fitTolerance, 
    const OdGeVector3d& startTangent, 
    const OdGeVector3d& endTangent );
 
  void setFitData(
    const OdGePoint3dArray& fitPoints, 
    int degree, 
    double fitTolerance, 
    const OdGeVector3d& startTangent, 
    const OdGeVector3d& endTangent,
    OdGe::OdGeKnotParameterization knotParam);
  
  /** \details
    Purges the fit data for this Spline entity.
  */
  void purgeFitData();
  
  /** \details
      TBC.
      void updateFitData();
  */
  
  /** \details
    Returns the NURBS data for this Spline entity.
    \param degree [out]  Receives the degree.
    \param rational [out]  Receives true if and only if this Spline entity is rational.
    \param closed [out]  Receives true if and only if this Spline entity is closed.
    \param periodic [out]  Receives true if and only if this Spline entity is periodic.
    \param controlPoints [out]  Receives an array of WCS control points.
    \param knots [out]  Receives the knot vector.
    \param weights [out]  Receives an array of weights.
    \param controlPtTol [out]  Receives the control point tolerance.
    \param knotTol [out]  Receives the knot tolerance.
  */
  void getNurbsData(
    int& degree, 
    bool& rational, 
    bool& closed, 
    bool& periodic,
    OdGePoint3dArray& controlPoints, 
    OdGeDoubleArray& knots, 
    OdGeDoubleArray& weights, 
    double& controlPtTol,
    double& knotTol) const;
 
  void getNurbsData(
    int& degree, 
    bool& rational, 
    bool& closed, 
    bool& periodic,
    OdGePoint3dArray& controlPoints, 
    OdGeKnotVector& knots, 
    OdGeDoubleArray& weights, 
    double& controlPtTol) const;
  
  /** \details
    Sets the NURBS data for this Spline entity.
    \param degree [in]  Degree.
    \param rational [in]  Controls if this Spline entity is rational.
    \param closed [in]  Controls if this Spline entity closed.
    \param periodic [in]  Controls if this Spline entity is periodic.
    \param controlPoints [in]  Array of WCS control points.
    \param knots [in]  Knot vector.
    \param weights [in]  Array of weights.
    \param controlPtTol [in]  Control point tolerance.
    \param knotTol [in]  Knot tolerance.
    
    \remarks
    * degree is in the range of [1..25]
    * If rational is true, controlPoints.length() must equal weights.length()
    * If periodic is false, then knots.length() must equal controlPoints.length() + degree + 1
    * If periodic is true, then knots.length() must equal controlPoints.length(), 
      the first and last controlPoints must be equal, and the first and last weights (if provided) must be equal.
    * If two control points are within controlPtTol, they are treated as the same control point.
    * If two knots are within knotTol, they are treated as the same knot.
  */
  void setNurbsData(int degree, 
    bool rational, 
    bool closed, 
    bool periodic,
    const OdGePoint3dArray& controlPoints, 
    const OdGeDoubleArray& knots, 
    const OdGeDoubleArray& weights,
    double controlPtTol, 
    double knotTol );
  
  void setNurbsData(
    int degree, 
    bool rational, 
    bool closed, 
    bool periodic,
    const OdGePoint3dArray& controlPoints, 
    const OdGeKnotVector& knots, 
    const OdGeDoubleArray& weights,
    double controlPtTol);
  
  /** \details
    Returns the specified weight (DXF 41).
    \param weightIndex [in]  Weight index.
  */
  double weightAt(
    int weightIndex) const;
  
  /** \details
    Sets the specified weight (DXF 41).
    \param weightIndex [in]  Weight index.
    \param weight [in]  Weight.
  */
  void setWeightAt(
    int weightIndex, 
    double weight);
  
  /** \details
      Inserts a knot value into this spline.
  */
  void insertKnot(double param);
  
  /** \details
     Reverses this Spline entity.
     
     \remarks
     The start point becomes the end point, and vice versa.
  */
  virtual OdResult reverseCurve();
  
  
  virtual OdResult subGetClassID(
    void* pClsid) const;
  
  /*
     void getOffsetCurvesGivenPlaneNormal(const OdGeVector3d& normal,  //Replace OdRxObjectPtrArray
                                          double offsetDist, 
                                          OdRxObjectPtrArray& offsetCurves ) const;
  */
    
  virtual OdResult dwgInFields(
    OdDbDwgFiler* pFiler);
  
  virtual void dwgOutFields(
    OdDbDwgFiler* pFiler) const;
  
  virtual OdResult dxfInFields(
    OdDbDxfFiler* pFiler);
  
  virtual void dxfOutFields(
    OdDbDxfFiler* pFiler) const;
  
  virtual bool subWorldDraw(
    OdGiWorldDraw* pWd) const;
 
  virtual OdResult subTransformBy(
    const OdGeMatrix3d& xfm);
 
  virtual bool isPlanar() const;
 
  virtual OdResult getPlane(
    OdGePlane& plane, 
    OdDb::Planarity& planarity) const;
 
 
  /** \details
      OdDbCurve methods
  */
 
  virtual OdResult getPointAtParam(
    double param, 
    OdGePoint3d& pointOnCurve) const;
 
  virtual OdResult getParamAtPoint(
    const OdGePoint3d& pointOnCurve, 
    double& param) const;
 
  virtual OdResult getStartParam(
    double& startParam) const;
 
  virtual OdResult getEndParam (
    double& endParam) const;
 
  virtual OdResult getStartPoint(
    OdGePoint3d& startPoint) const;
 
  virtual OdResult getEndPoint(
    OdGePoint3d& endPoint) const;
 
  virtual OdResult getDistAtParam( double param, double& dist ) const;
 
  virtual OdResult getParamAtDist( double dist, double& param ) const;
 
  virtual OdResult getFirstDeriv (
    double param,
    OdGeVector3d& firstDeriv) const;
 
  virtual OdResult getSecondDeriv (
    double param,
    OdGeVector3d& secondDeriv) const;
 
  virtual OdResult getArea(
    double& area) const;
 
  TD_USING(OdDbCurve::getFirstDeriv);
  TD_USING(OdDbCurve::getSecondDeriv);
 
  /** \details
    Returns pointers to the curves that result from splitting this curve at the points corresponding 
    to params.
 
    \param params [in]  The parameter values corresponding to the split points.
    \param entitySet [out]  Receives an array of pointers to the split curves.
    
    \remarks
    * The first split curve will be from the start of this curve to params[0].
    * The second split curve will be from params[0] to params[1].
    * The last split curve will be from params[n-1] to the end of his curve.
  */
        virtual OdResult getSplitCurves(
    const OdGeDoubleArray& params, 
    OdRxObjectPtrArray& entitySet) const;
 
  TD_USING(OdDbCurve::getSplitCurves);
  
  OdDbObjectPtr decomposeForSave(
    OdDb::DwgVersion ver,
    OdDbObjectId& replaceId,
    bool& exchangeXData);
 
  /** \details
    Defines the spline method (either by fit points or by control points).
  */
    enum SplineType 
  {
    kFitPoints = 0,     // By fit points.
    kControlPoints = 1  // By control points.
  };
 
  /** \details
    Returns the spline method (either by fit points or by control points).
  */
    SplineType type() const;
 
  /** \details
    Sets the spline method (either by fit points or by control points).
 
    \param type [in]  spline type to be set.
 
    \note
    Returns the result of the operation: eOk if successful, or an appropriate error code if not.
 
    \remarks
    Changing type from kControlPoints to kFitPoints recalculates fit points from control points.
  */
 
  OdResult setType(SplineType type);
 
  /** \details
    Returns true if Control Vertices frame is visible.
  */
        bool cvFrame() const;
 
  /** \details
    Sets visibility of Control Vertices frame for this Spline entity.
    \param bVisible [in]  Control vertices frame visiblity.
  */
        void setCvFrame(bool bVisible);
 
   /** \details
    Inserts a control point at the specified knot.
    
    \param knotParam [in]  The knot parameter to add the control point at.
    \param ctrlPt [in]  Coordinates of the control point to be added.
    \param weight [in] The weight to be assigned to the control point.
    
    \remarks
    When called for a non-rational spline, weight is ignored.
    
      \note
    eOk if successful, or an appropriate error code if not.
   */
  OdResult insertControlPointAt(double knotParam, const OdGePoint3d& ctrlPt, double weight = 1.0);
 
  /** \details
    Deletes a control point at the specified index.
    
    \param index [in]  The index of the control point to be deleted.
    
      \note
    eOk if successful, or an appropriate error code if not.
  */
  OdResult removeControlPointAt(int index);
 
/** \details
    Returns true if the spline doesn't contain control points.
*/
   bool isNull() const;
 
  /** \details
    Modifies the position and tangent of the point with a specified parameter.
 
    \param param [in]  Parameter value of the point.
    \param point [in]  New position of the point.
    \param deriv [in]  New value of the tangent vector at the point.
           
    \note
    Returns true if and only if the point has successfully been adjusted.
  */
  bool modifyPositionAndTangent(double param, const OdGePoint3d& point, const OdGeVector3d* deriv);
 
  virtual OdResult getOdGeCurve(OdGeCurve3d*& pGeCurve, const OdGeTol& tol = OdGeContext::gTol) const;
  virtual OdResult setFromOdGeCurve(const OdGeCurve3d& geCurve, OdGeVector3d *normal = NULL, const OdGeTol& tol = OdGeContext::gTol);
 
  /** \details
    Explodes this entity into a set of simpler entities.  
 
    \param entitySet [in/out] Receives an array of pointers to the new entities.
    
    \remarks
    Returns eOk if successful, or an appropriate error code if not.
 
    \note
    Entities resulting from the explosion are appended to the specified array.
    
    The newly created entities are not database residents.
    
    The default implementation of this function returns eNotApplicable. This function can be
    overridden in custom classes.
  */
  virtual OdResult subExplode(OdRxObjectPtrArray& entitySet) const;
};
 
/** \details
    This template class is a specialization of the OdSmartPtr class for OdDbSpline object pointers.
*/
typedef OdSmartPtr<OdDbSpline> OdDbSplinePtr;
 
/** \details
    This class represents Spline entities in an OdDbDatabase instance.
 
    \sa
    TD_Db
    <group OdDb_Classes> 
*/
class TOOLKIT_EXPORT OdDbSplinePE : public OdRxObject
{
public:
    ODRX_DECLARE_MEMBERS(OdDbSplinePE);
 
  virtual OdResult getParamAtPoint(
    const OdDbCurve* pCurve,
    const OdGePoint3d& pointOnCurve,
    double& param) const = 0;
 
  virtual OdResult getArea(
    const OdDbCurve* pCurve,
    double& area) const = 0;
};
 
/** \details
This template class is a specialization of the OdSmartPtr class for OdDbSplinePE object pointers.
*/
typedef OdSmartPtr<OdDbSplinePE> OdDbSplinePEPtr;
 
#include "TD_PackPop.h"
 
#endif