MeshKit  1.0
CopyMesh.hpp
Go to the documentation of this file.
00001 #ifndef MESHKIT_COPY_MESH_HPP
00002 #define MESHKIT_COPY_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 namespace MeshKit {
00019 
00020   class MKCore;
00021 
00022 
00038   class CopyMesh : public MeshScheme
00039   {
00040   public:
00042     CopyMesh(MKCore *mkcore, const MEntVector &me_vec);
00043 
00045     virtual ~CopyMesh();
00046 
00048     static const char* name();
00049 
00054     static bool can_mesh(iBase_EntityType dim);
00055 
00062     static bool can_mesh(ModelEnt *me);
00063 
00067     static const moab::EntityType* output_types();
00068 
00072     virtual const moab::EntityType* mesh_types_arr() const;
00073 
00077     virtual bool add_modelent(ModelEnt *model_ent);
00078 
00080     virtual void setup_this();
00081 
00083     virtual void execute_this();
00084 
00085     // CopyMesh function local //////////////////
00086 
00087     /* \brief Return the copyTag used to indicate set copies
00088      */
00089     iBase_TagHandle copy_tag();
00090 
00091     void set_transform(const Copy::Transform &transform);
00092 
00093     void update_sets();
00094 
00095     /* \brief Reset the copy and expand set lists
00096      */
00097     void reset_sets();
00098 
00099     /* \brief Return reference to copy sets
00100      */
00101     CESets &copy_sets();
00102 
00103     /* \brief Return reference to expand sets
00104      */
00105     CESets &expand_sets();
00106 
00107     /* \brief Tag copied sets with indicated tag from original set
00108      */
00109     void tag_copied_sets(const char **tag_names, const char **tag_vals,
00110                          const int num_tags);
00111 
00112     /* \brief Tag copied sets with indicated tag from original set
00113      */
00114     void tag_copied_sets(iMesh::TagHandle *tags, const char **tag_vals,
00115                          const int num_tags);
00116   private:
00117     void do_copy(iMesh::EntitySetHandle set_handle);
00118 
00119     //- get the copy/expand sets based on copy/expand tags
00120     void get_copy_expand_sets(iMesh::EntitySetHandle *&copy_sets,
00121                               int &num_copy_sets,
00122                               iMesh::EntitySetHandle *&expand_sets,
00123                               int &num_expand_sets);
00124 
00125     //- get the sets tagged with the given vector of tags/values
00126     void get_tagged_sets(iMesh::EntitySetHandle from_set,
00127                          iMesh::TagHandle *tag_handles,
00128                          const char **tag_vals,
00129                          int num_tags,
00130                          iMesh::EntitySetHandle *&tagged_sets,
00131                          int &num_tagged_sets);
00132 
00133     // - get structure
00134     int getStructure(iMesh_Instance instance,
00135                      iBase_EntitySetHandle set,
00136                      std::vector<iBase_EntityHandle> &ents,
00137                      std::vector<iBase_EntityHandle> &unique_adj,
00138                      std::vector<int> &indices,
00139                      std::vector<int> &offsets);
00140 
00141     iMesh *mesh;                // mesh instance
00142     LocalTag copyTag;           // tag storing copy-to tag
00143     Copy::Transform *transform; // transform function for copy-move
00144 
00145     CESets copySets;
00146     CESets expandSets;
00147   };
00148 
00163   void connect_the_dots(iMesh *mesh, iBase_TagHandle local_tag,
00164                         const std::vector<iBase_EntityHandle> &ents,
00165                         const std::vector<int> &indices,
00166                         const std::vector<int> &offsets,
00167                         const std::vector<iBase_EntityHandle> &verts);
00168 
00169   inline const char* CopyMesh::name()
00170   {
00171     return "CopyMesh";
00172   }
00173 
00174   inline bool CopyMesh::can_mesh(iBase_EntityType)
00175   {
00176     // Given just a dimension, CopyMesh can't do anything since it doesn't know
00177     // what to copy.
00178     return false;
00179   }
00180 
00181   inline bool CopyMesh::can_mesh(ModelEnt *)
00182   {
00183     return true;
00184   }
00185 
00186   inline const moab::EntityType* CopyMesh::mesh_types_arr() const
00187   {
00188     return output_types();
00189   }
00190 
00191   inline void CopyMesh::set_transform(const Copy::Transform &trans)
00192   {
00193     delete transform;
00194     transform = trans.clone();
00195   }
00196 
00197   inline iBase_TagHandle CopyMesh::copy_tag()
00198   {
00199     return copyTag;
00200   }
00201 
00202   inline void CopyMesh::reset_sets()
00203   {
00204     copySets.clear();
00205     expandSets.clear();
00206   }
00207 
00208   inline CESets &CopyMesh::copy_sets()
00209   {
00210     return copySets;
00211   }
00212 
00213   inline CESets &CopyMesh::expand_sets()
00214   {
00215     return expandSets;
00216   }
00217 } // namespace MeshKit
00218 #endif
00219 
00220 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines