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