MeshKit  1.0
ExtrudeMesh.hpp
Go to the documentation of this file.
00001 #ifndef MESHKIT_EXTRUDE_MESH_HPP
00002 #define MESHKIT_EXTRUDE_MESH_HPP
00003 
00004 #include <vector>
00005 #include <set>
00006 
00007 #include "meshkit/Types.hpp"
00008 #include "meshkit/Error.hpp"
00009 #include "meshkit/MeshScheme.hpp"
00010 #include "meshkit/ModelEnt.hpp"
00011 
00012 #include "CESets.hpp"
00013 #include "meshkit/LocalTag.hpp"
00014 #include "Transform.hpp"
00015 
00016 #include "meshkit/iMesh.hpp"
00017 
00018 
00019 namespace MeshKit {
00020 
00021   class MKCore;
00022 
00023 
00039   class ExtrudeMesh : public MeshScheme
00040   {
00041   public:
00043     ExtrudeMesh(MKCore *mkcore, const MEntVector &me_vec);
00044 
00046     virtual ~ExtrudeMesh();
00047 
00049     static const char* name();
00050 
00055     static bool can_mesh(iBase_EntityType dim);
00056 
00063     static bool can_mesh(ModelEnt *me);
00064 
00068     static const moab::EntityType* output_types();
00069 
00073     virtual const moab::EntityType* mesh_types_arr() const;
00074 
00078     virtual bool add_modelent(ModelEnt *model_ent);
00079 
00081     virtual void setup_this();
00082 
00084     virtual void execute_this();
00085 
00086     // ExtrudeMesh function local //////////////////
00087 
00088     /* \brief Return the tag used to indicate extruded sets
00089      */
00090     iBase_TagHandle extrude_tag();
00091 
00092     /* \brief Return the tag used to indicate copied sets
00093      */
00094     iBase_TagHandle copy_tag();
00095 
00096     /* \brief Set the transform function for this operation
00097      */
00098     void set_transform(const Extrude::Transform &transform);
00099 
00100     /* \brief Turn copying of faces on (true) or off (false)
00101      */
00102     void copy_faces(bool copy);
00103 
00104     void update_sets();
00105 
00106     /* \brief Reset the copy and expand set lists
00107      */
00108     void reset_sets();
00109 
00110     /* \brief Return reference to extrude sets
00111      */
00112     CESets &extrude_sets();
00113 
00114     /* \brief Return reference to copy sets
00115      */
00116     CESets &copy_sets();
00117 
00118     /* \brief Return reference to expand sets
00119      */
00120     CESets &expand_sets();
00121 
00122     // - get structure
00123     int getStructure(iMesh_Instance instance,
00124                      iBase_EntitySetHandle set,
00125                      std::vector<iBase_EntityHandle> &ents,
00126                      std::vector<iBase_EntityHandle> &unique_adj,
00127                      std::vector<int> &indices,
00128                      std::vector<int> &offsets);
00129 
00130   private:
00131     void do_extrude(iMesh::EntitySetHandle set_handle);
00132 
00133     void get_normals(const std::vector<iBase_EntityHandle> &verts,
00134                      const std::vector<int> &indices,
00135                      const std::vector<int> &offsets, const Vector<3> &dv,
00136                      std::vector<int> &normals);
00137 
00138     void connect_up_dots(iBase_EntityHandle *src, int size,
00139                          iBase_TagHandle local_tag, int *norms, int *inds,
00140                          int *offs, iBase_EntityHandle *pre,
00141                          iBase_EntityHandle *post);
00142     void connect_up_dots(iBase_EntityHandle *src, int size,
00143                          iBase_TagHandle local_tag,
00144                          int *pre_norms,  int *pre_inds,  int *pre_offs,
00145                          iBase_EntityHandle *pre,
00146                          int *post_norms, int *post_inds, int *post_offs,
00147                          iBase_EntityHandle *post);
00148 
00149     iMesh *mesh;                   // mesh instance
00150     LocalTag extrudeTag;           // tag storing extrude-to tag
00151     LocalTag copyTag;              // tag storing copy-to tag
00152     Extrude::Transform *transform; // transform function for extrusion
00153     bool copyFaces;
00154 
00155     CESets extrudeSets;
00156     CESets copySets;
00157     CESets expandSets;
00158   };
00159 
00160   inline const char* ExtrudeMesh::name()
00161   {
00162     return "ExtrudeMesh";
00163   }
00164 
00165   inline bool ExtrudeMesh::can_mesh(iBase_EntityType)
00166   {
00167     // Given just a dimension, ExtrudeMesh can't do anything since it doesn't
00168     // know what to extrude.
00169     return false;
00170   }
00171 
00172   inline bool ExtrudeMesh::can_mesh(ModelEnt *me)
00173   {
00174     return me->dimension() < 3;
00175   }
00176 
00177   inline const moab::EntityType* ExtrudeMesh::mesh_types_arr() const
00178   {
00179     return output_types();
00180   }
00181 
00182   inline void ExtrudeMesh::set_transform(const Extrude::Transform &trans)
00183   {
00184     delete transform;
00185     transform = trans.clone();
00186   }
00187 
00188   inline void ExtrudeMesh::copy_faces(bool copy)
00189   {
00190     copyFaces = copy;
00191   }
00192 
00193   inline iBase_TagHandle ExtrudeMesh::copy_tag()
00194   {
00195     return copyTag;
00196   }
00197 
00198   inline iBase_TagHandle ExtrudeMesh::extrude_tag()
00199   {
00200     return extrudeTag;
00201   }
00202 
00203   inline void ExtrudeMesh::reset_sets()
00204   {
00205     extrudeSets.clear();
00206     copySets.clear();
00207     expandSets.clear();
00208   }
00209 
00210   inline CESets &ExtrudeMesh::copy_sets()
00211   {
00212     return copySets;
00213   }
00214 
00215   inline CESets &ExtrudeMesh::expand_sets()
00216   {
00217     return expandSets;
00218   }
00219 
00220   inline CESets &ExtrudeMesh::extrude_sets()
00221   {
00222     return extrudeSets;
00223   }
00224 
00225   inline void
00226   ExtrudeMesh::connect_up_dots(iBase_EntityHandle *src, int size,
00227                                iBase_TagHandle local_tag, int *norms, int *inds,
00228                                int *offs, iBase_EntityHandle *pre,
00229                                iBase_EntityHandle *post)
00230   {
00231     connect_up_dots(src, size, local_tag,
00232                     norms, inds, offs, pre,
00233                     norms, inds, offs, post);
00234   }
00235 
00236 } // namespace MeshKit
00237 #endif
00238 
00239 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines