From 7987c4ba1a66850a3043b37287ebdcd37c7fbcc3 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 12 Feb 2013 14:45:52 +0000 Subject: [PATCH] Merge from V6_main 11/02/2013 --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 183 ++++++++++++------ src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 10 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 9 +- .../BLSURFPlugin_Hypothesis_i.cxx | 61 +++--- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 19 +- 5 files changed, 173 insertions(+), 109 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 01cc508..fa3e87f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -443,13 +443,10 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) GEOM::GEOM_Object_var aGeomObj; TopoDS_Shape S = TopoDS_Shape(); SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() ); - SALOMEDS::GenericAttribute_var anAttr; - - if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal); + 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() ); @@ -700,7 +697,7 @@ void BLSURFPlugin_BLSURF::SetParameters( const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t * css, precad_session_t * pcs, - SMESH_Mesh& mesh, + const TopoDS_Shape& GeomShape, bool * use_precad ) { @@ -708,7 +705,7 @@ void BLSURFPlugin_BLSURF::SetParameters( // Clear map so that it is not stored in the algorithm with old enforced vertices in it EnfVertexCoords2EnfVertexList.clear(); - double diagonal = mesh.GetShapeDiagonalSize(); + double diagonal = SMESH_Mesh::GetShapeDiagonalSize( GeomShape ); double bbSegmentation = _gen->GetBoundaryBoxSegmentation(); int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh(); int _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh(); @@ -743,17 +740,23 @@ void BLSURFPlugin_BLSURF::SetParameters( MESSAGE("BLSURFPlugin_BLSURF::SetParameters"); _physicalMesh = (int) hyp->GetPhysicalMesh(); _geometricMesh = (int) hyp->GetGeometricMesh(); - if (hyp->GetPhySize() > 0) - _phySize = hyp->GetPhySize(); - _phySizeRel = hyp->IsPhySizeRel(); - if (hyp->GetMinSize() > 0) - _minSize = hyp->GetMinSize(); - _minSizeRel = hyp->IsMinSizeRel(); - if (hyp->GetMaxSize() > 0) - _maxSize = hyp->GetMaxSize(); - _maxSizeRel = hyp->IsMaxSizeRel(); - if (hyp->GetGradation() > 0) - _gradation = hyp->GetGradation(); + if (hyp->GetPhySize() > 0) { + _phySize = hyp->GetPhySize(); + // if user size is not explicitly specified, "relative" flag is ignored + _phySizeRel = hyp->IsPhySizeRel(); + } + if (hyp->GetMinSize() > 0) { + _minSize = hyp->GetMinSize(); + // if min size is not explicitly specified, "relative" flag is ignored + _minSizeRel = hyp->IsMinSizeRel(); + } + if (hyp->GetMaxSize() > 0) { + _maxSize = hyp->GetMaxSize(); + // if max size is not explicitly specified, "relative" flag is ignored + _maxSizeRel = hyp->IsMaxSizeRel(); + } + if (hyp->GetGradation() > 0) + _gradation = hyp->GetGradation(); _quadAllowed = hyp->GetQuadAllowed(); if (hyp->GetAngleMesh() > 0) _angleMesh = hyp->GetAngleMesh(); @@ -782,7 +785,7 @@ void BLSURFPlugin_BLSURF::SetParameters( for ( opIt = opts.begin(); opIt != opts.end(); ++opIt ) if ( !opIt->second.empty() ) { MESSAGE("cadsurf_set_param(): " << opIt->first << " = " << opIt->second); - cadsurf_set_param(css, opIt->first.c_str(), opIt->second.c_str()); + set_param(css, opIt->first.c_str(), opIt->second.c_str()); } const BLSURFPlugin_Hypothesis::TOptionValues & preCADopts = hyp->GetPreCADOptionValues(); @@ -819,58 +822,83 @@ void BLSURFPlugin_BLSURF::SetParameters( switch (_physicalMesh) { case BLSURFPlugin_Hypothesis::PhysicalGlobalSize: - cadsurf_set_param(css, "physical_size_mode", "global"); - cadsurf_set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); + set_param(css, "physical_size_mode", "global"); + set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); break; case BLSURFPlugin_Hypothesis::PhysicalLocalSize: - cadsurf_set_param(css, "physical_size_mode", "local"); - cadsurf_set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); + set_param(css, "physical_size_mode", "local"); + set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); useGradation = true; break; default: - cadsurf_set_param(css, "physical_size_mode", "none"); + set_param(css, "physical_size_mode", "none"); } switch (_geometricMesh) { case BLSURFPlugin_Hypothesis::GeometricalGlobalSize: - cadsurf_set_param(css, "geometric_size_mode", "global"); - cadsurf_set_param(css, "geometric_approximation", to_string(_angleMesh).c_str()); - cadsurf_set_param(css, "chordal_error", to_string(_chordalError).c_str()); + set_param(css, "geometric_size_mode", "global"); + set_param(css, "geometric_approximation", to_string(_angleMesh).c_str()); + set_param(css, "chordal_error", to_string(_chordalError).c_str()); useGradation = true; break; case BLSURFPlugin_Hypothesis::GeometricalLocalSize: - cadsurf_set_param(css, "geometric_size_mode", "local"); - cadsurf_set_param(css, "geometric_approximation", to_string(_angleMesh).c_str()); - cadsurf_set_param(css, "chordal_error", to_string(_chordalError).c_str()); + set_param(css, "geometric_size_mode", "local"); + set_param(css, "geometric_approximation", to_string(_angleMesh).c_str()); + set_param(css, "chordal_error", to_string(_chordalError).c_str()); useGradation = true; break; default: - cadsurf_set_param(css, "geometric_size_mode", "none"); + set_param(css, "geometric_size_mode", "none"); } - cadsurf_set_param(css, "minsize", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str()); - cadsurf_set_param(css, "maxsize", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str()); - if ( useGradation ) - cadsurf_set_param(css, "gradation", to_string(_gradation).c_str()); - cadsurf_set_param(css, "element_generation", _quadAllowed ? "quad_dominant" : "triangle"); + if ( hyp && hyp->GetPhySize() > 0 ) { + // user size is explicitly specified via hypothesis parameters + // min and max sizes should be compared with explicitly specified user size + // - compute absolute min size + double mins = _minSizeRel ? _minSize * diagonal : _minSize; + // - min size should not be greater than user size + if ( _phySize < mins ) + set_param(css, "min_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); + else + set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str()); + // - compute absolute max size + double maxs = _maxSizeRel ? _maxSize * diagonal : _maxSize; + // - max size should not be less than user size + if ( _phySize > maxs ) + set_param(css, "max_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str()); + else + set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str()); + } + else { + // user size is not explicitly specified + // - if minsize is not explicitly specified, we pass default value computed automatically, in this case "relative" flag is ignored + set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str()); + // - if maxsize is not explicitly specified, we pass default value computed automatically, in this case "relative" flag is ignored + set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str()); + } + + if ( useGradation ) + set_param(css, "gradation", to_string(_gradation).c_str()); + set_param(css, "element_generation", _quadAllowed ? "quad_dominant" : "triangle"); - cadsurf_set_param(css, "metric", _anisotropic ? "anisotropic" : "isotropic"); + set_param(css, "metric", _anisotropic ? "anisotropic" : "isotropic"); if ( _anisotropic ) - cadsurf_set_param(css, "anisotropic_ratio", to_string(_anisotropicRatio).c_str()); - cadsurf_set_param(css, "remove_tiny_edges", _removeTinyEdges ? "1" : "0"); + set_param(css, "anisotropic_ratio", to_string(_anisotropicRatio).c_str()); + set_param(css, "remove_tiny_edges", _removeTinyEdges ? "1" : "0"); if ( _removeTinyEdges ) - cadsurf_set_param(css, "tiny_edge_length", to_string(_tinyEdgeLength).c_str()); - cadsurf_set_param(css, "force_bad_surface_element_removal", _badElementRemoval ? "1" : "0"); + set_param(css, "tiny_edge_length", to_string(_tinyEdgeLength).c_str()); + set_param(css, "force_bad_surface_element_removal", _badElementRemoval ? "1" : "0"); if ( _badElementRemoval ) - cadsurf_set_param(css, "bad_surface_element_aspect_ratio", to_string(_badElementAspectRatio).c_str()); - cadsurf_set_param(css, "optimisation", _optimizeMesh ? "yes" : "no"); - cadsurf_set_param(css, "element_order", _quadraticMesh ? "quadratic" : "linear"); - cadsurf_set_param(css, "verbose", to_string(_verb).c_str()); + set_param(css, "bad_surface_element_aspect_ratio", to_string(_badElementAspectRatio).c_str()); + set_param(css, "optimisation", _optimizeMesh ? "yes" : "no"); + set_param(css, "element_order", _quadraticMesh ? "quadratic" : "linear"); + set_param(css, "verbose", to_string(_verb).c_str()); _smp_phy_size = _phySizeRel ? _phySize*diagonal : _phySize; - std::cout << "_smp_phy_size = " << _smp_phy_size << std::endl; + if ( _verb > 0 ) + std::cout << "_smp_phy_size = " << _smp_phy_size << std::endl; if (_physicalMesh == BLSURFPlugin_Hypothesis::PhysicalLocalSize){ TopoDS_Shape GeomShape; @@ -1110,7 +1138,6 @@ void BLSURFPlugin_BLSURF::SetParameters( if (useInternalVertexAllFaces) { std::string grpName = BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(hyp); MESSAGE("Setting Internal Enforced Vertices"); - GeomShape = mesh.GetShapeToMesh(); gp_Pnt aPnt; TopExp_Explorer exp (GeomShape, TopAbs_FACE); for (; exp.More(); exp.Next()){ @@ -1173,6 +1200,33 @@ void BLSURFPlugin_BLSURF::SetParameters( } } +//================================================================================ +/*! + * \brief Throws an exception if a parameter name is wrong + */ +//================================================================================ + +void BLSURFPlugin_BLSURF::set_param(cadsurf_session_t *css, + const char * option_name, + const char * option_value) +{ + status_t status = cadsurf_set_param(css, option_name, option_value ); + if ( status != MESHGEMS_STATUS_OK ) + { + if ( status == MESHGEMS_STATUS_UNKNOWN_PARAMETER ) { + throw SALOME_Exception + ( SMESH_Comment("Invalid name of CADSURF parameter: ") << option_name ); + } + else if ( status == MESHGEMS_STATUS_NOLICENSE ) + throw SALOME_Exception + ( "No valid license available" ); + else + throw SALOME_Exception + ( SMESH_Comment("Unacceptable value of CADSURF parameter '") + << option_name << "': " << option_value); + } +} + namespace { // -------------------------------------------------------------------------- @@ -1491,6 +1545,15 @@ namespace } }; + /*! + * \brief A structure holding an error description and a verbisity level + */ + struct message_cb_user_data + { + std::string * _error; + int _verbosity; + }; + } // namespace @@ -1593,13 +1656,15 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, context_t *ctx = context_new(); /* Set the message callback in the working context */ - context_set_message_callback(ctx, message_cb, &_comment); -#ifdef WITH_SMESH_CANCEL_COMPUTE + message_cb_user_data mcud; + mcud._error = & this->SMESH_Algo::_comment; + mcud._verbosity = + _hypothesis ? _hypothesis->GetVerbosity() : BLSURFPlugin_Hypothesis::GetDefaultVerbosity(); + context_set_message_callback(ctx, message_cb, &mcud); + + /* set the interruption callback */ _compute_canceled = false; context_set_interrupt_callback(ctx, interrupt_cb, this); -#else - context_set_interrupt_callback(ctx, interrupt_cb, NULL); -#endif /* create the CAD object we will work on. It is associated to the context ctx. */ cad_t *c = cad_new(ctx); @@ -1636,7 +1701,7 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, // #if BLSURF_VERSION_LONG >= "3.1.1" // c, // #endif - _hypothesis, css, pcs, aMesh, &use_precad); + _hypothesis, css, pcs, aShape, &use_precad); MESSAGE("END SetParameters"); haveQuadraticSubMesh = haveQuadraticSubMesh || (_hypothesis != NULL && _hypothesis->GetQuadraticMesh()); @@ -2761,18 +2826,16 @@ status_t message_cb(message_t *msg, void *user_data) message_get_number(msg, &errnumber); message_get_description(msg, &desc); string err( desc ); + message_cb_user_data * mcud = (message_cb_user_data*)user_data; if ( errnumber < 0 || err.find("license") != string::npos ) { - string * error = (string*)user_data; -// if ( !error->empty() ) -// *error += "\n"; // remove ^A from the tail int len = strlen( desc ); while (len > 0 && desc[len-1] != '\n') len--; - error->append( desc, len ); + mcud->_error->append( desc, len ); } - else { - std::cout << desc << std::endl; + else if ( mcud->_verbosity > 0 ) { + std::cout << desc << std::endl; } return STATUS_OK; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index cbee8ae..fd27670 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -84,14 +84,12 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus); - void SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls, precad_session_t *pcs, SMESH_Mesh& aMesh, bool *use_precad); + void SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls, precad_session_t *pcs, const TopoDS_Shape& shape, bool *use_precad); virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); -#ifdef WITH_SMESH_CANCEL_COMPUTE virtual void CancelCompute(); bool computeCanceled() { return _compute_canceled; } -#endif virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, MapShapeNbElems& aResMap); @@ -104,6 +102,10 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { bool compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + void set_param(cadsurf_session_t *css, + const char * option_name, + const char * option_value); + TopoDS_Shape entryToShape(std::string entry); void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList); void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed); @@ -115,9 +117,7 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { SALOMEDS::Study_var myStudy; SMESH_Gen_i* smeshGen_i; -#ifdef WITH_SMESH_CANCEL_COMPUTE volatile bool _compute_canceled; -#endif }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index ada8a38..ab6e14d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -197,13 +197,10 @@ TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry) TopoDS_Shape S = TopoDS_Shape(); SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() ); - SALOMEDS::GenericAttribute_var anAttr; - - if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal); + 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() ); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 77af19a..1cf2944 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -24,17 +24,20 @@ // --- // #include "BLSURFPlugin_Hypothesis_i.hxx" -#include "SMESH_Gen.hxx" -#include "SMESH_Gen_i.hxx" -#include "SMESH_PythonDump.hxx" -#include "GEOM_Object.hxx" -#include "Utils_CorbaException.hxx" -#include "utilities.h" +#include +#include +#include + +#include + +#include +#include +#include #include #include -#include "boost/regex.hpp" +#include //============================================================================= /*! @@ -176,7 +179,7 @@ CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsPhySizeRel() { //============================================================================= void BLSURFPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize) { ASSERT(myBaseImpl); - if (GetMinSize() != theMinSize) { + if (IsMinSizeRel() || GetMinSize() != theMinSize ) { this->GetImpl()->SetMinSize(theMinSize, false); SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )"; } @@ -185,7 +188,7 @@ void BLSURFPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize) { //============================================================================= void BLSURFPlugin_Hypothesis_i::SetMinSizeRel(CORBA::Double theMinSize) { ASSERT(myBaseImpl); - if ( IsMinSizeRel() && (GetMinSize() != theMinSize) ) { + if ( !IsMinSizeRel() || (GetMinSize() != theMinSize) ) { this->GetImpl()->SetMinSize(theMinSize, true); SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << ", isRelative = True )"; } @@ -207,7 +210,7 @@ CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMinSizeRel() { //============================================================================= void BLSURFPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize) { ASSERT(myBaseImpl); - if (GetMaxSize() != theMaxSize) { + if (IsMaxSizeRel() || GetMaxSize() != theMaxSize) { this->GetImpl()->SetMaxSize(theMaxSize, false); SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )"; } @@ -216,7 +219,7 @@ void BLSURFPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize) { //============================================================================= void BLSURFPlugin_Hypothesis_i::SetMaxSizeRel(CORBA::Double theMaxSize) { ASSERT(myBaseImpl); - if ( IsMaxSizeRel() && (GetMaxSize() != theMaxSize) ) { + if ( !IsMaxSizeRel() || (GetMaxSize() != theMaxSize) ) { this->GetImpl()->SetMaxSize(theMaxSize, true); SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << ", isRelative = True )"; } @@ -1242,7 +1245,7 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr theFace, if (theFaceEntry.empty()) { aName = "Face_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1259,7 +1262,7 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr theFace, if (theAttractor->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theAttractor->GetEntry(); - SALOMEDS::SObject_ptr theSAtt = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theAttractor, aName.c_str()); + SALOMEDS::SObject_wrap theSAtt = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theAttractor, aName.c_str()); if (!theSAtt->_is_nil()) theAttEntry = theSAtt->GetID(); } @@ -1286,7 +1289,7 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace if (theFaceEntry.empty()) { aName = "Face_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1706,7 +1709,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1744,7 +1747,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr the if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1799,7 +1802,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1812,7 +1815,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -1854,7 +1857,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1894,7 +1897,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Objec if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1940,7 +1943,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -1953,7 +1956,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -1995,7 +1998,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object // if (theFace->GetShapeType() == GEOM::COMPOUND) // aName = "Compound_"; // aName += theFace->GetEntry(); -// SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); +// SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); // if (!theSFace->_is_nil()) // theFaceEntry = theSFace->GetID(); // } @@ -2034,7 +2037,7 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEO if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -2070,7 +2073,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFac if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -2121,7 +2124,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -2134,7 +2137,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); } @@ -2169,7 +2172,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theF if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } @@ -2492,7 +2495,7 @@ void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Ob if (theFace->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theFace->GetEntry(); - SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); if (!theSFace->_is_nil()) theFaceEntry = theSFace->GetID(); } diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index daee40e..a4db08b 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -1680,20 +1680,23 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetGeometricMesh( (int) h_data.myGeometricMesh ); if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) { - if ( h->GetPhySize() != h_data.myPhySize ) { + if ( h->GetPhySize() != h_data.myPhySize || + h->IsPhySizeRel() != h_data.myPhySizeRel ) { if ( h_data.myPhySizeRel ) h->SetPhySizeRel( h_data.myPhySize ); else h->SetPhySize( h_data.myPhySize ); } } - if (h->GetMinSize() != h_data.myMinSize) { + if (h->GetMinSize() != h_data.myMinSize || + h->IsMinSizeRel() != h_data.myMinSizeRel ) { if ( h_data.myMinSizeRel ) h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize ); else h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize ); } - if (h->GetMaxSize() != h_data.myMaxSize) { + if (h->GetMaxSize() != h_data.myMaxSize || + h->IsMaxSizeRel() != h_data.myMaxSizeRel ) { if ( h_data.myMaxSizeRel ) h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize ); else @@ -2683,14 +2686,12 @@ LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr() CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry) { SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy(); + SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy(); CORBA::Object_var obj; - SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() ); - if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - obj = myStudy->ConvertIORToObject(aVal); + if (!aSObj->_is_nil()) { + obj = aSObj->GetObject(); + aSObj->UnRegister(); } return obj; } -- 2.39.2