From d6b7cb735f99cfc9d68fd3a44c0d4c456017f384 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 7 Nov 2014 18:07:13 +0300 Subject: [PATCH] Mesh edit dlg bug: algos are not filtered by shape at mesh edition More bug: "Belong to geom" filter does not find nodes bound to SOLID --- src/Controls/SMESH_Controls.cxx | 37 ++++++++++++++--------- src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx | 20 +++++++----- src/SMESHGUI/SMESHGUI_GEOMGenUtils.h | 2 +- src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx | 4 +++ src/SMESHGUI/SMESHGUI_MeshOp.cxx | 9 +++--- 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index dcb5d7b1a..6311da713 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -4251,11 +4251,11 @@ void BelongToGeom::init() myIsSubshape = IsSubShape(aMap, myShape); } - if (!myIsSubshape) + //if (!myIsSubshape) // to be always ready to check an element not bound to geometry { myElementsOnShapePtr.reset(new ElementsOnShape()); myElementsOnShapePtr->SetTolerance(myTolerance); - myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on" + myElementsOnShapePtr->SetAllNodes(true); // "belong", while false means "lays on" myElementsOnShapePtr->SetMesh(myMeshDS); myElementsOnShapePtr->SetShape(myShape, myType); } @@ -4296,36 +4296,43 @@ bool BelongToGeom::IsSatisfy (long theId) { if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) ) { + if ( aNode->getshapeId() < 1 ) + return myElementsOnShapePtr->IsSatisfy(theId); + const SMDS_PositionPtr& aPosition = aNode->GetPosition(); SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition(); switch( aTypeOfPosition ) { - case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX ); - case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE ); - case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE ); - case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL ); + case SMDS_TOP_VERTEX : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX )); + case SMDS_TOP_EDGE : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE )); + case SMDS_TOP_FACE : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_FACE )); + case SMDS_TOP_3DSPACE: return ( IsContains( myMeshDS,myShape,aNode,TopAbs_SOLID ) || + IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL )); } } } else { - if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) ) + if ( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId )) { + if ( anElem->getshapeId() < 1 ) + return myElementsOnShapePtr->IsSatisfy(theId); + if( myType == SMDSAbs_All ) { - return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) || - IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) || - IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| - IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID ); + return ( IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) || + IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) || + IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID )|| + IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )); } else if( myType == anElem->GetType() ) { switch( myType ) { - case SMDSAbs_Edge : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ); - case SMDSAbs_Face : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ); - case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| - IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID ); + case SMDSAbs_Edge : return ( IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE )); + case SMDSAbs_Face : return ( IsContains( myMeshDS,myShape,anElem,TopAbs_FACE )); + case SMDSAbs_Volume: return ( IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID )|| + IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )); } } } diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx index 88b181944..5453a6a1b 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -82,20 +82,25 @@ namespace SMESH return GEOM::GEOM_Object::_nil(); } - GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO) + GEOM::GEOM_Object_var GetGeom (_PTR(SObject) theSO) { + GEOM::GEOM_Object_var aMeshShape; if (!theSO) - return GEOM::GEOM_Object::_nil(); + return aMeshShape; + + CORBA::Object_var obj = _CAST( SObject,theSO )->GetObject(); + aMeshShape = GEOM::GEOM_Object::_narrow( obj ); + if ( !aMeshShape->_is_nil() ) + return aMeshShape; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); if (!aStudy) - return GEOM::GEOM_Object::_nil(); + return aMeshShape; _PTR(ChildIterator) anIter (aStudy->NewChildIterator(theSO)); for ( ; anIter->More(); anIter->Next()) { _PTR(SObject) aSObject = anIter->Value(); _PTR(SObject) aRefSOClient; - GEOM::GEOM_Object_var aMeshShape; if (aSObject->ReferencedObject(aRefSOClient)) { SALOMEDS_SObject* aRefSO = _CAST(SObject,aRefSOClient); @@ -104,11 +109,10 @@ namespace SMESH SALOMEDS_SObject* aSO = _CAST(SObject,aSObject); aMeshShape = GEOM::GEOM_Object::_narrow(aSO->GetObject()); } - - if (!aMeshShape->_is_nil()) - return aMeshShape._retn(); + if ( !aMeshShape->_is_nil() ) + return aMeshShape; } - return GEOM::GEOM_Object::_nil(); + return aMeshShape; } SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ) diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h index f9cdeafd4..0aa10bd7a 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -47,7 +47,7 @@ namespace SMESH SMESHGUI_EXPORT GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh( _PTR(SObject), bool* isMesh=0 ); - SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetGeom( _PTR(SObject) ); + SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) ); SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ); diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index dc499bd73..fa29da180 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -511,10 +511,14 @@ namespace SMESH return SMESH::SMESH_Hypothesis::_nil(); } + bool IsApplicable(const QString& aHypType, GEOM::GEOM_Object_ptr theGeomObject, const bool toCheckAll) { + if ( getenv("NO_LIMIT_ALGO_BY_SHAPE")) // allow a workaround for a case if + return true; // IsApplicable() returns false due to a bug + HypothesisData* aHypData = GetHypothesisData(aHypType); QString aServLib = aHypData->ServerLibName; return SMESHGUI::GetSMESHGen()->IsApplicable( aHypType.toLatin1().data(), diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 151328f9b..5f7f27ace 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -247,8 +247,9 @@ void SMESHGUI_MeshOp::startOperation() myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh ); } else + { myDlg->activateObject( SMESHGUI_MeshDlg::Obj ); - + } myDlg->setCurrentTab( SMESH::DIM_3D ); QStringList TypeMeshList; @@ -2614,11 +2615,11 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI bool toCheckIsApplicableToAll = !myIsMesh; GEOM::GEOM_Object_var aGeomVar; - QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom ); + QString anEntry = + myDlg->selectedObject( myToCreate ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Obj ); if ( _PTR(SObject) so = studyDS()->FindObjectID( anEntry.toLatin1().data() )) { - CORBA::Object_var obj = _CAST( SObject,so )->GetObject(); - aGeomVar = GEOM::GEOM_Object::_narrow( obj ); + aGeomVar = SMESH::GetGeom( so ); if ( !aGeomVar->_is_nil() && toCheckIsApplicableToAll ) toCheckIsApplicableToAll = ( aGeomVar->GetType() == GEOM_GROUP ); } -- 2.39.2