DRange1d.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 
11 
13 
14 
41 struct DRange1d
42 {
43 
45 double low;
47 double high;
48 
49 #ifdef __cplusplus
50 
51 public:
53 GEOMDLLIMPEXP DRange1d ();
54 
56 GEOMDLLIMPEXP DRange1d (double low, double high);
57 
59 static GEOMDLLIMPEXP DRange1d FromLowHigh (double low, double high);
60 
62 GEOMDLLIMPEXP DRange1d (DRange1dCR source);
63 
65 static GEOMDLLIMPEXP DRange1d NullRange ();
66 
68 static GEOMDLLIMPEXP DRange1d InfiniteRange ();
70 static GEOMDLLIMPEXP DRange1d ZeroAndPositiveRange ();
72 static GEOMDLLIMPEXP DRange1d ZeroAndNegativeRange ();
73 
74 
76 GEOMDLLIMPEXP void InitNull ();
77 
79 static GEOMDLLIMPEXP DRange1d From (double value);
80 
82 static GEOMDLLIMPEXP DRange1d From (double valueA, double valueB);
83 
85 static GEOMDLLIMPEXP DRange1d From (double valueA, double valueB, double valueC);
86 
88 static GEOMDLLIMPEXP DRange1d From (double *values, size_t n);
89 
91 static GEOMDLLIMPEXP DRange1d FromAltitudes (bvector<DPoint3d> &points, DPlane3dCR plane);
92 
93 
95 bool GEOMDLLIMPEXP IsNull () const;
96 
98 bool GEOMDLLIMPEXP IsEmpty () const;
99 
101 bool GEOMDLLIMPEXP IsEmptyOrSinglePoint () const;
102 
104 bool GEOMDLLIMPEXP IsSinglePoint () const;
105 
107 bool GEOMDLLIMPEXP IsSinglePoint (double value) const;
109 bool GEOMDLLIMPEXP IsPositiveLength () const;
110 
112 bool GEOMDLLIMPEXP IsInfinitePositive () const;
113 
115 bool GEOMDLLIMPEXP IsInfiniteNegative () const;
116 
118 bool GEOMDLLIMPEXP IsDoublyInfinite () const;
119 
123 bool GEOMDLLIMPEXP GetLowHigh (double &a, double &b) const;
124 
126 double GEOMDLLIMPEXP Low () const;
128 double GEOMDLLIMPEXP High () const;
129 
135 double GEOMDLLIMPEXP Length () const;
136 
138 bool GEOMDLLIMPEXP Contains (double a) const;
139 
141 void GEOMDLLIMPEXP Extend (double valueA);
143 void GEOMDLLIMPEXP Extend (double valueA, double valueB);
145 void GEOMDLLIMPEXP Extend (double *values, size_t count);
146 
148 void GEOMDLLIMPEXP Extend (bvector<double> &values);
149 
151 void GEOMDLLIMPEXP Extend(DRange1dCR other);
152 
153 
156 void GEOMDLLIMPEXP ExtendBySignedShift (double tol);
157 
159 void GEOMDLLIMPEXP IntersectInPlace (DRange1dCR other);
160 
162 static GEOMDLLIMPEXP DRange1d FromIntersection (DRange1dCR rangeA, DRange1dCR rangeB);
164 static GEOMDLLIMPEXP DRange1d FromUnion (DRange1dCR rangeA, DRange1dCR rangeB);
165 
169 bool GEOMDLLIMPEXP StrictlyNonEmptyFractionalIntersection (DRange1dCR rangeB, DRange1dR fractionalIntersection);
170 
172 bool GEOMDLLIMPEXP IsSubsetOf (DRange1dCR other) const;
174 bool GEOMDLLIMPEXP HasNonEmptyIntersectionWith (DRange1dCR other) const;
176 bool GEOMDLLIMPEXP HasPositiveLengthIntersectionWith (DRange1dCR other) const;
177 
179 bool GEOMDLLIMPEXP IsContainedIn (DRange1dCR other) const;
181 double GEOMDLLIMPEXP MaxAbs (double defaultValeForNullRange = 0.0) const;
182 
185 bool GEOMDLLIMPEXP IsEqualInterval (DRange1dCR other) const;
186 
188 bool GEOMDLLIMPEXP IsEqualLowHigh (DRange1dCR other) const;
189 
191 bool GEOMDLLIMPEXP IsSameMinMax (DRange1dCR other, double absTol) const;
193 // (i.e. two ranges with reversed low and high return false here, true for {IsSameMinMax}
194 bool GEOMDLLIMPEXP IsSameLowHigh (DRange1dCR other, double relTol) const;
195 
197 bool GEOMDLLIMPEXP FractionToDouble (double fraction, double &x, double defaultReturnX = 0.0) const;
199 bool GEOMDLLIMPEXP DoubleToFraction (double x, double &fraction, double defaultReturnX = 0.0) const;
200 
203 double GEOMDLLIMPEXP GetTolerance (double absTol = 1.0e-14, double localRelTol = 1.0e-14, double globalRelTol = 0.0);
204 
206 static GEOMDLLIMPEXP void SortLowInPlace (bvector<DRange1d> &data);
208 static GEOMDLLIMPEXP void SimplifyInPlace (bvector<DRange1d> &data);
209 
211 static GEOMDLLIMPEXP DRange1d FromExtent (bvector <DRange1d> &data);
213 static GEOMDLLIMPEXP DRange1d FromIntersection (bvector <DRange1d> &data);
214 
217 static GEOMDLLIMPEXP void AppendClips (bvector <DRange1d> &dataA, DRange1dCR clipper, bvector<DRange1d> &dataOut);
218 
220 static GEOMDLLIMPEXP void ClipInPlace (bvector <DRange1d> &dataA, DRange1dCR clipper);
221 
223 static GEOMDLLIMPEXP void IntersectSorted (bvector <DRange1d> &dataA, bvector <DRange1d> &dataB, bvector <DRange1d> &dataOut);
224 
226 static GEOMDLLIMPEXP void UnionSorted (bvector <DRange1d> &dataA, bvector <DRange1d> &dataB, bvector <DRange1d> &dataOut);
227 
229 static GEOMDLLIMPEXP void DifferenceSorted (bvector <DRange1d> &dataA, bvector <DRange1d> &dataB, bvector <DRange1d> &dataOut);
230 
232 static GEOMDLLIMPEXP bool IsIncreasing (bvector <DRange1d> &data, bool allowZeroLength = false, bool allowZeroGaps = false);
233 
235 static GEOMDLLIMPEXP double LengthSum (bvector <DRange1d> &data);
236 
246 bool GEOMDLLIMPEXP UpdateRay1dIntersection
247 (
248 double x0,
249 double dxds,
250 double xA,
251 double xB
252 );
253 
254 
255 
256 #endif
257 
258 };
bool FractionToDouble(double fraction, double &x, double defaultReturnX=0.0) const
map fractional coordinate to real. Returns false if null range.
bool HasNonEmptyIntersectionWith(DRange1dCR other) const
Test if the instance range is a (possibly complete, but not empty) subset of {other} range...
static DRange1d FromLowHigh(double low, double high)
Return a range with explicit (possibly reversed) low and high.
DRange1d()
constructor for a NULL range.
double Length() const
Return {MAX(0, high - low)} The DRange1::NullRange returns 0.
static DRange1d ZeroAndPositiveRange()
Return a complete 0 and positive range (0 to DBL_MAX)
static void SortLowInPlace(bvector< DRange1d > &data)
Sort on low values.
void Extend(double valueA)
Extend to include a value.
bool IsInfiniteNegative() const
Test if the range has the most negative possible {low}.
static DRange1d FromUnion(DRange1dCR rangeA, DRange1dCR rangeB)
return the (possibly null) union of two ranges.
bool GetLowHigh(double &a, double &b) const
Get the low and high limits (unchecked).
static void IntersectSorted(bvector< DRange1d > &dataA, bvector< DRange1d > &dataB, bvector< DRange1d > &dataOut)
Intersect intervals in two pre-sorted sets. Output may NOT be the same as either input.
bool IsContainedIn(DRange1dCR other) const
Test if the instnace range is a (possibly complete) subset of {other} range.
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
static DRange1d FromExtent(bvector< DRange1d > &data)
Return the encompassing single range.
static bool IsIncreasing(bvector< DRange1d > &data, bool allowZeroLength=false, bool allowZeroGaps=false)
Test for increasing relationships, optionally allowing zero length.
static DRange1d FromIntersection(DRange1dCR rangeA, DRange1dCR rangeB)
return the (possibly null) intersection of two ranges.
size_type count(const key_type &__x) const
Definition: stdcxx/bstdmap.h:277
bool UpdateRay1dIntersection(double x0, double dxds, double xA, double xB)
Update a bounding interval of a line based on the variation of that line within one dimension...
struct DRange1d const & DRange1dCR
Definition: msgeomstructs_typedefs.h:102
static DRange1d From(double value)
Return a range containing a single value.
static double LengthSum(bvector< DRange1d > &data)
Sum the interval lengths.
bool IsEmpty() const
Test if the range has {low > high}, i.e. there are no x for which {low &le x && x &le high}...
static DRange1d NullRange()
Return a range which satisfies IsNull ()
bool Contains(double a) const
Test if the range contains a given value.
bool IsSinglePoint() const
Test if the range is a single point.
bool IsDoublyInfinite() const
Test if the range has the most negative {low} and most positive {high}.
bool IsNull() const
Test if the range is exactly the same as the null ranges returned by NullRange ().
double Low() const
Get the low limit (unchecked).
static void AppendClips(bvector< DRange1d > &dataA, DRange1dCR clipper, bvector< DRange1d > &dataOut)
Intersect each range in dataA with clipper.
void ExtendBySignedShift(double tol)
If non empty, shift endpoints by (-tol, +tol).
double GetTolerance(double absTol=1.0e-14, double localRelTol=1.0e-14, double globalRelTol=0.0)
return a tolerance computed as {absTol + localRelTol * Extent() + globalRelTol * MaxAbs ()} ...
static void SimplifyInPlace(bvector< DRange1d > &data)
Combine intervals so there are no overlaps.
double low
low point of box
Definition: DRange1d.h:45
static DRange1d ZeroAndNegativeRange()
Return a complete 0 and negative range (-DBL_MAX to 0)
double MaxAbs(double defaultValeForNullRange=0.0) const
return the largest coordinate (absolute value) in the range.
bool IsEqualInterval(DRange1dCR other) const
Test if equal intervals in point set sense.
double high
high point of box
Definition: DRange1d.h:47
struct DPlane3d const & DPlane3dCR
Definition: msgeomstructs_typedefs.h:113
bool IsSameLowHigh(DRange1dCR other, double relTol) const
test for toleranced equality of low to low and high to high
bool IsEqualLowHigh(DRange1dCR other) const
Direct equality test for low and high parts.
bool IsSameMinMax(DRange1dCR other, double absTol) const
test for toleranced equality of (min max of) low and high.
A 1d interval with low and high values.
Definition: DRange1d.h:41
bool StrictlyNonEmptyFractionalIntersection(DRange1dCR rangeB, DRange1dR fractionalIntersection)
Compute intersection of the instance with rangeB.
static DRange1d InfiniteRange()
Return a complete range (-DBL_MAX to DBL_MAX)
static void UnionSorted(bvector< DRange1d > &dataA, bvector< DRange1d > &dataB, bvector< DRange1d > &dataOut)
Union of intervals in two pre-sorted sets. Output may NOT be the same as either input.
bool IsSubsetOf(DRange1dCR other) const
Test if the instance range is a (possibly complete, possibly empty) subset of {other} range...
static DRange1d FromAltitudes(bvector< DPoint3d > &points, DPlane3dCR plane)
Return a (sorted) range of altitudes of points.
double High() const
Get the low limit (unchecked).
bool IsPositiveLength() const
Test if the range has {high > low}, i.e. has a non-empty set of points with properly sorted lower and...
void InitNull()
Set this range to the {NullRange}.
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
bool IsEmptyOrSinglePoint() const
Test if the range has {high >= low}, i.e. is empty or just one point.
struct DRange1d & DRange1dR
Definition: msgeomstructs_typedefs.h:102
static void ClipInPlace(bvector< DRange1d > &dataA, DRange1dCR clipper)
Intersect each range in dataA with clipper. Retain non-empty result parts.
bool HasPositiveLengthIntersectionWith(DRange1dCR other) const
Test if the instance range has a positive-length (more than single point) intersection with {other}...
void IntersectInPlace(DRange1dCR other)
Restrict to overlap with another (possibly null!!) range.
static void DifferenceSorted(bvector< DRange1d > &dataA, bvector< DRange1d > &dataB, bvector< DRange1d > &dataOut)
Intersect intervals in two pre-sorted sets. Output may NOT be the same as either input.
bool DoubleToFraction(double x, double &fraction, double defaultReturnX=0.0) const
map real to fraction. Returns false if null range or single point.
bool IsInfinitePositive() const
Test if the range has the largest possible {high}.

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