A derived class based on MappedSPnode < cxsc::interval >. More...
Classes | |
class | Measurer |
Inner interface for types measuring nodes. More... | |
Public Types | |
typedef std::vector < IntervalMappedSPnode * > | Ptrs |
typedef Ptrs::iterator | PtrsItr |
typedef std::vector< const IntervalMappedSPnode * > | ConstPtrs |
typedef ConstPtrs::const_iterator | ConstPtrsItr |
typedef std::list < IntervalMappedSPnode * > | ListPtrs |
typedef ListPtrs::iterator | ListPtrsItr |
typedef std::list< const IntervalMappedSPnode * > | ListConstPtrs |
typedef ListConstPtrs::const_iterator | ListConstPtrsItr |
Public Member Functions | |
virtual | ~IntervalMappedSPnode () |
Destructor. | |
IntervalMappedSPnode () | |
No-argument constructor. | |
IntervalMappedSPnode (const ivector &v) | |
initialised constructor. | |
IntervalMappedSPnode (const LabBox &lb) | |
Initialised constructor. | |
IntervalMappedSPnode (const ivector &v, const cxsc::interval &range) | |
Initialised constructor. | |
IntervalMappedSPnode (const LabBox &lb, const cxsc::interval &range) | |
Initialised constructor. | |
IntervalMappedSPnode (const SPnode &other) | |
Copy constructor. | |
IntervalMappedSPnode (const IntervalMappedSPnode &other) | |
Copy constructor. | |
IntervalMappedSPnode (const MappedSPnode< cxsc::interval > &other) | |
Copy constructor. | |
IntervalMappedSPnode & | operator= (IntervalMappedSPnode rhs) |
Copy assignment operator. | |
IntervalMappedSPnode & | operator= (MappedSPnode< cxsc::interval > rhs) |
Copy assignment operator. | |
void | replaceMe (IntervalMappedSPnode newNode) |
Replace the properties of this node and its descendents with the properties of another node and its descendents. | |
void | replaceMe (MappedSPnode< cxsc::interval > newNode) |
Replace the properties of this node and its descendents with the properties of another node and its descendents. | |
IntervalMappedSPnode * | getParent () const |
Accessor for the parent of a node. | |
IntervalMappedSPnode * | getLeftChild () const |
Accessor for the left child of a node. | |
IntervalMappedSPnode * | getRightChild () const |
Accessor for the right child of a node. | |
bool | operator< (const IntervalMappedSPnode &rhs) const |
Less-than operator. | |
IntervalMappedSPnode & | operator+= (const real &val) |
Self-scalar addition operator with real scalar. | |
const IntervalMappedSPnode | operator+ (const real &val) const |
Scalar addition operator with real scalar. | |
IntervalMappedSPnode & | operator-= (const real &val) |
Self-scalar subraction operator with real scalar. | |
const IntervalMappedSPnode | operator- (const real &val) const |
Scalar subtraction operator with real scalar. | |
IntervalMappedSPnode & | operator*= (const real &val) |
Self-scalar multiplication operator with real scalar. | |
const IntervalMappedSPnode | operator* (const real &val) const |
Scalar multiplication operator with real scalar. | |
IntervalMappedSPnode & | operator/= (const real &val) |
Self-scalar division operator with real scalar. | |
const IntervalMappedSPnode | operator/ (const real &val) const |
Scalar division operator with real scalar. | |
const IntervalMappedSPnode * | findContainingNode (const cxsc::rvector &pt, OPERATIONS_ON childInd=ON_PARENT) const |
virtual void | nodeExpand (int comp) |
Add two sibling child nodes to this provided this is a leaf. | |
virtual void | nodeExpand () |
Add two sibling child nodes to this provided this is a leaf. | |
virtual void | hullPropagation () |
Propagate the interval hull of the children upwards. | |
cxsc::real | getRangeDiameter () const |
Get the diameter of interval range of this. | |
virtual cxsc::real | getIntervalAreaOnBox () const |
Get the "area" of the interval range over the box of this. | |
virtual cxsc::real | getTotalLeafIntervalAreaOnBox () const |
Get the total "area" of the interval ranges over the boxes for the leaves of this. | |
cxsc::real | getIntervalAreaDiffToChildren () const |
Get the difference between the "area" of the interval range over the box of this and the sum of the "areas" of the interval ranges of the children over their boxes. | |
Ptrs & | getLeaves (Ptrs &leaves) |
Return a reference to a container of nodes. | |
ConstPtrs & | getConstLeaves (ConstPtrs &leaves) const |
Return a reference to a container of const nodes. | |
Ptrs & | getSubLeaves (Ptrs &subleaves) |
Return a reference to a container of nodes. | |
ConstPtrs & | getConstSubLeaves (ConstPtrs &subleaves) const |
Return a reference to a container of const nodes. | |
void | swapIMSP (IntervalMappedSPnode &spn) |
virtual std::ostream & | nodePrint (std::ostream &os) const |
Print the details of a specific node in a subpaving. |
A derived class based on MappedSPnode < cxsc::interval >.
The base class MappedSPnode is a node in the representation of a mapped regular subpaving as a binary tree, where the type mapped to the nodes is a real. A node represents a box (interval vector). MappedSPnodes are linked together to form the tree. The initial box of the subpaving is the box represented by the root node of the tree. A box which has been split will be represented as node with one or two children. A subpaving of [x] (union of non-overlapping sub- boxes of [x]) is represented by the leaves (degenerate/ child-less) nodes in the tree. Each node will have a single interval value mapped to it.
A IntervalMappedSPnode provides the functionality of the MappedSPnode <interval> and extended functionality appropriate for interval mapped nodes.
typedef std::vector< IntervalMappedSPnode* > subpavings::IntervalMappedSPnode::Ptrs |
@ name Definitions for collection types for IntervalMappedSPnodes
IntervalMappedSPnode::IntervalMappedSPnode | ( | const ivector & | v | ) | [explicit] |
initialised constructor.
Initialised with a box. Range is set to cxsc::interval(0.0,0.0).
: MappedSPnode<cxsc::interval>(v, cxsc::interval(0.0,0.0)) {}
IntervalMappedSPnode::IntervalMappedSPnode | ( | const LabBox & | lb | ) | [explicit] |
Initialised constructor.
Initialised with a labeled box. Range is set to cxsc::interval(0.0,0.0).
: MappedSPnode<cxsc::interval>(lb, cxsc::interval(0.0,0.0)) {}
IntervalMappedSPnode::IntervalMappedSPnode | ( | const ivector & | v, |
const cxsc::interval & | range | ||
) |
Initialised constructor.
Initialised with a box and an interval value for the rangeCollection.
: MappedSPnode<cxsc::interval>(v, range) {}
IntervalMappedSPnode::IntervalMappedSPnode | ( | const LabBox & | lb, |
const cxsc::interval & | range | ||
) |
Initialised constructor.
Initialised with a labeled box and an interval value for the rangeCollection.
: MappedSPnode<cxsc::interval>(lb, range) {}
IntervalMappedSPnode::IntervalMappedSPnode | ( | const SPnode & | other | ) | [explicit] |
Copy constructor.
Range is set to csxc::interval(0.0, 0.0).
Copies from given SPnode downwards.
{ if (!other.isEmpty()) { theBox = new ivector( other.getBox() ); } nodeName = other.getNodeName(); range = cxsc::interval(0.0,0.0); //recursion on the children if (other.hasLCwithBox()) { nodeAddLeft(new IntervalMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new IntervalMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
IntervalMappedSPnode::IntervalMappedSPnode | ( | const IntervalMappedSPnode & | other | ) |
Copy constructor.
Copies from given IntervalMappedSPnode downwards.
{ if (other.theBox != NULL) { theBox = new ivector( other.getBox() ); } nodeName = other.getNodeName(); range = other.getRange(); //recursion on the children if (other.hasLCwithBox()) { nodeAddLeft(new IntervalMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new IntervalMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
IntervalMappedSPnode::IntervalMappedSPnode | ( | const MappedSPnode< cxsc::interval > & | other | ) |
Copy constructor.
Copies from a given MappedSPnode<cxsc::interval> node downwards.
{ if (!other.isEmpty()) { theBox = new ivector( other.getBox() ); } nodeName = other.getNodeName(); range = other.getRange(); //recursion on the children if (other.hasLCwithBox()) { nodeAddLeft(new IntervalMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new IntervalMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
const IntervalMappedSPnode * IntervalMappedSPnode::findContainingNode | ( | const cxsc::rvector & | pt, |
OPERATIONS_ON | childInd = ON_PARENT |
||
) | const |
Get a pointer to the leaf node descendent of this whose box contains the point pt.
{ if ( isEmpty() ) { throw NoBox_Error( "IntervalMappedSPnode::findContainingNode(const cxsc::rvector&, OPERATIONS_ON)"); } // start at the top const IntervalMappedSPnode* retObj = NULL; if(nodeContains(pt, childInd)) { if(isLeaf()) { // give this node as return value retObj = this; } // end of isLeaf // if not a leaf and contains data // recurse on the children if any else { if(hasRCwithBox()){ retObj = (getRightChild())->findContainingNode( pt, ON_RIGHT); } // only try left if we did not find on the right if(retObj == NULL && hasLCwithBox()) { retObj = (getLeftChild())->findContainingNode( pt, ON_LEFT); } } } // end if node contains // will return null if does not contain the data return retObj; }
IntervalMappedSPnode::ConstPtrs & IntervalMappedSPnode::getConstLeaves | ( | IntervalMappedSPnode::ConstPtrs & | leaves | ) | const |
Return a reference to a container of const nodes.
Contents of container are the leaves descended from this, or this if this is a leaf, left to right order.
{ //if children, recurse on the children if (hasLCwithBox()) { getLeftChild()->getConstLeaves(leaves); } if (hasRCwithBox()) { getRightChild()->getConstLeaves(leaves); } if ( isLeaf() ) { // this is a leaf leaves.push_back(this); } return leaves; }
IntervalMappedSPnode::ConstPtrs & IntervalMappedSPnode::getConstSubLeaves | ( | IntervalMappedSPnode::ConstPtrs & | subleaves | ) | const |
Return a reference to a container of const nodes.
Contents of container are the sub-leaves descended from this, or this if this is a sub-leaf, left to right order.
A sub-leaf (aka "cherry") is a node with two leaf child nodes.
{ if (isSubLeaf()) { // this is a subleaf subleaves.push_back(this); } //if children, recurse on the children else if (!isLeaf()) { getLeftChild()->getConstSubLeaves(subleaves); getRightChild()->getConstSubLeaves(subleaves); } return subleaves; }
cxsc::real IntervalMappedSPnode::getIntervalAreaDiffToChildren | ( | ) | const |
Get the difference between the "area" of the interval range over the box of this and the sum of the "areas" of the interval ranges of the children over their boxes.
{ cxsc::real retr(0.0); if (isLeaf() ) { retr = getIntervalAreaOnBox(); } else { retr = nodeRealVolume() * (getRangeDiameter() - 0.5*(getLeftChild()->getRangeDiameter() + getRightChild()->getRangeDiameter() ) ); } return retr; }
cxsc::real IntervalMappedSPnode::getIntervalAreaOnBox | ( | ) | const [virtual] |
Get the "area" of the interval range over the box of this.
The "area" returned is calculated as the volume of the box represented by this multiplied by the diameter of the interval range of this (which can also be seen as the volume of the box represented by this with the interval range of this added as an extra dimension).
{ cxsc::real retr(0.0); if (!cxsc::IsEmpty(range)) { retr = getRangeDiameter() * nodeRealVolume(); } return retr; }
Return a reference to a container of nodes.
Contents of container are the leaves descended from this, or this if this is a leaf, left to right order.
{ //if children, recurse on the children if (hasLCwithBox()) { getLeftChild()->getLeaves(leaves); } if (hasRCwithBox()) { getRightChild()->getLeaves(leaves); } if ( isLeaf() ) { // this is a leaf leaves.push_back(this); } return leaves; }
Accessor for the left child of a node.
Returns a copy of the pointer to leftChild node.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ return (IntervalMappedSPnode*) leftChild; }
IntervalMappedSPnode * IntervalMappedSPnode::getParent | ( | ) | const |
Accessor for the parent of a node.
Returns a copy of the pointer to parent node.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ return (IntervalMappedSPnode*) parent; }
Accessor for the right child of a node.
Returns a copy of the pointer to rightChild node.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ return (IntervalMappedSPnode*) rightChild; }
IntervalMappedSPnode::Ptrs & IntervalMappedSPnode::getSubLeaves | ( | IntervalMappedSPnode::Ptrs & | subleaves | ) |
Return a reference to a container of nodes.
Contents of container are the sub-leaves descended from this, or this if this is a sub-leaf, left to right order.
A sub-leaf (aka "cherry") is a node with two leaf child nodes.
{ if (isSubLeaf()) { // this is a subleaf subleaves.push_back(this); } //if children, recurse on the children else if (!isLeaf()) { getLeftChild()->getSubLeaves(subleaves); getRightChild()->getSubLeaves(subleaves); } return subleaves; }
cxsc::real IntervalMappedSPnode::getTotalLeafIntervalAreaOnBox | ( | ) | const [virtual] |
Get the total "area" of the interval ranges over the boxes for the leaves of this.
For each leaf descendent of this the "area" returned is calculated as the volume of the box represented multiplied by the diameter of the interval range of the node (which can also be seen as the volume of the box represented with the interval range of the node added as an extra dimension).
{ if (isLeaf()) return getIntervalAreaOnBox(); else { return ( getLeftChild()->getTotalLeafIntervalAreaOnBox() + getRightChild()->getTotalLeafIntervalAreaOnBox() ); } }
void IntervalMappedSPnode::hullPropagation | ( | ) | [virtual] |
Propagate the interval hull of the children upwards.
hullPropagates children then recalculates the range for this node as the interval hull of the ranges of the children.
{ #ifdef MYDEBUGHULL std::cout << "In hullPropagation, I am " << nodeName << std::endl; #endif // first recursively deal with the children of the children if (hasLCwithBox()) getLeftChild()->hullPropagation(); if (hasRCwithBox()) getRightChild()->hullPropagation(); // now deal with this if (hasLCwithBox() && hasRCwithBox()) { #ifdef MYDEBUGHULL std::cout << "Back in hullPropagation for " << nodeName << std::endl; std::cout << "my range is " << range << std::endl; std::cout << "getLeftChild()->range is " << (getLeftChild()->range) << std::endl; std::cout << "getRightChild()->range is " << (getRightChild()->range) << std::endl; std::cout << "(getLeftChild()->getRange() | getRightChild()->getRange()) is " << ((getLeftChild()->getRange() | getRightChild()->getRange())) << std::endl; #endif // hull range = (getLeftChild()->getRange() | getRightChild()->getRange()); } }
void IntervalMappedSPnode::nodeExpand | ( | int | comp | ) | [virtual] |
Add two sibling child nodes to this provided this is a leaf.
Each new child gets half of the box associated with this, splitting the box in half normal to dimension set by comp.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ // can only expand if there is a box if (NULL == theBox) { throw NoBox_Error("IntervalMappedSPnode::nodeExpand(int)"); } // only do something if this node is a leaf if (isLeaf()) { IntervalMappedSPnode* newLC = NULL; IntervalMappedSPnode* newRC = NULL; try { // ivectors to become boxes for new children ivector lC, rC; // Call Lower() and Upper() to put split boxes // into lC and rC respectively Lower(getBox(), lC, comp); Upper(getBox(), rC, comp); // make and add the new children newLC = new IntervalMappedSPnode(lC, range); newRC = new IntervalMappedSPnode(rC, range); nodeAddLeft(newLC); nodeAddRight(newRC); // both children get the same range as this //name the new children getLeftChild()->setNodeName(nodeName + "L"); getRightChild()->setNodeName(nodeName + "R"); // new children have summary from this } catch(std::exception& e) { // overkill, but try to deal with all eventualities... try { if (getLeftChild() != NULL) { delete (getLeftChild()); leftChild = NULL; } if (getRightChild() != NULL) { delete (getRightChild()); rightChild = NULL; } if (newLC != NULL) { delete newLC; newLC = NULL; } if (newRC != NULL) { delete newRC; newRC = NULL; } } catch(std::exception& e) {} //catch and swallow throw; // rethrow original exception } } }
void IntervalMappedSPnode::nodeExpand | ( | ) | [virtual] |
Add two sibling child nodes to this provided this is a leaf.
Each new child gets half of the box associated with this, splitting the box in half normal to the first longest dimension of the box associated with this.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ int maxdiamcomp; // variable to hold first longest dimension double temp = ::MaxDiam(getBox(), maxdiamcomp); nodeExpand(maxdiamcomp); // complete nodeExpand }
const IntervalMappedSPnode IntervalMappedSPnode::operator* | ( | const real & | val | ) | const |
Scalar multiplication operator with real scalar.
val | the value to multiply this by to give the object returned. |
{ return this->MappedSPnode<cxsc::interval>::operator*(cxsc::interval(val));; }
IntervalMappedSPnode & IntervalMappedSPnode::operator*= | ( | const real & | val | ) |
Self-scalar multiplication operator with real scalar.
val | the value to multiply this by. |
{ MappedSPnode<cxsc::interval>::operator*=(cxsc::interval(val)); return *this; }
const IntervalMappedSPnode IntervalMappedSPnode::operator+ | ( | const real & | val | ) | const |
Scalar addition operator with real scalar.
val | the value to add to this to give the object returned. |
{ return this->MappedSPnode<cxsc::interval>::operator+(cxsc::interval(val));; }
IntervalMappedSPnode & IntervalMappedSPnode::operator+= | ( | const real & | val | ) |
Self-scalar addition operator with real scalar.
val | the value to add to this. |
{ MappedSPnode<cxsc::interval>::operator+=(cxsc::interval(val)); return *this; }
const IntervalMappedSPnode IntervalMappedSPnode::operator- | ( | const real & | val | ) | const |
Scalar subtraction operator with real scalar.
val | the value to subtract from this to give the object returned. |
{ return this->MappedSPnode<cxsc::interval>::operator-(cxsc::interval(val));; }
IntervalMappedSPnode & IntervalMappedSPnode::operator-= | ( | const real & | val | ) |
Self-scalar subraction operator with real scalar.
val | the value to subtract from this. |
{ MappedSPnode<cxsc::interval>::operator-=(cxsc::interval(val)); return *this; }
const IntervalMappedSPnode IntervalMappedSPnode::operator/ | ( | const real & | val | ) | const |
Scalar division operator with real scalar.
val | the value to divide this by to give the object returned. |
{ return this->MappedSPnode<cxsc::interval>::operator/(cxsc::interval(val));; }
IntervalMappedSPnode & IntervalMappedSPnode::operator/= | ( | const real & | val | ) |
Self-scalar division operator with real scalar.
val | the value to divide this by. |
{ MappedSPnode<cxsc::interval>::operator/=(cxsc::interval(val)); return *this; }
bool IntervalMappedSPnode::operator< | ( | const IntervalMappedSPnode & | rhs | ) | const |
IntervalMappedSPnode & IntervalMappedSPnode::operator= | ( | IntervalMappedSPnode | rhs | ) |
Copy assignment operator.
Copies from given IntervalMappedSPnode downwards.
{ rhs.swapIMSP(*this); // make sure we use our version of swap return(*this); }
IntervalMappedSPnode & IntervalMappedSPnode::operator= | ( | MappedSPnode< cxsc::interval > | rhs | ) |
Copy assignment operator.
Copies from a given MappedSPnode<cxsc::interval> node downwards.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ rhs.swapMSPSR(*this); // make sure we use our version of swap return(*this); }
void IntervalMappedSPnode::replaceMe | ( | IntervalMappedSPnode | newNode | ) |
Replace the properties of this node and its descendents with the properties of another node and its descendents.
Copies newNode node downwards into this, but keeps the relationship of this with its parent, ie if this is a node in a tree, the part of the tree rooted at this is made identical to newNode but the relationship to the rest of the tree,through the link between this and its parent, is retained.
{ IntervalMappedSPnode* pNode = getParent(); newNode.swapIMSP(*this); if (NULL != pNode) { this->parent = pNode; } }
void IntervalMappedSPnode::replaceMe | ( | MappedSPnode< cxsc::interval > | newNode | ) |
Replace the properties of this node and its descendents with the properties of another node and its descendents.
Copies newNode node downwards into this, but keeps the relationship of this with its parent, ie if this is a node in a tree, the part of the tree rooted at this is made identical to newNode but the relationship to the rest of the tree,through the link between this and its parent, is retained.
Reimplemented from subpavings::MappedSPnode< cxsc::interval >.
{ IntervalMappedSPnode* pNode = getParent(); newNode.swapMSPSR(*this); if (NULL != pNode) { this->parent = pNode; } }