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