From: rnv Date: Fri, 9 Jun 2017 10:57:57 +0000 (+0300) Subject: Merge multi-study removal branch. X-Git-Tag: Before_python3_27062017 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a4ddaa3e853fe240d166df56c6b3a6149a537e3;p=plugins%2Fblsurfplugin.git Merge multi-study removal branch. --- 1a4ddaa3e853fe240d166df56c6b3a6149a537e3 diff --cc src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 82da99f,434b732..cf6f1f6 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@@ -241,30 -238,20 +241,22 @@@ bool HasSizeMapOnVertex=false */ //============================================================================= -BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen) +BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, - int studyId, + SMESH_Gen* gen, + bool theHasGEOM) - : SMESH_2D_Algo(hypId, studyId, gen) + : SMESH_2D_Algo(hypId, gen) { - MESSAGE("BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF"); - - _name = "MG-CADSurf";//"BLSURF"; + _name = theHasGEOM ? "MG-CADSurf" : "MG-CADSurf_NOGEOM";//"BLSURF"; _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type - _compatibleHypothesis.push_back(BLSURFPlugin_Hypothesis::GetHypType()); - _compatibleHypothesis.push_back(StdMeshers_ViscousLayers2D::GetHypType()); + _compatibleHypothesis.push_back(BLSURFPlugin_Hypothesis::GetHypType(theHasGEOM)); + if ( theHasGEOM ) + _compatibleHypothesis.push_back(StdMeshers_ViscousLayers2D::GetHypType()); _requireDiscreteBoundary = false; _onlyUnaryInput = false; _hypothesis = NULL; _supportSubmeshes = true; + _requireShape = theHasGEOM; - smeshGen_i = SMESH_Gen_i::GetSMESHGen(); - CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager"); - SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); - - myStudy = NULL; - myStudy = aStudyMgr->GetStudyByID(_studyId); - /* Initialize the Python interpreter */ assert(Py_IsInitialized()); PyGILState_STATE gstate; @@@ -503,19 -430,17 +495,16 @@@ projectionPoint getProjectionPoint(Topo ///////////////////////////////////////////////////////// TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) { - TopoDS_Shape S; - if ( !entry.empty() ) - { - GEOM::GEOM_Object_var aGeomObj; - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() ); - if (!aSObj->_is_nil()) { - CORBA::Object_var obj = aSObj->GetObject(); - aGeomObj = GEOM::GEOM_Object::_narrow(obj); - aSObj->UnRegister(); - } - if ( !aGeomObj->_is_nil() ) - S = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); - MESSAGE("BLSURFPlugin_BLSURF::entryToShape "<FindObjectID( entry.c_str() ); + if (!aSObj->_is_nil()) { + CORBA::Object_var obj = aSObj->GetObject(); + aGeomObj = GEOM::GEOM_Object::_narrow(obj); + aSObj->UnRegister(); } + if ( !aGeomObj->_is_nil() ) + S = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aGeomObj.in() ); return S; } diff --cc src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 60c5e29,e87d33e..14ff95f --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@@ -75,7 -75,7 +75,7 @@@ class TopoDS_Shape class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { public: - BLSURFPlugin_BLSURF(int hypId, int studyId, SMESH_Gen* gen, bool theHasGEOM); - BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen); ++ BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen, bool theHasGEOM); virtual ~BLSURFPlugin_BLSURF(); @@@ -158,9 -157,7 +158,7 @@@ private: PyObject * main_mod; PyObject * main_dict; - SMESH_Mesh* myMesh; + SMESH_MesherHelper* myHelper; - SALOMEDS::Study_var myStudy; - SMESH_Gen_i* smeshGen_i; volatile bool _compute_canceled; }; diff --cc src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx index 947bf71,b223515..ea8a9f9 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx @@@ -37,18 -37,15 +37,16 @@@ //============================================================================= BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) + ::SMESH_Gen* theGenImpl, + bool theHasGEOM ) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ), SMESH_Algo_i( thePOA ), SMESH_2D_Algo_i( thePOA ) { - MESSAGE( "BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i" ); myBaseImpl = new ::BLSURFPlugin_BLSURF( theGenImpl->GetANewId(), - theStudyId, - theGenImpl ); + theGenImpl, + theHasGEOM); } //============================================================================= diff --cc src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx index 1b3b30d,3d382ee..8c1d570 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx @@@ -41,9 -41,7 +41,8 @@@ class BLSURFPlugin_BLSURF_i public: // Constructor BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ); + ::SMESH_Gen* theGenImpl, + bool theHasGEOM); // Destructor virtual ~BLSURFPlugin_BLSURF_i(); diff --cc src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index d567f50,12d12bf..0d8d9f9 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@@ -49,8 -49,8 +49,8 @@@ namespac } //============================================================================= - BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen, bool hasgeom) : - SMESH_Hypothesis(hypId, studyId, gen), -BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen) : - SMESH_Hypothesis(hypId, gen), ++BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom) : ++ SMESH_Hypothesis(hypId, gen), _physicalMesh(GetDefaultPhysicalMesh()), _geometricMesh(GetDefaultGeometricMesh()), _phySize(GetDefaultPhySize()), @@@ -255,12 -244,11 +255,10 @@@ TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry) { - MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<GetCurrentStudy(); TopoDS_Shape S = TopoDS_Shape(); - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() ); + SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() ); if (!aSObj->_is_nil() ) { CORBA::Object_var obj = aSObj->GetObject(); aGeomObj = GEOM::GEOM_Object::_narrow(obj); diff --cc src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 1531872,1d8c200..4153e56 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@@ -43,7 -43,7 +43,7 @@@ class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis { public: - BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen, bool hasgeom); - BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen); ++ BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom); enum Topology { FromCAD, @@@ -243,7 -231,7 +243,7 @@@ */ typedef std::multimap< std::string, BLSURFPlugin_Attractor* > TAttractorMap; -- typedef std::map< std::string, std::vector > TParamsMap; //TODO à finir ++ typedef std::map< std::string, std::vector > TParamsMap; //TODO ?? finir void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius); std::string GetClassAttractorEntry(const std::string& entry); diff --cc src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 3eef21b,8939ad5..a9d96cf --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@@ -47,15 -47,10 +47,14 @@@ using namespace std */ //============================================================================= BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl) : - SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA) { - MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" ); - myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(), theGenImpl); + ::SMESH_Gen* theGenImpl, + bool theHasGEOM) : + SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA) +{ + myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(), - theStudyId, ++ + theGenImpl, + theHasGEOM); } //============================================================================= @@@ -1759,7 -1753,7 +1758,7 @@@ void BLSURFPlugin_Hypothesis_i::SetAttr //============================================================================= --void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius) //TODO à finir ++void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius) //TODO ?? finir throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); @@@ -1822,7 -1818,7 +1821,7 @@@ char* BLSURFPlugin_Hypothesis_i::GetAtt // //============================================================================= // --// // TODO coder cette fonction (utilisée pour savoir si la valeur a changé ++// // TODO coder cette fonction (utilis??e pour savoir si la valeur a chang?? // // A finir pour le dump // char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry) // throw (SALOME::SALOME_Exception) @@@ -2903,197 -2969,13 +2889,197 @@@ bool BLSURFPlugin_Hypothesis_i::UnsetEn } /*! - * Set/get/unset an enforced vertex on geom object given by entry + * Set/get/unset an enforced vertex on face - NEW (no face) + */ +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + try { + return SetEnforcedVertexEntry("", x, y, z); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set/get/unset an enforced vertex with name on face + */ +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName) throw (SALOME::SALOME_Exception) +{ + try { + return SetEnforcedVertexEntry("", x, y, z, theVertexName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set/get/unset an enforced vertex with geom object on face + */ +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) +{ + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); - SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); ++ SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + string theVertexName = theVertex->GetName(); + try { + return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str()); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set an enforced vertex with group name on face + */ +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + try { + return SetEnforcedVertexEntry("", x, y, z, "", "", theGroupName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set an enforced vertex with name and group name on face */ -bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, - CORBA::Double z, const char* theVertexName, const char* theVertexEntry, const char* theGroupName) - throw (SALOME::SALOME_Exception) { +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexName, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ ASSERT(myBaseImpl); - MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")"); + + try { + return SetEnforcedVertexEntry("", x, y, z, theVertexName, "", theGroupName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set an enforced vertex with geom entry and group name on face + */ +bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); - SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); ++ SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + string theVertexName = theVertex->GetName(); + try { + return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) +{ + try { + return UnsetEnforcedVertexEntry("", x, y, z); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) +{ + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + std::string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); - SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); ++ SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + try { + return UnsetEnforcedVertexEntry("", 0, 0, 0, theVertexEntry.c_str()); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertices() throw (SALOME::SALOME_Exception) +{ + try { + return UnsetEnforcedVerticesEntry(""); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set/get/unset an enforced vertex on geom object given by entry + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, + CORBA::Double x, + CORBA::Double y, + CORBA::Double z, + const char* theVertexName, + const char* theVertexEntry, + const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ bool newValue = false; if (string(theVertexEntry).empty()) { try { @@@ -3307,50 -3246,99 +3293,50 @@@ char* BLSURFPlugin_Hypothesis_i::GetInt /* * Enable internal enforced vertices on specific face if requested by user * -void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices) + void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices) throw (SALOME::SALOME_Exception) -{ - MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFace"); - try { - SetInternalEnforcedVertexWithGroup(theFace, toEnforceInternalVertices); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } -} + { + try { + SetInternalEnforcedVertexWithGroup(theFace, toEnforceInternalVertices); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + } -void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName) + void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName) throw (SALOME::SALOME_Exception) -{ - MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFaceWithGroup"); - - if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { - MESSAGE("theFace shape type is not FACE or COMPOUND"); - THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); - } - - string theFaceEntry = theFace->GetStudyEntry(); - - if (theFaceEntry.empty()) { - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - string aName; - if (theFace->GetShapeType() == GEOM::FACE) - aName = "Face_"; - if (theFace->GetShapeType() == GEOM::COMPOUND) - aName = "Compound_"; - aName += theFace->GetEntry(); - SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str()); - if (!theSFace->_is_nil()) - theFaceEntry = theSFace->GetID(); - } - if (theFaceEntry.empty()) - THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); - - MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : GetInternalEnforcedVertexEntry ( "<< theFaceEntry << ")"); - try { - SetInternalEnforcedVertexEntry(theFaceEntry.c_str(), toEnforceInternalVertices, theGroupName); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } -} + { -void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexEntry(const char* theFaceEntry, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFaceEntry"); - ASSERT(myBaseImpl); - try { - this->GetImpl()->SetInternalEnforcedVertex(theFaceEntry, toEnforceInternalVertices, theGroupName); - std::string theValueStr = toEnforceInternalVertices ? "True" : "False"; - if (string(theGroupName).empty()) - SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertex( " << theFaceEntry << ", " << theValueStr.c_str() << " )"; - else - SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexWithGroup( " << theFaceEntry << ", " << theValueStr.c_str() << ", \"" << theGroupName << "\" )"; - } catch (const std::exception& ex) { - std::cout << "Exception: " << ex.what() << std::endl; - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } -} + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } -*/ + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); - SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); ++ SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); -/* TODO GROUPS - char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) - { - ASSERT(myBaseImpl); - MESSAGE("ENGINE : GetEnforcedVertexGroupName START "); try { - return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str()); - } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)"; - ExDescription.lineNumber = 1146; - throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + SetInternalEnforcedVertexEntry(theFaceEntry.c_str(), toEnforceInternalVertices, theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - MESSAGE("ENGINE : GetEnforcedVertexGroupName END "); - return 0; } - - void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) + void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexEntry(const char* theFaceEntry, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); diff --cc src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index aceec48,3e19cd4..020299e --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@@ -37,16 -37,11 +37,15 @@@ class GEOM_Object // BLSURFPlugin parameters hypothesis -class BLSURFPlugin_Hypothesis_i: public virtual POA_BLSURFPlugin::BLSURFPlugin_Hypothesis, - public virtual SMESH_Hypothesis_i { +class BLSURFPlugin_Hypothesis_i: + public virtual POA_BLSURFPlugin::BLSURFPlugin_Hypothesis, + public virtual SMESH_Hypothesis_i +{ public: // Constructor - BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, ::SMESH_Gen* theGenImpl); + BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, - int theStudyId, + ::SMESH_Gen* theGenImpl, + bool theHasGEOM); // Destructor virtual ~BLSURFPlugin_Hypothesis_i(); diff --cc src/BLSURFPlugin/BLSURFPlugin_i.cxx index 9cefe5c,f357ebd..9d0296c --- a/src/BLSURFPlugin/BLSURFPlugin_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_i.cxx @@@ -37,17 -37,8 +37,16 @@@ #include "BLSURFPlugin_BLSURF_i.hxx" #include "BLSURFPlugin_Hypothesis_i.hxx" -template class BLSURFPlugin_Creator_i:public HypothesisCreator_i +template +class BLSURFPlugin_Creator_i : public GenericHypothesisCreator_i { + // Create a hypothesis + virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA, - int theStudyId, + ::SMESH_Gen* theGenImpl) + { - return new T (thePOA, theStudyId, theGenImpl, !NOGEOM); ++ return new T (thePOA, theGenImpl, !NOGEOM); + } + // as we have 'module BLSURFPlugin' in BLSURFPlugin_Algorithm.idl virtual std::string GetModuleName() { return "BLSURFPlugin"; } }; diff --cc tests/test_enforced_vertex.py index a96de40,395c75a..1f5470b --- a/tests/test_enforced_vertex.py +++ b/tests/test_enforced_vertex.py @@@ -5,8 -5,10 +5,8 @@@ import mat import GEOM from salome.geom import geomBuilder - geompy = geomBuilder.New(salome.myStudy) + geompy = geomBuilder.New() -r = 10 -dist = 10 dist_coin = 10.1 p1 = geompy.MakeVertex(0., 0., 0.) @@@ -51,21 -38,15 +51,22 @@@ algo2d.SetAngleMesh( 4 algo2d.SetPhySize( 8 ) algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin) +algo2d.AddEnforcedVertexGeom( pp ) +algo2d.AddEnforcedVertexGeom( p6 ) +algo2d.AddEnforcedVertex( *xyz7 ) -Mesh.Compute() +assert Mesh.Compute() +assert not Mesh.FindCoincidentNodes( 1e-7 ) -id_node = Mesh.FindNodeClosestTo(dist_coin, 0, dist_coin) +for x,y,z in allEnforcedCoords: -x, y, z = Mesh.GetNodeXYZ(id_node) + id_node = Mesh.FindNodeClosestTo( x,y,z ) + xn, yn, zn = Mesh.GetNodeXYZ( id_node ) -assert("%.2f, %.2f, %.2f"%(x, y, z) == "%.2f, %.2f, %.2f"%(dist_coin, 0, dist_coin)) + # compare X and Z + assert "%.2f, %.2f"%(x, z) == "%.2f, %.2f"%( xn, zn ), \ + "%.2f, %.2f, %.2f != %.2f, %.2f, %.2f"%( xn, yn, zn, x,y,z ) - salome.sg.updateObjBrowser(True) + salome.sg.updateObjBrowser() +