Salome HOME
Merge from V6_main (dev of Anthony GEAY) 11/06/2013
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingExtrudedMesh.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_MEDCOUPLINGEXTRUDEDMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingMesh.hxx"
26
27 #include <vector>
28
29 namespace ParaMEDMEM
30 {
31   class DataArrayInt;
32   class DataArrayDouble;
33   class MEDCouplingUMesh;
34   class MEDCouplingFieldDouble;
35
36   class MEDCOUPLING_EXPORT MEDCouplingExtrudedMesh : public MEDCouplingMesh
37   {
38   public:
39     static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
40     static MEDCouplingExtrudedMesh *New();
41     MEDCouplingMeshType getType() const;
42     std::size_t getHeapMemorySize() const;
43     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
44     int getNumberOfCells() const;
45     int getNumberOfNodes() const;
46     int getSpaceDimension() const;
47     int getMeshDimension() const;
48     MEDCouplingMesh *deepCpy() const;
49     MEDCouplingExtrudedMesh *clone(bool recDeepCpy) const;
50     bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
51     bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
52     void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
53                               DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
54     void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
55                                          DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
56     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
57     std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
58     DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
59     DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
60     DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
61     int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
62     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
63     void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
64     std::string simpleRepr() const;
65     std::string advancedRepr() const;
66     void checkCoherency() const throw (INTERP_KERNEL::Exception);
67     void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
68     void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
69     void getBoundingBox(double *bbox) const;
70     void updateTime() const;
71     void renumberCells(const int *old2NewBg, bool check=true) throw(INTERP_KERNEL::Exception);
72     MEDCouplingUMesh *getMesh2D() const { return _mesh2D; }
73     MEDCouplingUMesh *getMesh1D() const { return _mesh1D; }
74     DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; }
75     MEDCouplingUMesh *build3DUnstructuredMesh() const;
76     MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
77     MEDCouplingFieldDouble *getMeasureField(bool) const;
78     MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
79     MEDCouplingFieldDouble *buildOrthogonalField() const;
80     int getCellContainingPoint(const double *pos, double eps) const;
81     static int FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
82                                           const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception);
83     static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
84                                 MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception);
85     void rotate(const double *center, const double *vector, double angle);
86     void translate(const double *vector);
87     void scale(const double *point, double factor);
88     std::vector<int> getDistributionOfTypes() const throw(INTERP_KERNEL::Exception);
89     DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
90     void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
91     MEDCouplingMesh *buildPart(const int *start, const int *end) const;
92     MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
93     DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
94     MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
95     DataArrayDouble *getCoordinatesAndOwner() const;
96     DataArrayDouble *getBarycenterAndOwner() const;
97     DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
98     //Serialization unserialisation
99     void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
100     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
101     void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
102     void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
103                          const std::vector<std::string>& littleStrings);
104     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
105   private:
106     MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
107     MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh& other, bool deepCopy);
108     MEDCouplingExtrudedMesh();
109     void computeExtrusion(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception);
110     void computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception);
111     void build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh,
112                           const int *desc3D, const int *descIndx3D,
113                           const int *revDesc3D, const int *revDescIndx3D,
114                           bool computeMesh1D) throw(INTERP_KERNEL::Exception);
115     int findOppositeFaceOf(int current2DCell, int current3DCell, const std::vector<int>& connSorted,
116                            const int *desc3D, const int *descIndx3D,
117                            const int *conn2D, const int *conn2DIndx) throw(INTERP_KERNEL::Exception);
118     void computeBaryCenterOfFace(const std::vector<int>& nodalConnec, int lev1DId);
119     ~MEDCouplingExtrudedMesh();
120     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
121     std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
122   private:
123     MEDCouplingUMesh *_mesh2D;
124     MEDCouplingUMesh *_mesh1D;
125     //! New to old 3D cell Ids Array
126     DataArrayInt *_mesh3D_ids;
127     int _cell_2D_id;
128   };
129 }
130
131 #endif