MineLink
 All Data Structures Functions Variables Pages
blocksel.h
1 #ifndef __BLOCKSEL_H__
2 #define __BLOCKSEL_H__
3 
4 #include <set>
5 #include <vector>
6 #include "blockmodel.h"
7 #include <iostream>
8 
9 using namespace std;
10 //using std::set;
11 //using std::vector;
12 
13 namespace delphos{
14 
15 
34 private:
35  set<BlockIndexType> * _blocks;
36  vector<BlockIndexType> * _block_indexes;
37  bool _is_ordered;
38 
39  void init();
40  void Fast_AddBlock(const delphos::BlockIndexType & index);
41 
42 public:
50  #ifndef DOXYGEN
52  #endif
53 
61  BlockSelection(delphos::BlockModel & bm, const string & column);
62 
69  #ifndef DOXYGEN
71  #endif
72 
88 
89  #ifndef DOXYGEN
90 
102  BlockSelection* IntersectOrdered(const delphos::BlockSelection& bs);
103  #endif
104 
114  delphos::BlockSelection* Complement() ;
115 
116  #ifndef DOXYGEN
117 
128  BlockSelection* ComplementOrdered();
129  #endif
130 
138  bool Union(const delphos::BlockSelection& bs) ;
139 
140  #ifndef DOXYGEN
141 
150  bool UnionOrdered(const BlockSelection& bs) ;
151  #endif
152 
156  virtual ~BlockSelection();
157 
163  void ClearSelection();
164 
174  bool Contains(const delphos::BlockIndexType & index) const;
175 
185  bool Contains(const delphos::Coordinates & coords) const;
186 
198  bool Contains(const double & x, const double & y, const double & z) const;
199 
200  //bool ContainsIndex(const unsigned long & index) const;
201 
212  bool AddBlock(const delphos::BlockIndexType & index);
213 
223  bool AddBlock(const delphos::Coordinates & coords);
224 
236  bool AddBlock(const double & x, const double & y, const double & z);
237 
251  delphos::BlockIndexType GetIndex(const delphos::BlockIndexType & index) const;
252 
266  delphos::BlockIndexType GetIndexInBS(const delphos::BlockIndexType & index) const;
267 
283  delphos::Block GetBlock(const delphos::BlockIndexType & index);
284 
292  delphos::BlockIndexType Size() const;
293 
299  delphos::BlockIndexType GetSize() const;
300 
309  void StoreAsAttribute(const string & new_attr);
310 
311  #ifndef DOXYGEN
312 
319  delphos::BlockModel* ToBlockModel();
320 
332  delphos::BlockModel* ToBlockModel(const string& column);
333  #endif
334 
343  bool RemoveBlock(const delphos::BlockIndexType& index );
344 };
345 
346 
351 public:
359  virtual double Eval(const delphos::BlockSelection & bsel) const = 0;
363  virtual ~SelectionFunctor(){}
364 };
365 
366 
371 private:
372  const string _column;
373 public:
379  SelectionSum(const string & column_to_add);
383  virtual const string& ColumnToAdd() const;
393  virtual double Eval(const delphos::BlockSelection & bsel) const;
394 };
395 
399 class SelectionAvg : public SelectionSum {
400 private:
401  const string* _weight;
402 public:
406  static string NO_WEIGHT_COLUMN;
412  SelectionAvg(const string & column_to_add);
419  SelectionAvg(const string & column_to_add, const string& weight);
423  virtual ~SelectionAvg();
428  const string& WeightColumn() const;
438  virtual double Eval(const delphos::BlockSelection & bsel) const;
439 };
440 
441 
446 private:
447  const string _column;
448 public:
454  SelectionMin(const string & column_to_minimize);
460  const string ColumnToMinimize() const;
461 
469  virtual double Eval(const delphos::BlockSelection & bsel) const;
470 };
471 
472 
477 private:
478  const string _column;
479 public:
485  SelectionMax(const string & column_to_maximize);
491  const string ColumnToMaximize() const;
499  virtual double Eval(const delphos::BlockSelection & bsel) const;
500 };
501 
506 private:
507  const string _column;
508 public:
514  SelectionMajor(const string & column_to_majorize);
518  const string ColumnToMajorize() const;
530  virtual double Eval(const delphos::BlockSelection & bsel) const;
531 };
532 
533 }
534 #endif
535 
Abstracts a sum function to be evaluated over a set of blocks.
Definition: blocksel.h:370
Abstracts a set of blocks (subset of a blockmodel).
Definition: blocksel.h:33
Abstracts a function to perform statistical mode.
Definition: blocksel.h:505
An utility class to abstract coordinates so they can be used as map and set keys by means of string c...
Definition: coords.h:20
Abstract class that defines the basis for classes that abstracts functions to perform selections...
Definition: blocksel.h:350
A utility class to access blocks individually.
Definition: blockmodel.h:1390
Abstracts the maximum function to be evaluated over a set of blocks.
Definition: blocksel.h:476
Abstracts a container of blocks as a table with arbitrary number of attributes that can be accessed b...
Definition: blockmodel.h:62
static string NO_WEIGHT_COLUMN
"No Weight" column name. This name is used in case no weight is wanted for averaging.
Definition: blocksel.h:406
virtual ~SelectionFunctor()
Destroys the selection functor.
Definition: blocksel.h:363
A base class for object associated to a given block model.
Definition: blockmodel.h:1356
Abstracts average-type functions to be evaluated over a set of blocks.
Definition: blocksel.h:399
Abstracts the minimum function to be evaluated over a set of blocks.
Definition: blocksel.h:445