Back to index

salome-med  6.5.0
MEDMEM_MeshFuse.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 // File      : MEDMEM_MeshFuse.hxx
00020 // Created   : Tue Jul  7 17:04:38 2009
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 #ifndef __MEDMEM_MeshFuse_HXX__
00024 #define __MEDMEM_MeshFuse_HXX__
00025 
00026 #include "MEDMEM_Meshing.hxx"
00027 
00028 #include <vector>
00029 #include <map>
00030 #include <set>
00031 
00032 namespace MEDMEM
00033 {
00037   class MEDMEM_EXPORT MeshFuse : public MESHING
00038   {
00039   public:
00040     MeshFuse();
00041     virtual ~MeshFuse();
00042 
00043     void concatenate( const MESH* mesh, const std::vector<int>& node_glob_numbers );
00044 
00045     // unite glob_numbers and add_glob_numbers 
00046     void append( MED_EN::medEntityMesh   entity,
00047                  std::vector<int>&       glob_numbers,
00048                  const std::vector<int>& add_glob_numbers );
00049 
00050     // if MeshFuse is filled via MESHING
00051     void setNodeNumbers( const std::vector<int>& node_glob_numbers );
00052 
00053     // return number collected during all concatenate()s
00054     const std::vector<int> & getNodeNumbers() const { return _node_glob_numbers; }
00055 
00056   private:
00057 
00058     int makeNewNodeIds(const std::vector<int>& node_glob_numbers);
00059 
00060     void expandCoordinates(int final_nb_nodes);
00061 
00062     void expandConnectivity(int final_nb_nodes);
00063 
00064     void updateNodeIds( CONNECTIVITY* connectivity );
00065 
00066     struct TConnData
00067     {
00068       int _nb_elems;
00069       std::vector< int > _connectivity, _index;
00070 
00071       TConnData(): _nb_elems(0) {}
00072     };
00073 
00074     int appendConnectivity( TConnData&                 data,
00075                             const MESH*                mesh,
00076                             MED_EN::medEntityMesh      entity,
00077                             MED_EN::medGeometryElement type);
00078 
00079     template< class TSUPPORT >
00080     TSUPPORT* updateOldSupport(TSUPPORT* support) const;
00081 
00082     template< class TSUPPORT >
00083     TSUPPORT* makeSupport(const TSUPPORT* add_support, TSUPPORT* same_name_support);
00084 
00085     void expandSupports();
00086 
00087     int getElemNbShift( const MED_EN::medEntityMesh& entity,
00088                         MED_EN::medGeometryElement   type,
00089                         int which, bool prev ) const;
00090 
00091     void uniteSupportElements(const SUPPORT*             add_support,
00092                               SUPPORT*                   old_support,
00093                               MED_EN::medGeometryElement type,
00094                               std::vector<int> &         elements);
00095 
00096     void makeNewElemIds(MED_EN::medEntityMesh      entity,
00097                         MED_EN::medGeometryElement type,
00098                         std::vector< int > &       new_ids);
00099 
00100     void findEqualOldElements(MED_EN::medEntityMesh      entity,
00101                               MED_EN::medGeometryElement type,
00102                               std::vector< int > &       old_ids);
00103 
00104   private:
00105 
00106     const MESH* _mesh; // mesh to add
00107 
00108     std::vector<int> _node_glob_numbers; // global numbers of nodes
00109 
00110     // local ids of merged entities (whose all nodes are merged) of the added mesh
00111     std::map< MED_EN::medGeometryElement, std::vector<int> > _merged_of_type;
00112     // and corresponding ids of EQUAL elements (if any) of OLD mesh
00113     std::map< MED_EN::medGeometryElement, std::vector<int> > _equalo_of_type;
00114 
00115     // ids in final mesh of added elements of a geom type filled in case of double elements
00116     std::map< MED_EN::medGeometryElement, std::vector<int> > _new_elem_ids_of_type;
00117 
00118     // global numbering index by type:
00119     // - of old mesh before addition
00120     // - of added mesh before addition
00121     // - of mesh added (taking merging into account)
00122     enum { INIT_OLD=0, INIT_ADD, RSLT_ADD, NB_INDICES };
00123     typedef std::map< MED_EN::medGeometryElement, int > TNbOfGeom;
00124     vector< TNbOfGeom > _nb_index[NB_INDICES]; // for each entity
00125 
00126   };
00127 }
00128 
00129 #endif