Salome HOME
0a503fe974475e92cbf87660f9142ea4c966df5a
[modules/med.git] / src / MEDCoupling / MEDCouplingCMesh.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_MEDCOUPLINGCMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingStructuredMesh.hxx"
26
27 namespace ParaMEDMEM
28 {
29   class DataArrayDouble;
30   class MEDCouplingUMesh;
31
32   class MEDCouplingCMesh : public MEDCouplingStructuredMesh
33   {
34   public:
35     MEDCOUPLING_EXPORT static MEDCouplingCMesh *New();
36     MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(const std::string& meshName);
37     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
38     MEDCOUPLING_EXPORT MEDCouplingCMesh *clone(bool recDeepCpy) const;
39     MEDCOUPLING_EXPORT void updateTime() const;
40     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
41     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
42     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return CARTESIAN; }
43     MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
44     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
45     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
46     MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
47                                                  DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
48     MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
49                                                             DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
50     MEDCOUPLING_EXPORT void checkCoherency() const;
51     MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
52     MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
53     MEDCOUPLING_EXPORT int getNumberOfCells() const;
54     MEDCOUPLING_EXPORT int getNumberOfNodes() const;
55     MEDCOUPLING_EXPORT int getSpaceDimension() const;
56     MEDCOUPLING_EXPORT int getMeshDimension() const;
57     MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
58     MEDCOUPLING_EXPORT std::string simpleRepr() const;
59     MEDCOUPLING_EXPORT std::string advancedRepr() const;
60     MEDCOUPLING_EXPORT const DataArrayDouble *getCoordsAt(int i) const;
61     MEDCOUPLING_EXPORT DataArrayDouble *getCoordsAt(int i);
62     MEDCOUPLING_EXPORT void setCoordsAt(int i, const DataArrayDouble *arr);
63     MEDCOUPLING_EXPORT void setCoords(const DataArrayDouble *coordsX,
64                                       const DataArrayDouble *coordsY=0,
65                                       const DataArrayDouble *coordsZ=0);
66     // tools
67     MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
68     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
69     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
70     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
71     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
72     MEDCOUPLING_EXPORT void translate(const double *vector);
73     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
74     MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
75     MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
76     MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
77     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
78     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
79     //some useful methods
80     MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const;
81     MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const;
82     MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
83     MEDCOUPLING_EXPORT std::vector<int> getNodeGridStructure() const;
84     MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
85     //serialisation-unserialization
86     MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
87     MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
88     MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
89     MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
90                                             const std::vector<std::string>& littleStrings);
91     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
92   private:
93     MEDCouplingCMesh();
94     MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy);
95     ~MEDCouplingCMesh();
96     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
97     std::string getVTKDataSetType() const;
98   private:
99     DataArrayDouble *_x_array;
100     DataArrayDouble *_y_array;
101     DataArrayDouble *_z_array;
102   };
103 }
104
105 #endif