]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/HexLaw.hxx
Salome HOME
f274a3301d492abb526d0ddd6fb8fc0ff2000163
[modules/hexablock.git] / src / HEXABLOCK / HexLaw.hxx
1
2 // class : Au nom de la loi
3
4 #ifndef __LAW_H
5 #define __LAW_H
6
7 #include "HexXmlWriter.hxx"
8
9 BEGIN_NAMESPACE_HEXA
10
11 class Law 
12 {
13 public:
14    const char* getName ()          { return law_name.c_str() ; }
15    int     getNodes ()             { return nbr_nodes ; }
16    double  getCoefficient ()       { return law_coefficient ; }
17    KindLaw getKind ()              { return law_type ;  }
18
19    int     setNodes (int  nbre);
20    int     setCoefficient (double coeff);
21    void    setKind (KindLaw type)  { law_type = type ;  }
22    int     setName (const char* nom);
23
24 public:
25     Law (cpchar name, int nbnodes);
26     void saveXml (XmlWriter& xml);
27
28 private:
29     std::string law_name;
30     int         nbr_nodes;
31     KindLaw     law_type;
32     double      law_coefficient;
33 };
34 // ================================================== Constructeur
35 inline Law::Law (cpchar name, int nbnodes)
36 {
37    nbr_nodes = nbnodes;
38    law_name  = name;
39    law_type  = Uniform;
40    law_coefficient = 0.0;
41 }
42 // ================================================== setNodes
43 inline int Law::setNodes (int  nbre)
44 {
45    nbr_nodes = nbre;
46    return HOK;
47 }
48 // ================================================== setCoefficient
49 inline int Law::setCoefficient (double coeff)
50 {
51    law_coefficient = coeff;
52    return HOK;
53 }
54 // ================================================== setName
55 inline int Law::setName (const char* name)
56 {
57    law_name = name;
58    return HOK;
59 }
60 // ================================================== saveXml
61 inline void Law::saveXml (XmlWriter& xml)
62 {
63    cpchar kind_law [] = { "Uniform", "Arithmetic", "Geometric" };
64
65    xml.openMark     ("Law");
66    xml.addAttribute ("id",          getName ());
67    xml.addAttribute ("kind",    kind_law [law_type]);
68    xml.addAttribute ("nodes",   nbr_nodes);
69    xml.addAttribute ("coeff", law_coefficient);
70    xml.closeMark ();
71 }
72 END_NAMESPACE_HEXA
73 #endif