X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Propagation.cxx;h=3d82126adf50eeba19d875054d7669f3b9da6a72;hp=15bd1944cc121a3faad57c2caa4a587848ec2e59;hb=264eeb2edd6977ccf2d2bd88cbb210353f63f7c9;hpb=f7aba4830d53719b963fdb7fccc98b760fdef2d1 diff --git a/src/StdMeshers/StdMeshers_Propagation.cxx b/src/StdMeshers/StdMeshers_Propagation.cxx index 15bd1944c..3d82126ad 100644 --- a/src/StdMeshers/StdMeshers_Propagation.cxx +++ b/src/StdMeshers/StdMeshers_Propagation.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -85,16 +85,15 @@ namespace { */ //============================================================================= -StdMeshers_Propagation::StdMeshers_Propagation (int hypId, int studyId, SMESH_Gen * gen) - : SMESH_Hypothesis(hypId, studyId, gen) +StdMeshers_Propagation::StdMeshers_Propagation (int hypId, SMESH_Gen * gen) + : SMESH_Hypothesis(hypId, gen) { _name = GetName(); _param_algo_dim = -1; // 1D auxiliary } StdMeshers_PropagOfDistribution::StdMeshers_PropagOfDistribution (int hypId, - int studyId, SMESH_Gen * gen) - : StdMeshers_Propagation(hypId, studyId, gen) { _name = GetName(); } + : StdMeshers_Propagation(hypId, gen) { _name = GetName(); } StdMeshers_Propagation::~StdMeshers_Propagation() {} string StdMeshers_Propagation::GetName () { return "Propagation"; } string StdMeshers_PropagOfDistribution::GetName () { return "PropagOfDistribution"; } @@ -114,7 +113,17 @@ TopoDS_Edge StdMeshers_Propagation::GetPropagationSource(SMESH_Mesh& the return PropagationMgr::GetSource( theMesh.GetSubMeshContaining( theEdge ), isPropagOfDistribution); } - +const SMESH_HypoFilter& StdMeshers_Propagation::GetFilter() +{ + static SMESH_HypoFilter propagHypFilter; + if ( propagHypFilter.IsEmpty() ) + { + propagHypFilter. + Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())). + Or ( SMESH_HypoFilter::HasName( StdMeshers_PropagOfDistribution::GetName ())); + } + return propagHypFilter; +} //============================================================================= //============================================================================= // PROPAGATION MANAGEMENT @@ -174,7 +183,7 @@ namespace { } //============================================================================= /*! - * \brief return PropagationMgrData found on a submesh + * \brief return PropagationMgrData found on a sub-mesh */ PropagationMgrData* findData(SMESH_subMesh* sm) { @@ -184,14 +193,14 @@ namespace { } //============================================================================= /*! - * \brief return PropagationMgrData found on theEdge submesh + * \brief return PropagationMgrData found on theEdge sub-mesh */ - PropagationMgrData* findData(SMESH_Mesh& theMesh, const TopoDS_Shape& theEdge) - { - if ( theEdge.ShapeType() == TopAbs_EDGE ) - return findData( theMesh.GetSubMeshContaining( theEdge ) ); - return 0; - } + // PropagationMgrData* findData(SMESH_Mesh& theMesh, const TopoDS_Shape& theEdge) + // { + // if ( theEdge.ShapeType() == TopAbs_EDGE ) + // return findData( theMesh.GetSubMeshContaining( theEdge ) ); + // return 0; + // } //============================================================================= /*! * \brief return existing or a new PropagationMgrData @@ -209,30 +218,27 @@ namespace { /*! * \brief Returns a local 1D hypothesis used for theEdge */ - const SMESH_Hypothesis* getLocal1DHyp (SMESH_Mesh& theMesh, - const TopoDS_Shape& theEdge) + const SMESH_Hypothesis* getLocal1DHyp (SMESH_subMesh* theSubMesh, + //const TopoDS_Shape& theEdge, + TopoDS_Shape* theSssignedTo=0) { static SMESH_HypoFilter hypo; hypo.Init( hypo.HasDim( 1 )). AndNot ( hypo.IsAlgo() ). - AndNot ( hypo.IsAssignedTo( theMesh.GetMeshDS()->ShapeToMesh() )); - return theMesh.GetHypothesis( theEdge, hypo, true ); + AndNot ( hypo.HasName( StdMeshers_Propagation::GetName() )). + AndNot ( hypo.HasName( StdMeshers_PropagOfDistribution::GetName() )). + AndNot ( hypo.IsAssignedTo( theSubMesh->GetFather()->GetShapeToMesh() )); + + return theSubMesh->GetFather()->GetHypothesis( theSubMesh, hypo, true, theSssignedTo ); } //============================================================================= /*! * \brief Returns a propagation hypothesis assigned to theEdge */ - const SMESH_Hypothesis* getProagationHyp (SMESH_Mesh& theMesh, - const TopoDS_Shape& theEdge) + const SMESH_Hypothesis* getProagationHyp (SMESH_subMesh* theSubMesh) { - static SMESH_HypoFilter propagHypFilter; - if ( propagHypFilter.IsEmpty() ) - { - propagHypFilter. - Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())). - Or ( SMESH_HypoFilter::HasName( StdMeshers_PropagOfDistribution::GetName ())); - } - return theMesh.GetHypothesis( theEdge, propagHypFilter, true ); + return theSubMesh->GetFather()->GetHypothesis + ( theSubMesh, StdMeshers_Propagation::GetFilter(), true ); } //================================================================================ /*! @@ -258,10 +264,14 @@ namespace { SMESH_Mesh* mesh = theMainSubMesh->GetFather(); + TopoDS_Shape shapeOfHyp1D; // shape to which an hyp being propagated is assigned + const SMESH_Hypothesis* hyp1D = getLocal1DHyp( theMainSubMesh, &shapeOfHyp1D ); + SMESH_HypoFilter moreLocalCheck( SMESH_HypoFilter::IsMoreLocalThan( shapeOfHyp1D, *mesh )); + PropagationMgrData* chainData = getData( theMainSubMesh ); chainData->SetState( HAS_PROPAG_HYP ); - if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( *mesh, theMainEdge )) + if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( theMainSubMesh )) chainData->myIsPropagOfDistribution = ( StdMeshers_PropagOfDistribution::GetName() == propagHyp->GetName() ); @@ -273,6 +283,8 @@ namespace { TopTools_MapOfShape checkedShapes; checkedShapes.Add( theMainEdge ); + vector edges; + list::iterator smIt = chain.begin(); for ( ; smIt != chain.end(); ++smIt ) { @@ -289,10 +301,9 @@ namespace { continue; // Get ordered edges and find index of anE in a sequence + edges.clear(); BRepTools_WireExplorer aWE (TopoDS::Wire(itA.Value())); - vector edges; - edges.reserve(4); - int edgeIndex = 0; + size_t edgeIndex = 0; for (; aWE.More(); aWE.Next()) { TopoDS_Edge edge = aWE.Current(); edge.Orientation( aWE.Orientation() ); @@ -313,8 +324,8 @@ namespace { else { // count nb sides TopoDS_Edge prevEdge = anE; - int nbSide = 0, eIndex = edgeIndex + 1; - for ( int i = 0; i < edges.size(); ++i, ++eIndex ) + size_t nbSide = 0, eIndex = edgeIndex + 1; + for ( size_t i = 0; i < edges.size(); ++i, ++eIndex ) { if ( eIndex == edges.size() ) eIndex = 0; @@ -355,7 +366,8 @@ namespace { if ( oppData->State() == WAIT_PROPAG_HYP ) // ... anOppE is not in any chain { oppData->SetSource( theMainSubMesh ); - if ( !getLocal1DHyp( *mesh, anOppE )) // ... no 1d hyp on anOppE + if ( ! (hyp1D = getLocal1DHyp( oppSM, &shapeOfHyp1D )) || //...no 1d hyp on anOppE + ! (moreLocalCheck.IsOk( hyp1D, shapeOfHyp1D ))) // ... or hyp1D is "more global" { oppData->myForward = data->myForward; if ( edges[ edgeIndex ].Orientation() == anOppE.Orientation() ) @@ -366,8 +378,8 @@ namespace { DBGMSG( "set IN_CHAIN on " << oppSM->GetId() ); if ( oppSM->GetAlgoState() != SMESH_subMesh::HYP_OK ) // make oppSM check algo state - if ( SMESH_Algo* algo = mesh->GetGen()->GetAlgo( *mesh, anOppE )) - oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO,algo); + if ( SMESH_Algo* algo = oppSM->GetAlgo() ) + oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO, algo); } else { oppData->SetState( LAST_IN_CHAIN ); @@ -483,7 +495,7 @@ namespace { submesh->SetEventListener( getListener(), data, submesh ); const SMESH_Hypothesis * propagHyp = - getProagationHyp( *submesh->GetFather(), submesh->GetSubShape() ); + getProagationHyp( submesh ); if ( propagHyp ) { data->myIsPropagOfDistribution = @@ -549,11 +561,10 @@ namespace { case WAIT_PROPAG_HYP: { // propagation hyp or local 1D hyp is missing // -------------------------------------------------------- - bool hasPropagHyp = ( isPropagHyp || - getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) ); + bool hasPropagHyp = ( isPropagHyp || getProagationHyp( subMesh )); if ( !hasPropagHyp ) return; - bool hasLocal1DHyp = getLocal1DHyp( *subMesh->GetFather(), subMesh->GetSubShape()); + bool hasLocal1DHyp = getLocal1DHyp( subMesh ); if ( !hasLocal1DHyp ) return; if ( event == SMESH_subMesh::ADD_HYP || @@ -570,7 +581,7 @@ namespace { switch ( event ) { case SMESH_subMesh::REMOVE_HYP: case SMESH_subMesh::REMOVE_FATHER_HYP: // remove propagation hyp - if ( isPropagHyp && !getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) ) + if ( isPropagHyp && !getProagationHyp( subMesh )) { DBGMSG( "REMOVE_HYP propagation from HAS_PROPAG_HYP " << subMesh->GetId() ); // clear propagation chain @@ -621,7 +632,11 @@ namespace { } return; } + case MEANINGLESS_LAST: { + break; + } } // switch by SubMeshState - } + + } // ProcessEvent() } // namespace