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.40 2009/01/16 17:02:46 guser2 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 <u3d_progress.hpp>
10 
11 
12 class U3dGrid;
13 
14 //============================================================================
16 class U3dModel
17 {
18  friend bool U3dModelExport(char*, U3dModel*, char*, U3dProgress*);
19 
20 public:
21 
23  U3dModel(U3dModAreaPos modAreaPos, U3dBox modelBox,
24  U3dBoundInfoAr bounds, U3dBodyInfoAr bodies, U3dProgress* prg=0x0);
25 
27  U3dModel(U3dModAreaPos modAreaPos, U3dBox modelBox, U3d1dModBodyInfoAr mod1dBodies, U3dProgress* prg=0x0);
28 
30  U3dModel(U3dModel*, U3dProgress* prg=0x0);
31  ~U3dModel();
32 
34  double getVel(U3dPoint p, U3D_WAVE_TYPE wt, int bId=-1);
35 
37  bool getVelGrad(U3dPoint point, double &v, double &vf, double &vaz, U3D_WAVE_TYPE wt) ;
38 
40  bool getVelGrad(U3dPoint point, int bodyId, double &v, double &vf, double &vaz, U3D_WAVE_TYPE wt) ;
41 
43  // double getDensity(U3dPoint p) const;
44 
46  int getBodyId(U3dPoint);
47 
48 
55  U3dBody* getBody(int bodyId);
56 
57 
59  const U3dBody* getBody(int bodyId) const { return const_cast<U3dModel&>(*this).getBody(bodyId); };
60 
62  int getBodiesNum() const { return m_bodies.size(); }
63 
65  U3dBox getModelBox() const { return m_modellingArea; }
66 
68  U3dGrid* getGrid() { return m_grid; }
69 
71  const U3dGrid* getGrid() const { return m_grid; }
72 
73 
75  U3dBound* getBound(int boundId) const;
76 
78  int getBoundsNum() const { return m_bounds.size(); }
79 
82 
83  void setModelAreaPos(U3dModAreaPos MAP);
84 
86  bool getFBNormal(U3dPoint p, double &iA, double &iAz);
87 
89  bool getReady() { return m_ready; }
90 
92  void addDescription(const char* description);
93 
94  std::vector<int> getCommonBoundsIds(int bodyId_0, int bodyId_1);
95 
96  //protected:
97 
99  void constructGrid(bool plane_surf_model);
100 
102  void gridCrusher(int boundId);
103 
105  void getCommonCells(U3dGridCellsArray *common_cells, U3dBox* surfBox, U3dGridCell* root);
106 
108  void recursiveDivideCell(int boundId, int_set &trianglesId_ar, U3dGridCell* cell);
109 
110 
111 
112 
115  void fillGridInfoSimple();
116 
119 
122  void fillGridInfoComplex();
123 
126  void getNeighbours(U3dBox box, U3dGridCellsArray &cell_array, U3dGridCellsArray &neighbour_cells);
127 
129  void fillBoundCellsInfo();
130 
132  void fillBoundCellsInfo(std::vector<int> bodies, int boundId, U3dGridCell *cell, U3D_COLOR b_color);
133 
134 
135 
136 
138  U3dGridCell* getBodyIdFromGrid(U3dPoint p, int &body_id) ;
139 
141  int getBodyIdFromCell(U3dPoint p, U3dGridCell* cell);
142 
144  int getBodyIdDummy(U3dPoint p);
145 
146 
147 
148 
150  bool getNormalLimPoints(U3dPoint p, U3dPoint *&p0, U3dPoint *&p1,
151  double &iA0, double &iAz0, double &iA1, double &iAz1);
152 
156  void defineNearestIntPoints(U3dPoint p, int bodyId, U3dPointsAr intersection_ps, std::vector<int> intersected_bounds_ind,
157  int &p0_ind, int &p1_ind);
158 
160  void interpolateNormals(U3dPoint p, U3dPoint* p0, U3dPoint* p1,
161  double iA0, double iAz0, double iA1, double iAz1,
162  double &iA, double &iAz);
163 
165  void intersectCellTriangles(U3dPoint* p0, U3dPoint* p1, U3dGridCell* goal_cell, std::vector<int>& int_trIds, U3dPointsAr& int_points);
166 
167  void clearOnStop();
168 
171  void checkInternalData(std::string &errstr);
172 
173  bool m_ready;
175  char* m_name;
176  char* m_desc;
177 
178  U3dModAreaPos m_modelAreaPosition;
181  U3dBodiesAr m_bodies;
182  U3dBoundsAr m_bounds;
184  U3dBox m_modellingArea;
185  U3dGrid* m_grid;
187  U3dProgress* progress;
188 
189 
190 };
191 
192 #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:62
void getNeighbours(U3dBox box, U3dGridCellsArray &cell_array, U3dGridCellsArray &neighbour_cells)
U3dBox getModelBox() const
Definition: u3d_model.hpp:65
friend bool U3dModelExport(char *, U3dModel *, char *, U3dProgress *)
Definition: u3d_model_defines.hpp:20
int getBoundsNum() const
Definition: u3d_model.hpp:78
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:89
U3dGrid * getGrid()
Definition: u3d_model.hpp:68
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)
void checkInternalData(std::string &errstr)
const U3dGrid * getGrid() const
Definition: u3d_model.hpp:71
bool getNormalLimPoints(U3dPoint p, U3dPoint *&p0, U3dPoint *&p1, double &iA0, double &iAz0, double &iA1, double &iAz1)
const U3dBody * getBody(int bodyId) const
Definition: u3d_model.hpp:59
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)