diff --git a/src/ShapeFix/ShapeFix_IntersectionTool.cxx b/src/ShapeFix/ShapeFix_IntersectionTool.cxx index 9d17b1b6a3..223143eec2 100644 --- a/src/ShapeFix/ShapeFix_IntersectionTool.cxx +++ b/src/ShapeFix/ShapeFix_IntersectionTool.cxx @@ -253,6 +253,8 @@ Standard_Boolean ShapeFix_IntersectionTool::SplitEdge1(const Handle(ShapeExtend_ const Standard_Real preci, ShapeFix_DataMapOfShapeBox2d& boxes) const { + Standard_ASSERT_RETURN (num > 0 && num <= sewd->NbEdges(), "Edge index out of range", Standard_False); + TopoDS_Edge edge = sewd->Edge(num); TopoDS_Edge newE1, newE2; if(!SplitEdge(edge,param,vert,face,newE1,newE2,preci)) return Standard_False; @@ -1801,24 +1803,22 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires } } if( akey1==0 && akey2==0 ) { + int num1split2 = num1; // what edge to split by point 2 if(SplitEdge1(sewd1, face, num1, p11, NewV1, tolV1, boxes1)) { NbModif++; - } - tmpE = sewd1->Edge(num1); - Standard_Real a,b; - Handle(Geom2d_Curve) c2d; - sae.PCurve(tmpE,face,c2d,a,b,Standard_False); - if( (a-p12)*(b-p12)>0 ) { // p12 - external for [a,b] => split next edge - if(SplitEdge1(sewd1, face, num1+1, p12, NewV2, tolV2, boxes1) ) { - NbModif++; - numseg1=num1+1; + tmpE = sewd1->Edge (num1); + Standard_Real a, b; + Handle (Geom2d_Curve) c2d; + sae.PCurve (tmpE, face, c2d, a, b, Standard_False); + if ((a - p12)*(b - p12) > 0) + { // p12 - external for [a,b] => split next edge + num1split2++; } } - else { - if(SplitEdge1(sewd1, face, num1, p12, NewV2, tolV2, boxes1) ) { - NbModif++; - numseg1=num1+1; - } + if (SplitEdge1 (sewd1, face, num1split2, p12, NewV2, tolV2, boxes1)) + { + NbModif++; + numseg1=num1+1; } } SegE = sewd1->Edge(numseg1); // get edge from segment @@ -1885,25 +1885,23 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires } } if( akey1==0 && akey2==0 ) { + int num2split2 = num2; if(SplitEdge1(sewd2, face, num2, p21, NewV1, tolV1, boxes2)) { NbModif++; numseg2=num2+1; - } - tmpE = sewd2->Edge(num2); - Standard_Real a,b; - Handle(Geom2d_Curve) c2d; - sae.PCurve(tmpE,face,c2d,a,b,Standard_False); - if( (a-p22)*(b-p22)>0 ) { // p22 - external for [a,b] => split next edge - if(SplitEdge1(sewd2, face, num2+1, p22, NewV2, tolV2, boxes2) ) { - NbModif++; - numseg2=num2+1; + tmpE = sewd2->Edge (num2); + Standard_Real a, b; + Handle (Geom2d_Curve) c2d; + sae.PCurve (tmpE, face, c2d, a, b, Standard_False); + if ((a - p22)*(b - p22) > 0) + { // p22 - external for [a,b] => split next edge + num2split2++; } } - else { - if(SplitEdge1(sewd2, face, num2, p22, NewV2, tolV2, boxes2) ) { - NbModif++; - numseg2=num2+1; - } + if (SplitEdge1 (sewd2, face, num2split2, p22, NewV2, tolV2, boxes2)) + { + NbModif++; + numseg2 = num2 + 1; } } tmpE = sewd2->Edge(numseg2); diff --git a/tests/bugs/heal/bug29695 b/tests/bugs/heal/bug29695 new file mode 100644 index 0000000000..df1ac6bad5 --- /dev/null +++ b/tests/bugs/heal/bug29695 @@ -0,0 +1,7 @@ + + +restore [locate_data_file bug29695_badface.brep] a +fixshape result a + +checkshape result +