DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0033418

Modeling Algorithms - BRepExtrema_DistShapeShape wrong arc ellipse - point result

CommunityOCCT:Modeling Algorithmsassigned13 public notes

Search issues

Description

When creating an arc of ellipse, in my case a half ellipse, the method PointOnShape of the class BRepExtrema_DistShapeShape does not give correct outcome.

The method seems to work as intended in most cases and when I make a full ellipse using geom_ellipse, however in the particular case when I make a Arc of Ellipse that is shaped as a perfect half circle, that being major and minor radius are equal, the PointOnshape fucntion returns the start and endingn points of the arc.

Steps to reproduce

    gp_Pnt pt1(2, 0, 0);
    gp_Pnt pt2(12, 0, 0);
    gp_Pnt centerPt(7, 0, 0);
    gp_Dir dir(0, 1, 0);
    gp_Ax2 ax2(centerPt, dir);
    gp_Elips elips(ax2, 5, 5);
    gp_Pnt point(7, 0, 6);  

    Handle(Geom_TrimmedCurve) aArcOfEllipse = GC_MakeArcOfEllipse(elips, pt1, pt2, true);
    Geom_TrimmedCurve* curve = new Geom_TrimmedCurve(aArcOfEllipse.get(), aArcOfEllipse.get()->FirstParameter(), aArcOfEllipse.get()->LastParameter());

    BRepBuilderAPI_MakeEdge maker(curve);
    TopoDS_Shape shape = maker.Shape();


    BRepBuilderAPI_MakeVertex vertex(point);
    TopoDS_Shape pointAsShape = vertex.Shape();

    BRepExtrema_DistShapeShape extrema(shape, pointAsShape);
    gp_Pnt closestPoint = extrema.PointOnShape1(1);
    BRepBuilderAPI_MakeVertex vertex2(closestPoint);
    TopoDS_Shape closestPoinAsShape = vertex2.Shape();

The result of the above code should be (5, 0, 5), however the outcome is (0, 0, 0)

Additional information

Public activity

13 archived notes

Participants are labeled by their role within this record.

01Commenter 1
>> I use the opencascade 7.7.0 not 7.7.1, could that have an impact?
I guess no. We don't fix this problem in the last version
02Commenter 1
Dear Commenter 2

Please don't use native C pointers(type* varName).
Use Handle(type) varName. Your code leads to indefined behavior.
03Commenter 1
Moreover, GC_MakeArcOfEllipse returns Geom_TrimmedCurve in parametric space.
And you make Geom_TrimmedCurve with Geom_TrimmedCurve. This is not recommended way. I guess the most part of alghorihms will be broken in with this curve.
Please use Geom_TrimmedCurve with only Basic curve.
04Commenter 1
Please check my remarks and give me feedback.
05Author
Thank you for your swift reply!

I agree in what you write, but I rewrote my code in order to not use native C pointers, and the outcome is still not as I want it.

Modified code:
    gp_Pnt pt1(0, 0, 0);
    gp_Pnt pt2(10, 0, 0);
    gp_Pnt centerPt(5, 0, 0);
    gp_Dir dir(0, 1, 0);
    gp_Ax2 ax2(centerPt, dir);
    gp_Elips elips(ax2, 5, 5);
    gp_Pnt point(5, 0, 6);

    Handle(Geom_TrimmedCurve) aArcOfEllipse = GC_MakeArcOfEllipse(elips, pt1, pt2, true);

    BRepBuilderAPI_MakeEdge maker(aArcOfEllipse);
    TopoDS_Shape shape = maker.Shape();

    BRepBuilderAPI_MakeVertex vertex(point);
    TopoDS_Shape pointAsShape = vertex.Shape();

    BRepExtrema_DistShapeShape extrema(shape, pointAsShape);

    gp_Pnt closestPoint = extrema.PointOnShape1(1);
    BRepBuilderAPI_MakeVertex vertex2(closestPoint);
    TopoDS_Shape closestPoinAsShape = vertex2.Shape();

I also attached a picture of the outcome visualized in OpenCascade, imported as a STEP file
Attachment 1 (JPEG) (20,900 bytes)   
06Commenter 1
Dear Commenter 2
Thank you for the update.
I reassigne the ticket to the Algo team.
07Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 4
Date: Wed Aug 2 10:35:30 2023 +0100

    0033418: Modeling Algorithms - BRepExtrema_DistShapeShape wrong arc ellipse - point result
    
    Wrong calculation of distance arises when first or last parameter of trimmed ellipse more then 2*pi
    Added correction of these parameters for extrema calculation
    Deleted duplicated commented line
08Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
09Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
10Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
11Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 4
Date: Wed Aug 2 10:35:30 2023 +0100

    0033418: Modeling Algorithms - BRepExtrema_DistShapeShape wrong arc ellipse - point result
    
    Wrong calculation of distance arises for ellipse with MajorRadius == MinorRadius when first or last parameter of trimmed ellipse more then 2*pi
    This case should be calculated as circle
12Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
13Commenter 4
Dear Commenter 5, can you take a look on the branch CR33418?
Some of cases are failed only on Linux platform.
There are no porblems on Windows.
http://occt-tests/CR33418_1-master-Commenter 4-OCCT/Ubuntu2004-64/diff_summary.html - link to jenkins result