Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
DRange1d Struct Reference

A 1d interval with low and high values. More...

#include <DRange1d.h>

Public Member Functions

 DRange1d ()
 constructor for a NULL range. More...
 
 DRange1d (double low, double high)
 Constructor from explicit low and high. More...
 
 DRange1d (DRange1dCR source)
 copy constructor. More...
 
void InitNull ()
 Set this range to the {NullRange}. More...
 
bool IsNull () const
 Test if the range is exactly the same as the null ranges returned by NullRange (). More...
 
bool IsEmpty () const
 Test if the range has {low > high}, i.e. there are no x for which {low &le x && x &le high}. More...
 
bool IsEmptyOrSinglePoint () const
 Test if the range has {high >= low}, i.e. is empty or just one point. More...
 
bool IsSinglePoint () const
 Test if the range is a single point. More...
 
bool IsSinglePoint (double value) const
 Test if the range is a particular single point. More...
 
bool IsPositiveLength () const
 Test if the range has {high > low}, i.e. has a non-empty set of points with properly sorted lower and upper limit. More...
 
bool IsInfinitePositive () const
 Test if the range has the largest possible {high}. More...
 
bool IsInfiniteNegative () const
 Test if the range has the most negative possible {low}. More...
 
bool IsDoublyInfinite () const
 Test if the range has the most negative {low} and most positive {high}. More...
 
bool GetLowHigh (double &a, double &b) const
 Get the low and high limits (unchecked). More...
 
double Low () const
 Get the low limit (unchecked). More...
 
double High () const
 Get the low limit (unchecked). More...
 
double Length () const
 Return {MAX(0, high - low)} The DRange1::NullRange returns 0. More...
 
bool Contains (double a) const
 Test if the range contains a given value. More...
 
void Extend (double valueA)
 Extend to include a value. More...
 
void Extend (double valueA, double valueB)
 Extend to include 2 values. More...
 
void Extend (double *values, size_t count)
 Extend to include an array of values. More...
 
void Extend (bvector< double > &values)
 Extend to include an array of values. More...
 
void Extend (DRange1dCR other)
 Extend to include (union) another (possibly null!!) range. More...
 
void ExtendBySignedShift (double tol)
 If non empty, shift endpoints by (-tol, +tol). More...
 
void IntersectInPlace (DRange1dCR other)
 Restrict to overlap with another (possibly null!!) range. More...
 
bool StrictlyNonEmptyFractionalIntersection (DRange1dCR rangeB, DRange1dR fractionalIntersection)
 Compute intersection of the instance with rangeB. More...
 
bool IsSubsetOf (DRange1dCR other) const
 Test if the instance range is a (possibly complete, possibly empty) subset of {other} range. More...
 
bool HasNonEmptyIntersectionWith (DRange1dCR other) const
 Test if the instance range is a (possibly complete, but not empty) subset of {other} range. More...
 
bool HasPositiveLengthIntersectionWith (DRange1dCR other) const
 Test if the instance range has a positive-length (more than single point) intersection with {other}. More...
 
bool IsContainedIn (DRange1dCR other) const
 Test if the instnace range is a (possibly complete) subset of {other} range. More...
 
double MaxAbs (double defaultValeForNullRange=0.0) const
 return the largest coordinate (absolute value) in the range. More...
 
bool IsEqualInterval (DRange1dCR other) const
 Test if equal intervals in point set sense. More...
 
bool IsEqualLowHigh (DRange1dCR other) const
 Direct equality test for low and high parts. More...
 
bool IsSameMinMax (DRange1dCR other, double absTol) const
 test for toleranced equality of (min max of) low and high. More...
 
bool IsSameLowHigh (DRange1dCR other, double relTol) const
 test for toleranced equality of low to low and high to high More...
 
bool FractionToDouble (double fraction, double &x, double defaultReturnX=0.0) const
 map fractional coordinate to real. Returns false if null range. More...
 
bool DoubleToFraction (double x, double &fraction, double defaultReturnX=0.0) const
 map real to fraction. Returns false if null range or single point. More...
 
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 ()} More...
 
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. More...
 

Static Public Member Functions

static DRange1d FromLowHigh (double low, double high)
 Return a range with explicit (possibly reversed) low and high. More...
 
static DRange1d NullRange ()
 Return a range which satisfies IsNull () More...
 
static DRange1d InfiniteRange ()
 Return a complete range (-DBL_MAX to DBL_MAX) More...
 
static DRange1d ZeroAndPositiveRange ()
 Return a complete 0 and positive range (0 to DBL_MAX) More...
 
static DRange1d ZeroAndNegativeRange ()
 Return a complete 0 and negative range (-DBL_MAX to 0) More...
 
static DRange1d From (double value)
 Return a range containing a single value. More...
 
static DRange1d From (double valueA, double valueB)
 Return a (sorted) range of 2 values. More...
 
static DRange1d From (double valueA, double valueB, double valueC)
 Return a (sorted) range of 3 values. More...
 
