RealMappedShapeNodes are nodes in the representation of a non-regular non-rectangular non-axis aligned polygon-paving ("shape") as a binary tree, with each node having a real value mapped to it. More...
Public Types | |||||
typedef std::vector < RealMappedShapeNode * > | Ptrs | ||||
typedef Ptrs::iterator | PtrsItr | ||||
typedef Ptrs::const_iterator | PtrsConstItr | ||||
typedef std::vector< const RealMappedShapeNode * > | ConstPtrs | ||||
typedef ConstPtrs::const_iterator | ConstPtrsItr | ||||
Public Member Functions | |||||
RealMappedShapeNode (const RealMappedSPnode &rmsp, const std::vector< std::vector< double > > &backtransform, const std::vector< double > &scale, const std::vector< double > &shift) | |||||
Constructor with a transformation matrix. | |||||
RealMappedShapeNode (const RealMappedSPnode &rmsp, const std::vector< double > &scale, const std::vector< double > &shift) | |||||
Constructor with no transformation matrix. | |||||
RealMappedShapeNode (const cxsc::ivector &box, const std::vector< std::vector< double > > &backtransform, const std::vector< double > &scale, const std::vector< double > &shift, cxsc::real r=0.0) | |||||
Constructor with a transformation matrix, box and range. | |||||
RealMappedShapeNode (const cxsc::ivector &box, const std::vector< double > &scale, const std::vector< double > &shift, cxsc::real r=0.0) | |||||
Constructor with a scale, shift, box and range. | |||||
RealMappedShapeNode (const RealMappedShapeNode &other) | |||||
Copy constructor. | |||||
virtual | ~RealMappedShapeNode () | ||||
Destructor. | |||||
RealMappedShapeNode & | operator= (RealMappedShapeNode rhs) | ||||
Copy assignment operator. | |||||
size_t | getDimension () const | ||||
Accessor for the dimension of theBox of a node. | |||||
std::vector< std::vector< real > > | getVertices () const | ||||
Accessor for vertices of the box associated with the node. | |||||
real | getRange () const | ||||
Accessor for the value mapped to this. | |||||
std::string | getNodeName () const | ||||
Get the node name. | |||||
bool | isLeaf () const | ||||
Check if this RealMappedShapeNode is a leaf. | |||||
void | swap (RealMappedShapeNode &rmsn) | ||||
Swap this and another node. | |||||
Accessors for links between the nodes. | |||||
| |||||
RealMappedShapeNode * | getParent () const | ||||
Accessor for the parent of a node. | |||||
RealMappedShapeNode * | getLeftChild () const | ||||
Accessor for the left child of a node. | |||||
RealMappedShapeNode * | getRightChild () const | ||||
Accessor for the right child of a node. | |||||
Output for for <b>all leaves</b> of a binary tree. | |||||
Output intended for a txt file, in numeric form only.
| |||||
std::ostream & | leavesOutputTabs (std::ostream &os) const | ||||
std::ostream & | leavesOutputTabs (std::ostream &os, int prec) const | ||||
Output for <b>all nodes</b> in binary tree. | |||||
Output for all nodes in binary tree representing a subpaving in tab-delimited form. Output intended for console output. | |||||
std::ostream & | nodesAllOutput (std::ostream &os, int level) const | ||||
std::ostream & | nodesAllOutput (std::ostream &os, int level, int prec) const |
RealMappedShapeNodes are nodes in the representation of a non-regular non-rectangular non-axis aligned polygon-paving ("shape") as a binary tree, with each node having a real value mapped to it.
A RealMappedShapeNode represents a non-regular non-rectangular polygon shape with a real value mapped to it. RealMappedShapeNodes are linked together to form the tree. The initial polygon of the non-regular non-rectangular paving is the "root box" represented by the root node of the tree. A polygon which has been split will be represented as node with one or two children.
RealMappedShapeNodes have limited functionality compared to SPnode types and are intended to be able to display the results of transforming a RealMappedSPnode using transformations such as scaling, rotation and reflection, and also translation of the origin of the axes.
RealMappedShapeNode::RealMappedShapeNode | ( | const RealMappedSPnode & | rmsp, |
const std::vector< std::vector< double > > & | backtransform, | ||
const std::vector< double > & | scale, | ||
const std::vector< double > & | shift | ||
) |
Constructor with a transformation matrix.
This is constructed by applying a volume and angle-preserving back-transformation to the boxes in the paving represented by rmsp, then scaling as specifed in scale, then shifting as specified in shift.
The back-transformation is specified by the matrix represented by backtransform.
The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.
The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.
The tree rooted at this will have as many descendent nodes as rmsp and each node in the tree will have a box that is the result of applying the back-transformation matrix backtransform to the box of the equivalent node in rmsp, scaling it and shifting it, and then giving it a range value equal to the range value of the equivalent node in rmsp divided by the product of the elements in scale (ie adjusting for the change in the volume of the box that results from scaling the shapes in this).
rmsp | the RealMappedSPnode to use to provide the tree structure for this and the values to be adjusted for volume scaling to give the values mapped to nodes in this. |
backtransform | A representation of a volume preserving and angle preserving back-transformation matrix specified in row major order, ie the inner vectors of backtransform are the rows of the back-transformation matrix. |
scale | The scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this. |
shift | The shiftg to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this. |
: verticesPtr(NULL), range(rmsp.getRange()), parent(NULL), leftChild(NULL), rightChild(NULL), nodeName(rmsp.getNodeName()) { if (rmsp.isEmpty()) { throw NoBox_Error("RealMappedShapeNode::RealMappedShapeNode(...)"); } try { try { ivector box = rmsp.getBox(); extractVertices(box, backtransform); scaleAndShiftShape(scale, shift); } catch (std::invalid_argument& ia) { throw std::invalid_argument( string("RealMappedShapeNode::RealMappedShapeNode(...) :\n") + ia.what() ); } #ifdef MYDEBUG // output the name, range cout << nodeName << "\t" << range << "\t"; // followed by vertices all on one line for (std::vector < std::vector < real > >::const_iterator it = verticesPtr->begin(); it < verticesPtr->end(); ++it) { ostream_iterator< real > out_it (cout,"\t"); copy ( it->begin(), it->end(), out_it ); } cout << endl; #endif //recursion on the children if (rmsp.getLeftChild()) { leftChild=new RealMappedShapeNode(*rmsp.getLeftChild(), backtransform, scale, shift); leftChild->parent = this; } else leftChild=NULL; if (rmsp.getRightChild()) { rightChild=new RealMappedShapeNode(*rmsp.getRightChild(), backtransform, scale, shift); rightChild->parent = this; } else rightChild=NULL; } catch (exception const& e) { constructor_error_handler(); } }
RealMappedShapeNode::RealMappedShapeNode | ( | const RealMappedSPnode & | rmsp, |
const std::vector< double > & | scale, | ||
const std::vector< double > & | shift | ||
) |
Constructor with no transformation matrix.
This is constructed by scaling and shifting the subpaving represented in rmsp.
The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.
The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.
The tree rooted at this will have as many descendent nodes as rmsp and each node in the tree will have a box that is the result of scaling and shifting it the box of the equivalent node in rmsp, and then giving it a range value equal to the range value of the equivalent node in rmsp divided by the product of the elements in scale (ie adjusting for the change in the volume of the box that results from scaling the shapes in this).
rmsp | the RealMappedSPnode to use to provide the tree structure for this and the values to be adjusted for volume scaling to give the values mapped to nodes in this. |
scale | The scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this. |
shift | The shiftg to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this. |
: verticesPtr(NULL), range(rmsp.getRange()), parent(NULL), leftChild(NULL), rightChild(NULL), nodeName(rmsp.getNodeName()) { if (rmsp.isEmpty()) { throw NoBox_Error("RealMappedShapeNode::RealMappedShapeNode(...)"); } try { try { ivector box = rmsp.getBox(); extractVertices(box); scaleAndShiftShape(scale, shift); } catch (std::invalid_argument& ia) { throw std::invalid_argument( string("RealMappedShapeNode::RealMappedShapeNode(...) :\n") + ia.what() ); } #ifdef MYDEBUG // output the name, range cout << nodeName << "\t" << range << "\t"; // followed by vertices all on one line for (std::vector < std::vector < real > >::const_iterator it = verticesPtr->begin(); it < verticesPtr->end(); ++it) { ostream_iterator< real > out_it (cout,"\t"); copy ( it->begin(), it->end(), out_it ); } cout << endl; #endif //recursion on the children if (rmsp.getLeftChild()) { leftChild=new RealMappedShapeNode(*rmsp.getLeftChild(), scale, shift); leftChild->parent = this; } else leftChild=NULL; if (rmsp.getRightChild()) { rightChild=new RealMappedShapeNode(*rmsp.getRightChild(), scale, shift); rightChild->parent = this; } else rightChild=NULL; } catch (exception const& e) { constructor_error_handler(); } }
subpavings::RealMappedShapeNode::RealMappedShapeNode | ( | const cxsc::ivector & | box, |
const std::vector< std::vector< double > > & | backtransform, | ||
const std::vector< double > & | scale, | ||
const std::vector< double > & | shift, | ||
cxsc::real | r = 0.0 |
||
) |
Constructor with a transformation matrix, box and range.
This is constructed by applying a volume and angle-preserving back-transformation to the boxbox, then scaling as specifed in scale, then shifting as specified in shift.
The back-transformation is specified by the matrix represented by backtransform.
The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.
The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.
The tree rooted at this will consist of a single leaf node. That node will have a box that is the result of applying the back-transformation matrix backtransform to the box box, scaling it and shifting it, and then giving it a range value equal to the value of r divided by the product of the elements in scale (ie adjusting for the change in the volume of the box that results from scaling the shapes in this).
box | the box to use to find the vertices of this after scaling and shifting and back transforming. |
backtransform | A representation of a volume preserving and angle preserving back-transformation matrix specified in row major order, ie the inner vectors of backtransform are the rows of the back-transformation matrix. |
scale | The scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this. |
shift | The shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this. |
r | The value to be used for the range of this after adjusting for changes in scaling. |
subpavings::RealMappedShapeNode::RealMappedShapeNode | ( | const cxsc::ivector & | box, |
const std::vector< double > & | scale, | ||
const std::vector< double > & | shift, | ||
cxsc::real | r = 0.0 |
||
) |
Constructor with a scale, shift, box and range.
This is constructed scaling as specifed in scale, then shifting as specified in shift.
The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.
The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.
The tree rooted at this will consist of a single leaf node. That node will have a box that is the result of scaling box it and shifting it, and then giving it a range value equal to the value of r divided by the product of the elements in scale (ie adjusting for the change in the volume of the box that results from scaling the shapes in this).
box | the box to use to find the vertices of this after scaling and shifting and back transforming. |
scale | The scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this. |
shift | The shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this. |
r | The value to be used for the range of this after adjusting for changes in scaling. |
RealMappedShapeNode * RealMappedShapeNode::getLeftChild | ( | ) | const |
Accessor for the left child of a node.
Returns a pointer to leftChild node.
{ return leftChild; }
RealMappedShapeNode * RealMappedShapeNode::getParent | ( | ) | const |
Accessor for the parent of a node.
Returns a pointer to parent node.
{ return parent; }
Accessor for the right child of a node.
Returns a pointer to rightChild node.
{ return rightChild; }
bool RealMappedShapeNode::isLeaf | ( | ) | const |
Check if this RealMappedShapeNode is a leaf.
{return ( (NULL == leftChild) && (NULL == rightChild)); }
void RealMappedShapeNode::swap | ( | RealMappedShapeNode & | rmsn | ) |
Swap this and another node.
Swaps all the data members of this with the other node.
spn | a reference to the node to swap with |
{ std::swap(verticesPtr, rmsn.verticesPtr); std::swap(range, rmsn.range); std::swap(nodeName, rmsn.nodeName); std::swap(parent, rmsn.parent); // can just swap child pointers std::swap(leftChild, rmsn.leftChild); std::swap(rightChild, rmsn.rightChild); // children have to be repointed to the new swapped parents if (leftChild != NULL) leftChild->parent = this; if (rightChild != NULL) rightChild->parent = this; if (rmsn.leftChild != NULL) rmsn.leftChild->parent = &rmsn; if (rmsn.rightChild != NULL) rmsn.rightChild->parent = &rmsn; }