moab
|
00001 #ifndef FBENGINE_HPP_ 00002 #define FBENGINE_HPP_ 00003 #include <stdlib.h> 00004 00005 #include <vector> 00006 #include <map> 00007 00008 #include "moab/Types.hpp" 00009 #include "moab/Interface.hpp" 00010 #include "moab/Range.hpp" 00011 #include "moab/CartVect.hpp" 00012 00013 namespace moab { 00014 class GeomTopoTool; 00015 00016 // some forward declarations 00017 class SmoothFace; 00018 class SmoothCurve; 00019 00020 /* 00021 * Facet Based engine class for mesh-based geometry 00022 */ 00023 class FBEngine { 00024 public: 00025 FBEngine(Interface *impl, GeomTopoTool* geomTopoTool = NULL, 00026 const bool smooth = false); 00027 00028 ~FBEngine(); 00029 00030 ErrorCode Init(); 00031 00032 ErrorCode getRootSet(EntityHandle * root_set); 00033 00034 ErrorCode getNumEntSets(EntityHandle set, int num_hops, int * all_sets); 00035 00036 ErrorCode createEntSet(int isList, EntityHandle * pSet); 00037 00038 ErrorCode addEntSet(EntityHandle entity_set_to_add, 00039 EntityHandle entity_set_handle); 00040 00041 ErrorCode getEntities(EntityHandle root_set, int ent_type, Range & gentities); 00042 00043 ErrorCode addEntArrToSet(Range entities, EntityHandle set); 00044 00045 ErrorCode getNumOfType(EntityHandle set, int ent_type, int * pNum); 00046 00047 ErrorCode getEntType(EntityHandle gent, int * type); 00048 00049 ErrorCode getEntBoundBox(EntityHandle this_gent, double * x0, double * y0, 00050 double * z0, double * x1, double *y1, double * z1); 00051 ErrorCode getEntClosestPt(EntityHandle this_gent, double x, double y, 00052 double z, double * x1, double * y1, double *y3); 00053 00054 ErrorCode getVtxCoord(EntityHandle this_gent, double * x0, double * y0, double * z0); 00055 00056 ErrorCode gsubtract(EntityHandle entity_set_1, EntityHandle entity_set_2, 00057 EntityHandle result_entity_set); 00058 00059 ErrorCode getEntNrmlXYZ( EntityHandle entity_handle, double x, double y, double z, 00060 double* nrml_i, double* nrml_j, double* nrml_k); 00061 00062 ErrorCode getPntRayIntsct( double x, double y, double z, 00063 double dir_x, double dir_y, double dir_z, 00064 std::vector<EntityHandle> &intersect_entity_handles, 00065 /* int storage_order,*/ 00066 std::vector<double> & intersect_coords, 00067 std::vector<double> & param_coords); 00068 00069 // some new methods, that are needed 00070 00071 ErrorCode createTag( const char* tag_name, 00072 int tag_num_type_values, 00073 int tag_type, 00074 Tag & tag_handle_out ); 00075 00076 Interface * moab_instance () { return _mbImpl; } 00077 00078 ErrorCode getArrData(const moab::EntityHandle* entity_handles, 00079 int entity_handles_size, 00080 Tag tag_handle, 00081 void* tag_values_out); 00082 00083 ErrorCode setArrData(const EntityHandle* entity_handles, 00084 int entity_handles_size, 00085 Tag tag_handle, 00086 const void* tag_values); 00087 00088 ErrorCode getEntAdj(EntityHandle handle, 00089 int type_requested, Range & adjEnts ); 00090 00091 ErrorCode getEgFcSense(EntityHandle mbedge, EntityHandle mbface, int & sense ); 00092 00093 ErrorCode measure(const EntityHandle * moab_entities, int entities_size, 00094 double * measures); 00095 00096 // to do 00097 ErrorCode getEntNrmlSense( EntityHandle face, EntityHandle region, 00098 int& sense ); 00099 00100 ErrorCode getEgEvalXYZ( EntityHandle edge, 00101 double x, double y, double z, 00102 double& on_x, double& on_y, double& on_z, 00103 double& tngt_i, double& tngt_j, double& tngt_k, 00104 double& cvtr_i, double& cvtr_j, double& cvtr_k ); 00105 ErrorCode getFcEvalXYZ( EntityHandle face, 00106 double x, double y, double z, 00107 double& on_x, double& on_y, double& on_z, 00108 double& nrml_i, double& nrml_j, double& nrml_k, 00109 double& cvtr1_i, double& cvtr1_j, double& cvtr1_k, 00110 double& cvtr2_i, double& cvtr2_j, double& cvtr2_k ); 00111 00112 ErrorCode getEgVtxSense( EntityHandle edge, EntityHandle vtx1, EntityHandle vtx2, int& sense ); 00113 00114 ErrorCode getEntURange( EntityHandle edge, 00115 double& u_min, double& u_max ); 00116 00117 ErrorCode getEntUtoXYZ( EntityHandle edge, double u, 00118 double& x, double& y, double& z ); 00119 00120 ErrorCode getEntTgntU( EntityHandle edge, 00121 double u, 00122 double& i, double& j, double& k ); 00123 00124 ErrorCode isEntAdj( EntityHandle entity1, EntityHandle entity2, 00125 bool& adjacent_out ); 00126 00127 ErrorCode split_surface_with_direction(EntityHandle face, std::vector<double> & xyz, double * direction, 00128 int closed, double min_dot, EntityHandle & oNewFace ); 00129 // these new points will be on edges or triangles, if in interior of triangles 00130 ErrorCode split_surface(EntityHandle face, 00131 std::vector<EntityHandle> & chainedEdges, 00132 std::vector<EntityHandle> & splittingNodes, EntityHandle & newFace); 00133 00134 ErrorCode split_edge_at_point(EntityHandle edge, CartVect & point, EntityHandle & new_edge); 00135 00136 ErrorCode split_edge_at_mesh_node(EntityHandle edge, EntityHandle node, EntityHandle & new_edge); 00137 00138 ErrorCode split_bedge_at_new_mesh_node(EntityHandle b_edge, EntityHandle atNode, EntityHandle brokenEdge, 00139 EntityHandle & new_edge); 00140 // helper for cleaning the stuff 00141 // will be called if the topology is modified 00142 void clean(); 00143 00144 void delete_smooth_tags(); 00145 00146 // access to the geom topo tool 00147 // be careful what you do with it 00148 GeomTopoTool * get_gtt() { return this->_my_geomTopoTool ; } 00149 00150 ErrorCode create_volume_with_direction(EntityHandle newFace1, EntityHandle newFace2, double * direction, 00151 EntityHandle & volume); 00152 00153 // get nodes from edge in order 00154 ErrorCode get_nodes_from_edge(EntityHandle gedge, std::vector<EntityHandle> & nodes); 00155 00156 ErrorCode weave_lateral_face_from_edges(EntityHandle bEdge, EntityHandle tEdge, double * direction, 00157 EntityHandle & newLatFace); 00158 00159 // chain "chain"-able edges 00160 // this could be useful if there are too many points / edges in the splitting 00161 // polyline 00162 // 2 edges are "chain"-able if 00163 /* 00164 * 1. they have the same adjacent faces 00165 * 2. their orientation is such as the end of one is the start of the other 00166 * 3. at meeting point, their tangents make an angle smaller then something 00167 * (cos(angle) > cos (max_angle) = min_dot) 00168 */ 00169 ErrorCode chain_edges(double min_dot); 00170 00171 // 2 edges will be chained, along with modification of the topology 00172 ErrorCode chain_two_edges(EntityHandle edge, EntityHandle next_edge); 00173 00174 ErrorCode get_vert_edges(EntityHandle edge, EntityHandle & v1, EntityHandle & v2); 00175 00176 void set_smooth() { _smooth = true;} 00177 private: 00178 00179 ErrorCode initializeSmoothing(); 00180 00181 ErrorCode getAdjacentEntities(const EntityHandle from, const int to_dim, 00182 Range &adj_ents); 00183 00184 ErrorCode compute_intersection_points(EntityHandle & face, 00185 EntityHandle from, EntityHandle to, CartVect & Dir, std::vector<CartVect> & points, 00186 std::vector<EntityHandle> & entities, std::vector<EntityHandle> & triangles); 00187 00188 ErrorCode BreakTriangle(EntityHandle tri, EntityHandle e1, EntityHandle e3, EntityHandle n1, 00189 EntityHandle n2, EntityHandle n3);// nodesAlongPolyline are on entities! 00190 00191 ErrorCode BreakTriangle2(EntityHandle tri, EntityHandle e1, EntityHandle e2, EntityHandle n1, 00192 EntityHandle n2);// nodesAlongPolyline are on entities! 00193 00194 void print_debug_triangle(EntityHandle triangle); 00195 00196 ErrorCode create_new_gedge(std::vector<EntityHandle> &nodesAlongPolyline, 00197 EntityHandle & new_geo_edge); 00198 00199 // used for splitting surfaces 00200 ErrorCode separate (EntityHandle face, 00201 std::vector<EntityHandle> & chainedEdges, Range & first, 00202 Range & second); 00203 00204 ErrorCode smooth_new_intx_points(EntityHandle face, 00205 std::vector<EntityHandle> & chainedEdges); 00206 00207 // having a node, split boundary along that node 00208 ErrorCode split_boundary(EntityHandle face, EntityHandle atNode); 00209 00210 // see if the node is already part of a vertex set, do not create another one 00211 bool find_vertex_set_for_node(EntityHandle iNode, EntityHandle & oVertexSet); 00212 00213 // if the splitting edge is not a loop, the original boundary edges will belong to 00214 // either original face, or new face 00215 // only the new geo edge (splitting) will be part of both, with the 00216 // orientation already decided 00217 // 00218 ErrorCode redistribute_boundary_edges_to_faces(EntityHandle face, EntityHandle newFace, 00219 std::vector<EntityHandle> & chainedEdges); 00220 00221 // used as a way to isolate the faces after splitting 00222 ErrorCode set_neumann_tags(EntityHandle face, EntityHandle newFace); 00223 00224 // split the quads if needed; it will create a new gtt, which will 00225 // contain triangles instead of quads 00226 ErrorCode split_quads(); 00227 00228 ErrorCode boundary_nodes_on_face(EntityHandle face, std::vector<EntityHandle> & boundary_nodes); 00229 00230 ErrorCode boundary_mesh_edges_on_face(EntityHandle face, Range & boundary_mesh_edges); 00231 00232 // used for splitting an edge 00233 ErrorCode split_internal_edge(EntityHandle & edge, EntityHandle & newVertex); 00234 // triangle split 00235 ErrorCode divide_triangle(EntityHandle triangle, EntityHandle & newVertex); 00236 Interface * _mbImpl; 00237 00238 // this will be used during volume creation 00239 ErrorCode set_default_neumann_tags(); 00240 00241 ErrorCode chain_able_edge(EntityHandle edge, double min_dot, EntityHandle & next_edge, bool & chainable); 00242 00243 GeomTopoTool* _my_geomTopoTool; 00244 bool _t_created; 00245 bool _smooth; 00246 bool _initialized; 00247 // these are initial ranges, that should not change during geometry gimmicks 00248 // those that are added are changing gtt ranges, but they are not yet "smoothed" 00249 // when new geometry is created, these ranges are not yet updated 00250 Range _my_gsets[5]; 00251 // these are used only for smooth evaluations 00252 // these smooth faces and edges will be initialized after reading the file 00253 // the maps keep the link between EH in moab (geom sets) and 00254 // their corresponding smooth counterparts 00255 std::map<EntityHandle, SmoothFace*> _faces; 00256 std::map<EntityHandle, SmoothCurve*> _edges; 00257 SmoothFace ** _smthFace; 00258 SmoothCurve ** _smthCurve; 00259 00260 Range _piercedTriangles; // triangles to delete 00261 Range _newTriangles; 00262 Range _piercedEdges;// edges to delete 00263 std::map<EntityHandle, EntityHandle> _brokenEdges; // this is a map between splitting nodes and edges that 00264 // are broken on the boundary, by the polyline; the edges will be deleted in the end 00265 // new edges? 00266 00267 }; 00268 00269 } // namespace moab 00270 #endif /* FBENGINE_HPP_ */