1 // Copyright (C) 2004-2016 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, or (at your option) any later version.
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 : GHS3DPlugin_Hypothesis_i.cxx
21 // Created : Wed Apr 2 13:53:01 2008
22 // Author : Edward AGAPOV (eap)
24 #include "GHS3DPlugin_Hypothesis_i.hxx"
26 #include <SMESH_Gen.hxx>
27 #include <SMESH_PythonDump.hxx>
29 #include <Utils_CorbaException.hxx>
30 #include <utilities.h>
31 #include <SMESH_Mesh_i.hxx>
32 #include <SMESH_Group_i.hxx>
33 #include <SMESH_Gen_i.hxx>
34 //#include <SMESH_TypeDefs.hxx>
35 #include <SMESHDS_GroupBase.hxx>
37 // SALOME KERNEL includes
38 // #include <SALOMEDSClient.hxx>
39 // #include <SALOMEDSClient_definitions.hxx>
43 //=======================================================================
44 //function : GHS3DPlugin_Hypothesis_i
45 //=======================================================================
47 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
49 ::SMESH_Gen* theGenImpl)
50 : SALOME::GenericObj_i( thePOA ),
51 SMESH_Hypothesis_i( thePOA )
53 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
58 //=======================================================================
59 //function : ~GHS3DPlugin_Hypothesis_i
60 //=======================================================================
62 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
66 //=======================================================================
67 //function : SetToMeshHoles
68 //=======================================================================
70 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
73 this->GetImpl()->SetToMeshHoles(toMesh);
74 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
77 //=======================================================================
78 //function : GetToMeshHoles
79 //=======================================================================
81 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
84 return this->GetImpl()->GetToMeshHoles();
87 //=======================================================================
88 //function : SetToMakeGroupsOfDomains
89 //=======================================================================
91 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
94 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
95 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
98 //=======================================================================
99 //function : GetToMakeGroupsOfDomains
100 //=======================================================================
102 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
105 return this->GetImpl()->GetToMakeGroupsOfDomains();
108 //=======================================================================
109 //function : SetMaximumMemory
110 //=======================================================================
112 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
113 throw ( SALOME::SALOME_Exception )
116 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
118 this->GetImpl()->SetMaximumMemory(MB);
119 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
122 //=======================================================================
123 //function : GetMaximumMemory
124 //=======================================================================
126 CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
129 return this->GetImpl()->GetMaximumMemory();
132 //=======================================================================
133 //function : SetInitialMemory
134 //=======================================================================
136 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
137 throw ( SALOME::SALOME_Exception )
140 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
142 this->GetImpl()->SetInitialMemory(MB);
143 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
146 //=======================================================================
147 //function : GetInitialMemory
148 //=======================================================================
150 CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
153 return this->GetImpl()->GetInitialMemory();
156 //=======================================================================
157 //function : SetOptimizationLevel
158 //=======================================================================
160 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
161 throw ( SALOME::SALOME_Exception )
163 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
164 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
165 if ( l < ::GHS3DPlugin_Hypothesis::None ||
166 l > ::GHS3DPlugin_Hypothesis::Strong )
167 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
170 this->GetImpl()->SetOptimizationLevel(l);
171 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
174 //=======================================================================
175 //function : GetOptimizationLevel
176 //=======================================================================
178 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
181 return this->GetImpl()->GetOptimizationLevel();
184 //=======================================================================
185 //function : SetWorkingDirectory
186 //=======================================================================
188 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
191 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
194 const char lastChar = *file.rbegin();
196 if ( lastChar != '\\' ) file += '\\';
198 if ( lastChar != '/' ) file += '/';
201 SMESH_Mesh_i::PrepareForWriting (file.c_str());
204 this->GetImpl()->SetWorkingDirectory(path);
205 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
208 //=======================================================================
209 //function : GetWorkingDirectory
210 //=======================================================================
212 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
215 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
218 //=======================================================================
219 //function : SetKeepFiles
220 //=======================================================================
222 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
225 this->GetImpl()->SetKeepFiles(toKeep);
226 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
229 //=======================================================================
230 //function : GetKeepFiles
231 //=======================================================================
233 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
236 return this->GetImpl()->GetKeepFiles();
239 //=======================================================================
240 //function : SetVerboseLevel
241 //=======================================================================
243 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
244 throw ( SALOME::SALOME_Exception )
246 if (level < 0 || level > 10 )
247 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
250 this->GetImpl()->SetVerboseLevel(level);
251 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
254 //=======================================================================
255 //function : GetVerboseLevel
256 //=======================================================================
258 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
261 return this->GetImpl()->GetVerboseLevel();
264 //=======================================================================
265 //function : SetToCreateNewNodes
266 //=======================================================================
268 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
271 this->GetImpl()->SetToCreateNewNodes(toCreate);
272 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
275 //=======================================================================
276 //function : GetToCreateNewNodes
277 //=======================================================================
279 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
282 return this->GetImpl()->GetToCreateNewNodes();
285 //=======================================================================
286 //function : SetToUseBoundaryRecoveryVersion
287 //=======================================================================
289 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
292 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
293 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
296 //=======================================================================
297 //function : GetToUseBoundaryRecoveryVersion
298 //=======================================================================
300 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
303 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
306 //=======================================================================
307 //function : SetFEMCorrection
308 //=======================================================================
310 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
313 this->GetImpl()->SetFEMCorrection(toUseFem);
314 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
317 //=======================================================================
318 //function : GetFEMCorrection
319 //=======================================================================
321 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
324 return this->GetImpl()->GetFEMCorrection();
327 //=======================================================================
328 //function : SetToRemoveCentralPoint
329 //=======================================================================
331 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
334 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
335 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
338 //=======================================================================
339 //function : GetToRemoveCentralPoint
340 //=======================================================================
342 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
345 return this->GetImpl()->GetToRemoveCentralPoint();
348 //=======================================================================
349 //function : SetTextOption
350 //=======================================================================
352 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
355 this->GetImpl()->SetAdvancedOption(option);
356 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
359 //=======================================================================
360 //function : GetTextOption
361 //=======================================================================
363 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
366 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
369 //=======================================================================
370 //function : SetAdvancedOption
371 //=======================================================================
373 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
376 this->GetImpl()->SetAdvancedOption(option);
377 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
380 //=======================================================================
381 //function : GetAdvancedOption
382 //=======================================================================
384 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
387 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
390 //=======================================================================
391 //function : SetToRemoveCentralPoint
392 //=======================================================================
394 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
397 if (gradation != GetGradation()) {
398 this->GetImpl()->SetGradation(gradation);
399 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
403 //=======================================================================
404 //function : GetToRemoveCentralPoint
405 //=======================================================================
407 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
410 return this->GetImpl()->GetGradation();
413 //=======================================================================
414 //function : SetStandardOutputLog
415 //=======================================================================
417 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
420 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
421 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
424 //=======================================================================
425 //function : GetStandardOutputLog
426 //=======================================================================
428 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
431 return this->GetImpl()->GetStandardOutputLog();
434 //=======================================================================
435 //function : SetRemoveLogOnSuccess
436 //=======================================================================
438 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
441 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
442 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
445 //=======================================================================
446 //function : GetRemoveLogOnSuccess
447 //=======================================================================
449 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
452 return this->GetImpl()->GetRemoveLogOnSuccess();
455 //=======================================================================
456 //function : SetEnforcedVertex
457 //=======================================================================
459 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
460 throw (SALOME::SALOME_Exception) {
462 return p_SetEnforcedVertex(size, x, y, z);
465 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
466 throw (SALOME::SALOME_Exception) {
468 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
471 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
472 throw (SALOME::SALOME_Exception) {
474 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
477 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
478 throw (SALOME::SALOME_Exception) {
480 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
483 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
484 throw (SALOME::SALOME_Exception) {
487 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
488 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
491 string theVertexEntry = theVertex->GetStudyEntry();
492 CORBA::Double x = 0, y = 0, z = 0;
493 CORBA::Boolean isCompound = false;
494 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
495 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
496 if (theVertexEntry.empty()) {
498 if (theVertex->GetShapeType() == GEOM::VERTEX) {
501 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
505 aName += theVertex->GetEntry();
506 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
507 if (!theSVertex->_is_nil())
508 theVertexEntry = theSVertex->GetID();
510 if (theVertexEntry.empty())
511 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
513 if (theVertex->GetShapeType() == GEOM::VERTEX) {
514 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
515 if (CORBA::is_nil(measureOp))
518 measureOp->PointCoordinates (theVertex, x, y, z);
521 string theVertexName = theVertex->GetName();
523 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
526 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
527 throw (SALOME::SALOME_Exception) {
530 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
531 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
534 string theVertexEntry = theVertex->GetStudyEntry();
535 CORBA::Double x = 0, y = 0, z = 0;
536 CORBA::Boolean isCompound = false;
537 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
538 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
539 if (theVertexEntry.empty()) {
541 if (theVertex->GetShapeType() == GEOM::VERTEX) {
544 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
548 aName += theVertex->GetEntry();
549 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
550 if (!theSVertex->_is_nil())
551 theVertexEntry = theSVertex->GetID();
553 if (theVertexEntry.empty())
554 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
556 if (theVertex->GetShapeType() == GEOM::VERTEX) {
557 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
558 if (CORBA::is_nil(measureOp))
561 measureOp->PointCoordinates (theVertex, x, y, z);
564 string theVertexName = theVertex->GetName();
566 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
569 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
570 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
571 CORBA::Boolean isCompound)
572 throw (SALOME::SALOME_Exception) {
574 bool newValue = false;
576 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
577 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
578 if (string(theVertexEntry).empty()) {
579 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
580 std::vector<double> coords;
584 if (coordsList.find(coords) == coordsList.end()) {
588 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
589 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
595 if (string(theVertexName).empty()) {
596 if (string(theGroupName).empty())
597 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
599 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
602 if (string(theGroupName).empty())
603 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
605 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
610 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
611 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
615 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
616 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
622 if (string(theGroupName).empty())
623 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
625 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
630 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
635 //=======================================================================
636 //function : GetEnforcedVertex
637 //=======================================================================
639 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
640 throw (SALOME::SALOME_Exception)
644 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
645 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
648 catch (const std::invalid_argument& ex) {
649 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
651 catch (SALOME_Exception& ex) {
652 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
656 //=======================================================================
657 //function : GetEnforcedVertex
658 //=======================================================================
660 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
661 throw (SALOME::SALOME_Exception)
665 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
666 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
669 string theVertexEntry = theVertex->GetStudyEntry();
670 if (theVertexEntry.empty()) {
671 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
672 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
674 if (theVertex->GetShapeType() == GEOM::VERTEX)
676 if (theVertex->GetShapeType() == GEOM::COMPOUND)
678 aName += theVertex->GetEntry();
679 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
680 if (!theSVertex->_is_nil())
681 theVertexEntry = theSVertex->GetID();
683 if (theVertexEntry.empty())
684 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
686 string theVertexName = theVertex->GetName();
689 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
690 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
693 catch (const std::invalid_argument& ex) {
694 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
696 catch (SALOME_Exception& ex) {
697 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
701 //=======================================================================
702 //function : GetEnforcedVertices
703 //=======================================================================
705 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
708 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
710 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
711 result->length( enfVertexList.size() );
713 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
715 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
716 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
717 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
719 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
721 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
723 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
724 coords->length(currentVertex->coords.size());
725 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
726 coords[ind] = currentVertex->coords[ind];
727 enfVertex->coords = coords;
729 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
731 enfVertex->size = currentVertex->size;
733 enfVertex->isCompound = currentVertex->isCompound;
738 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
740 return result._retn();
743 //=======================================================================
744 //function : RemoveEnforcedVertex
745 //=======================================================================
747 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
748 throw (SALOME::SALOME_Exception)
752 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
753 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
756 catch (const std::invalid_argument& ex) {
757 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
759 catch (SALOME_Exception& ex) {
760 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
764 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
765 throw (SALOME::SALOME_Exception)
769 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
770 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
773 string theVertexEntry = theVertex->GetStudyEntry();
774 if (theVertexEntry.empty()) {
775 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
776 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
778 if (theVertex->GetShapeType() == GEOM::VERTEX)
780 if (theVertex->GetShapeType() == GEOM::COMPOUND)
782 aName += theVertex->GetEntry();
783 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
784 if (!theSVertex->_is_nil())
785 theVertexEntry = theSVertex->GetID();
787 if (theVertexEntry.empty())
788 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
791 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
792 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
795 catch (const std::invalid_argument& ex) {
796 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
798 catch (SALOME_Exception& ex) {
799 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
803 //=======================================================================
804 //function : ClearEnforcedVertices
805 //=======================================================================
807 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
810 this->GetImpl()->ClearEnforcedVertices();
811 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
814 //=======================================================================
815 //function : ClearEnforcedMeshes
816 //=======================================================================
818 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
821 this->GetImpl()->ClearEnforcedMeshes();
822 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
825 //=======================================================================
826 //function : GetEnforcedMeshes
827 //=======================================================================
829 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
832 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
834 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
835 result->length( enfMeshList.size() );
837 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
839 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
840 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
841 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
843 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
845 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
847 enfMesh->elementType = currentMesh->elementType;
849 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
854 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
856 return result._retn();
860 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
862 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
863 throw (SALOME::SALOME_Exception)
865 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
869 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
871 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
872 throw (SALOME::SALOME_Exception)
874 return p_SetEnforcedMesh(theSource, theType);
878 * \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.
880 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
881 throw (SALOME::SALOME_Exception)
883 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
887 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
889 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
890 throw (SALOME::SALOME_Exception)
892 return p_SetEnforcedMesh(theSource, theType);
895 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
896 SMESH::ElementType theType,
898 const char* theGroupName)
899 throw (SALOME::SALOME_Exception)
903 if (CORBA::is_nil( theSource ))
904 THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
909 case SMESH::FACE: break;
913 SMESH::array_of_ElementType_var types = theSource->GetTypes();
914 if ( types->length() >= 1 && types[types->length()-1] < theType)
919 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
920 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
922 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
923 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
924 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
926 string enfMeshName = theName;
927 if (enfMeshName.empty())
928 enfMeshName = SObj->GetName();
933 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
934 if (theGroupName && theGroupName[0] ) {
935 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
936 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
939 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
940 << theSource << ".GetMesh(), " << theType << " )";
945 catch (const std::invalid_argument& ex) {
946 SALOME::ExceptionStruct ExDescription;
947 ExDescription.text = ex.what();
948 ExDescription.type = SALOME::BAD_PARAM;
949 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
950 ExDescription.lineNumber = 840;
951 throw SALOME::SALOME_Exception(ExDescription);
953 catch (SALOME_Exception& ex) {
954 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
957 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
960 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
961 if ( theGroupName && theGroupName[0] ) {
962 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
963 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
966 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
967 << theSource << ", " << theType << " )";
971 catch (const std::invalid_argument& ex) {
972 SALOME::ExceptionStruct ExDescription;
973 ExDescription.text = ex.what();
974 ExDescription.type = SALOME::BAD_PARAM;
975 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
976 ExDescription.lineNumber = 840;
977 throw SALOME::SALOME_Exception(ExDescription);
979 catch (SALOME_Exception& ex) {
980 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
983 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
986 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
987 if ( theGroupName && theGroupName[0] ) {
988 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
989 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
992 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
993 << theSource << ", " << theType << " )";
997 catch (const std::invalid_argument& ex) {
998 SALOME::ExceptionStruct ExDescription;
999 ExDescription.text = ex.what();
1000 ExDescription.type = SALOME::BAD_PARAM;
1001 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1002 ExDescription.lineNumber = 840;
1003 throw SALOME::SALOME_Exception(ExDescription);
1005 catch (SALOME_Exception& ex) {
1006 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1011 //=============================================================================
1013 * Get implementation
1015 //=============================================================================
1017 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1019 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1022 //================================================================================
1024 * \brief Verify whether hypothesis supports given entity type
1026 //================================================================================
1028 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1030 return type == SMESH::DIM_3D;