X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshOp.cxx;h=d511701400528d9486e37e7ff56105ee65ba402e;hb=8e93201bcf959a3355c84d17a6a10d52d0a7114e;hp=909fbdd578c25004bb3de6fa2f75fcca199cae36;hpb=d303154d91eb916a55ac93a372cbdb918aa18d14;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 909fbdd57..d51170140 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -1,29 +1,29 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_MeshOp.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. -// - // SMESH includes +// #include "SMESHGUI_MeshOp.h" #include "SMESHGUI.h" @@ -61,8 +61,11 @@ #include // OCCT includes +#include #include +#include #include +#include // IDL includes #include @@ -321,7 +324,7 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const while(1) { if (mainObj->_is_nil()) return false; - if (string(mainObj->GetEntry()) == string(mainGeom->GetEntry())) + if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry())) return true; mainObj = op->GetMainShape(mainObj); } @@ -332,10 +335,57 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const return false; } +//================================================================================ +/*! + * \brief Return name of the algorithm that does not support submeshes and makes + * submesh creation useless + * \retval char* - string is to be deleted!!! + */ +//================================================================================ + +char* SMESHGUI_MeshOp::isSubmeshIgnored() const +{ + if ( myToCreate && !myIsMesh ) { + + QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); + QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom ); + _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() ); + if ( pMesh ) { + + QStringList algoNames; + THypList algoList; + existingHyps(3, Algo, pMesh, algoNames, algoList); + if (!algoList.empty()) { + HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() ); + if ( algo && + algo->InputTypes.empty() && // builds all dimensions it-self + !algo->IsSupportSubmeshes ) + return CORBA::string_dup( algoNames[0].toLatin1().data() ); + } + +// GEOM::GEOM_Object_var geom; +// if (_PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() )) +// geom = SMESH::SObjectToInterface( pGeom ); + +// if ( !geom->_is_nil() && geom->GetShapeType() >= GEOM::FACE ) { // WIRE, EDGE as well + existingHyps(2, Algo, pMesh, algoNames, algoList); + if (!algoList.empty()) { + HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() ); + if ( algo && + algo->InputTypes.empty() && // builds all dimensions it-self + !algo->IsSupportSubmeshes ) + return CORBA::string_dup( algoNames[0].toLatin1().data() ); + } +// } + } + } + return 0; +} + //================================================================================ /*! * \brief find an existing submesh by the selected shape - * \retval _PTR(SObject) - the found submesh SObject + * \retval _PTR(SObject) - the found submesh SObject */ //================================================================================ @@ -453,28 +503,50 @@ void SMESHGUI_MeshOp::selectionDone() 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::SOLID: shapeDim = 3; break; + case GEOM::SHELL: + { + //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab + shapeDim = (shapeDim < 2) ? 2 : shapeDim; + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aGeomVar, aShape)) { + if (/*aShape.Closed()*/BRep_Tool::IsClosed(aShape)) + 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; + { + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aGeomVar, aShape)) { + TopExp_Explorer exp (aShape, TopAbs_SHELL); + if (exp.More()) { + //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab + shapeDim = (shapeDim < 2) ? 2 : shapeDim; + for (; exp.More() && shapeDim == 2; exp.Next()) { + if (/*exp.Current().Closed()*/BRep_Tool::IsClosed(exp.Current())) + 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; + } } } } } + for (int i = SMESH::DIM_3D; i > shapeDim; i--) { + // reset algos before disabling tabs (0020138) + onAlgoSelected(-1, i); + } myDlg->setMaxHypoDim( shapeDim ); @@ -520,8 +592,20 @@ void SMESHGUI_MeshOp::selectionDone() myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" ); selectObject( _PTR(SObject)() ); selectionDone(); + return; } } + // discard selected mesh if submesh creation not allowed because of + // a global algorithm that does not support submeshes + if ( char* algoName = isSubmeshIgnored() ) { + SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), + tr("SUBMESH_NOT_ALLOWED").arg(algoName)); + CORBA::string_free( algoName ); + myDlg->selectObject( "", SMESHGUI_MeshDlg::Mesh, "" ); + selectObject( _PTR(SObject)() ); + selectionDone(); + return; + } // enable/disable popup for choice of geom selection way bool enable = false;