Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARD / HOMARD_Cas.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : HOMARD_Cas.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : HOMARD
27
28 #include "HOMARD_Cas.hxx"
29 #include "utilities.h"
30 #include <iostream>
31
32 //=============================================================================
33 /*!
34  *  default constructor:
35  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
36  */
37 //=============================================================================
38 HOMARD_Cas::HOMARD_Cas():
39   _NomCas(""), _NomDir("/tmp"), _ConfType(1)
40 {
41   MESSAGE("HOMARD_Cas");
42 }
43 //=============================================================================
44 HOMARD_Cas::~HOMARD_Cas()
45 //=============================================================================
46 {
47   MESSAGE("~HOMARD_Cas");
48 }
49
50 //=============================================================================
51 void HOMARD_Cas::SetDirName( const char* NomDir )
52 //=============================================================================
53 {
54      MESSAGE("SetDirName, NomDir :  "<<NomDir);
55      if (chdir(NomDir) == 0)
56      {
57        _NomDir = std::string( NomDir );
58      }
59     else 
60     {
61        // GERALD -- QMESSAGE BOX
62        // std::cerr << "Pb pour entrer dans le repertoire :  "<<NomDir << std::endl;
63        _NomDir = "/tmp";
64     };
65 }
66
67 //=============================================================================
68 std::string HOMARD_Cas::GetDirName() const
69 //=============================================================================
70 {
71   return _NomDir;
72 }
73
74 //=============================================================================
75 void HOMARD_Cas::SetName( const char* NomCas )
76 //=============================================================================
77 {
78   _NomCas = std::string( NomCas );
79 }
80
81 //=============================================================================
82 std::string HOMARD_Cas::GetName() const
83 //=============================================================================
84 {
85   return _NomCas;
86 }
87
88
89 //=============================================================================
90 std::string HOMARD_Cas::GetDumpPython() const
91 //=============================================================================
92 {
93   std::ostringstream aScript;
94   aScript << "\t" <<_NomCas << ".SetDirName('";
95   aScript << _NomDir << "')\n";
96   aScript << "\t" <<_NomCas << ".SetConfType(";
97   aScript << _ConfType << ")\n";
98 // Suivi de frontieres
99   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
100   while(it != _ListBoundaryGroup.end())
101   {
102     aScript << "\t" <<_NomCas << ".AddBoundaryGroup('";
103     aScript << *it << "', '";
104     it++;
105     aScript << *it << "')\n";
106     it++;
107   }
108   return aScript.str();
109 }
110 //AddBoundaryGroup( 'cyl_4', 'T2_INT' )
111 //=============================================================================
112 void HOMARD_Cas::AddIteration( const char* NomIteration )
113 //=============================================================================
114 {
115   _ListIter.push_back( std::string( NomIteration ) );
116 }
117
118 //=============================================================================
119 const std::list<std::string>& HOMARD_Cas::GetIterations() const
120 //=============================================================================
121 {
122   return _ListIter;
123 }
124
125 //=============================================================================
126 void HOMARD_Cas::SupprIterations()
127 //=============================================================================
128 {
129   _ListIter.clear();
130 }
131
132 //=============================================================================
133 std::string HOMARD_Cas::GetIter0Name() const
134 //=============================================================================
135 {
136 // Par construction de la liste, l'iteration a ete mise en tete.
137   return (*(_ListIter.begin()));
138 }
139
140 //=============================================================================
141 void HOMARD_Cas::SetConfType( int Conftype )
142 //=============================================================================
143 {
144   _ConfType = Conftype;
145 }
146 //=============================================================================
147 const int HOMARD_Cas::GetConfType() const
148 //=============================================================================
149 {
150   return _ConfType;
151 }
152 //=============================================================================
153 int HOMARD_Cas::GetNumber() 
154 //=============================================================================
155
156 {
157   return _ListIter.size();
158 }
159 //
160 // La boite englobante
161 //
162 //=============================================================================
163 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
164 //=============================================================================
165 {
166   _Boite.clear();
167   _Boite.resize( extremas.size() );
168   for ( int i = 0; i < extremas.size(); i++ )
169     _Boite[i] = extremas[i];
170 }
171
172 //=============================================================================
173 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
174 //=============================================================================
175 {
176   return _Boite;
177 }
178 //
179 // Les groupes
180 //
181 //=============================================================================
182 const std::list<std::string>& HOMARD_Cas::GetGroups() const
183 //=============================================================================
184 {
185   return _ListGroup;
186 }
187 //=============================================================================
188 void HOMARD_Cas::SupprGroups()
189 //=============================================================================
190 {
191   _ListGroup.clear();
192 }
193 //=============================================================================
194 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
195 //=============================================================================
196 {
197   _ListGroup.clear();
198   std::list<std::string>::const_iterator it = ListGroup.begin();
199   while(it != ListGroup.end())
200   {
201     _ListGroup.push_back((*it++));
202   }
203 }
204 //=============================================================================
205 void HOMARD_Cas::AddGroup( const char* Group )
206 {
207   _ListGroup.push_back(Group);
208 }
209 //
210 // Les frontieres
211 //
212 //=============================================================================
213 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
214 //=============================================================================
215 {
216   return _ListBoundaryGroup;
217 }
218 //=============================================================================
219 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
220 {
221   _ListBoundaryGroup.push_back( Boundary );
222   _ListBoundaryGroup.push_back( Group    );
223 }
224 //=============================================================================
225 void HOMARD_Cas::SupprBoundaryGroup()
226 //=============================================================================
227 {
228   _ListBoundaryGroup.clear();
229 }
230