1 // Copyright (C) 2004-2015 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()->SetTextOption(option);
364 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
367 //=======================================================================
368 //function : GetTextOption
369 //=======================================================================
371 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
374 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
377 //=======================================================================
378 //function : SetToRemoveCentralPoint
379 //=======================================================================
381 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
384 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
386 if (gradation != GetGradation()) {
387 this->GetImpl()->SetGradation(gradation);
388 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
392 //=======================================================================
393 //function : GetToRemoveCentralPoint
394 //=======================================================================
396 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
399 return this->GetImpl()->GetGradation();
402 //=======================================================================
403 //function : SetStandardOutputLog
404 //=======================================================================
406 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
409 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
410 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
413 //=======================================================================
414 //function : GetStandardOutputLog
415 //=======================================================================
417 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
420 return this->GetImpl()->GetStandardOutputLog();
423 //=======================================================================
424 //function : SetRemoveLogOnSuccess
425 //=======================================================================
427 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
430 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
431 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
434 //=======================================================================
435 //function : GetRemoveLogOnSuccess
436 //=======================================================================
438 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
441 return this->GetImpl()->GetRemoveLogOnSuccess();
444 //=======================================================================
445 //function : SetEnforcedVertex
446 //=======================================================================
448 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
449 throw (SALOME::SALOME_Exception) {
451 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
452 return p_SetEnforcedVertex(size, x, y, z);
455 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
456 throw (SALOME::SALOME_Exception) {
458 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
459 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
462 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
463 throw (SALOME::SALOME_Exception) {
465 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
466 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
469 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
470 throw (SALOME::SALOME_Exception) {
472 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
473 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
476 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
477 throw (SALOME::SALOME_Exception) {
480 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
481 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
482 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
485 string theVertexEntry = theVertex->GetStudyEntry();
486 CORBA::Double x = 0, y = 0, z = 0;
487 CORBA::Boolean isCompound = false;
488 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
489 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
490 if (theVertexEntry.empty()) {
492 if (theVertex->GetShapeType() == GEOM::VERTEX) {
495 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
499 aName += theVertex->GetEntry();
500 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
501 if (!theSVertex->_is_nil())
502 theVertexEntry = theSVertex->GetID();
504 if (theVertexEntry.empty())
505 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
507 if (theVertex->GetShapeType() == GEOM::VERTEX) {
508 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
509 if (CORBA::is_nil(measureOp))
512 measureOp->PointCoordinates (theVertex, x, y, z);
513 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
516 string theVertexName = theVertex->GetName();
517 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
519 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
522 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
523 throw (SALOME::SALOME_Exception) {
526 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
527 MESSAGE("theVertex shape type is not VERTEX or 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 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
536 if (theVertexEntry.empty()) {
538 if (theVertex->GetShapeType() == GEOM::VERTEX) {
541 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
545 aName += theVertex->GetEntry();
546 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
547 if (!theSVertex->_is_nil())
548 theVertexEntry = theSVertex->GetID();
550 if (theVertexEntry.empty())
551 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
553 if (theVertex->GetShapeType() == GEOM::VERTEX) {
554 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
555 if (CORBA::is_nil(measureOp))
558 measureOp->PointCoordinates (theVertex, x, y, z);
559 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
562 string theVertexName = theVertex->GetName();
563 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
565 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
568 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
569 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
570 CORBA::Boolean isCompound)
571 throw (SALOME::SALOME_Exception) {
573 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
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()) {
585 MESSAGE("Coords not found: add it in coordsList");
589 MESSAGE("Coords already found, compare names");
590 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
591 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
592 MESSAGE("The names or size are different: update");
593 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
597 MESSAGE("The names and size are identical");
602 if (string(theVertexName).empty()) {
603 if (string(theGroupName).empty())
604 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
606 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
609 if (string(theGroupName).empty())
610 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
612 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
617 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
618 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
619 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
620 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
621 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
625 MESSAGE("Geom entry already found, compare names");
626 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
627 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
628 MESSAGE("The names or size are different: update");
629 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
633 MESSAGE("The names and size are identical");
638 if (string(theGroupName).empty())
639 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
641 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
646 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
648 MESSAGE("IDL : SetEnforcedVertexEntry END");
652 //=======================================================================
653 //function : GetEnforcedVertex
654 //=======================================================================
656 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
657 throw (SALOME::SALOME_Exception)
661 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
662 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
665 catch (const std::invalid_argument& ex) {
666 SALOME::ExceptionStruct ExDescription;
667 ExDescription.text = ex.what();
668 ExDescription.type = SALOME::BAD_PARAM;
669 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
670 ExDescription.lineNumber = 513;
671 throw SALOME::SALOME_Exception(ExDescription);
673 catch (SALOME_Exception& ex) {
674 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
678 //=======================================================================
679 //function : GetEnforcedVertex
680 //=======================================================================
682 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
683 throw (SALOME::SALOME_Exception)
687 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
688 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
689 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
692 string theVertexEntry = theVertex->GetStudyEntry();
693 if (theVertexEntry.empty()) {
694 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
695 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
697 if (theVertex->GetShapeType() == GEOM::VERTEX)
699 if (theVertex->GetShapeType() == GEOM::COMPOUND)
701 aName += theVertex->GetEntry();
702 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
703 if (!theSVertex->_is_nil())
704 theVertexEntry = theSVertex->GetID();
706 if (theVertexEntry.empty())
707 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
709 string theVertexName = theVertex->GetName();
712 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
713 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
716 catch (const std::invalid_argument& ex) {
717 SALOME::ExceptionStruct ExDescription;
718 ExDescription.text = ex.what();
719 ExDescription.type = SALOME::BAD_PARAM;
720 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
721 ExDescription.lineNumber = 538;
722 throw SALOME::SALOME_Exception(ExDescription);
724 catch (SALOME_Exception& ex) {
725 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
729 //=======================================================================
730 //function : GetEnforcedVertices
731 //=======================================================================
733 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
736 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
738 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
739 result->length( enfVertexList.size() );
741 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
743 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
744 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
745 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
747 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
749 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
751 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
752 coords->length(currentVertex->coords.size());
753 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
754 coords[ind] = currentVertex->coords[ind];
755 enfVertex->coords = coords;
757 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
759 enfVertex->size = currentVertex->size;
761 enfVertex->isCompound = currentVertex->isCompound;
766 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
768 return result._retn();
771 //=======================================================================
772 //function : RemoveEnforcedVertex
773 //=======================================================================
775 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
776 throw (SALOME::SALOME_Exception)
780 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
781 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
784 catch (const std::invalid_argument& ex) {
785 SALOME::ExceptionStruct ExDescription;
786 ExDescription.text = ex.what();
787 ExDescription.type = SALOME::BAD_PARAM;
788 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
789 ExDescription.lineNumber = 625;
790 throw SALOME::SALOME_Exception(ExDescription);
792 catch (SALOME_Exception& ex) {
793 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
797 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
798 throw (SALOME::SALOME_Exception)
802 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
803 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
804 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
807 string theVertexEntry = theVertex->GetStudyEntry();
808 if (theVertexEntry.empty()) {
809 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
810 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
812 if (theVertex->GetShapeType() == GEOM::VERTEX)
814 if (theVertex->GetShapeType() == GEOM::COMPOUND)
816 aName += theVertex->GetEntry();
817 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
818 if (!theSVertex->_is_nil())
819 theVertexEntry = theSVertex->GetID();
821 if (theVertexEntry.empty())
822 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
825 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
826 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
829 catch (const std::invalid_argument& ex) {
830 SALOME::ExceptionStruct ExDescription;
831 ExDescription.text = ex.what();
832 ExDescription.type = SALOME::BAD_PARAM;
833 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
834 ExDescription.lineNumber = 648;
835 throw SALOME::SALOME_Exception(ExDescription);
837 catch (SALOME_Exception& ex) {
838 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
842 //=======================================================================
843 //function : ClearEnforcedVertices
844 //=======================================================================
846 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
849 this->GetImpl()->ClearEnforcedVertices();
850 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
853 //=======================================================================
854 //function : ClearEnforcedMeshes
855 //=======================================================================
857 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
860 this->GetImpl()->ClearEnforcedMeshes();
861 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
864 //=======================================================================
865 //function : GetEnforcedMeshes
866 //=======================================================================
868 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
871 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
873 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
874 result->length( enfMeshList.size() );
876 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
878 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
879 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
880 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
882 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
884 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
886 enfMesh->elementType = currentMesh->elementType;
888 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
893 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
895 return result._retn();
899 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
901 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
902 throw (SALOME::SALOME_Exception)
904 // #if GHS3D_VERSION >= 42
905 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
907 // SALOME::ExceptionStruct ExDescription;
908 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
909 // ExDescription.type = SALOME::BAD_PARAM;
910 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
911 // ExDescription.lineNumber = 719;
912 // throw SALOME::SALOME_Exception(ExDescription);
917 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
919 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
920 throw (SALOME::SALOME_Exception)
922 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
923 // #if GHS3D_VERSION >= 42
924 return p_SetEnforcedMesh(theSource, theType);
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 = 750;
931 // throw SALOME::SALOME_Exception(ExDescription);
936 * \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.
938 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
939 throw (SALOME::SALOME_Exception)
941 // #if GHS3D_VERSION >= 42
942 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
944 // SALOME::ExceptionStruct ExDescription;
945 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
946 // ExDescription.type = SALOME::BAD_PARAM;
947 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
948 // ExDescription.lineNumber = 750;
949 // throw SALOME::SALOME_Exception(ExDescription);
954 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
956 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
957 throw (SALOME::SALOME_Exception)
959 // #if GHS3D_VERSION >= 42
960 return p_SetEnforcedMesh(theSource, theType);
962 // SALOME::ExceptionStruct ExDescription;
963 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
964 // ExDescription.type = SALOME::BAD_PARAM;
965 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
966 // ExDescription.lineNumber = 750;
967 // throw SALOME::SALOME_Exception(ExDescription);
971 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
972 throw (SALOME::SALOME_Exception)
974 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
977 if (CORBA::is_nil( theSource ))
979 SALOME::ExceptionStruct ExDescription;
980 ExDescription.text = "The source mesh CORBA object is NULL";
981 ExDescription.type = SALOME::BAD_PARAM;
982 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
983 ExDescription.lineNumber = 840;
984 throw SALOME::SALOME_Exception(ExDescription);
989 MESSAGE("Required type is NODE");
992 MESSAGE("Required type is EDGE");
995 MESSAGE("Required type is FACE");
998 MESSAGE("Incompatible required type: " << theType);
1001 // MESSAGE("Required type is "<<theType);
1002 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1003 MESSAGE("Available types:");
1004 for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
1005 if ( types->length() >= 1 && types[types->length()-1] < theType)
1007 MESSAGE("Required type not available");
1009 // SALOME::ExceptionStruct ExDescription;
1010 // ExDescription.text = "The source mesh has bad type";
1011 // ExDescription.type = SALOME::BAD_PARAM;
1012 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1013 // ExDescription.lineNumber = 840;
1014 // throw SALOME::SALOME_Exception(ExDescription);
1018 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1019 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1021 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1022 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1023 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1025 string enfMeshName = theName;
1026 if (enfMeshName.empty())
1027 enfMeshName = SObj->GetName();
1032 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1033 if (theGroupName && theGroupName[0] ) {
1034 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1035 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1038 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1039 << theSource << ".GetMesh(), " << theType << " )";
1044 catch (const std::invalid_argument& ex) {
1045 SALOME::ExceptionStruct ExDescription;
1046 ExDescription.text = ex.what();
1047 ExDescription.type = SALOME::BAD_PARAM;
1048 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1049 ExDescription.lineNumber = 840;
1050 throw SALOME::SALOME_Exception(ExDescription);
1052 catch (SALOME_Exception& ex) {
1053 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1056 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1058 MESSAGE("The source is a group")
1060 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1061 if ( theGroupName && theGroupName[0] ) {
1062 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1063 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1066 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1067 << theSource << ", " << theType << " )";
1071 catch (const std::invalid_argument& ex) {
1072 SALOME::ExceptionStruct ExDescription;
1073 ExDescription.text = ex.what();
1074 ExDescription.type = SALOME::BAD_PARAM;
1075 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1076 ExDescription.lineNumber = 840;
1077 throw SALOME::SALOME_Exception(ExDescription);
1079 catch (SALOME_Exception& ex) {
1080 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1083 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1085 MESSAGE("The source is a group on geom")
1087 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1088 if ( theGroupName && theGroupName[0] ) {
1089 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1090 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1093 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1094 << theSource << ", " << theType << " )";
1098 catch (const std::invalid_argument& ex) {
1099 SALOME::ExceptionStruct ExDescription;
1100 ExDescription.text = ex.what();
1101 ExDescription.type = SALOME::BAD_PARAM;
1102 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1103 ExDescription.lineNumber = 840;
1104 throw SALOME::SALOME_Exception(ExDescription);
1106 catch (SALOME_Exception& ex) {
1107 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1112 //=============================================================================
1114 * Get implementation
1116 //=============================================================================
1118 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1120 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1123 //================================================================================
1125 * \brief Verify whether hypothesis supports given entity type
1127 //================================================================================
1129 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1131 return type == SMESH::DIM_3D;