From: mpv Date: Wed, 25 Mar 2015 13:44:14 +0000 (+0300) Subject: Make the correct order in the searching of shape by name algorithm X-Git-Tag: V_1.1.0~78^2~1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e0c2fdad66f1a242309a66363dd91eb1e35896c3;p=modules%2Fshaper.git Make the correct order in the searching of shape by name algorithm --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index a87cea536..d19f2d6d1 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -796,8 +796,8 @@ TopAbs_ShapeEnum translateType (const std::string& theType) return TopAbs_SHAPE; } -const TopoDS_Shape getShapeFromCompound( - const std::string& theSubShapeName, const TopoDS_Shape& theCompound) +const TopoDS_Shape getShapeFromNS( + const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS) { TopoDS_Shape aSelection; std::string::size_type n = theSubShapeName.rfind('/'); @@ -807,13 +807,12 @@ const TopoDS_Shape getShapeFromCompound( if (n == std::string::npos) return aSelection; aSubString = aSubString.substr(n+1); int indx = atoi(aSubString.c_str()); - TopoDS_Iterator it(theCompound); - for (int i = 1;it.More();it.Next(), i++) { - if(i == indx) { - aSelection = it.Value(); - break; + + TNaming_Iterator anItL(theNS); + for(int i = 1; anItL.More(); anItL.Next(), i++) { + if (i == indx) { + return anItL.NewShape(); } - else continue; } return aSelection; } @@ -837,13 +836,7 @@ const TopoDS_Shape findFaceByName( if(aLabel.IsNull()) return aFace; Handle(TNaming_NamedShape) aNS; if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - const TopoDS_Shape& aShape = aNS->Get(); - if(!aShape.IsNull()) { - if(aShape.ShapeType() == TopAbs_COMPOUND) - aFace = getShapeFromCompound(theSubShapeName, aShape); - else - aFace = aShape; - } + aFace = getShapeFromNS(theSubShapeName, aNS); } return aFace; } @@ -1002,13 +995,7 @@ void Model_AttributeSelection::selectSubShape( if(!aLabel.IsNull()) { Handle(TNaming_NamedShape) aNS; if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - const TopoDS_Shape& aShape = aNS->Get(); - if(!aShape.IsNull()) { - if(aShape.ShapeType() == TopAbs_COMPOUND) - aSelection = getShapeFromCompound(theSubShapeName, aShape); - else - aSelection = aShape; - } + aSelection = getShapeFromNS(theSubShapeName, aNS); } } if(aSelection.IsNull()) { @@ -1038,13 +1025,7 @@ void Model_AttributeSelection::selectSubShape( if(!aLabel.IsNull()) { Handle(TNaming_NamedShape) aNS; if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - const TopoDS_Shape& aShape = aNS->Get(); - if(!aShape.IsNull()) { - if(aShape.ShapeType() == TopAbs_COMPOUND) - aSelection = getShapeFromCompound(theSubShapeName, aShape); - else - aSelection = aShape; - } + aSelection = getShapeFromNS(theSubShapeName, aNS); } } if(aSelection.IsNull()) {