MRS  1.0
A C++ Class Library for Statistical Set Processing
subpavings::SpatialObjectRepresentationBV Class Reference

A wrapper or manager for an BooleanValueMappedSPnode tree representing a spatial object. More...

List of all members.

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.
SpatialObjectRepresentationBVoperator= (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.
SpatialObjectRepresentationBVoperator+= (const SpatialObjectRepresentationBV &rhs)
 Union to self operator.
const SpatialObjectRepresentationBV operator+ (const SpatialObjectRepresentationBV &rhs) const
 Union operator.
SpatialObjectRepresentationBVoperator+= (bool val)
 Self-scalar OR operator.
const SpatialObjectRepresentationBV operator+ (bool val) const
 Scalar addition operator.
SpatialObjectRepresentationBVoperator-= (const SpatialObjectRepresentationBV &rhs)
 XOR (symmetric set difference) against self operator.
const SpatialObjectRepresentationBV operator- (const SpatialObjectRepresentationBV &rhs) const
 XOR (symmetric set difference) operator.
SpatialObjectRepresentationBVoperator-= (bool val)
 Self-scalar XOR (symmetric set difference) operator.
const SpatialObjectRepresentationBV operator- (bool val) const
 Scalar XOR (symmetric set difference) operator.
SpatialObjectRepresentationBVoperator*= (const SpatialObjectRepresentationBV &rhs)
 Intersection of self operator.
const SpatialObjectRepresentationBV operator* (const SpatialObjectRepresentationBV &rhs) const
 Intersection operator.
SpatialObjectRepresentationBVoperator*= (bool val)
 Self-scalar ANd operator.
const SpatialObjectRepresentationBV operator* (bool val) const
 Scalar AND operator.
SpatialObjectRepresentationBVoperator/= (const SpatialObjectRepresentationBV &rhs)
 Set difference against self operator.
const SpatialObjectRepresentationBV operator/ (const SpatialObjectRepresentationBV &rhs) const
 Set difference operator.
SpatialObjectRepresentationBVoperator/= (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.
Note:
The sliceDims are given as 1, 2, 3, etc, ie are numbered from 1 upwards not from 0 upwards<>.

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.

Parameters:
sliceDimsis a vector of dimensions to slice on, indexed from 1 onwards.
slicePtsis a vector of points to slice on, assumed to correspond to the dimensions in sliceDims, ie the ith value in sliceDims gives the dimension for the ith point in slicePts.
sliceFilenameis the name of file to use to capture the boxes of this that are used in the slice by outputting them to the file named sliceFilename. Defaults to the empty string "". If sliceFilename is the empty string "" no boxes will be captured to file.
Returns:
The slice of this on the specified dimensions and points.
Precondition:
This must have a subpaving to manage.
sliceDims must contain only valid dimensions, ie dimensions in this, with minimum dimension 1.

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.

Parameters:
sthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
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.

Parameters:
sthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
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

a given stream.

Format is a tab-delimited data giving details of all nodes.

Parameters:
osis a reference to the stream to output to.
precthe precision for output formatting. ie, number of decimal places, defaulting to 5.
Returns:
a reference to the given stream.
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)

Detailed Description

A wrapper or manager for an BooleanValueMappedSPnode tree representing a spatial object.


Constructor & Destructor Documentation

No argument constructor.

Postcondition:
This has no subpaving and label 0.
         : 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).

Parameters:
vThe box to use for the subpaving to be managed.
labThe label for this (defaults to 0).
Postcondition:
This has subpaving that consists of single leaf node (the root) with a box like v) and the range on that single node is false.
         : 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();
    }
}

Initialised constructor.

Initialised with a subpaving.

Parameters:
spnA subpaving to copy as the subpaving to be managed.
labThe label for this (defaults to 0).
Precondition:
bmspn has a box.
Postcondition:
The spatial object representation constructed has label lab, and a subpaving that is a copy of bmspn.
         : 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();
    }
}

Member Function Documentation

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.

Returns:
a copy of the subpaving managed by this.
Precondition:
hasSubPaving() == true.
{
  if (!hasSubPaving()) {
    throw NullSubpavingPointer_Error(
          "SpatialObjectRepresentationBV::getCopySubpaving()");
  }
  return BooleanValueMappedSPnode(*getSubPaving());
}

get the dimensions of the subpaving this manages.

Returns:
0 if this does not have a subpaving, else returns the dimensions of the subpaving.
{
  int retValue = 0;
  if (hasSubPaving()) {
    retValue = getSubPaving()->getDimension();
  }
  return retValue;
}

