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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/////////////////////////////////////////////////////////////////////////////// 
// 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_INTERVAL_H
#define OD_GE_INTERVAL_H /*!DOM*/
 
#include "Ge/GeExport.h"
#include "TD_PackPush.h"
 
/** \details
    This class represents a finite, infinite, or semi-infinite
    interval as the real axis.
  
    Library: TD_Ge
 
    <group OdGe_Classes> 
*/
class GE_TOOLKIT_EXPORT OdGeInterval
{
public:
  /** \param lower [in]  Lower bound.
    \param upper [in]  Upper bound.
    \param tol [in]  Boundary tolerance.
    \param boundedBelow [in]  Determines if the interval is bounded below.
    \param bound [in]  Specifies a lower and upper bounds if boundedBelow is true, or only an upper
              bound if it is false.     
 
    \remarks
    With no arguments other than tol, creates an unbounded interval.
  */
  OdGeInterval(
    double tol = 1.e-12);
  OdGeInterval(
    double lower,
    double upper,
    double tol = 1.e-12);
  OdGeInterval(
    bool boundedBelow,
    double bound,
    double tol = 1.e-12);
 
  ~OdGeInterval();
 
  /** \details
    Returns the lower bound of this interval.
    
    \remarks
    This value is meaningful if and only if the interval has a lower bound.
  */
  double lowerBound() const;
 
  /** \details
    Returns the upper bound of this interval.
    
    \remarks
    This value is meaningful if and only if the interval has an upper bound.
  */
  double upperBound() const;
 
  /** \details
    Returns a point on this interval.
    
    \remarks
    <table>
    Bounded Above   Bounded Below          Returns
    Yes             ---                    Upper Bound
    No              Yes                    Lower Bound
    No              No                     0.0
    </table>
 
  */
    double element() const;
 
  /** \details
    Returns the bounds of this interval.
    
    \param lower [out]  Receives the Lower bound.
    \param upper [out]  Receives the Upper bound.
  */
  void getBounds(
    double& lower,
    double& upper) const;
    
  /** \details
    Returns the length of this interval.
    
    \remarks
    Returns -1.0 if this interval is unbounded above or below.
  */
  double length() const;
  
  /** \details
    Returns the boundary tolerance for this interval.
  */
  double tolerance() const;
 
  /** \details
    Sets the parameters for this interval according to the arguments.
 
    \param lower [in]  Lower bound.
    \param upper [in]  Upper bound.
    \param boundedBelow [in]  Determines if bound specifies a lower or an upper bound.
    \param bound [in]  Specifies a lower bound if boundedBelow is true, or an upper
              bound if it is false.
              
    \remarks
    Returns a reference to this interval.
    
    If called with no parameters, unbounds this interval.     
  */
  OdGeInterval& set(
    double lower,
    double upper);
  OdGeInterval& set(
    bool boundedBelow,
    double bound);
  OdGeInterval& set();
 
  /** \details
    Sets the upper bound for this interval.
 
    \param upper [in]  Upper bound.
    
  */
  OdGeInterval& setUpper(
    double upper);
    
  /** \details
    Sets the lower bound for this interval.
 
    \param lower [in] Lower bound.
    \remarks
    Returns a reference to this interval.
  */
  OdGeInterval& setLower(
    double lower);
 
  /** \details
    Sets the boundary tolerance for this interval.
 
    \param tol [in]  Boundary tolerance.
 
    \remarks
    Returns a reference to this interval.
  */
  OdGeInterval& setTolerance(
    double tol);
 
  /** \details
    Returns the smallest interval containing both the specified interval and this interval.
 
    \param otherInterval [in]  The interval to be merged with this one.
    \param result [out]  Receives the merged interval.
  */
  void getMerge(
    const OdGeInterval& otherInterval,
    OdGeInterval& result) const;
    
  /** \details
    Subtracts the specified interval from this interval.
    \remarks
    Returns the number of intervals, and the intervals, resulting from the subtraction
 
    \param otherInterval [in]  The interval to be subtracted from this one.
    \param lInterval [out]  Receives the Left (or only) interval.
    \param rInterval [out]  Receives the right interval.
    
    \remarks
    <table>
    return value   Results
    0              Empty result
    1              Single interval in lInterval
    2              Left in lInterval, Right in rInterval.
    </table>
  */
  int subtract(
    const OdGeInterval& otherInterval,
    OdGeInterval& lInterval,
    OdGeInterval& rInterval) const;
 
  /** \details
    Intersects the specified interval from this one.
    \remarks
    Returns true if and only this specified interval intersects with this one, 
    and the interval of intersection.
 
    \param otherInterval [in]  The interval to be intersected.
    \param result [out]  Receives the intersected interval.
  */
  bool intersectWith(
    const OdGeInterval& otherInterval,
    OdGeInterval& result) const;
    
  /** \details
    Returns true if and only if this interval is bounded above and below.
  */
  bool isBounded() const;
    
  /** \details
    Returns true if and only if this interval is bounded above.
  */
  bool isBoundedAbove() const;
    
