From b846d1e002c0596c73c8727297bfe24a4a5ec51d Mon Sep 17 00:00:00 2001 From: ika Date: Thu, 14 Jan 2016 15:46:25 +0300 Subject: [PATCH] 0027078: Exception in ShapeFixIntersectionTool::UnionVertexes() Add checks to avoid exceptions. Remove check for small 3D curve, now pcurve will be built for all small edges, which have not been removed by FixSmall. --- src/ShapeFix/ShapeFix_Edge.cxx | 2 +- src/ShapeFix/ShapeFix_IntersectionTool.cxx | 48 ++++++++++++++-------- tests/bugs/heal/bug27078 | 8 ++++ tests/de/iges_2/I7 | 11 ++--- 4 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 tests/bugs/heal/bug27078 diff --git a/src/ShapeFix/ShapeFix_Edge.cxx b/src/ShapeFix/ShapeFix_Edge.cxx index 639e7173f8..6a68768d00 100644 --- a/src/ShapeFix/ShapeFix_Edge.cxx +++ b/src/ShapeFix/ShapeFix_Edge.cxx @@ -466,7 +466,7 @@ Standard_Boolean ShapeFix_Edge::FixAddPCurve (const TopoDS_Edge& edge, Standard_Real preci = ( prec >0. ? prec : BRep_Tool::Tolerance(edge) ); Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge, /*Loc,*/ First, Last); // Handle(Geom_Curve) c3d = BRep_Tool::Curve(E, First, Last); - if (c3d.IsNull() || (Abs(Last-First) Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V21L.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge21,V21F,V1F); //NewE = sbe.CopyReplaceVertices(edge21,V21F,V); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V22F.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge22,V1F,V22L); //NewE = sbe.CopyReplaceVertices(edge22,V,V22L); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } if(V22L.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge22,V22F,V1F); //NewE = sbe.CopyReplaceVertices(edge22,V22F,V); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } @@ -545,28 +549,32 @@ Standard_Boolean ShapeFix_IntersectionTool::UnionVertexes(const Handle(ShapeExte if(V21F.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge21,V1F,V21L); //NewE = sbe.CopyReplaceVertices(edge21,V,V21L); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V21L.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge21,V21F,V1F); //NewE = sbe.CopyReplaceVertices(edge21,V21F,V); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V22F.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge22,V1F,V22L); //NewE = sbe.CopyReplaceVertices(edge22,V,V22L); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } if(V22L.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge22,V22F,V1F); //NewE = sbe.CopyReplaceVertices(edge22,V22F,V); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } @@ -604,28 +612,32 @@ Standard_Boolean ShapeFix_IntersectionTool::UnionVertexes(const Handle(ShapeExte if(V21F.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge21,V1L,V21L); //NewE = sbe.CopyReplaceVertices(edge21,V,V21L); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V21L.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge21,V21F,V1L); //NewE = sbe.CopyReplaceVertices(edge21,V21F,V); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V22F.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge22,V1L,V22L); //NewE = sbe.CopyReplaceVertices(edge22,V,V22L); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } if(V22L.IsSame(V2F)) { NewE = sbe.CopyReplaceVertices(edge22,V22F,V1L); //NewE = sbe.CopyReplaceVertices(edge22,V22F,V); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } @@ -663,28 +675,32 @@ Standard_Boolean ShapeFix_IntersectionTool::UnionVertexes(const Handle(ShapeExte if(V21F.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge21,V1L,V21L); //NewE = sbe.CopyReplaceVertices(edge21,V,V21L); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V21L.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge21,V21F,V1L); //NewE = sbe.CopyReplaceVertices(edge21,V21F,V); - boxes.Bind(NewE,boxes.Find(edge21)); // update boxes + if (boxes.IsBound(edge21)) + boxes.Bind(NewE,boxes.Find(edge21)); // update boxes myContext->Replace(edge21,NewE); sewd->Set(NewE,num21); } if(V22F.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge22,V1L,V22L); //NewE = sbe.CopyReplaceVertices(edge22,V,V22L); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } if(V22L.IsSame(V2L)) { NewE = sbe.CopyReplaceVertices(edge22,V22F,V1L); //NewE = sbe.CopyReplaceVertices(edge22,V22F,V); - boxes.Bind(NewE,boxes.Find(edge22)); // update boxes + if (boxes.IsBound(edge22)) + boxes.Bind(NewE,boxes.Find(edge22)); // update boxes myContext->Replace(edge22,NewE); sewd->Set(NewE,num22); } diff --git a/tests/bugs/heal/bug27078 b/tests/bugs/heal/bug27078 new file mode 100644 index 0000000000..2f532c36e9 --- /dev/null +++ b/tests/bugs/heal/bug27078 @@ -0,0 +1,8 @@ +################################################################## +# OCC27078: Exception in ShapeFixIntersectionTool::UnionVertexes() +################################################################## + +testreadiges [locate_data_file bug27078.igs] a + +# fixshape should not throw an exception +fixshape result a diff --git a/tests/de/iges_2/I7 b/tests/de/iges_2/I7 index bef85b6642..32fdf204b4 100644 --- a/tests/de/iges_2/I7 +++ b/tests/de/iges_2/I7 @@ -1,7 +1,8 @@ # !!!! This file is generated automatically, do not edit manually! See end script +puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" +puts "TODO CR23096 ALL: NBSHAPES : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: COLORS : Faulty" -puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" set filename ims016.igs @@ -9,10 +10,10 @@ set filename ims016.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) TPSTAT : Faulties = 0 ( 0 ) Warnings = 120 ( 402 ) Summary = 120 ( 402 ) -CHECKSHAPE : Wires = 4 ( 0 ) Faces = 2 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) Summary = 10599 ( 10569 ) -STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) FreeWire = 6 ( 6 ) FreeEdge = 353 ( 353 ) SharedEdge = 4953 ( 4953 ) -TOLERANCE : MaxTol = 0.2092687841 ( 0.2092687804 ) AvgTol = 0.0009010196362 ( 0.0009882759183 ) +CHECKSHAPE : Wires = 2 ( 0 ) Faces = 2 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) Summary = 10567 ( 10569 ) +STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) FreeWire = 6 ( 6 ) FreeEdge = 353 ( 353 ) SharedEdge = 4951 ( 4953 ) +TOLERANCE : MaxTol = 0.2092687841 ( 0.2092687804 ) AvgTol = 0.001094782521 ( 0.0009882759182 ) LABELS : N0Labels = 503 ( 503 ) N1Labels = 0 ( 200 ) N2Labels = 0 ( 0 ) TotalLabels = 503 ( 703 ) NameLabels = 503 ( 503 ) ColorLabels = 470 ( 703 ) LayerLabels = 313 ( 344 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 6 ( 7 )