zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
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
/////////////////////////////////////////////////////////////////////////////// 
// 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 OD_GE_KNOT_VECTOR
#define OD_GE_KNOT_VECTOR /*!DOM*/
 
#include "Ge/GeExport.h"
#include "Ge/GeDoubleArray.h"
#include "Ge/GeIntArray.h"
 
class OdGeInterval;
 
#include "TD_PackPush.h"
 
/** \details
    This class represents an ordered series of monotonically increasing doubles used by spline entities.
 
    Library: TD_Ge
 
    <group OdGe_Classes> 
*/
class GE_TOOLKIT_EXPORT OdGeKnotVector
{
public:
  /** \param tol [in]  Knot equality tolerance.
    \param size [in]  Length of vector.
    \param growSize [in]  Length of future vector size increments.
    \param plusMult [in]  Multiplicity increment for each knot.
    \param source [in]  Object to be cloned.
 
  */
  OdGeKnotVector(
    double tol = 1.e-9); 
  OdGeKnotVector(
    int size, 
    int growSize, 
    double tol = 1.e-9);
  OdGeKnotVector(
    int size, 
    const double source[], 
    double tol = 1.e-9);
  OdGeKnotVector(
    int plusMult, 
    const OdGeKnotVector& source);
  OdGeKnotVector(
    const OdGeKnotVector& source);
  OdGeKnotVector(
    const OdGeDoubleArray& source, 
    double tol = 1.e-9);
  ~OdGeKnotVector();
 
  OdGeKnotVector& operator =(
      const OdGeKnotVector& knotVector);
  OdGeKnotVector& operator =(
      const OdGeDoubleArray& dblArray);
 
  /** \param i [in]  Index of knot.
    
    \remarks
    Returns or references the ith knot of the knot vector.
  */
  double& operator [](
    int i);
  double operator [](
    int i) const;
   
  /** \details
    Returns true if and only if knotVector is identical to this one.
    
    \param knotVector [in]  Knot vector. 
  */
  bool isEqualTo(
    const OdGeKnotVector& knotVector) const;
 
  /** \details
    Returns the first knot value of this vector.
  */
  double startParam() const;
 
  /** \details
    Returns the last knot value of this vector.
  */
  double endParam() const;
  
  /** \details
    Returns knot multiplicity (repetitions) of the knot value at the specified index.
    
    \param knotIndex [in]  Knot index.
    
    \remarks
    If consecutive knots are within the knot equality tolerance,
    the knots are considered identical, and their multiplicities combined.
  */
  int multiplicityAt(
    int knotIndex) const;
    
  /** \details
    Returns the number of intervals between distinct knots. 
 
    \remarks
    Consecutive knots are considered distinct if and only if
    they are not within the knot equality tolerance.
  */
  int numIntervals() const;
  
  /** \details
    Returns the knot interval, and the index of the knot interval, containing the point specified by param. 
 
    \param order [in]  The order of the spline.
    \param param [in]  Parameter to specify a point on the vector.
    \param interval [out]  Receives the interval containing the point specified by param.
    \remarks
    param must lie between the knot values indexed by order -1 and length() - order, where order is the order of the spline. 
  */
  int getInterval(
    int order, 
    double param, 
    OdGeInterval& interval) const;
 
  /** \details
    Returns the number of distinct knots. 
    
    \param knots [in]  Array of knots.
    \param multiplicity [out]  Receives an array of multiplicities (repetitions) of each knot.
 
    \remarks
    If consecutive knots are within the knot equality tolerance,
    the knots are considered identical, and their multiplicities combined.
  */
      void getDistinctKnots(
    OdGeDoubleArray& knots, 
    OdGeIntArray *multiplicity = NULL) const;
 
  /** \details
    Returns true if an only if the specified parameter is
    between the first and last knots.
    
    \param param [in]  Parameter to be tested. 
  */
  bool contains(
    double param) const;
 
  /** \details
    Returns true if and only if knot is a member of this vector within the knot equality tolerance.
  */
  bool isOn(
    double knot) const;
 
  /** \details
    Reverses the order of this vector, and returns a reference to this vector.
  */
  OdGeKnotVector& reverse();
 
  /** \details
    Removes the specified knot from this vector, and returns a reference to this vector.
    
    \param knotIndex [in]  Knot index.
  */
  OdGeKnotVector& removeAt(
    int knotIndex);
 
  /** \details
    Removes the specified range of knots from this vector, and returns a reference to this vector.
    
    \param startIndex [in]  Index of the first knot to be removed.
    \param endIndex [in]  Index of the last knot to be removed.
  */
  OdGeKnotVector& removeSubVector(
    int startIndex, 
    int endIndex);
 
