Salome HOME
Implementation of planar symmetry + aggregation methods for MEDFileData+MEDFileUMesh
[tools/medcoupling.git] / src / MEDLoader / MEDFileMesh.hxx
index b29871d368de58aa9a6ac7c745a0fec197a66ee5..1e0f48bb2cb855431ca99f80bc00a7b91dba18ef 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@
 #include <map>
 #include <list>
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
   class MEDFileFieldGlobsReal;
   class MEDFileField1TSStructItem;
@@ -45,7 +45,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0;
-    MEDLOADER_EXPORT virtual MEDFileMesh *deepCpy() const = 0;
+    MEDLOADER_EXPORT virtual MEDFileMesh *deepCopy() const = 0;
     MEDLOADER_EXPORT virtual MEDFileMesh *shallowCpy() const = 0;
     MEDLOADER_EXPORT virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
     MEDLOADER_EXPORT virtual void clearNonDiscrAttributes() const;
@@ -67,8 +67,8 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT double getTimeValue() const { return _time; }
     MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
     MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
-    MEDLOADER_EXPORT void setAxType(MEDCouplingAxisType at) { _axis_type=at; }
-    MEDLOADER_EXPORT MEDCouplingAxisType getAxType() const { return _axis_type; }
+    MEDLOADER_EXPORT void setAxisType(MEDCouplingAxisType at) { _axis_type=at; }
+    MEDLOADER_EXPORT MEDCouplingAxisType getAxisType() const { return _axis_type; }
     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
     MEDLOADER_EXPORT virtual int getNumberOfNodes() const = 0;
     MEDLOADER_EXPORT virtual int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const = 0;
@@ -204,7 +204,7 @@ namespace ParaMEDMEM
     void getFamilyRepr(std::ostream& oss) const;
     virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
     virtual void changeFamilyIdArr(int oldId, int newId) = 0;
-    virtual std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const = 0;
+    virtual std::list< MCAuto<DataArrayInt> > getAllNonNullFamilyIds() const = 0;
     virtual void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) = 0;
     void loadLLWithAdditionalItems(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
     void addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr);
@@ -231,8 +231,8 @@ namespace ParaMEDMEM
     bool _univ_wr_status;
     std::string _desc_name;
     MEDCouplingAxisType _axis_type;
-    MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
-    MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> _equiv;
+    MCAuto<MEDFileJoints> _joints;
+    MCAuto<MEDFileEquivalences> _equiv;
   protected:
     std::map<std::string, std::vector<std::string> > _groups;
     std::map<std::string,int> _families;
@@ -252,9 +252,12 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
-    MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
-    MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
+    MEDLOADER_EXPORT MEDFileUMesh *deepCopy() const;
+    MEDLOADER_EXPORT MEDFileUMesh *shallowCpy() const;
     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
+    MEDLOADER_EXPORT void checkConsistency() const;
+    MEDLOADER_EXPORT void checkSMESHConsistency() const;
+    MEDLOADER_EXPORT void clearNodeAndCellNumbers();
     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
     MEDLOADER_EXPORT void setName(const std::string& name);
     //
@@ -296,6 +299,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
     MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
     MEDLOADER_EXPORT std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
+    MEDLOADER_EXPORT std::vector< std::pair<int,int> > getAllDistributionOfTypes() const;
     MEDLOADER_EXPORT MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const;
     MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const;
     MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const;
@@ -309,6 +313,7 @@ namespace ParaMEDMEM
     //
     MEDLOADER_EXPORT void setFamilyNameAttachedOnId(int id, const std::string& newFamName);
     MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords);
+    MEDLOADER_EXPORT void setCoordsForced(DataArrayDouble *coords);
     MEDLOADER_EXPORT void eraseGroupsAtLevel(int meshDimRelToMaxExt);
     MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr);
     MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr);
@@ -326,14 +331,18 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT void buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified);
     MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
     MEDLOADER_EXPORT DataArrayInt *zipCoords();
+    MEDLOADER_EXPORT DataArrayInt *deduceNodeSubPartFromCellSubPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef) const;
+    MEDLOADER_EXPORT MEDFileUMesh *extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef) const;
     MEDLOADER_EXPORT MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const;
     MEDLOADER_EXPORT MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const;
     MEDLOADER_EXPORT MEDFileUMesh *quadraticToLinear(double eps=1e-12) const;
+    MEDLOADER_EXPORT MCAuto<MEDFileUMesh> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
+    MEDLOADER_EXPORT static MCAuto<MEDFileUMesh> Aggregate(const std::vector<const MEDFileUMesh *>& meshes);
     // serialization
     MEDLOADER_EXPORT void serialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
-                                    std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
+                                    std::vector< MCAuto<DataArrayInt> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD);
     MEDLOADER_EXPORT void unserialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
-                                      std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
+                                      std::vector< MCAuto<DataArrayInt> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD);
   private:
     MEDLOADER_EXPORT ~MEDFileUMesh();
     void writeLL(med_idt fid) const;
@@ -349,16 +358,16 @@ namespace ParaMEDMEM
     void computeRevNum() const;
     void synchronizeTinyInfoOnLeaves() const;
     void changeFamilyIdArr(int oldId, int newId);
