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)
48 #define GHS3D_VERSION 41
50 //=======================================================================
51 //function : GHS3DPlugin_Hypothesis_i
52 //=======================================================================
54 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
56 ::SMESH_Gen* theGenImpl)
57 : SALOME::GenericObj_i( thePOA ),
58 SMESH_Hypothesis_i( thePOA )
60 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
61 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
66 //=======================================================================
67 //function : ~GHS3DPlugin_Hypothesis_i
68 //=======================================================================
70 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
72 MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
75 //=======================================================================
76 //function : SetToMeshHoles
77 //=======================================================================
79 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
82 this->GetImpl()->SetToMeshHoles(toMesh);
83 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
86 //=======================================================================
87 //function : GetToMeshHoles
88 //=======================================================================
90 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
93 return this->GetImpl()->GetToMeshHoles();
96 //=======================================================================
97 //function : SetMaximumMemory
98 //=======================================================================
100 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
101 throw ( SALOME::SALOME_Exception )
104 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
106 this->GetImpl()->SetMaximumMemory(MB);
107 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
110 //=======================================================================
111 //function : GetMaximumMemory
112 //=======================================================================
114 CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
117 return this->GetImpl()->GetMaximumMemory();
120 //=======================================================================
121 //function : SetInitialMemory
122 //=======================================================================
124 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
125 throw ( SALOME::SALOME_Exception )
128 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
130 this->GetImpl()->SetInitialMemory(MB);
131 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
134 //=======================================================================
135 //function : GetInitialMemory
136 //=======================================================================
138 CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
141 return this->GetImpl()->GetInitialMemory();
144 //=======================================================================
145 //function : SetOptimizationLevel
146 //=======================================================================
148 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
149 throw ( SALOME::SALOME_Exception )
151 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
152 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
153 if ( l < ::GHS3DPlugin_Hypothesis::None ||
154 l > ::GHS3DPlugin_Hypothesis::Strong )
155 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
158 this->GetImpl()->SetOptimizationLevel(l);
159 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
162 //=======================================================================
163 //function : GetOptimizationLevel
164 //=======================================================================
166 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
169 return this->GetImpl()->GetOptimizationLevel();
172 //=======================================================================
173 //function : SetWorkingDirectory
174 //=======================================================================
176 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
179 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
182 const char lastChar = *file.rbegin();
184 if ( lastChar != '\\' ) file += '\\';
186 if ( lastChar != '/' ) file += '/';
189 SMESH_Mesh_i::PrepareForWriting (file.c_str());
192 this->GetImpl()->SetWorkingDirectory(path);
193 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
196 //=======================================================================
197 //function : GetWorkingDirectory
198 //=======================================================================
200 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
203 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
206 //=======================================================================
207 //function : SetKeepFiles
208 //=======================================================================
210 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
213 this->GetImpl()->SetKeepFiles(toKeep);
214 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
217 //=======================================================================
218 //function : GetKeepFiles
219 //=======================================================================
221 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
224 return this->GetImpl()->GetKeepFiles();
227 //=======================================================================
228 //function : SetVerboseLevel
229 //=======================================================================
231 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
232 throw ( SALOME::SALOME_Exception )
234 if (level < 0 || level > 10 )
235 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
238 this->GetImpl()->SetVerboseLevel(level);
239 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
242 //=======================================================================
243 //function : GetVerboseLevel
244 //=======================================================================
246 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
249 return this->GetImpl()->GetVerboseLevel();
252 //=======================================================================
253 //function : SetToCreateNewNodes
254 //=======================================================================
256 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
259 this->GetImpl()->SetToCreateNewNodes(toCreate);
260 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
263 //=======================================================================
264 //function : GetToCreateNewNodes
265 //=======================================================================
267 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
270 return this->GetImpl()->GetToCreateNewNodes();
273 //=======================================================================
274 //function : SetToUseBoundaryRecoveryVersion
275 //=======================================================================
277 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
280 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
281 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
284 //=======================================================================
285 //function : GetToUseBoundaryRecoveryVersion
286 //=======================================================================
288 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
291 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
294 //=======================================================================
295 //function : SetFEMCorrection
296 //=======================================================================
298 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
301 this->GetImpl()->SetFEMCorrection(toUseFem);
302 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
305 //=======================================================================
306 //function : GetFEMCorrection
307 //=======================================================================
309 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
312 return this->GetImpl()->GetFEMCorrection();
315 //=======================================================================
316 //function : SetToRemoveCentralPoint
317 //=======================================================================
319 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
322 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
323 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
326 //=======================================================================
327 //function : GetToRemoveCentralPoint
328 //=======================================================================
330 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
333 return this->GetImpl()->GetToRemoveCentralPoint();
336 //=======================================================================
337 //function : SetTextOption
338 //=======================================================================
340 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
343 this->GetImpl()->SetTextOption(option);
344 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
347 //=======================================================================
348 //function : GetTextOption
349 //=======================================================================
351 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
354 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
357 //=======================================================================
358 //function : SetToRemoveCentralPoint
359 //=======================================================================
361 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
364 THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
366 if (gradation != GetGradation()) {
367 this->GetImpl()->SetGradation(gradation);
368 SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
372 //=======================================================================
373 //function : GetToRemoveCentralPoint
374 //=======================================================================
376 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
379 return this->GetImpl()->GetGradation();
382 //=======================================================================
383 //function : SetEnforcedVertex
384 //=======================================================================
386 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
387 throw (SALOME::SALOME_Exception) {
389 MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
390 return p_SetEnforcedVertex(size, x, y, z);
393 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
394 throw (SALOME::SALOME_Exception) {
396 MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
397 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
400 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
401 throw (SALOME::SALOME_Exception) {
403 MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
404 return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
407 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
408 throw (SALOME::SALOME_Exception) {
410 MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
411 return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
414 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
415 throw (SALOME::SALOME_Exception) {
418 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
419 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
420 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
423 string theVertexEntry = theVertex->GetStudyEntry();
424 CORBA::Double x = 0, y = 0, z = 0;
425 CORBA::Boolean isCompound = false;
426 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
427 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
428 if (theVertexEntry.empty()) {
430 if (theVertex->GetShapeType() == GEOM::VERTEX) {
433 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
437 aName += theVertex->GetEntry();
438 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
439 if (!theSVertex->_is_nil())
440 theVertexEntry = theSVertex->GetID();
442 if (theVertexEntry.empty())
443 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
445 if (theVertex->GetShapeType() == GEOM::VERTEX) {
446 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
447 if (CORBA::is_nil(measureOp))
450 measureOp->PointCoordinates (theVertex, x, y, z);
451 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
454 string theVertexName = theVertex->GetName();
455 MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
457 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
460 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
461 throw (SALOME::SALOME_Exception) {
464 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
465 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
466 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
469 string theVertexEntry = theVertex->GetStudyEntry();
470 CORBA::Double x = 0, y = 0, z = 0;
471 CORBA::Boolean isCompound = false;
472 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
473 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
474 if (theVertexEntry.empty()) {
476 if (theVertex->GetShapeType() == GEOM::VERTEX) {
479 if (theVertex->GetShapeType() == GEOM::COMPOUND) {
483 aName += theVertex->GetEntry();
484 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
485 if (!theSVertex->_is_nil())
486 theVertexEntry = theSVertex->GetID();
488 if (theVertexEntry.empty())
489 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
491 if (theVertex->GetShapeType() == GEOM::VERTEX) {
492 GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
493 if (CORBA::is_nil(measureOp))
496 measureOp->PointCoordinates (theVertex, x, y, z);
497 MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
500 string theVertexName = theVertex->GetName();
501 MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
503 return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
506 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
507 const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
508 CORBA::Boolean isCompound)
509 throw (SALOME::SALOME_Exception) {
511 MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
512 bool newValue = false;
514 ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
515 ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
516 if (string(theVertexEntry).empty()) {
517 coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
518 std::vector<double> coords;
522 if (coordsList.find(coords) == coordsList.end()) {
523 MESSAGE("Coords not found: add it in coordsList");
527 MESSAGE("Coords already found, compare names");
528 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
529 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
530 MESSAGE("The names or size are different: update");
531 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
535 MESSAGE("The names and size are identical");
540 if (string(theVertexName).empty()) {
541 if (string(theGroupName).empty())
542 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
544 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
547 if (string(theGroupName).empty())
548 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
550 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
555 // if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
556 enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
557 // ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
558 if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
559 MESSAGE("Geom entry not found: add it in enfVertexEntryList");
563 MESSAGE("Geom entry already found, compare names");
564 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
565 if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
566 MESSAGE("The names or size are different: update");
567 // this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
571 MESSAGE("The names and size are identical");
576 if (string(theGroupName).empty())
577 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
579 SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
584 this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
586 MESSAGE("IDL : SetEnforcedVertexEntry END");
590 //=======================================================================
591 //function : GetEnforcedVertex
592 //=======================================================================
594 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
595 throw (SALOME::SALOME_Exception)
599 bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
600 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
603 catch (const std::invalid_argument& ex) {
604 SALOME::ExceptionStruct ExDescription;
605 ExDescription.text = ex.what();
606 ExDescription.type = SALOME::BAD_PARAM;
607 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
608 ExDescription.lineNumber = 513;
609 throw SALOME::SALOME_Exception(ExDescription);
611 catch (SALOME_Exception& ex) {
612 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
616 //=======================================================================
617 //function : GetEnforcedVertex
618 //=======================================================================
620 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
621 throw (SALOME::SALOME_Exception)
625 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
626 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
627 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
630 string theVertexEntry = theVertex->GetStudyEntry();
631 if (theVertexEntry.empty()) {
632 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
633 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
635 if (theVertex->GetShapeType() == GEOM::VERTEX)
637 if (theVertex->GetShapeType() == GEOM::COMPOUND)
639 aName += theVertex->GetEntry();
640 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
641 if (!theSVertex->_is_nil())
642 theVertexEntry = theSVertex->GetID();
644 if (theVertexEntry.empty())
645 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
647 string theVertexName = theVertex->GetName();
650 bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
651 SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
654 catch (const std::invalid_argument& ex) {
655 SALOME::ExceptionStruct ExDescription;
656 ExDescription.text = ex.what();
657 ExDescription.type = SALOME::BAD_PARAM;
658 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
659 ExDescription.lineNumber = 538;
660 throw SALOME::SALOME_Exception(ExDescription);
662 catch (SALOME_Exception& ex) {
663 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
667 //=======================================================================
668 //function : GetEnforcedVertices
669 //=======================================================================
671 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
674 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
676 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
677 result->length( enfVertexList.size() );
679 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
681 for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
682 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
683 GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
685 enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
687 enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
689 GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
690 coords->length(currentVertex->coords.size());
691 for (int ind = 0; ind < currentVertex->coords.size(); ind++)
692 coords[ind] = currentVertex->coords[ind];
693 enfVertex->coords = coords;
695 enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
697 enfVertex->size = currentVertex->size;
699 enfVertex->isCompound = currentVertex->isCompound;
704 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
706 return result._retn();
709 //=======================================================================
710 //function : RemoveEnforcedVertex
711 //=======================================================================
713 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
714 throw (SALOME::SALOME_Exception)
718 bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
719 SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
722 catch (const std::invalid_argument& ex) {
723 SALOME::ExceptionStruct ExDescription;
724 ExDescription.text = ex.what();
725 ExDescription.type = SALOME::BAD_PARAM;
726 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
727 ExDescription.lineNumber = 625;
728 throw SALOME::SALOME_Exception(ExDescription);
730 catch (SALOME_Exception& ex) {
731 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
735 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
736 throw (SALOME::SALOME_Exception)
740 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
741 MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
742 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
745 string theVertexEntry = theVertex->GetStudyEntry();
746 if (theVertexEntry.empty()) {
747 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
748 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
750 if (theVertex->GetShapeType() == GEOM::VERTEX)
752 if (theVertex->GetShapeType() == GEOM::COMPOUND)
754 aName += theVertex->GetEntry();
755 SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
756 if (!theSVertex->_is_nil())
757 theVertexEntry = theSVertex->GetID();
759 if (theVertexEntry.empty())
760 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
763 bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
764 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
767 catch (const std::invalid_argument& ex) {
768 SALOME::ExceptionStruct ExDescription;
769 ExDescription.text = ex.what();
770 ExDescription.type = SALOME::BAD_PARAM;
771 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
772 ExDescription.lineNumber = 648;
773 throw SALOME::SALOME_Exception(ExDescription);
775 catch (SALOME_Exception& ex) {
776 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
780 //=======================================================================
781 //function : ClearEnforcedVertices
782 //=======================================================================
784 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
787 this->GetImpl()->ClearEnforcedVertices();
788 SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
791 //=======================================================================
792 //function : ClearEnforcedMeshes
793 //=======================================================================
795 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
798 this->GetImpl()->ClearEnforcedMeshes();
799 SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
802 //=======================================================================
803 //function : GetEnforcedMeshes
804 //=======================================================================
806 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
809 GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
811 const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
812 result->length( enfMeshList.size() );
814 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
816 for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
817 ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
818 GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
820 enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
822 enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
824 enfMesh->elementType = currentMesh->elementType;
826 enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
831 // SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
833 return result._retn();
837 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
839 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
840 throw (SALOME::SALOME_Exception)
842 #if GHS3D_VERSION >= 42
843 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
845 SALOME::ExceptionStruct ExDescription;
846 ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
847 ExDescription.type = SALOME::BAD_PARAM;
848 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
849 ExDescription.lineNumber = 719;
850 throw SALOME::SALOME_Exception(ExDescription);
855 * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
857 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
858 throw (SALOME::SALOME_Exception)
860 // MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
861 #if GHS3D_VERSION >= 42
862 return p_SetEnforcedMesh(theSource, theType);
864 SALOME::ExceptionStruct ExDescription;
865 ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
866 ExDescription.type = SALOME::BAD_PARAM;
867 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
868 ExDescription.lineNumber = 750;
869 throw SALOME::SALOME_Exception(ExDescription);
874 * \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.
876 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
877 throw (SALOME::SALOME_Exception)
879 #if GHS3D_VERSION >= 42
880 return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
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.
894 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
895 throw (SALOME::SALOME_Exception)
897 #if GHS3D_VERSION >= 42
898 return p_SetEnforcedMesh(theSource, theType);
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);
909 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
910 throw (SALOME::SALOME_Exception)
912 MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
915 if (CORBA::is_nil( theSource ))
917 SALOME::ExceptionStruct ExDescription;
918 ExDescription.text = "The source mesh CORBA object is NULL";
919 ExDescription.type = SALOME::BAD_PARAM;
920 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
921 ExDescription.lineNumber = 840;
922 throw SALOME::SALOME_Exception(ExDescription);
927 MESSAGE("Required type is NODE");
930 MESSAGE("Required type is EDGE");
933 MESSAGE("Required type is FACE");
936 MESSAGE("Incompatible required type: " << theType);
939 // MESSAGE("Required type is "<<theType);
940 SMESH::array_of_ElementType_var types = theSource->GetTypes();
941 MESSAGE("Available types:");
942 for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
943 if ( types->length() >= 1 && types[types->length()-1] < theType)
945 MESSAGE("Required type not available");
947 // SALOME::ExceptionStruct ExDescription;
948 // ExDescription.text = "The source mesh has bad type";
949 // ExDescription.type = SALOME::BAD_PARAM;
950 // ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
951 // ExDescription.lineNumber = 840;
952 // throw SALOME::SALOME_Exception(ExDescription);
956 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
957 SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
959 SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
960 SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
961 SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
963 string enfMeshName = theName;
964 if (enfMeshName.empty())
965 enfMeshName = SObj->GetName();
970 bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
971 if (theGroupName != "") {
972 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
973 << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
976 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
977 << theSource << ".GetMesh(), " << theType << " )";
982 catch (const std::invalid_argument& ex) {
983 SALOME::ExceptionStruct ExDescription;
984 ExDescription.text = ex.what();
985 ExDescription.type = SALOME::BAD_PARAM;
986 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
987 ExDescription.lineNumber = 840;
988 throw SALOME::SALOME_Exception(ExDescription);
990 catch (SALOME_Exception& ex) {
991 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
994 else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
996 MESSAGE("The source is a group")
998 bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
999 if (theGroupName != "") {
1000 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1001 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1004 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1005 << theSource << ", " << theType << " )";
1009 catch (const std::invalid_argument& ex) {
1010 SALOME::ExceptionStruct ExDescription;
1011 ExDescription.text = ex.what();
1012 ExDescription.type = SALOME::BAD_PARAM;
1013 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1014 ExDescription.lineNumber = 840;
1015 throw SALOME::SALOME_Exception(ExDescription);
1017 catch (SALOME_Exception& ex) {
1018 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1021 else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1023 MESSAGE("The source is a group on geom")
1025 bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1026 if (theGroupName != "") {
1027 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1028 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1031 SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1032 << theSource << ", " << theType << " )";
1036 catch (const std::invalid_argument& ex) {
1037 SALOME::ExceptionStruct ExDescription;
1038 ExDescription.text = ex.what();
1039 ExDescription.type = SALOME::BAD_PARAM;
1040 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1041 ExDescription.lineNumber = 840;
1042 throw SALOME::SALOME_Exception(ExDescription);
1044 catch (SALOME_Exception& ex) {
1045 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1050 //=============================================================================
1052 * Get implementation
1054 //=============================================================================
1056 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1058 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1061 //================================================================================
1063 * \brief Verify whether hypothesis supports given entity type
1065 //================================================================================
1067 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1069 return type == SMESH::DIM_3D;