X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelection.cpp;h=cab45489b05f4e184edba3bb7adee9b546f02a23;hb=f4a151eefd549e40307125cf088652d31d92a01e;hp=e2db4ae207114bfc744606a8ec116953742ade14;hpb=f15b088eb4ce09ba9740bd614398c8048916a17c;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index e2db4ae20..cab45489b 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -819,12 +819,21 @@ const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTool //fill maps TopTools_ListIteratorOfListOfShape it(theList); for(int i = 0;it.More();it.Next(),i++) { - const TopoDS_Shape& aFace = it.Value(); - TopExp_Explorer anExp (aFace, theType); - for(;anExp.More();anExp.Next()) { - const TopoDS_Shape& anEdge = anExp.Current(); - if (!anEdge.IsNull()) - aVec[i].Add(anExp.Current()); + const TopoDS_Shape& aFace = it.Value(); + if(i < 2) { + TopExp_Explorer anExp (aFace, theType); + for(;anExp.More();anExp.Next()) { + const TopoDS_Shape& anEdge = anExp.Current(); + if (!anEdge.IsNull()) + aVec[i].Add(anExp.Current()); + } + } else { + TopExp_Explorer anExp (aFace, TopAbs_VERTEX); + for(;anExp.More();anExp.Next()) { + const TopoDS_Shape& aVertex = anExp.Current(); + if (!aVertex.IsNull()) + aVec[i].Add(anExp.Current()); + } } } //trivial case: 2 faces @@ -844,8 +853,18 @@ const TopoDS_Shape findCommonShape(const TopAbs_ShapeEnum theType, const TopTool TopTools_ListIteratorOfListOfShape it(aList); for(;it.More();it.Next()) { const TopoDS_Shape& aCand = it.Value(); - // not yet implemented - + // not yet completelly implemented, to be rechecked + TopoDS_Vertex aV1, aV2; + TopExp::Vertices(TopoDS::Edge(aCand), aV1, aV2); + int aNum(0); + if(aVec[2].Contains(aV1)) aNum++; + else if(aVec[2].Contains(aV2)) aNum++; + if(aVec[3].Contains(aV1)) aNum++; + else if(aVec[3].Contains(aV2)) aNum++; + if(aNum == 2) { + aShape = aCand; + break; + } } } } @@ -987,3 +1006,20 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const } } + +int Model_AttributeSelection::Id() +{ + std::shared_ptr aSelection = value(); + std::shared_ptr aContext = context()->shape(); + const TopoDS_Shape& aMainShape = aContext->impl(); + const TopoDS_Shape& aSubShape = aSelection->impl(); + int anID = 0; + if (aSelection && !aSelection->isNull() && + aContext && !aContext->isNull()) + { + TopTools_IndexedMapOfShape aSubShapesMap; + TopExp::MapShapes(aMainShape, aSubShapesMap); + anID = aSubShapesMap.FindIndex(aSubShape); + } + return anID; +}