1 // Copyright (C) 2004-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : HYBRIDPlugin_Hypothesis_i.cxx
21 // Created : Wed Apr 2 13:53:01 2008
22 // Author : Edward AGAPOV (eap)
24 #include "HYBRIDPlugin_Hypothesis_i.hxx"
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>
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"
40 // SALOME KERNEL includes
41 #include "SALOMEDSClient.hxx"
42 #include <SALOMEDSClient_definitions.hxx>
44 // #include <SALOMEconfig.h>
45 // #include CORBA_SERVER_HEADER(SALOMEDS)
47 //=======================================================================
48 //function : HYBRIDPlugin_Hypothesis_i
49 //=======================================================================
51 HYBRIDPlugin_Hypothesis_i::HYBRIDPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
53 ::SMESH_Gen* theGenImpl)
54 : SALOME::GenericObj_i( thePOA ),
55 SMESH_Hypothesis_i( thePOA )
57 MESSAGE( "HYBRIDPlugin_Hypothesis_i::HYBRIDPlugin_Hypothesis_i" );
58 myBaseImpl = new ::HYBRIDPlugin_Hypothesis (theGenImpl->GetANewId(),
63 //=======================================================================
64 //function : ~HYBRIDPlugin_Hypothesis_i
65 //=======================================================================
67 HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i()
69 MESSAGE( "HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i" );
72 //=======================================================================
73 //function : SetToMeshHoles
74 //=======================================================================
76 void HYBRIDPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
79 this->GetImpl()->SetToMeshHoles(toMesh);
80 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
83 //=======================================================================
84 //function : GetToMeshHoles
85 //=======================================================================
87 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMeshHoles()
90 return this->GetImpl()->GetToMeshHoles();
93 //=======================================================================
94 //function : SetToMakeGroupsOfDomains
95 //=======================================================================
97 void HYBRIDPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
100 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
101 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
104 //=======================================================================
105 //function : GetToMakeGroupsOfDomains
106 //=======================================================================
108 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
111 return this->GetImpl()->GetToMakeGroupsOfDomains();
114 //=======================================================================
115 //function : SetMaximumMemory
116 //=======================================================================
118 void HYBRIDPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
119 throw ( SALOME::SALOME_Exception )
122 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
124 this->GetImpl()->SetMaximumMemory(MB);
125 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
128 //=======================================================================
129 //function : GetMaximumMemory
130 //=======================================================================
132 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMaximumMemory()
135 return this->GetImpl()->GetMaximumMemory();
138 //=======================================================================
139 //function : SetInitialMemory
140 //=======================================================================
142 void HYBRIDPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
143 throw ( SALOME::SALOME_Exception )
146 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
148 this->GetImpl()->SetInitialMemory(MB);
149 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
152 //=======================================================================
153 //function : GetInitialMemory
154 //=======================================================================
156 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetInitialMemory()
159 return this->GetImpl()->GetInitialMemory();
162 //=======================================================================
163 //function : SetOptimizationLevel
164 //=======================================================================
166 void HYBRIDPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
167 throw ( SALOME::SALOME_Exception )
169 ::HYBRIDPlugin_Hypothesis::OptimizationLevel l =
170 (::HYBRIDPlugin_Hypothesis::OptimizationLevel) level;
171 if ( l < ::HYBRIDPlugin_Hypothesis::None ||
172 l > ::HYBRIDPlugin_Hypothesis::Strong )
173 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
176 this->GetImpl()->SetOptimizationLevel(l);
177 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
180 //=======================================================================
181 //function : GetOptimizationLevel
182 //=======================================================================
184 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel()
187 return this->GetImpl()->GetOptimizationLevel();
190 //=======================================================================
191 //function : SetWorkingDirectory
192 //=======================================================================
194 void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
197 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
200 const char lastChar = *file.rbegin();
202 if ( lastChar != '\\' ) file += '\\';
204 if ( lastChar != '/' ) file += '/';
206 file += "HYBRID.log";
207 SMESH_Mesh_i::PrepareForWriting (file.c_str());
210 this->GetImpl()->SetWorkingDirectory(path);
211 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
214 //=======================================================================
215 //function : GetWorkingDirectory
216 //=======================================================================
218 char* HYBRIDPlugin_Hypothesis_i::GetWorkingDirectory()
221 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
224 //=======================================================================
225 //function : SetKeepFiles
226 //=======================================================================
228 void HYBRIDPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
231 this->GetImpl()->SetKeepFiles(toKeep);
232 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
235 //=======================================================================
236 //function : GetKeepFiles
237 //=======================================================================
239 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetKeepFiles()
242 return this->GetImpl()->GetKeepFiles();
245 //=======================================================================
246 //function : SetVerboseLevel
247 //=======================================================================
249 void HYBRIDPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
250 throw ( SALOME::SALOME_Exception )
252 if (level < 0 || level > 10 )
253 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
256 this->GetImpl()->SetVerboseLevel(level);
257 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
260 //=======================================================================
261 //function : GetVerboseLevel
262 //=======================================================================
264 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetVerboseLevel()
267 return this->GetImpl()->GetVerboseLevel();
270 //=======================================================================
271 //function : SetToCreateNewNodes
272 //=======================================================================
274 void HYBRIDPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
277 this->GetImpl()->SetToCreateNewNodes(toCreate);
278 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
281 //=======================================================================
282 //function : GetToCreateNewNodes
283 //=======================================================================
285 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToCreateNewNodes()
288 return this->GetImpl()->GetToCreateNewNodes();
291 //=======================================================================
292 //function : SetToUseBoundaryRecoveryVersion
293 //=======================================================================
295 void HYBRIDPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
298 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
299 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
302 //=======================================================================
303 //function : GetToUseBoundaryRecoveryVersion
304 //=======================================================================
306 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
309 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
312 //=======================================================================
313 //function : SetFEMCorrection
314 //=======================================================================
316 void HYBRIDPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
319 this->GetImpl()->SetFEMCorrection(toUseFem);
320 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
323 //=======================================================================
324 //function : GetFEMCorrection
325 //=======================================================================
327 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetFEMCorrection()
330 return this->GetImpl()->GetFEMCorrection();
333 //=======================================================================
334 //function : SetToRemoveCentralPoint
335 //=======================================================================
337 void HYBRIDPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
340 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
341 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
344 //=======================================================================
345 //function : GetToRemoveCentralPoint
346 //=======================================================================
348 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToRemoveCentralPoint()
351 return this->GetImpl()->GetToRemoveCentralPoint();
354 //=======================================================================
355 //function : SetTextOption
356 //=======================================================================
358 void HYBRIDPlugin_Hypothesis_i::SetTextOption(const char* option)
361 this->GetImpl()->SetTextOption(option);
362 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
365 //=======================================================================
366 //function : GetTextOption
367 //=======================================================================
369 char* HYBRIDPlugin_Hypothesis_i::GetTextOption()
372 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
375 //=======================================================================
376 //function : SetToRemoveCentralPoint
377 //=======================================================================
379 void HYBRIDPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
382 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
384 if (gradation != GetGradation()) {
385 this->GetImpl()->SetGradation(gradation);
386 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
390 //=======================================================================
391 //function : GetToRemoveCentralPoint
392 //=======================================================================
394 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetGradation()
397 return this->GetImpl()->GetGradation();
400 //=======================================================================
401 //function : SetStandardOutputLog
402 //=======================================================================
404 void HYBRIDPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
407 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
408 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
411 //=======================================================================
412 //function : GetStandardOutputLog
413 //=======================================================================
415 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetStandardOutputLog()
418 return this->GetImpl()->GetStandardOutputLog();
421 //=======================================================================
422 //function : SetRemoveLogOnSuccess
423 //=======================================================================
425 void HYBRIDPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
428 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
429 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
432 //=======================================================================
433 //function : GetRemoveLogOnSuccess
434 //=======================================================================
436 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
439 return this->GetImpl()->GetRemoveLogOnSuccess();
442 //=======================================================================
443 //function : SetEnforcedVertex
444 //=======================================================================
446 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
447 throw (SALOME::SALOME_Exception) {
449 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
450 return p_SetEnforcedVertex(size, x, y, z);
453 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
454 throw (SALOME::SALOME_Exception) {
456 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
457 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
460 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
461 throw (SALOME::SALOME_Exception) {
463 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
464 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
467 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
468 throw (SALOME::SALOME_Exception) {
470 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
471 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
474 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
475 throw (SALOME::SALOME_Exception) {
478 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
479 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
480 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
483 string theVertexEntry = theVertex->GetStudyEntry();
484 CORBA::Double x = 0, y = 0, z = 0;
485 CORBA::Boolean isCompound = false;
486 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
487 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
488 if (theVertexEntry.empty()) {
490 if (theVertex->GetShapeType() == GEOM::VERTEX) {
493 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
497 aName += theVertex->GetEntry();
498 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
499 if (!theSVertex->_is_nil())
500 theVertexEntry = theSVertex->GetID();
502 if (theVertexEntry.empty())
503 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
505 if (theVertex->GetShapeType() == GEOM::VERTEX) {
506 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
507 if (CORBA::is_nil(measureOp))
510 measureOp->PointCoordinates (theVertex, x, y, z);
511 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
514 string theVertexName = theVertex->GetName();
515 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
517 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
520 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
521 throw (SALOME::SALOME_Exception) {
524 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
525 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
526 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
529 string theVertexEntry = theVertex->GetStudyEntry();
530 CORBA::Double x = 0, y = 0, z = 0;
531 CORBA::Boolean isCompound = false;
532 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
533 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
534 if (theVertexEntry.empty()) {
536 if (theVertex->GetShapeType() == GEOM::VERTEX) {
539 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
543 aName += theVertex->GetEntry();
544 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
545 if (!theSVertex->_is_nil())
546 theVertexEntry = theSVertex->GetID();
548 if (theVertexEntry.empty())
549 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
551 if (theVertex->GetShapeType() == GEOM::VERTEX) {
552 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
553 if (CORBA::is_nil(measureOp))
556 measureOp->PointCoordinates (theVertex, x, y, z);
557 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
560 string theVertexName = theVertex->GetName();
561 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
563 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
566 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
567 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
568 CORBA::Boolean isCompound)
569 throw (SALOME::SALOME_Exception) {
571 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
572 bool newValue = false;
574 ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
575 ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
576 if (string(theVertexEntry).empty()) {
577 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
578 std::vector<double> coords;
582 if (coordsList.find(coords) == coordsList.end()) {
583 MESSAGE("Coords not found: add it in coordsList");
587 MESSAGE("Coords already found, compare names");
588 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
589 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
590 MESSAGE("The names or size are different: update");
591 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
595 MESSAGE("The names and size are identical");
600 if (string(theVertexName).empty()) {
601 if (string(theGroupName).empty())
602 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
604 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
607 if (string(theGroupName).empty())
608 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
610 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
615 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
616 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
617 // ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
618 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
619 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
623 MESSAGE("Geom entry already found, compare names");
624 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
625 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
626 MESSAGE("The names or size are different: update");
627 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
631 MESSAGE("The names and size are identical");
636 if (string(theGroupName).empty())
637 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
639 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
644 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
646 MESSAGE("IDL : SetEnforcedVertexEntry END");
650 //=======================================================================
651 //function : GetEnforcedVertex
652 //=======================================================================
654 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
655 throw (SALOME::SALOME_Exception)
659 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
660 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
663 catch (const std::invalid_argument& ex) {
664 SALOME::ExceptionStruct ExDescription;
665 ExDescription.text = ex.what();
666 ExDescription.type = SALOME::BAD_PARAM;
667 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
668 ExDescription.lineNumber = 513;
669 throw SALOME::SALOME_Exception(ExDescription);
671 catch (SALOME_Exception& ex) {
672 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
676 //=======================================================================
677 //function : GetEnforcedVertex
678 //=======================================================================
680 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
681 throw (SALOME::SALOME_Exception)
685 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
686 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
687 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
690 string theVertexEntry = theVertex->GetStudyEntry();
691 if (theVertexEntry.empty()) {
692 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
693 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
695 if (theVertex->GetShapeType() == GEOM::VERTEX)
697 if (theVertex->GetShapeType() == GEOM::COMPOUND)
699 aName += theVertex->GetEntry();
700 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
701 if (!theSVertex->_is_nil())
702 theVertexEntry = theSVertex->GetID();
704 if (theVertexEntry.empty())
705 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
707 string theVertexName = theVertex->GetName();
710 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
711 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
714 catch (const std::invalid_argument& ex) {
715 SALOME::ExceptionStruct ExDescription;
716 ExDescription.text = ex.what();
717 ExDescription.type = SALOME::BAD_PARAM;
718 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
719 ExDescription.lineNumber = 538;
720 throw SALOME::SALOME_Exception(ExDescription);
722 catch (SALOME_Exception& ex) {
723 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
727 //=======================================================================
728 //function : GetEnforcedVertices
729 //=======================================================================
731 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
734 HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
736 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
737 result->length( enfVertexList.size() );
739 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
741 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
742 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
743 HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
745 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
747 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
749 HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
750 coords->length(currentVertex->coords.size());
751 for (int ind = 0; ind < currentVertex->coords.size(); ind++)
752 coords[ind] = currentVertex->coords[ind];
753 enfVertex->coords = coords;
755 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
757 enfVertex->size = currentVertex->size;
759 enfVertex->isCompound = currentVertex->isCompound;
764 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
766 return result._retn();
769 //=======================================================================
770 //function : RemoveEnforcedVertex
771 //=======================================================================
773 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
774 throw (SALOME::SALOME_Exception)
778 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
779 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
782 catch (const std::invalid_argument& ex) {
783 SALOME::ExceptionStruct ExDescription;
784 ExDescription.text = ex.what();
785 ExDescription.type = SALOME::BAD_PARAM;
786 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
787 ExDescription.lineNumber = 625;
788 throw SALOME::SALOME_Exception(ExDescription);
790 catch (SALOME_Exception& ex) {
791 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
795 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
796 throw (SALOME::SALOME_Exception)
800 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
801 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
802 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
805 string theVertexEntry = theVertex->GetStudyEntry();
806 if (theVertexEntry.empty()) {
807 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
808 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
810 if (theVertex->GetShapeType() == GEOM::VERTEX)
812 if (theVertex->GetShapeType() == GEOM::COMPOUND)
814 aName += theVertex->GetEntry();
815 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
816 if (!theSVertex->_is_nil())
817 theVertexEntry = theSVertex->GetID();
819 if (theVertexEntry.empty())
820 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
823 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
824 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
827 catch (const std::invalid_argument& ex) {
828 SALOME::ExceptionStruct ExDescription;
829 ExDescription.text = ex.what();
830 ExDescription.type = SALOME::BAD_PARAM;
831 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
832 ExDescription.lineNumber = 648;
833 throw SALOME::SALOME_Exception(ExDescription);
835 catch (SALOME_Exception& ex) {
836 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
840 //=======================================================================
841 //function : ClearEnforcedVertices
842 //=======================================================================
844 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
847 this->GetImpl()->ClearEnforcedVertices();
848 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
851 //=======================================================================
852 //function : ClearEnforcedMeshes
853 //=======================================================================
855 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
858 this->GetImpl()->ClearEnforcedMeshes();
859 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
862 //=======================================================================
863 //function : GetEnforcedMeshes
864 //=======================================================================
866 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
869 HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
871 const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
872 result->length( enfMeshList.size() );
874 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
876 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
877 ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
878 HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
880 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
882 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
884 enfMesh->elementType = currentMesh->elementType;
886 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
891 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
893 return result._retn();
897 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
899 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
900 throw (SALOME::SALOME_Exception)
902 // #if HYBRID_VERSION >= 42
903 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
905 // SALOME::ExceptionStruct ExDescription;
906 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
907 // ExDescription.type = SALOME::BAD_PARAM;
908 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
909 // ExDescription.lineNumber = 719;
910 // throw SALOME::SALOME_Exception(ExDescription);
915 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
917 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
918 throw (SALOME::SALOME_Exception)
920 // MESSAGE("HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh");
921 // #if HYBRID_VERSION >= 42
922 return p_SetEnforcedMesh(theSource, theType);
924 // SALOME::ExceptionStruct ExDescription;
925 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
926 // ExDescription.type = SALOME::BAD_PARAM;
927 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
928 // ExDescription.lineNumber = 750;
929 // throw SALOME::SALOME_Exception(ExDescription);
934 * \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.
936 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
937 throw (SALOME::SALOME_Exception)
939 // #if HYBRID_VERSION >= 42
940 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
942 // SALOME::ExceptionStruct ExDescription;
943 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
944 // ExDescription.type = SALOME::BAD_PARAM;
945 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
946 // ExDescription.lineNumber = 750;
947 // throw SALOME::SALOME_Exception(ExDescription);
952 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
954 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
955 throw (SALOME::SALOME_Exception)
957 // #if HYBRID_VERSION >= 42
958 return p_SetEnforcedMesh(theSource, theType);
960 // SALOME::ExceptionStruct ExDescription;
961 // ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
962 // ExDescription.type = SALOME::BAD_PARAM;
963 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
964 // ExDescription.lineNumber = 750;
965 // throw SALOME::SALOME_Exception(ExDescription);
969 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
970 throw (SALOME::SALOME_Exception)
972 MESSAGE("HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh");
975 if (CORBA::is_nil( theSource ))
977 SALOME::ExceptionStruct ExDescription;
978 ExDescription.text = "The source mesh CORBA object is NULL";
979 ExDescription.type = SALOME::BAD_PARAM;
980 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
981 ExDescription.lineNumber = 840;
982 throw SALOME::SALOME_Exception(ExDescription);
987 MESSAGE("Required type is NODE");
990 MESSAGE("Required type is EDGE");
993 MESSAGE("Required type is FACE");
996 MESSAGE("Incompatible required type: " << theType);
999 // MESSAGE("Required type is "<<theType);
1000 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1001 MESSAGE("Available types:");
1002 for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
1003 if ( types->length() >= 1 && types[types->length()-1] < theType)
1005 MESSAGE("Required type not available");
1007 // SALOME::ExceptionStruct ExDescription;
1008 // ExDescription.text = "The source mesh has bad type";
1009 // ExDescription.type = SALOME::BAD_PARAM;
1010 // ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1011 // ExDescription.lineNumber = 840;
1012 // throw SALOME::SALOME_Exception(ExDescription);
1016 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1017 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1019 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1020 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1021 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1023 string enfMeshName = theName;
1024 if (enfMeshName.empty())
1025 enfMeshName = SObj->GetName();
1030 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1031 if (theGroupName != "") {
1032 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1033 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1036 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1037 << theSource << ".GetMesh(), " << theType << " )";
1042 catch (const std::invalid_argument& ex) {
1043 SALOME::ExceptionStruct ExDescription;
1044 ExDescription.text = ex.what();
1045 ExDescription.type = SALOME::BAD_PARAM;
1046 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1047 ExDescription.lineNumber = 840;
1048 throw SALOME::SALOME_Exception(ExDescription);
1050 catch (SALOME_Exception& ex) {
1051 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1054 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1056 MESSAGE("The source is a group")
1058 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1059 if (theGroupName != "") {
1060 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1061 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1064 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1065 << theSource << ", " << theType << " )";
1069 catch (const std::invalid_argument& ex) {
1070 SALOME::ExceptionStruct ExDescription;
1071 ExDescription.text = ex.what();
1072 ExDescription.type = SALOME::BAD_PARAM;
1073 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1074 ExDescription.lineNumber = 840;
1075 throw SALOME::SALOME_Exception(ExDescription);
1077 catch (SALOME_Exception& ex) {
1078 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1081 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1083 MESSAGE("The source is a group on geom")
1085 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1086 if (theGroupName != "") {
1087 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1088 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1091 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1092 << theSource << ", " << theType << " )";
1096 catch (const std::invalid_argument& ex) {
1097 SALOME::ExceptionStruct ExDescription;
1098 ExDescription.text = ex.what();
1099 ExDescription.type = SALOME::BAD_PARAM;
1100 ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1101 ExDescription.lineNumber = 840;
1102 throw SALOME::SALOME_Exception(ExDescription);
1104 catch (SALOME_Exception& ex) {
1105 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1110 //=============================================================================
1112 * Get implementation
1114 //=============================================================================
1116 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1118 return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1121 //================================================================================
1123 * \brief Verify whether hypothesis supports given entity type
1125 //================================================================================
1127 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1129 return type == SMESH::DIM_3D;