Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
FBEngine.hpp
Go to the documentation of this file.
1 #ifndef FBENGINE_HPP_
2 #define FBENGINE_HPP_
3 #include <cstdlib>
4 
5 #include <vector>
6 #include <map>
7 
8 #include "moab/Types.hpp"
9 #include "moab/Interface.hpp"
10 #include "moab/Range.hpp"
11 #include "moab/CartVect.hpp"
12 
13 namespace moab
14 {
15 class GeomTopoTool;
16 
17 // some forward declarations
18 class SmoothFace;
19 class SmoothCurve;
20 
21 /*
22  * Facet Based engine class for mesh-based geometry
23  */
24 class FBEngine
25 {
26  public:
27  FBEngine( Interface* impl, GeomTopoTool* geomTopoTool = NULL, const bool smooth = false );
28 
29  ~FBEngine();
30 
31  ErrorCode Init();
32 
33  ErrorCode getRootSet( EntityHandle* root_set );
34 
35  ErrorCode getNumEntSets( EntityHandle set, int num_hops, int* all_sets );
36 
37  ErrorCode createEntSet( int isList, EntityHandle* pSet );
38 
39  ErrorCode addEntSet( EntityHandle entity_set_to_add, EntityHandle entity_set_handle );
40 
41  ErrorCode getEntities( EntityHandle root_set, int ent_type, Range& gentities );
42 
44 
45  ErrorCode getNumOfType( EntityHandle set, int ent_type, int* pNum );
46 
47  ErrorCode getEntType( EntityHandle gent, int* type );
48 
50  double* x0,
51  double* y0,
52  double* z0,
53  double* x1,
54  double* y1,
55  double* z1 );
57  double x,
58  double y,
59  double z,
60  double* x1,
61  double* y1,
62  double* y3 );
63 
64  ErrorCode getVtxCoord( EntityHandle this_gent, double* x0, double* y0, double* z0 );
65 
66  ErrorCode gsubtract( EntityHandle entity_set_1, EntityHandle entity_set_2, EntityHandle result_entity_set );
67 
68  ErrorCode getEntNrmlXYZ( EntityHandle entity_handle,
69  double x,
70  double y,
71  double z,
72  double* nrml_i,
73  double* nrml_j,
74  double* nrml_k );
75 
76  ErrorCode getPntRayIntsct( double x,
77  double y,
78  double z,
79  double dir_x,
80  double dir_y,
81  double dir_z,
82  std::vector< EntityHandle >& intersect_entity_handles,
83  /* int storage_order,*/
84  std::vector< double >& intersect_coords,
85  std::vector< double >& param_coords );
86 
87  // some new methods, that are needed
88 
89  ErrorCode createTag( const char* tag_name, int tag_num_type_values, int tag_type, Tag& tag_handle_out );
90 
92  {
93  return _mbImpl;
94  }
95 
96  ErrorCode getArrData( const moab::EntityHandle* entity_handles,
97  int entity_handles_size,
98  Tag tag_handle,
99  void* tag_values_out );
100 
101  ErrorCode setArrData( const EntityHandle* entity_handles,
102  int entity_handles_size,
103  Tag tag_handle,
104  const void* tag_values );
105 
106  ErrorCode getEntAdj( EntityHandle handle, int type_requested, Range& adjEnts );
107 
108  ErrorCode getEgFcSense( EntityHandle mbedge, EntityHandle mbface, int& sense );
109 
110  ErrorCode measure( const EntityHandle* moab_entities, int entities_size, double* measures );
111 
112  // to do
113  ErrorCode getEntNrmlSense( EntityHandle face, EntityHandle region, int& sense );
114 
116  double x,
117  double y,
118  double z,
119  double& on_x,
120  double& on_y,
121  double& on_z,
122  double& tngt_i,
123  double& tngt_j,
124  double& tngt_k,
125  double& cvtr_i,
126  double& cvtr_j,
127  double& cvtr_k );
129  double x,
130  double y,
131  double z,
132  double& on_x,
133  double& on_y,
134  double& on_z,
135  double& nrml_i,
136  double& nrml_j,
137  double& nrml_k,
138  double& cvtr1_i,
139  double& cvtr1_j,
140  double& cvtr1_k,
141  double& cvtr2_i,
142  double& cvtr2_j,
143  double& cvtr2_k );
144 
146 
147  ErrorCode getEntURange( EntityHandle edge, double& u_min, double& u_max );
148 
149  ErrorCode getEntUtoXYZ( EntityHandle edge, double u, double& x, double& y, double& z );
150 
151  ErrorCode getEntTgntU( EntityHandle edge, double u, double& i, double& j, double& k );
152 
153  ErrorCode isEntAdj( EntityHandle entity1, EntityHandle entity2, bool& adjacent_out );
154 
156  std::vector< double >& xyz,
157  double* direction,
158  int closed,
159  double min_dot,
160  EntityHandle& oNewFace );
161  // these new points will be on edges or triangles, if in interior of triangles
163  std::vector< EntityHandle >& chainedEdges,
164  std::vector< EntityHandle >& splittingNodes,
165  EntityHandle& newFace );
166 
168 
170 
172  EntityHandle atNode,
173  EntityHandle brokenEdge,
174  EntityHandle& new_edge );
175  // helper for cleaning the stuff
176  // will be called if the topology is modified
177  void clean();
178 
179  void delete_smooth_tags();
180 
181  // access to the geom topo tool
182  // be careful what you do with it
184  {
185  return this->_my_geomTopoTool;
186  }
187 
189  EntityHandle newFace2,
190  double* direction,
191  EntityHandle& volume );
192 
193  // get nodes from edge in order
194  ErrorCode get_nodes_from_edge( EntityHandle gedge, std::vector< EntityHandle >& nodes );
195 
197  EntityHandle tEdge,
198  double* direction,
199  EntityHandle& newLatFace );
200 
201  // chain "chain"-able edges
202  // this could be useful if there are too many points / edges in the splitting
203  // polyline
204  // 2 edges are "chain"-able if
205  /*
206  * 1. they have the same adjacent faces
207  * 2. their orientation is such as the end of one is the start of the other
208  * 3. at meeting point, their tangents make an angle smaller then something
209  * (cos(angle) > cos (max_angle) = min_dot)
210  */
211  ErrorCode chain_edges( double min_dot );
212 
213  // 2 edges will be chained, along with modification of the topology
215 
217 
218  void set_smooth()
219  {
220  _smooth = true;
221  }
222 
223  private:
225 
226  ErrorCode getAdjacentEntities( const EntityHandle from, const int to_dim, Range& adj_ents );
227 
229  EntityHandle from,
230  EntityHandle to,
231  CartVect& Dir,
232  std::vector< CartVect >& points,
233  std::vector< EntityHandle >& entities,
234  std::vector< EntityHandle >& triangles );
235 
237  EntityHandle e1,
238  EntityHandle e3,
239  EntityHandle n1,
240  EntityHandle n2,
241  EntityHandle n3 ); // nodesAlongPolyline are on entities!
242 
244  EntityHandle e1,
245  EntityHandle e2,
246  EntityHandle n1,
247  EntityHandle n2 ); // nodesAlongPolyline are on entities!
248 
249  void print_debug_triangle( EntityHandle triangle );
250 
251  ErrorCode create_new_gedge( std::vector< EntityHandle >& nodesAlongPolyline, EntityHandle& new_geo_edge );
252 
253  // used for splitting surfaces
254  ErrorCode separate( EntityHandle face, std::vector< EntityHandle >& chainedEdges, Range& first, Range& second );
255 
256  ErrorCode smooth_new_intx_points( EntityHandle face, std::vector< EntityHandle >& chainedEdges );
257 
258  // having a node, split boundary along that node
260 
261  // see if the node is already part of a vertex set, do not create another one
262  bool find_vertex_set_for_node( EntityHandle iNode, EntityHandle& oVertexSet );
263 
264  // if the splitting edge is not a loop, the original boundary edges will belong to
265  // either original face, or new face
266  // only the new geo edge (splitting) will be part of both, with the
267  // orientation already decided
268  //
270  EntityHandle newFace,
271  std::vector< EntityHandle >& chainedEdges );
272 
273  // used as a way to isolate the faces after splitting
275 
276  // split the quads if needed; it will create a new gtt, which will
277  // contain triangles instead of quads
279 
280  ErrorCode boundary_nodes_on_face( EntityHandle face, std::vector< EntityHandle >& boundary_nodes );
281 
283 
284  // used for splitting an edge
286  // triangle split
287  ErrorCode divide_triangle( EntityHandle triangle, EntityHandle& newVertex );
289 
290  // this will be used during volume creation
292 
293  ErrorCode chain_able_edge( EntityHandle edge, double min_dot, EntityHandle& next_edge, bool& chainable );
294 
297  bool _smooth;
299  // these are initial ranges, that should not change during geometry gimmicks
300  // those that are added are changing gtt ranges, but they are not yet "smoothed"
301  // when new geometry is created, these ranges are not yet updated
303  // these are used only for smooth evaluations
304  // these smooth faces and edges will be initialized after reading the file
305  // the maps keep the link between EH in moab (geom sets) and
306  // their corresponding smooth counterparts
307  std::map< EntityHandle, SmoothFace* > _faces;
308  std::map< EntityHandle, SmoothCurve* > _edges;
311 
312  Range _piercedTriangles; // triangles to delete
314  Range _piercedEdges; // edges to delete
315  std::map< EntityHandle, EntityHandle > _brokenEdges; // this is a map between splitting nodes and edges that
316  // are broken on the boundary, by the polyline; the edges will be deleted in the end
317  // new edges?
318 };
319 
320 } // namespace moab
321 #endif /* FBENGINE_HPP_ */