From af20c2c02dcffaacd238af5482f182b36f4a39df Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 31 Jan 2014 13:25:13 +0000 Subject: [PATCH] patch for crash in channel --- src/HYDROData/HYDROData_Pipes.cxx | 36 ++++++++++++++++++++++++++----- src/HYDROData/HYDROData_Pipes.h | 11 ++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/HYDROData/HYDROData_Pipes.cxx b/src/HYDROData/HYDROData_Pipes.cxx index 997f8a20..2427ba03 100644 --- a/src/HYDROData/HYDROData_Pipes.cxx +++ b/src/HYDROData/HYDROData_Pipes.cxx @@ -960,7 +960,7 @@ static void addEdgeRelation(TopTools_DataMapOfShapeShape& theMap, HYDROData_Canal3dAnd2d::HYDROData_Canal3dAnd2d(const TopoDS_Wire& Profile, const TopoDS_Wire& Guideline) - : myProfile(Profile), myOriginalGuideline(Guideline) + : myProfile(Profile), myOriginalGuideline(Guideline), myStatus(0) { TopExp::Vertices(myProfile, myLeftVertex, myRightVertex); gp_Pnt LeftPoint = BRep_Tool::Pnt(myLeftVertex); @@ -974,10 +974,15 @@ HYDROData_Canal3dAnd2d::HYDROData_Canal3dAnd2d(const TopoDS_Wire& Profile, else myGuideline = myOriginalGuideline; - ProjectWireOntoXOY(myGuideline, myProjectedGuideline); - Make2dProfile(); - SetMiddlePoint2d(); - SetMiddlePoint3d(); + if (myStatus == 0) + { + if (ProjectWireOntoXOY(myGuideline, myProjectedGuideline)) + { + Make2dProfile(); + SetMiddlePoint2d(); + SetMiddlePoint3d(); + } + } } void HYDROData_Canal3dAnd2d::MakeSharpVertexList() @@ -1042,10 +1047,14 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet() TopoDS_Wire LocalWire = BRepLib_MakeWire(anEdge1, anEdge2); //if ( !takePlane(anEdge1, anEdge2, aV, aPlane) ) if (!PlaneOfWire(LocalWire, aPlane)) + { + myStatus = 1; return Standard_False; // seems edges does not belong to same plane or parallel (fillet can not be build) + } GEOMImpl_Fillet1d aFilletAlgo (anEdge1, anEdge2, aPlane); if (!aFilletAlgo.Perform(myFilletRadius)) { + myStatus = 2; return Standard_False; //can not create fillet at this vertex with given radius } @@ -1053,6 +1062,7 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet() TopoDS_Edge aModifE1, aModifE2; TopoDS_Edge aNewE = aFilletAlgo.Result(BRep_Tool::Pnt(aV), aModifE1, aModifE2); if (aNewE.IsNull()) { + myStatus = 3; return Standard_False; //fillet failed at this vertex } @@ -1068,6 +1078,7 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet() } if (anEdgeToEdgeMap.IsEmpty() && aListOfNewEdge.IsEmpty()) { + myStatus = 4; return Standard_False; //fillet can't be computed on the given shape with the given radius } @@ -1108,7 +1119,10 @@ Standard_Boolean HYDROData_Canal3dAnd2d::ProjectWireOntoXOY(const TopoDS_Wire& a OrtProj.BuildWire(Wires); if (Wires.Extent() != 1) + { + myStatus = 5; return Standard_False; + } ProjectedWire = TopoDS::Wire(Wires.First()); return Standard_True; @@ -1226,7 +1240,10 @@ Standard_Boolean HYDROData_Canal3dAnd2d::Create3dPresentation() /////////////////////// mySweep3d->Build(); if (!mySweep3d->IsDone()) + { + myStatus = 6; return Standard_False; + } myPipe3d = mySweep3d->Shape(); return Standard_True; @@ -1245,7 +1262,10 @@ Standard_Boolean HYDROData_Canal3dAnd2d::Create2dPresentation() /////////////////////// mySweep2d->Build(); if (!mySweep2d->IsDone()) + { + myStatus = 7; return Standard_False; + } myPipe2d = mySweep2d->Shape(); myUnifier.Initialize(myPipe2d); @@ -1329,6 +1349,12 @@ TopoDS_Wire HYDROData_Canal3dAnd2d::GetRightBank() return GetBank(myRightVertex2d); } +Standard_Integer HYDROData_Canal3dAnd2d::GetStatus() +{ + return myStatus; +} + + /*TopoDS_Wire HYDROData_Canal3dAnd2d::GetRoundedGuideline() { return myGuideline; diff --git a/src/HYDROData/HYDROData_Pipes.h b/src/HYDROData/HYDROData_Pipes.h index 05b1561d..15e1da9a 100644 --- a/src/HYDROData/HYDROData_Pipes.h +++ b/src/HYDROData/HYDROData_Pipes.h @@ -47,6 +47,7 @@ public: TopoDS_Wire GetRightBank(); TopoDS_Wire GetInlet(); TopoDS_Wire GetOutlet(); + Standard_Integer GetStatus(); void MakeSharpVertexList(); @@ -79,6 +80,16 @@ private: //TopoDS_Shape myLeftBank; //TopoDS_Shape myRightBank; + Standard_Integer myStatus; + //0 - Ok + //1 - some edges does not belong to same plane or parallel (fillet can not be build) + //2 - can not create fillet at some vertex with given radius: the length of some edge is too small respective to width of canal + //3 - fillet failed at some vertex + //4 - fillet failed + //5 - projection failed + //6 - sweep 3d failed + //7 - sweep 2d failed + Standard_Real myFilletRadius; TopTools_ListOfShape mySharpVertexList; Standard_Real myTolAngular; -- 2.39.2