X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Gen.cxx;h=56da2ac331be6e4424520f4588ba891ccbe4ed5b;hp=2e79fb278b6c6b63b05e59ad8613da60425905a8;hb=4b5fd249abfca52265832f10435f18f5bb9c69ae;hpb=0953f1790ffd9569803302d26650a59f715b4f12 diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 2e79fb278..56da2ac33 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -1,23 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 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 SMESH : implementaion of SMESH idl descriptions @@ -38,10 +38,7 @@ #include "OpUtil.hxx" #include "Utils_ExceptHandlers.hxx" -#include -#include -#include -#include +#include #include "memoire.h" @@ -62,6 +59,10 @@ SMESH_Gen::SMESH_Gen() SMDS_Mesh::_meshList.clear(); MESSAGE(SMDS_Mesh::_meshList.size()); _counters = new counters(100); +#ifdef WITH_SMESH_CANCEL_COMPUTE + _compute_canceled = false; + _sm_current = NULL; +#endif } //============================================================================= @@ -151,7 +152,17 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, } if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) + { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if (_compute_canceled) + return false; + _sm_current = smToCompute; +#endif smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE ); +#ifdef WITH_SMESH_CANCEL_COMPUTE + _sm_current = NULL; +#endif + } // we check all the submeshes here and detect if any of them failed to compute if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) @@ -170,6 +181,14 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, // and collect submeshes with algos that DO support submeshes // ----------------------------------------------------------------- list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes; + + // map to sort sm with same dim algos according to dim of + // the shape the algo assigned to (issue 0021217) + multimap< int, SMESH_subMesh* > shDim2sm; + multimap< int, SMESH_subMesh* >::reverse_iterator shDim2smIt; + TopoDS_Shape algoShape; + int prevShapeDim = -1; + smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst); while ( smIt->more() ) { @@ -178,27 +197,55 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, continue; const TopoDS_Shape& aSubShape = smToCompute->GetSubShape(); - const int aShapeDim = GetShapeDim( aSubShape ); + int aShapeDim = GetShapeDim( aSubShape ); if ( aShapeDim < 1 ) break; // check for preview dimension limitations if ( aShapesId && aShapeDim > (int)aDim ) continue; - SMESH_Algo* algo = GetAlgo( aMesh, aSubShape ); + SMESH_Algo* algo = GetAlgo( aMesh, aSubShape, &algoShape ); if ( algo && !algo->NeedDescretBoundary() ) { if ( algo->SupportSubmeshes() ) - smWithAlgoSupportingSubmeshes.push_front( smToCompute ); + { + // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes + if ( prevShapeDim != aShapeDim ) + { + prevShapeDim = aShapeDim; + for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt ) + smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second ); + shDim2sm.clear(); + } + // add smToCompute to shDim2sm map + aShapeDim = GetShapeDim( algoShape ); + if ( algoShape.ShapeType() == TopAbs_COMPOUND ) + { + TopoDS_Iterator it( algoShape ); + aShapeDim += GetShapeDim( it.Value() ); + } + shDim2sm.insert( make_pair( aShapeDim, smToCompute )); + } else { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if (_compute_canceled) + return false; + _sm_current = smToCompute; +#endif smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE ); +#ifdef WITH_SMESH_CANCEL_COMPUTE + _sm_current = NULL; +#endif if ( aShapesId ) aShapesId->insert( smToCompute->GetId() ); } } } - + // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes + for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt ) + smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second ); + // ------------------------------------------------------------ // sort list of submeshes according to mesh order // ------------------------------------------------------------ @@ -217,7 +264,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, sm = *subIt; // get a shape the algo is assigned to - TopoDS_Shape algoShape; if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) continue; // strange... @@ -262,7 +308,15 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, if ( aShapesId && GetShapeDim( aShType ) > (int)aDim ) continue; +#ifdef WITH_SMESH_CANCEL_COMPUTE + if (_compute_canceled) + return false; + _sm_current = sm; +#endif sm->ComputeStateEngine( SMESH_subMesh::COMPUTE ); +#ifdef WITH_SMESH_CANCEL_COMPUTE + _sm_current = NULL; +#endif if ( aShapesId ) aShapesId->insert( sm->GetId() ); } @@ -298,6 +352,34 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, } +#ifdef WITH_SMESH_CANCEL_COMPUTE +//============================================================================= +/*! + * Prepare Compute a mesh + */ +//============================================================================= +void SMESH_Gen::PrepareCompute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape) +{ + _compute_canceled = false; + _sm_current = NULL; +} +//============================================================================= +/*! + * Cancel Compute a mesh + */ +//============================================================================= +void SMESH_Gen::CancelCompute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape) +{ + _compute_canceled = true; + if(_sm_current) + { + _sm_current->ComputeStateEngine( SMESH_subMesh::COMPUTE_CANCELED ); + } +} +#endif + //============================================================================= /*! * Evaluate a mesh