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_MEDCOUPLING1GTUMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLING1GTUMESH_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingPointSet.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
29 #include "CellModel.hxx"
33 class MEDCoupling1GTUUMeshCellIterator;
35 class MEDCoupling1GTUMesh : public MEDCouplingPointSet
38 MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
39 MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const MEDCouplingUMesh *m);
40 MEDCOUPLING_EXPORT const INTERP_KERNEL::CellModel& getCellModel() const;
41 MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getCellModelEnum() const;
42 MEDCOUPLING_EXPORT int getMeshDimension() const;
43 MEDCOUPLING_EXPORT DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
44 MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
45 MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
46 MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
47 MEDCOUPLING_EXPORT std::vector<int> getDistributionOfTypes() const;
48 MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const;
49 MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
50 MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
51 MEDCOUPLING_EXPORT std::string getVTKDataSetType() const;
52 MEDCOUPLING_EXPORT std::string getVTKFileExtension() const;
54 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
55 MEDCOUPLING_EXPORT int getNodalConnectivityLength() const;
56 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
57 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
58 MEDCOUPLING_EXPORT void checkCoherency() const;
59 MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
60 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
61 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
62 MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
63 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
64 MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const;
65 MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps);
66 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
67 MEDCOUPLING_EXPORT DataArrayInt *findBoundaryNodes() const;
68 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
69 MEDCOUPLING_EXPORT void findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const;
70 MEDCOUPLING_EXPORT static MEDCouplingUMesh *AggregateOnSameCoordsToUMesh(const std::vector< const MEDCoupling1GTUMesh *>& parts);
72 MEDCOUPLING_EXPORT virtual void allocateCells(int nbOfCells=0) = 0;
73 MEDCOUPLING_EXPORT virtual void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd) = 0;
74 MEDCOUPLING_EXPORT virtual DataArrayInt *getNodalConnectivity() const = 0;
75 MEDCOUPLING_EXPORT virtual void checkCoherencyOfConnectivity() const = 0;
77 MEDCoupling1GTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
78 MEDCoupling1GTUMesh(const MEDCoupling1GTUMesh& other, bool recDeepCpy);
79 MEDCoupling1GTUMesh();
81 const INTERP_KERNEL::CellModel *_cm;
84 class MEDCoupling1DGTUMesh;
85 class MEDCouplingCMesh;
87 class MEDCoupling1SGTUMesh : public MEDCoupling1GTUMesh
90 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
91 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(const MEDCouplingUMesh *m);
92 //! useless constructor only for CORBA -> not swigged
93 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New();
94 MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *clone(bool recDeepCpy) const;
95 MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const;
96 // overload of TimeLabel and RefCountObject
97 MEDCOUPLING_EXPORT void updateTime() const;
98 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
99 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
100 // overload of MEDCouplingMesh
101 MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED; }
102 MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
103 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
104 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
105 MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const;
106 MEDCOUPLING_EXPORT void checkCoherency() const;
107 MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
108 MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
109 MEDCOUPLING_EXPORT int getNumberOfCells() const;
110 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const;
111 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const;
112 MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const;
113 MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
114 MEDCOUPLING_EXPORT std::string simpleRepr() const;
115 MEDCOUPLING_EXPORT std::string advancedRepr() const;
116 MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
117 MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
118 MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
119 MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
120 MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy);
121 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
122 // overload of MEDCouplingPointSet
123 MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other);
124 MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const;
125 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const;
126 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords2(int start, int end, int step) const;
127 MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const;
128 MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
129 MEDCOUPLING_EXPORT void checkFullyDefined() const;
130 MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
131 MEDCOUPLING_EXPORT DataArrayInt *computeFetchedNodeIds() const;
132 MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
133 MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
134 MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
135 MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
136 MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
137 MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
138 MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const;
139 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const;
140 // overload of MEDCoupling1GTUMesh
141 MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const;
142 MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0);
143 MEDCOUPLING_EXPORT void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd);
145 MEDCOUPLING_EXPORT void setNodalConnectivity(DataArrayInt *nodalConn);
146 MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const;
147 MEDCOUPLING_EXPORT int getNumberOfNodesPerCell() const;
148 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(const MEDCoupling1SGTUMesh *mesh1, const MEDCoupling1SGTUMesh *mesh2);
149 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(std::vector<const MEDCoupling1SGTUMesh *>& a);
150 MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshesOnSameCoords(std::vector<const MEDCoupling1SGTUMesh *>& a);
151 MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildSetInstanceFromThis(int spaceDim) const;
152 MEDCOUPLING_EXPORT MEDCoupling1GTUMesh *computeDualMesh() const;
153 MEDCOUPLING_EXPORT DataArrayInt *sortHexa8EachOther();
154 MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *explodeEachHexa8To6Quad4() const;
155 MEDCOUPLING_EXPORT MEDCouplingCMesh *structurizeMe(DataArrayInt *& cellPerm, DataArrayInt *& nodePerm, double eps=1e-12) const;
156 public://serialization
157 MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
158 MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
159 MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
160 MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
161 const std::vector<std::string>& littleStrings);
163 MEDCoupling1SGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
164 MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy);
165 MEDCoupling1SGTUMesh();
167 void checkNonDynamicGeoType() const;
168 static MEDCoupling1SGTUMesh *Merge1SGTUMeshesLL(std::vector<const MEDCoupling1SGTUMesh *>& a);
169 DataArrayInt *simplexizePol0();
170 DataArrayInt *simplexizePol1();
171 DataArrayInt *simplexizePlanarFace5();
172 DataArrayInt *simplexizePlanarFace6();
173 MEDCoupling1DGTUMesh *computeDualMesh3D() const;
174 MEDCoupling1DGTUMesh *computeDualMesh2D() const;
176 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;
178 static const int HEXA8_FACE_PAIRS[6];
181 class MEDCoupling1DGTUMesh : public MEDCoupling1GTUMesh
184 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
185 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(const MEDCouplingUMesh *m);
186 //! useless constructor only for CORBA -> not swigged
187 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New();
188 MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *clone(bool recDeepCpy) const;
189 MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const;
190 // overload of TimeLabel and RefCountObject
191 MEDCOUPLING_EXPORT void updateTime() const;
192 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
193 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
194 // overload of MEDCouplingMesh
195 MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED; }
196 MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
197 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
198 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
199 MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const;
200 MEDCOUPLING_EXPORT void checkCoherency() const;
201 MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
202 MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
203 MEDCOUPLING_EXPORT int getNumberOfCells() const;
204 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const;
205 MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const;
206 MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const;
207 MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
208 MEDCOUPLING_EXPORT std::string simpleRepr() const;
209 MEDCOUPLING_EXPORT std::string advancedRepr() const;
210 MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
211 MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
212 MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
213 MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
214 MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy);
215 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
216 // overload of MEDCouplingPointSet
217 MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other);
218 MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const;
219 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const;
220 MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords2(int start, int end, int step) const;
221 MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const;
222 MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
223 MEDCOUPLING_EXPORT void checkFullyDefined() const;
224 MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
225 MEDCOUPLING_EXPORT DataArrayInt *computeFetchedNodeIds() const;
226 MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
227 MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
228 MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
229 MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
230 MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
231 MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
232 MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const;
233 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const;
234 // overload of MEDCoupling1GTUMesh
235 MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const;
236 MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0);
237 MEDCOUPLING_EXPORT void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd);
239 MEDCOUPLING_EXPORT void setNodalConnectivity(DataArrayInt *nodalConn, DataArrayInt *nodalConnIndex);
240 MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const;
241 MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const;
242 MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const;
243 MEDCOUPLING_EXPORT bool retrievePackedNodalConnectivity(DataArrayInt *&nodalConn, DataArrayInt *&nodalConnIndx) const;
244 MEDCOUPLING_EXPORT bool isPacked() const;
245 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *Merge1DGTUMeshes(const MEDCoupling1DGTUMesh *mesh1, const MEDCoupling1DGTUMesh *mesh2);
246 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *Merge1DGTUMeshes(std::vector<const MEDCoupling1DGTUMesh *>& a);
247 MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *Merge1DGTUMeshesOnSameCoords(std::vector<const MEDCoupling1DGTUMesh *>& a);
248 MEDCOUPLING_EXPORT static DataArrayInt *AggregateNodalConnAndShiftNodeIds(const std::vector<const DataArrayInt *>& nodalConns, const std::vector<int>& offsetInNodeIdsPerElt);
249 MEDCOUPLING_EXPORT static std::vector<int> BuildAPolygonFromParts(const std::vector< std::vector<int> >& parts);
250 MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *buildSetInstanceFromThis(int spaceDim) const;
251 public://serialization
252 MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
253 MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
254 MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
255 MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
256 const std::vector<std::string>& littleStrings);
258 MEDCoupling1DGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
259 MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy);
260 MEDCoupling1DGTUMesh();
262 void checkDynamicGeoT2ype() const;
263 static MEDCoupling1DGTUMesh *Merge1DGTUMeshesLL(std::vector<const MEDCoupling1DGTUMesh *>& a);
265 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn_indx;
266 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;