static DRange1d From (double *values, size_t n)
 Return a (sorted) range of an array of values. More...
 
static DRange1d FromAltitudes (bvector< DPoint3d > &points, DPlane3dCR plane)
 Return a (sorted) range of altitudes of points. More...
 
static DRange1d FromIntersection (DRange1dCR rangeA, DRange1dCR rangeB)
 return the (possibly null) intersection of two ranges. More...
 
static DRange1d FromUnion (DRange1dCR rangeA, DRange1dCR rangeB)
 return the (possibly null) union of two ranges. More...
 
static void SortLowInPlace (bvector< DRange1d > &data)
 Sort on low values. More...
 
static void SimplifyInPlace (bvector< DRange1d > &data)
 Combine intervals so there are no overlaps. More...
 
static DRange1d FromExtent (bvector< DRange1d > &data)
 Return the encompassing single range. More...
 
static DRange1d FromIntersection (bvector< DRange1d > &data)
 Return the overall intersection. More...
 
static void AppendClips (bvector< DRange1d > &dataA, DRange1dCR clipper, bvector< DRange1d > &dataOut)
 Intersect each range in dataA with clipper. More...
 
static void ClipInPlace (bvector< DRange1d > &dataA, DRange1dCR clipper)
 Intersect each range in dataA with clipper. Retain non-empty result parts. More...
 
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. More...
 
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. More...
 
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. More...
 
static bool IsIncreasing (bvector< DRange1d > &data, bool allowZeroLength=false, bool allowZeroGaps=false)
 Test for increasing relationships, optionally allowing zero length. More...
 
static double LengthSum (bvector< DRange1d > &data)
 Sum the interval lengths. More...
 

Public Attributes

double low
 low point of box More...
 
double high
 high point of box More...
 

Detailed Description

A 1d interval with low and high values.

Useful typedefs for DRange1d

typdedef struct const &DRange1d DRange1dCR;
typdedef struct &DRange1d DRange1dR;
typdedef struct const *DRange1d DRange1dCP;
typdedef struct *DRange1d DRange1dP;

If you look closely at "names" for special intervals, there are several tricky distinctions:

Be aware that if the application needs to treat a single point interval as "empty" for its purposes, the use of "empty" will be what the methods call {IsEmptyOrSinglePoint()}

Constructor & Destructor Documentation

DRange1d ( )

constructor for a NULL range.

DRange1d ( double  low,
double  high 
)

Constructor from explicit low and high.

DRange1d ( DRange1dCR  source)

copy constructor.

Member Function Documentation

static void AppendClips ( bvector< DRange1d > &  dataA,
DRange1dCR  clipper,
bvector< DRange1d > &  dataOut 
)
static

Intersect each range in dataA with clipper.

Append non-empty results to dataOut. Note that if the same array is passed for dataA and dataOut, all input contents will remain. (Use {ClipInPlace} to get compaction)

static void ClipInPlace ( bvector< DRange1d > &  dataA,
DRange1dCR  clipper 
)
static

Intersect each range in dataA with clipper. Retain non-empty result parts.

bool Contains ( double  a) const

Test if the range contains a given value.

static void DifferenceSorted ( bvector< DRange1d > &  dataA,
bvector< DRange1d > &  dataB,
bvector< DRange1d > &  dataOut 
)
static

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.

void Extend ( double  valueA)

Extend to include a value.

void Extend ( double  valueA,
double  valueB 
)

Extend to include 2 values.

void Extend ( double *  values,
size_t  count 
)

Extend to include an array of values.

void Extend ( bvector< double > &  values)

Extend to include an array of values.

void Extend ( DRange1dCR  other)

Extend to include (union) another (possibly null!!) range.

void ExtendBySignedShift ( double  tol)

If non empty, shift endpoints by (-tol, +tol).

No change if empty !!!

bool FractionToDouble ( double  fraction,
double &  x,
double  defaultReturnX = 0.0 
) const

map fractional coordinate to real. Returns false if null range.

static DRange1d From ( double  value)
static

Return a range containing a single value.

static DRange1d From ( double  valueA,
double  valueB 
)
static

Return a (sorted) range of 2 values.

static DRange1d From ( double  valueA,
double  valueB,
double  valueC 
)
static

Return a (sorted) range of 3 values.

static DRange1d From ( double *  values,
size_t  n 
)
static

Return a (sorted) range of an array of values.

static DRange1d FromAltitudes ( bvector< DPoint3d > &  points,
DPlane3dCR  plane 
)
static

Return a (sorted) range of altitudes of points.

static DRange1d FromExtent ( bvector< DRange1d > &  data)
static

Return the encompassing single range.

static DRange1d FromIntersection ( DRange1dCR  rangeA,
DRange1dCR  rangeB 
)
static

return the (possibly null) intersection of two ranges.

static DRange1d FromIntersection ( bvector< DRange1d > &  data)
static

Return the overall intersection.

static DRange1d FromLowHigh ( double  low,
double  high 
)
static

Return a range with explicit (possibly reversed) low and high.

