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