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.15 2008/03/31 07:58:19 guser1 Exp $ */
3 #ifndef __u3d_grid_hpp
4 #define __u3d_grid_hpp
5 
6 #include "u3d_grid_cell.hpp"
7 #include <u3d_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 
80 
82  U3dGridCellsArray getEmptyCellsList();
83 
85  U3dGridCellsArray getBodyCellsList(int bodyId);
86 
88  U3dGridCellsArray getBoundCellsList(int boundId);
89 
92  U3dGridCellsArray getColumnBoundCellsList(U3dPoint p, int boundId) const;
93 
95  bool getReady() { return m_ready; }
96 
98  void setReady(bool ready) { m_ready = ready; }
99 
100 protected:
101  //const U3dModel1 *m_parentModel; /**< model object to which serves this grid */
104  static unsigned m_maxCellID;
105 
106 private:
107  int m_ready;
108  int m_maxCellId;
113  void deleteGridCells(U3dGridCell* root);
114 
116  int pointInCell(U3dPoint point, const U3dGridCell* cell);
117 
119  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, U3dBox box);
120 
122  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, U3dPoint p);
123 
124  U3dGridCell* recursiveFindCell(U3dGridCell* initCell, int ID);
125 
127  void recursiveFillEmptyCellsList(U3dGridCell *cell, U3dGridCellsArray &cell_ar);
128 
130  void recursiveFindBodyCell(U3dGridCell* cell, int bodyId, U3dGridCellsArray &cell_ar);
131 
133  void recursiveFindBoundCell(U3dGridCell* cell, int boundId, U3dGridCellsArray &cell_ar);
134 
136  void recursiveFindColumnBoundCell(U3dGridCell* cell, U3dPoint p, int boundId, U3dGridCellsArray &cell_ar) const;
137 
138  /* Find cell by body id starting with initial cell i.e. only among cells that are children of this cell */
139  //U3dGridCell* recursiveFindBodyCell(U3dGridCell* cell, U3dBodyId bodyId, U3D_CELL_TOPOLOGY cellType);
140 
141 };
142 
143 #if 0
144 class U3dModel1
145 {
146 public:
147  U3dModel1()
148  {
149  U3dPoint p1(1., 1., 0.);
150  U3dPoint p2(4., 4., 2.5);
151  m_Root = new U3dBox(p1, p2);
152  m_Grid = new U3dGrid(m_Root);
153  };
154 
155  U3dBox* getModelBox() const { return m_Root; };
156  U3dGrid* getGrid() { return m_Grid; };
157 
158 protected:
159  U3dBox* m_Root;
160  U3dGrid* m_Grid;
161 };
162 #endif
163 
164 #endif /* u3d_grid.hpp */
165 
166 
bool getReady()
Definition: u3d_grid.hpp:95
virtual ~U3dGrid()
void setReady(bool ready)
Definition: u3d_grid.hpp:98
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)