get volume of the root box of the subpaving this manages.

Returns:
volume of the root box of the subpaving this manages, or 0.0 if this has no subpaving.
{
  real retValue(0.0);
  if (hasSubPaving()) {
    retValue = getSubPaving()->nodeRealVolume();
  }
  return retValue;
}

Get the label.

Returns:
the label for this.
{return label;}

Get a vector of the leaf node levels.

Root is level 0, next level down is 1, etc.

Returns:
a vector of leaf levels, left to right order,
{
    IntVec levels; // empty container

    if (hasSubPaving()) {
        getSubPaving()->getLeafNodeLevels(levels, 0);
        //levels has now been filled in
    }
    return levels;
}

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"

Returns:
a comma separated string of leaf levels, left to right order
{
    string retValue = "";
    if (hasSubPaving())
        retValue = getSubPaving()->getLeafNodeLevelsString();

    return retValue;
}

Get the box of the subpaving managed by this.

Note:
with the present constructors, it is impossible for this to have a subpaving but for the subpaving to have no box.
Returns:
copy of the box of the subpaving managed by this.
Precondition:
hasSubPaving() == true.
{
  if (!hasSubPaving()) {
    throw NullSubpavingPointer_Error(
          "SpatialObjectRepresentationBV::getRootBox()");
  }
  return getSubPaving()->getBox();
}

Gets number of leaf nodes in the root paving.

Returns:
the total number of leaves in the subpaving managed by this. Returns 0 if this has no subpaving to manage.
{
  size_t result = 0;
  if (hasSubPaving()) {
    result = getSubPaving()->getNumberLeaves();
  }
  return result;
}

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.

Returns:
total volume of the spatial object represented by this.
Precondition:
This must have a subpaving to manage.
{
  if (!hasSubPaving()) {
    throw NullSubpavingPointer_Error(
    "SpatialObjectRepresentationBV::getTotalVolume()");
  }
  return getSubPaving()->getTotalLeafTrueAreaOnBox();
}

Get whether this has a subpaving to manage.

Note:
with the present constructors, it is impossible for this to have a subpaving but for the subpaving to have no box.
Returns:
true if this has a subpaving to manage. false otherwise.
{
    return ( getSubPaving() != NULL );
}

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.

