Salome HOME
625a85293262acf3d16e7ea4aa356b779f254529
[tools/medcoupling.git] / src / MEDLoader / MEDFileMeshElt.hxx
1 // Copyright (C) 2007-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDFILEMESHELT_HXX__
22 #define __MEDFILEMESHELT_HXX__
23
24 #include "MEDCouplingMemArray.hxx"
25 #include "MEDCoupling1GTUMesh.hxx"
26 #include "MEDCouplingPartDefinition.hxx"
27 #include "MCAuto.hxx"
28
29 #include "NormalizedUnstructuredMesh.hxx"
30
31 #include "med.h"
32
33 namespace MEDCoupling
34 {
35   class MEDCouplingUMesh;
36   class MEDFileMeshReadSelector;
37
38   class MEDFileUMeshPerTypeCommon : public RefCountObject
39   {
40   public:
41     static MEDFileUMeshPerTypeCommon *New();
42     std::string getClassName() const override { return std::string("MEDFileUMeshPerTypeCommon"); }
43     void loadCommonPart(med_idt fid, const char *mName, int dt, int it, mcIdType curNbOfElem, med_geometry_type geoElt,
44                         med_entity_type entity, MEDFileMeshReadSelector *mrs);
45     std::size_t getHeapMemorySizeWithoutChildren() const;
46     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
47     const DataArrayIdType *getFam() const { return _fam; }
48     const DataArrayIdType *getNum() const { return _num; }
49     const DataArrayAsciiChar *getNames() const { return _names; }
50   protected:
51     MCAuto<DataArrayIdType> _num;
52     MCAuto<DataArrayIdType> _fam;
53     MCAuto<DataArrayAsciiChar> _names;
54   };
55
56   class MEDFileUMeshPerType : public MEDFileUMeshPerTypeCommon
57   {
58   public:
59     static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs);
60     static MEDFileUMeshPerType *NewPart(med_idt fid, const char *mName, int dt, int it, int mdim, INTERP_KERNEL::NormalizedCellType geoElt2, mcIdType strt, mcIdType stp, mcIdType step, MEDFileMeshReadSelector *mrs);
61     static MEDFileUMeshPerType *NewPart(med_idt fid, const char *mName, int dt, int it, int mdim, INTERP_KERNEL::NormalizedCellType geoElt2, const std::vector<mcIdType>& distrib, MEDFileMeshReadSelector *mrs);
62
63     std::string getClassName() const override { return std::string("MEDFileUMeshPerType"); }
64     static bool isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity);
65     std::size_t getHeapMemorySizeWithoutChildren() const;
66     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
67     int getDim() const;
68     MEDCoupling1GTUMesh *getMesh() const { return const_cast<MEDCoupling1GTUMesh *>((const MEDCoupling1GTUMesh *)_m); }
69     const PartDefinition *getPartDef() const { return _pd; }
70     static void Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayIdType *fam, const DataArrayIdType *num, const DataArrayAsciiChar *names);
71   private:
72     MEDFileUMeshPerType();
73     MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
74                         med_entity_type entity, MEDFileMeshReadSelector *mrs);
75     void loadPart(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
76                   med_entity_type entity, mcIdType strt, mcIdType end, mcIdType step, MEDFileMeshReadSelector *mrs);
77     void loadPart(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
78                   med_entity_type entity, const std::vector<mcIdType>& distrib, MEDFileMeshReadSelector *mrs);
79     void loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
80                             med_entity_type entity, MEDFileMeshReadSelector *mrs);
81     void loadPartStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
82                             med_entity_type entity, MEDFileMeshReadSelector *mrs);
83     void loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType arraySize, med_geometry_type geoElt,
84                    med_entity_type entity, MEDFileMeshReadSelector *mrs);
85     void loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType connFaceLgth, med_geometry_type geoElt,
86                    med_entity_type entity, MEDFileMeshReadSelector *mrs);
87     void loadPartOfCellCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
88
89   private:
90     MCAuto<MEDCoupling1GTUMesh> _m;
91     MCAuto<PartDefinition> _pd;
92   };
93 }
94 #endif