  /** \details
    Returns true if and only if this interval is bounded below.
  */
  bool isBoundedBelow() const;
 
  /** \details
    Returns true if and only if this interval is unbounded above or below.
  */
  bool isUnBounded() const;
  
  /** \details
    Returns true if and only if this interval object is a singleton.
    \remarks
    Returns true if and only if this interval is bounded, and the upper and lower bounds are equal within tolerance().
  */
  bool isSingleton() const;
 
  /** \details
    Returns true if and only if the specified interval is disjoint from this interval.
    \remarks
    Returns true if and only if this interval does not intersect otherInterval within tolerance().
    
    \param otherInterval [in]  The interval to be tested.
  */
  bool isDisjoint(
    const OdGeInterval& otherInterval) const;
 
  /** \details
    Returns true if and only if this interval contains the specified value or Interval.
    \remarks
    Returns true if and only if this Interval contains value or otherInterval within tolerance().
    
    \param otherInterval [in]  The Interval to be tested.
    \param value [in]  The value to be tested.
  */
  bool contains(
    const OdGeInterval& otherInterval) const;
  bool contains(
    double value) const;
 
  /** \details
    Returns true if and only if the specified Interval is continuous with the upper bound of this Interval.
    \remarks
    Returns true if and only if this Interval is bounded above, otherInterval is bounded below, 
    and the upper bound of this Interval is equal to the lower bound of otherInterval within tolerance().
    
    \param otherInterval [in]  The Interval to be tested.
  */
  bool isContinuousAtUpper(
    const OdGeInterval& otherInterval) const;
 
  /** \details
    Returns true if and only if the specified Interval and this Interval overlap at the upper bound of this Interval.
    \remarks
    Returns true if and only if
     
    1.  This Interval is bounded above, otherInterval is bounded below. 
    2.  Neither Interval is a singleton.
    3.  The Intervals Intersect.
    4.  otherInterval does not contain this one.
    5.  The upper bound of this Interval is contained in otherInterval.
    6.  The lower bound of otherInterval is contained within this one. 
    
    If all these conditions are met, this function returns the intersection of the Intervals.
    
    \param otherInterval [in]  The Interval to be tested.
    \param overlap [out]  Receives the overlap of the Intervals.
  */
  bool isOverlapAtUpper(
    const OdGeInterval& otherInterval,
    OdGeInterval& overlap) const;
 
  bool operator ==(
    const OdGeInterval& otherInterval) const;
  bool operator !=(
    const OdGeInterval& otherInterval) const;
    
  /** \details
    Returns true if and only if upper bounds of the specified Interval and this Interval are equal.
    \remarks
    
    Returns true if and only if
    
    1. Both this Interval and otherInterval are unbounded above or bounded 
       above with their upper bounds equal within tolerance().
    2. This Interval is bounded above, and the upper bound is equal to value within tolerance(). 
 
    \param otherInterval [in]  The Interval to be tested.
    \param value [in]  The value to be tested.
  */
  bool isEqualAtUpper(
    const OdGeInterval& otherInterval) const;
  bool isEqualAtUpper(
    double value) const;
    
  /** \details
    Returns true if and only if lower bounds of the specified Interval and this Interval are equal.
    \remarks
    Returns true if and only if
    
    1. Both this Interval and otherInterval are unbounded below or bounded 
       below with their lower bounds equal within tolerance.
    2. This Interval is bounded below, and the lower bound is equal to value within tolerance. 
 
    
    \param otherInterval [in]  The Interval to be tested.
    \param value [in]  The value to be tested.
  */
  bool isEqualAtLower(
    const OdGeInterval& otherInterval) const;
  bool isEqualAtLower(
    double value) const;
 
  /** \details
    Returns true if and only if the specified value is periodically on this Interval.
    \remarks
    Returns true if and only if there is a positive integer N such that
    
            value + N * period
            
    is on this Interval. If so, returns that value.         
    
    \param period [in]  Period.
    \param value [in/out] Value.
  */
  bool isPeriodicallyOn(
    double period,
    double& value);
 
  friend 
    bool operator > (
    double value,
    const OdGeInterval& interval);
  bool operator > (
    double value) const;
  bool operator > (
    const OdGeInterval& otherInterval) const;
  friend 
    bool operator >= (
    double value,
    const OdGeInterval& interval);
  bool operator >= (
    double value) const;
  bool operator >= (
    const OdGeInterval& otherInterval) const;
  friend 
    bool operator < (
    double value,
    const OdGeInterval& interval);
  bool operator < (
    double value) const;
  bool operator < (
    const OdGeInterval& otherInterval) const;
  friend 
    bool operator <= (
    double value,
    const OdGeInterval& interval);
  bool operator <= (
    double value) const;
  bool operator <= (
    const OdGeInterval& otherInterval) const;
 
private:
  double m_Tol;
  double m_UpperParam;
  double m_LowerParam;
  bool m_bBoundedAbove;
  bool m_bBoundedBelow;
};
 
#include "TD_PackPop.h"
#endif // OD_GE_INTERVAL_H