  /** \details
    Inserts the specified knot the specified number of times at the specified index, and returns a reference to 
    this vector.
    
    \param knotIndex [in]  Knot index.
    \param knot [in]  Value to be inserted
    \param multiplicity [in]  Number ot times to insert the knot.
  */
  OdGeKnotVector& insertAt(
    int knotIndex, 
    double knot, 
    int multiplicity = 1);
 
  /** \details
    Inserts a knot in the appropriate knot interval as specified
    by param, and returns a reference to this vector.
    
    \param param [in]  Parameter to specify a point on the vector.
    
    \remarks
    If the specified point is within the knot equality tolerance of another knot,
    said knot's multiplicity is incremented.
  */
    OdGeKnotVector& insert(
    double param);
 
  /** \details
    Appends a vector, or single knot, to this vector, and returns a reference to this vector, or the value of the single knot. 
   
    \param knot [in]  New last knot value.
    \param tail [in]  Knot vector to be appended.
    \param knotRatio [in]  Knot ratio.
    
    \remarks
    If knotRatio > 0, append performs a linear transformations on this vector and on tail,
    such that the ratio of their lengths is equal to knotRatio, and that tail immediately follows
    this vector. tail is modified by this operation.
  */
  int append(
    double knot);
  OdGeKnotVector& append(
    OdGeKnotVector& tail, 
    double knotRatio = 0.0);
 
  /** \details
    
    Splits this vector at the point corresponding to param.
    
    \param param [in]  Parameter to specify a point on the vector.
    \param pKnotHead [out]  Receives the head portion of the split.
    \param multLast [in]  Multiplicity of the last knot in the head portion.
    \param pKnotTail [out]  Receives the tail portion of the split.
    \param multFirst [in]  Multiplicity of the first knot in the tail portion.
  */
  int split(
    double param,
    OdGeKnotVector* pKnotHead,
    int multLast,
    OdGeKnotVector* pKnotTail,
    int multFirst) const;
 
  /** \details
    Transforms this vector such that the first knot has a value
    of lower, and the last knot has a value of upper, and 
    returns a reference to this vector. 
  
    \param lower [in]  New lower knot.
    \param upper [in]  New upper knot.
  */
  OdGeKnotVector& setRange(
    double lower, 
    double upper);
 
  /** \details
    Returns the knot equality tolerance.
  */
  double tolerance() const;
  
  /** \details
    Sets the knot equality tolerance for this vector, 
    and returns a reference to this vector.
 
     \param tol [in]  Knot equality tolerance.
  */
  OdGeKnotVector& setTolerance(
    double tol); 
 
  /** \details
    Returns the length of this vector.
  */
  int length() const;
 
  /** \details
    Returns true if and only if length() == 0.
  */
  bool isEmpty() const;
  
  /** \details
    Returns the logical length of this vector.
    
    \remarks
    The logical length is the number of elements in the array returned
    by asArrayPtr() and getPtr().
  */
    int logicalLength() const;
 
  /** \details
    Sets the logical length of this vector, 
    and returns a reference to this vector.
    
    \param size [in]  Logical length of vector.
    
    \remarks
    The logical length is the number of elements in the array returned
    by asArrayPtr() and getPtr().
  */
    OdGeKnotVector& setLogicalLength(
    int size);
    
  int physicalLength() const;
  OdGeKnotVector& setPhysicalLength(int);
 
  /** \details
    Returns the length by which the array is set to grow automatically.
  */
  int growLength() const;
 
  /** \details
    Set the length by which the array will grow automatically.
 
    \param rowLength [in]  The length for the array automatic resizing.
  */
  OdGeKnotVector& setGrowLength(int rowLength);
 
  /** \details
    Returns this vector as an array of doubles.
    
    \remarks
    The number of elements in this array is returned by
    logicalLength(), and set by setLogicalLength().
  */
  const double* getPtr() const;
 
  /** \details
    Returns this vector as an array of doubles.
    
    \remarks
    The number of elements in this array is returned by
    logicalLength(), and set by setLogicalLength().
  */
  const double* asArrayPtr() const;
  double* asArrayPtr();
 
  /** \details
    Sets the parameters for this vector according to the arguments, 
    and returns a reference to this vector.
 
    \param tol [in]  Knot equality tolerance.
    \param size [in]  Length of vector.
  */
  OdGeKnotVector& set(
    int size, 
    const double source[], 
    double tol = 1.e-9);
 
protected:
  /** \details
    Returns true if and only if index < length()
    
    \param knotIndex [in]  Knot index.
  */
   bool isValid(
    OdUInt32 knotIndex) const;
 
   OdGeDoubleArray m_Data;
   double m_Tolerance;
};
 
#include "TD_PackPop.h"
 
#endif // OD_GE_KNOT_VECTOR