CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GeInterval.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25#ifndef OD_GE_INTERVAL_H
26#define OD_GE_INTERVAL_H
27
28#include "Ge/GeExport.h"
29#include "TD_PackPush.h"
30
40{
41public:
47 OdGeInterval(double tol = 1.e-12)
48 : m_LowerParam(0.0)
49 , m_UpperParam(0.0)
50 , m_Tol(tol)
51 , m_bBoundedBelow(false)
52 , m_bBoundedAbove(false)
53 {
54 }
55
63 OdGeInterval(double lower, double upper, double tol = 1.e-12)
64 : m_LowerParam(lower)
65 , m_UpperParam(upper)
66 , m_Tol(tol)
67 , m_bBoundedBelow(true)
68 , m_bBoundedAbove(true)
69 {
70 }
71
72
81 bool boundedBelow,
82 double bound,
83 double tol = 1.e-12);
84
91 double lowerBound() const {
92 ODA_ASSERT_ONCE(m_bBoundedBelow);
93 return m_LowerParam;
94 }
95
102 double upperBound() const {
103 ODA_ASSERT_ONCE(m_bBoundedAbove);
104 return m_UpperParam;
105 }
106
113 double middle() const {
114 return 0.5 * (m_LowerParam + m_UpperParam);
115 }
116
129 double element() const;
130
138 double& lower,
139 double& upper) const
140 {
141 lower = m_LowerParam;
142 upper = m_UpperParam;
143 }
144
150 double getEnd(
151 int index) const
152 {
153 ODA_ASSERT(index == 0 || index == 1);
154 return index == 0 ? m_LowerParam : m_UpperParam;
155 }
156
163 double length() const
164 {
165 return (isBounded() ? (m_UpperParam - m_LowerParam) : -1.0);
166 }
167
171 double tolerance() const
172 {
173 return m_Tol;
174 }
175
182 double eval(
183 double ratio) const
184 {
186 return m_LowerParam * (1.0 - ratio) + m_UpperParam * ratio;
187 }
188
199 double lower,
200 double upper)
201 {
202 setLower(lower);
203 return setUpper(upper);
204 }
205
217 bool boundedBelow,
218 double bound);
219
227 {
228 m_LowerParam = m_UpperParam = 0.0;
229 m_bBoundedBelow = m_bBoundedAbove = false;
230 return *this;
231 }
232
240 double upper)
241 {
242 m_UpperParam = upper;
243 m_bBoundedAbove = true;
244 return *this;
245 }
246
255 double lower)
256 {
257 m_LowerParam = lower;
258 m_bBoundedBelow = true;
259 return *this;
260 }
261
271 double tol)
272 {
273 m_Tol = tol;
274 return *this;
275 }
276
288 OdGeInterval& scale(double factor);
289
297
305 const OdGeInterval& otherInterval,
306 OdGeInterval& result) const;
307
327 const OdGeInterval& otherInterval,
328 OdGeInterval& lInterval,
329 OdGeInterval& rInterval) const;
330
341 const OdGeInterval& otherInterval,
342 OdGeInterval& result) const;
343
355
359 bool isBounded() const
360 {
361 return (m_bBoundedAbove && m_bBoundedBelow);
362 }
363
367 bool isBoundedAbove() const
368 {
369 return m_bBoundedAbove;
370 }
371
375 bool isBoundedBelow() const
376 {
377 return m_bBoundedBelow;
378 }
379
383 bool isUnBounded() const
384 {
385 return (!m_bBoundedAbove || !m_bBoundedBelow);
386 }
387
393 bool isSingleton() const;
394
403 const OdGeInterval& otherInterval) const;
404
414 const OdGeInterval& otherInterval) const;
415
425 double value) const
426 {
427 return ((!m_bBoundedBelow || m_LowerParam - m_Tol <= value)
428 && (!m_bBoundedAbove || m_UpperParam + m_Tol >= value));
429 }
430
438 double clamp(
439 double value) const
440 {
441 if (m_bBoundedAbove)
442 value = odmin(value, m_UpperParam);
443 if (m_bBoundedBelow)
444 value = odmax(value, m_LowerParam);
445 return value;
446 }
447
457 const OdGeInterval& otherInterval) const;
458
477 const OdGeInterval& otherInterval,
478 OdGeInterval& overlap) const;
479
489 const OdGeInterval& otherInterval) const;
490
500 const OdGeInterval& otherInterval) const;
501
514 const OdGeInterval& otherInterval) const;
515
527 double value) const;
528
540 const OdGeInterval& otherInterval) const;
541
552 double value) const;
553
570 double period,
571 double& value);
572//DOM-IGNORE-BEGIN
573
574 friend
576 double value,
577 const OdGeInterval& interval);
579 double value) const;
581 const OdGeInterval& otherInterval) const;
582 friend
584 double value,
585 const OdGeInterval& interval);
587 double value) const;
589 const OdGeInterval& otherInterval) const;
590 friend
592 double value,
593 const OdGeInterval& interval);
595 double value) const;
597 const OdGeInterval& otherInterval) const;
598 friend
600 double value,
601 const OdGeInterval& interval);
603 double value) const;
605 const OdGeInterval& otherInterval) const;
606
607private:
608 double m_LowerParam;
609 double m_UpperParam;
610 double m_Tol;
611 bool m_bBoundedBelow;
612 bool m_bBoundedAbove;
613//DOM-IGNORE-END
614};
615
616#include "TD_PackPop.h"
617#endif // OD_GE_INTERVAL_H
#define ODA_ASSERT_ONCE(exp)
Definition DebugStuff.h:73
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
tol
true
false
Definition DimVarDefs.h:165
#define GE_TOOLKIT_EXPORT
Definition GeExport.h:35
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:405
bool operator==(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:399
ODRX_CONSTEXPR const T & odmin(const T &a, const T &b)
Definition OdPlatform.h:64
ODRX_CONSTEXPR const T & odmax(const T &a, const T &b)
Definition OdPlatform.h:38
bool operator>=(const OdString &s1, const OdString &s2)
Definition OdString.h:1384
bool operator<=(const OdString &s1, const OdString &s2)
Definition OdString.h:1362
bool operator<(const OdString &s1, const OdString &s2)
Definition OdString.h:1317
bool operator>(const OdString &s1, const OdString &s2)
Definition OdString.h:1340
OdGeInterval & set(bool boundedBelow, double bound)
OdGeInterval(double tol=1.e-12)
Definition GeInterval.h:47
OdGeInterval(bool boundedBelow, double bound, double tol=1.e-12)
double upperBound() const
Definition GeInterval.h:102
bool isEqualAtUpper(double value) const
bool contains(const OdGeInterval &otherInterval) const
void getBounds(double &lower, double &upper) const
Definition GeInterval.h:137
OdGeInterval & scale(double factor)
double getEnd(int index) const
Definition GeInterval.h:150
OdGeInterval & swap()
double middle() const
Definition GeInterval.h:113
bool isEqualAtUpper(const OdGeInterval &otherInterval) const
bool isSingleton() const
bool isOverlapAtUpper(const OdGeInterval &otherInterval, OdGeInterval &overlap) const
double lowerBound() const
Definition GeInterval.h:91
OdGeInterval & setUpper(double upper)
Definition GeInterval.h:239
bool isBoundedBelow() const
Definition GeInterval.h:375
bool isPeriodicallyOn(double period, double &value)
OdGeInterval & setTolerance(double tol)
Definition GeInterval.h:270
double clamp(double value) const
Definition GeInterval.h:438
OdGeInterval & set(double lower, double upper)
Definition GeInterval.h:198
double tolerance() const
Definition GeInterval.h:171
OdGeInterval(double lower, double upper, double tol=1.e-12)
Definition GeInterval.h:63
double eval(double ratio) const
Definition GeInterval.h:182
bool contains(double value) const
Definition GeInterval.h:424
bool isEqualAtLower(double value) const
bool intersectWith(const OdGeInterval &otherInterval, OdGeInterval &result) const
bool isUnBounded() const
Definition GeInterval.h:383
bool isBounded() const
Definition GeInterval.h:359
bool isDisjoint(const OdGeInterval &otherInterval) const
bool isBoundedAbove() const
Definition GeInterval.h:367
void getMerge(const OdGeInterval &otherInterval, OdGeInterval &result) const
OdGeInterval & set()
Definition GeInterval.h:226
bool isEqualAtLower(const OdGeInterval &otherInterval) const
bool finiteIntersectWith(const OdGeInterval &range, OdGeInterval &result) const
double element() const
OdGeInterval & setLower(double lower)
Definition GeInterval.h:254
int subtract(const OdGeInterval &otherInterval, OdGeInterval &lInterval, OdGeInterval &rInterval) const
bool isContinuousAtUpper(const OdGeInterval &otherInterval) const
double length() const
Definition GeInterval.h:163
GLuint index
Definition gles2_ext.h:265
GLenum GLint * range
Definition gles2_ext.h:563
GLsizei const GLfloat * value
Definition gles2_ext.h:302