From ad9b0aac3ac51eb0dc3a42abede585dea1ba3da4 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 19 Feb 2007 15:35:40 +0000 Subject: [PATCH] PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis") ignore shape orientation at hypothesis addition/removal --- src/SMESHDS/SMESHDS_Mesh.cxx | 61 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index d8a1d5942..6a82e05c5 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -105,18 +105,18 @@ void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S) //======================================================================= bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS, - const SMESHDS_Hypothesis * H) + const SMESHDS_Hypothesis * H) { - list& alist=myShapeToHypothesis[SS]; + list& alist= + myShapeToHypothesis[SS.Oriented(TopAbs_FORWARD)]; // ignore orientation of SS - //Check if the Hypothesis is still present - list::iterator ith=alist.begin(); + //Check if the Hypothesis is still present + list::iterator ith=find(alist.begin(),alist.end(), H ); - for (; ith!=alist.end(); ith++) - if (H == *ith) return false; + if (alist.end() != ith) return false; - alist.push_back(H); - return true; + alist.push_back(H); + return true; } //======================================================================= @@ -124,22 +124,23 @@ bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS, //purpose : //======================================================================= -bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S, - const SMESHDS_Hypothesis * H) +bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S, + const SMESHDS_Hypothesis * H) { - ShapeToHypothesis::iterator its=myShapeToHypothesis.find(S); - if(its!=myShapeToHypothesis.end()) - { - list::iterator ith=(*its).second.begin(); + ShapeToHypothesis::iterator its= + myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S - for (; ith!=(*its).second.end(); ith++) - if (H == *ith) - { - (*its).second.erase(ith); - return true; - } - } - return false; + if(its!=myShapeToHypothesis.end()) + { + list& alist=(*its).second; + list::iterator ith=find(alist.begin(),alist.end(), H ); + if (ith != alist.end()) + { + alist.erase(ith); + return true; + } + } + return false; } //======================================================================= @@ -1015,14 +1016,16 @@ list SMESHDS_Mesh::SubMeshIndices() //purpose : //======================================================================= -const list& SMESHDS_Mesh::GetHypothesis( - const TopoDS_Shape & S) const +const list& +SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const { - if (myShapeToHypothesis.find(S)!=myShapeToHypothesis.end()) - return myShapeToHypothesis.find(S)->second; + ShapeToHypothesis::const_iterator its= + myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S + if (its!=myShapeToHypothesis.end()) + return its->second; - static list empty; - return empty; + static list empty; + return empty; } //======================================================================= @@ -1060,7 +1063,7 @@ bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) //======================================================================= bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S) { - return myShapeToHypothesis.find(S)!=myShapeToHypothesis.end(); + return myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD))!=myShapeToHypothesis.end(); } //=======================================================================