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"
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)
49 //=======================================================================
50 //function : GHS3DPlugin_Hypothesis_i
51 //=======================================================================
53 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
55 ::SMESH_Gen* theGenImpl)
56 : SALOME::GenericObj_i( thePOA ),
57 SMESH_Hypothesis_i( thePOA )
59 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
60 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
65 //=======================================================================
66 //function : ~GHS3DPlugin_Hypothesis_i
67 //=======================================================================
69 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
71 MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
74 //=======================================================================
75 //function : SetToMeshHoles
76 //=======================================================================
78 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
81 this->GetImpl()->SetToMeshHoles(toMesh);
82 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
85 //=======================================================================
86 //function : GetToMeshHoles
87 //=======================================================================
89 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
92 return this->GetImpl()->GetToMeshHoles();
95 //=======================================================================
96 //function : SetToMakeGroupsOfDomains
97 //=======================================================================
99 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
102 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
103 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
106 //=======================================================================
107 //function : GetToMakeGroupsOfDomains
108 //=======================================================================
110 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
113 return this->GetImpl()->GetToMakeGroupsOfDomains();
116 //=======================================================================
117 //function : SetMaximumMemory
118 //=======================================================================
120 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
121 throw ( SALOME::SALOME_Exception )
124 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
126 this->GetImpl()->SetMaximumMemory(MB);
127 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
130 //=======================================================================
131 //function : GetMaximumMemory
132 //=======================================================================
134 CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
137 return this->GetImpl()->GetMaximumMemory();
140 //=======================================================================
141 //function : SetInitialMemory
142 //=======================================================================
144 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
145 throw ( SALOME::SALOME_Exception )
148 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
150 this->GetImpl()->SetInitialMemory(MB);
151 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
154 //=======================================================================
155 //function : GetInitialMemory
156 //=======================================================================
158 CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
161 return this->GetImpl()->GetInitialMemory();
164 //=======================================================================
165 //function : SetOptimizationLevel
166 //=======================================================================
168 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
169 throw ( SALOME::SALOME_Exception )
171 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
172 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
173 if ( l < ::GHS3DPlugin_Hypothesis::None ||
174 l > ::GHS3DPlugin_Hypothesis::Strong )
175 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
178 this->GetImpl()->SetOptimizationLevel(l);
179 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
182 //=======================================================================
183 //function : GetOptimizationLevel
184 //=======================================================================
186 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
189 return this->GetImpl()->GetOptimizationLevel();
192 //=======================================================================
193 //function : SetWorkingDirectory
194 //=======================================================================
196 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
199 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
202 const char lastChar = *file.rbegin();
204 if ( lastChar != '\\' ) file += '\\';
206 if ( lastChar != '/' ) file += '/';
209 SMESH_Mesh_i::PrepareForWriting (file.c_str());
212 this->GetImpl()->SetWorkingDirectory(path);
213 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
216 //=======================================================================
217 //function : GetWorkingDirectory
218 //=======================================================================
220 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
223 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
226 //=======================================================================
227 //function : SetKeepFiles
228 //=======================================================================
230 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
233 this->GetImpl()->SetKeepFiles(toKeep);
234 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
237 //=======================================================================
238 //function : GetKeepFiles
239 //=======================================================================
241 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
244 return this->GetImpl()->GetKeepFiles();
247 //=======================================================================
248 //function : SetVerboseLevel
249 //=======================================================================
251 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
252 throw ( SALOME::SALOME_Exception )
254 if (level < 0 || level > 10 )
255 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
258 this->GetImpl()->SetVerboseLevel(level);
259 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
262 //=======================================================================
263 //function : GetVerboseLevel
264 //=======================================================================
266 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
269 return this->GetImpl()->GetVerboseLevel();
272 //=======================================================================
273 //function : SetToCreateNewNodes
274 //=======================================================================
276 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
279 this->GetImpl()->SetToCreateNewNodes(toCreate);
280 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
283 //=======================================================================
284 //function : GetToCreateNewNodes
285 //=======================================================================
287 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
290 return this->GetImpl()->GetToCreateNewNodes();
293 //=======================================================================
294 //function : SetToUseBoundaryRecoveryVersion
295 //=======================================================================
297 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
300 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
301 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
304 //=======================================================================
305 //function : GetToUseBoundaryRecoveryVersion
306 //=======================================================================
308 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
311 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
314 //=======================================================================
315 //function : SetFEMCorrection
316 //=======================================================================
318 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
321 this->GetImpl()->SetFEMCorrection(toUseFem);
322 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
325 //=======================================================================
326 //function : GetFEMCorrection
327 //=======================================================================
329 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
332 return this->GetImpl()->GetFEMCorrection();
335 //=======================================================================
336 //function : SetToRemoveCentralPoint
337 //=======================================================================
339 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
342 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
343 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
346 //=======================================================================
347 //function : GetToRemoveCentralPoint
348 //=======================================================================
350 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
353 return this->GetImpl()->GetToRemoveCentralPoint();
356 //=======================================================================
357 //function : SetTextOption
358 //=======================================================================
360 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
363 this->GetImpl()->SetAdvancedOption(option);
364 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
367 //=======================================================================
368 //function : GetTextOption
369 //=======================================================================
371 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
374 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
377 //=======================================================================
378 //function : SetAdvancedOption
379 //=======================================================================
381 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
384 this->GetImpl()->SetAdvancedOption(option);
385 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
388 //=======================================================================
389 //function : GetAdvancedOption
390 //=======================================================================
392 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
395 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
398 //=======================================================================
399 //function : SetToRemoveCentralPoint
400 //=======================================================================
402 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
405 if (gradation != GetGradation()) {
406 this->GetImpl()->SetGradation(gradation);
407 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
411 //=======================================================================
412 //function : GetToRemoveCentralPoint
413 //=======================================================================
415 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
418 return this->GetImpl()->GetGradation();
421 //=======================================================================
422 //function : SetStandardOutputLog
423 //=======================================================================
425 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
428 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
429 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
432 //=======================================================================
433 //function : GetStandardOutputLog
434 //=======================================================================
436 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
439 return this->GetImpl()->GetStandardOutputLog();
442 //=======================================================================
443 //function : SetRemoveLogOnSuccess
444 //=======================================================================
446 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
449 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
450 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
453 //=======================================================================
454 //function : GetRemoveLogOnSuccess
455 //=======================================================================
457 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
460 return this->GetImpl()->GetRemoveLogOnSuccess();
463 //=======================================================================
464 //function : SetEnforcedVertex
465 //=======================================================================
467 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
468 throw (SALOME::SALOME_Exception) {
470 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
471 return p_SetEnforcedVertex(size, x, y, z);
474 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
475 throw (SALOME::SALOME_Exception) {
477 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
478 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
481 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
482 throw (SALOME::SALOME_Exception) {
484 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
485 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
488 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
489 throw (SALOME::SALOME_Exception) {
491 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
492 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
495 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
496 throw (SALOME::SALOME_Exception) {
499 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
500 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
501 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
504 string theVertexEntry = theVertex->GetStudyEntry();
505 CORBA::Double x = 0, y = 0, z = 0;
506 CORBA::Boolean isCompound = false;
507 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
508 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
509 if (theVertexEntry.empty()) {
511 if (theVertex->GetShapeType() == GEOM::VERTEX) {
514 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
518 aName += theVertex->GetEntry();
519 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
520 if (!theSVertex->_is_nil())
521 theVertexEntry = theSVertex->GetID();
523 if (theVertexEntry.empty())
524 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
526 if (theVertex->GetShapeType() == GEOM::VERTEX) {
527 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
528 if (CORBA::is_nil(measureOp))
531 measureOp->PointCoordinates (theVertex, x, y, z);
532 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
535 string theVertexName = theVertex->GetName();
536 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
538 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
541 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
542 throw (SALOME::SALOME_Exception) {
545 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
546 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
547 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
550 string theVertexEntry = theVertex->GetStudyEntry();
551 CORBA::Double x = 0, y = 0, z = 0;
552 CORBA::Boolean isCompound = false;
553 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
554 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
555 if (theVertexEntry.empty()) {
557 if (theVertex->GetShapeType() == GEOM::VERTEX) {
560 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
564 aName += theVertex->GetEntry();
565 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
566 if (!theSVertex->_is_nil())
567 theVertexEntry = theSVertex->GetID();
569 if (theVertexEntry.empty())
570 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
572 if (theVertex->GetShapeType() == GEOM::VERTEX) {
573 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
574 if (CORBA::is_nil(measureOp))
577 measureOp->PointCoordinates (theVertex, x, y, z);
578 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
581 string theVertexName = theVertex->GetName();
582 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
584 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
587 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
588 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
589 CORBA::Boolean isCompound)
590 throw (SALOME::SALOME_Exception) {
592 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
593 bool newValue = false;
595 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
596 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
597 if (string(theVertexEntry).empty()) {
598 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
599 std::vector<double> coords;
603 if (coordsList.find(coords) == coordsList.end()) {
604 MESSAGE("Coords not found: add it in coordsList");
608 MESSAGE("Coords already found, compare names");
609 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
610 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
611 MESSAGE("The names or size are different: update");
612 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
616 MESSAGE("The names and size are identical");
621 if (string(theVertexName).empty()) {
622 if (string(theGroupName).empty())
623 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
625 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
628 if (string(theGroupName).empty())
629 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
631 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
636 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
637 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
638 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
639 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
640 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
644 MESSAGE("Geom entry already found, compare names");
645 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
646 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
647 MESSAGE("The names or size are different: update");
648 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
652 MESSAGE("The names and size are identical");
657 if (string(theGroupName).empty())
658 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
660 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
665 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
667 MESSAGE("IDL : SetEnforcedVertexEntry END");
671 //=======================================================================
672 //function : GetEnforcedVertex
673 //=======================================================================
675 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
676 throw (SALOME::SALOME_Exception)
680 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
681 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
684 catch (const std::invalid_argument& ex) {
685 SALOME::ExceptionStruct ExDescription;
686 ExDescription.text = ex.what();
687 ExDescription.type = SALOME::BAD_PARAM;
688 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
689 ExDescription.lineNumber = 513;
690 throw SALOME::SALOME_Exception(ExDescription);
692 catch (SALOME_Exception& ex) {
693 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
697 //=======================================================================
698 //function : GetEnforcedVertex
699 //=======================================================================
701 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
702 throw (SALOME::SALOME_Exception)
706 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
707 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
708 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
711 string theVertexEntry = theVertex->GetStudyEntry();
712 if (theVertexEntry.empty()) {
713 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
714 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
716 if (theVertex->GetShapeType() == GEOM::VERTEX)
718 if (theVertex->GetShapeType() == GEOM::COMPOUND)
720 aName += theVertex->GetEntry();
721 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
722 if (!theSVertex->_is_nil())
723 theVertexEntry = theSVertex->GetID();
725 if (theVertexEntry.empty())
726 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
728 string theVertexName = theVertex->GetName();
731 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
732 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
735 catch (const std::invalid_argument& ex) {
736 SALOME::ExceptionStruct ExDescription;
737 ExDescription.text = ex.what();
738 ExDescription.type = SALOME::BAD_PARAM;
739 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
740 ExDescription.lineNumber = 538;
741 throw SALOME::SALOME_Exception(ExDescription);
743 catch (SALOME_Exception& ex) {
744 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
748 //=======================================================================
749 //function : GetEnforcedVertices
750 //=======================================================================
752 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
755 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
757 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
758 result->length( enfVertexList.size() );
760 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
762 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
763 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
764 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
766 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
768 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
770 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
771 coords->length(currentVertex->coords.size());
772 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
773 coords[ind] = currentVertex->coords[ind];
774 enfVertex->coords = coords;
776 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
778 enfVertex->size = currentVertex->size;
780 enfVertex->isCompound = currentVertex->isCompound;
785 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
787 return result._retn();
790 //=======================================================================
791 //function : RemoveEnforcedVertex
792 //=======================================================================
794 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
795 throw (SALOME::SALOME_Exception)
799 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
800 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
803 catch (const std::invalid_argument& ex) {
804 SALOME::ExceptionStruct ExDescription;
805 ExDescription.text = ex.what();
806 ExDescription.type = SALOME::BAD_PARAM;
807 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
808 ExDescription.lineNumber = 625;
809 throw SALOME::SALOME_Exception(ExDescription);
811 catch (SALOME_Exception& ex) {
812 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
816 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
817 throw (SALOME::SALOME_Exception)
821 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
822 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
823 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
826 string theVertexEntry = theVertex->GetStudyEntry();
827 if (theVertexEntry.empty()) {
828 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
829 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
831 if (theVertex->GetShapeType() == GEOM::VERTEX)
833 if (theVertex->GetShapeType() == GEOM::COMPOUND)
835 aName += theVertex->GetEntry();
836 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
837 if (!theSVertex->_is_nil())
838 theVertexEntry = theSVertex->GetID();
840 if (theVertexEntry.empty())
841 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
844 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
845 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
848 catch (const std::invalid_argument& ex) {
849 SALOME::ExceptionStruct ExDescription;
850 ExDescription.text = ex.what();
851 ExDescription.type = SALOME::BAD_PARAM;
852 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
853 ExDescription.lineNumber = 648;
854 throw SALOME::SALOME_Exception(ExDescription);
856 catch (SALOME_Exception& ex) {
857 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
861 //=======================================================================
862 //function : ClearEnforcedVertices
863 //=======================================================================
865 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
868 this->GetImpl()->ClearEnforcedVertices();
869 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
872 //=======================================================================
873 //function : ClearEnforcedMeshes
874 //=======================================================================
876 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
879 this->GetImpl()->ClearEnforcedMeshes();
880 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
883 //=======================================================================
884 //function : GetEnforcedMeshes
885 //=======================================================================
887 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
890 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
892 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
893 result->length( enfMeshList.size() );
895 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
897 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
898 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
899 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
901 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
903 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
905 enfMesh->elementType = currentMesh->elementType;
907 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
912 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
914 return result._retn();
918 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
920 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
921 throw (SALOME::SALOME_Exception)
923 // #if GHS3D_VERSION >= 42
924 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
926 // SALOME::ExceptionStruct ExDescription;
927 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
928 // ExDescription.type = SALOME::BAD_PARAM;
929 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
930 // ExDescription.lineNumber = 719;
931 // throw SALOME::SALOME_Exception(ExDescription);
936 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
938 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
939 throw (SALOME::SALOME_Exception)
941 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
942 // #if GHS3D_VERSION >= 42
943 return p_SetEnforcedMesh(theSource, theType);
945 // SALOME::ExceptionStruct ExDescription;
946 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
947 // ExDescription.type = SALOME::BAD_PARAM;
948 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
949 // ExDescription.lineNumber = 750;
950 // throw SALOME::SALOME_Exception(ExDescription);
955 * \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.
957 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
958 throw (SALOME::SALOME_Exception)
960 // #if GHS3D_VERSION >= 42
961 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
963 // SALOME::ExceptionStruct ExDescription;
964 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
965 // ExDescription.type = SALOME::BAD_PARAM;
966 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
967 // ExDescription.lineNumber = 750;
968 // throw SALOME::SALOME_Exception(ExDescription);
973 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
975 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
976 throw (SALOME::SALOME_Exception)
978 // #if GHS3D_VERSION >= 42
979 return p_SetEnforcedMesh(theSource, theType);
981 // SALOME::ExceptionStruct ExDescription;
982 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
983 // ExDescription.type = SALOME::BAD_PARAM;
984 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
985 // ExDescription.lineNumber = 750;
986 // throw SALOME::SALOME_Exception(ExDescription);
990 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
991 throw (SALOME::SALOME_Exception)
993 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
996 if (CORBA::is_nil( theSource ))
998 SALOME::ExceptionStruct ExDescription;
999 ExDescription.text = "The source mesh CORBA object is NULL";
1000 ExDescription.type = SALOME::BAD_PARAM;
1001 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1002 ExDescription.lineNumber = 840;
1003 throw SALOME::SALOME_Exception(ExDescription);
1008 MESSAGE("Required type is NODE");
1011 MESSAGE("Required type is EDGE");
1014 MESSAGE("Required type is FACE");
1017 MESSAGE("Incompatible required type: " << theType);
1020 // MESSAGE("Required type is "<<theType);
1021 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1022 MESSAGE("Available types:");
1023 for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
1024 if ( types->length() >= 1 && types[types->length()-1] < theType)
1026 MESSAGE("Required type not available");
1028 // SALOME::ExceptionStruct ExDescription;
1029 // ExDescription.text = "The source mesh has bad type";
1030 // ExDescription.type = SALOME::BAD_PARAM;
1031 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1032 // ExDescription.lineNumber = 840;
1033 // throw SALOME::SALOME_Exception(ExDescription);
1037 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1038 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1040 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1041 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1042 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1044 string enfMeshName = theName;
1045 if (enfMeshName.empty())
1046 enfMeshName = SObj->GetName();
1051 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1052 if (theGroupName && theGroupName[0] ) {
1053 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1054 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1057 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1058 << theSource << ".GetMesh(), " << theType << " )";
1063 catch (const std::invalid_argument& ex) {
1064 SALOME::ExceptionStruct ExDescription;
1065 ExDescription.text = ex.what();
1066 ExDescription.type = SALOME::BAD_PARAM;
1067 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1068 ExDescription.lineNumber = 840;
1069 throw SALOME::SALOME_Exception(ExDescription);
1071 catch (SALOME_Exception& ex) {
1072 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1075 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1077 MESSAGE("The source is a group")
1079 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1080 if ( theGroupName && theGroupName[0] ) {
1081 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1082 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1085 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1086 << theSource << ", " << theType << " )";
1090 catch (const std::invalid_argument& ex) {
1091 SALOME::ExceptionStruct ExDescription;
1092 ExDescription.text = ex.what();
1093 ExDescription.type = SALOME::BAD_PARAM;
1094 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1095 ExDescription.lineNumber = 840;
1096 throw SALOME::SALOME_Exception(ExDescription);
1098 catch (SALOME_Exception& ex) {
1099 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1102 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1104 MESSAGE("The source is a group on geom")
1106 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1107 if ( theGroupName && theGroupName[0] ) {
1108 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1109 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1112 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1113 << theSource << ", " << theType << " )";
1117 catch (const std::invalid_argument& ex) {
1118 SALOME::ExceptionStruct ExDescription;
1119 ExDescription.text = ex.what();
1120 ExDescription.type = SALOME::BAD_PARAM;
1121 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1122 ExDescription.lineNumber = 840;
1123 throw SALOME::SALOME_Exception(ExDescription);
1125 catch (SALOME_Exception& ex) {
1126 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1131 //=============================================================================
1133 * Get implementation
1135 //=============================================================================
1137 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1139 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1142 //================================================================================
1144 * \brief Verify whether hypothesis supports given entity type
1146 //================================================================================
1148 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1150 return type == SMESH::DIM_3D;