From 9df5d8add277259cb517730430d4d85b4d642db4 Mon Sep 17 00:00:00 2001 From: szy Date: Fri, 6 Feb 2015 17:26:39 +0300 Subject: [PATCH] Small workaround to avoid consequences of OCCT bug in TopExp::MapShapesAndAncestors. --- src/Model/Model_AttributeSelection.cpp | 32 ++++++++++++++++++++++---- src/Model/Model_ResultBody.cpp | 2 +- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index b6bbd8e15..00111809f 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -384,6 +384,7 @@ void Model_AttributeSelection::selectBody( return; } } + //BRepTools::Write(aNewShape, "Selection0.brep"); aSel.Select(aNewShape, aContext); } @@ -615,8 +616,10 @@ std::string Model_AttributeSelection::namingName() TopoDS_Shape aSubShape = aSubSh->impl(); TopoDS_Shape aContext = aCont->shape()->impl(); #ifdef DEB_NAMING + if(aSubShape.ShapeType() == TopAbs_COMPOUND) { BRepTools::Write(aSubShape, "Selection.brep"); BRepTools::Write(aContext, "Context.brep"); + } #endif std::shared_ptr aDoc = std::dynamic_pointer_cast(aCont->document()); @@ -632,7 +635,11 @@ std::string Model_AttributeSelection::namingName() case TopAbs_EDGE: { // name structure: F1 | F2 [| F3 | F4], where F1 & F2 the faces which gives the Edge in trivial case - // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces + // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces + if (BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) { + aName = "Degenerated_Edge"; + break; + } TopTools_IndexedDataMapOfShapeListOfShape aMap; TopExp::MapShapesAndAncestors(aContext, TopAbs_EDGE, TopAbs_FACE, aMap); TopTools_IndexedMapOfShape aSMap; // map for ancestors of the sub-shape @@ -716,12 +723,24 @@ std::string Model_AttributeSelection::namingName() //n = aList.Extent(); #endif int n = aList.Extent(); - if(n < 3) { // open topology case => via edges + if(n < 3) { // open topology case or Compound case => via edges TopTools_IndexedDataMapOfShapeListOfShape aMap; TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap); - const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape); - if(aList2.Extent() >= 2) { // regular solution - TopTools_ListIteratorOfListOfShape itl(aList2); + const TopTools_ListOfShape& aList22 = aMap.FindFromKey(aSubShape); + if(aList22.Extent() >= 2) { // regular solution +#ifdef FIX_BUG1 + + // bug! duplication; fix is below + aFMap.Clear(); + TopTools_ListOfShape aListE; + TopTools_ListIteratorOfListOfShape itl2(aList22); + for (int i = 1;itl2.More();itl2.Next(),i++) { + if(aFMap.Add(itl2.Value())) + aListE.Append(itl2.Value()); + } + n = aListE.Extent(); +#endif + TopTools_ListIteratorOfListOfShape itl(aListE); for (int i = 1;itl.More();itl.Next(),i++) { const TopoDS_Shape& anEdge = itl.Value(); std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel()); @@ -730,6 +749,9 @@ std::string Model_AttributeSelection::namingName() else aName += "|" + anEdgeName; } + }//reg + else { // dangle vertex: if(aList22.Extent() == 1) + //it should be already in DF } } else { diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index b7c7a0f91..1351c260e 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -33,7 +33,7 @@ // DEB //#include //#include -#define DEB_IMPORT 1 +//#define DEB_IMPORT 1 Model_ResultBody::Model_ResultBody() { -- 2.39.2