UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_model.hpp
1 /* u3d_model.hpp */
2 /* $Id: u3d_model.hpp,v 1.8 2008/06/06 15:57:50 sad Exp $ */
3 #ifndef __u3d_model_hpp
4 #define __u3d_model_hpp
5 
6 #include "u3d_body.hpp"
7 #include "u3d_bound.hpp"
8 #include "u3d_grid.hpp"
9 #include <mix/u3d_progress.hpp>
10 
11 class U3dGrid;
12 
13 //============================================================================
15 class U3dModel
16 {
17  friend bool U3dModelExport(char*, U3dModel*, char*, U3dProgress*);
18  friend void U3dModelSaveUnivers(const U3dModel*, const char*, const char*) throw();
19  friend U3dModel* U3dModelLoadUnivers(const char*, const char* ) throw();
20 
21 public:
22 
24  U3dModel(U3dModAreaPos modAreaPos, U3dBox modelBox,
25  U3dBoundInfoAr bounds, U3dBodyInfoAr bodies, U3dProgress* prg=0x0);
26 
28  U3dModel(U3dModAreaPos modAreaPos, U3dBox modelBox, U3d1dModBodyInfoAr mod1dBodies, U3dProgress* prg=0x0);
29 
31  U3dModel(U3dModel*, U3dProgress* prg=0x0);
32  ~U3dModel();
33 
35  double getVel(U3dPoint p, U3D_WAVE_TYPE wt, int bId=-1);
36 
38  bool getVelGrad(U3dPoint point, double &v, double &vf, double &vaz, U3D_WAVE_TYPE wt) ;
39 
41  bool getVelGrad(U3dPoint point, int bodyId, double &v, double &vf, double &vaz, U3D_WAVE_TYPE wt) ;
42 
44  // double getDensity(U3dPoint p) const;
45 
47  int getBodyId(U3dPoint);
48 
49 
56  U3dBody* getBody(int bodyId);
57 
58 
60  const U3dBody* getBody(int bodyId) const;
61 
63  int getBodiesNum() const { return m_bodies.size(); }
64 
66  U3dBox getModelBox() const { return m_modellingArea; }
67 
69  U3dGrid* getGrid() { return m_grid; }
70 
72  const U3dGrid* getGrid() const { return m_grid; }
73 
74 
76  U3dBound* getBound(int boundId);
77 
79  const U3dBound* getBound(int boundId) const;
80 
81 
83  int getBoundsNum() const { return m_bounds.size(); }
84 
87 
88  void setModelAreaPos(U3dModAreaPos MAP);
89 
91  bool getFBNormal(U3dPoint p, double &iA, double &iAz);
92 
94  bool getReady() { return m_ready; }
95 
97  void addDescription(const char* description);
98 
99  std::vector<int> getCommonBoundsIds(int bodyId_0, int bodyId_1);
100 
101  //protected:
102 
104  void constructGrid(bool plane_surf_model);
105 
107  void gridCrusher(int boundId);
108 
110  void getCommonCells(U3dGridCellsArray *common_cells, U3dBox* surfBox, U3dGridCell* root);
111 
113  void recursiveDivideCell(int boundId, std::set<int> &trianglesId_ar, U3dGridCell* cell);
114 
115 
116 
117 
120  void fillGridInfoSimple();
121 
124 
127  void fillGridInfoComplex();
128 
131  void getNeighbours(U3dBox box, U3dGridCellsArray &cell_array, U3dGridCellsArray &neighbour_cells);
132 
134  void fillBoundCellsInfo();
135 
137  void fillBoundCellsInfo(std::vector<int> bodies, int boundId, U3dGridCell *cell, U3D_COLOR b_color);
138 
139 
140 
141 
143  U3dGridCell* getBodyIdFromGrid(U3dPoint p, int &body_id) ;
144 
146  int getBodyIdFromCell(U3dPoint p, U3dGridCell* cell);
147 
149  int getBodyIdDummy(U3dPoint p);
150 
151 
152 
153 
155  bool getNormalLimPoints(U3dPoint p, U3dPoint *&p0, U3dPoint *&p1,
156  double &iA0, double &iAz0, double &iA1, double &iAz1);
157 
161  void defineNearestIntPoints(U3dPoint p, int bodyId, U3dPointsAr intersection_ps, std::vector<int> intersected_bounds_ind,
162  int &p0_ind, int &p1_ind);
163 
165  void interpolateNormals(U3dPoint p, U3dPoint* p0, U3dPoint* p1,
166  double iA0, double iAz0, double iA1, double iAz1,
167  double &iA, double &iAz);
168 
170  void intersectCellTriangles(U3dPoint* p0, U3dPoint* p1, U3dGridCell* goal_cell, std::vector<int>& int_trIds, U3dPointsAr& int_points);
171 
172  void clearOnStop();
173 
174 private:
175 
176  bool m_ready;
178  char* m_name;
179  std::string m_desc;
180 
181  U3dModAreaPos m_modelAreaPosition;
184  U3dBodiesAr m_bodies;
185  U3dBoundsAr m_bounds;
187  U3dBox m_modellingArea;
188  U3dGrid* m_grid;
190  U3dProgress* progress;
191 
192 
193 };
194 
195 #endif /* u3d_model.hpp */
void defineNearestIntPoints(U3dPoint p, int bodyId, U3dPointsAr intersection_ps, std::vector< int > intersected_bounds_ind, int &p0_ind, int &p1_ind)
U3dModAreaPos getModelAreaPos() const
void addDescription(const char *description)
Definition: u3d_body.hpp:13
void intersectCellTriangles(U3dPoint *p0, U3dPoint *p1, U3dGridCell *goal_cell, std::vector< int > &int_trIds, U3dPointsAr &int_points)
int getBodyIdFromCell(U3dPoint p, U3dGridCell *cell)
void getCommonCells(U3dGridCellsArray *common_cells, U3dBox *surfBox, U3dGridCell *root)
double getVel(U3dPoint p, U3D_WAVE_TYPE wt, int bId=-1)
int getBodiesNum() const
Definition: u3d_model.hpp:63
void getNeighbours(U3dBox box, U3dGridCellsArray &cell_array, U3dGridCellsArray &neighbour_cells)
U3dBox getModelBox() const
Definition: u3d_model.hpp:66
friend bool U3dModelExport(char *, U3dModel *, char *, U3dProgress *)
Definition: u3d_model_defines.hpp:20
int getBoundsNum() const
Definition: u3d_model.hpp:83
Definition: u3d_box.hpp:24
Definition: u3d_bound.hpp:21
void fillGridInfoSimple()
U3dModel(U3dModAreaPos modAreaPos, U3dBox modelBox, U3dBoundInfoAr bounds, U3dBodyInfoAr bodies, U3dProgress *prg=0x0)
bool getFBNormal(U3dPoint p, double &iA, double &iAz)
Definition: geometry.H:16
U3dGridCell * getBodyIdFromGrid(U3dPoint p, int &body_id)
Definition: u3d_point.hpp:16
U3dBound * getBound(int boundId)
U3dBody * getBody(int bodyId)
bool getVelGrad(U3dPoint point, double &v, double &vf, double &vaz, U3D_WAVE_TYPE wt)
Definition: u3d_model.hpp:15
void fillGridInfoComplex()
void recursiveDivideCell(int boundId, std::set< int > &trianglesId_ar, U3dGridCell *cell)
Definition: u3d_progress.hpp:10
bool getReady()
Definition: u3d_model.hpp:94
U3dGrid * getGrid()
Definition: u3d_model.hpp:69
Definition: u3d_grid.hpp:25
Definition: u3d_grid_cell.hpp:32
void fillBoundCellsInfo()
int getBodyIdDummy(U3dPoint p)
void gridCrusher(int boundId)
void recursiveFillCellInfo(U3dGridCell *cell)
const U3dGrid * getGrid() const
Definition: u3d_model.hpp:72
bool getNormalLimPoints(U3dPoint p, U3dPoint *&p0, U3dPoint *&p1, double &iA0, double &iAz0, double &iA1, double &iAz1)
void interpolateNormals(U3dPoint p, U3dPoint *p0, U3dPoint *p1, double iA0, double iAz0, double iA1, double iAz1, double &iA, double &iAz)
void constructGrid(bool plane_surf_model)
int getBodyId(U3dPoint)