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