From e7485effb4fa527c47b79e95b3881764720fded6 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Tue, 11 Sep 2018 23:52:45 +0300 Subject: [PATCH] Part, PartDesign, Attacher: fix a few problems with infinite shapes To throw an error instead of returning a semi-infinite result that kills rendering. fixes #3439 --- src/Mod/Part/App/Attacher.cpp | 15 ++++++++++----- src/Mod/PartDesign/App/DatumLine.cpp | 4 +++- src/Mod/PartDesign/App/DatumPlane.cpp | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index 0fa765ff6f..9974c90363 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -800,8 +800,9 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references, geof->Placement.getValue().multVec(Base::Vector3d(),org); //make shape - an local-XY plane infinite face gp_Pln pl = gp_Pln(gp_Pnt(org.x, org.y, org.z), gp_Dir(norm.x, norm.y, norm.z)); - BRepBuilderAPI_MakeFace builder(pl); - storage.push_back( builder.Shape() ); + TopoDS_Shape myShape = BRepBuilderAPI_MakeFace(pl).Shape(); + myShape.Infinite(true); + storage.push_back(myShape); shapes[i] = &(storage[storage.size()-1]); } else if ( geof->isDerivedFrom(App::Line::getClassTypeId()) ){ //obtain X axis and origin of placement @@ -812,8 +813,9 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references, geof->Placement.getValue().multVec(Base::Vector3d(),org); //make shape - an infinite line along local X axis gp_Lin l = gp_Lin(gp_Pnt(org.x, org.y, org.z), gp_Dir(dir.x, dir.y, dir.z)); - BRepBuilderAPI_MakeEdge builder(l); - storage.push_back( builder.Shape() ); + TopoDS_Shape myShape = BRepBuilderAPI_MakeEdge(l).Shape(); + myShape.Infinite(true); + storage.push_back(myShape); shapes[i] = &(storage[storage.size()-1]); } else { Base::Console().Warning("Attacher: linked object %s is unexpected, assuming it has no shape.\n",geof->getNameInDocument()); @@ -2011,7 +2013,10 @@ Base::Placement AttachEnginePoint::calculateAttachedPlacement(Base::Placement or } else if (sh.ShapeType() == TopAbs_EDGE) { const TopoDS_Edge &e = TopoDS::Edge(sh); BRepAdaptor_Curve crv(e); - BasePoint = crv.Value(crv.FirstParameter()); + double u = crv.FirstParameter(); + if(Precision::IsInfinite(u)) + throw Base::ValueError("Edge is infinite"); + BasePoint = crv.Value(u); } }break; diff --git a/src/Mod/PartDesign/App/DatumLine.cpp b/src/Mod/PartDesign/App/DatumLine.cpp index 618c6704f8..777468a48f 100644 --- a/src/Mod/PartDesign/App/DatumLine.cpp +++ b/src/Mod/PartDesign/App/DatumLine.cpp @@ -44,7 +44,9 @@ Line::Line() BRepBuilderAPI_MakeEdge builder(gp_Lin(gp_Pnt(0,0,0), gp_Dir(0,0,1))); if (!builder.IsDone()) return; - Shape.setValue(builder.Shape()); + TopoDS_Shape myShape = builder.Shape(); + myShape.Infinite(Standard_True); + Shape.setValue(myShape); Support.touch(); } diff --git a/src/Mod/PartDesign/App/DatumPlane.cpp b/src/Mod/PartDesign/App/DatumPlane.cpp index 66d8345b77..8f301d9634 100644 --- a/src/Mod/PartDesign/App/DatumPlane.cpp +++ b/src/Mod/PartDesign/App/DatumPlane.cpp @@ -60,7 +60,9 @@ Plane::Plane() BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(0,0,1))); if (!builder.IsDone()) return; - Shape.setValue(builder.Shape()); + TopoDS_Shape myShape = builder.Shape(); + myShape.Infinite(Standard_True); + Shape.setValue(myShape); } Plane::~Plane()