UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_grid.hpp
1 /* u3d_grid.hpp */
2 /* $Id: u3d_grid.hpp,v 1.2 2008/05/29 12:13:35 sasha Exp $ */
3 #ifndef __u3d_grid_hpp
4 #define __u3d_grid_hpp
5 
6 #include "u3d_grid_cell.hpp"
7 //#include <u_message.hpp>
8 
16 enum U3D_CELL_TOPOLOGY
17 {
18  WHOLE_CELL = 0,
19  DIVIDED_CELL
20 };
21 
22 //class U3dModel;
23 
25 class U3dGrid
26 {
27 public:
30  U3dGrid (const U3dBox* modelBox);//, double min_cell_size);
31 
33  virtual ~U3dGrid();
34 
35  /* Return array of cells which lie into the given 3d box or intersect it. */
36  // IntAr getCellsInBox(U3dBox box);
37 
40 
42  const U3dGridCell* findCell(U3dBox box);
43 
44  U3dGridCell* findCell(int ID);
45 
46  /* Get all neighbours of given cell.
47  Returns pointer to first neighbour in array of ones.
48  n - number of neihbours in array. */
49  //U3dGridCell* getNeighbours(const U3dGridCell* cell, unsigned* n); //not implemented yet
50 
52  void divideCell(U3dGridCell* cell);
53 
57  void mergeSubCells(U3dGridCell* cell);
58 
60  U3dGridCell* getRoot(){ return m_Root; };
61 
62 
63  /* In the model grid find first entrance of cell with given parameters.
64  bodiId - idebtifier of the body
65  cellType - parameter that equal WHOLE_CELL if cell is not intersected by any model surface
66  and DIVIDED_CELL if cell is intersected by one or more surfaces.
67  if cellType is DIVIDED_CELL, this function finds the cell whose "first" point (point with min values of x,y,z)
68  belongs to the given body. */
69  //U3dGridCell* findBodyCell(U3dBodyId bodyId, U3D_CELL_TOPOLOGY cellType);
70 
72  void updateMaxCellId(int cellId){ m_maxCellId = cellId; }
73 
74 
75  /*------------DEBUG-------------------*/
76  void printCell();
77  void recursivePrintCell(const U3dGridCell* initCell);
78  /*------------DEBUG-------------------*/
79 
81  bool getCommonCells(U3dGridCellsArray *common_cells, U3dBox* surfBox, U3dGridCell* root);
82 
84  U3dGridCellsArray getEmptyCellsList();
85 
87  U3dGridCellsArray getBodyCellsList(int bodyId);
88 
90  U3dGridCellsArray getBoundCellsList(int boundId);
91 
94  U3dGridCellsArray getColumnBoundCellsList(U3dPoint p, int boundId) const;
95 
97  bool getReady() { return m_ready; }
98 
100  void setReady(bool ready) { m_ready = ready; }
101 
102 protected:
103  //const U3dModel1 *m_parentModel; /**< model object to which serves this grid */
106  static unsigned m_maxCellID;
107 
108 private:
109  int m_ready;
110  int m_maxCellId;
115  void deleteGridCells(U3dGridCell* root);
116 
118  int pointInCell(U3dPoint point, const U3dGridCell* cell);
119 
121  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, U3dBox box);
122 
124  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, U3dPoint p);
125 
126  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, int ID);
127 
129  void recursiveFillEmptyCellsList(U3dGridCell *cell, U3dGridCellsArray &cell_ar);
130 
132  void recursiveFindBodyCell(U3dGridCell* cell, int bodyId, U3dGridCellsArray &cell_ar);
133 
135  void recursiveFindBoundCell(U3dGridCell* cell, int boundId, U3dGridCellsArray &cell_ar);
136 
138  void recursiveFindColumnBoundCell(U3dGridCell* cell, U3dPoint p, int boundId, U3dGridCellsArray &cell_ar) const;
139 
140  /* Find cell by body id starting with initial cell i.e. only among cells that are children of this cell */
141  //U3dGridCell* recursiveFindBodyCell(U3dGridCell* cell, U3dBodyId bodyId, U3D_CELL_TOPOLOGY cellType);
142 
143 };
144 
145 #if 0
146 class U3dModel1
147 {
148 public:
149  U3dModel1()
150  {
151  U3dPoint p1(1., 1., 0.);
152  U3dPoint p2(4., 4., 2.5);
153  m_Root = new U3dBox(p1, p2);
154  m_Grid = new U3dGrid(m_Root);
155  };
156 
157  U3dBox* getModelBox() const { return m_Root; };
158  U3dGrid* getGrid() { return m_Grid; };
159 
160 protected:
161  U3dBox* m_Root;
162  U3dGrid* m_Grid;
163 };
164 #endif
165 
166 #endif /* u3d_grid.hpp */
167 
168 
bool getReady()
Definition: u3d_grid.hpp:97
virtual ~U3dGrid()
void setReady(bool ready)
Definition: u3d_grid.hpp:100
Definition: u3d_box.hpp:24
void divideCell(U3dGridCell *cell)
Definition: geometry.H:16
void mergeSubCells(U3dGridCell *cell)
U3dGridCellsArray getEmptyCellsList()
U3dGridCellsArray getColumnBoundCellsList(U3dPoint p, int boundId) const
Definition: u3d_point.hpp:16
void updateMaxCellId(int cellId)
Definition: u3d_grid.hpp:72
U3dGridCell * getRoot()
Definition: u3d_grid.hpp:60
U3dGrid(const U3dBox *modelBox)
U3dGridCellsArray getBoundCellsList(int boundId)
Definition: u3d_grid.hpp:25
Definition: u3d_grid_cell.hpp:32
U3dGridCellsArray getBodyCellsList(int bodyId)
U3dGridCell * m_Root
Definition: u3d_grid.hpp:104
const U3dGridCell * findCell(U3dPoint point)
bool getCommonCells(U3dGridCellsArray *common_cells, U3dBox *surfBox, U3dGridCell *root)