Skip to content

Commit

Permalink
Part: [skip ci] fixes #4169: DatumPoint at the intersection of a Datu…
Browse files Browse the repository at this point in the history
…mPlane and DatumPoint not working correctly
  • Loading branch information
wwmayer committed Nov 27, 2020
1 parent 11c3de1 commit 0e93dd1
Showing 1 changed file with 20 additions and 69 deletions.
89 changes: 20 additions & 69 deletions src/Mod/Part/App/Attacher.cpp
Expand Up @@ -33,23 +33,16 @@
# include <gp_Ax1.hxx>
# include <gp_Pnt.hxx>
# include <gp_Dir.hxx>
# include <gp_Circ.hxx>
# include <gp_Elips.hxx>
# include <gp_Parab.hxx>
# include <gp_Hypr.hxx>
# include <Geom_Line.hxx>
# include <Geom_Circle.hxx>
# include <Geom_Ellipse.hxx>
# include <Geom_Hyperbola.hxx>
# include <Geom_Parabola.hxx>
# include <Geom_BezierCurve.hxx>
# include <Geom_BSplineCurve.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
# include <Geom_Plane.hxx>
# include <Geom2d_Curve.hxx>
# include <Geom2dAPI_InterCurveCurve.hxx>
# include <Geom2dAPI_ProjectPointOnCurve.hxx>
# include <GeomAPI.hxx>
# include <GeomAdaptor.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
Expand Down Expand Up @@ -2119,71 +2112,29 @@ 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;
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();
}
case GeomAbs_BezierCurve:
{
Handle(Geom_BezierCurve) geomt = crv.Bezier();
typedcrv.Load(geomt);
break;
else {
curve = Handle(Geom_Curve)::DownCast(curve->Copy());
curve->Transform(crv.Trsf());
typedcrv.Load(curve);
}
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;
}

// 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());
std::vector<gp_Pnt> points;
Expand Down

1 comment on commit 0e93dd1

@donovaly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot compile this, I get:

2>D:\FreeCAD-git\src\Mod\Part\App\Attacher.cpp(2123): error C2653: 'GeomAdaptor': is not a class or namespace name
2>D:\FreeCAD-git\src\Mod\Part\App\Attacher.cpp(2123): error C3861: 'MakeCurve': identifier not found

Please sign in to comment.