Salome HOME
Target MEDReader
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingStructuredMesh.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
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.
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 __PARAMEDMEM_MEDCOUPLINGSTRUCTUREDMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGSTRUCTUREDMESH_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingMesh.hxx"
26
27 namespace ParaMEDMEM
28 {
29   class MEDCoupling1SGTUMesh;
30
31   class MEDCOUPLING_EXPORT MEDCouplingStructuredMesh : public MEDCouplingMesh
32   {
33   public:
34     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
35     std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
36     int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
37     DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
38     DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
39     DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
40     static void GetPosFromId(int nodeId, int meshDim, const int *split, int *res);
41     static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
42     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
43     std::size_t getHeapMemorySize() const;
44     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
45     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
46     //tools
47     std::vector<int> getDistributionOfTypes() const throw(INTERP_KERNEL::Exception);
48     DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
49     void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
50     MEDCoupling1SGTUMesh *build1SGTUnstructured() const throw(INTERP_KERNEL::Exception);
51     MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
52     MEDCouplingMesh *buildPart(const int *start, const int *end) const;
53     MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
54     DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
55     MEDCouplingFieldDouble *buildOrthogonalField() const;
56     //some useful methods
57     int getCellIdFromPos(int i, int j, int k) const;
58     int getNodeIdFromPos(int i, int j, int k) const;
59     virtual void getNodeGridStructure(int *res) const = 0;
60     virtual void getSplitCellValues(int *res) const = 0;
61     virtual void getSplitNodeValues(int *res) const = 0;
62     virtual std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception) = 0;
63     std::vector<int> getCellGridStructure() const throw(INTERP_KERNEL::Exception);
64     virtual MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const throw(INTERP_KERNEL::Exception) = 0;
65     static bool IsPartStructured(const int *startIds, const int *stopIds, const std::vector<int>& st, std::vector< std::pair<int,int> >& partCompactFormat) throw(INTERP_KERNEL::Exception);
66     static DataArrayInt *BuildExplicitIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat) throw(INTERP_KERNEL::Exception);
67     static DataArrayInt *Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd) throw(INTERP_KERNEL::Exception);
68   private:
69     static DataArrayInt *Build1GTNodalConnectivity1D(const int *nodeStBg) throw(INTERP_KERNEL::Exception);
70     static DataArrayInt *Build1GTNodalConnectivity2D(const int *nodeStBg) throw(INTERP_KERNEL::Exception);
71     static DataArrayInt *Build1GTNodalConnectivity3D(const int *nodeStBg) throw(INTERP_KERNEL::Exception);
72   protected:
73     MEDCouplingStructuredMesh();
74     MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy);
75     ~MEDCouplingStructuredMesh();
76   };
77 }
78
79 #endif