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,
54 ::SMESH_Gen* theGenImpl)
55 : SALOME::GenericObj_i( thePOA ),
56 SMESH_Hypothesis_i( thePOA )
58 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
59 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
63 //=======================================================================
64 //function : ~GHS3DPlugin_Hypothesis_i
65 //=======================================================================
67 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
69 MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
72 //=======================================================================
73 //function : SetToMeshHoles
74 //=======================================================================
76 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
79 this->GetImpl()->SetToMeshHoles(toMesh);
80 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
83 //=======================================================================
84 //function : GetToMeshHoles
85 //=======================================================================
87 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
90 return this->GetImpl()->GetToMeshHoles();
93 //=======================================================================
94 //function : SetToMakeGroupsOfDomains
95 //=======================================================================
97 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
100 this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
101 SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
104 //=======================================================================
105 //function : GetToMakeGroupsOfDomains
106 //=======================================================================
108 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
111 return this->GetImpl()->GetToMakeGroupsOfDomains();
114 //=======================================================================
115 //function : SetMaximumMemory
116 //=======================================================================
118 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
119 throw ( SALOME::SALOME_Exception )
122 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
124 this->GetImpl()->SetMaximumMemory(MB);
125 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
128 //=======================================================================
129 //function : GetMaximumMemory
130 //=======================================================================
132 CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
135 return this->GetImpl()->GetMaximumMemory();
138 //=======================================================================
139 //function : SetInitialMemory
140 //=======================================================================
142 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
143 throw ( SALOME::SALOME_Exception )
146 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
148 this->GetImpl()->SetInitialMemory(MB);
149 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
152 //=======================================================================
153 //function : GetInitialMemory
154 //=======================================================================
156 CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
159 return this->GetImpl()->GetInitialMemory();
162 //=======================================================================
163 //function : SetOptimizationLevel
164 //=======================================================================
166 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
167 throw ( SALOME::SALOME_Exception )
169 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
170 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
171 if ( l < ::GHS3DPlugin_Hypothesis::None ||
172 l > ::GHS3DPlugin_Hypothesis::Strong )
173 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
176 this->GetImpl()->SetOptimizationLevel(l);
177 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
180 //=======================================================================
181 //function : GetOptimizationLevel
182 //=======================================================================
184 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
187 return this->GetImpl()->GetOptimizationLevel();
190 //=======================================================================
191 //function : SetWorkingDirectory
192 //=======================================================================
194 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
197 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
200 const char lastChar = *file.rbegin();
202 if ( lastChar != '\\' ) file += '\\';
204 if ( lastChar != '/' ) file += '/';
207 SMESH_Mesh_i::PrepareForWriting (file.c_str());
210 this->GetImpl()->SetWorkingDirectory(path);
211 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
214 //=======================================================================
215 //function : GetWorkingDirectory
216 //=======================================================================
218 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
221 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
224 //=======================================================================
225 //function : SetKeepFiles
226 //=======================================================================
228 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
231 this->GetImpl()->SetKeepFiles(toKeep);
232 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
235 //=======================================================================
236 //function : GetKeepFiles
237 //=======================================================================
239 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
242 return this->GetImpl()->GetKeepFiles();
245 //=======================================================================
246 //function : SetVerboseLevel
247 //=======================================================================
249 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
250 throw ( SALOME::SALOME_Exception )
252 if (level < 0 || level > 10 )
253 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
256 this->GetImpl()->SetVerboseLevel(level);
257 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
260 //=======================================================================
261 //function : GetVerboseLevel
262 //=======================================================================
264 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
267 return this->GetImpl()->GetVerboseLevel();
270 //=======================================================================
271 //function : SetToCreateNewNodes
272 //=======================================================================
274 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
277 this->GetImpl()->SetToCreateNewNodes(toCreate);
278 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
281 //=======================================================================
282 //function : GetToCreateNewNodes
283 //=======================================================================
285 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
288 return this->GetImpl()->GetToCreateNewNodes();
291 //=======================================================================
292 //function : SetToUseBoundaryRecoveryVersion
293 //=======================================================================
295 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
298 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
299 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
302 //=======================================================================
303 //function : GetToUseBoundaryRecoveryVersion
304 //=======================================================================
306 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
309 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
312 //=======================================================================
313 //function : SetFEMCorrection
314 //=======================================================================
316 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
319 this->GetImpl()->SetFEMCorrection(toUseFem);
320 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
323 //=======================================================================
324 //function : GetFEMCorrection
325 //=======================================================================
327 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
330 return this->GetImpl()->GetFEMCorrection();
333 //=======================================================================
334 //function : SetToRemoveCentralPoint
335 //=======================================================================
337 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
340 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
341 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
344 //=======================================================================
345 //function : GetToRemoveCentralPoint
346 //=======================================================================
348 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
351 return this->GetImpl()->GetToRemoveCentralPoint();
354 //=======================================================================
355 //function : SetTextOption
356 //=======================================================================
358 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
361 this->GetImpl()->SetAdvancedOption(option);
362 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
365 //=======================================================================
366 //function : GetTextOption
367 //=======================================================================
369 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
372 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
375 //=======================================================================
376 //function : SetAdvancedOption
377 //=======================================================================
379 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
382 this->GetImpl()->SetAdvancedOption(option);
383 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
386 //=======================================================================
387 //function : GetAdvancedOption
388 //=======================================================================
390 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
393 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
396 //=======================================================================
397 //function : SetToRemoveCentralPoint
398 //=======================================================================
400 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
403 if (gradation != GetGradation()) {
404 this->GetImpl()->SetGradation(gradation);
405 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
409 //=======================================================================
410 //function : GetToRemoveCentralPoint
411 //=======================================================================
413 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
416 return this->GetImpl()->GetGradation();
419 //=======================================================================
420 //function : SetStandardOutputLog
421 //=======================================================================
423 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
426 this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
427 SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
430 //=======================================================================
431 //function : GetStandardOutputLog
432 //=======================================================================
434 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
437 return this->GetImpl()->GetStandardOutputLog();
440 //=======================================================================
441 //function : SetRemoveLogOnSuccess
442 //=======================================================================
444 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
447 this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
448 SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
451 //=======================================================================
452 //function : GetRemoveLogOnSuccess
453 //=======================================================================
455 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
458 return this->GetImpl()->GetRemoveLogOnSuccess();
461 //=======================================================================
462 //function : SetEnforcedVertex
463 //=======================================================================
465 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
466 throw (SALOME::SALOME_Exception) {
468 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
469 return p_SetEnforcedVertex(size, x, y, z);
472 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
473 throw (SALOME::SALOME_Exception) {
475 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
476 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
479 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
480 throw (SALOME::SALOME_Exception) {
482 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
483 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
486 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
487 throw (SALOME::SALOME_Exception) {
489 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
490 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
493 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
494 throw (SALOME::SALOME_Exception) {
497 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
498 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
499 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
502 string theVertexEntry = theVertex->GetStudyEntry();
503 CORBA::Double x = 0, y = 0, z = 0;
504 CORBA::Boolean isCompound = false;
505 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
506 if (theVertexEntry.empty()) {
508 if (theVertex->GetShapeType() == GEOM::VERTEX) {
511 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
515 aName += theVertex->GetEntry();
516 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
517 if (!theSVertex->_is_nil())
518 theVertexEntry = theSVertex->GetID();
520 if (theVertexEntry.empty())
521 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
523 if (theVertex->GetShapeType() == GEOM::VERTEX) {
524 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
525 if (CORBA::is_nil(measureOp))
528 measureOp->PointCoordinates (theVertex, x, y, z);
529 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
532 string theVertexName = theVertex->GetName();
533 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
535 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
538 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
539 throw (SALOME::SALOME_Exception) {
542 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
543 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
544 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
547 string theVertexEntry = theVertex->GetStudyEntry();
548 CORBA::Double x = 0, y = 0, z = 0;
549 CORBA::Boolean isCompound = false;
550 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
551 if (theVertexEntry.empty()) {
553 if (theVertex->GetShapeType() == GEOM::VERTEX) {
556 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
560 aName += theVertex->GetEntry();
561 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
562 if (!theSVertex->_is_nil())
563 theVertexEntry = theSVertex->GetID();
565 if (theVertexEntry.empty())
566 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
568 if (theVertex->GetShapeType() == GEOM::VERTEX) {
569 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
570 if (CORBA::is_nil(measureOp))
573 measureOp->PointCoordinates (theVertex, x, y, z);
574 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
577 string theVertexName = theVertex->GetName();
578 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
580 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
583 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
584 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
585 CORBA::Boolean isCompound)
586 throw (SALOME::SALOME_Exception) {
588 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
589 bool newValue = false;
591 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
592 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
593 if (string(theVertexEntry).empty()) {
594 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
595 std::vector<double> coords;
599 if (coordsList.find(coords) == coordsList.end()) {
600 MESSAGE("Coords not found: add it in coordsList");
604 MESSAGE("Coords already found, compare names");
605 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
606 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
607 MESSAGE("The names or size are different: update");
608 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
612 MESSAGE("The names and size are identical");
617 if (string(theVertexName).empty()) {
618 if (string(theGroupName).empty())
619 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
621 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
624 if (string(theGroupName).empty())
625 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
627 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
632 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
633 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
634 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
635 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
636 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
640 MESSAGE("Geom entry already found, compare names");
641 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
642 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
643 MESSAGE("The names or size are different: update");
644 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
648 MESSAGE("The names and size are identical");
653 if (string(theGroupName).empty())
654 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
656 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
661 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
663 MESSAGE("IDL : SetEnforcedVertexEntry END");
667 //=======================================================================
668 //function : GetEnforcedVertex
669 //=======================================================================
671 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
672 throw (SALOME::SALOME_Exception)
676 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
677 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
680 catch (const std::invalid_argument& ex) {
681 SALOME::ExceptionStruct ExDescription;
682 ExDescription.text = ex.what();
683 ExDescription.type = SALOME::BAD_PARAM;
684 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
685 ExDescription.lineNumber = 513;
686 throw SALOME::SALOME_Exception(ExDescription);
688 catch (SALOME_Exception& ex) {
689 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
693 //=======================================================================
694 //function : GetEnforcedVertex
695 //=======================================================================
697 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
698 throw (SALOME::SALOME_Exception)
702 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
703 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
704 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
707 string theVertexEntry = theVertex->GetStudyEntry();
708 if (theVertexEntry.empty()) {
709 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
711 if (theVertex->GetShapeType() == GEOM::VERTEX)
713 if (theVertex->GetShapeType() == GEOM::COMPOUND)
715 aName += theVertex->GetEntry();
716 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
717 if (!theSVertex->_is_nil())
718 theVertexEntry = theSVertex->GetID();
720 if (theVertexEntry.empty())
721 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
723 string theVertexName = theVertex->GetName();
726 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
727 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
730 catch (const std::invalid_argument& ex) {
731 SALOME::ExceptionStruct ExDescription;
732 ExDescription.text = ex.what();
733 ExDescription.type = SALOME::BAD_PARAM;
734 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
735 ExDescription.lineNumber = 538;
736 throw SALOME::SALOME_Exception(ExDescription);
738 catch (SALOME_Exception& ex) {
739 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
743 //=======================================================================
744 //function : GetEnforcedVertices
745 //=======================================================================
747 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
750 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
752 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
753 result->length( enfVertexList.size() );
755 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
757 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
758 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
759 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
761 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
763 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
765 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
766 coords->length(currentVertex->coords.size());
767 for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
768 coords[ind] = currentVertex->coords[ind];
769 enfVertex->coords = coords;
771 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
773 enfVertex->size = currentVertex->size;
775 enfVertex->isCompound = currentVertex->isCompound;
780 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
782 return result._retn();
785 //=======================================================================
786 //function : RemoveEnforcedVertex
787 //=======================================================================
789 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
790 throw (SALOME::SALOME_Exception)
794 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
795 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
798 catch (const std::invalid_argument& ex) {
799 SALOME::ExceptionStruct ExDescription;
800 ExDescription.text = ex.what();
801 ExDescription.type = SALOME::BAD_PARAM;
802 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
803 ExDescription.lineNumber = 625;
804 throw SALOME::SALOME_Exception(ExDescription);
806 catch (SALOME_Exception& ex) {
807 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
811 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
812 throw (SALOME::SALOME_Exception)
816 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
817 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
818 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
821 string theVertexEntry = theVertex->GetStudyEntry();
822 if (theVertexEntry.empty()) {
823 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
825 if (theVertex->GetShapeType() == GEOM::VERTEX)
827 if (theVertex->GetShapeType() == GEOM::COMPOUND)
829 aName += theVertex->GetEntry();
830 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
831 if (!theSVertex->_is_nil())
832 theVertexEntry = theSVertex->GetID();
834 if (theVertexEntry.empty())
835 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
838 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
839 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
842 catch (const std::invalid_argument& ex) {
843 SALOME::ExceptionStruct ExDescription;
844 ExDescription.text = ex.what();
845 ExDescription.type = SALOME::BAD_PARAM;
846 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
847 ExDescription.lineNumber = 648;
848 throw SALOME::SALOME_Exception(ExDescription);
850 catch (SALOME_Exception& ex) {
851 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
855 //=======================================================================
856 //function : ClearEnforcedVertices
857 //=======================================================================
859 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
862 this->GetImpl()->ClearEnforcedVertices();
863 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
866 //=======================================================================
867 //function : ClearEnforcedMeshes
868 //=======================================================================
870 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
873 this->GetImpl()->ClearEnforcedMeshes();
874 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
877 //=======================================================================
878 //function : GetEnforcedMeshes
879 //=======================================================================
881 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
884 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
886 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
887 result->length( enfMeshList.size() );
889 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
891 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
892 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
893 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
895 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
897 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
899 enfMesh->elementType = currentMesh->elementType;
901 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
906 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
908 return result._retn();
912 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
914 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
915 throw (SALOME::SALOME_Exception)
917 // #if GHS3D_VERSION >= 42
918 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
920 // SALOME::ExceptionStruct ExDescription;
921 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
922 // ExDescription.type = SALOME::BAD_PARAM;
923 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
924 // ExDescription.lineNumber = 719;
925 // throw SALOME::SALOME_Exception(ExDescription);
930 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
932 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
933 throw (SALOME::SALOME_Exception)
935 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
936 // #if GHS3D_VERSION >= 42
937 return p_SetEnforcedMesh(theSource, theType);
939 // SALOME::ExceptionStruct ExDescription;
940 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
941 // ExDescription.type = SALOME::BAD_PARAM;
942 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
943 // ExDescription.lineNumber = 750;
944 // throw SALOME::SALOME_Exception(ExDescription);
949 * \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.
951 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
952 throw (SALOME::SALOME_Exception)
954 // #if GHS3D_VERSION >= 42
955 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
957 // SALOME::ExceptionStruct ExDescription;
958 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
959 // ExDescription.type = SALOME::BAD_PARAM;
960 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
961 // ExDescription.lineNumber = 750;
962 // throw SALOME::SALOME_Exception(ExDescription);
967 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
969 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
970 throw (SALOME::SALOME_Exception)
972 // #if GHS3D_VERSION >= 42
973 return p_SetEnforcedMesh(theSource, theType);
975 // SALOME::ExceptionStruct ExDescription;
976 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
977 // ExDescription.type = SALOME::BAD_PARAM;
978 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
979 // ExDescription.lineNumber = 750;
980 // throw SALOME::SALOME_Exception(ExDescription);
984 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
985 throw (SALOME::SALOME_Exception)
987 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
990 if (CORBA::is_nil( theSource ))
992 SALOME::ExceptionStruct ExDescription;
993 ExDescription.text = "The source mesh CORBA object is NULL";
994 ExDescription.type = SALOME::BAD_PARAM;
995 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
996 ExDescription.lineNumber = 840;
997 throw SALOME::SALOME_Exception(ExDescription);
1002 MESSAGE("Required type is NODE");
1005 MESSAGE("Required type is EDGE");
1008 MESSAGE("Required type is FACE");
1011 MESSAGE("Incompatible required type: " << theType);
1014 // MESSAGE("Required type is "<<theType);
1015 SMESH::array_of_ElementType_var types = theSource->GetTypes();
1016 MESSAGE("Available types:");
1017 for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
1018 if ( types->length() >= 1 && types[types->length()-1] < theType)
1020 MESSAGE("Required type not available");
1022 // SALOME::ExceptionStruct ExDescription;
1023 // ExDescription.text = "The source mesh has bad type";
1024 // ExDescription.type = SALOME::BAD_PARAM;
1025 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1026 // ExDescription.lineNumber = 840;
1027 // throw SALOME::SALOME_Exception(ExDescription);
1031 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1032 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1034 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1035 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1036 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1038 string enfMeshName = theName;
1039 if (enfMeshName.empty())
1040 enfMeshName = SObj->GetName();
1045 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1046 if (theGroupName && theGroupName[0] ) {
1047 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1048 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1051 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1052 << theSource << ".GetMesh(), " << theType << " )";
1057 catch (const std::invalid_argument& ex) {
1058 SALOME::ExceptionStruct ExDescription;
1059 ExDescription.text = ex.what();
1060 ExDescription.type = SALOME::BAD_PARAM;
1061 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1062 ExDescription.lineNumber = 840;
1063 throw SALOME::SALOME_Exception(ExDescription);
1065 catch (SALOME_Exception& ex) {
1066 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1069 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1071 MESSAGE("The source is a group")
1073 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1074 if ( theGroupName && theGroupName[0] ) {
1075 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1076 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1079 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1080 << theSource << ", " << theType << " )";
1084 catch (const std::invalid_argument& ex) {
1085 SALOME::ExceptionStruct ExDescription;
1086 ExDescription.text = ex.what();
1087 ExDescription.type = SALOME::BAD_PARAM;
1088 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1089 ExDescription.lineNumber = 840;
1090 throw SALOME::SALOME_Exception(ExDescription);
1092 catch (SALOME_Exception& ex) {
1093 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1096 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1098 MESSAGE("The source is a group on geom")
1100 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1101 if ( theGroupName && theGroupName[0] ) {
1102 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1103 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1106 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1107 << theSource << ", " << theType << " )";
1111 catch (const std::invalid_argument& ex) {
1112 SALOME::ExceptionStruct ExDescription;
1113 ExDescription.text = ex.what();
1114 ExDescription.type = SALOME::BAD_PARAM;
1115 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1116 ExDescription.lineNumber = 840;
1117 throw SALOME::SALOME_Exception(ExDescription);
1119 catch (SALOME_Exception& ex) {
1120 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1125 //=============================================================================
1127 * Get implementation
1129 //=============================================================================
1131 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1133 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1136 //================================================================================
1138 * \brief Verify whether hypothesis supports given entity type
1140 //================================================================================
1142 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1144 return type == SMESH::DIM_3D;