1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingMesh.hxx"
32 class DataArrayDouble;
33 class MEDCouplingUMesh;
34 class MEDCouplingFieldDouble;
36 class MEDCouplingExtrudedMesh : public MEDCouplingMesh
39 MEDCOUPLING_EXPORT static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId);
40 MEDCOUPLING_EXPORT static MEDCouplingExtrudedMesh *New();
41 MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const;
42 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
43 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
44 MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
45 MEDCOUPLING_EXPORT int getNumberOfCells() const;
46 MEDCOUPLING_EXPORT int getNumberOfNodes() const;
47 MEDCOUPLING_EXPORT int getSpaceDimension() const;
48 MEDCOUPLING_EXPORT int getMeshDimension() const;
49 MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
50 MEDCouplingExtrudedMesh *clone(bool recDeepCpy) const;
51 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
52 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
53 MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
54 DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const;
55 MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
56 DataArrayInt *&cellCor) const;
57 MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
58 MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
59 MEDCOUPLING_EXPORT DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
60 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const;
61 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const;
62 MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const;
63 MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
64 MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
65 MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
66 MEDCOUPLING_EXPORT std::string simpleRepr() const;
67 MEDCOUPLING_EXPORT std::string advancedRepr() const;
68 MEDCOUPLING_EXPORT void checkCoherency() const;
69 MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
70 MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
71 MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
72 MEDCOUPLING_EXPORT void updateTime() const;
73 MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
74 MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh2D() const { return _mesh2D; }
75 MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh1D() const { return _mesh1D; }
76 MEDCOUPLING_EXPORT DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; }
77 MEDCOUPLING_EXPORT MEDCouplingUMesh *build3DUnstructuredMesh() const;
78 MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
79 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool) const;
80 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
81 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
82 MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
83 MEDCOUPLING_EXPORT static int FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
84 const int *revNodalPtr, const int *revNodalIndxPtr);
85 MEDCOUPLING_EXPORT static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
86 MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v);
87 MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
88 MEDCOUPLING_EXPORT void translate(const double *vector);
89 MEDCOUPLING_EXPORT void scale(const double *point, double factor);
90 MEDCOUPLING_EXPORT std::vector<int> getDistributionOfTypes() const;
91 MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
92 MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const;
93 MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const int *start, const int *end) const;
94 MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
95 MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy);
96 MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
97 MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
98 MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
99 MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
100 MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
101 //Serialization unserialisation
102 MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
103 MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
104 MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
105 MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
106 const std::vector<std::string>& littleStrings);
107 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
108 MEDCOUPLING_EXPORT std::string getVTKFileExtension() const;
110 MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId);
111 MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh& other, bool deepCopy);
112 MEDCouplingExtrudedMesh();
113 void computeExtrusion(const MEDCouplingUMesh *mesh3D);
114 void computeExtrusionAlg(const MEDCouplingUMesh *mesh3D);
115 void build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh,
116 const int *desc3D, const int *descIndx3D,
117 const int *revDesc3D, const int *revDescIndx3D,
119 int findOppositeFaceOf(int current2DCell, int current3DCell, const std::vector<int>& connSorted,
120 const int *desc3D, const int *descIndx3D,
121 const int *conn2D, const int *conn2DIndx);
122 void computeBaryCenterOfFace(const std::vector<int>& nodalConnec, int lev1DId);
123 ~MEDCouplingExtrudedMesh();
124 void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
125 std::string getVTKDataSetType() const;
127 MEDCouplingUMesh *_mesh2D;
128 MEDCouplingUMesh *_mesh1D;
129 //! New to old 3D cell Ids Array
130 DataArrayInt *_mesh3D_ids;