![]() |
MineLink
|
Abstracts a set of blocks (subset of a blockmodel). More...
#include <blocksel.h>
Public Member Functions | |
BlockSelection (delphos::BlockModel &bm) | |
Creates an empty BlockSelection instance. More... | |
BlockSelection (delphos::BlockModel &bm, const string &column) | |
Creates a BlockSelection instance consisting of blocks such that a certain block value (specified by column) is different from zero. More... | |
BlockSelection (delphos::BlockSelection &bs) | |
Creates a copy of another BlockSelection instance. More... | |
delphos::BlockSelection & | operator= (const delphos::BlockSelection &bs) |
Operator = used to assign to another varible (symbol) a given BlockSelection instance. | |
delphos::BlockSelection * | Intersect (const delphos::BlockSelection &bs) |
Creates the intersection of block selections. More... | |
delphos::BlockSelection * | Complement () |
Creates the complement (set theory) of the current BlockSelection instance. More... | |
bool | Union (const delphos::BlockSelection &bs) |
Union (set theory) between the current instance and a given BlockSelection instance. More... | |
virtual | ~BlockSelection () |
Destroys the block selection. | |
void | ClearSelection () |
Clears the block selection. More... | |
bool | Contains (const delphos::BlockIndexType &index) const |
Checks whether areferenced block belongs to the selection or not. More... | |
bool | Contains (const delphos::Coordinates &coords) const |
Checks whether a block with given coordinates in the selection or not. More... | |
bool | Contains (const double &x, const double &y, const double &z) const |
Checks whether a block with the given coordinates belongs to the selection or not. More... | |
bool | AddBlock (const delphos::BlockIndexType &index) |
Adds a new block (referenced by an index) to the current selection. More... | |
bool | AddBlock (const delphos::Coordinates &coords) |
Adds the block of given coordinates to the selection. More... | |
bool | AddBlock (const double &x, const double &y, const double &z) |
Adds the block of given coordinates to the selection. More... | |
delphos::BlockIndexType | GetIndex (const delphos::BlockIndexType &index) const |
Gets the index in the subyacent BlockModel instance of the block with given index in the current selection. More... | |
delphos::BlockIndexType | GetIndexInBS (const delphos::BlockIndexType &index) const |
Gets the index in the current BlockSelection instance of the the block of given index in the subyacent BlockModel instance. More... | |
delphos::Block | GetBlock (const delphos::BlockIndexType &index) |
Gets the Block instance corresponding to the block of given index in the selection. More... | |
delphos::BlockIndexType | Size () const |
Returns the number of blocks in the selection. More... | |
delphos::BlockIndexType | GetSize () const |
Returns the number of blocks in the selection. More... | |
void | StoreAsAttribute (const string &new_attr) |
Saves the current selection as a new column of the subyacent BlockModel instance. More... | |
bool | RemoveBlock (const delphos::BlockIndexType &index) |
Removes a block from the current selection. More... | |
![]() | |
BlockModelEntity (delphos::BlockModel &bm) | |
Creates a new block instance associated to a given block model. More... | |
delphos::BlockModel & | GetBlockModel () |
Retrieves the block model to which the entity is associated. More... | |
const delphos::BlockModel & | GetBlockModel () const |
Retrieves the block model to which the entity is associated. More... | |
Abstracts a set of blocks (subset of a blockmodel).
A selection can be efficiently queried in order to check if a given block belongs to the selection or not.
Blocks in the selection are also indexed with integers starting from 0. These indexes do not correspond, then, to the indexes in the original full block model.
BlockSelection provides methods to retrieve the original index (in the full block model) and the blocks themselves.
A BlockSelection instance is always binded to a BlockModel instance (the instance from wich the blocks will be selected): the subyacent BlockModel instance.
delphos::BlockSelection::BlockSelection | ( | delphos::BlockModel & | bm | ) |
Creates an empty BlockSelection instance.
bm | The BlockModel instance to considered as the subyacent model. |
delphos::BlockSelection::BlockSelection | ( | delphos::BlockModel & | bm, |
const string & | column | ||
) |
Creates a BlockSelection instance consisting of blocks such that a certain block value (specified by column) is different from zero.
bm | The BlockModel instance to considered as the subyacent model. |
column | The name of the attribute from wich the selection will be generated. |
delphos::BlockSelection::BlockSelection | ( | delphos::BlockSelection & | bs | ) |
Creates a copy of another BlockSelection instance.
bs | The BlockSelection instance to be copied. |
bool delphos::BlockSelection::AddBlock | ( | const delphos::BlockIndexType & | index | ) |
Adds a new block (referenced by an index) to the current selection.
index | The index of the block to be added. |
The index of the block being added must be the one on the subyacent BlockModel instance. The range for the given index must go from 0 to BlockModel::GetSize()-1.
bool delphos::BlockSelection::AddBlock | ( | const delphos::Coordinates & | coords | ) |
Adds the block of given coordinates to the selection.
coords | The Coordinates instance associated to the block to be added. |
The given coordinates are matched against the ones on the subyacet BlockModel instance.
bool delphos::BlockSelection::AddBlock | ( | const double & | x, |
const double & | y, | ||
const double & | z | ||
) |
Adds the block of given coordinates to the selection.
x | The \(x\) coordinate value of the block to be added. |
y | The \(y\) coordinate value of the block to be added. |
z | The \(z\) coordinate value of the block to be added. |
The given coordinates are matched against the ones on the subyacet BlockModel instance.
void delphos::BlockSelection::ClearSelection | ( | ) |
Clears the block selection.
This method empties the current selection but the subyacent BlockModel instance es preserved.
BlockSelection * delphos::BlockSelection::Complement | ( | ) |
Creates the complement (set theory) of the current BlockSelection instance.
The universe (set theory) to be considered is always the subyacent BlockModel instance of the current BlockSelection instance. This is, the output is comprised by all the blocks present in the subyacent BlockModel instance that are not present in the original BlockSelection instance.
bool delphos::BlockSelection::Contains | ( | const delphos::BlockIndexType & | index | ) | const |
Checks whether areferenced block belongs to the selection or not.
index | The index (in the subyacent BlockModel instance) of the block being queried. |
The index of the block being queried must be the the one on the subyacent BlockModel instance.
bool delphos::BlockSelection::Contains | ( | const delphos::Coordinates & | coords | ) | const |
Checks whether a block with given coordinates in the selection or not.
coords | The coordinates of the block being queried. |
The given coordinates are matched against the coordinates stored in the subyacent BlockModel instace.
bool delphos::BlockSelection::Contains | ( | const double & | x, |
const double & | y, | ||
const double & | z | ||
) | const |
Checks whether a block with the given coordinates belongs to the selection or not.
x | The \(x\) coordinate of the block being queried. |
y | The \(y\) coordinate of the block being queried. |
z | The \(z\) coordinate of the block being queried. |
The submitted coordinates are mathched against the coordinates stored in the subyacent BlockModel instace.
Block delphos::BlockSelection::GetBlock | ( | const delphos::BlockIndexType & | index | ) |
Gets the Block instance corresponding to the block of given index in the selection.
index | The index of the block in the current selection instance. |
In this case, index goes from 0 to BlockSelection::GetSize()-1. If the given index is greater than BlockSelection::GetSize()-1, an exception is thrown.
This is a shortcut for
this->GetBlockModel().GetBlock(this->GetIndex(index))
BlockIndexType delphos::BlockSelection::GetIndex | ( | const delphos::BlockIndexType & | index | ) | const |
Gets the index in the subyacent BlockModel instance of the block with given index in the current selection.
index | The index of the block in the current selection. |
The return value corresponds to the "original" index of the block (in the subyacent BlockModel instance).
In this case, the given index goes from 0 to BlockSelection::GetSize()-1, if the given index is greater than BlockSelection::GetSize()-1 then BlockModel::NO_INDEX is returned.
BlockIndexType delphos::BlockSelection::GetIndexInBS | ( | const delphos::BlockIndexType & | index | ) | const |
Gets the index in the current BlockSelection instance of the the block of given index in the subyacent BlockModel instance.
index | The index of the block in the subyacent BlockModel instance. |
The return value corresponds to the index of the block in the current BlockSelection instance.
If the given index goes from 0 to BlockModel::GetSize()-1, if the given index is greater than BlockModel::GetSize()-1 then BlockModel::NO_INDEX is returned.
BlockIndexType delphos::BlockSelection::GetSize | ( | ) | const |
Returns the number of blocks in the selection.
BlockSelection * delphos::BlockSelection::Intersect | ( | const delphos::BlockSelection & | bs | ) |
Creates the intersection of block selections.
bs | The BlockSelection instance to be intersected. |
If no blocks are in both instances, then an empty BloskSelection instance is returned.
bool delphos::BlockSelection::RemoveBlock | ( | const delphos::BlockIndexType & | index | ) |
Removes a block from the current selection.
index | The index of the block (in the subyacent BlockModel instance) to be removed of the current selection. |
BlockIndexType delphos::BlockSelection::Size | ( | ) | const |
Returns the number of blocks in the selection.
void delphos::BlockSelection::StoreAsAttribute | ( | const string & | new_attr | ) |
Saves the current selection as a new column of the subyacent BlockModel instance.
new_attr | The name of the new column. |
The new column in the model contains 0-1 values depending if the block is in the block selection or not, respectively.
bool delphos::BlockSelection::Union | ( | const delphos::BlockSelection & | bs | ) |
Union (set theory) between the current instance and a given BlockSelection instance.
The current BlockSelection instance is augmented with all the blocks in the given BlockSelection instance.