From 9d1c5188ae08280dda71f3e98db6a7223d6aec10 Mon Sep 17 00:00:00 2001 From: emv Date: Thu, 3 Oct 2013 14:20:54 +0400 Subject: [PATCH] 0024213: bopargcheck complains on sphere Added check for degenerated edges. Test case for issue CR24213 --- src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx | 47 +++++++++++++----------- tests/bugs/modalg_5/bug24213 | 17 +++++++++ 2 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 tests/bugs/modalg_5/bug24213 diff --git a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx index 44349abccc..fe1d2e27ef 100644 --- a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx +++ b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx @@ -304,7 +304,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences() Standard_Boolean bSelfInt; for(ii = 0; ii < 2; ii++) { - TopoDS_Shape aS = (ii == 0) ? myShape1 : myShape2; + const TopoDS_Shape& aS = (ii == 0) ? myShape1 : myShape2; if(aS.IsNull()) continue; @@ -431,7 +431,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() aCtx = new BOPInt_Context; for(i = 0; i < 2; i++) { - TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2; + const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2; if(aS.IsNull()) continue; @@ -439,13 +439,16 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() TopExp_Explorer anExp(aS, TopAbs_EDGE); for(; anExp.More(); anExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current()); + const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&anExp.Current(); + if (BRep_Tool::Degenerated(anEdge)) { + continue; + } if(BOPTools_AlgoTools::IsMicroEdge(anEdge, aCtx)) { Standard_Boolean bKeepResult = Standard_True; if(myOperation == BOPAlgo_SECTION) { - TopoDS_Shape anOtherS = (i == 0) ? myShape2 : myShape1; + const TopoDS_Shape& anOtherS = (i == 0) ? myShape2 : myShape1; if(!anOtherS.IsNull()) { aDist.LoadS2(anOtherS); @@ -455,7 +458,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX); for(; anExpV.More(); anExpV.Next()) { - TopoDS_Shape aV = anExpV.Current(); + const TopoDS_Shape& aV = anExpV.Current(); aDist.LoadS1(aV); aDist.Perform(); @@ -463,20 +466,20 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge() if(aDist.IsDone()) { for(ii = 1; ii <= aDist.NbSolution(); ii++) { - Standard_Real aTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(aV)); - TopoDS_Shape aSupportShape = aDist.SupportOnShape2(ii); + Standard_Real aTolerance = BRep_Tool::Tolerance(*(TopoDS_Vertex*)&aV); + const TopoDS_Shape& aSupportShape = aDist.SupportOnShape2(ii); switch(aSupportShape.ShapeType()) { case TopAbs_VERTEX: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Vertex(aSupportShape)); + aTolerance += BRep_Tool::Tolerance(*(TopoDS_Vertex*)&(aSupportShape)); break; } case TopAbs_EDGE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Edge(aSupportShape)); + aTolerance += BRep_Tool::Tolerance(*(TopoDS_Edge*)&(aSupportShape)); break; } case TopAbs_FACE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Face(aSupportShape)); + aTolerance += BRep_Tool::Tolerance(*(TopoDS_Face*)&(aSupportShape)); break; } default: @@ -533,7 +536,7 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace() Standard_Integer i = 0; for(i = 0; i < 2; i++) { - TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2; + const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2; if(aS.IsNull()) continue; @@ -542,7 +545,7 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace() BOPCol_ListOfShape aLS; for(; anExp.More(); anExp.Next()) { - TopoDS_Face aFace = TopoDS::Face(anExp.Current()); + const TopoDS_Face& aFace = *(TopoDS_Face*)&(anExp.Current()); TopoDS_Face aFF = aFace; aFF.Orientation(TopAbs_FORWARD); @@ -655,7 +658,7 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() BOPCol_MapOfShape aMap1, aMap2; for(; anExp1.More(); anExp1.Next()) { - TopoDS_Shape aS1 = anExp1.Current(); + const TopoDS_Shape& aS1 = anExp1.Current(); if(aMap1.Contains(aS1)) continue; @@ -664,7 +667,7 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() } for(; anExp2.More(); anExp2.Next()) { - TopoDS_Shape aS2 = anExp2.Current(); + const TopoDS_Shape& aS2 = anExp2.Current(); if(aMap2.Contains(aS2)) continue; aSeq2.Append(aS2); @@ -678,18 +681,18 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() anArrayOfFlag.SetValue(i, j, Standard_False); for(i = 1; i <= aSeq1.Length(); i++) { - TopoDS_Shape aS1 = aSeq1.Value(i); + const TopoDS_Shape& aS1 = aSeq1.Value(i); BOPCol_ListOfShape aListOfS2; Standard_Integer nbs = 0; for(j = 1; j <= aSeq2.Length(); j++) { - TopoDS_Shape aS2 = aSeq2.Value(j); + const TopoDS_Shape& aS2 = aSeq2.Value(j); Standard_Boolean bIsEqual = Standard_False; if(theType == TopAbs_VERTEX) { - TopoDS_Vertex aV1 = TopoDS::Vertex(aS1); - TopoDS_Vertex aV2 = TopoDS::Vertex(aS2); + const TopoDS_Vertex& aV1 = *(TopoDS_Vertex*)&(aS1); + const TopoDS_Vertex& aV2 = *(TopoDS_Vertex*)&(aS2); gp_Pnt aP1 = BRep_Tool::Pnt(aV1); gp_Pnt aP2 = BRep_Tool::Pnt(aV2); Standard_Real aDist = aP1.Distance(aP2); @@ -701,8 +704,8 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() else if(theType == TopAbs_EDGE) { Standard_Integer aDiscretize = 30; Standard_Real aDeflection = 0.01; - TopoDS_Edge aE1 = TopoDS::Edge(aS1); - TopoDS_Edge aE2 = TopoDS::Edge(aS2); + const TopoDS_Edge& aE1 = *(TopoDS_Edge*)&(aS1); + const TopoDS_Edge& aE2 = *(TopoDS_Edge*)&(aS2); IntTools_EdgeEdge aEE; aEE.SetEdge1 (aE1); @@ -767,12 +770,12 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent() } for(i = 1; i <= aSeq2.Length(); i++) { - TopoDS_Shape aS2 = aSeq2.Value(i); + const TopoDS_Shape& aS2 = aSeq2.Value(i); BOPCol_ListOfShape aListOfS1; Standard_Integer nbs = 0; for(j = 1; j <= aSeq1.Length(); j++) { - TopoDS_Shape aS1 = aSeq1.Value(j); + const TopoDS_Shape& aS1 = aSeq1.Value(j); if(anArrayOfFlag.Value(j, i)) { aListOfS1.Append(aS1); diff --git a/tests/bugs/modalg_5/bug24213 b/tests/bugs/modalg_5/bug24213 new file mode 100644 index 0000000000..b80ed26838 --- /dev/null +++ b/tests/bugs/modalg_5/bug24213 @@ -0,0 +1,17 @@ +puts "============" +puts "OCC24213" +puts "============" +puts "" +###################################################### +# bopargcheck complains on sphere +###################################################### + +psphere s 10 + +set info [bopargcheck s #F] + +if { [regexp "to be valid for BOP" ${info}] != 1 } { + puts "Error : complain of bopargcheck command is not correct" +} else { + puts "OK : bopargcheck command work properly" +}