X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_HypoFilter.cxx;h=d0125d1e56083efe4f2c89912ffd6333a8196d01;hp=5552964bbcffce76194533616607fc53fa0bab27;hb=eb22cf46cb0f386218d79291dfebcec8fc831055;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/SMESH/SMESH_HypoFilter.cxx b/src/SMESH/SMESH_HypoFilter.cxx index 5552964bb..d0125d1e5 100644 --- a/src/SMESH/SMESH_HypoFilter.cxx +++ b/src/SMESH/SMESH_HypoFilter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 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 @@ -157,8 +157,9 @@ void SMESH_HypoFilter::IsMoreLocalThanPredicate::findPreferable() bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp, const TopoDS_Shape& aShape) const { - if ( aShape.IsSame( _mesh.GetShapeToMesh() )) - return false; // aHyp is global + if ( aShape.IsSame( _mesh.GetShapeToMesh() ) || // aHyp is global + aShape.IsSame( _shape )) + return false; if ( SMESH_MesherHelper::IsSubShape( aShape, /*mainShape=*/_shape )) return true; @@ -185,6 +186,7 @@ bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aH //======================================================================= SMESH_HypoFilter::SMESH_HypoFilter() + : myNbPredicates(0) { } @@ -193,9 +195,10 @@ SMESH_HypoFilter::SMESH_HypoFilter() //purpose : //======================================================================= -SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNagate ) +SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNegate ) + : myNbPredicates(0) { - add( notNagate ? AND : AND_NOT, aPredicate ); + add( notNegate ? AND : AND_NOT, aPredicate ); } //======================================================================= @@ -352,15 +355,14 @@ SMESH_HypoPredicate* SMESH_HypoFilter::HasType(const int theHypType) bool SMESH_HypoFilter::IsOk (const SMESH_Hypothesis* aHyp, const TopoDS_Shape& aShape) const { - if ( myPredicates.empty() ) + if ( IsEmpty() ) return true; - bool ok = ( myPredicates.front()->_logical_op <= AND_NOT ); - list::const_iterator pred = myPredicates.begin(); - for ( ; pred != myPredicates.end(); ++pred ) + bool ok = ( myPredicates[0]->_logical_op <= AND_NOT ); + for ( int i = 0; i < myNbPredicates; ++i ) { - bool ok2 = (*pred)->IsOk( aHyp, aShape ); - switch ( (*pred)->_logical_op ) { + bool ok2 = myPredicates[i]->IsOk( aHyp, aShape ); + switch ( myPredicates[i]->_logical_op ) { case AND: ok = ok && ok2; break; case AND_NOT: ok = ok && !ok2; break; case OR: ok = ok || ok2; break; @@ -376,14 +378,15 @@ bool SMESH_HypoFilter::IsOk (const SMESH_Hypothesis* aHyp, //purpose : //======================================================================= -SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNagate ) +SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNegate ) { - list::const_iterator pred = myPredicates.begin(); - for ( ; pred != myPredicates.end(); ++pred ) + SMESH_HypoPredicate** pred = &myPredicates[0]; + SMESH_HypoPredicate** end = &myPredicates[myNbPredicates]; + for ( ; pred != end; ++pred ) delete *pred; - myPredicates.clear(); + myNbPredicates = 0; - add( notNagate ? AND : AND_NOT, aPredicate ); + add( notNegate ? AND : AND_NOT, aPredicate ); return *this; } @@ -395,7 +398,11 @@ SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bo SMESH_HypoFilter::~SMESH_HypoFilter() { - Init(0); + SMESH_HypoPredicate** pred = &myPredicates[0]; + SMESH_HypoPredicate** end = &myPredicates[myNbPredicates]; + for ( ; pred != end; ++pred ) + delete *pred; + myNbPredicates = 0; }