-    std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
-    MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m);
+    std::list< MCAuto<DataArrayInt> > getAllNonNullFamilyIds() const;
+    MCAuto<MEDFileUMeshSplitL1>& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m);
   private:
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
-    mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
-    MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
+    std::vector< MCAuto<MEDFileUMeshSplitL1> > _ms;
+    MCAuto<DataArrayDouble> _coords;
+    MCAuto<DataArrayInt> _fam_coords;
+    MCAuto<DataArrayInt> _num_coords;
+    MCAuto<DataArrayAsciiChar> _name_coords;
+    mutable MCAuto<DataArrayInt> _rev_num_coords;
+    MCAuto<PartDefinition> _part_coords;
   };
 
   class MEDFileStructuredMesh : public MEDFileMesh
@@ -407,7 +416,7 @@ namespace ParaMEDMEM
   protected:
     ~MEDFileStructuredMesh() { }
     void changeFamilyIdArr(int oldId, int newId);
-    std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
+    std::list< MCAuto<DataArrayInt> > getAllNonNullFamilyIds() const;
     void deepCpyAttributes();
     void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
     void writeStructuredLL(med_idt fid, const std::string& maa) const;
@@ -416,20 +425,20 @@ namespace ParaMEDMEM
     static med_geometry_type GetGeoTypeFromMeshDim(int meshDim);
   private:
     static void LoadStrMeshDAFromFile(med_idt fid, int meshDim, int dt, int it, const std::string& mName, MEDFileMeshReadSelector *mrs,
-                                      MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& famCells, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& numCells, MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar>& namesCells);
+                                      MCAuto<DataArrayInt>& famCells, MCAuto<DataArrayInt>& numCells, MCAuto<DataArrayAsciiChar>& namesCells);
   private:
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_nodes;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_nodes;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_nodes;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_cells;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_cells;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_cells;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_faces;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_faces;
-    MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_faces;
-    mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_nodes;
-    mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_cells;
-    mutable MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> _faces_if_necessary;
+    MCAuto<DataArrayInt> _fam_nodes;
+    MCAuto<DataArrayInt> _num_nodes;
+    MCAuto<DataArrayAsciiChar> _names_nodes;
+    MCAuto<DataArrayInt> _fam_cells;
+    MCAuto<DataArrayInt> _num_cells;
+    MCAuto<DataArrayAsciiChar> _names_cells;
+    MCAuto<DataArrayInt> _fam_faces;
+    MCAuto<DataArrayInt> _num_faces;
+    MCAuto<DataArrayAsciiChar> _names_faces;
+    mutable MCAuto<DataArrayInt> _rev_num_nodes;
+    mutable MCAuto<DataArrayInt> _rev_num_cells;
+    mutable MCAuto<MEDCoupling1SGTUMesh> _faces_if_necessary;
   };
 
   class MEDFileCMesh : public MEDFileStructuredMesh
@@ -442,8 +451,8 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
-    MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
-    MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
+    MEDLOADER_EXPORT MEDFileCMesh *deepCopy() const;
+    MEDLOADER_EXPORT MEDFileCMesh *shallowCpy() const;
     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
     MEDLOADER_EXPORT int getMeshDimension() const;
     MEDLOADER_EXPORT int getSpaceDimension() const;
@@ -462,7 +471,7 @@ namespace ParaMEDMEM
     MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
     void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
   private:
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
+    MCAuto<MEDCouplingCMesh> _cmesh;
   };
 
   class MEDFileCurveLinearMesh : public MEDFileStructuredMesh
@@ -475,8 +484,8 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
-    MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
-    MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
+    MEDLOADER_EXPORT MEDFileCurveLinearMesh *deepCopy() const;
+    MEDLOADER_EXPORT MEDFileCurveLinearMesh *shallowCpy() const;
     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
     MEDLOADER_EXPORT int getMeshDimension() const;
     MEDLOADER_EXPORT std::string simpleRepr() const;
@@ -494,7 +503,7 @@ namespace ParaMEDMEM
     void writeLL(med_idt fid) const;
     void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
   private:
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
+    MCAuto<MEDCouplingCurveLinearMesh> _clmesh;
   };
 
   class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
@@ -503,7 +512,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New();
     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName);
     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName);
-    MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCpy() const;
+    MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCopy() const;
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT std::string getName() const;
@@ -523,7 +532,7 @@ namespace ParaMEDMEM
     MEDFileMeshMultiTS(const std::string& fileName);
     MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName);
   private:
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
+    std::vector< MCAuto<MEDFileMesh> > _mesh_one_ts;
   };
 
   class MEDFileMeshesIterator;
@@ -533,7 +542,7 @@ namespace ParaMEDMEM
   public:
     MEDLOADER_EXPORT static MEDFileMeshes *New();
     MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName);
-    MEDLOADER_EXPORT MEDFileMeshes *deepCpy() const;
+    MEDLOADER_EXPORT MEDFileMeshes *deepCopy() const;
     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDLOADER_EXPORT std::string simpleRepr() const;
@@ -554,12 +563,12 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT void destroyMeshAtPos(int i);
   private:
     ~MEDFileMeshes() { }
-    void checkCoherency() const;
+    void checkConsistencyLight() const;
     void loadFromFile(const std::string& fileName);
     MEDFileMeshes();
     MEDFileMeshes(const std::string& fileName);
   private:
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
+    std::vector< MCAuto<MEDFileMeshMultiTS> > _meshes;
   };
 
   class MEDFileMeshesIterator
@@ -569,7 +578,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT ~MEDFileMeshesIterator();
     MEDLOADER_EXPORT MEDFileMesh *nextt();
   private:
-    MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _ms;
+    MCAuto<MEDFileMeshes> _ms;
     int _iter_id;
     int _nb_iter;
   };