COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coDoBasisTree.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_DO_BASIS_TREE_H
9 #define CO_DO_BASIS_TREE_H
10 
11 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 // CLASS BasisTree
13 //
14 // Basis class for OctTrees and QuadTrees
15 //
16 // Initial version: 2001-12-10 Sergio Leseduarte
17 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18 // (C) 2001 by VirCinity IT Consulting
19 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 // Changes:
21 
22 #include "coDistributedObject.h"
23 #include <vector>
24 #include <util/coVector.h>
25 
26 namespace covise
27 {
28 
30 {
31 public:
32  enum // number of shared-memory objects
33  {
34  SHM_OBJ = 8,
35  MAX_NO_LEVELS = 10, // maximum tree depth
36  MIN_SMALL_ENOUGH = 32, // minimum goal for macro-cell division
37  CRIT_LEVEL = 3, // after this level tree division is interrupted
38  // if a son leaf inherits all cells from the father
39  NORMAL_SIZE = 800 // population per tree if the grid were uniform
40  };
60  coDoBasisTree(const coObjInfo &info,
61  const char *label1, const char *label2,
62  int nelem_l, int nconn_l, int ncoord_l,
63  int *el, int *conn,
64  float *x_c, float *y_c, float *z_c,
65  int normal_size,
66  int max_no_levels,
67  int min_small_enough,
68  int crit_level,
69  int limit_fX,
70  int limit_fY,
71  int limit_fZ);
73  coDoBasisTree(const coObjInfo &info);
75  coDoBasisTree(const coObjInfo &info, const char *label);
76 
86  coDoBasisTree(const coObjInfo &info,
87  const char *label1, const char *label2,
88  int cellListSize,
89  int macroCellListSize,
90  int cellBBoxesSize,
91  int gridBBoxSize);
92 
94  virtual ~coDoBasisTree();
95 
102  void Visualise(std::vector<int> &ll, std::vector<int> &cl,
103  std::vector<float> &xi, std::vector<float> &yi, std::vector<float> &zi);
108  const int *search(const float *point) const;
110  const int *extended_search(const coVector &point1, const coVector &point2, std::vector<int> &OctreePolygonList) const;
112  bool cutLineCuboid(const coVector &point1, const coVector &point2, const float *cuboidBbox, std::vector<coVector> &CutVec) const;
114  bool cutThroughOct(int baum, const float bbox[6], std::vector<int> &ll, std::vector<int> &cl, std::vector<float> &xi, std::vector<float> &yi, std::vector<float> &zi, const coVector &point1, const coVector &point2, std::vector<int> &OctreePolygonList) const;
116  const int *getBbox(std::vector<float> &boundingBox) const;
118  const int *area_search(std::vector<float> &Bbox, std::vector<int> &GridElemList) const;
120  void getMacroCellElements(int baum, float bbox[6], std::vector<int> &ElementList, const float *reference_Bbox) const;
122  bool lineInBbox(const coVector &point1, const coVector &point2, const float bbox[6]) const;
124 
125  friend ostream &operator<<(ostream &outfile, coDoBasisTree &tree);
130  {
131  public:
132  virtual bool operator()(const float[6]) const = 0;
133 
134  virtual ~functionObject() = 0;
135  };
136  void getChunks(vector<const int *> &chunks, const functionObject *test);
137 
138  int getNumCellLists();
139  int getNumMacroCellLists();
140  int getNumCellBBoxes();
141  int getNumGridBBoxes();
142 
143  void getAddresses(int **cellList, int **macroCellList, float **cellBBox, float **gridBBox, int **fX, int **fY, int **fZ, int **max_no_levels);
144 
145 protected:
146  int getObjInfo(int, coDoInfo **) const;
147  int rebuildFromShm();
148 
149  void BBoxForElement(int i);
150 
151  // once the tree is made up to some level, we share the cell
152  // population and recursively split the cells
153  void ShareCellsBetweenLeaves();
154  void IniBBox(float *,
155  const int *) const;
156  static int IsInMacroCell(const int *okey,
157  const int *macro_keys);
158  void fillBBoxSon(float *bbox_son,
159  const float *bbox,
160  int son) const;
161  void SplitOctTree(const float *bbox,
162  std::vector<int> &population_,
163  int level,
164  int offset);
165  int CellsAreTooBig(const float *bbox,
166  std::vector<int> &population);
167  // Recreate Shared Memory objects here
168  void RecreateShm(const char *label1, const char *label2);
169  // determines how many times we apply SplitMacroCells
170  void DivideUpToLevel();
171  // used by search...
172  const int *lookUp(int position,
173  int *okey,
174  int mask) const;
175  // used in constructor...
176  void MakeOctTree(int *el, int *conn, float *x_c, float *y_c, float *z_c);
177  // position of a tree in the forest
178  int Position(int *key) const;
179 
180  // Shared memory stuff
185 
190 
191  //+++++++++++++++++++++++++++++++++++++++++++++++++++++
192  // real tree construction
193  //+++++++++++++++++++++++++++++++++++++++++++++++++++++
194  std::vector<int> macCellList_;
195  std::vector<int> cellList_;
196  std::vector<int> *populations_;
197  std::vector<float> cellBBoxes_;
198  // size and pointers to grid lists... do not delete them
199  int nelem;
200  int nconn;
201  int ncoord;
202  int *el_;
203  int *conn_;
204  float *x_c_;
205  float *y_c_;
206  float *z_c_;
207  // used only when making the tree!!!
208  float *cell_bbox_;
209  mutable float grid_bbox_[6];
210 
211  mutable int fX_;
212  mutable int fY_;
213  mutable int fZ_;
214 
215  // use when making the octtree for the first time
216  const int normal_size_;
217  mutable int max_no_levels_;
218  const int min_small_enough_;
219  const int crit_level_;
220  const int limit_fX_;
221  const int limit_fY_;
222  const int limit_fZ_;
223 
224 private:
225  void addChunk(vector<const int *> &chunks,
226  int position, const float bbox[6], const functionObject *);
227  float cellFactor_;
229  void treePrint(ostream &outfile, int level,
230  int *key, int offset);
231  void VisualiseOneOctTree(int baum, const float bbox[6], std::vector<int> &ll, std::vector<int> &cl, std::vector<float> &xi, std::vector<float> &yi, std::vector<float> &zi);
232 
233  void RecreateShmDL(covise_data_list *);
234 };
235 }
236 #endif
float * z_c_
Definition: coDoBasisTree.h:206
const int min_small_enough_
Definition: coDoBasisTree.h:218
coIntShmArray macroCellList
Definition: coDoBasisTree.h:182
std::vector< float > cellBBoxes_
Definition: coDoBasisTree.h:197
Definition: coDoBasisTree.h:129
coIntShm fXShm
Definition: coDoBasisTree.h:186
GLuint GLsizei const GLchar * label
Definition: khronos-glext.h:8634
int * el_
Definition: coDoBasisTree.h:202
Definition: coDoBasisTree.h:29
int nconn
Definition: coDoBasisTree.h:200
coIntShm fYShm
Definition: coDoBasisTree.h:187
int * conn_
Definition: coDoBasisTree.h:203
int fZ_
Definition: coDoBasisTree.h:213
GLenum GLint GLuint mask
Definition: khronos-glext.h:6719
float * x_c_
Definition: coDoBasisTree.h:204
coIntShm fZShm
Definition: coDoBasisTree.h:188
const int limit_fY_
Definition: coDoBasisTree.h:221
Definition: coObjID.h:230
coFloatShmArray cellBBoxes
Definition: coDoBasisTree.h:183
int fX_
Definition: coDoBasisTree.h:211
Definition: coDistributedObject.h:266
float cellFactor_
Definition: coDoBasisTree.h:227
Definition: coDistributedObject.h:90
Definition: coVector.h:41
#define DOEXPORT
Definition: coExport.h:307
std::vector< int > macCellList_
Definition: coDoBasisTree.h:194
int nelem
Definition: coDoBasisTree.h:199
int small_enough_
Definition: coDoBasisTree.h:228
const int crit_level_
Definition: coDoBasisTree.h:219
int fY_
Definition: coDoBasisTree.h:212
GLint level
Definition: khronos-glext.h:6344
Definition: coDistributedObject.h:295
coFloatShmArray gridBBox
Definition: coDoBasisTree.h:184
std::vector< int > * populations_
Definition: coDoBasisTree.h:196
GLintptr offset
Definition: khronos-glext.h:6611
const int limit_fX_
Definition: coDoBasisTree.h:220
void boundingBox(float **x, float **y, float **z, int *c, int n, float *bbx1, float *bby1, float *bbz1, float *bbx2, float *bby2, float *bbz2)
Definition: DeleteUnusedPoints.cpp:159
std::vector< int > cellList_
Definition: coDoBasisTree.h:195
coIntShmArray cellList
Definition: coDoBasisTree.h:181
const int limit_fZ_
Definition: coDoBasisTree.h:222
float * y_c_
Definition: coDoBasisTree.h:205
float * cell_bbox_
Definition: coDoBasisTree.h:208
const int normal_size_
Definition: coDoBasisTree.h:216
coIntShm max_no_levels_Shm
Definition: coDoBasisTree.h:189
int max_no_levels_
Definition: coDoBasisTree.h:217
int ncoord
Definition: coDoBasisTree.h:201
QTextStream & operator<<(QTextStream &out, const coConfigEntryStringList list)
Definition: coConfigEntryString.cpp:166