]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/HexLaw.hxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / HEXABLOCK / HexLaw.hxx
1
2 // class : Au nom de la loi
3
4 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef __LAW_H_
23 #define __LAW_H_
24
25 #include "HexXmlWriter.hxx"
26
27 BEGIN_NAMESPACE_HEXA
28
29 class Law 
30 {
31 public:
32    const char* getName ()          { return law_name.c_str() ; }
33    int     getNodes ()             { return nbr_nodes ; }
34    double  getCoefficient ()       { return law_coefficient ; }
35    KindLaw getKind ()              { return law_type ;  }
36
37    int     setNodes (int  nbre);
38    int     setCoefficient (double coeff);
39    void    setKind (KindLaw type)  { law_type = type ;  }
40    void    setKind (cpchar  type);
41    int     setName (cpchar  nom);
42
43     Law (cpchar name, int nbnodes);
44     Law (Law* other);
45     void saveXml (XmlWriter* xml);
46
47 private:
48     int law_id;
49     static int last_law_id;
50     std::string law_name;
51     int         nbr_nodes;
52     KindLaw     law_type;
53     double      law_coefficient;
54 };
55
56 // ================================================== setNodes
57 inline int Law::setNodes (int  nbre)
58 {
59    nbr_nodes = nbre;
60    return HOK;
61 }
62 // ================================================== setCoefficient
63 inline int Law::setCoefficient (double coeff)
64 {
65    law_coefficient = coeff;
66    return HOK;
67 }
68 // ================================================== setName
69 inline int Law::setName (cpchar name)
70 {
71    law_name = name;
72    return HOK;
73 }
74 // ================================================== saveXml
75 inline void Law::saveXml (XmlWriter* xml)
76 {
77    cpchar kind_law [] = { "Uniform", "Arithmetic", "Geometric" };
78
79    xml->openMark     ("Law");
80    xml->addAttribute ("id",          getName ());
81    xml->addAttribute ("kind",    kind_law [law_type]);
82    xml->addAttribute ("nodes",   nbr_nodes);
83    xml->addAttribute ("coeff", law_coefficient);
84    xml->closeMark ();
85 }
86 // ================================================== setKind
87 inline void Law::setKind (cpchar type)
88 {
89 #define VerifKind(t,k) if (strcmp(t,#k)==0) law_type = k
90    VerifKind (type, Uniform);
91    VerifKind (type, Arithmetic);
92    VerifKind (type, Geometric);
93 }
94
95 END_NAMESPACE_HEXA
96 #endif