A derived class based on MappedSPnode < bool >. More...
Public Types | |
typedef std::vector < BooleanValueMappedSPnode * > | Ptrs |
typedef Ptrs::iterator | PtrsItr |
typedef std::vector< const BooleanValueMappedSPnode * > | ConstPtrs |
typedef ConstPtrs::const_iterator | ConstPtrsItr |
typedef std::list < BooleanValueMappedSPnode * > | ListPtrs |
typedef ListPtrs::iterator | ListPtrsItr |
typedef std::list< const BooleanValueMappedSPnode * > | ListConstPtrs |
typedef ListConstPtrs::const_iterator | ListConstPtrsItr |
Public Member Functions | |
virtual | ~BooleanValueMappedSPnode () |
Destructor. | |
BooleanValueMappedSPnode () | |
No-argument constructor. | |
BooleanValueMappedSPnode (const ivector &v) | |
initialised constructor. | |
BooleanValueMappedSPnode (const LabBox &lb) | |
Initialised constructor. | |
BooleanValueMappedSPnode (const ivector &v, bool range) | |
Initialised constructor. | |
BooleanValueMappedSPnode (const LabBox &lb, bool range) | |
Initialised constructor. | |
BooleanValueMappedSPnode (const ivector &v, const BooleanMappedValue &range) | |
Initialised constructor. | |
BooleanValueMappedSPnode (const LabBox &lb, const BooleanMappedValue &range) | |
Initialised constructor. | |
BooleanValueMappedSPnode (const SPnode &other) | |
Copy constructor. | |
BooleanValueMappedSPnode (const BooleanValueMappedSPnode &other) | |
Copy constructor. | |
BooleanValueMappedSPnode (const MappedSPnode< BooleanMappedValue > &other) | |
Copy constructor. | |
BooleanValueMappedSPnode & | operator= (BooleanValueMappedSPnode rhs) |
Copy assignment operator. | |
BooleanValueMappedSPnode & | operator= (MappedSPnode< BooleanMappedValue > rhs) |
Copy assignment operator. | |
void | replaceMe (BooleanValueMappedSPnode newNode) |
Replace the properties of this node and its descendents with the properties of another node and its descendents. | |
void | replaceMe (MappedSPnode< BooleanMappedValue > newNode) |
Replace the properties of this node and its descendents with the properties of another node and its descendents. | |
BooleanValueMappedSPnode * | getParent () const |
Accessor for the parent of a node. | |
BooleanValueMappedSPnode * | getLeftChild () const |
Accessor for the left child of a node. | |
BooleanValueMappedSPnode * | getRightChild () const |
Accessor for the right child of a node. | |
bool | getRange () const |
Get the value represented by this, as a boolean. | |
const BooleanValueMappedSPnode * | 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 cxsc::real | getTrueAreaOnBox () const |
Get the "area" of the true range over the box of this. | |
virtual cxsc::real | getTotalLeafTrueAreaOnBox () const |
Get the total "area" of the true ranges over the boxes for the leaves of this. | |
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 | swapBMSP (BooleanValueMappedSPnode &spn) |
virtual std::ostream & | nodePrint (std::ostream &os) const |
Print the details of a specific node in a subpaving. | |
virtual std::ostream & | leavesOutputTabsTrue (std::ostream &os) const |
Output all leaf nodes with true values mapped to them. | |
virtual std::ostream & | leavesOutputTabsTrue (std::ostream &os, int prec) const |
Output all leaf nodes with true values mapped to them. |
A derived class based on MappedSPnode < bool >.
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 boolean value mapped to it.
A BooleanValueMappedSPnode provides the functionality of the MappedSPnode <bool> and extended functionality appropriate for boolean mapped nodes.
typedef std::vector< BooleanValueMappedSPnode* > subpavings::BooleanValueMappedSPnode::Ptrs |
@ name Definitions for collection types for BooleanValueMappedSPnodes
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const ivector & | v | ) | [explicit] |
initialised constructor.
Initialised with a box. Range is set to false.
: MappedSPnode<BooleanMappedValue>(v, BooleanMappedValue(false)) {}
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const LabBox & | lb | ) | [explicit] |
Initialised constructor.
Initialised with a labeled box. Range is set to false.
: MappedSPnode<BooleanMappedValue>(lb, BooleanMappedValue(false)) {}
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const ivector & | v, |
bool | range | ||
) |
Initialised constructor.
Initialised with a box and a boolean value for the range.
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const LabBox & | lb, |
bool | range | ||
) |
Initialised constructor.
Initialised with a labeled box and a boolean value for the range.
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const ivector & | v, |
const BooleanMappedValue & | range | ||
) |
Initialised constructor.
Initialised with a box and a BooleanMappedValue for the range.
: MappedSPnode<BooleanMappedValue>(v, range) {}
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const LabBox & | lb, |
const BooleanMappedValue & | range | ||
) |
Initialised constructor.
Initialised with a labeled box and a BooleanMappedValue for the range.
: MappedSPnode<BooleanMappedValue>(lb, range) {}
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const SPnode & | other | ) | [explicit] |
Copy constructor.
Range is set to false.
Copies from given SPnode downwards.
{ if (!other.isEmpty()) { theBox = new ivector( other.getBox() ); } nodeName = other.getNodeName(); range = BooleanMappedValue(false); //recursion on the children if (other.hasLCwithBox()) { nodeAddLeft(new BooleanValueMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new BooleanValueMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
Copy constructor.
Copies from given BooleanValueMappedSPnode 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 BooleanValueMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new BooleanValueMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
BooleanValueMappedSPnode::BooleanValueMappedSPnode | ( | const MappedSPnode< BooleanMappedValue > & | other | ) |
Copy constructor.
Copies from a given MappedSPnode<BooleanMappedValue> 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 BooleanValueMappedSPnode( *(other.getLeftChild()))); } else leftChild=NULL; if (other.hasRCwithBox()) { nodeAddRight(new BooleanValueMappedSPnode( *(other.getRightChild()))); } else rightChild=NULL; }
const BooleanValueMappedSPnode * BooleanValueMappedSPnode::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 BooleanValueMappedSPnode* 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; }
BooleanValueMappedSPnode::ConstPtrs & BooleanValueMappedSPnode::getConstLeaves | ( | BooleanValueMappedSPnode::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; }
BooleanValueMappedSPnode::ConstPtrs & BooleanValueMappedSPnode::getConstSubLeaves | ( | BooleanValueMappedSPnode::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; }
BooleanValueMappedSPnode::Ptrs & BooleanValueMappedSPnode::getLeaves | ( | BooleanValueMappedSPnode::Ptrs & | leaves | ) |
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< BooleanMappedValue >.
{ return (BooleanValueMappedSPnode*) leftChild; }
Accessor for the parent of a node.
Returns a copy of the pointer to parent node.
Reimplemented from subpavings::MappedSPnode< BooleanMappedValue >.
{ return (BooleanValueMappedSPnode*) parent; }
Accessor for the right child of a node.
Returns a copy of the pointer to rightChild node.
Reimplemented from subpavings::MappedSPnode< BooleanMappedValue >.
{ return (BooleanValueMappedSPnode*) rightChild; }
BooleanValueMappedSPnode::Ptrs & BooleanValueMappedSPnode::getSubLeaves | ( | BooleanValueMappedSPnode::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 BooleanValueMappedSPnode::getTotalLeafTrueAreaOnBox | ( | ) | const [virtual] |
Get the total "area" of the true 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 if the range it true, else 0.0.
{ if (isLeaf()) return getTrueAreaOnBox(); else { return ( getLeftChild()->getTotalLeafTrueAreaOnBox() + getRightChild()->getTotalLeafTrueAreaOnBox() ); } }
cxsc::real BooleanValueMappedSPnode::getTrueAreaOnBox | ( | ) | const [virtual] |
Get the "area" of the true range over the box of this.
The "area" returned is calculated as the volume of the box represented by this if the range is true, 0.0 otherwise.
{ cxsc::real retr(0.0); if (range.getValue()) { retr = nodeRealVolume(); } return retr; }
std::ostream & BooleanValueMappedSPnode::leavesOutputTabsTrue | ( | std::ostream & | os, |
int | prec | ||
) | const [virtual] |
Output all leaf nodes with true values mapped to them.
prec | the precision for the output |
{ os << cxsc::SaveOpt; os << cxsc::Variable << cxsc::SetPrecision(prec+2,prec); leavesOutputTabsTrue(os); os << cxsc::RestoreOpt; return os; }
void BooleanValueMappedSPnode::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< BooleanMappedValue >.
{ // can only expand if there is a box if (NULL == theBox) { throw NoBox_Error("BooleanValueMappedSPnode::nodeExpand(int)"); } // only do something if this node is a leaf if (isLeaf()) { BooleanValueMappedSPnode* newLC = NULL; BooleanValueMappedSPnode* 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 BooleanValueMappedSPnode(lC, range); newRC = new BooleanValueMappedSPnode(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"); } 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 BooleanValueMappedSPnode::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< BooleanMappedValue >.
{ int maxdiamcomp; // variable to hold first longest dimension double temp = ::MaxDiam(getBox(), maxdiamcomp); nodeExpand(maxdiamcomp); // complete nodeExpand }
BooleanValueMappedSPnode & BooleanValueMappedSPnode::operator= | ( | BooleanValueMappedSPnode | rhs | ) |
Copy assignment operator.
Copies from given BooleanValueMappedSPnode downwards.
{ rhs.swapBMSP(*this); // make sure we use our version of swap return(*this); }
BooleanValueMappedSPnode & BooleanValueMappedSPnode::operator= | ( | MappedSPnode< BooleanMappedValue > | rhs | ) |
Copy assignment operator.
Copies from a given MappedSPnode<BooleanMappedValue> node downwards.
Reimplemented from subpavings::MappedSPnode< BooleanMappedValue >.
{ rhs.swapMSPSR(*this); // make sure we use our version of swap return(*this); }
void BooleanValueMappedSPnode::replaceMe | ( | BooleanValueMappedSPnode | 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.
{ BooleanValueMappedSPnode* pNode = getParent(); newNode.swapBMSP(*this); if (NULL != pNode) { this->parent = pNode; } }
void BooleanValueMappedSPnode::replaceMe | ( | MappedSPnode< BooleanMappedValue > | 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< BooleanMappedValue >.
{ BooleanValueMappedSPnode* pNode = getParent(); newNode.swapMSPSR(*this); if (NULL != pNode) { this->parent = pNode; } }