static DRange1d FromUnion ( DRange1dCR  rangeA,
DRange1dCR  rangeB 
)
static

return the (possibly null) union of two ranges.

bool GetLowHigh ( double &  a,
double &  b 
) const

Get the low and high limits (unchecked).

Returns
true if {b >= a}, i.e. the interval is single point or postive length. (i.e. any empty interval returns false, with whatever limit data is present)
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 ()}

bool HasNonEmptyIntersectionWith ( DRange1dCR  other) const

Test if the instance range is a (possibly complete, but not empty) subset of {other} range.

bool HasPositiveLengthIntersectionWith ( DRange1dCR  other) const

Test if the instance range has a positive-length (more than single point) intersection with {other}.

double High ( ) const

Get the low limit (unchecked).

static DRange1d InfiniteRange ( )
static

Return a complete range (-DBL_MAX to DBL_MAX)

void InitNull ( )

Set this range to the {NullRange}.

void IntersectInPlace ( DRange1dCR  other)

Restrict to overlap with another (possibly null!!) range.

static void IntersectSorted ( bvector< DRange1d > &  dataA,
bvector< DRange1d > &  dataB,
bvector< DRange1d > &  dataOut 
)
static

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.

bool IsDoublyInfinite ( ) const

Test if the range has the most negative {low} and most positive {high}.

bool IsEmpty ( ) const

Test if the range has {low > high}, i.e. there are no x for which {low &le x && x &le high}.

bool IsEmptyOrSinglePoint ( ) const

Test if the range has {high >= low}, i.e. is empty or just one point.

bool IsEqualInterval ( DRange1dCR  other) const

Test if equal intervals in point set sense.

Any pair of empty intervals (even if different low and high) are equal.

bool IsEqualLowHigh ( DRange1dCR  other) const

Direct equality test for low and high parts.

static bool IsIncreasing ( bvector< DRange1d > &  data,
bool  allowZeroLength = false,
bool  allowZeroGaps = false 
)
static

Test for increasing relationships, optionally allowing zero length.

bool IsInfiniteNegative ( ) const

Test if the range has the most negative possible {low}.

bool IsInfinitePositive ( ) const

Test if the range has the largest possible {high}.

bool IsNull ( ) const

Test if the range is exactly the same as the null ranges returned by NullRange ().

bool IsPositiveLength ( ) const

Test if the range has {high > low}, i.e. has a non-empty set of points with properly sorted lower and upper limit.

bool IsSameLowHigh ( DRange1dCR  other,
double  relTol 
) const

test for toleranced equality of low to low and high to high

bool IsSameMinMax ( DRange1dCR  other,
double  absTol 
) const

test for toleranced equality of (min max of) low and high.

bool IsSinglePoint ( ) const

Test if the range is a single point.

bool IsSinglePoint ( double  value) const

Test if the range is a particular single point.

bool IsSubsetOf ( DRange1dCR  other) const

Test if the instance range is a (possibly complete, possibly empty) subset of {other} range.

double Length ( ) const

Return {MAX(0, high - low)} The DRange1::NullRange returns 0.

A single-point interval returns 0. An interval with {high < low} returns 0. Normal case returns {high - low}

static double LengthSum ( bvector< DRange1d > &  data)
static

Sum the interval lengths.

double Low ( ) const

Get the low limit (unchecked).

double MaxAbs ( double  defaultValeForNullRange = 0.0) const

return the largest coordinate (absolute value) in the range.

static DRange1d NullRange ( )
static

Return a range which satisfies IsNull ()

static void SimplifyInPlace ( bvector< DRange1d > &  data)
static

Combine intervals so there are no overlaps.

static void SortLowInPlace ( bvector< DRange1d > &  data)
static

Sort on low values.

bool StrictlyNonEmptyFractionalIntersection ( DRange1dCR  rangeB,
DRange1dR  fractionalIntersection 
)

Compute intersection of the instance with rangeB.

Return the intersection as fractions of the instance.

Returns
true if the fractional intersection is more than single point.
static void UnionSorted ( bvector< DRange1d > &  dataA,
bvector< DRange1d > &  dataB,
bvector< DRange1d > &  dataOut 
)
static

Union of intervals in two pre-sorted sets. Output may NOT be the same as either input.

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.

The ray parameterized {x = x0+s*dxdx} The instance is an {s} range that is live. This is usually initialized to InfiniteRange before clipping. {xA,xB} is an interval of the {x} space. (xA and xB are not required to be sorted.}

Parameters
[in]x0ray start coordinate in this dimension
[in]dxdsRate of change of ray in this dimension.
[in]xAx limit
[in]xBx limit.
Returns
true if interval is nonempty at return.
static DRange1d ZeroAndNegativeRange ( )
static

Return a complete 0 and negative range (-DBL_MAX to 0)

static DRange1d ZeroAndPositiveRange ( )
static

Return a complete 0 and positive range (0 to DBL_MAX)

Member Data Documentation

double high

high point of box

double low

low point of box


The documentation for this struct was generated from the following file:

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