Library of Assembled Shared Sources
lass::prim::AutoMinMax Struct Reference

MinMaxPolicy automatically correcting wrong minima and maxima. More...

#include <min_max_policy.h>

Static Public Member Functions

template<typename PointType>
static void setMin (PointType &oMin, PointType &ioMax, const PointType &iMin)
 set value oMin to iMin and move ioMax (if necessary) so it stays correct.
 
template<typename PointType>
static void setMax (PointType &ioMin, PointType &oMax, const PointType &iMax)
 set value oMax to iMax and move ioMin (if necessary) so it stays correct.
 
template<typename PointType>
static void checkMinMax (PointType &ioMin, PointType &ioMax)
 correct ioMin and ioMax so that they are indeed then minimum and maximum.
 

Detailed Description

MinMaxPolicy automatically correcting wrong minima and maxima.

Author
Bram de Greve
Date
2003

The auto policy will silently correct wrong min/max situations by squeezing or swapping the values until a valid situation is achieved. How this is done, depends on the situation. We must consider two different possibities:

  • The easiest thing to explain is when you set both the minimum and the maximum at the same time. It can happen that you have swapped them by accident: you provided the maximum as minimum and vice versa. This policy will detect this and swap it again. Now the good thing is: it does this per component! So, you can have swapped x and y coordinates and coorect z coordinates, it will distill a correct minimum and maximum out of this. This is illustrated in the following example.
LASS_EVAL(aabb);
// output: aabb == '(1, 2, 3)-(4, 5, 6)'
your momma's axis aligned bounding box.
Definition aabb_3d.h:89
  • The other situation is when you only set the minimumm or maximum, and you want to keep to current maximum or minimum. In this case, we've opted for squeezing the values, rather than swapping them. The philosophy behind it is: when you set the minimum, you want to enforce a minimum. You don't want to be the maximum become a lesser minimum than the one you're setting, because it doesn't quite fit. No, instead of this, we squeeze or move the maximum along with the minimum. i.e. A new maximum is chooses so that it is not less than the current maximum, but not less than the new minimum either. It's hard to explain, but an example might illustrate this beautifully: for the y and z coordinate, there's nothing special to it: you set minimum values that are not greater than the maximum value, no misbehaviour here. On the other hand, for x coordinate the new minimum 5 is greater than the current maximum 4. Instead of swapping this values so that 4 becomes the new minimum, we enforce 5 as the minimum. All that is left is to choose a new value for the maximum x coordinate that is greater than 4 or not less than 5. Hmmm ... Would that be 5? :)
aabb.min() = Point3D<int>(5, 5, 5);
LASS_EVAL(aabb);
// output: aabb == '(5, 5, 5)-(5, 5, 6)'.
Note
this policy will not correct the empty state of an AABB. After all, in in contrary to other primitives, the empty state is a valid state for the AABB, so it does not have to be corrected.

The rest of the class are implementation details for the AABB and should not be called by the client (you :). In short we can say of this policy: if you try to do something stupid, we try to correct it for you.

Definition at line 222 of file min_max_policy.h.


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