Bug 0020228: [CEA 331] the geompy.RemoveExtraEdges crash with the attached brep shape file.

This commit is contained in:
jfa 2009-04-03 08:22:54 +00:00
parent 7cb3d2610b
commit ad5a032fcc

View File

@ -22,7 +22,7 @@
// File: BlockFix_UnionEdges.cxx // File: BlockFix_UnionEdges.cxx
// Created: 07.12.04 15:27:30 // Created: 07.12.04 15:27:30
// Author: Sergey KUUL // Author: Sergey KUUL
//
#include <BlockFix_UnionEdges.ixx> #include <BlockFix_UnionEdges.ixx>
#include <Approx_Curve3d.hxx> #include <Approx_Curve3d.hxx>
@ -169,7 +169,7 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2);
gp_Pnt P01 = C1->Location(); gp_Pnt P01 = C1->Location();
gp_Pnt P02 = C2->Location(); gp_Pnt P02 = C2->Location();
if(P01.Distance(P02)>Precision::Confusion()) continue; if (P01.Distance(P02) > Precision::Confusion()) continue;
// can union circles => create new edge // can union circles => create new edge
TopoDS_Vertex V1 = sae.FirstVertex(edge1); TopoDS_Vertex V1 = sae.FirstVertex(edge1);
gp_Pnt PV1 = BRep_Tool::Pnt(V1); gp_Pnt PV1 = BRep_Tool::Pnt(V1);
@ -177,19 +177,31 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
gp_Pnt PV2 = BRep_Tool::Pnt(V2); gp_Pnt PV2 = BRep_Tool::Pnt(V2);
TopoDS_Vertex VM = sae.LastVertex(edge1); TopoDS_Vertex VM = sae.LastVertex(edge1);
gp_Pnt PVM = BRep_Tool::Pnt(VM); gp_Pnt PVM = BRep_Tool::Pnt(VM);
GC_MakeCircle MC(PV1,PVM,PV2); GC_MakeCircle MC (PV1,PVM,PV2);
Handle(Geom_Circle) C = MC.Value(); Handle(Geom_Circle) C = MC.Value();
gp_Pnt P0 = C->Location();
gp_Dir D1(gp_Vec(P0,PV1));
gp_Dir D2(gp_Vec(P0,PV2));
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
TopoDS_Edge E; TopoDS_Edge E;
B.MakeEdge (E,tc,Precision::Confusion()); if (!MC.IsDone() || C.IsNull()) {
B.Add (E,V1); B.Add (E,V2); // jfa for Mantis issue 0020228
B.UpdateVertex(V1, fpar, E, 0.); if (PV1.Distance(PV2) > Precision::Confusion()) continue;
B.UpdateVertex(V2, lpar, E, 0.); // closed chain
C = C1;
B.MakeEdge (E,C,Precision::Confusion());
B.Add(E,V1);
B.Add(E,V2);
}
else {
gp_Pnt P0 = C->Location();
gp_Dir D1(gp_Vec(P0,PV1));
gp_Dir D2(gp_Vec(P0,PV2));
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
B.MakeEdge (E,tc,Precision::Confusion());
B.Add(E,V1);
B.Add(E,V2);
B.UpdateVertex(V1, fpar, E, 0.);
B.UpdateVertex(V2, lpar, E, 0.);
}
ShapeFix_Edge sfe; ShapeFix_Edge sfe;
sfe.FixAddPCurve(E,aFace,Standard_False); sfe.FixAddPCurve(E,aFace,Standard_False);
sfe.FixSameParameter(E); sfe.FixSameParameter(E);
@ -198,11 +210,11 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
j--; j--;
} }
} }
if(j<aChain.Length()) { if (j < aChain.Length()) {
MESSAGE ("null curve3d in edge..."); MESSAGE ("null curve3d in edge...");
return Standard_False; return Standard_False;
} }
if(aChain.Length()>1) { if (aChain.Length() > 1) {
// second step: union edges with various curves // second step: union edges with various curves
// skl for bug 0020052 from Mantis: perform such unions // skl for bug 0020052 from Mantis: perform such unions
// only if curves are bspline or bezier // only if curves are bspline or bezier