Salome HOME
9a5180ecb93ceb26e3b50bd4a70c632f4535b2f0
[modules/hexablock.git] / src / HEXABLOCK / HexLaw.hxx
1
2 // class : Au nom de la loi
3
4 // Copyright (C) 2009-2023  CEA, EDF
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, or (at your option) any later version.
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 "HexEltBase.hxx"
26 #include "HexXmlWriter.hxx"
27
28 BEGIN_NAMESPACE_HEXA
29
30 class HexaExport Law : public EltBase  
31 {
32 public:
33    const char* getName ()          { return law_name.c_str() ; }
34    char* getNextName  (pchar buffer);
35    int     getNodes ()             { return nbr_nodes ; }
36    double  getCoefficient ()       { return law_coefficient ; }
37    KindLaw getKind ()              { return law_type ;  }
38
39    int     setNodes (int  nbre);
40    int     setCoefficient (double coeff);
41    void    setKind (KindLaw type)  { law_type = type ;  }
42    void    setKind (cpchar  type);
43    int     setName (cpchar  nom);
44
45     Law (Document* dad, cpchar name, int nbnodes);
46     Law (Law* other);
47     void saveXml (XmlWriter* xml);
48
49 private:
50     int law_id;
51     static int last_law_id;
52     std::string law_name;
53     int         nbr_nodes;
54     KindLaw     law_type;
55     double      law_coefficient;
56 };
57
58 // ================================================== setNodes
59 inline int Law::setNodes (int  nbre)
60 {
61    nbr_nodes = nbre;
62    return HOK;
63 }
64 // ================================================== setCoefficient
65 inline int Law::setCoefficient (double coeff)
66 {
67    law_coefficient = coeff;
68    return HOK;
69 }
70 // ================================================== setName
71 inline int Law::setName (cpchar name)
72 {
73    law_name = name;
74    return HOK;
75 }
76 // ================================================== saveXml
77 inline void Law::saveXml (XmlWriter* xml)
78 {
79    cpchar kind_law [] = { "Uniform", "Arithmetic", "Geometric" };
80
81    xml->openMark     ("Law");
82    xml->addAttribute ("id",          getName ());
83    xml->addAttribute ("kind",    kind_law [law_type]);
84    xml->addAttribute ("nodes",   nbr_nodes);
85    xml->addAttribute ("coeff", law_coefficient);
86    xml->closeMark ();
87 }
88 // ================================================== setKind
89 inline void Law::setKind (cpchar type)
90 {
91 #define VerifKind(t,k) if (strcmp(t,#k)==0) law_type = k
92    VerifKind (type, Uniform);
93    VerifKind (type, Arithmetic);
94    VerifKind (type, Geometric);
95 }
96
97 END_NAMESPACE_HEXA
98 #endif