View Issue Details

IDProjectCategoryView StatusLast Update
0033418CommunityOCCT:Modeling Algorithmspublic2023-08-08 14:58
Reporterkristofer.sejersted Assigned Todpasukhi  
PrioritynormalSeverityminor 
Status assignedResolutionopen 
PlatformWindowsOSVC++ 2022 
Product Version7.7.1 
Target VersionUnscheduled 
Summary0033418: Modeling Algorithms - BRepExtrema_DistShapeShape wrong arc ellipse - point result
DescriptionWhen 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
and documentation updates
https://dev.opencascade.org/content/orientation-arcofcircle
TagsNo tags attached.
Test case number

Attached Files

  • aArcOfEllipse.jpeg (20,900 bytes)

Activities

dpasukhi

2023-06-29 10:57

administrator   ~0113688

>> 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

dpasukhi

2023-06-29 11:01

administrator   ~0113689

Dear @kristofer.sejersted

Please don't use native C pointers(type* varName).
Use Handle(type) varName. Your code leads to indefined behavior.

dpasukhi

2023-06-29 11:04

administrator   ~0113690

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.

dpasukhi

2023-06-29 11:04

administrator   ~0113691

Please check my remarks and give me feedback.

kristofer.sejersted

2023-06-29 11:42

reporter   ~0113695

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
aArcOfEllipse.jpeg (20,900 bytes)

dpasukhi

2023-06-29 11:45

administrator   ~0113696

Dear @kristofer.sejersted
Thank you for the update.
I reassigne the ticket to the Algo team.

git

2023-08-02 12:35

administrator   ~0113851

Branch CR33418 has been created by andrey.kaftasev_159541.

SHA-1: acea26fce449ab90f19219b4a786ab057d5d429c


Detailed log of new commits:

Author: akaftasev
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

git

2023-08-02 16:26

administrator   ~0113861

Branch CR33418 has been updated forcibly by andrey.kaftasev_159541.

SHA-1: 96c0fd146c9dff6a6c2281008ba369bc1fd54d45

git

2023-08-02 16:35

administrator   ~0113862

Branch CR33418 has been updated forcibly by andrey.kaftasev_159541.

SHA-1: 058e85c26237c84c5c203a12b66f72acaaa4a5ce

git

2023-08-03 15:15

administrator   ~0113868

Branch CR33418 has been updated forcibly by andrey.kaftasev_159541.

SHA-1: a959673d9d44201ece888cc446ccf123a5341e11

git

2023-08-03 18:55

administrator   ~0113869

Branch CR33418_1 has been created by andrey.kaftasev_159541.

SHA-1: 9d9b512267286923cfa4713df844cede0aaedfeb


Detailed log of new commits:

Author: akaftasev
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

git

2023-08-04 12:04

administrator   ~0113874

Branch CR33418 has been updated forcibly by andrey.kaftasev_159541.

SHA-1: 1083b94cf9ba10e6860590a462afa53971dd3d70

akaftasev

2023-08-07 11:37

developer   ~0113889

Last edited: 2023-08-07 11:37

Dear @dpasukhi, 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-akaftasev-OCCT/Ubuntu2004-64/diff_summary.html - link to jenkins result

Issue History

Date Modified Username Field Change
2023-06-29 10:21 kristofer.sejersted New Issue
2023-06-29 10:21 kristofer.sejersted Assigned To => oan
2023-06-29 10:57 dpasukhi Summary BRepExtrema_DistShapeShape returns wrong point between a arc of ellipse and point in space => Modeling Algorithms - BRepExtrema_DistShapeShape wrong arc ellipse - point result
2023-06-29 10:57 dpasukhi Steps to Reproduce Updated
2023-06-29 10:57 dpasukhi Additional Information Updated
2023-06-29 10:57 dpasukhi Note Added: 0113688
2023-06-29 10:58 dpasukhi Assigned To oan => akaftasev
2023-06-29 10:58 dpasukhi Target Version => Unscheduled
2023-06-29 11:01 dpasukhi Note Added: 0113689
2023-06-29 11:04 dpasukhi Note Added: 0113690
2023-06-29 11:04 dpasukhi Assigned To akaftasev => kristofer.sejersted
2023-06-29 11:04 dpasukhi Status new => feedback
2023-06-29 11:04 dpasukhi Note Added: 0113691
2023-06-29 11:42 kristofer.sejersted Note Added: 0113695
2023-06-29 11:42 kristofer.sejersted File Added: aArcOfEllipse.jpeg
2023-06-29 11:44 dpasukhi Assigned To kristofer.sejersted => akaftasev
2023-06-29 11:44 dpasukhi Status feedback => assigned
2023-06-29 11:45 dpasukhi Note Added: 0113696
2023-06-29 15:56 dpasukhi Additional Information Updated
2023-08-02 12:35 git Note Added: 0113851
2023-08-02 16:26 git Note Added: 0113861
2023-08-02 16:35 git Note Added: 0113862
2023-08-03 15:15 git Note Added: 0113868
2023-08-03 18:55 git Note Added: 0113869
2023-08-04 12:04 git Note Added: 0113874
2023-08-07 11:37 akaftasev Assigned To akaftasev => dpasukhi
2023-08-07 11:37 akaftasev Status assigned => feedback
2023-08-07 11:37 akaftasev Note Added: 0113889
2023-08-07 11:37 akaftasev Note Edited: 0113889
2023-08-08 14:58 dpasukhi Status feedback => assigned