Parameters:
otheris the SpatialObjectRepresentationBV to make the union against.
Returns:
A SpatialObjectRepresentationBV that has a subpaving that is the union of the shape of the subpaving managed by this and the shape of the subpaving managed by other. this and other are unchanged.
Precondition:
Both this and other have subpavings with boxes to manage.
The boxes of the subpavings of this and other are the same.
{
  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.

Note:
Note that if this and rhs have the same label the result of the operation will have that label, but if this and rhs do not have the same label, the result will get the default label (0).
Parameters:
rhsthe object to intersect with this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of that subpaving is the result of ANDing the values on the equivalent nodes of this with the values on the equivalent nodes of rhs. If the labels of this and rhs are the same, the returned object will have the same label as this; otherwise the returned object's label will be the default label (0).
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
{
  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.

Parameters:
multthe value to AND with this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that the same as the subpaving managed by this and the value on each node of that subpaving is the result of ANDing the values on the equivalent nodes of this with val. The label of this is unchanged.
Precondition:
This has a subpaving to manage.
{
  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.

Parameters:
rhsthe object to intersect with this.
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
Postcondition:
this manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of the subpaving is the result of ANDing the values on the equivalent nodes of this with the values on the equivalent nodes of rhs before the operation. The label of this is unchanged.
{
  
  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.

Parameters:
multthe value to AND with this.
Precondition:
This has a subpaving to manage.
Postcondition:
this manages a subpaving that is the same as the subpaving managed by this before the operation and the value on each node of the subpaving is the result of ANDing the values on the equivalent nodes of this with val. The label of this is unchanged.
{
  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.

Note:
Note that if this and rhs have the same label the result of the operation will have that label, but if this and rhs do not have the same label, the result will get the default label (0).
Parameters:
rhsthe object to add to this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of that subpaving is the result of ORing the values on the equivalent nodes of this and rhs. If the labels of this and rhs are the same, the returned object will have the same label as this; otherwise the returned object's label will be the default label (0).
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
{
  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.

Parameters:
valthe value to OR with this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that the same as the subpaving managed by this and the value on each node of that subpaving is the result of ORing val with the values on the equivalent nodes of this. The label of this is unchanged.
Precondition:
This has a subpaving to manage.
{
  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.

Parameters:
rhsthe object to add to this.
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
Postcondition:
this manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of the subpaving is the result of ORing the values on the equivalent nodes of this before the operation and rhs. The label of this is unchanged.
{
  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.

Parameters:
valthe value to OR with this.
Precondition:
This has a subpaving to manage.
Postcondition:
this manages a subpaving that is the same as the subpaving managed by this before the operation and the value on each node of the subpaving is the result of ORing val with the values on the equivalent nodes of this. The label of this is unchanged.
{
  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.

Note:
Note that if this and rhs have the same label the result of the operation will have that label, but if this and rhs do not have the same label, the result will get the default label (0).
Parameters:
rhsthe object to subtract from this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of that subpaving is the result of doing XOR of the values on the equivalent nodes of rhs against the values on the equivalent nodes of this. If the labels of this and rhs are the same, the returned object will have the same label as this; otherwise the returned object's label will be the default label (0).
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
{
  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.

Parameters:
valthe value to subtract from this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that is the same as the subpaving managed by this and the value on each node of that subpaving is the result of doing XOR of val against the values on the equivalent nodes of this. The label of this is unchanged.
Precondition:
This has a subpaving to manage.
{
  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.

Parameters:
rhsthe object to do XOR with this.
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
Postcondition:
this manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of the subpaving is the result of doing XOR of the values on the equivalent nodes of rhs against values on the equivalent nodes of this before the operation. The label of this is unchanged.
{
  
  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.

Parameters:
valthe value to use to do set difference against this.
Precondition:
This has a subpaving to manage.
Postcondition:
this manages a subpaving that is the same as the subpaving managed by this before the operation and the value on each node of the subpaving is the result of doing the XOR of val against the values on the equivalent nodes of this. The label of this is unchanged.
{
  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.

Note:
Note that if this and rhs have the same label the result of the operation will have that label, but if this and rhs do not have the same label, the result will get the default label (0).
Parameters:
rhsthe object to set difference against this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of that subpaving is the result of set differencing the values on the equivalent nodes of this with the values on the equivalent nodes of rhs. If the labels of this and rhs are the same, the returned object will have the same label as this; otherwise the returned object's label will be the default label (0).
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
{
  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.

Parameters:
valthe value to set difference against this.
Returns:
A SpatialObjectRepresentationBV that manages a subpaving that the same as the subpaving managed by this and the value on each node of that subpaving is the result of set differencing the values on the equivalent nodes of this with val. The label of this is unchanged.
Precondition:
This has a subpaving to manage.
{
  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.

Parameters:
rhsthe object to do set difference against this.
Precondition:
Both this and rhs have subpavings to manage.
This and rhs have identical root boxes.
Postcondition:
this manages a subpaving that is the non-minimal union of the subpavings managed by this and rhs and the value on each node of the subpaving is the result of set differencing the values on the equivalent nodes of this with the values on the equivalent nodes of rhs before the operation. The label of this is unchanged.
{
  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.

Parameters:
valthe value to set difference against this.
Precondition:
This has a subpaving to manage.
Postcondition:
this manages a subpaving that is the same as the subpaving managed by this before the operation and the value on each node of the subpaving is the result of set differencing the values on the equivalent nodes of this with val. The label of this is unchanged.
{
  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.

Parameters:
sthe name of the txt file to send output to.
ithe number of pass (ie, 0, 1, 2, 3 etc) in process.
precthe 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.

Parameters:
osis a reference to the stream to output the histogramm to.
precthe precision for output formatting. ie, number of decimal places.
Returns:
a reference to the given stream.
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.

Parameters:
ptthe point to find pointwise extension for.
Returns:
the value at the point.
Precondition:
This must have a subpaving to manage.
Dimensions of pt and this must match.
{
  
  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;
}

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.

Parameters:
otheris the SpatialObjectRepresentationBV to make the union against.
Precondition:
Both this and other have subpavings with boxes to manage.
The boxes of the subpavings of this and other are the same.
Postcondition:
the subpaving managed by this has the shape that is the union of its shape before the operation and the shape of the subpaving managed by other. other is unchanged.
{
  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.

Note:
that ranges for each node in the revised shape will have to be set explicitly, using allocateRanges().

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.

Parameters:
instructionspecifies the required shape, eg "3, 3, 2, 1"
Returns:
true if the split was successful, false otherwise
Precondition:
hasSubPaving() == true.
Postcondition:
this has subpaving with shape specified by instruction and the function value mapped to each node in the subpaving is the same as the value mapped to the root box before the operation.
{
  
  // 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
}

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.

Returns:
the string summary.
{
  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();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends