Salome HOME
for MG-adapt TUI
[modules/smesh.git] / src / SMESH_I / MG_ADAPT_i.cxx
1 // Copyright (C) 2011-2020  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, or (at your option) any later version.
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 // Remarques :
21 // L'ordre de description des fonctions est le meme dans tous les fichiers
22 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
23 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
24 // 2. Les caracteristiques
25 // 3. Le lien avec les autres structures
26 //
27 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
28 //
29
30 #include "MG_ADAPT_i.hxx"
31 //~#include "ADAPT_Gen_i.hxx"
32 #include "string.h"
33 #include "SMESH_Gen_i.hxx"
34 #include <SMESH_Gen.hxx>
35 #include <SALOMEconfig.h>
36 #include CORBA_CLIENT_HEADER(SALOMEDS)
37 //~#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
38 //~#include CORBA_CLIENT_HEADER(SMESH_Gen)
39
40
41 //=============================================================================
42 /*!
43  *  SMESH_Gen_i::CreateMG_ADAPT
44  *
45  *  Create measurement instance
46  */
47 //=============================================================================
48
49
50 using namespace SMESH;
51 void MG_ADAPT_i::copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const
52 {
53     to->myFileInDir = from.myFileInDir;
54     to->myMeshFileIn = from.myMeshFileIn;
55     to->myMeshFileBackground = from.myMeshFileBackground;
56     to->myOutMeshName = from.myOutMeshName;
57     to->myMeshFileOut = from.myMeshFileOut;
58     to->myFileOutDir = from.myFileOutDir;
59     to->myFileSizeMapDir = from.myFileSizeMapDir;
60     to->myFieldName = from.myFieldName;
61     to->fromMedFile = from.fromMedFile;
62     to->myPublish = from.myPublish;
63     to->myMeshOutMed = from.myMeshOutMed;
64     to->myUseLocalMap = from.myUseLocalMap;
65     to->myUseBackgroundMap = from.myUseBackgroundMap;
66     to->myUseConstantValue = from.myUseConstantValue;
67     to->myConstantValue = from.myConstantValue;
68     to->myTimeStep = from.myTimeStep;
69     to->myRank = from.myRank;
70     to->myUseNoTimeStep = from.myUseNoTimeStep;
71     to->myUseLastTimeStep = from.myUseLastTimeStep;
72     to->myUseChosenTimeStep = from.myUseChosenTimeStep;
73     to->myWorkingDir = from.myWorkingDir;
74     to->myLogFile = from.myLogFile;
75     to->myPrintLogInFile = from.myPrintLogInFile;
76     to->myKeepFiles = from.myKeepFiles;
77     to->myRemoveLogOnSuccess = from.myRemoveLogOnSuccess;
78     to->myVerboseLevel = from.myVerboseLevel;
79 }
80 void MG_ADAPT_i::copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const
81 {
82     to->myFileInDir = CORBA::string_dup(from->myFileInDir.c_str());
83     to->myMeshFileIn = CORBA::string_dup(from->myMeshFileIn.c_str());
84     to->myMeshFileBackground = CORBA::string_dup(from->myMeshFileBackground.c_str());
85     to->myOutMeshName = CORBA::string_dup(from->myOutMeshName.c_str());
86     to->myMeshFileOut = CORBA::string_dup(from->myMeshFileOut.c_str());
87     to->myFileOutDir = CORBA::string_dup(from->myFileOutDir.c_str());
88     to->myFileSizeMapDir = CORBA::string_dup(from->myFileSizeMapDir.c_str());
89     to->myFieldName = CORBA::string_dup(from->myFieldName.c_str());
90     to->fromMedFile = from->fromMedFile;
91     to->myPublish = from->myPublish;
92     to->myMeshOutMed = from->myMeshOutMed;
93     to->myUseLocalMap = from->myUseLocalMap;
94     to->myUseBackgroundMap = from->myUseBackgroundMap;
95     to->myUseConstantValue = from->myUseConstantValue;
96     to->myConstantValue = from->myConstantValue;
97     to->myTimeStep = from->myTimeStep;
98     to->myRank = from->myRank;
99     to->myUseNoTimeStep = from->myUseNoTimeStep;
100     to->myUseLastTimeStep = from->myUseLastTimeStep;
101     to->myUseChosenTimeStep = from->myUseChosenTimeStep;
102     to->myWorkingDir = CORBA::string_dup(from->myWorkingDir.c_str());
103     to->myLogFile = CORBA::string_dup(from->myLogFile.c_str());
104     to->myPrintLogInFile = from->myPrintLogInFile;
105     to->myKeepFiles = from->myKeepFiles;
106     to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess;
107     to->myVerboseLevel = from->myVerboseLevel;
108 }
109 SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT()
110 {
111   SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i();
112   SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
113   return anObj._retn();
114 }
115 //~SMESH::MG_ADAPT_ptr MG_ADAPT_i::CreateMG_ADAPT()
116 //~{
117   
118   //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();      
119   //~SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(smeshGen_i->GetPOA());
120   //~SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
121   //~return anObj._retn();
122 //~}
123 //=============================================================================
124 /*!
125  *  standard constructor
126  */
127 //=============================================================================
128 MG_ADAPT_i::MG_ADAPT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
129 {
130   myMgAdapt = new ::MG_ADAPT::MgAdapt();
131 }
132 //~MG_ADAPT_i::MG_ADAPT_i(PortableServer::POA_var myPoa): SALOME::GenericObj_i( myPoa )
133 //~{
134   //~myMgAdapt = new ::MG_ADAPT::MgAdapt();
135 //~}
136
137 //=============================================================================
138 /*!
139  *  standard constructor
140  */
141 //=============================================================================
142 //~MG_ADAPT_i::MG_ADAPT_i( CORBA::ORB_ptr orb,
143                             //~ADAPT::ADAPT_Gen_var engine )
144 //~{
145
146   //~_gen_i = engine;
147   //~_orb = orb;
148   //~myMgAdapt = new MgAdapt();
149 //~}
150
151 //=============================================================================
152 /*!
153  *  standard destructor
154  */
155 //=============================================================================
156 MG_ADAPT_i::~MG_ADAPT_i()
157 {
158 }
159 void MG_ADAPT_i::setData( SMESH::MgAdaptHypothesisData& data)
160 {
161         ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData();
162         copyHypothesisDataToImpl(data, baseData);
163         myMgAdapt->setData(baseData);
164         delete baseData;
165 }       
166 void MG_ADAPT_i::setMedFileIn(const char* str)
167 {
168         myMgAdapt->setMedFileIn(str);
169 }
170 char* MG_ADAPT_i::getMedFileIn()
171 {
172         return CORBA::string_dup(myMgAdapt->getMedFileIn().c_str());
173 }
174 void MG_ADAPT_i::setMedFileOut(const char* str)
175 {
176         myMgAdapt->setMedFileOut(str);
177 }
178 char* MG_ADAPT_i::getMedFileOut()
179 {
180         return CORBA::string_dup(myMgAdapt->getMedFileOut().c_str());
181 }
182 void MG_ADAPT_i::setMeshName(const char* str)
183 {
184         myMgAdapt->setMeshName(str);
185 }
186 char* MG_ADAPT_i::getMeshName()
187 {
188         return CORBA::string_dup(myMgAdapt->getMeshName().c_str());
189 }
190 void MG_ADAPT_i::setMeshNameOut(const char* str)
191 {
192         myMgAdapt->setMeshNameOut(str);
193 }
194 char* MG_ADAPT_i::getMeshNameOut()
195 {
196         return CORBA::string_dup(myMgAdapt->getMeshNameOut().c_str());
197 }
198 void MG_ADAPT_i::setMeshOutMed(bool mybool)
199 {
200         myMgAdapt->setMeshOutMed(mybool);
201 }
202 bool MG_ADAPT_i::getMeshOutMed()
203 {
204         return myMgAdapt->getMeshOutMed();
205 }
206 void MG_ADAPT_i::setPublish(bool mybool)
207 {
208         myMgAdapt->setPublish(mybool);
209 }
210 bool MG_ADAPT_i::getPublish()
211 {
212         return myMgAdapt->getPublish();
213 }
214 void MG_ADAPT_i::setFieldName(const char* str)
215 {
216         myMgAdapt->setFieldName(str);
217 }
218 char* MG_ADAPT_i::getFieldName()
219 {
220         return CORBA::string_dup(myMgAdapt->getFieldName().c_str());
221 }
222 void MG_ADAPT_i::setTimeStep(CORBA::Long t)
223 {
224         myMgAdapt->setTimeStep(t);
225 }
226 CORBA::Long MG_ADAPT_i::getTimeStep() 
227 {
228         return myMgAdapt->getTimeStep();
229 }
230 void MG_ADAPT_i::setRankTimeStep(CORBA::Long t, CORBA::Long r)
231 {
232         myMgAdapt->setRankTimeStep(t, r);
233 }
234 CORBA::Long MG_ADAPT_i::getRank()
235 {
236         return myMgAdapt->getRank();
237 }
238 void MG_ADAPT_i::setTimeStepRankLast()
239 {
240         myMgAdapt->setTimeStepRankLast();
241 }
242 void MG_ADAPT_i::setNoTimeStep()
243 {
244         myMgAdapt->setNoTimeStep();
245 }
246 void MG_ADAPT_i::setLogFile(const char* str)
247 {
248         myMgAdapt->setLogFile(str);
249 }
250 char* MG_ADAPT_i::getLogFile()
251 {
252         return CORBA::string_dup(myMgAdapt->getLogFile().c_str());
253 }
254
255 void MG_ADAPT_i::setVerbosityLevel(CORBA::Long v)
256 {
257         myMgAdapt->setVerbosityLevel(v);
258 }
259 CORBA::Long MG_ADAPT_i::getVerbosityLevel()
260 {
261         return myMgAdapt->getVerbosityLevel();
262 }
263 void MG_ADAPT_i::setRemoveOnSuccess(bool mybool)
264 {
265         myMgAdapt->setRemoveOnSuccess(mybool);
266 }
267 bool MG_ADAPT_i::getRemoveOnSuccess()
268 {
269         myMgAdapt->getRemoveOnSuccess();
270 }
271 SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData() 
272 {
273         SMESH::MgAdaptHypothesisData* result = new      SMESH::MgAdaptHypothesisData();
274         ::MG_ADAPT::MgAdaptHypothesisData* from =  myMgAdapt->getData();
275         copyHypothesisDataFromImpl(from, result);       
276         return result;
277 }
278 void MG_ADAPT_i::setUseLocalMap(bool mybool)
279 {
280         myMgAdapt->setUseLocalMap(mybool);
281 }
282 bool MG_ADAPT_i::getUseLocalMap()
283 {
284         return myMgAdapt->getUseLocalMap();
285 }
286 void MG_ADAPT_i::setUseBackgroundMap(bool mybool)
287 {
288         myMgAdapt->setUseBackgroundMap(mybool);
289 }
290 bool MG_ADAPT_i::getUseBackgroundMap()
291 {
292         return myMgAdapt->getUseBackgroundMap();
293 }
294 void MG_ADAPT_i::setUseConstantValue(bool mybool)
295 {
296         myMgAdapt->setUseConstantValue(mybool);
297 }
298 bool MG_ADAPT_i::getUseConstantValue()
299 {
300         return myMgAdapt->getUseConstantValue();
301 }
302
303 void MG_ADAPT_i::setConstantValue(double value)
304 {
305         myMgAdapt->setConstantValue(value);
306 }
307 double MG_ADAPT_i::getConstantValue() 
308 {
309         return myMgAdapt->getConstantValue();
310 }
311 void MG_ADAPT_i::setSizeMapFile(const char* str)
312 {
313         myMgAdapt->setSizeMapFile(str);
314 }
315 char* MG_ADAPT_i::getSizeMapFile()
316 {
317         return CORBA::string_dup(myMgAdapt->getSizeMapFile().c_str());
318 }
319 void MG_ADAPT_i::setFromMedFile(bool mybool)
320 {
321         myMgAdapt->setFromMedFile(mybool);
322 }
323 bool MG_ADAPT_i::isFromMedFile()
324 {
325         return myMgAdapt->isFromMedFile();
326 }
327
328 void MG_ADAPT_i::setKeepWorkingFiles(bool mybool)
329 {
330         myMgAdapt->setKeepWorkingFiles(mybool);
331 }
332 bool MG_ADAPT_i::getKeepWorkingFiles()
333 {
334         return myMgAdapt->getKeepWorkingFiles();
335 }
336
337 //~void MG_ADAPT_i::setPrCORBA::LongLogInFile(bool);
338 //~bool MG_ADAPT_i::getPrCORBA::LongLogInFile();
339
340 void MG_ADAPT_i::setWorkingDir(const char* dir)
341 {
342         myMgAdapt->setWorkingDir(dir);
343 }
344 char* MG_ADAPT_i::getWorkingDir() 
345 {
346         return CORBA::string_dup(myMgAdapt->getWorkingDir().c_str());
347 }
348 bool MG_ADAPT_i::setAll()
349 {
350         return myMgAdapt->setAll();
351 }
352 char* MG_ADAPT_i::getCommandToRun()
353 {
354         return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str());
355 }
356
357 //~CORBA::Long MG_ADAPT_i::compute(::CORBA::String_out errStr)
358 //~{
359         //~std::string err("");
360         //~CORBA::Long ret = myMgAdapt->compute(err);
361         //~errStr =  err.c_str();
362         //~return ret;
363 //~}
364 CORBA::Long MG_ADAPT_i::compute()
365 {
366         errStr = "";
367         CORBA::Long ret = myMgAdapt->compute(errStr);
368         //~errStr =  err.c_str();
369         return ret;
370 }
371 char* MG_ADAPT_i::getErrMsg()
372 {
373         return CORBA::string_dup(errStr.c_str());
374 }
375 char* MG_ADAPT_i::getFileName() 
376 {
377         return CORBA::string_dup(myMgAdapt->getFileName().c_str());
378 }
379 char* MG_ADAPT_i::getExeName()
380 {
381         return CORBA::string_dup(myMgAdapt->getExeName().c_str());
382 }
383 void MG_ADAPT_i::copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data)
384 {
385         ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData(); 
386         copyHypothesisDataToImpl(data, baseData);
387         myMgAdapt->copyMgAdaptHypothesisData(baseData);
388         delete baseData;
389 }
390
391 //~void MG_ADAPT_i::checkDirPath(char*& str)
392 //~{
393         //~myMgAdapt->checkDirPath(str);
394 //~}
395
396 bool MG_ADAPT_i::hasOptionDefined( const char* optionName ) 
397 {
398         return myMgAdapt->hasOptionDefined(optionName);
399 }
400 void MG_ADAPT_i::setOptionValue(const char* optionName,
401                                         const char* optionValue) throw (std::invalid_argument)
402 {
403         myMgAdapt->setOptionValue(optionName, optionValue);
404 }                                       
405
406 char* MG_ADAPT_i::getOptionValue(const char* optionName,
407                                                    bool&              isDefault)  throw (std::invalid_argument)
408 {
409     return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str());
410 }
411 str_array* MG_ADAPT_i::getCustomOptionValuesStrVec() 
412 {
413         SMESH::str_array_var result = new SMESH::str_array();
414         std::vector <std::string> vals = myMgAdapt->getCustomOptionValuesStrVec();
415         result->length(vals.size());
416         for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
417         return result._retn();
418 }
419 str_array*  MG_ADAPT_i::getOptionValuesStrVec() 
420 {
421
422         SMESH::str_array_var result = new SMESH::str_array();
423         std::vector <std::string> vals = myMgAdapt->getOptionValuesStrVec();
424         result->length(vals.size());
425         for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
426         return result._retn();
427 }
428
429 void MG_ADAPT_i::setPrintLogInFile(bool mybool)
430 {
431         myMgAdapt->setPrintLogInFile(mybool);
432 }
433 bool MG_ADAPT_i::getPrintLogInFile()
434 {
435         return myMgAdapt->getPrintLogInFile();
436 }
437 //~TOptionValues        MG_ADAPT_i::getOptionValues()       const;
438 //~const TOptionValues& MG_ADAPT_i::getCustomOptionValues() const ;