From e28cd63140ca9482eb73918a1d37aebf2c55996e Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 24 Oct 2007 07:05:58 +0000 Subject: [PATCH] Implementation of NPAL13504 improvement. --- resources/StdMeshers.xml | 1 + src/SMESH/SMESH_Gen.cxx | 8 + src/SMESH/SMESH_Mesh.cxx | 6 +- src/SMESH/SMESH_MesherHelper.cxx | 33 +++ src/SMESH/SMESH_MesherHelper.hxx | 8 + src/SMESH/SMESH_subMesh.cxx | 37 ++- src/SMESHGUI/SMESHGUI_ComputeDlg.cxx | 18 +- src/SMESHGUI/SMESHGUI_Hypotheses.h | 7 +- src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx | 57 ++-- src/SMESHGUI/SMESHGUI_HypothesesUtils.h | 3 +- src/SMESHGUI/SMESHGUI_MeshDlg.cxx | 21 ++ src/SMESHGUI/SMESHGUI_MeshDlg.h | 3 + src/SMESHGUI/SMESHGUI_MeshOp.cxx | 308 +++++++++++++--------- src/SMESHGUI/SMESHGUI_MeshOp.h | 1 + src/SMESHGUI/SMESHGUI_Selection.cxx | 21 +- src/SMESHGUI/SMESHGUI_XmlHandler.cxx | 6 +- src/SMESH_I/SMESH_2smeshpy.cxx | 91 ++++++- src/SMESH_I/SMESH_2smeshpy.hxx | 3 + src/SMESH_I/SMESH_Gen_i.cxx | 52 ++-- src/SMESH_I/SMESH_Gen_i_1.cxx | 15 +- src/SMESH_I/SMESH_Mesh_i.cxx | 40 ++- 21 files changed, 534 insertions(+), 205 deletions(-) diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index 70530de01..821cd587b 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -83,6 +83,7 @@ GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) ret = false;; } + if ((algo && !aMesh.HasShapeToMesh())) + { + if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) + smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE ); + + if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) + ret = false;; + } } // ----------------------------------------------- diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index bbc40cd6d..236d400fe 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -214,7 +214,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName) if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<NbEdges() + myMesh->NbFaces(); + + //Quadratic faces and edges + NbQuadFacesAndEdgs = myMesh->NbEdges(ORDER_QUADRATIC) + myMesh->NbFaces(ORDER_QUADRATIC); + + //Linear faces and edges + NbFacesAndEdges = myMesh->NbEdges(ORDER_LINEAR) + myMesh->NbFaces(ORDER_LINEAR); + + if (NbAllEdgsAndFaces == NbQuadFacesAndEdgs) { + //Quadratic mesh + return SMESH_MesherHelper::QUADRATIC; + } + else if (NbAllEdgsAndFaces == NbFacesAndEdges) { + //Linear mesh + return SMESH_MesherHelper::LINEAR; + } + else + //Mesh with both type of elements + return SMESH_MesherHelper::COMP; +} + diff --git a/src/SMESH/SMESH_MesherHelper.hxx b/src/SMESH/SMESH_MesherHelper.hxx index ad3a1e8f8..41544a3f4 100644 --- a/src/SMESH/SMESH_MesherHelper.hxx +++ b/src/SMESH/SMESH_MesherHelper.hxx @@ -306,6 +306,14 @@ public: */ const NLinkNodeMap& GetNLinkNodeMap() const { return myNLinkNodeMap; } + /** + * Check mesh without geometry for: if all elements on this shape are quadratic, + * quadratic elements will be created. + * Used then generated 3D mesh without geometry. + */ + enum MType{ LINEAR, QUADRATIC, COMP }; + MType IsQuadraticMesh(); + protected: /*! diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index ebb96e21d..e47c030bf 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -412,10 +412,12 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() case TopAbs_SOLID: { //MESSAGE("solid"); - for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); + if(_father->HasShapeToMesh()) { + for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } } break; } @@ -496,9 +498,14 @@ const TopoDS_Shape & SMESH_subMesh::GetSubShape() const bool SMESH_subMesh::CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const { int aHypDim = theHypothesis->GetDim(); - int aShapeDim = SMESH_Gen::GetShapeDim(_subShape); - if ( aHypDim <= aShapeDim ) - return true; + if(_father->HasShapeToMesh()) { + int aShapeDim = SMESH_Gen::GetShapeDim(_subShape); + if ( aHypDim <= aShapeDim ) + return true; + } + else + //Only 3D hypothesis may be assigned to the mesh w/o geometry + return aHypDim == 3; // if ( aHypDim < aShapeDim ) // return ( _father->IsMainShape( _subShape )); @@ -601,8 +608,9 @@ SMESH_Hypothesis::Hypothesis_Status // check if a shape needed by algo is present // ------------------------------------------- algo = static_cast< SMESH_Algo* >( anHyp ); - if ( !_father->HasShapeToMesh() && algo->NeedShape() ) - return SMESH_Hypothesis::HYP_BAD_GEOMETRY; + if(_father->GetShapeToMesh() != SMESH_Mesh::PseudoShape()) + if ( !_father->HasShapeToMesh() && algo->NeedShape() ) + return SMESH_Hypothesis::HYP_BAD_GEOMETRY; // ---------------------- // check mesh conformity // ---------------------- @@ -618,6 +626,17 @@ SMESH_Hypothesis::Hypothesis_Status if ( ! CanAddHypothesis( anHyp )) // check dimension return SMESH_Hypothesis::HYP_BAD_DIM; + if(anHyp->GetDim() == 3 && !_father->HasShapeToMesh() + && event == ADD_ALGO) { + //Only NETGEN_3D and GHS3D_3D can be assigned to the Mesh w/o geometryy + bool isNetgen3D = (strcmp( "NETGEN_3D", anHyp->GetName()) == 0); + bool isGhs3d = (strcmp( "GHS3D_3D", anHyp->GetName()) == 0); + if( !isNetgen3D && !isGhs3d) + return SMESH_Hypothesis::HYP_BAD_DIM; + } + + + if ( /*!anHyp->IsAuxiliary() &&*/ GetSimilarAttached( _subShape, anHyp ) ) return SMESH_Hypothesis::HYP_ALREADY_EXIST; diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index 1da473118..a4d8fca51 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -806,7 +806,9 @@ void SMESHGUI_ComputeOp::startOperation() MemoryReserve aMemoryReserve; _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh); myMainShape = aMesh->GetShapeToMesh(); - if ( !myMainShape->_is_nil() && aMeshSObj ) + if ( ((!myMainShape->_is_nil() && aMesh->HasShapeToMesh()) || + (myMainShape->_is_nil() && !aMesh->HasShapeToMesh())) + && aMeshSObj ) { myDlg->myMeshName->setText( aMeshSObj->GetName() ); SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen(); @@ -919,10 +921,20 @@ void SMESHGUI_ComputeOp::startOperation() myDlg->myBriefInfo->show(); myDlg->myFullInfo->hide(); myDlg->myErrorGroup->show(); - + + bool hasShape = aMesh->HasShapeToMesh(); + if ( !hasShape ) + { + myDlg->myPublishBtn->hide(); + myDlg->myShowBtn->hide(); + } + else + { + myDlg->myPublishBtn->show(); + myDlg->myShowBtn->show(); + } // fill table of errors tbl->setNumRows( anErrors->length() ); - bool hasShape = aMesh->HasShapeToMesh(); if ( !hasShape ) tbl->hideColumn( COL_SHAPE ); else tbl->showColumn( COL_SHAPE ); tbl->setColumnWidth( COL_ERROR, 200 ); diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index b411cf7b8..fba15ebd1 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -149,7 +149,8 @@ class HypothesisData const QStringList& theNeededHypos, const QStringList& theOptionalHypos, const QStringList& theInputTypes, - const QStringList& theOutputTypes) + const QStringList& theOutputTypes, + const bool theIsNeedGeometry = true) : TypeName( theTypeName ), PluginName( thePluginName ), ServerLibName( theServerLibName ), @@ -159,7 +160,8 @@ class HypothesisData Dim( theDim ), IsAux( theIsAux ), NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ), - InputTypes( theInputTypes ), OutputTypes( theOutputTypes ) + InputTypes( theInputTypes ), OutputTypes( theOutputTypes ), + IsNeedGeometry( theIsNeedGeometry ) {}; QString TypeName; //!< hypothesis type name @@ -170,6 +172,7 @@ class HypothesisData QString IconId; //!< icon identifier QValueList Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration) bool IsAux; //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise + bool IsNeedGeometry; //!< TRUE if for given hypothesis need shape, FALSE otherwise // for algorithm only: dependencies algo <-> algo and algo -> hypos QStringList NeededHypos; //!< list of obligatory hypotheses diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 4be1a4cbb..119406be5 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -208,21 +208,27 @@ namespace SMESH{ QStringList GetAvailableHypotheses( const bool isAlgo, const int theDim, - const bool isAux ) + const bool isAux, + const bool isNeedGeometry) { QStringList aHypList; // Init list of available hypotheses, if needed InitAvailableHypotheses(); - + bool checkGeometry = !isNeedGeometry; // fill list of hypotheses/algorithms THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap; THypothesisDataMap::iterator anIter; for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ ) { HypothesisData* aData = (*anIter).second; - if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux ) - aHypList.append(((*anIter).first).c_str()); + if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) + if (checkGeometry){ + if (aData->IsNeedGeometry == isNeedGeometry) + aHypList.append(((*anIter).first).c_str()); + } + else + aHypList.append(((*anIter).first).c_str()); } return aHypList; } @@ -533,27 +539,36 @@ namespace SMESH{ if (MorSM) { try { GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); - if (!aShapeObject->_is_nil()) { - SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); - - if (!aSubMesh->_is_nil()) - aMesh = aSubMesh->GetFather(); - - if (!aMesh->_is_nil()) { - res = aMesh->RemoveHypothesis(aShapeObject, anHyp); - if (res < SMESH::HYP_UNKNOWN_FATAL) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); + + if (!aSubMesh->_is_nil()) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) { + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if (res < SMESH::HYP_UNKNOWN_FATAL) { _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); if (meshSO) SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0); } - if (res > SMESH::HYP_OK) { - wc.suspend(); - processHypothesisStatus(res, anHyp, false); - wc.resume(); - } - } - } + + } + else if(!aMesh->HasShapeToMesh()){ + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if (res < SMESH::HYP_UNKNOWN_FATAL) { + _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); + if (meshSO) + SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0); + } + } + if (res > SMESH::HYP_OK) { + wc.suspend(); + processHypothesisStatus(res, anHyp, false); + wc.resume(); + } + } } catch(const SALOME::SALOME_Exception& S_ex) { wc.suspend(); SalomeApp_Tools::QtCatchCorbaException(S_ex); diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h index f62b14da2..42172d76b 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h @@ -57,7 +57,8 @@ namespace SMESH{ SMESHGUI_EXPORT QStringList GetAvailableHypotheses( const bool isAlgo, const int theDim = -1, - const bool isAux = false); + const bool isAux = false, + const bool isNeedGeometry = true); SMESHGUI_EXPORT QStringList GetHypothesesSets(); diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index 33d2e6485..b9b4f079d 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -569,6 +569,27 @@ void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable ) } } + +//================================================================================ +/*! + * \brief Disable tab + * \param int - tab ID + */ +//================================================================================ +void SMESHGUI_MeshDlg::disableTab(const int theTabId) { + myTabWg->setTabEnabled( myTabs[ theTabId ], false ); +} + +//================================================================================ +/*! + * \brief Enable tabs + * \param int - tab ID + */ +//================================================================================ +void SMESHGUI_MeshDlg::enableTab(const int theTabId) { + myTabWg->setTabEnabled( myTabs[ theTabId ], true ); +} + void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn) { if ( myGeomPopup && isBtnOn ) diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.h b/src/SMESHGUI/SMESHGUI_MeshDlg.h index 33f1b2d57..4b909b3c8 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.h @@ -74,6 +74,9 @@ public: void setMaxHypoDim( const int ); void setHypoSets( const QStringList& ); void setGeomPopupEnabled( const bool ); + void disableTab(const int); + void enableTab(const int); + signals: diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index ca82f9dd3..c8d85ecb0 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -102,6 +102,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh ) { if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists GeometryGUI::InitGeomGen(); + myIsOnGeometry = true; } //================================================================================ @@ -412,125 +413,165 @@ void SMESHGUI_MeshOp::selectionDone() { if ( !dlg()->isShown() || !myDlg->isEnabled() ) return; - + SMESHGUI_SelectionOp::selectionDone(); - + try { - // Enable tabs according to shape dimension - - int shapeDim = 3; - - QStringList aGEOMs; - myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs); - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - if (aGEOMs.count() > 0) { - // one or more GEOM shape selected - aSeq->length(aGEOMs.count()); - QStringList::const_iterator aSubShapesIter = aGEOMs.begin(); - int iSubSh = 0; - for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) { - QString aSubGeomEntry = (*aSubShapesIter); - _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1()); - GEOM::GEOM_Object_var aSubGeomVar = - GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject()); - aSeq[iSubSh] = aSubGeomVar; - } - } else { - // get geometry by selected sub-mesh - QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); - _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() ); - GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj ); - if (!aGeomVar->_is_nil()) { - aSeq->length(1); - aSeq[0] = aGeomVar; - } + //Check geometry for mesh + QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() ); + if ( !pObj ) + return; + + SMESH::SMESH_subMesh_var aSubMeshVar = + SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); + if ( !aSubMeshVar->_is_nil() ) + myIsOnGeometry = true; + else { + SMESH::SMESH_Mesh_var aMeshVar = + SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pObj )->GetObject() ); + if ( !myToCreate && !aMeshVar->HasShapeToMesh() ) + myIsOnGeometry = false; + else + myIsOnGeometry = true; } + + if ( myIsOnGeometry ) { + // Enable tabs according to shape dimension + + int shapeDim = 3; + QStringList aGEOMs; + myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs); + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + if (aGEOMs.count() > 0) { + // one or more GEOM shape selected + aSeq->length(aGEOMs.count()); + QStringList::const_iterator aSubShapesIter = aGEOMs.begin(); + int iSubSh = 0; + for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) { + QString aSubGeomEntry = (*aSubShapesIter); + _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1()); + GEOM::GEOM_Object_var aSubGeomVar = + GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject()); + aSeq[iSubSh] = aSubGeomVar; + } + } else { + // get geometry by selected sub-mesh + QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() ); + GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj ); + if (!aGeomVar->_is_nil()) { + aSeq->length(1); + aSeq[0] = aGeomVar; + } + } - if (aSeq->length() > 0) { - shapeDim = 0; - for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) { - GEOM::GEOM_Object_var aGeomVar = aSeq[iss]; - switch ( aGeomVar->GetShapeType() ) { - case GEOM::SOLID: - case GEOM::SHELL: shapeDim = 3; break; - case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break; - case GEOM::WIRE: - case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break; - case GEOM::VERTEX: break; - default: - TopoDS_Shape aShape; - if ( GEOMBase::GetShape(aGeomVar, aShape)) { - TopExp_Explorer exp( aShape, TopAbs_SHELL ); - if ( exp.More() ) - shapeDim = 3; - else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() ) - shapeDim = (shapeDim < 2) ? 2 : shapeDim; - else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() ) - shapeDim = (shapeDim < 1) ? 1 : shapeDim; - else - ;//shapeDim = 0; + if (aSeq->length() > 0) { + shapeDim = 0; + for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) { + GEOM::GEOM_Object_var aGeomVar = aSeq[iss]; + switch ( aGeomVar->GetShapeType() ) { + case GEOM::SOLID: + case GEOM::SHELL: shapeDim = 3; break; + case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break; + case GEOM::WIRE: + case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break; + case GEOM::VERTEX: break; + default: + TopoDS_Shape aShape; + if ( GEOMBase::GetShape(aGeomVar, aShape)) { + TopExp_Explorer exp( aShape, TopAbs_SHELL ); + if ( exp.More() ) + shapeDim = 3; + else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() ) + shapeDim = (shapeDim < 2) ? 2 : shapeDim; + else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() ) + shapeDim = (shapeDim < 1) ? 1 : shapeDim; + else + ;//shapeDim = 0; + } } } } - } - myDlg->setMaxHypoDim( shapeDim ); + myDlg->setMaxHypoDim( shapeDim ); - - if ( !myToCreate ) // edition: read hypotheses - { - QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); - _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() ); - if ( pObj != 0 ) + + if ( !myToCreate ) // edition: read hypotheses { - SMESH::SMESH_subMesh_var aVar = - SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); - myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() ); - myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide(); - myDlg->updateGeometry(); - myDlg->adjustSize(); - readMesh(); - } - else - myDlg->reset(); - - } - else if ( !myIsMesh ) // submesh creation - { - // if a submesh on the selected shape already exist, pass to submesh edition mode - if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) { - SMESH::SMESH_subMesh_var sm = - SMESH::SObjectToInterface( pSubmesh ); - bool editSubmesh = ( !sm->_is_nil() && - SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ), - tr( "EDIT_SUBMESH_QUESTION"), - tr( "SMESH_BUT_YES" ), - tr( "SMESH_BUT_NO" ), 1, 0, 0 )); - if ( editSubmesh ) + QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() ); + if ( pObj != 0 ) { - selectionMgr()->clearFilters(); - selectObject( pSubmesh ); - SMESHGUI::GetSMESHGUI()->switchToOperation(704); - return; + + SMESH::SMESH_subMesh_var aVar = + SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); + myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() ); + myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true ); + myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide(); + myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide(); + myDlg->updateGeometry(); + myDlg->adjustSize(); + readMesh(); } else - { - myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" ); - selectObject( _PTR(SObject)() ); - selectionDone(); + myDlg->reset(); + + } + else if ( !myIsMesh ) // submesh creation + { + // if a submesh on the selected shape already exist, pass to submesh edition mode + if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) { + SMESH::SMESH_subMesh_var sm = + SMESH::SObjectToInterface( pSubmesh ); + bool editSubmesh = ( !sm->_is_nil() && + SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ), + tr( "EDIT_SUBMESH_QUESTION"), + tr( "SMESH_BUT_YES" ), + tr( "SMESH_BUT_NO" ), 1, 0, 0 )); + if ( editSubmesh ) + { + selectionMgr()->clearFilters(); + selectObject( pSubmesh ); + SMESHGUI::GetSMESHGUI()->switchToOperation(704); + return; + } + else + { + myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" ); + selectObject( _PTR(SObject)() ); + selectionDone(); + } + } + + // enable/disable popup for choice of geom selection way + bool enable = false; + QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); + if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) { + SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface( pMesh ); + if ( !mesh->_is_nil() ) + enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 ); } + myDlg->setGeomPopupEnabled( enable ); } - - // enable/disable popup for choice of geom selection way - bool enable = false; - QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); - if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) { - SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface( pMesh ); - if ( !mesh->_is_nil() ) - enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 ); + } + else { + myDlg->enableTab( SMESH::DIM_3D ); + QStringList hypList; + availableHyps( SMESH::DIM_3D, Algo, hypList, + myAvailableHypData[SMESH::DIM_3D][Algo]); + + SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D ); + aTab->setAvailableHyps( Algo, hypList ); + for( int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i ) { + myDlg->disableTab(i); } - myDlg->setGeomPopupEnabled( enable ); + //Hide labels and fields (Mesh ang Geometry) + myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false ); + myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false ); + myDlg->adjustSize(); + readMesh(); } } catch ( const SALOME::SALOME_Exception& S_ex ) @@ -570,7 +611,7 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const return false; } - // Imported mesh, if create sub-mesh or edit mesh +/* // Imported mesh, if create sub-mesh or edit mesh if ( !myToCreate || ( myToCreate && !myIsMesh )) { QString aMeshEntry = myDlg->selectedObject @@ -582,7 +623,7 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const return false; } } - } + }*/ // Geom if ( myToCreate ) @@ -673,7 +714,7 @@ void SMESHGUI_MeshOp::availableHyps( const int theDim, theHyps.clear(); bool isAlgo = ( theHypType == Algo ); bool isAux = ( theHypType == AddHyp ); - QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux ); + QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry ); QStringList::const_iterator anIter; for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter ) @@ -1224,6 +1265,9 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName ) } else { bool mainHyp = true; + QStringList anAvailable; + availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] ); + myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable ); int index = myAvailableHypData[aDim][MainHyp].findIndex( aHypData ); if ( index < 0 ) { mainHyp = false; @@ -1591,32 +1635,35 @@ void SMESHGUI_MeshOp::readMesh() if ( !pObj ) return; - // Get name of mesh if current object is sub-mesh - SMESH::SMESH_subMesh_var aSubMeshVar = + if( myIsOnGeometry ) { + // Get name of mesh if current object is sub-mesh + SMESH::SMESH_subMesh_var aSubMeshVar = SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); - if ( !aSubMeshVar->_is_nil() ) - { - SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather(); - if ( !aMeshVar->_is_nil() ) + if ( !aSubMeshVar->_is_nil() ) { - _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar ); - QString aMeshName = name( aMeshSO ); - myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName ); + SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather(); + if ( !aMeshVar->_is_nil() ) + { + _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar ); + QString aMeshName = name( aMeshSO ); + myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName ); + } + } + + // Get name of geometry object + GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj ); + if ( !aGeomVar->_is_nil() ) + { + _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() ); + QString aShapeName = name( aGeomSO ); + myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName ); } - } - - // Get name of geometry object - GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj ); - if ( !aGeomVar->_is_nil() ) - { - _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() ); - QString aShapeName = name( aGeomSO ); - myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName ); } // Get hypotheses and algorithms assigned to the mesh/sub-mesh QStringList anExisting; - for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ ) + const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D; + for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) { // get algorithm existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] ); @@ -1641,7 +1688,7 @@ void SMESHGUI_MeshOp::readMesh() // get hypotheses bool hypWithoutAlgo = false; - for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ ) + for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) { for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ ) { @@ -1754,18 +1801,19 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess ) // Set new name QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj ); SMESH::SetName( pObj, aName.latin1() ); + int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D; // First, remove old algos in order to avoid messages on algorithm hiding - for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ ) + for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) { if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 ) { SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first; CORBA::String_var anOldName = anOldAlgo->GetName(); SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim ); - CORBA::String_var anAlgoName = anAlgoVar->GetName(); + // CORBA::String_var anAlgoName = anAlgoVar->GetName(); if ( anAlgoVar->_is_nil() || // no new algo selected or - strcmp(anOldName.in(), anAlgoName.in()) ) // algo change + strcmp(anOldName.in(), anAlgoVar->GetName()) ) // algo change { // remove old algorithm SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first ); @@ -1775,7 +1823,7 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess ) } // Assign new algorithms and hypotheses - for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ ) + for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) { if ( !isAccessibleDim( dim )) continue; diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.h b/src/SMESHGUI/SMESHGUI_MeshOp.h index 23365fd1a..c8b2ed7c0 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.h +++ b/src/SMESHGUI/SMESHGUI_MeshOp.h @@ -137,6 +137,7 @@ private: SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; bool myToCreate; bool myIsMesh; + bool myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 7602c410b..36fdceb67 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -296,8 +296,25 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).latin1() ); //FindSObject( mesh ); if ( so ) { - GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so ); - return QVariant( !shape->_is_nil(), 0 ); + CORBA::Object_var obj = SMESH::SObjectToObject(so, SMESH::GetActiveStudyDocument()); + if(!CORBA::is_nil(obj)){ + SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj ); + if (!mesh->_is_nil()){ + if(mesh->HasShapeToMesh()) { + GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so ); + return QVariant( !shape->_is_nil(), 0 ); + } + else + { + return QVariant(!mesh->NbFaces()==0, 0); + } + } + else + { + GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so ); + return QVariant( !shape->_is_nil(), 0 ); + } + } } // } // } diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index e1ade0980..2fa20059d 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -130,6 +130,10 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, QString aLabel = atts.value("label-id"); QString anIcon = atts.value("icon-id"); bool isAux = atts.value("auxiliary") == "true"; + bool isNeedGeom = true; + QString aNeedGeom = atts.value("need-geom"); + if ( !aNeedGeom.isEmpty() ) + isNeedGeom = (aNeedGeom == "true"); QString aDimStr = atts.value("dim"); aDimStr = aDimStr.remove( ' ' ); @@ -159,7 +163,7 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, HypothesisData* aHypData = new HypothesisData (aHypAlType, myPluginName, myServerLib, myClientLib, aLabel, anIcon, aDim, isAux, - attr[ HYPOS ], attr[ OPT_HYPOS ], attr[ INPUT ], attr[ OUTPUT ]); + attr[ HYPOS ], attr[ OPT_HYPOS ], attr[ INPUT ], attr[ OUTPUT ], isNeedGeom ); if (qName == "algorithm") { diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 998266806..4d362f69c 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -81,6 +81,7 @@ static TCollection_AsciiString theEmptyString; #undef DUMP_CONVERSION #endif + namespace { //================================================================================ @@ -250,7 +251,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand AddMeshAccessorMethod( aCommand ); // Add access to a wrapped algorithm - AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ??? + // AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ??? // PAL12227. PythonDump was not updated at proper time; result is // aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1)) @@ -287,16 +288,26 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) // Concatenate( [mesh1, ...], ... ) // CreateHypothesis( theHypType, theLibName ) // Compute( mesh, geom ) - // mesh creation if ( theCommand->GetMethod() == "CreateMesh" || - theCommand->GetMethod() == "CreateEmptyMesh" ) + theCommand->GetMethod() == "CreateEmptyMesh" || + theCommand->GetMethod() == "CreateMeshesFromUNV" || + theCommand->GetMethod() == "CreateMeshesFromSTL") { Handle(_pyMesh) mesh = new _pyMesh( theCommand ); myMeshes.insert( make_pair( mesh->GetID(), mesh )); return; } + if(theCommand->GetMethod() == "CreateMeshesFromMED") + { + for(int ind = 0;indGetNbResultValues();ind++) + { + Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind)); + myMeshes.insert( make_pair( theCommand->GetResultValue(ind), mesh )); + } + } + // CreateHypothesis() if ( theCommand->GetMethod() == "CreateHypothesis" ) { @@ -589,12 +600,32 @@ _pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd): { // convert my creation command Handle(_pyCommand) creationCmd = GetCreationCmd(); - creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); - creationCmd->SetMethod( "Mesh" ); + TCollection_AsciiString str = creationCmd->GetMethod(); + + creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); + if(str != "CreateMeshesFromUNV" && + str != "CreateMeshesFromMED" && + str != "CreateMeshesFromSTL") + creationCmd->SetMethod( "Mesh" ); theGen->SetAccessorMethod( GetID(), "GetMesh()" ); } +//================================================================================ +/*! + * \brief + * \param theCreationCmd - + */ +//================================================================================ +_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString& id): + _pyObject(theCreationCmd), myHasEditor(false) +{ + // convert my creation command + Handle(_pyCommand) creationCmd = GetCreationCmd(); + creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); + theGen->SetAccessorMethod( id, "GetMesh()" ); +} + //================================================================================ /*! * \brief Convert a IDL API command of SMESH::Mesh to a method call of python Mesh @@ -676,7 +707,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) } } Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID ); - if ( ! hasAddCmd ) { // hypo addition already wrapped + if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped // RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 ) _pyID geom = theCommand->GetArg( 1 ); theCommand->RemoveArgs(); @@ -1562,6 +1593,54 @@ const TCollection_AsciiString & _pyCommand::GetResultValue() return myRes; } +//================================================================================ +/*! + * \brief Return number of python command result value ResultValue = Obj.Meth() + * \retval const int + */ +//================================================================================ + +const int _pyCommand::GetNbResultValues() +{ + int begPos = 1; + int Nb=0; + int endPos = myString.Location( "=", 1, Length() ); + TCollection_AsciiString str = ""; + while ( begPos < endPos) { + str = GetWord( myString, begPos, true ); + begPos = begPos+ str.Length(); + Nb++; + } + return (Nb-1); +} + + +//================================================================================ +/*! + * \brief Return substring of python command looking like + * ResultValue1 , ResultValue1,... = Obj.Meth() with res index + * \retval const TCollection_AsciiString & - ResultValue with res index substring + */ +//================================================================================ +const TCollection_AsciiString & _pyCommand::GetResultValue(int res) +{ + int begPos = 1; + int Nb=0; + int endPos = myString.Location( "=", 1, Length() ); + while ( begPos < endPos) { + myRes = GetWord( myString, begPos, true ); + begPos = begPos + myRes.Length(); + Nb++; + if(res == Nb){ + myRes.RemoveAll('[');myRes.RemoveAll(']'); + return myRes; + } + if(Nb>res) + break; + } + return theEmptyString; +} + //================================================================================ /*! * \brief Return substring of python command looking like ResVal = Object.Meth() diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index a09a84cd6..a5fd82413 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -111,6 +111,8 @@ public: bool IsEmpty() const { return myString.IsEmpty(); } TCollection_AsciiString GetIndentation(); const TCollection_AsciiString & GetResultValue(); + const int GetNbResultValues(); + const TCollection_AsciiString & GetResultValue(int res); const TCollection_AsciiString & GetObject(); const TCollection_AsciiString & GetMethod(); const TCollection_AsciiString & GetArg( int index ); @@ -210,6 +212,7 @@ class _pyMesh: public _pyObject bool myHasEditor; public: _pyMesh(const Handle(_pyCommand) theCreationCmd); + _pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString &); const _pyID& GetGeom() { return GetCreationCmd()->GetArg(1); } void Process( const Handle(_pyCommand)& theCommand); void Flush(); diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index cf94c0ec7..d79dfa565 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1030,7 +1030,7 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetComputeErrors()" ); - if ( CORBA::is_nil( theSubObject ) ) + if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -1040,7 +1040,12 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr try { if ( SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh )) { - TopoDS_Shape shape = GeomObjectToShape( theSubObject ); + TopoDS_Shape shape; + if(theMesh->HasShapeToMesh()) + shape = GeomObjectToShape( theSubObject ); + else + shape = SMESH_Mesh::PseudoShape(); + ::SMESH_Mesh& mesh = meshServant->GetImpl(); error_array->length( mesh.GetMeshDS()->MaxShapeIndex() ); @@ -1095,7 +1100,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetAlgoState()" ); - if ( CORBA::is_nil( theSubObject ) ) + if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -1106,7 +1111,12 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh ); ASSERT( meshServant ); if ( meshServant ) { - TopoDS_Shape myLocShape = GeomObjectToShape( theSubObject ); + TopoDS_Shape myLocShape; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theSubObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); + ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); list< ::SMESH_Gen::TAlgoStateError > error_list; list< ::SMESH_Gen::TAlgoStateError >::iterator error; @@ -1224,7 +1234,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" ); - if ( CORBA::is_nil( theShapeObject ) ) + if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); @@ -1244,7 +1254,11 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, // NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation" meshServant->CheckGeomGroupModif(); // get local TopoDS_Shape - TopoDS_Shape myLocShape = GeomObjectToShape( theShapeObject ); + TopoDS_Shape myLocShape; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theShapeObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); // call implementation compute ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); return myGen.Compute( myLocMesh, myLocShape); @@ -1785,6 +1799,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, int id = myStudyContext->findId( string( objStr.in() ) ); ::SMESH_Mesh& myLocMesh = myImpl->GetImpl(); SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS(); + bool hasShape = myLocMesh.HasShapeToMesh(); // for each mesh open the HDF group basing on its id char meshGrpName[ 30 ]; @@ -1830,10 +1845,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write applied hypotheses if exist SALOMEDS::SObject_var myHypBranch; found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch ); - if ( found && !shapeRefFound ) { // remove applied hyps + if ( found && !shapeRefFound && hasShape) { // remove applied hyps myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch ); } - if ( found && shapeRefFound ) { + if ( found && (shapeRefFound || !hasShape) ) { aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup ); aGroup->CreateOnDisk(); @@ -1873,10 +1888,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write applied algorithms if exist SALOMEDS::SObject_var myAlgoBranch; found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch ); - if ( found && !shapeRefFound ) { // remove applied algos + if ( found && !shapeRefFound && hasShape) { // remove applied algos myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch ); } - if ( found && shapeRefFound ) { + if ( found && (shapeRefFound || !hasShape)) { aGroup = new HDFgroup( "Applied Algorithms", aTopGroup ); aGroup->CreateOnDisk(); @@ -2185,7 +2200,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, myWriter.Perform(); // maybe a shape was deleted in the study - if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) { + if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() && hasShape) { TopoDS_Shape nullShape; myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data } @@ -2911,7 +2926,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil() + || !myNewMeshImpl->HasShapeToMesh()) ) myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } @@ -2948,7 +2964,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + if ( !anHyp->_is_nil() && (!aShapeObject->_is_nil() + || !myNewMeshImpl->HasShapeToMesh()) ) myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } @@ -3314,9 +3331,14 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } // if ( hasData ) // Recompute State (as computed sub-meshes are restored from MED) - if ( !aShapeObject->_is_nil() ) { + if ( !aShapeObject->_is_nil() || !myNewMeshImpl->HasShapeToMesh()) { MESSAGE("Compute State Engine ..."); - TopoDS_Shape myLocShape = GeomObjectToShape( aShapeObject ); + TopoDS_Shape myLocShape; + if(myNewMeshImpl->HasShapeToMesh()) + myLocShape = GeomObjectToShape( aShapeObject ); + else + myLocShape = SMESH_Mesh::PseudoShape(); + myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine (SMESH_subMesh::SUBMESH_RESTORED); MESSAGE("Compute State Engine finished"); diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index d179f62d1..2460bcc1c 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -740,10 +740,15 @@ SALOMEDS::SObject_ptr { if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape") SALOMEDS::SObject_var aMeshOrSubMesh; - if ( theShape->_is_nil() || theMesh->_is_nil() ) + if (theMesh->_is_nil() || ( theShape->_is_nil() && theMesh->HasShapeToMesh())) return aMeshOrSubMesh._retn(); + + TopoDS_Shape aShape; + if(theMesh->HasShapeToMesh()) + aShape = GeomObjectToShape( theShape ); + else + aShape = SMESH_Mesh::PseudoShape(); - TopoDS_Shape aShape = GeomObjectToShape( theShape ); SMESH_Mesh_i* mesh_i = objectToServant( theMesh ); if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) { @@ -773,7 +778,8 @@ bool SMESH_Gen_i::AddHypothesisToShape(SALOMEDS::Study_ptr theStudy, { if(MYDEBUG) MESSAGE("AddHypothesisToShape") if (theStudy->_is_nil() || theMesh->_is_nil() || - theHyp->_is_nil() || theShape->_is_nil() ) + theHyp->_is_nil() || (theShape->_is_nil() + && theMesh->HasShapeToMesh()) ) return false; SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh ); @@ -827,7 +833,8 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy SMESH::SMESH_Hypothesis_ptr theHyp) { if (theStudy->_is_nil() || theMesh->_is_nil() || - theHyp->_is_nil() || theShape->_is_nil() ) + theHyp->_is_nil() || (theShape->_is_nil() + && theMesh->HasShapeToMesh())) return false; SALOMEDS::SObject_var aHypSO = ObjectToSObject( theStudy, theHyp ); diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 647439380..274e05f39 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -364,9 +364,14 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); // Update Python script - TPythonDump() << "status = " << _this() << ".AddHypothesis( " - << aSubShapeObject << ", " << anHyp << " )"; - + if(_impl->HasShapeToMesh()) { + TPythonDump() << "status = " << _this() << ".AddHypothesis( " + << aSubShapeObject << ", " << anHyp << " )"; + } + else { + TPythonDump() << "status = " << _this() << ".AddHypothesis( "<< anHyp << " )"; + } + return ConvertHypothesisStatus(status); } @@ -382,7 +387,7 @@ SMESH_Hypothesis::Hypothesis_Status { if(MYDEBUG) MESSAGE("addHypothesis"); - if (CORBA::is_nil(aSubShapeObject)) + if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM); @@ -394,7 +399,13 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; try { - TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject); + TopoDS_Shape myLocSubShape; + //use PseudoShape in case if mesh has no shape + if(HasShapeToMesh()) + myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject); + else + myLocSubShape = _impl->GetShapeToMesh(); + int hypId = myHyp->GetId(); status = _impl->AddHypothesis(myLocSubShape, hypId); if ( !SMESH_Hypothesis::IsStatusFatal(status) ) { @@ -432,8 +443,15 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS aSubShapeObject, anHyp ); // Update Python script + // Update Python script + if(_impl->HasShapeToMesh()) { TPythonDump() << "status = " << _this() << ".RemoveHypothesis( " << aSubShapeObject << ", " << anHyp << " )"; + } + else { + TPythonDump() << "status = " << _this() << ".RemoveHypothesis( " + << anHyp << " )"; + } return ConvertHypothesisStatus(status); } @@ -450,7 +468,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Ob if(MYDEBUG) MESSAGE("removeHypothesis()"); // **** proposer liste de subShape (selection multiple) - if (CORBA::is_nil(aSubShapeObject)) + if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM); @@ -462,8 +480,14 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Ob SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; try { - TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject); - int hypId = myHyp->GetId(); + TopoDS_Shape myLocSubShape; + //use PseudoShape in case if mesh has no shape + if(HasShapeToMesh()) + myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject); + else + myLocSubShape = _impl->GetShapeToMesh(); + + int hypId = myHyp->GetId(); status = _impl->RemoveHypothesis(myLocSubShape, hypId); if ( !SMESH_Hypothesis::IsStatusFatal(status) ) _mapHypo.erase( hypId ); -- 2.39.2