Salome HOME
new combo for element generation etc...
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2004-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 // File      : HYBRIDPlugin_Hypothesis_i.cxx
21 // Created   : Wed Apr  2 13:53:01 2008
22 // Author    : Edward AGAPOV (eap)
23 //
24 #include "HYBRIDPlugin_Hypothesis_i.hxx"
25
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28 //#include "SMESH_Mesh.hxx"
29 //#include "SMESH_ProxyMesh.hxx"
30 //#include <StdMeshers_QuadToTriaAdaptor.hxx>
31
32 #include "Utils_CorbaException.hxx"
33 #include "utilities.h"
34 #include "SMESH_Mesh_i.hxx"
35 #include "SMESH_Group_i.hxx"
36 #include "SMESH_Gen_i.hxx"
37 #include "SMESH_TypeDefs.hxx"
38 #include "SMESHDS_GroupBase.hxx"
39
40 // SALOME KERNEL includes
41 #include "SALOMEDSClient.hxx"
42 #include <SALOMEDSClient_definitions.hxx>
43 // // IDL headers
44 // #include <SALOMEconfig.h>
45 // #include CORBA_SERVER_HEADER(SALOMEDS)
46
47 //=======================================================================
48 //function : HYBRIDPlugin_Hypothesis_i
49 //=======================================================================
50 HYBRIDPlugin_Hypothesis_i::HYBRIDPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
51                                                     int                     theStudyId,
52                                                     ::SMESH_Gen*            theGenImpl)
53   : SALOME::GenericObj_i( thePOA ), 
54     SMESH_Hypothesis_i( thePOA )
55 {
56   MESSAGE( "HYBRIDPlugin_Hypothesis_i::HYBRIDPlugin_Hypothesis_i" );
57   myBaseImpl = new ::HYBRIDPlugin_Hypothesis (theGenImpl->GetANewId(),
58                                               theStudyId,
59                                               theGenImpl);
60 }
61
62 //=======================================================================
63 //function : ~HYBRIDPlugin_Hypothesis_i
64 //=======================================================================
65 HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i()
66 {
67   MESSAGE( "HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i" );
68 }
69
70 //=======================================================================
71 //function : SetToMeshHoles
72 //=======================================================================
73
74 void HYBRIDPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
75 {
76   ASSERT(myBaseImpl);
77   this->GetImpl()->SetToMeshHoles(toMesh);
78   SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
79 }
80
81 //=======================================================================
82 //function : GetToMeshHoles
83 //=======================================================================
84
85 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMeshHoles()
86 {
87   ASSERT(myBaseImpl);
88   return this->GetImpl()->GetToMeshHoles();
89 }
90
91 //=======================================================================
92 //function : SetToMakeGroupsOfDomains
93 //=======================================================================
94
95 void HYBRIDPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
96 {
97   ASSERT(myBaseImpl);
98   this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
99   SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
100 }
101
102 //=======================================================================
103 //function : GetToMakeGroupsOfDomains
104 //=======================================================================
105
106 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
107 {
108   ASSERT(myBaseImpl);
109   return this->GetImpl()->GetToMakeGroupsOfDomains();
110 }
111
112 //=======================================================================
113 //function : SetMaximumMemory
114 //=======================================================================
115
116 void HYBRIDPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
117    throw ( SALOME::SALOME_Exception )
118 {
119   if ( MB == 0 )
120     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
121   ASSERT(myBaseImpl);
122   this->GetImpl()->SetMaximumMemory(MB);
123   SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
124 }
125
126 //=======================================================================
127 //function : GetMaximumMemory
128 //=======================================================================
129
130 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMaximumMemory()
131 {
132   ASSERT(myBaseImpl);
133   return this->GetImpl()->GetMaximumMemory();
134 }
135
136 //=======================================================================
137 //function : SetInitialMemory
138 //=======================================================================
139
140 void HYBRIDPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
141   throw ( SALOME::SALOME_Exception )
142 {
143   if ( MB == 0 )
144     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
145   ASSERT(myBaseImpl);
146   this->GetImpl()->SetInitialMemory(MB);
147   SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
148 }
149
150 //=======================================================================
151 //function : GetInitialMemory
152 //=======================================================================
153
154 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetInitialMemory()
155 {
156   ASSERT(myBaseImpl);
157   return this->GetImpl()->GetInitialMemory();
158 }
159
160 //=======================================================================
161 //function : SetOptimizationLevel
162 //=======================================================================
163
164 void HYBRIDPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
165   throw ( SALOME::SALOME_Exception )
166 {
167   ::HYBRIDPlugin_Hypothesis::OptimizationLevel l =
168       (::HYBRIDPlugin_Hypothesis::OptimizationLevel) level;
169   if ( l < ::HYBRIDPlugin_Hypothesis::None ||
170        l > ::HYBRIDPlugin_Hypothesis::Strong )
171     THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
172     
173   ASSERT(myBaseImpl);
174   this->GetImpl()->SetOptimizationLevel(l);
175   SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
176 }
177
178 //=======================================================================
179 //function : GetOptimizationLevel
180 //=======================================================================
181
182 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel()
183 {
184   ASSERT(myBaseImpl);
185   return this->GetImpl()->GetOptimizationLevel();
186 }
187
188
189 //=======================================================================
190 //function : SetCollisionMode
191 //=======================================================================
192 void HYBRIDPlugin_Hypothesis_i::SetCollisionMode(CORBA::Short level)
193   throw ( SALOME::SALOME_Exception )
194 {
195   ::HYBRIDPlugin_Hypothesis::CollisionMode l =
196       (::HYBRIDPlugin_Hypothesis::CollisionMode) level;
197   if ( l < ::HYBRIDPlugin_Hypothesis::Decrease ||
198        l > ::HYBRIDPlugin_Hypothesis::Stop )
199     THROW_SALOME_CORBA_EXCEPTION( "Invalid collision mode",SALOME::BAD_PARAM );
200     
201   ASSERT(myBaseImpl);
202   this->GetImpl()->SetCollisionMode(l);
203   SMESH::TPythonDump() << _this() << ".SetCollisionMode( " << level << " )";
204 }
205
206 //=======================================================================
207 //function : GetCollisionMode
208 //=======================================================================
209 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetCollisionMode()
210 {
211   ASSERT(myBaseImpl);
212   return this->GetImpl()->GetCollisionMode();
213 }
214
215 //=======================================================================
216 //function : SetWorkingDirectory
217 //=======================================================================
218 void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
219 {
220   if (!path )
221     THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
222
223   string file(path);
224   const char lastChar = *file.rbegin();
225 #ifdef WIN32
226   if ( lastChar != '\\' ) file += '\\';
227 #else
228   if ( lastChar != '/' ) file += '/';
229 #endif
230   file += "HYBRID.log";
231   SMESH_Mesh_i::PrepareForWriting (file.c_str());
232
233   ASSERT(myBaseImpl);
234   this->GetImpl()->SetWorkingDirectory(path);
235   SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
236 }
237
238 //=======================================================================
239 //function : GetWorkingDirectory
240 //=======================================================================
241 char* HYBRIDPlugin_Hypothesis_i::GetWorkingDirectory()
242 {
243   ASSERT(myBaseImpl);
244   return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
245 }
246
247 //=======================================================================
248 //function : SetKeepFiles
249 //=======================================================================
250 void HYBRIDPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
251 {
252   ASSERT(myBaseImpl);
253   this->GetImpl()->SetKeepFiles(toKeep);
254   SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
255 }
256
257 //=======================================================================
258 //function : GetKeepFiles
259 //=======================================================================
260 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetKeepFiles()
261 {
262   ASSERT(myBaseImpl);
263   return this->GetImpl()->GetKeepFiles();
264 }
265
266 //=======================================================================
267 //function : SetVerboseLevel
268 //=======================================================================
269 void HYBRIDPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
270   throw ( SALOME::SALOME_Exception )
271 {
272   if (level < 0 || level > 10 )
273     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
274                                   SALOME::BAD_PARAM );
275   ASSERT(myBaseImpl);
276   this->GetImpl()->SetVerboseLevel(level);
277   SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
278 }
279
280 //=======================================================================
281 //function : GetVerboseLevel
282 //=======================================================================
283 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetVerboseLevel()
284 {
285   ASSERT(myBaseImpl);
286   return this->GetImpl()->GetVerboseLevel();
287 }
288
289 //=======================================================================
290 //function : SetToCreateNewNodes
291 //=======================================================================
292
293 void HYBRIDPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
294 {
295   ASSERT(myBaseImpl);
296   this->GetImpl()->SetToCreateNewNodes(toCreate);
297   SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
298 }
299
300 //=======================================================================
301 //function : GetToCreateNewNodes
302 //=======================================================================
303
304 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToCreateNewNodes()
305 {
306   ASSERT(myBaseImpl);
307   return this->GetImpl()->GetToCreateNewNodes();
308 }
309
310 //=======================================================================
311 //function : SetToUseBoundaryRecoveryVersion
312 //=======================================================================
313
314 void HYBRIDPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
315 {
316   ASSERT(myBaseImpl);
317   this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
318   SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
319 }
320
321 //=======================================================================
322 //function : GetToUseBoundaryRecoveryVersion
323 //=======================================================================
324
325 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
326 {
327   ASSERT(myBaseImpl);
328   return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
329 }
330
331 //=======================================================================
332 //function : SetFEMCorrection
333 //=======================================================================
334
335 void HYBRIDPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
336 {
337   ASSERT(myBaseImpl);
338   this->GetImpl()->SetFEMCorrection(toUseFem);
339   SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
340 }
341
342 //=======================================================================
343 //function : GetFEMCorrection
344 //=======================================================================
345
346 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetFEMCorrection()
347 {
348   ASSERT(myBaseImpl);
349   return this->GetImpl()->GetFEMCorrection();
350 }
351
352 //=======================================================================
353 //function : SetToRemoveCentralPoint
354 //=======================================================================
355
356 void HYBRIDPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
357 {
358   ASSERT(myBaseImpl);
359   this->GetImpl()->SetToRemoveCentralPoint(toRemove);
360   SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
361 }
362
363 //=======================================================================
364 //function : GetToRemoveCentralPoint
365 //=======================================================================
366
367 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToRemoveCentralPoint()
368 {
369   ASSERT(myBaseImpl);
370   return this->GetImpl()->GetToRemoveCentralPoint();
371 }
372
373 //=======================================================================
374 //function : SetTextOption
375 //=======================================================================
376 void HYBRIDPlugin_Hypothesis_i::SetTextOption(const char* option)
377 {
378   ASSERT(myBaseImpl);
379   this->GetImpl()->SetTextOption(option);
380   SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
381 }
382
383 //=======================================================================
384 //function : GetTextOption
385 //=======================================================================
386 char* HYBRIDPlugin_Hypothesis_i::GetTextOption()
387 {
388   ASSERT(myBaseImpl);
389   return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
390 }
391
392 //=======================================================================
393 //function : SetToRemoveCentralPoint
394 //=======================================================================
395
396 void HYBRIDPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
397 {
398   if (gradation <= 1)
399     THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
400   ASSERT(myBaseImpl);
401   if (gradation != GetGradation()) {
402     this->GetImpl()->SetGradation(gradation);
403     SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
404   }
405 }
406
407 //=======================================================================
408 //function : GetToRemoveCentralPoint
409 //=======================================================================
410
411 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetGradation()
412 {
413   ASSERT(myBaseImpl);
414   return this->GetImpl()->GetGradation();
415 }
416
417 //=======================================================================
418 //function : SetStandardOutputLog
419 //=======================================================================
420 void HYBRIDPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
421 {
422   ASSERT(myBaseImpl);
423   this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
424   SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
425 }
426
427 //=======================================================================
428 //function : GetStandardOutputLog
429 //=======================================================================
430 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetStandardOutputLog()
431 {
432   ASSERT(myBaseImpl);
433   return this->GetImpl()->GetStandardOutputLog();
434 }
435
436 //=======================================================================
437 //function : SetRemoveLogOnSuccess
438 //=======================================================================
439 void HYBRIDPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
440 {
441   ASSERT(myBaseImpl);
442   this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
443   SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
444 }
445
446 //=======================================================================
447 //function : GetRemoveLogOnSuccess
448 //=======================================================================
449 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
450 {
451   ASSERT(myBaseImpl);
452   return this->GetImpl()->GetRemoveLogOnSuccess();
453 }
454
455 //=======================================================================
456 //function : SetBoundaryLayersGrowth
457 //=======================================================================
458 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersGrowth(CORBA::Short level)
459   throw ( SALOME::SALOME_Exception )
460 {
461   ::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth l =
462       (::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth) level;
463   if ( l < ::HYBRIDPlugin_Hypothesis::Layer_Growth_Inward ||
464        l > ::HYBRIDPlugin_Hypothesis::Layer_Growth_Outward )
465     THROW_SALOME_CORBA_EXCEPTION( "Invalid BoundaryLayersGrowth mode",SALOME::BAD_PARAM );
466     
467   ASSERT(myBaseImpl);
468   this->GetImpl()->SetBoundaryLayersGrowth(l);
469   SMESH::TPythonDump() << _this() << ".SetBoundaryLayersGrowth( " << level << " )";
470 }
471
472 //=======================================================================
473 //function : GetBoundaryLayersGrowth
474 //=======================================================================
475 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersGrowth()
476 {
477   ASSERT(myBaseImpl);
478   return this->GetImpl()->GetBoundaryLayersGrowth();
479 }
480
481 //=======================================================================
482 //function : SetElementGeneration
483 //=======================================================================
484 void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level)
485   throw ( SALOME::SALOME_Exception )
486 {
487   ::HYBRIDPlugin_Hypothesis::ElementGeneration l =
488       (::HYBRIDPlugin_Hypothesis::ElementGeneration) level;
489   if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant ||
490        l > ::HYBRIDPlugin_Hypothesis::Generation_Hexa_Dominant )
491     THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM );
492     
493   ASSERT(myBaseImpl);
494   this->GetImpl()->SetElementGeneration(l);
495   SMESH::TPythonDump() << _this() << ".SetElementGeneration( " << level << " )";
496 }
497
498 //=======================================================================
499 //function : GetElementGeneration
500 //=======================================================================
501 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetElementGeneration()
502 {
503   ASSERT(myBaseImpl);
504   return this->GetImpl()->GetElementGeneration();
505 }
506
507 //=======================================================================
508 //function : SetAddMultinormals
509 //=======================================================================
510 void HYBRIDPlugin_Hypothesis_i::SetAddMultinormals(CORBA::Boolean toAddMultinormals)
511 {
512   ASSERT(myBaseImpl);
513   this->GetImpl()->SetAddMultinormals(toAddMultinormals);
514   SMESH::TPythonDump() << _this() << ".SetAddMultinormals( " << toAddMultinormals << " )";
515 }
516
517 //=======================================================================
518 //function : GetAddMultinormals
519 //=======================================================================
520 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetAddMultinormals()
521 {
522   ASSERT(myBaseImpl);
523   return this->GetImpl()->GetAddMultinormals();
524 }
525
526 //=======================================================================
527 //function : SetSmoothNormals
528 //=======================================================================
529 void HYBRIDPlugin_Hypothesis_i::SetSmoothNormals(CORBA::Boolean toSmoothNormals)
530 {
531   ASSERT(myBaseImpl);
532   this->GetImpl()->SetSmoothNormals(toSmoothNormals);
533   SMESH::TPythonDump() << _this() << ".SetSmoothNormals( " << toSmoothNormals << " )";
534 }
535
536 //=======================================================================
537 //function : GetSmoothNormals
538 //=======================================================================
539 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetSmoothNormals()
540 {
541   ASSERT(myBaseImpl);
542   return this->GetImpl()->GetSmoothNormals();
543 }
544
545 //=======================================================================
546 //function : SetHeightFirstLayer
547 //=======================================================================
548 void HYBRIDPlugin_Hypothesis_i::SetHeightFirstLayer(CORBA::Double toHeightFirstLayer)
549 {
550   ASSERT(myBaseImpl);
551   this->GetImpl()->SetHeightFirstLayer(toHeightFirstLayer);
552   SMESH::TPythonDump() << _this() << ".SetHeightFirstLayer( " << toHeightFirstLayer << " )";
553 }
554
555 //=======================================================================
556 //function : GetHeightFirstLayer
557 //=======================================================================
558 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetHeightFirstLayer()
559 {
560   ASSERT(myBaseImpl);
561   return this->GetImpl()->GetHeightFirstLayer();
562 }
563
564 //=======================================================================
565 //function : SetBoundaryLayersProgression
566 //=======================================================================
567 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersProgression(CORBA::Double toBoundaryLayersProgression)
568 {
569   ASSERT(myBaseImpl);
570   this->GetImpl()->SetBoundaryLayersProgression(toBoundaryLayersProgression);
571   SMESH::TPythonDump() << _this() << ".SetBoundaryLayersProgression( " << toBoundaryLayersProgression << " )";
572 }
573
574 //=======================================================================
575 //function : GetBoundaryLayersProgression
576 //=======================================================================
577 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersProgression()
578 {
579   ASSERT(myBaseImpl);
580   return this->GetImpl()->GetBoundaryLayersProgression();
581 }
582
583 //=======================================================================
584 //function : SetMultinormalsAngle
585 //=======================================================================
586 void HYBRIDPlugin_Hypothesis_i::SetMultinormalsAngle(CORBA::Double toMultinormalsAngle)
587 {
588   ASSERT(myBaseImpl);
589   this->GetImpl()->SetMultinormalsAngle(toMultinormalsAngle);
590   SMESH::TPythonDump() << _this() << ".SetMultinormalsAngle( " << toMultinormalsAngle << " )";
591 }
592
593 //=======================================================================
594 //function : GetMultinormalsAngle
595 //=======================================================================
596 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMultinormalsAngle()
597 {
598   ASSERT(myBaseImpl);
599   return this->GetImpl()->GetMultinormalsAngle();
600 }
601
602 //=======================================================================
603 //function : SetNbOfBoundaryLayers
604 //=======================================================================
605 void HYBRIDPlugin_Hypothesis_i::SetNbOfBoundaryLayers(CORBA::Short toNbOfBoundaryLayers)
606 {
607   ASSERT(myBaseImpl);
608   this->GetImpl()->SetNbOfBoundaryLayers(toNbOfBoundaryLayers);
609   SMESH::TPythonDump() << _this() << ".SetNbOfBoundaryLayers( " << toNbOfBoundaryLayers << " )";
610 }
611
612 //=======================================================================
613 //function : GetNbOfBoundaryLayers
614 //=======================================================================
615 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetNbOfBoundaryLayers()
616 {
617   ASSERT(myBaseImpl);
618   return this->GetImpl()->GetNbOfBoundaryLayers();
619 }
620
621 //=======================================================================
622 //function : SetEnforcedVertex
623 //=======================================================================
624
625 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
626     throw (SALOME::SALOME_Exception) {
627   ASSERT(myBaseImpl);
628   MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
629   return p_SetEnforcedVertex(size, x, y, z);
630 }
631
632 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
633     throw (SALOME::SALOME_Exception) {
634   ASSERT(myBaseImpl);
635   MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
636   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
637 }
638
639 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
640     throw (SALOME::SALOME_Exception) {
641   ASSERT(myBaseImpl);
642   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
643   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
644 }
645
646 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
647     throw (SALOME::SALOME_Exception) {
648   ASSERT(myBaseImpl);
649   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
650   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
651 }
652
653 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
654     throw (SALOME::SALOME_Exception) {
655   ASSERT(myBaseImpl);
656   
657   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
658     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
659     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
660   }
661   
662   string theVertexEntry = theVertex->GetStudyEntry();
663   CORBA::Double x = 0, y = 0, z = 0;
664   CORBA::Boolean isCompound = false;
665   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
666   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
667   if (theVertexEntry.empty()) {
668     string aName;
669     if (theVertex->GetShapeType() == GEOM::VERTEX) {
670       aName = "Vertex_";
671     }
672     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
673       aName = "Compound_";
674       isCompound = true;
675     }
676     aName += theVertex->GetEntry();
677     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
678     if (!theSVertex->_is_nil())
679       theVertexEntry = theSVertex->GetID();
680   }
681   if (theVertexEntry.empty())
682     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
683
684   if (theVertex->GetShapeType() == GEOM::VERTEX) {
685     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
686     if (CORBA::is_nil(measureOp))
687       return false;
688     
689     measureOp->PointCoordinates (theVertex, x, y, z);
690     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
691   }
692
693   string theVertexName = theVertex->GetName();
694   MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
695   
696   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
697 }
698
699 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
700     throw (SALOME::SALOME_Exception) {
701   ASSERT(myBaseImpl);
702   
703   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
704     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
705     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
706   }
707   
708   string theVertexEntry = theVertex->GetStudyEntry();
709   CORBA::Double x = 0, y = 0, z = 0;
710   CORBA::Boolean isCompound = false;
711   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
712   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
713   if (theVertexEntry.empty()) {
714     string aName;
715     if (theVertex->GetShapeType() == GEOM::VERTEX) {
716       aName = "Vertex_";
717     }
718     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
719       aName = "Compound_";
720       isCompound = true;
721     }
722     aName += theVertex->GetEntry();
723     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
724     if (!theSVertex->_is_nil())
725       theVertexEntry = theSVertex->GetID();
726   }
727   if (theVertexEntry.empty())
728     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
729
730   if (theVertex->GetShapeType() == GEOM::VERTEX) {
731     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
732     if (CORBA::is_nil(measureOp))
733       return false;
734     
735     measureOp->PointCoordinates (theVertex, x, y, z);
736     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
737   }
738     
739   string theVertexName = theVertex->GetName();
740   MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
741   
742   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
743 }
744
745 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
746                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
747                                                    CORBA::Boolean isCompound)
748     throw (SALOME::SALOME_Exception) {
749   ASSERT(myBaseImpl);
750   MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
751   bool newValue = false;
752
753   ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
754   ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
755   if (string(theVertexEntry).empty()) {
756     coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
757     std::vector<double> coords;
758     coords.push_back(x);
759     coords.push_back(y);
760     coords.push_back(z);
761     if (coordsList.find(coords) == coordsList.end()) {
762       MESSAGE("Coords not found: add it in coordsList");
763       newValue = true;
764     }
765     else {
766       MESSAGE("Coords already found, compare names");
767       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
768       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
769         MESSAGE("The names or size are different: update");
770 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
771         newValue = true;
772       }
773       else {
774         MESSAGE("The names and size are identical");
775       }
776     }
777
778     if (newValue) {
779       if (string(theVertexName).empty()) {
780         if (string(theGroupName).empty())
781           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
782         else
783           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
784       }
785       else {
786         if (string(theGroupName).empty())
787           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\")";
788         else
789           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
790       }
791     }
792   } 
793   else {
794 //   if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
795     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
796 //     ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
797     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
798       MESSAGE("Geom entry not found: add it in enfVertexEntryList");
799       newValue = true;
800     }
801     else {
802       MESSAGE("Geom entry already found, compare names");
803       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
804       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
805         MESSAGE("The names or size are different: update");
806 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
807         newValue = true;
808       }
809       else {
810         MESSAGE("The names and size are identical");
811       }
812     }
813
814     if (newValue) {
815       if (string(theGroupName).empty())
816         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
817       else
818         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
819     }
820   }
821
822   if (newValue)
823     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
824
825   MESSAGE("IDL : SetEnforcedVertexEntry END");
826   return newValue;
827 }
828
829 //=======================================================================
830 //function : GetEnforcedVertex
831 //=======================================================================
832
833 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
834   throw (SALOME::SALOME_Exception)
835 {
836   ASSERT(myBaseImpl);
837   try {
838     bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
839     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
840     return isDone;
841   }
842   catch (const std::invalid_argument& ex) {
843     SALOME::ExceptionStruct ExDescription;
844     ExDescription.text = ex.what();
845     ExDescription.type = SALOME::BAD_PARAM;
846     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
847     ExDescription.lineNumber = 513;
848     throw SALOME::SALOME_Exception(ExDescription);
849   }
850   catch (SALOME_Exception& ex) {
851     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
852   }
853 }
854
855 //=======================================================================
856 //function : GetEnforcedVertex
857 //=======================================================================
858
859 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
860   throw (SALOME::SALOME_Exception)
861 {
862   ASSERT(myBaseImpl);
863   
864   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
865     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
866     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
867   }
868   
869   string theVertexEntry = theVertex->GetStudyEntry();
870   if (theVertexEntry.empty()) {
871     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
872     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
873     string aName;
874     if (theVertex->GetShapeType() == GEOM::VERTEX)
875       aName = "Vertex_";
876     if (theVertex->GetShapeType() == GEOM::COMPOUND)
877       aName = "Compound_";
878     aName += theVertex->GetEntry();
879     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
880     if (!theSVertex->_is_nil())
881       theVertexEntry = theSVertex->GetID();
882   }
883   if (theVertexEntry.empty())
884     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
885
886   string theVertexName = theVertex->GetName();
887   
888   try {
889     bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
890     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
891     return isDone;
892   }
893   catch (const std::invalid_argument& ex) {
894     SALOME::ExceptionStruct ExDescription;
895     ExDescription.text = ex.what();
896     ExDescription.type = SALOME::BAD_PARAM;
897     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
898     ExDescription.lineNumber = 538;
899     throw SALOME::SALOME_Exception(ExDescription);
900   }
901   catch (SALOME_Exception& ex) {
902     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
903   }
904 }
905
906 //=======================================================================
907 //function : GetEnforcedVertices
908 //=======================================================================
909
910 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
911 {
912   ASSERT(myBaseImpl);
913   HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
914
915   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
916   result->length( enfVertexList.size() );
917
918   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
919
920   for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
921     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
922     HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
923     // Name
924     enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
925     // Geom Vertex Entry
926     enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
927     // Coords
928     HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
929     coords->length(currentVertex->coords.size());
930     for (int ind = 0; ind < currentVertex->coords.size(); ind++)
931       coords[ind] = currentVertex->coords[ind];
932     enfVertex->coords = coords;
933     // Group Name
934     enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
935     // Size
936     enfVertex->size = currentVertex->size;
937     // isCompound
938     enfVertex->isCompound = currentVertex->isCompound;
939     
940     result[i]=enfVertex;
941     }
942   
943 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
944
945   return result._retn();
946 }
947
948 //=======================================================================
949 //function : RemoveEnforcedVertex
950 //=======================================================================
951
952 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
953   throw (SALOME::SALOME_Exception)
954 {
955   ASSERT(myBaseImpl);
956   try {
957     bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
958     SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
959     return res;
960   }
961   catch (const std::invalid_argument& ex) {
962     SALOME::ExceptionStruct ExDescription;
963     ExDescription.text = ex.what();
964     ExDescription.type = SALOME::BAD_PARAM;
965     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
966     ExDescription.lineNumber = 625;
967     throw SALOME::SALOME_Exception(ExDescription);
968   }
969   catch (SALOME_Exception& ex) {
970     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
971   }
972 }
973
974 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
975   throw (SALOME::SALOME_Exception)
976 {
977   ASSERT(myBaseImpl);
978   
979   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
980     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
981     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
982   }
983   
984   string theVertexEntry = theVertex->GetStudyEntry();
985   if (theVertexEntry.empty()) {
986     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
987     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
988     string aName;
989     if (theVertex->GetShapeType() == GEOM::VERTEX)
990       aName = "Vertex_";
991     if (theVertex->GetShapeType() == GEOM::COMPOUND)
992       aName = "Compound_";
993     aName += theVertex->GetEntry();
994     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
995     if (!theSVertex->_is_nil())
996       theVertexEntry = theSVertex->GetID();
997   }
998   if (theVertexEntry.empty())
999     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1000   
1001   try {
1002     bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1003     SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1004     return res;
1005   }
1006   catch (const std::invalid_argument& ex) {
1007     SALOME::ExceptionStruct ExDescription;
1008     ExDescription.text = ex.what();
1009     ExDescription.type = SALOME::BAD_PARAM;
1010     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1011     ExDescription.lineNumber = 648;
1012     throw SALOME::SALOME_Exception(ExDescription);
1013   }
1014   catch (SALOME_Exception& ex) {
1015     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1016   }
1017 }
1018
1019 //=======================================================================
1020 //function : ClearEnforcedVertices
1021 //=======================================================================
1022
1023 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
1024 {
1025   ASSERT(myBaseImpl);
1026   this->GetImpl()->ClearEnforcedVertices();
1027   SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1028 }
1029
1030 //=======================================================================
1031 //function : ClearEnforcedMeshes
1032 //=======================================================================
1033
1034 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
1035 {
1036   ASSERT(myBaseImpl);
1037   this->GetImpl()->ClearEnforcedMeshes();
1038   SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1039 }
1040
1041 //=======================================================================
1042 //function : GetEnforcedMeshes
1043 //=======================================================================
1044
1045 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
1046 {
1047   ASSERT(myBaseImpl);
1048   HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
1049
1050   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1051   result->length( enfMeshList.size() );
1052
1053   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
1054
1055   for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1056     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
1057     HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
1058     // Name
1059     enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1060     // Mesh Entry
1061     enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1062     // isCompound
1063     enfMesh->elementType = currentMesh->elementType;
1064     // Group Name
1065     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1066     
1067     result[i]=enfMesh;
1068     }
1069   
1070 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1071
1072   return result._retn();
1073 }
1074
1075 /*!
1076  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1077  */
1078 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1079   throw (SALOME::SALOME_Exception)
1080 {
1081 // #if HYBRID_VERSION >= 42
1082   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1083 // #else
1084 //   SALOME::ExceptionStruct ExDescription;
1085 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1086 //   ExDescription.type = SALOME::BAD_PARAM;
1087 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1088 //   ExDescription.lineNumber = 719;
1089 //   throw SALOME::SALOME_Exception(ExDescription);
1090 // #endif
1091 }
1092
1093 /*!
1094  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1095  */
1096 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1097   throw (SALOME::SALOME_Exception)
1098 {
1099 //   MESSAGE("HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh");
1100 // #if HYBRID_VERSION >= 42
1101   return p_SetEnforcedMesh(theSource, theType);
1102 // #else
1103 //   SALOME::ExceptionStruct ExDescription;
1104 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1105 //   ExDescription.type = SALOME::BAD_PARAM;
1106 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1107 //   ExDescription.lineNumber = 750;
1108 //   throw SALOME::SALOME_Exception(ExDescription);
1109 // #endif
1110 }
1111
1112 /*!
1113  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName.
1114  */
1115 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
1116   throw (SALOME::SALOME_Exception)
1117 {
1118 // #if HYBRID_VERSION >= 42
1119   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1120 // #else
1121 //   SALOME::ExceptionStruct ExDescription;
1122 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1123 //   ExDescription.type = SALOME::BAD_PARAM;
1124 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1125 //   ExDescription.lineNumber = 750;
1126 //   throw SALOME::SALOME_Exception(ExDescription);
1127 // #endif
1128 }
1129
1130 /*!
1131  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1132  */
1133 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
1134   throw (SALOME::SALOME_Exception)
1135 {
1136 // #if HYBRID_VERSION >= 42
1137   return p_SetEnforcedMesh(theSource, theType);
1138 // #else
1139 //   SALOME::ExceptionStruct ExDescription;
1140 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1141 //   ExDescription.type = SALOME::BAD_PARAM;
1142 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1143 //   ExDescription.lineNumber = 750;
1144 //   throw SALOME::SALOME_Exception(ExDescription);
1145 // #endif
1146 }
1147
1148 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
1149   throw (SALOME::SALOME_Exception)
1150 {
1151   MESSAGE("HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh");
1152   ASSERT(myBaseImpl);
1153   
1154   if (CORBA::is_nil( theSource ))
1155   {
1156     SALOME::ExceptionStruct ExDescription;
1157     ExDescription.text = "The source mesh CORBA object is NULL";
1158     ExDescription.type = SALOME::BAD_PARAM;
1159     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1160     ExDescription.lineNumber = 840;
1161     throw SALOME::SALOME_Exception(ExDescription);
1162   }
1163   
1164   switch (theType) {
1165     case SMESH::NODE:
1166       MESSAGE("Required type is NODE");
1167       break;
1168     case SMESH::EDGE:
1169       MESSAGE("Required type is EDGE");
1170       break;
1171     case SMESH::FACE:
1172       MESSAGE("Required type is FACE");
1173       break;
1174     default:
1175         MESSAGE("Incompatible required type: " << theType);
1176         return false;
1177   }
1178 //   MESSAGE("Required type is "<<theType);
1179   SMESH::array_of_ElementType_var types = theSource->GetTypes();
1180   MESSAGE("Available types:");
1181   for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
1182   if ( types->length() >= 1 && types[types->length()-1] <  theType)
1183   {
1184     MESSAGE("Required type not available");
1185     return false;
1186 //     SALOME::ExceptionStruct ExDescription;
1187 //     ExDescription.text = "The source mesh has bad type";
1188 //     ExDescription.type = SALOME::BAD_PARAM;
1189 //     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1190 //     ExDescription.lineNumber = 840;
1191 //     throw SALOME::SALOME_Exception(ExDescription);
1192   }
1193   
1194
1195   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1196   SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1197
1198   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1199   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1200   SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1201
1202   string enfMeshName = theName;
1203   if (enfMeshName.empty())
1204           enfMeshName = SObj->GetName();
1205
1206   if (theMesh_i)
1207   {
1208     try {
1209         bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1210                 if (theGroupName != "") {
1211                   SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1212                                                                 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1213                 }
1214                 else {
1215                   SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1216                                                                 << theSource << ".GetMesh(), " << theType << " )";
1217                 }
1218
1219       return res;
1220     }
1221     catch (const std::invalid_argument& ex) {
1222       SALOME::ExceptionStruct ExDescription;
1223       ExDescription.text = ex.what();
1224       ExDescription.type = SALOME::BAD_PARAM;
1225       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1226       ExDescription.lineNumber = 840;
1227       throw SALOME::SALOME_Exception(ExDescription);
1228     }
1229     catch (SALOME_Exception& ex) {
1230       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1231     }
1232   }
1233   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1234   {
1235     MESSAGE("The source is a group")
1236     try {
1237         bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1238         if (theGroupName != "") {
1239           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1240                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1241         }
1242         else {
1243           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1244                                 << theSource << ", " << theType << " )";
1245         }
1246       return res;
1247     }
1248     catch (const std::invalid_argument& ex) {
1249       SALOME::ExceptionStruct ExDescription;
1250       ExDescription.text = ex.what();
1251       ExDescription.type = SALOME::BAD_PARAM;
1252       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1253       ExDescription.lineNumber = 840;
1254       throw SALOME::SALOME_Exception(ExDescription);
1255     }
1256     catch (SALOME_Exception& ex) {
1257       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1258     }
1259   }
1260   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1261   {
1262     MESSAGE("The source is a group on geom")
1263     try {
1264         bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1265         if (theGroupName != "") {
1266           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1267                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1268         }
1269         else {
1270           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1271                                 << theSource << ", " << theType << " )";
1272         }
1273       return res;
1274     }
1275     catch (const std::invalid_argument& ex) {
1276       SALOME::ExceptionStruct ExDescription;
1277       ExDescription.text = ex.what();
1278       ExDescription.type = SALOME::BAD_PARAM;
1279       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1280       ExDescription.lineNumber = 840;
1281       throw SALOME::SALOME_Exception(ExDescription);
1282     }
1283     catch (SALOME_Exception& ex) {
1284       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1285     }
1286   }
1287   return false;
1288 }
1289 //=============================================================================
1290 /*!
1291  *  Get implementation
1292  */
1293 //=============================================================================
1294
1295 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1296 {
1297   return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1298 }
1299
1300 //================================================================================
1301 /*!
1302  * \brief Verify whether hypothesis supports given entity type 
1303  */
1304 //================================================================================  
1305
1306 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1307 {
1308   return type == SMESH::DIM_3D;
1309 }
1310