Salome HOME
d80a3e2a33b2db6d64582d2ebc871741168ea650
[modules/med.git] / src / MEDCoupling / MEDCouplingCMesh.hxx
1 // Copyright (C) 2007-2012  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
20 #ifndef __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
22
23 #include "MEDCoupling.hxx"
24 #include "MEDCouplingMesh.hxx"
25
26 namespace ParaMEDMEM
27 {
28   class DataArrayDouble;
29   class MEDCouplingUMesh;
30
31   class MEDCOUPLING_EXPORT MEDCouplingCMesh : public MEDCouplingMesh
32   {
33   public:
34     static MEDCouplingCMesh *New();
35     static MEDCouplingCMesh *New(const char *meshName);
36     MEDCouplingMesh *deepCpy() const;
37     MEDCouplingCMesh *clone(bool recDeepCpy) const;
38     void updateTime() const;
39     MEDCouplingMeshType getType() const { return CARTESIAN; }
40     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
41     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
42     bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
43     void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
44                               DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
45     void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
46                                          DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
47     void checkCoherency() const throw(INTERP_KERNEL::Exception);
48     void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
49     void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
50     int getNumberOfCells() const;
51     int getNumberOfNodes() const;
52     int getSpaceDimension() const;
53     int getMeshDimension() const;
54     int getCellIdFromPos(int i, int j, int k) const;
55     int getNodeIdFromPos(int i, int j, int k) const;
56     static void GetPosFromId(int nodeId, int spaceDim, const int *split, int *res);
57     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
58     std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
59     int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
60     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
61     void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
62     std::string simpleRepr() const;
63     std::string advancedRepr() const;
64     const DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
65     DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception);
66     void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
67     void setCoords(const DataArrayDouble *coordsX,
68                    const DataArrayDouble *coordsY=0,
69                    const DataArrayDouble *coordsZ=0);
70     // tools
71     std::vector<int> getDistributionOfTypes() const throw(INTERP_KERNEL::Exception);
72     DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
73     void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
74     MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
75     MEDCouplingMesh *buildPart(const int *start, const int *end) const;
76     MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
77     DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
78     void getBoundingBox(double *bbox) const;
79     MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
80     MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
81     MEDCouplingFieldDouble *buildOrthogonalField() const;
82     int getCellContainingPoint(const double *pos, double eps) const;
83     void rotate(const double *center, const double *vector, double angle);
84     void translate(const double *vector);
85     void scale(const double *point, double factor);
86     MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
87     DataArrayDouble *getCoordinatesAndOwner() const;
88     DataArrayDouble *getBarycenterAndOwner() const;
89     void renumberCells(const int *old2NewBg, bool check=true) throw(INTERP_KERNEL::Exception);
90     void fill1DUnstructuredMesh(MEDCouplingUMesh *m) const;
91     void fill2DUnstructuredMesh(MEDCouplingUMesh *m) const;
92     void fill3DUnstructuredMesh(MEDCouplingUMesh *m) const;
93     //some useful methods
94     void getSplitCellValues(int *res) const;
95     void getSplitNodeValues(int *res) const;
96     //serialisation-unserialization
97     void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
98     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
99     void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
100     void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
101                          const std::vector<std::string>& littleStrings);
102   private:
103     MEDCouplingCMesh();
104     MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy);
105     ~MEDCouplingCMesh();
106     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
107     std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
108   private:
109     DataArrayDouble *_x_array;
110     DataArrayDouble *_y_array;
111     DataArrayDouble *_z_array;
112   };
113 }
114
115 #endif