Salome HOME
07985d66073d97988d2ddea33967d2a4439030df
[modules/hexablock.git] / src / HEXABLOCK / HexLaw.cxx
1
2 // Copyright (C) 2009-2023  CEA, EDF
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 //
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #include "HexLaw.hxx"
22
23 BEGIN_NAMESPACE_HEXA
24
25 int Law::last_law_id = 0;
26
27 // ================================================== Constructeur
28 Law::Law (Document* dad, cpchar name, int nbnodes) : EltBase (dad, EL_LAW)
29 {
30    nbr_nodes = nbnodes;
31    law_id = last_law_id++;
32
33    //Initialisation du nom: un nom par défaut est donné s'il n'est pas fourni
34    std::string _nom = std::string(name);
35    _nom.erase (_nom.find_last_not_of (" \n\r\t" ) + 1);
36    _nom.erase (0, _nom.find_first_not_of (" \n\r\t" ));
37    if (!_nom.empty())
38         law_name = _nom;
39    else {
40         char buffer [16];
41     sprintf (buffer, "l%04d", law_id);
42     law_name = std::string(buffer);
43    }
44
45    law_type  = Uniform;
46    law_coefficient = 0.0;
47 }
48
49 // ================================================== Constructeur 2
50 Law::Law (Law* other)
51 {
52    nbr_nodes       = other->nbr_nodes;
53    law_name        = other->law_name ;
54    law_type        = other->law_type ;
55    law_coefficient = other->law_coefficient;
56    el_root         = other->el_root;
57 }
58
59 // ========================================================= getNextName
60 char* Law::getNextName  (pchar buffer)
61 {
62    sprintf (buffer, "l%04d", last_law_id);
63    return   buffer;
64 }
65
66 END_NAMESPACE_HEXA