Salome HOME
Undef max Visual Studio definition.
[modules/hexablock.git] / src / HEXABLOCK / HexPropagation.hxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // class : Ensembles de propagation
21
22 #ifndef __PROPAGATION_H
23 #define __PROPAGATION_H
24
25 #include "Hex_defines.hxx"
26 #include "HexEltBase.hxx"
27
28 #include "HexDocument.hxx"
29 #include "HexEdge.hxx"
30 #include "HexXmlWriter.hxx"
31 #include "HexLaw.hxx"
32 #include "HexGlobale.hxx"
33
34 BEGIN_NAMESPACE_HEXA
35
36 class HEXABLOCKENGINE_EXPORT Propagation : public EltBase 
37 {
38 public:
39    const Edges& getEdges ()        { return prop_edges; }
40    Law*  getLaw ();
41    bool  getWay ()                 { return prop_way; }
42
43    void  setWay (bool sens)        { prop_way = sens; }
44    int   setLaw (Law* loi);
45
46 public:
47     Propagation  (Document*  doc);
48     void saveXml (XmlWriter* xml);
49     void addEdge (Edge* arete);
50     void majLaw  ();
51
52 private:
53     Edges prop_edges;
54     Law*  prop_law;
55     bool  prop_way;
56 };
57 // =========================================================== Constructeur
58 inline Propagation::Propagation (Document* doc)
59                   : EltBase (doc, EL_PROPAGATION)
60 {
61     prop_law = NULL;
62     prop_way = true;
63 }
64 // =========================================================== getLaw
65 inline Law* Propagation::getLaw ()
66 {
67     return prop_law; 
68 /* **********************************  Modif Abu du 18/10/2010
69     if (prop_law != NULL) 
70        return prop_law; 
71
72     if (prop_edges.size()==0) 
73        return NULL;
74
75     Document* root = prop_edges[0]->dad();
76     return root->getLaw (0);
77    ********************************** */
78 }
79 // =========================================================== setLaw
80 inline int Propagation::setLaw (Law* loi)
81 {
82    prop_law = loi; 
83    majLaw ();
84
85    DumpStart  ("setLaw", loi);
86    DumpEnd;
87    return HOK;
88 }
89 // =========================================================== majLaw
90 inline void Propagation::majLaw ()
91 {
92    int nbre = prop_edges.size();
93    for (int nro=0 ; nro < nbre ; nro++)
94         prop_edges[0]->setLaw (prop_law);
95 }
96 // =========================================================== addEdge
97 inline void Propagation::addEdge (Edge* arete)
98 {
99    prop_edges.push_back (arete);
100
101    if (prop_law == NULL)
102        prop_law =  arete->getLaw();
103 }
104 // =========================================================== saveXml
105 inline void Propagation::saveXml (XmlWriter* xml)
106 {
107     char   buffer[12];
108     cpchar booleen [] = { "true", "false" };
109     cpchar law = prop_law == NULL ? "default" : prop_law->getName();
110
111     xml->openMark     ("Propagation");
112     xml->addAttribute ("edge", prop_edges[0]->getName (buffer));
113     xml->addAttribute ("law",  law);
114     xml->addAttribute ("way",  booleen [prop_way]);
115     xml->closeMark ();
116 }
117 END_NAMESPACE_HEXA
118
119 #endif