From: Chris Hennes Date: Sat, 30 Jan 2021 23:58:39 +0000 (-0600) Subject: [PATCH] Add error-checking to chamfer and fillet code X-Git-Tag: archive/raspbian/7.5.2+dfsg1-2+rpi1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2241b5d5ea645e6da2d216518f4aff79f8e8c6e8;p=opencascade.git [PATCH] Add error-checking to chamfer and fillet code Gbp-Pq: Name 0008-Add-error-checking-to-chamfer-and-fillet-code.patch --- diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index de2ff457d..b089d3e4d 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -4394,6 +4394,9 @@ void ChFi3d_cherche_face1 (const TopTools_ListOfShape & map, if (!Fcur.IsSame(F1)) { F=Fcur;trouve=Standard_True;} } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find element."); + } } //======================================================================= //function : cherche_element @@ -4433,6 +4436,9 @@ void ChFi3d_cherche_element(const TopoDS_Vertex & V, } } } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find edge."); + } } //======================================================================= //function : cherche_edge @@ -4477,6 +4483,9 @@ void ChFi3d_cherche_edge(const TopoDS_Vertex & V, } } } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find element."); + } } //======================================================================= diff --git a/src/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ChFi3d/ChFi3d_Builder_C1.cxx index 09a2e1030..8b7e9b260 100644 --- a/src/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_C1.cxx @@ -338,6 +338,7 @@ static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs, return Standard_False; Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul); + if (gpcprol.IsNull()) throw Standard_Failure("Failed to create curve."); Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol); Standard_Real partemp = BRep_Tool::Parameter(Vtx,Eprol); @@ -822,11 +823,13 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, if (onsame && IFopArc == 1) pfac1 = p2dbout; else { Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid); + if (Hc1.IsNull()) throw Standard_Failure("Failed to create curve."); pfac1 = Hc1->Value(CV1.ParameterOnArc()); } if (onsame && IFopArc == 2) pfac2 = p2dbout; else { Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid); + if (Hc2.IsNull()) throw Standard_Failure("Failed to create curve."); pfac2 = Hc2->Value(CV2.ParameterOnArc()); } if (Fi1.LineIndex() != 0) { @@ -868,6 +871,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, //Standard_Real Ubid,Vbid; Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid); + if (C.IsNull()) throw Standard_Failure("Failed to create curve."); Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid); GeomAdaptor_Curve cur1(Ctrim->BasisCurve()); GeomAdaptor_Curve cur2(Cc); @@ -1050,6 +1054,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, Standard_Real first, last, prm1, prm2; Standard_Boolean onfirst, FirstToPar; Handle(Geom2d_Curve) Hc = BRep_Tool::CurveOnSurface( CV[i].Arc(), Fv, first, last ); + if (Hc.IsNull()) throw Standard_Failure("Failed to create curve."); pfac1 = Hc->Value( CV[i].ParameterOnArc() ); PcF = Pc->Value( Udeb ); PcL = Pc->Value( Ufin ); @@ -1101,6 +1106,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, TopoDS_Edge aLocalEdge = CV[i].Arc(); aLocalEdge.Reverse(); Handle(Geom2d_Curve) HcR = BRep_Tool::CurveOnSurface( aLocalEdge, Fv, first, last ); + if (HcR.IsNull()) throw Standard_Failure("Failed to create curve."); Interfc = ChFi3d_FilCurveInDS( indcurv, indface, HcR, aLocalEdge.Orientation() ); DStr.ChangeShapeInterferences(indface).Append( Interfc ); //modify degenerated edge @@ -1126,6 +1132,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, { Standard_Real fd, ld; Handle(Geom2d_Curve) Cd = BRep_Tool::CurveOnSurface( Edeg, Fv, fd, ld ); + if (Cd.IsNull()) throw Standard_Failure("Failed to create curve."); Handle(Geom2d_TrimmedCurve) tCd = Handle(Geom2d_TrimmedCurve)::DownCast(Cd); if (! tCd.IsNull()) Cd = tCd->BasisCurve(); @@ -1244,9 +1251,11 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc); gp_Pnt2d pop1, pop2, pv1, pv2; Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid); + if (Hc.IsNull()) throw Standard_Failure("Failed to create curve."); pop1 = Hc->Value(parVtx); pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst)); Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid); + if (Hc.IsNull()) throw Standard_Failure("Failed to create curve."); pv1 = Hc->Value(parVtx); pv2 = p2dbout; ChFi3d_Recale(Bs,pv1,pv2,1); @@ -1436,6 +1445,9 @@ static void cherche_face (const TopTools_ListOfShape & map, } } } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find face."); + } } //======================================================================= @@ -1466,6 +1478,9 @@ static void cherche_edge1 (const TopoDS_Face & F1, {Edge=Ecur1;trouve=Standard_True;} } } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find edge."); + } } //======================================================================= @@ -2147,6 +2162,7 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index) if (nb==1) { Hc1 = BRep_Tool::CurveOnSurface(Edge[0],Face[0],Ubid,Ubid); + if (Hc1.IsNull()) throw Standard_Failure("Failed to create curve."); if (isOnSame1) { // update interference param on Fi1 and point of CV1 if (prolface[0]) Bs.Initialize(faceprol[0], Standard_False); @@ -2219,6 +2235,7 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index) Handle(Geom_Curve) C; C=BRep_Tool::Curve(E2,Ubid,Vbid); + if (C.IsNull()) throw Standard_Failure("Failed to create curve."); Handle(Geom_TrimmedCurve) Ctrim = new Geom_TrimmedCurve(C,Ubid,Vbid); Standard_Real Utrim,Vtrim; Utrim=Ctrim->BasisCurve()->FirstParameter(); @@ -2344,7 +2361,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index) paredge2=inters.Point(nbp).W(); if (!extend) { cfacemoins1=BRep_Tool::CurveOnSurface(E2,F,u2,v2); + if (cfacemoins1.IsNull()) throw Standard_Failure("Failed to create curve."); cface=BRep_Tool::CurveOnSurface(E2,Face[nb],u2,v2); + if (cface.IsNull()) throw Standard_Failure("Failed to create curve."); cfacemoins1->D0(paredge2,pfac2); cface->D0(paredge2,pint); } @@ -4010,11 +4029,13 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index) if( IFopArc == 1) pfac1 = p2dbout; else { Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid); + if (Hc1.IsNull()) throw Standard_Failure("Failed to create curve."); pfac1 = Hc1->Value(CV1.ParameterOnArc()); } if(IFopArc == 2) pfac2 = p2dbout; else { Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid); + if (Hc2.IsNull()) throw Standard_Failure("Failed to create curve."); pfac2 = Hc2->Value(CV2.ParameterOnArc()); } if(Fi1.LineIndex() != 0){ @@ -4054,6 +4075,7 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index) //Standard_Real Ubid,Vbid; Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid); + if (C.IsNull()) throw Standard_Failure("Failed to create curve."); Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid); GeomAdaptor_Curve cur1(Ctrim->BasisCurve()); GeomAdaptor_Curve cur2(Cc); @@ -4284,9 +4306,11 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index) // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End //fin modif Hc = BRep_Tool::CurveOnSurface(Arcprolbis,Fop,Ubid,Ubid); + if (Hc.IsNull()) throw Standard_Failure("Failed to create curve."); pop1 = Hc->Value(parVtx); pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst)); Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid); + if (Hc.IsNull()) throw Standard_Failure("Failed to create curve."); //modif parVtx = BRep_Tool::Parameter(Vtx,Arcprol); //fin modif diff --git a/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx b/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx index e8087c1cd..a04497a6a 100644 --- a/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx +++ b/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx @@ -291,6 +291,9 @@ static void cherche_edge1 (const TopoDS_Face & F1, {Edge=Ecur1;trouve=Standard_True;} } } + if (trouve == Standard_False) { + throw Standard_Failure("Failed to find edge."); + } } //======================================================================= @@ -332,6 +335,7 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr, Handle (Geom_Curve) c1,c2; if (sharpicmoins) { c1=BRep_Tool::Curve(Eviveicmoins,up1,up2); + if (c1.IsNull()) throw Standard_Failure("Failed to create curve."); } else { if (jficmoins==1) @@ -341,6 +345,7 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr, } if (sharpicplus){ c2=BRep_Tool::Curve(Eviveicplus,up1,up2); + if (c2.IsNull()) throw Standard_Failure("Failed to create curve."); } else { jfp=3-jficplus; @@ -414,8 +419,10 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr, } Eproj.Append(E1); proj1=BRep_Tool::CurveOnSurface(E1,F,up1,up2); + if (proj1.IsNull()) throw Standard_Failure("Failed to create curve."); proj2d.Append(new Geom2d_TrimmedCurve(proj1,up1,up2)); proj1c=BRep_Tool::Curve(E1,up1,up2); + if (proj1c.IsNull()) throw Standard_Failure("Failed to create curve."); cproj.Append(new Geom_TrimmedCurve(proj1c,up1,up2)); if (error>BRep_Tool::Tolerance(E1)) error=BRep_Tool::Tolerance(E1); } @@ -2459,15 +2466,20 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex, Pf=BRep_Tool::Pnt(Vf); Pl=BRep_Tool::Pnt(Vl); para=parcom.Value(nb); - Pcom=BRep_Tool::Curve(TopoDS::Edge(Ecom.Value(nb)),up1,up2)->Value(para); + Handle(Geom_Curve) result = BRep_Tool::Curve(TopoDS::Edge(Ecom.Value(nb)),up1,up2); + if (result.IsNull()) throw Standard_Failure("Failed to create curve."); + Pcom=result->Value(para); + if (Pf.Distance(BRep_Tool::Pnt(V1))< Pl.Distance(BRep_Tool::Pnt(V1))) orvt=TopAbs_FORWARD; if (!Eproj.Value(nb).IsNull()) { n3d++; proj=BRep_Tool::CurveOnSurface(TopoDS::Edge(Eproj.Value(nb)), TopoDS::Face(Fproj.Value(nb)),up1,up2); + if (proj.IsNull()) throw Standard_Failure("Failed to create curve."); proj2d=new Geom2d_TrimmedCurve(proj,up1,up2); projc=BRep_Tool::Curve(TopoDS::Edge(Eproj.Value(nb)),up1,up2); + if (projc.IsNull()) throw Standard_Failure("Failed to create curve."); cproj=new Geom_TrimmedCurve(projc,up1,up2); pardeb=cproj->FirstParameter(); parfin=cproj->LastParameter();