1 // Copyright (C) 2004-2013 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.
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)
47 //=======================================================================
48 //function : GHS3DPlugin_Hypothesis_i
49 //=======================================================================
51 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
53 ::SMESH_Gen* theGenImpl)
54 : SALOME::GenericObj_i( thePOA ),
55 SMESH_Hypothesis_i( thePOA )
57 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
58 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()->SetTextOption(option);
362 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
365 //=======================================================================
366 //function : GetTextOption
367 //=======================================================================
369 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
372 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
375 //=======================================================================
376 //function : SetToRemoveCentralPoint
377 //=======================================================================
379 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
382 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
384 if (gradation != GetGradation()) {
385 this->GetImpl()->SetGradation(gradation);
386 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
390 //=======================================================================
391 //function : GetToRemoveCentralPoint
392 //=======================================================================
394 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
397 return this->GetImpl()->GetGradation();
400 //=======================================================================
401 //function : SetEnforcedVertex
402 //=======================================================================
404 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
405 throw (SALOME::SALOME_Exception) {
407 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
408 return p_SetEnforcedVertex(size, x, y, z);
411 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
412 throw (SALOME::SALOME_Exception) {
414 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
415 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
418 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
419 throw (SALOME::SALOME_Exception) {
421 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
422 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
425 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
426 throw (SALOME::SALOME_Exception) {
428 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
429 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
432 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
433 throw (SALOME::SALOME_Exception) {
436 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
437 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
438 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
441 string theVertexEntry = theVertex->GetStudyEntry();
442 CORBA::Double x = 0, y = 0, z = 0;
443 CORBA::Boolean isCompound = false;
444 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
445 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
446 if (theVertexEntry.empty()) {
448 if (theVertex->GetShapeType() == GEOM::VERTEX) {
451 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
455 aName += theVertex->GetEntry();
456 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
457 if (!theSVertex->_is_nil())
458 theVertexEntry = theSVertex->GetID();
460 if (theVertexEntry.empty())
461 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
463 if (theVertex->GetShapeType() == GEOM::VERTEX) {
464 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
465 if (CORBA::is_nil(measureOp))
468 measureOp->PointCoordinates (theVertex, x, y, z);
469 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
472 string theVertexName = theVertex->GetName();
473 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
475 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
478 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
479 throw (SALOME::SALOME_Exception) {
482 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
483 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
484 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
487 string theVertexEntry = theVertex->GetStudyEntry();
488 CORBA::Double x = 0, y = 0, z = 0;
489 CORBA::Boolean isCompound = false;
490 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
491 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
492 if (theVertexEntry.empty()) {
494 if (theVertex->GetShapeType() == GEOM::VERTEX) {
497 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
501 aName += theVertex->GetEntry();
502 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
503 if (!theSVertex->_is_nil())
504 theVertexEntry = theSVertex->GetID();
506 if (theVertexEntry.empty())
507 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
509 if (theVertex->GetShapeType() == GEOM::VERTEX) {
510 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
511 if (CORBA::is_nil(measureOp))
514 measureOp->PointCoordinates (theVertex, x, y, z);
515 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
518 string theVertexName = theVertex->GetName();
519 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
521 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
524 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
525 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
526 CORBA::Boolean isCompound)
527 throw (SALOME::SALOME_Exception) {
529 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
530 bool newValue = false;
532 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
533 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
534 if (string(theVertexEntry).empty()) {
535 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
536 std::vector<double> coords;
540 if (coordsList.find(coords) == coordsList.end()) {
541 MESSAGE("Coords not found: add it in coordsList");
545 MESSAGE("Coords already found, compare names");
546 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
547 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
548 MESSAGE("The names or size are different: update");
549 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
553 MESSAGE("The names and size are identical");
558 if (string(theVertexName).empty()) {
559 if (string(theGroupName).empty())
560 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
562 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
565 if (string(theGroupName).empty())
566 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
568 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
573 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
574 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
575 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
576 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
577 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
581 MESSAGE("Geom entry already found, compare names");
582 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
583 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
584 MESSAGE("The names or size are different: update");
585 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
589 MESSAGE("The names and size are identical");
594 if (string(theGroupName).empty())
595 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
597 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
602 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
604 MESSAGE("IDL : SetEnforcedVertexEntry END");
608 //=======================================================================
609 //function : GetEnforcedVertex
610 //=======================================================================
612 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
613 throw (SALOME::SALOME_Exception)
617 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
618 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
621 catch (const std::invalid_argument& ex) {
622 SALOME::ExceptionStruct ExDescription;
623 ExDescription.text = ex.what();
624 ExDescription.type = SALOME::BAD_PARAM;
625 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
626 ExDescription.lineNumber = 513;
627 throw SALOME::SALOME_Exception(ExDescription);
629 catch (SALOME_Exception& ex) {
630 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
634 //=======================================================================
635 //function : GetEnforcedVertex
636 //=======================================================================
638 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
639 throw (SALOME::SALOME_Exception)
643 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
644 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
645 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
648 string theVertexEntry = theVertex->GetStudyEntry();
649 if (theVertexEntry.empty()) {
650 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
651 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
653 if (theVertex->GetShapeType() == GEOM::VERTEX)
655 if (theVertex->GetShapeType() == GEOM::COMPOUND)
657 aName += theVertex->GetEntry();
658 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
659 if (!theSVertex->_is_nil())
660 theVertexEntry = theSVertex->GetID();
662 if (theVertexEntry.empty())
663 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
665 string theVertexName = theVertex->GetName();
668 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
669 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
672 catch (const std::invalid_argument& ex) {
673 SALOME::ExceptionStruct ExDescription;
674 ExDescription.text = ex.what();
675 ExDescription.type = SALOME::BAD_PARAM;
676 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
677 ExDescription.lineNumber = 538;
678 throw SALOME::SALOME_Exception(ExDescription);
680 catch (SALOME_Exception& ex) {
681 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
685 //=======================================================================
686 //function : GetEnforcedVertices
687 //=======================================================================
689 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
692 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
694 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
695 result->length( enfVertexList.size() );
697 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
699 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
700 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
701 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
703 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
705 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
707 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
708 coords->length(currentVertex->coords.size());
709 for (int ind = 0; ind < currentVertex->coords.size(); ind++)
710 coords[ind] = currentVertex->coords[ind];
711 enfVertex->coords = coords;
713 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
715 enfVertex->size = currentVertex->size;
717 enfVertex->isCompound = currentVertex->isCompound;
722 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
724 return result._retn();
727 //=======================================================================
728 //function : RemoveEnforcedVertex
729 //=======================================================================
731 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
732 throw (SALOME::SALOME_Exception)
736 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
737 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
740 catch (const std::invalid_argument& ex) {
741 SALOME::ExceptionStruct ExDescription;
742 ExDescription.text = ex.what();
743 ExDescription.type = SALOME::BAD_PARAM;
744 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
745 ExDescription.lineNumber = 625;
746 throw SALOME::SALOME_Exception(ExDescription);
748 catch (SALOME_Exception& ex) {
749 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
753 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
754 throw (SALOME::SALOME_Exception)
758 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
759 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
760 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
763 string theVertexEntry = theVertex->GetStudyEntry();
764 if (theVertexEntry.empty()) {
765 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
766 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
768 if (theVertex->GetShapeType() == GEOM::VERTEX)
770 if (theVertex->GetShapeType() == GEOM::COMPOUND)
772 aName += theVertex->GetEntry();
773 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
774 if (!theSVertex->_is_nil())
775 theVertexEntry = theSVertex->GetID();
777 if (theVertexEntry.empty())
778 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
781 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
782 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
785 catch (const std::invalid_argument& ex) {
786 SALOME::ExceptionStruct ExDescription;
787 ExDescription.text = ex.what();
788 ExDescription.type = SALOME::BAD_PARAM;
789 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
790 ExDescription.lineNumber = 648;
791 throw SALOME::SALOME_Exception(ExDescription);
793 catch (SALOME_Exception& ex) {
794 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
798 //=======================================================================
799 //function : ClearEnforcedVertices
800 //=======================================================================
802 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
805 this->GetImpl()->ClearEnforcedVertices();
806 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
809 //=======================================================================
810 //function : ClearEnforcedMeshes
811 //=======================================================================
813 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
816 this->GetImpl()->ClearEnforcedMeshes();
817 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
820 //=======================================================================
821 //function : GetEnforcedMeshes
822 //=======================================================================
824 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
827 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
829 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
830 result->length( enfMeshList.size() );
832 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
834 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
835 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
836 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
838 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
840 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
842 enfMesh->elementType = currentMesh->elementType;
844 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
849 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
851 return result._retn();
855 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
857 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
858 throw (SALOME::SALOME_Exception)
860 // #if GHS3D_VERSION >= 42
861 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
863 // SALOME::ExceptionStruct ExDescription;
864 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
865 // ExDescription.type = SALOME::BAD_PARAM;
866 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
867 // ExDescription.lineNumber = 719;
868 // throw SALOME::SALOME_Exception(ExDescription);
873 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
875 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
876 throw (SALOME::SALOME_Exception)
878 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
879 // #if GHS3D_VERSION >= 42
880 return p_SetEnforcedMesh(theSource, theType);
882 // SALOME::ExceptionStruct ExDescription;
883 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
884 // ExDescription.type = SALOME::BAD_PARAM;
885 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
886 // ExDescription.lineNumber = 750;
887 // throw SALOME::SALOME_Exception(ExDescription);
892 * \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.
894 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
895 throw (SALOME::SALOME_Exception)
897 // #if GHS3D_VERSION >= 42
898 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
900 // SALOME::ExceptionStruct ExDescription;
901 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
902 // ExDescription.type = SALOME::BAD_PARAM;
903 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
904 // ExDescription.lineNumber = 750;
905 // throw SALOME::SALOME_Exception(ExDescription);
910 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
912 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
913 throw (SALOME::SALOME_Exception)
915 // #if GHS3D_VERSION >= 42
916 return p_SetEnforcedMesh(theSource, theType);
918 // SALOME::ExceptionStruct ExDescription;
919 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
920 // ExDescription.type = SALOME::BAD_PARAM;
921 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
922 // ExDescription.lineNumber = 750;
923 // throw SALOME::SALOME_Exception(ExDescription);
927 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
928 throw (SALOME::SALOME_Exception)
930 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
933 if (CORBA::is_nil( theSource ))
935 SALOME::ExceptionStruct ExDescription;
936 ExDescription.text = "The source mesh CORBA object is NULL";
937 ExDescription.type = SALOME::BAD_PARAM;
938 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
939 ExDescription.lineNumber = 840;
940 throw SALOME::SALOME_Exception(ExDescription);
945 MESSAGE("Required type is NODE");
948 MESSAGE("Required type is EDGE");
951 MESSAGE("Required type is FACE");
954 MESSAGE("Incompatible required type: " << theType);
957 // MESSAGE("Required type is "<<theType);
958 SMESH::array_of_ElementType_var types = theSource->GetTypes();
959 MESSAGE("Available types:");
960 for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
961 if ( types->length() >= 1 && types[types->length()-1] < theType)
963 MESSAGE("Required type not available");
965 // SALOME::ExceptionStruct ExDescription;
966 // ExDescription.text = "The source mesh has bad type";
967 // ExDescription.type = SALOME::BAD_PARAM;
968 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
969 // ExDescription.lineNumber = 840;
970 // throw SALOME::SALOME_Exception(ExDescription);
974 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
975 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
977 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
978 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
979 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
981 string enfMeshName = theName;
982 if (enfMeshName.empty())
983 enfMeshName = SObj->GetName();
988 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
989 if (theGroupName != "") {
990 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
991 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
994 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
995 << theSource << ".GetMesh(), " << theType << " )";
1000 catch (const std::invalid_argument& ex) {
1001 SALOME::ExceptionStruct ExDescription;
1002 ExDescription.text = ex.what();
1003 ExDescription.type = SALOME::BAD_PARAM;
1004 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1005 ExDescription.lineNumber = 840;
1006 throw SALOME::SALOME_Exception(ExDescription);
1008 catch (SALOME_Exception& ex) {
1009 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1012 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1014 MESSAGE("The source is a group")
1016 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1017 if (theGroupName != "") {
1018 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1019 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1022 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1023 << theSource << ", " << theType << " )";
1027 catch (const std::invalid_argument& ex) {
1028 SALOME::ExceptionStruct ExDescription;
1029 ExDescription.text = ex.what();
1030 ExDescription.type = SALOME::BAD_PARAM;
1031 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1032 ExDescription.lineNumber = 840;
1033 throw SALOME::SALOME_Exception(ExDescription);
1035 catch (SALOME_Exception& ex) {
1036 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1039 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1041 MESSAGE("The source is a group on geom")
1043 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1044 if (theGroupName != "") {
1045 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1046 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1049 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1050 << theSource << ", " << theType << " )";
1054 catch (const std::invalid_argument& ex) {
1055 SALOME::ExceptionStruct ExDescription;
1056 ExDescription.text = ex.what();
1057 ExDescription.type = SALOME::BAD_PARAM;
1058 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1059 ExDescription.lineNumber = 840;
1060 throw SALOME::SALOME_Exception(ExDescription);
1062 catch (SALOME_Exception& ex) {
1063 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1068 //=============================================================================
1070 * Get implementation
1072 //=============================================================================
1074 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1076 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1079 //================================================================================
1081 * \brief Verify whether hypothesis supports given entity type
1083 //================================================================================
1085 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1087 return type == SMESH::DIM_3D;