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