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,
48 ::SMESH_Gen* theGenImpl)
49 : SALOME::GenericObj_i( thePOA ),
50 SMESH_Hypothesis_i( thePOA )
52 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
56 //=======================================================================
57 //function : ~GHS3DPlugin_Hypothesis_i
58 //=======================================================================
60 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
64 //=======================================================================
65 //function : SetToMeshHoles
66 //=======================================================================
68 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
71 this->GetImpl()->SetToMeshHoles(toMesh);
72 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
75 //=======================================================================
76 //function : GetToMeshHoles
77 //=======================================================================
79 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
82 return this->GetImpl()->GetToMeshHoles();
85 //=======================================================================
86 //function : SetToMakeGroupsOfDomains
87 //=======================================================================
89 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
92 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
93 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
96 //=======================================================================
97 //function : GetToMakeGroupsOfDomains
98 //=======================================================================
100 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
103 return this->GetImpl()->GetToMakeGroupsOfDomains();
106 //=======================================================================
107 //function : SetMaximumMemory
108 //=======================================================================
110 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Float MB)
111 throw ( SALOME::SALOME_Exception )
114 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
116 this->GetImpl()->SetMaximumMemory(MB);
117 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
120 //=======================================================================
121 //function : GetMaximumMemory
122 //=======================================================================
124 CORBA::Float GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
127 return this->GetImpl()->GetMaximumMemory();
130 //=======================================================================
131 //function : SetInitialMemory
132 //=======================================================================
134 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Float MB)
135 throw ( SALOME::SALOME_Exception )
138 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
140 this->GetImpl()->SetInitialMemory(MB);
141 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
144 //=======================================================================
145 //function : GetInitialMemory
146 //=======================================================================
148 CORBA::Float GHS3DPlugin_Hypothesis_i::GetInitialMemory()
151 return this->GetImpl()->GetInitialMemory();
154 //=======================================================================
155 //function : SetOptimizationLevel
156 //=======================================================================
158 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
159 throw ( SALOME::SALOME_Exception )
161 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
162 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
163 if ( l < ::GHS3DPlugin_Hypothesis::None ||
164 l > ::GHS3DPlugin_Hypothesis::Strong )
165 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
168 this->GetImpl()->SetOptimizationLevel(l);
169 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
172 //=======================================================================
173 //function : GetOptimizationLevel
174 //=======================================================================
176 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
179 return this->GetImpl()->GetOptimizationLevel();
182 //=======================================================================
183 //function : SetWorkingDirectory
184 //=======================================================================
186 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
189 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
192 const char lastChar = *file.rbegin();
194 if ( lastChar != '\\' ) file += '\\';
196 if ( lastChar != '/' ) file += '/';
199 SMESH_Mesh_i::PrepareForWriting (file.c_str());
202 this->GetImpl()->SetWorkingDirectory(path);
203 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
206 //=======================================================================
207 //function : GetWorkingDirectory
208 //=======================================================================
210 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
213 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
216 //=======================================================================
217 //function : SetKeepFiles
218 //=======================================================================
220 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
223 this->GetImpl()->SetKeepFiles(toKeep);
224 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
227 //=======================================================================
228 //function : GetKeepFiles
229 //=======================================================================
231 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
234 return this->GetImpl()->GetKeepFiles();
237 //=======================================================================
238 //function : SetVerboseLevel
239 //=======================================================================
241 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
242 throw ( SALOME::SALOME_Exception )
244 if (level < 0 || level > 10 )
245 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
248 this->GetImpl()->SetVerboseLevel(level);
249 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
252 //=======================================================================
253 //function : GetVerboseLevel
254 //=======================================================================
256 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
259 return this->GetImpl()->GetVerboseLevel();
262 //=======================================================================
263 //function : SetToCreateNewNodes
264 //=======================================================================
266 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
269 this->GetImpl()->SetToCreateNewNodes(toCreate);
270 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
273 //=======================================================================
274 //function : GetToCreateNewNodes
275 //=======================================================================
277 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
280 return this->GetImpl()->GetToCreateNewNodes();
283 //=======================================================================
284 //function : SetToUseBoundaryRecoveryVersion
285 //=======================================================================
287 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
290 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
291 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
294 //=======================================================================
295 //function : GetToUseBoundaryRecoveryVersion
296 //=======================================================================
298 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
301 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
304 //=======================================================================
305 //function : SetFEMCorrection
306 //=======================================================================
308 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
311 this->GetImpl()->SetFEMCorrection(toUseFem);
312 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
315 //=======================================================================
316 //function : GetFEMCorrection
317 //=======================================================================
319 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
322 return this->GetImpl()->GetFEMCorrection();
325 //=======================================================================
326 //function : SetToRemoveCentralPoint
327 //=======================================================================
329 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
332 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
333 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
336 //=======================================================================
337 //function : GetToRemoveCentralPoint
338 //=======================================================================
340 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
343 return this->GetImpl()->GetToRemoveCentralPoint();
346 //=======================================================================
347 //function : SetTextOption
348 //=======================================================================
350 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
353 this->GetImpl()->SetAdvancedOption(option);
354 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
357 //=======================================================================
358 //function : GetTextOption
359 //=======================================================================
361 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
364 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
367 //=======================================================================
368 //function : SetAdvancedOption
369 //=======================================================================
371 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
374 this->GetImpl()->SetAdvancedOption(option);
375 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
378 //=======================================================================
379 //function : GetAdvancedOption
380 //=======================================================================
382 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
385 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
388 //=======================================================================
389 //function : SetToRemoveCentralPoint
390 //=======================================================================
392 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
395 if (gradation != GetGradation()) {
396 this->GetImpl()->SetGradation(gradation);
397 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
401 //=======================================================================
402 //function : GetToRemoveCentralPoint
403 //=======================================================================
405 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
408 return this->GetImpl()->GetGradation();
411 //=======================================================================
412 //function : SetStandardOutputLog
413 //=======================================================================
415 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
418 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
419 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
422 //=======================================================================
423 //function : GetStandardOutputLog
424 //=======================================================================
426 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
429 return this->GetImpl()->GetStandardOutputLog();
432 //=======================================================================
433 //function : SetRemoveLogOnSuccess
434 //=======================================================================
436 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
439 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
440 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
443 //=======================================================================
444 //function : GetRemoveLogOnSuccess
445 //=======================================================================
447 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
450 return this->GetImpl()->GetRemoveLogOnSuccess();
453 //=======================================================================
454 //function : SetEnforcedVertex
455 //=======================================================================
457 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
458 throw (SALOME::SALOME_Exception) {
460 return p_SetEnforcedVertex(size, x, y, z);
463 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
464 throw (SALOME::SALOME_Exception) {
466 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
469 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
470 throw (SALOME::SALOME_Exception) {
472 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
475 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
476 throw (SALOME::SALOME_Exception) {
478 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
481 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
482 throw (SALOME::SALOME_Exception) {
485 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
486 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
489 string theVertexEntry = theVertex->GetStudyEntry();
490 CORBA::Double x = 0, y = 0, z = 0;
491 CORBA::Boolean isCompound = false;
492 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
493 if (theVertexEntry.empty()) {
495 if (theVertex->GetShapeType() == GEOM::VERTEX) {
498 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
502 aName += theVertex->GetEntry();
503 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
504 if (!theSVertex->_is_nil())
505 theVertexEntry = theSVertex->GetID();
507 if (theVertexEntry.empty())
508 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
510 if (theVertex->GetShapeType() == GEOM::VERTEX) {
511 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
512 if (CORBA::is_nil(measureOp))
515 measureOp->PointCoordinates (theVertex, x, y, z);
518 string theVertexName = theVertex->GetName();
520 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
523 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
524 throw (SALOME::SALOME_Exception) {
527 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
528 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
531 string theVertexEntry = theVertex->GetStudyEntry();
532 CORBA::Double x = 0, y = 0, z = 0;
533 CORBA::Boolean isCompound = false;
534 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
535 if (theVertexEntry.empty()) {
537 if (theVertex->GetShapeType() == GEOM::VERTEX) {
540 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
544 aName += theVertex->GetEntry();
545 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
546 if (!theSVertex->_is_nil())
547 theVertexEntry = theSVertex->GetID();
549 if (theVertexEntry.empty())
550 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
552 if (theVertex->GetShapeType() == GEOM::VERTEX) {
553 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
554 if (CORBA::is_nil(measureOp))
557 measureOp->PointCoordinates (theVertex, x, y, z);
560 string theVertexName = theVertex->GetName();
562 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
565 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
566 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
567 CORBA::Boolean isCompound)
568 throw (SALOME::SALOME_Exception) {
570 bool newValue = false;
572 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
573 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
574 if (string(theVertexEntry).empty()) {
575 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
576 std::vector<double> coords;
580 if (coordsList.find(coords) == coordsList.end()) {
584 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
585 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
591 if (string(theVertexName).empty()) {
592 if (string(theGroupName).empty())
593 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
595 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
598 if (string(theGroupName).empty())
599 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
601 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
606 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
607 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
611 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
612 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
618 if (string(theGroupName).empty())
619 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
621 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
626 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
631 //=======================================================================
632 //function : GetEnforcedVertex
633 //=======================================================================
635 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
636 throw (SALOME::SALOME_Exception)
640 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
641 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
644 catch (const std::invalid_argument& ex) {
645 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
647 catch (SALOME_Exception& ex) {
648 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
652 //=======================================================================
653 //function : GetEnforcedVertex
654 //=======================================================================
656 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
657 throw (SALOME::SALOME_Exception)
661 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
662 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
665 string theVertexEntry = theVertex->GetStudyEntry();
666 if (theVertexEntry.empty()) {
667 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
669 if (theVertex->GetShapeType() == GEOM::VERTEX)
671 if (theVertex->GetShapeType() == GEOM::COMPOUND)
673 aName += theVertex->GetEntry();
674 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
675 if (!theSVertex->_is_nil())
676 theVertexEntry = theSVertex->GetID();
678 if (theVertexEntry.empty())
679 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
681 string theVertexName = theVertex->GetName();
684 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
685 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
688 catch (const std::invalid_argument& ex) {
689 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
691 catch (SALOME_Exception& ex) {
692 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
696 //=======================================================================
697 //function : GetEnforcedVertices
698 //=======================================================================
700 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
703 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
705 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
706 result->length( enfVertexList.size() );
708 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
710 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
711 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
712 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
714 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
716 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
718 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
719 coords->length(currentVertex->coords.size());
720 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
721 coords[ind] = currentVertex->coords[ind];
722 enfVertex->coords = coords;
724 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
726 enfVertex->size = currentVertex->size;
728 enfVertex->isCompound = currentVertex->isCompound;
733 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
735 return result._retn();
738 //=======================================================================
739 //function : RemoveEnforcedVertex
740 //=======================================================================
742 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
743 throw (SALOME::SALOME_Exception)
747 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
748 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
751 catch (const std::invalid_argument& ex) {
752 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
754 catch (SALOME_Exception& ex) {
755 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
759 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
760 throw (SALOME::SALOME_Exception)
764 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
765 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
768 string theVertexEntry = theVertex->GetStudyEntry();
769 if (theVertexEntry.empty()) {
770 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
772 if (theVertex->GetShapeType() == GEOM::VERTEX)
774 if (theVertex->GetShapeType() == GEOM::COMPOUND)
776 aName += theVertex->GetEntry();
777 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
778 if (!theSVertex->_is_nil())
779 theVertexEntry = theSVertex->GetID();
781 if (theVertexEntry.empty())
782 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
785 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
786 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
789 catch (const std::invalid_argument& ex) {
790 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
792 catch (SALOME_Exception& ex) {
793 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
797 //=======================================================================
798 //function : ClearEnforcedVertices
799 //=======================================================================
801 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
804 this->GetImpl()->ClearEnforcedVertices();
805 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
808 //=======================================================================
809 //function : ClearEnforcedMeshes
810 //=======================================================================
812 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
815 this->GetImpl()->ClearEnforcedMeshes();
816 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
819 //=======================================================================
820 //function : GetEnforcedMeshes
821 //=======================================================================
823 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
826 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
828 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
829 result->length( enfMeshList.size() );
831 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
833 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
834 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
835 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
837 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
839 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
841 enfMesh->elementType = currentMesh->elementType;
843 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
848 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
850 return result._retn();
854 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
856 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
857 throw (SALOME::SALOME_Exception)
859 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
863 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
865 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
866 throw (SALOME::SALOME_Exception)
868 return p_SetEnforcedMesh(theSource, theType);
872 * \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.
874 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
875 throw (SALOME::SALOME_Exception)
877 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
881 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
883 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
884 throw (SALOME::SALOME_Exception)
886 return p_SetEnforcedMesh(theSource, theType);
889 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
890 SMESH::ElementType theType,
892 const char* theGroupName)
893 throw (SALOME::SALOME_Exception)
897 if (CORBA::is_nil( theSource ))
898 THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
903 case SMESH::FACE: break;
907 SMESH::array_of_ElementType_var types = theSource->GetTypes();
908 if ( types->length() >= 1 && types[types->length()-1] < theType)
913 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
914 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
916 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
917 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
918 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
920 string enfMeshName = theName;
921 if (enfMeshName.empty())
922 enfMeshName = SObj->GetName();
927 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
928 if (theGroupName && theGroupName[0] ) {
929 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
930 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
933 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
934 << theSource << ".GetMesh(), " << theType << " )";
939 catch (const std::invalid_argument& ex) {
940 SALOME::ExceptionStruct ExDescription;
941 ExDescription.text = ex.what();
942 ExDescription.type = SALOME::BAD_PARAM;
943 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
944 ExDescription.lineNumber = 840;
945 throw SALOME::SALOME_Exception(ExDescription);
947 catch (SALOME_Exception& ex) {
948 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
951 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
954 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
955 if ( theGroupName && theGroupName[0] ) {
956 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
957 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
960 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
961 << theSource << ", " << theType << " )";
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 = "GHS3DPlugin_Hypothesis_i.cxx";
970 ExDescription.lineNumber = 840;
971 throw SALOME::SALOME_Exception(ExDescription);
973 catch (SALOME_Exception& ex) {
974 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
977 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
980 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
981 if ( theGroupName && theGroupName[0] ) {
982 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
983 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
986 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
987 << theSource << ", " << theType << " )";
991 catch (const std::invalid_argument& ex) {
992 SALOME::ExceptionStruct ExDescription;
993 ExDescription.text = ex.what();
994 ExDescription.type = SALOME::BAD_PARAM;
995 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
996 ExDescription.lineNumber = 840;
997 throw SALOME::SALOME_Exception(ExDescription);
999 catch (SALOME_Exception& ex) {
1000 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1005 //=============================================================================
1007 * Get implementation
1009 //=============================================================================
1011 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1013 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1016 //================================================================================
1018 * \brief Verify whether hypothesis supports given entity type
1020 //================================================================================
1022 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1024 return type == SMESH::DIM_3D;
1028 //================================================================================
1030 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
1032 //================================================================================
1035 GHS3DPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
1036 std::vector< int > & subIDArray ) const
1038 typedef ::GHS3DPlugin_Hypothesis THyp;
1039 const THyp* h = static_cast< const THyp*>( myBaseImpl );
1042 const THyp::TGHS3DEnforcedVertexList& enfVertexList = h->_GetEnforcedVertices();
1043 THyp::TGHS3DEnforcedVertexList::const_iterator evIt = enfVertexList.begin();
1044 for ( ; evIt != enfVertexList.end(); ++evIt )
1046 const THyp::TGHS3DEnforcedVertex* ev = *evIt;
1047 entryArray.push_back( ev->geomEntry );
1051 const THyp::TGHS3DEnforcedVertexEntryValues&
1052 enfVertexEntrySizeList = h->_GetEnforcedVerticesEntrySize();
1053 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1054 for ( entry2size = enfVertexEntrySizeList.cbegin();
1055 entry2size != enfVertexEntrySizeList.cend();
1058 entryArray.push_back( entry2size->first );
1062 const THyp::TCoordsGHS3DEnforcedVertexMap&
1063 coordsEnfVertexMap = h->_GetEnforcedVerticesByCoords();
1064 THyp::TCoordsGHS3DEnforcedVertexMap::const_iterator size2ev = coordsEnfVertexMap.cbegin();
1065 for ( ; size2ev != coordsEnfVertexMap.cend(); ++size2ev )
1067 const THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1068 entryArray.push_back( ev->geomEntry );
1072 const THyp::TGeomEntryGHS3DEnforcedVertexMap&
1073 geomEntryEnfVertexMap = h->_GetEnforcedVerticesByEntry();
1074 THyp::TGeomEntryGHS3DEnforcedVertexMap::const_iterator entry2ev;
1075 for ( entry2ev = geomEntryEnfVertexMap.cbegin();
1076 entry2ev != geomEntryEnfVertexMap.cend();
1079 entryArray.push_back( entry2ev->first );
1081 const THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1082 entryArray.push_back( ev->geomEntry );
1086 return entryArray.size() > 0;
1089 //================================================================================
1091 * \brief Set new geometry instead of that returned by getObjectsDependOn()
1093 //================================================================================
1096 GHS3DPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
1097 std::vector< int > & subIDArray )
1099 typedef ::GHS3DPlugin_Hypothesis THyp;
1100 THyp* h = static_cast< THyp*>( myBaseImpl );
1104 THyp::TGHS3DEnforcedVertexList& enfVertexList =
1105 const_cast<THyp::TGHS3DEnforcedVertexList& >( h->_GetEnforcedVertices() );
1106 THyp::TGHS3DEnforcedVertexList::iterator evIt = enfVertexList.begin();
1107 for ( ; evIt != enfVertexList.end(); ++evIt )
1109 THyp::TGHS3DEnforcedVertex* ev = *evIt;
1110 ev->geomEntry = entryArray[ iEnt++ ];
1114 THyp::TGHS3DEnforcedVertexEntryValues& enfVertexEntrySizeListNew =
1115 const_cast< THyp::TGHS3DEnforcedVertexEntryValues& > ( h->_GetEnforcedVerticesEntrySize() );
1116 THyp::TGHS3DEnforcedVertexEntryValues enfVertexEntrySizeList;
1117 enfVertexEntrySizeList.swap( enfVertexEntrySizeListNew );
1118 THyp::TGHS3DEnforcedVertexEntryValues::const_iterator entry2size;
1119 for ( entry2size = enfVertexEntrySizeList.cbegin();
1120 entry2size != enfVertexEntrySizeList.cend();
1121 entry2size++, ++iEnt )
1123 if ( entry2size->first.empty() == entryArray[ iEnt ].empty() )
1124 enfVertexEntrySizeListNew[ entryArray[ iEnt ]] = entry2size->second;
1128 THyp::TCoordsGHS3DEnforcedVertexMap& coordsEnfVertexMap =
1129 const_cast< THyp::TCoordsGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByCoords() );
1130 THyp::TCoordsGHS3DEnforcedVertexMap::iterator size2ev = coordsEnfVertexMap.begin();
1131 for ( ; size2ev != coordsEnfVertexMap.end(); ++size2ev )
1133 THyp::TGHS3DEnforcedVertex* ev = size2ev->second;
1134 ev->geomEntry = entryArray[ iEnt++ ];
1138 THyp::TGeomEntryGHS3DEnforcedVertexMap& geomEntryEnfVertexMapNew =
1139 const_cast< THyp::TGeomEntryGHS3DEnforcedVertexMap& > ( h->_GetEnforcedVerticesByEntry() );
1140 THyp::TGeomEntryGHS3DEnforcedVertexMap geomEntryEnfVertexMap;
1141 geomEntryEnfVertexMap.swap( geomEntryEnfVertexMapNew );
1142 THyp::TGeomEntryGHS3DEnforcedVertexMap::iterator entry2ev;
1143 for ( entry2ev = geomEntryEnfVertexMap.begin();
1144 entry2ev != geomEntryEnfVertexMap.end();
1147 const std::string& entry = entryArray[ iEnt++ ];
1148 THyp::TGHS3DEnforcedVertex* ev = entry2ev->second;
1149 ev->geomEntry = entryArray[ iEnt++ ];
1151 geomEntryEnfVertexMapNew[ entry ] = ev;
1155 return iEnt == entryArray.size();