diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index ab008b7db5..441b5d6c07 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -33,23 +33,16 @@ # include # include # include -# include # include # include # include -# include -# include -# include -# include -# include -# include -# include # include # include # include # include # include # include +# include # include # include # include @@ -2119,70 +2112,28 @@ gp_Pnt AttachEnginePoint::getProximityPoint(eMapMode mmode, const TopoDS_Shape& BRepAdaptor_Curve crv(TopoDS::Edge(edge)); GeomAdaptor_Curve typedcrv; - - switch(crv.GetType()) { - case GeomAbs_Line: - { - Handle(Geom_Line) geomt = new Geom_Line(crv.Line()); - typedcrv.Load(geomt); - break; - } - case GeomAbs_Circle: - { - Handle(Geom_Circle) geomt = new Geom_Circle(crv.Circle()); - typedcrv.Load(geomt); - break; - } - case GeomAbs_Ellipse: - { - Handle(Geom_Ellipse) geomt = new Geom_Ellipse(crv.Ellipse()); - typedcrv.Load(geomt); - break; - } - case GeomAbs_Hyperbola: - { - Handle(Geom_Hyperbola) geomt = new Geom_Hyperbola(crv.Hyperbola()); - typedcrv.Load(geomt); - break; - } - case GeomAbs_Parabola: - { - Handle(Geom_Parabola) geomt = new Geom_Parabola(crv.Parabola()); - typedcrv.Load(geomt); - break; - } - case GeomAbs_BezierCurve: - { - Handle(Geom_BezierCurve) geomt = crv.Bezier(); - typedcrv.Load(geomt); - break; - } - case GeomAbs_BSplineCurve: - { - Handle(Geom_BSplineCurve) geomt = crv.BSpline(); - typedcrv.Load(geomt); - break; - } - #if OCC_VERSION_HEX >= 0x070000 - case GeomAbs_OffsetCurve: - #endif - case GeomAbs_OtherCurve: - Base::Console().Warning("AttachEnginePoint::getProximityPoint curve not supported, intersection may not work properly"); - typedcrv = crv.Curve(); - break; + try { + // Important note about BRepIntCurveSurface_Inter and GeomAdaptor_Curve + // + // A GeomAdaptor_Curve obtained directly from BRepAdaptor_Curve will lose the information + // about Location/orientation of the edge. + // + // That's why GeomAdaptor::MakeCurve() is used to create a new geometry with the + // transformation applied. + typedcrv.Load(GeomAdaptor::MakeCurve(crv)); + } + catch (const Standard_DomainError&) { + Handle(Geom_Curve) curve = crv.Curve().Curve(); + if (curve.IsNull()) { + // Can this ever happen? + typedcrv = crv.Curve(); + } + else { + curve = Handle(Geom_Curve)::DownCast(curve->Copy()); + curve->Transform(crv.Trsf()); + typedcrv.Load(curve); + } } - - // Important note about BRepIntCurveSurface_Inter and GeomAdaptor_Curve - // - // In OCCT 7.4 (and apparently <= 7.4 too): - // - // A GeomAdaptor_Curve obtained directly from BRepAdaptor_Curve will not work because it won't respect the - // Location/orientation of the underlying curve. - // - // This is why the code above is necessary to generate an intermediary curve handle, from which to get an - // GeomAdaptor_Curve that will maintain the location and orientation. - // - // To test this apparent OCCT bug, just change in intCS.Init below typedcrv with crv.Curve(). BRepIntCurveSurface_Inter intCS; intCS.Init(face, typedcrv, Precision::Confusion());