Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingCurveLinearMesh.hxx
1 // Copyright (C) 2007-2020  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, or (at your option) any later version.
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 "MCAuto.hxx"
27
28 namespace MEDCoupling
29 {
30   class MEDCouplingCurveLinearMesh : public MEDCouplingStructuredMesh
31   {
32   public:
33     MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New();
34     MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New(const std::string& meshName);
35     MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingCurveLinearMesh"); }
36     MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *deepCopy() const;
37     MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
38     MEDCOUPLING_EXPORT void updateTime() const;
39     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
40     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
41     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return CURVE_LINEAR; }
42     MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
43     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
44     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
45     MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
46                                                  DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const;
47     MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
48                                                             DataArrayIdType *&cellCor) const;
49     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
50     MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const;
51     MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const;
52     MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const;
53     MEDCOUPLING_EXPORT int getSpaceDimension() const;
54     MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector<double>& coo) const;
55     MEDCOUPLING_EXPORT std::string simpleRepr() const;
56     MEDCOUPLING_EXPORT std::string advancedRepr() const;
57     MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const;
58     MEDCOUPLING_EXPORT DataArrayDouble *getCoords();
59     MEDCOUPLING_EXPORT const DataArrayDouble *getCoords() const;
60     MEDCOUPLING_EXPORT void setCoords(const DataArrayDouble *coords);
61     MEDCOUPLING_EXPORT void setNodeGridStructure(const mcIdType *gridStructBg, const mcIdType *gridStructEnd);
62     MEDCOUPLING_EXPORT std::vector<mcIdType> getNodeGridStructure() const;
63     MEDCOUPLING_EXPORT MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<mcIdType,mcIdType> >& cellPart) const;
64     // tools
65     MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
66     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
67     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
68     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
69     MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const;
70     MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) 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 *computeCellCenterOfMass() const;
77     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
78     MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true);
79     //some useful methods
80     MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const;
81     //serialisation-unserialization
82     MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<mcIdType>& tinyInfo, std::vector<std::string>& littleStrings) const;
83     MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<mcIdType>& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
84     MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const;
85     MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<mcIdType>& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2,
86                                             const std::vector<std::string>& littleStrings);
87     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
88     MEDCOUPLING_EXPORT std::string getVTKFileExtension() const;
89   private:
90     void getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const;
91     void getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const;
92     void getMeasureFieldMeshDim3(bool isAbs, MEDCouplingFieldDouble *field) const;
93     void getBarycenterAndOwnerMeshDim3(DataArrayDouble *bary) const;
94     void getBarycenterAndOwnerMeshDim2(DataArrayDouble *bary) const;
95     void getBarycenterAndOwnerMeshDim1(DataArrayDouble *bary) const;
96   private:
97     MEDCouplingCurveLinearMesh();
98     MEDCouplingCurveLinearMesh(const MEDCouplingCurveLinearMesh& other, bool deepCpy);
99     ~MEDCouplingCurveLinearMesh();
100     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
101     std::string getVTKDataSetType() const;
102   private:
103     MCAuto<DataArrayDouble> _coords;
104     std::vector<mcIdType> _structure;
105   };
106 }
107
108 #endif