MineLink
 All Data Structures Functions Variables Pages
delphos::BlockSelection Class Reference

Abstracts a set of blocks (subset of a blockmodel). More...

#include <blocksel.h>

Inheritance diagram for delphos::BlockSelection:
Inheritance graph
Collaboration diagram for delphos::BlockSelection:
Collaboration graph

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::BlockSelectionoperator= (const delphos::BlockSelection &bs)
 Operator = used to assign to another varible (symbol) a given BlockSelection instance.
 
delphos::BlockSelectionIntersect (const delphos::BlockSelection &bs)
 Creates the intersection of block selections. More...
 
delphos::BlockSelectionComplement ()
 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...
 
- Public Member Functions inherited from delphos::BlockModelEntity
 BlockModelEntity (delphos::BlockModel &bm)
 Creates a new block instance associated to a given block model. More...
 
delphos::BlockModelGetBlockModel ()
 Retrieves the block model to which the entity is associated. More...
 
const delphos::BlockModelGetBlockModel () const
 Retrieves the block model to which the entity is associated. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

delphos::BlockSelection::BlockSelection ( delphos::BlockModel bm)

Creates an empty BlockSelection instance.

Parameters
bmThe 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.

Parameters
bmThe BlockModel instance to considered as the subyacent model.
columnThe name of the attribute from wich the selection will be generated.
delphos::BlockSelection::BlockSelection ( delphos::BlockSelection bs)

Creates a copy of another BlockSelection instance.

Parameters
bsThe BlockSelection instance to be copied.

Member Function Documentation

bool delphos::BlockSelection::AddBlock ( const delphos::BlockIndexType &  index)

Adds a new block (referenced by an index) to the current selection.

Parameters
indexThe index of the block to be added.
Returns
True on success. False otherwise.

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.

Parameters
coordsThe Coordinates instance associated to the block to be added.
Returns
True on success. False otherwise.

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.

Parameters
xThe \(x\) coordinate value of the block to be added.
yThe \(y\) coordinate value of the block to be added.
zThe \(z\) coordinate value of the block to be added.
Returns
True on success. False otherwise.

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.

Returns
A pointer to a new BlockSelection instance that represent the complement of the original BlockSelection.

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.

Parameters
indexThe index (in the subyacent BlockModel instance) of the block being queried.
Returns
True if the referenced block belongs to the current selection. False otherwise.

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.

Parameters
coordsThe coordinates of the block being queried.
Returns
True if such block belongs to the current selection. False otherwise.

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.

Parameters
xThe \(x\) coordinate of the block being queried.
yThe \(y\) coordinate of the block being queried.
zThe \(z\) coordinate of the block being queried.
Returns
True if such block belongs to the current selection. False otherwise.

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.

Parameters
indexThe index of the block in the current selection instance.
Returns
A Block instance of the block in the current selection instance referenced by the given index.

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.

Parameters
indexThe index of the block in the current selection.
Returns
True on success. False otherwise.

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.

Parameters
indexThe index of the block in the subyacent BlockModel instance.
Returns
The index of the block on the current BlockSelection 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.

Returns
The current amount of blocks in the selection instance.
BlockSelection * delphos::BlockSelection::Intersect ( const delphos::BlockSelection bs)

Creates the intersection of block selections.

Parameters
bsThe BlockSelection instance to be intersected.
Returns
A pointer to a new BlockSelection instance comprised by all the blocks present in both, the current BlockSelection instance and the given one.

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.

Parameters
indexThe index of the block (in the subyacent BlockModel instance) to be removed of the current selection.
Returns
True if the referenced block is found in the selection and removed from it. False otherwise.
BlockIndexType delphos::BlockSelection::Size ( ) const

Returns the number of blocks in the selection.

Deprecated:
See BlockSelection::GetSize() .
Returns
The current amount of blocks in the selection instance.
void delphos::BlockSelection::StoreAsAttribute ( const string &  new_attr)

Saves the current selection as a new column of the subyacent BlockModel instance.

Parameters
new_attrThe 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.

Returns
True on success. False otherwise.

The current BlockSelection instance is augmented with all the blocks in the given BlockSelection instance.


The documentation for this class was generated from the following files: