A type that visits SPnodes to check if they meet an interval image tolerance requirement. More...
Public Member Functions | |
IntervalImageToleranceCheck (const MappedFobj &f, cxsc::real tol) | |
Constructor. | |
void | visit (const SPnode *const spn) const |
The visit operation. | |
bool | getResult () const |
Get the result of the visit operation. |
A type that visits SPnodes to check if they meet an interval image tolerance requirement.
The interval image tolerance requirement is that the maximum distance between the real image of the mid point of the box associated with the node and the ends of the interval image of the box associated with the node should be less than or equal to the tolerance given by the constructor argument tol.
A node may not meet the requirement but not be splittable: in this case the result of the visit should be true (ie the node is deemed to meet the requirement because it is as close as it can be to meeting it).
The visit operation should return true if either the the node visited meets the interval image tolerance requirement or the node does not meet the requirement but is not splittable. Return false otherwise.
subpavings::IntervalImageToleranceCheck::IntervalImageToleranceCheck | ( | const MappedFobj & | f, |
cxsc::real | tol | ||
) |
Constructor.
f | describes a function against which to check the interval image tolerance requirement. |
tol | describes the tolerance to be used in the check. |
: fobj(f), tolerance(tol) { if (tolerance < cxsc::MinReal) throw std::invalid_argument( "IntervalImageToleranceCheck::IntervalImageToleranceCheck(MappedFobj&, cxsc::real) : tol < cxsc::MinReal"); }
void subpavings::IntervalImageToleranceCheck::visit | ( | const SPnode *const | spn | ) | const [virtual] |
The visit operation.
Checks the node pointed to by spn and records the result true if the interval image tolerance requirement is met.
spn | a pointer to an SPnode to be visited. |
Implements subpavings::SPCheckVisitor.
{ #ifdef MYDEBUG std::cout << "in IntervalImageToleranceCheck::visit, for " << spn->getNodeName() << std::endl; #endif if (spn->isSplittableNode()) { ivector box = spn->getBox(); #ifdef MYDEBUG std::cout << "this box is " << box << std::endl; #endif interval thisRange = fobj(box); real thisMidImage = fobj.imageMid(box); #ifdef MYDEBUG std::cout << "this midImage is " << thisMidImage << std::endl; #endif #ifdef MYDEBUG std::cout << "this range is " << thisRange << std::endl; #endif #ifdef MYDEBUG std::cout << "this tolerance is " << tolerance << std::endl; #endif result = true; if (max(Sup(thisRange) - thisMidImage, thisMidImage - Inf(thisRange) ) > tolerance) { result = false; } } #ifdef MYDEBUG_MIN std::cout << "conclusion " << result << std::endl; #endif }