Salome HOME
2660f946e67599de9222480025f1a15efe69ac93
[modules/med.git] / src / MEDCoupling / MEDCouplingGaussLocalization.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_MEDCOUPLINGGAUSSLOCALIZATION_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGGAUSSLOCALIZATION_HXX__
22
23 #include "MEDCoupling.hxx"
24 #include "NormalizedUnstructuredMesh.hxx"
25 #include "InterpKernelException.hxx"
26
27 #include <vector>
28
29 namespace ParaMEDMEM
30 {
31   class MEDCouplingMesh;
32
33   class MEDCOUPLING_EXPORT MEDCouplingGaussLocalization
34   {
35   public:
36     MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
37                                  const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
38     INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
39     int getNumberOfGaussPt() const { return (int)_weight.size(); }
40     int getDimension() const;
41     int getNumberOfPtsInRefCell() const;
42     std::string getStringRepr() const;
43     void checkCoherency() const throw(INTERP_KERNEL::Exception);
44     bool isEqual(const MEDCouplingGaussLocalization& other, double eps) const;
45     void pushTinySerializationIntInfo(std::vector<int>& tinyInfo) const;
46     void pushTinySerializationDblInfo(std::vector<double>& tinyInfo) const;
47     const double *fillWithValues(const double *vals);
48     //
49     const std::vector<double>& getRefCoords() const { return _ref_coord; }
50     double getRefCoord(int ptIdInCell, int comp) const throw(INTERP_KERNEL::Exception);
51     const std::vector<double>& getGaussCoords() const { return _gauss_coord; }
52     double getGaussCoord(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception);
53     const std::vector<double>& getWeights() const { return _weight; }
54     double getWeight(int gaussPtIdInCell, double newVal) const throw(INTERP_KERNEL::Exception);
55     void setRefCoord(int ptIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception);
56     void setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception);
57     void setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception);
58     //
59     static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData);
60     static bool AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
61   private:
62     int checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception);
63   private:
64     INTERP_KERNEL::NormalizedCellType _type;
65     std::vector<double> _ref_coord;
66     std::vector<double> _gauss_coord;
67     std::vector<double> _weight;
68   };
69 }
70
71 #endif