1 // Copyright (C) 2004-2012 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 : SetMaximumMemory
95 //=======================================================================
97 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
98 throw ( SALOME::SALOME_Exception )
101 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
103 this->GetImpl()->SetMaximumMemory(MB);
104 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
107 //=======================================================================
108 //function : GetMaximumMemory
109 //=======================================================================
111 CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
114 return this->GetImpl()->GetMaximumMemory();
117 //=======================================================================
118 //function : SetInitialMemory
119 //=======================================================================
121 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
122 throw ( SALOME::SALOME_Exception )
125 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
127 this->GetImpl()->SetInitialMemory(MB);
128 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
131 //=======================================================================
132 //function : GetInitialMemory
133 //=======================================================================
135 CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
138 return this->GetImpl()->GetInitialMemory();
141 //=======================================================================
142 //function : SetOptimizationLevel
143 //=======================================================================
145 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
146 throw ( SALOME::SALOME_Exception )
148 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
149 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
150 if ( l < ::GHS3DPlugin_Hypothesis::None ||
151 l > ::GHS3DPlugin_Hypothesis::Strong )
152 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
155 this->GetImpl()->SetOptimizationLevel(l);
156 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
159 //=======================================================================
160 //function : GetOptimizationLevel
161 //=======================================================================
163 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
166 return this->GetImpl()->GetOptimizationLevel();
169 //=======================================================================
170 //function : SetWorkingDirectory
171 //=======================================================================
173 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
176 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
179 const char lastChar = *file.rbegin();
181 if ( lastChar != '\\' ) file += '\\';
183 if ( lastChar != '/' ) file += '/';
186 SMESH_Mesh_i::PrepareForWriting (file.c_str());
189 this->GetImpl()->SetWorkingDirectory(path);
190 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
193 //=======================================================================
194 //function : GetWorkingDirectory
195 //=======================================================================
197 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
200 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
203 //=======================================================================
204 //function : SetKeepFiles
205 //=======================================================================
207 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
210 this->GetImpl()->SetKeepFiles(toKeep);
211 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
214 //=======================================================================
215 //function : GetKeepFiles
216 //=======================================================================
218 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
221 return this->GetImpl()->GetKeepFiles();
224 //=======================================================================
225 //function : SetVerboseLevel
226 //=======================================================================
228 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
229 throw ( SALOME::SALOME_Exception )
231 if (level < 0 || level > 10 )
232 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
235 this->GetImpl()->SetVerboseLevel(level);
236 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
239 //=======================================================================
240 //function : GetVerboseLevel
241 //=======================================================================
243 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
246 return this->GetImpl()->GetVerboseLevel();
249 //=======================================================================
250 //function : SetToCreateNewNodes
251 //=======================================================================
253 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
256 this->GetImpl()->SetToCreateNewNodes(toCreate);
257 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
260 //=======================================================================
261 //function : GetToCreateNewNodes
262 //=======================================================================
264 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
267 return this->GetImpl()->GetToCreateNewNodes();
270 //=======================================================================
271 //function : SetToUseBoundaryRecoveryVersion
272 //=======================================================================
274 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
277 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
278 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
281 //=======================================================================
282 //function : GetToUseBoundaryRecoveryVersion
283 //=======================================================================
285 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
288 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
291 //=======================================================================
292 //function : SetFEMCorrection
293 //=======================================================================
295 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
298 this->GetImpl()->SetFEMCorrection(toUseFem);
299 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
302 //=======================================================================
303 //function : GetFEMCorrection
304 //=======================================================================
306 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
309 return this->GetImpl()->GetFEMCorrection();
312 //=======================================================================
313 //function : SetToRemoveCentralPoint
314 //=======================================================================
316 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
319 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
320 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
323 //=======================================================================
324 //function : GetToRemoveCentralPoint
325 //=======================================================================
327 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
330 return this->GetImpl()->GetToRemoveCentralPoint();
333 //=======================================================================
334 //function : SetTextOption
335 //=======================================================================
337 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
340 this->GetImpl()->SetTextOption(option);
341 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
344 //=======================================================================
345 //function : GetTextOption
346 //=======================================================================
348 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
351 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
354 //=======================================================================
355 //function : SetToRemoveCentralPoint
356 //=======================================================================
358 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
361 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
363 if (gradation != GetGradation()) {
364 this->GetImpl()->SetGradation(gradation);
365 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
369 //=======================================================================
370 //function : GetToRemoveCentralPoint
371 //=======================================================================
373 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
376 return this->GetImpl()->GetGradation();
379 //=======================================================================
380 //function : SetEnforcedVertex
381 //=======================================================================
383 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
384 throw (SALOME::SALOME_Exception) {
386 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
387 return p_SetEnforcedVertex(size, x, y, z);
390 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
391 throw (SALOME::SALOME_Exception) {
393 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
394 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
397 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
398 throw (SALOME::SALOME_Exception) {
400 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
401 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
404 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
405 throw (SALOME::SALOME_Exception) {
407 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
408 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
411 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
412 throw (SALOME::SALOME_Exception) {
415 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
416 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
417 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
420 string theVertexEntry = theVertex->GetStudyEntry();
421 CORBA::Double x = 0, y = 0, z = 0;
422 CORBA::Boolean isCompound = false;
423 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
424 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
425 if (theVertexEntry.empty()) {
427 if (theVertex->GetShapeType() == GEOM::VERTEX) {
430 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
434 aName += theVertex->GetEntry();
435 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
436 if (!theSVertex->_is_nil())
437 theVertexEntry = theSVertex->GetID();
439 if (theVertexEntry.empty())
440 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
442 if (theVertex->GetShapeType() == GEOM::VERTEX) {
443 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
444 if (CORBA::is_nil(measureOp))
447 measureOp->PointCoordinates (theVertex, x, y, z);
448 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
451 string theVertexName = theVertex->GetName();
452 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
454 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
457 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
458 throw (SALOME::SALOME_Exception) {
461 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
462 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
463 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
466 string theVertexEntry = theVertex->GetStudyEntry();
467 CORBA::Double x = 0, y = 0, z = 0;
468 CORBA::Boolean isCompound = false;
469 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
470 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
471 if (theVertexEntry.empty()) {
473 if (theVertex->GetShapeType() == GEOM::VERTEX) {
476 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
480 aName += theVertex->GetEntry();
481 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
482 if (!theSVertex->_is_nil())
483 theVertexEntry = theSVertex->GetID();
485 if (theVertexEntry.empty())
486 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
488 if (theVertex->GetShapeType() == GEOM::VERTEX) {
489 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
490 if (CORBA::is_nil(measureOp))
493 measureOp->PointCoordinates (theVertex, x, y, z);
494 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
497 string theVertexName = theVertex->GetName();
498 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
500 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
503 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
504 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
505 CORBA::Boolean isCompound)
506 throw (SALOME::SALOME_Exception) {
508 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
509 bool newValue = false;
511 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
512 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
513 if (string(theVertexEntry).empty()) {
514 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
515 std::vector<double> coords;
519 if (coordsList.find(coords) == coordsList.end()) {
520 MESSAGE("Coords not found: add it in coordsList");
524 MESSAGE("Coords already found, compare names");
525 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
526 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
527 MESSAGE("The names or size are different: update");
528 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
532 MESSAGE("The names and size are identical");
537 if (string(theVertexName).empty()) {
538 if (string(theGroupName).empty())
539 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
541 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
544 if (string(theGroupName).empty())
545 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
547 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
552 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
553 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
554 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
555 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
556 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
560 MESSAGE("Geom entry already found, compare names");
561 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
562 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
563 MESSAGE("The names or size are different: update");
564 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
568 MESSAGE("The names and size are identical");
573 if (string(theGroupName).empty())
574 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
576 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
581 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
583 MESSAGE("IDL : SetEnforcedVertexEntry END");
587 //=======================================================================
588 //function : GetEnforcedVertex
589 //=======================================================================
591 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
592 throw (SALOME::SALOME_Exception)
596 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
597 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
600 catch (const std::invalid_argument& ex) {
601 SALOME::ExceptionStruct ExDescription;
602 ExDescription.text = ex.what();
603 ExDescription.type = SALOME::BAD_PARAM;
604 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
605 ExDescription.lineNumber = 513;
606 throw SALOME::SALOME_Exception(ExDescription);
608 catch (SALOME_Exception& ex) {
609 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
613 //=======================================================================
614 //function : GetEnforcedVertex
615 //=======================================================================
617 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
618 throw (SALOME::SALOME_Exception)
622 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
623 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
624 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
627 string theVertexEntry = theVertex->GetStudyEntry();
628 if (theVertexEntry.empty()) {
629 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
630 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
632 if (theVertex->GetShapeType() == GEOM::VERTEX)
634 if (theVertex->GetShapeType() == GEOM::COMPOUND)
636 aName += theVertex->GetEntry();
637 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
638 if (!theSVertex->_is_nil())
639 theVertexEntry = theSVertex->GetID();
641 if (theVertexEntry.empty())
642 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
644 string theVertexName = theVertex->GetName();
647 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
648 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
651 catch (const std::invalid_argument& ex) {
652 SALOME::ExceptionStruct ExDescription;
653 ExDescription.text = ex.what();
654 ExDescription.type = SALOME::BAD_PARAM;
655 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
656 ExDescription.lineNumber = 538;
657 throw SALOME::SALOME_Exception(ExDescription);
659 catch (SALOME_Exception& ex) {
660 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
664 //=======================================================================
665 //function : GetEnforcedVertices
666 //=======================================================================
668 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
671 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
673 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
674 result->length( enfVertexList.size() );
676 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
678 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
679 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
680 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
682 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
684 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
686 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
687 coords->length(currentVertex->coords.size());
688 for (int ind = 0; ind < currentVertex->coords.size(); ind++)
689 coords[ind] = currentVertex->coords[ind];
690 enfVertex->coords = coords;
692 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
694 enfVertex->size = currentVertex->size;
696 enfVertex->isCompound = currentVertex->isCompound;
701 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
703 return result._retn();
706 //=======================================================================
707 //function : RemoveEnforcedVertex
708 //=======================================================================
710 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
711 throw (SALOME::SALOME_Exception)
715 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
716 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
719 catch (const std::invalid_argument& ex) {
720 SALOME::ExceptionStruct ExDescription;
721 ExDescription.text = ex.what();
722 ExDescription.type = SALOME::BAD_PARAM;
723 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
724 ExDescription.lineNumber = 625;
725 throw SALOME::SALOME_Exception(ExDescription);
727 catch (SALOME_Exception& ex) {
728 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
732 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
733 throw (SALOME::SALOME_Exception)
737 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
738 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
739 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
742 string theVertexEntry = theVertex->GetStudyEntry();
743 if (theVertexEntry.empty()) {
744 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
745 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
747 if (theVertex->GetShapeType() == GEOM::VERTEX)
749 if (theVertex->GetShapeType() == GEOM::COMPOUND)
751 aName += theVertex->GetEntry();
752 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
753 if (!theSVertex->_is_nil())
754 theVertexEntry = theSVertex->GetID();
756 if (theVertexEntry.empty())
757 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
760 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
761 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
764 catch (const std::invalid_argument& ex) {
765 SALOME::ExceptionStruct ExDescription;
766 ExDescription.text = ex.what();
767 ExDescription.type = SALOME::BAD_PARAM;
768 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
769 ExDescription.lineNumber = 648;
770 throw SALOME::SALOME_Exception(ExDescription);
772 catch (SALOME_Exception& ex) {
773 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
777 //=======================================================================
778 //function : ClearEnforcedVertices
779 //=======================================================================
781 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
784 this->GetImpl()->ClearEnforcedVertices();
785 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
788 //=======================================================================
789 //function : ClearEnforcedMeshes
790 //=======================================================================
792 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
795 this->GetImpl()->ClearEnforcedMeshes();
796 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
799 //=======================================================================
800 //function : GetEnforcedMeshes
801 //=======================================================================
803 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
806 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
808 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
809 result->length( enfMeshList.size() );
811 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
813 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
814 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
815 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
817 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
819 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
821 enfMesh->elementType = currentMesh->elementType;
823 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
828 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
830 return result._retn();
834 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
836 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
837 throw (SALOME::SALOME_Exception)
839 // #if GHS3D_VERSION >= 42
840 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
842 // SALOME::ExceptionStruct ExDescription;
843 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
844 // ExDescription.type = SALOME::BAD_PARAM;
845 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
846 // ExDescription.lineNumber = 719;
847 // throw SALOME::SALOME_Exception(ExDescription);
852 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
854 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
855 throw (SALOME::SALOME_Exception)
857 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
858 // #if GHS3D_VERSION >= 42
859 return p_SetEnforcedMesh(theSource, theType);
861 // SALOME::ExceptionStruct ExDescription;
862 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
863 // ExDescription.type = SALOME::BAD_PARAM;
864 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
865 // ExDescription.lineNumber = 750;
866 // throw SALOME::SALOME_Exception(ExDescription);
871 * \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.
873 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
874 throw (SALOME::SALOME_Exception)
876 // #if GHS3D_VERSION >= 42
877 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
879 // SALOME::ExceptionStruct ExDescription;
880 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
881 // ExDescription.type = SALOME::BAD_PARAM;
882 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
883 // ExDescription.lineNumber = 750;
884 // throw SALOME::SALOME_Exception(ExDescription);
889 * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
891 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
892 throw (SALOME::SALOME_Exception)
894 // #if GHS3D_VERSION >= 42
895 return p_SetEnforcedMesh(theSource, theType);
897 // SALOME::ExceptionStruct ExDescription;
898 // ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
899 // ExDescription.type = SALOME::BAD_PARAM;
900 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
901 // ExDescription.lineNumber = 750;
902 // throw SALOME::SALOME_Exception(ExDescription);
906 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
907 throw (SALOME::SALOME_Exception)
909 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
912 if (CORBA::is_nil( theSource ))
914 SALOME::ExceptionStruct ExDescription;
915 ExDescription.text = "The source mesh CORBA object is NULL";
916 ExDescription.type = SALOME::BAD_PARAM;
917 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
918 ExDescription.lineNumber = 840;
919 throw SALOME::SALOME_Exception(ExDescription);
924 MESSAGE("Required type is NODE");
927 MESSAGE("Required type is EDGE");
930 MESSAGE("Required type is FACE");
933 MESSAGE("Incompatible required type: " << theType);
936 // MESSAGE("Required type is "<<theType);
937 SMESH::array_of_ElementType_var types = theSource->GetTypes();
938 MESSAGE("Available types:");
939 for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
940 if ( types->length() >= 1 && types[types->length()-1] < theType)
942 MESSAGE("Required type not available");
944 // SALOME::ExceptionStruct ExDescription;
945 // ExDescription.text = "The source mesh has bad type";
946 // ExDescription.type = SALOME::BAD_PARAM;
947 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
948 // ExDescription.lineNumber = 840;
949 // throw SALOME::SALOME_Exception(ExDescription);
953 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
954 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
956 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
957 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
958 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
960 string enfMeshName = theName;
961 if (enfMeshName.empty())
962 enfMeshName = SObj->GetName();
967 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
968 if (theGroupName != "") {
969 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
970 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
973 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
974 << theSource << ".GetMesh(), " << theType << " )";
979 catch (const std::invalid_argument& ex) {
980 SALOME::ExceptionStruct ExDescription;
981 ExDescription.text = ex.what();
982 ExDescription.type = SALOME::BAD_PARAM;
983 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
984 ExDescription.lineNumber = 840;
985 throw SALOME::SALOME_Exception(ExDescription);
987 catch (SALOME_Exception& ex) {
988 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
991 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
993 MESSAGE("The source is a group")
995 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
996 if (theGroupName != "") {
997 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
998 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1001 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1002 << theSource << ", " << theType << " )";
1006 catch (const std::invalid_argument& ex) {
1007 SALOME::ExceptionStruct ExDescription;
1008 ExDescription.text = ex.what();
1009 ExDescription.type = SALOME::BAD_PARAM;
1010 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1011 ExDescription.lineNumber = 840;
1012 throw SALOME::SALOME_Exception(ExDescription);
1014 catch (SALOME_Exception& ex) {
1015 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1018 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1020 MESSAGE("The source is a group on geom")
1022 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1023 if (theGroupName != "") {
1024 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1025 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1028 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1029 << theSource << ", " << theType << " )";
1033 catch (const std::invalid_argument& ex) {
1034 SALOME::ExceptionStruct ExDescription;
1035 ExDescription.text = ex.what();
1036 ExDescription.type = SALOME::BAD_PARAM;
1037 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1038 ExDescription.lineNumber = 840;
1039 throw SALOME::SALOME_Exception(ExDescription);
1041 catch (SALOME_Exception& ex) {
1042 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1047 //=============================================================================
1049 * Get implementation
1051 //=============================================================================
1053 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1055 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1058 //================================================================================
1060 * \brief Verify whether hypothesis supports given entity type
1062 //================================================================================
1064 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1066 return type == SMESH::DIM_3D;