A wrapper or manager for an BooleanValueMappedSPnode tree representing a spatial object. More...
Public Member Functions | |||||||
SpatialObjectRepresentationBV () | |||||||
No argument constructor. | |||||||
SpatialObjectRepresentationBV (const ivector &v, int lab=0) | |||||||
Initialised constructor. | |||||||
SpatialObjectRepresentationBV (const BooleanValueMappedSPnode &bmspn, int lab=0) | |||||||
Initialised constructor. | |||||||
SpatialObjectRepresentationBV (const SpatialObjectRepresentationBV &other) | |||||||
Copy constructor. | |||||||
~SpatialObjectRepresentationBV () | |||||||
Destructor. | |||||||
SpatialObjectRepresentationBV & | operator= (SpatialObjectRepresentationBV rhs) | ||||||
Copy assignment operator. | |||||||
int | getLabel () const | ||||||
Get the label. | |||||||
void | setLabel (int lab) | ||||||
Set the label. | |||||||
const BooleanValueMappedSPnode | getCopySubPaving () const | ||||||
Get a copy of the subpaving managed by this. | |||||||
bool | hasSubPaving () const | ||||||
Get whether this has a subpaving to manage. | |||||||
cxsc::ivector | getRootBox () const | ||||||
Get the box of the subpaving managed by this. | |||||||
int | getDimensions () const | ||||||
get the dimensions of the subpaving this manages. | |||||||
cxsc::real | getDomainVolume () const | ||||||
get volume of the root box of the subpaving this manages. | |||||||
size_t | getRootLeaves () const | ||||||
Gets number of leaf nodes in the root paving. | |||||||
IntVec | getLeafLevels () const | ||||||
std::string | getLeafLevelsString () const | ||||||
bool | splitToShape (std::string instruction) | ||||||
Split this to a specified shape. | |||||||
void | allocateRanges (const std::vector< bool > &rangesToAllocate) | ||||||
Recursively allocate a collection of ranges to this and children. | |||||||
void | allocateRanges (const std::vector< BooleanMappedValue > &rangesToAllocate) | ||||||
Recursively allocate a collection of ranges to this and children. | |||||||
void | reshapeToUnion (const SpatialObjectRepresentationBV &other) | ||||||
Change this so that the subpaving it manages is the union of this's subpaving and the subpaving of another SpatialObjectRepresentationBV. | |||||||
SpatialObjectRepresentationBV | makeShapeToUnion (const SpatialObjectRepresentationBV &other) const | ||||||
Return a SpatialObjectRepresentationBV that has subpaving that is the union of this's subpaving and the subpaving of another SpatialObjectRepresentationBV. | |||||||
cxsc::real | getTotalVolume () const | ||||||
Get the total volume of the of the spatial object represented by this. | |||||||
SpatialObjectRepresentationBV & | operator+= (const SpatialObjectRepresentationBV &rhs) | ||||||
Union to self operator. | |||||||
const SpatialObjectRepresentationBV | operator+ (const SpatialObjectRepresentationBV &rhs) const | ||||||
Union operator. | |||||||
SpatialObjectRepresentationBV & | operator+= (bool val) | ||||||
Self-scalar OR operator. | |||||||
const SpatialObjectRepresentationBV | operator+ (bool val) const | ||||||
Scalar addition operator. | |||||||
SpatialObjectRepresentationBV & | operator-= (const SpatialObjectRepresentationBV &rhs) | ||||||
XOR (symmetric set difference) against self operator. | |||||||
const SpatialObjectRepresentationBV | operator- (const SpatialObjectRepresentationBV &rhs) const | ||||||
XOR (symmetric set difference) operator. | |||||||
SpatialObjectRepresentationBV & | operator-= (bool val) | ||||||
Self-scalar XOR (symmetric set difference) operator. | |||||||
const SpatialObjectRepresentationBV | operator- (bool val) const | ||||||
Scalar XOR (symmetric set difference) operator. | |||||||
SpatialObjectRepresentationBV & | operator*= (const SpatialObjectRepresentationBV &rhs) | ||||||
Intersection of self operator. | |||||||
const SpatialObjectRepresentationBV | operator* (const SpatialObjectRepresentationBV &rhs) const | ||||||
Intersection operator. | |||||||
SpatialObjectRepresentationBV & | operator*= (bool val) | ||||||
Self-scalar ANd operator. | |||||||
const SpatialObjectRepresentationBV | operator* (bool val) const | ||||||
Scalar AND operator. | |||||||
SpatialObjectRepresentationBV & | operator/= (const SpatialObjectRepresentationBV &rhs) | ||||||
Set difference against self operator. | |||||||
const SpatialObjectRepresentationBV | operator/ (const SpatialObjectRepresentationBV &rhs) const | ||||||
Set difference operator. | |||||||
SpatialObjectRepresentationBV & | operator/= (bool val) | ||||||
Self-scalar set difference operator. | |||||||
const SpatialObjectRepresentationBV | operator/ (bool val) const | ||||||
Scalar division operator. | |||||||
bool | pointwiseExtension (const rvector &pt) const | ||||||
Find the pointwise extension of the piecewise constant function for a given data point. | |||||||
std::ostream & | outputToStreamTabs (std::ostream &os, int prec=5) const | ||||||
Output the subpaving managed by this to a given stream. | |||||||
Get a slice of this. | |||||||
Make a slice this on at the point jointly specified by sliceDims and slicePts. For example, if this has a 3-dimensional root box [-1,1]x[-1,1]x[-1,1], ie dimensions {1,2,3} and sliceDims = {2,3} and slicePts is (0.0,0.5) then we are slicing at point 0.0 on dimension 2, point 0.5 on dimension 3. The slice returned would then have only one-dimensional boxes on dimensions {1,2,3}2,3} = {1}, each box being one that did contain point 0.0 on dimension 2, point 0.5 on dimension 3. The range will be unchanged). Any boxes associated with this that do not contain the point 0.0 on dimension 2 and 0.5 on dimension 3 will not be represented in the returned object.
| |||||||
const SpatialObjectRepresentationBV | makeSlice (const std::vector< int > &sliceDims, const std::vector< cxsc::real > &slicePts, const std::string sliceFilename="") const | ||||||
const SpatialObjectRepresentationBV | makeSlice (const std::vector< int > &sliceDims, const std::vector< double > &slicePts, const std::string sliceFilename="") const | ||||||
Output this representation of the object to a txt file. | |||||||
Output only includes pieces comprising the object (ie leaf nodes with value true in the subpaving managed by this) Format is a tab-delimited file of numeric data starting with nodeName, then the node box volume, then the node value (true), then the description of the node box as a tab-delimited list of interval upper and lower bounds.
| |||||||
void | outputToTxtTabs (const std::string &s, int prec=5) const | ||||||
void | outputToTxtTabs (const std::string &s, int prec, bool confirm) const | ||||||
Output details of whole representation (from root) to txt file. | |||||||
Format is a mixture of alpha and numeric data.
| |||||||
void | outputRootToTxt (const std::string &s, int prec=5) const | ||||||
void | outputRootToTxt (const std::string &s, int prec, bool confirm) const | ||||||
Output all nodes of the subpaving managed by this to | |||||||
Format is a tab-delimited data giving details of all nodes.
| |||||||
std::ostream & | outputRootToStreamTabs (std::ostream &os, int prec=5) const | ||||||
void | outputLog (const std::string &s, int i, int prec=5) const | ||||||
Append current state of estimator to a txt log file. | |||||||
std::string | stringSummary () const | ||||||
Get a string summary of this estimator's properties. | |||||||
void | swap (SpatialObjectRepresentationBV &pcf) |
A wrapper or manager for an BooleanValueMappedSPnode tree representing a spatial object.
No argument constructor.
: rootPaving(NULL), label(0) {}
SpatialObjectRepresentationBV::SpatialObjectRepresentationBV | ( | const ivector & | v, |
int | lab = 0 |
||
) | [explicit] |
Initialised constructor.
Initialised with domain box and label.
Constructor to be used if spatial object representation is to be subsequently formed by, for example, splitToShape and allocateRanges.
Throws a MalconstructedBox_Error if the box is not suitable as the basis of a subpaving (eg, box has no dimensions, or the box has a thin interval on at least one dimension).
v | The box to use for the subpaving to be managed. |
lab | The label for this (defaults to 0). |
: rootPaving(NULL), label(lab) { try { // check the box here if (!checkBox(v)) { throw subpavings::MalconstructedBox_Error( "SpatialObjectRepresentationBV::SpatialObjectRepresentationBV(const ivector&, int lab)"); } rootPaving = new BooleanValueMappedSPnode(v, false); } catch (exception const& e) { constructor_error_handler(); } }
SpatialObjectRepresentationBV::SpatialObjectRepresentationBV | ( | const BooleanValueMappedSPnode & | bmspn, |
int | lab = 0 |
||
) | [explicit] |
Initialised constructor.
Initialised with a subpaving.
spn | A subpaving to copy as the subpaving to be managed. |
lab | The label for this (defaults to 0). |
: rootPaving(NULL), label(lab) { try { // check spn has box if (bmspn.isEmpty()) { throw subpavings::NoBox_Error( "SpatialObjectRepresentationBV::SpatialObjectRepresentationBV(const BooleanValueMappedSPnode&, int lab)"); } rootPaving = new BooleanValueMappedSPnode(bmspn); } catch (exception const& e) { constructor_error_handler(); } }
void SpatialObjectRepresentationBV::allocateRanges | ( | const std::vector< bool > & | rangesToAllocate | ) |
Recursively allocate a collection of ranges to this and children.
Allocation order is this, left child with remainder of allocation, right child with remainder.
{ // checks: is there a root paving, is the string properly formed? if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::allocateRanges(...)"); } vector< BooleanMappedValue > tmp; for (size_t i = 0; i < rangesToAllocate.size(); ++i) tmp.push_back(BooleanMappedValue(rangesToAllocate[i])); BooleanValueMappedSPnode temp(*getSubPaving()); // copy to temp try { getSubPaving()->allocateRanges(tmp); } catch (std::invalid_argument const& ia) { cerr << ia.what() << endl; handleSPError(temp); } // any other exceptions are unhandled }
void SpatialObjectRepresentationBV::allocateRanges | ( | const std::vector< BooleanMappedValue > & | rangesToAllocate | ) |
Recursively allocate a collection of ranges to this and children.
Allocation order is this, left child with remainder of allocation, right child with remainder.
{ // checks: is there a root paving, is the string properly formed? if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::allocateRanges(...)"); } BooleanValueMappedSPnode temp(*getSubPaving()); // copy to temp try { getSubPaving()->allocateRanges(rangesToAllocate); } catch (std::invalid_argument const& ia) { cerr << ia.what() << endl; handleSPError(temp); } // any other exceptions are unhandled }
Get a copy of the subpaving managed by this.
{ if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::getCopySubpaving()"); } return BooleanValueMappedSPnode(*getSubPaving()); }
int SpatialObjectRepresentationBV::getDimensions | ( | ) | const |
get the dimensions of the subpaving this manages.
{ int retValue = 0; if (hasSubPaving()) { retValue = getSubPaving()->getDimension(); } return retValue; }
cxsc::real SpatialObjectRepresentationBV::getDomainVolume | ( | ) | const |
get volume of the root box of the subpaving this manages.
{ real retValue(0.0); if (hasSubPaving()) { retValue = getSubPaving()->nodeRealVolume(); } return retValue; }
int SpatialObjectRepresentationBV::getLabel | ( | ) | const |
Get the label.
{return label;}
Get a vector of the leaf node levels.
Root is level 0, next level down is 1, etc.
{ IntVec levels; // empty container if (hasSubPaving()) { getSubPaving()->getLeafNodeLevels(levels, 0); //levels has now been filled in } return levels; }
std::string SpatialObjectRepresentationBV::getLeafLevelsString | ( | ) | const |
Get a string of the leaf node levels.
Root is level 0, next level down is 1, etc. Example return string "3,3,2,1"
{ string retValue = ""; if (hasSubPaving()) retValue = getSubPaving()->getLeafNodeLevelsString(); return retValue; }
cxsc::ivector SpatialObjectRepresentationBV::getRootBox | ( | ) | const |
Get the box of the subpaving managed by this.
{ if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::getRootBox()"); } return getSubPaving()->getBox(); }
size_t SpatialObjectRepresentationBV::getRootLeaves | ( | ) | const |
Gets number of leaf nodes in the root paving.
{ size_t result = 0; if (hasSubPaving()) { result = getSubPaving()->getNumberLeaves(); } return result; }
cxsc::real SpatialObjectRepresentationBV::getTotalVolume | ( | ) | const |
Get the total volume of the of the spatial object represented by this.
The volume is calculated as the sum over all the leaves of the subpaving managed by this with value true of the leaf box volume.
{ if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::getTotalVolume()"); } return getSubPaving()->getTotalLeafTrueAreaOnBox(); }
bool SpatialObjectRepresentationBV::hasSubPaving | ( | ) | const |
Get whether this has a subpaving to manage.
{
return ( getSubPaving() != NULL );
}
SpatialObjectRepresentationBV SpatialObjectRepresentationBV::makeShapeToUnion | ( | const SpatialObjectRepresentationBV & | other | ) | const |
Return a SpatialObjectRepresentationBV that has subpaving that is the union of this's subpaving and the subpaving of another SpatialObjectRepresentationBV.
Throws a NullSubpavings_Error if the subpaving that this manages is a NULL pointer or if the subpaving managed by other is a NULL pointer.
Throws a NoBox_Error if the subpaving of this has no box or if the the subpaving of other has no box.
Throws an IncompatibleDimensions_Error if the subpaving boxes of this and other are not identical.
other | is the SpatialObjectRepresentationBV to make the union against. |
{ if ( !hasSubPaving() || !other.hasSubPaving() ) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::reshapeToUnion(const SpatialObjectRepresentationBV&)"); } SpatialObjectRepresentationBV tmp(*this); tmp.reshapeToUnion(other); return tmp; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator* | ( | const SpatialObjectRepresentationBV & | rhs | ) | const |
Intersection operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to intersect with this. |
{ SpatialObjectRepresentationBV result =(*this); result*= rhs; if ( label != rhs.getLabel() ) result.setLabel(0); return result; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator* | ( | bool | val | ) | const |
Scalar AND operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
mult | the value to AND with this. |
{ SpatialObjectRepresentationBV result =(*this); result*= val; return result; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator*= | ( | const SpatialObjectRepresentationBV & | rhs | ) |
Intersection of self operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to intersect with this. |
{ if( !hasSubPaving() || !(rhs.hasSubPaving()) ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator*= (const SpatialObjectRepresentationBV&)"); } getSubPaving()->operator*=( *(rhs.getSubPaving()) ); return *this; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator*= | ( | bool | val | ) |
Self-scalar ANd operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
mult | the value to AND with this. |
{ if( !hasSubPaving() ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator*= (bool)"); } getSubPaving()->operator*=( val ); return *this; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator+ | ( | const SpatialObjectRepresentationBV & | rhs | ) | const |
Union operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to add to this. |
{ SpatialObjectRepresentationBV result =(*this); result+= rhs; if ( label != rhs.getLabel() ) result.setLabel(0); return result; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator+ | ( | bool | val | ) | const |
Scalar addition operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to OR with this. |
{ SpatialObjectRepresentationBV result =(*this); result+= val; return result; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator+= | ( | const SpatialObjectRepresentationBV & | rhs | ) |
Union to self operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to add to this. |
{ if( !hasSubPaving() || !(rhs.hasSubPaving()) ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator+= (const SpatialObjectRepresentationBV&)"); } getSubPaving()->operator+=( *(rhs.getSubPaving()) ); return *this; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator+= | ( | bool | val | ) |
Self-scalar OR operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to OR with this. |
{ if( !hasSubPaving() ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator+= (bool)"); } getSubPaving()->operator+=( val ); return *this; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator- | ( | const SpatialObjectRepresentationBV & | rhs | ) | const |
XOR (symmetric set difference) operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to subtract from this. |
{ SpatialObjectRepresentationBV result =(*this); result-= rhs; if ( label != rhs.getLabel() ) result.setLabel(0); return result; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator- | ( | bool | val | ) | const |
Scalar XOR (symmetric set difference) operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to subtract from this. |
{ SpatialObjectRepresentationBV result =(*this); result-= val; return result; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator-= | ( | const SpatialObjectRepresentationBV & | rhs | ) |
XOR (symmetric set difference) against self operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to do XOR with this. |
{ if( !hasSubPaving() || !(rhs.hasSubPaving()) ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator-= (const SpatialObjectRepresentationBV&)"); } getSubPaving()->operator-=( *(rhs.getSubPaving()) ); return *this; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator-= | ( | bool | val | ) |
Self-scalar XOR (symmetric set difference) operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to use to do set difference against this. |
{ if( !hasSubPaving() ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator-= (bool)"); } getSubPaving()->operator-=( val ); return *this; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator/ | ( | const SpatialObjectRepresentationBV & | rhs | ) | const |
Set difference operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to set difference against this. |
{ SpatialObjectRepresentationBV result =(*this); result/= rhs; if ( label != rhs.getLabel() ) result.setLabel(0); return result; }
const SpatialObjectRepresentationBV SpatialObjectRepresentationBV::operator/ | ( | bool | val | ) | const |
Scalar division operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to set difference against this. |
{ SpatialObjectRepresentationBV result =(*this); result/= val; return result; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator/= | ( | const SpatialObjectRepresentationBV & | rhs | ) |
Set difference against self operator.
Throws a NullSubpavingPointer_Error if either this or rhs do not have a subpaving to manage.
Throws an IncompatibleDimensions_Error if the root boxes of this and rhs are not identical.
rhs | the object to do set difference against this. |
{ if( !hasSubPaving() || !(rhs.hasSubPaving()) ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator/= (const SpatialObjectRepresentationBV&)"); } getSubPaving()->operator/=( *(rhs.getSubPaving()) ); return *this; }
SpatialObjectRepresentationBV & SpatialObjectRepresentationBV::operator/= | ( | bool | val | ) |
Self-scalar set difference operator.
Throws a NullSubpavingPointer_Error if this does not have a subpaving to manage.
val | the value to set difference against this. |
{ if( !hasSubPaving() ) { throw subpavings::NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::operator/= (bool val)"); } getSubPaving()->operator/=( val ); return *this; }
void SpatialObjectRepresentationBV::outputLog | ( | const std::string & | s, |
int | i, | ||
int | prec = 5 |
||
) | const |
Append current state of estimator to a txt log file.
Format is a tab-delimited file of numeric data. Output includes node contributions to unscaled EMP under COPERR and AIC and the changes in EMP that would result from splitting the node.
s | the name of the txt file to send output to. |
i | the number of pass (ie, 0, 1, 2, 3 etc) in process. |
prec | the precision for output formatting. ie, number of decimal places. |
{ // To add output of the SpatialObjectRepresentationBV object to file ofstream os(s.c_str(), ios::app); // append if (os.is_open()) { os << std::endl; os << "Pass " << i << std::endl; // numbering getSubPaving()->leavesOutputTabs(os, prec); // the output os.close(); } else { std::cerr << "Error: could not open file named " << s << std::endl << std::endl; } }
std::ostream& subpavings::SpatialObjectRepresentationBV::outputToStreamTabs | ( | std::ostream & | os, |
int | prec = 5 |
||
) | const |
Output the subpaving managed by this to a given stream.
Format is a tab-delimited data giving details of leaf nodes.
os | is a reference to the stream to output the histogramm to. |
prec | the precision for output formatting. ie, number of decimal places. |
bool SpatialObjectRepresentationBV::pointwiseExtension | ( | const rvector & | pt | ) | const |
Find the pointwise extension of the piecewise constant function for a given data point.
The pointwise extension is the value associated with the leaf node of the subpaving managed by this that has the box containing pt.
If the point is not in the rootbox of the subpaving managed by this at all, the pointwise extension is false; Throws a IncompatibleDimensions_Error if the dimensions of this and pt are not equal.
pt | the point to find pointwise extension for. |
{ if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::pointwiseExtension(const rvector&)"); } if (getDimensions() != (Ub(pt) - Lb(pt) + 1)) { throw IncompatibleDimensions_Error( "SpatialObjectRepresentationBV::pointwiseExtension(const rvector&)"); } bool result = false; const BooleanValueMappedSPnode * container = getSubPaving()->findContainingNode(pt); if (container != NULL) { result = container->getRange(); } return result; }
void SpatialObjectRepresentationBV::reshapeToUnion | ( | const SpatialObjectRepresentationBV & | other | ) |
Change this so that the subpaving it manages is the union of this's subpaving and the subpaving of another SpatialObjectRepresentationBV.
Throws a NullSubpavings_Error if the subpaving that this manages is a NULL pointer or if the subpaving managed by other is a NULL pointer.
Throws a NoBox_Error if the subpaving of this has no box or if the subpaving of other has no box.
Throws an IncompatibleDimensions_Error if the subpaving boxes of this and other are not identical.
There will be no change in this if the subpaving of is everywhere less split than the subpaving of this.
other | is the SpatialObjectRepresentationBV to make the union against. |
{ if ( !hasSubPaving() || !other.hasSubPaving() ) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::reshapeToUnion(const SpatialObjectRepresentationBV&)"); } getSubPaving()->reshapeToUnion(*other.getSubPaving()); }
bool SpatialObjectRepresentationBV::splitToShape | ( | std::string | instruction | ) |
Split this to a specified shape.
Throws a NullSubpavings_Error if the subpaving that this manages is a NULL pointer.
Throws a NoBox_Error if the subpaving box is empty.
Prints a message to the standard error output if the instruction could not be carried out.
instruction | specifies the required shape, eg "3, 3, 2, 1" |
{ // checks: is there a root paving, is the string properly formed? if (!hasSubPaving()) { throw NullSubpavingPointer_Error( "SpatialObjectRepresentationBV::splitToShape()"); } bool success = false; BooleanValueMappedSPnode temp(*getSubPaving()); // copy to temp try { if (instruction.length() == 0) { throw std::invalid_argument( "SpatialObjectRepresentationBV::splitToShape() : No instruction"); } std::string legal(", 0123456789"); if (instruction.find_first_not_of(legal) != std::string::npos) { throw std::invalid_argument( "SpatialObjectRepresentationBV::splitToShape() : Illegal character"); } // all seems to be okay, we can start splitting the root paving success = getSubPaving()->splitRootToShape(instruction); if (!success) { handleSPError(temp); } } catch (std::invalid_argument const& ia) { cerr << ia.what() << endl; handleSPError(temp); success = false; } catch (std::logic_error const& le) { cerr << le.what() << endl; handleSPError(temp); success = false; } return success; // any other exceptions are unhandled }
std::string SpatialObjectRepresentationBV::stringSummary | ( | ) | const |
Get a string summary of this estimator's properties.
A string description of this. Includes the address of the subpaving managed but not details of that subpaving.
{ std::ostringstream oss; oss << "This address = " << (this) << endl; oss << "This label = " << label << endl; if (hasSubPaving()) oss << "Address of subpaving is " << getSubPaving() << endl; else oss << "Subpaving is NULL" << endl; return oss.str(); }