ellipticalArc in subWorldDraw

ellipticalArc in subWorldDraw

PEPANOVAK
Contributor Contributor
866 Views
3 Replies
Message 1 of 4

ellipticalArc in subWorldDraw

PEPANOVAK
Contributor
Contributor

Hi,

I need help. I do not know how to use this function - geometry().ellipticalArc.

 

Thank you.

 

Adesk::Boolean MyCurve3d::subWorldDraw(AcGiWorldDraw* mode)
{
    assertReadEnabled () ;
    //------ Returning Adesk::kFalse here will force viewportDraw() call
    AcGeLineSeg3d *pGeLine=NULL;
    AcGeCircArc3d *pGeArc=NULL;
    AcGeEntity3d *pObj=NULL;
    AcGePoint3d points[2];
    AcGeEllipArc3d*    pGeEllipArc=NULL;

    mode->subEntityTraits().setColor(256);   
    int ij=1;
    for (int i=0; i < geCurves.length(); i++) {
        pObj=(AcGeEntity3d*)geCurves.at(i);
        if (pObj->isKindOf(AcGe::kLineSeg3d)) {
            pGeLine=(AcGeLineSeg3d*)geCurves.at(i);
            points[0]=pGeLine->startPoint();
            points[1]=pGeLine->endPoint();
            mode->subEntityTraits().setSelectionMarker(ij++);
            mode->geometry().worldLine(points);   
        } else
        if (pObj->isKindOf(AcGe::kCircArc3d)) {
            pGeArc=(AcGeCircArc3d*)geCurves.at(i);
            AcGePoint3d startpt(pGeArc->startPoint());
            AcGePoint3d endpt(pGeArc->endPoint());   
            AcGeVector3d startvec = startpt - pGeArc->center();   
            AcGeVector3d endvec = endpt - pGeArc->center();   
            double angle = pGeArc->endAng() - pGeArc->startAng();
            mode->subEntityTraits().setSelectionMarker(ij++);
            mode->geometry().circularArc(pGeArc->center(),pGeArc->radius(),pGeArc->normal(),startvec, angle, kAcGiArcSimple);
        } else
        if (pObj->isKindOf(AcGe::kEllipArc3d)) {
            double uhelStart=0, uhelEnd=0;
            mode->subEntityTraits().setSelectionMarker(ij++);
            pGeEllipArc=(AcGeEllipArc3d*)geCurves.at(i);

            AcGePoint3d cen(pGeEllipArc->center());   
            AcGePoint3d startpt(pGeEllipArc->startPoint());
            AcGePoint3d endpt(pGeEllipArc->endPoint());   

            angStart=pGeEllipArc->startAng();
            angEnd=pGeEllipArc->endAng();

            mode->geometry().ellipticalArc(cen, pGeEllipArc->normal(),pGeEllipArc->majorRadius(),pGeEllipArc->minorRadius(),
                angStart, angEnd, 0, kAcGiArcSimple);

        }
    }
    
    return (Adesk::kTrue) ;
}

0 Likes
Accepted solutions (1)
867 Views
3 Replies
Replies (3)
Message 2 of 4

tbrammer
Advisor
Advisor

So you try to draw a 3D arc with geometry().ellipticalArc()  that is identical to an AcGeEllipArc3d, right?

At first glance your code looks ok. It seems you are only missing a value for the 7th parameter double tiltDegreeInRads for

 

virtual Adesk::Boolean ellipticalArc(
    const AcGePoint3d& center,
    const AcGeVector3d& normal,
    double majorAxisLength,
    double minorAxisLength,
    double startDegreeInRads,
    double endDegreeInRads,
    double tiltDegreeInRads,
    AcGiArcType arcType = kAcGiArcSimple
)

 

I haven't tested it but I would suppose you can calculate it somehow like this:

 

  AcGePlane plane;
  pGeEllipArc->getPlane(plane);
  double tiltDegreeInRads = pGeEllipArc->minorAxis().angleOnPlane(plane);

 

Maybe the sign is wrong or you have to use majorAxis() instead of minorAxis(). Please try it yourself.

 

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 4

PEPANOVAK
Contributor
Contributor

Thank you tbrammer for your reply,

but there is also a problem with start and end angle and when elliptical arc is in 3D... Smiley Frustrated

 

0 Likes
Message 4 of 4

PEPANOVAK
Contributor
Contributor
Accepted solution

I got it, thank you.

 

AcGePoint3d cen(pGeEllipArc->center());
AcGePoint3d startpt(pGeEllipArc->startPoint());
AcGePoint3d endpt(pGeEllipArc->endPoint());
AcGeVector3d startvec = startpt - cen;
AcGeVector3d endvec = endpt - cen;
AcGeVector3d ellNorm=startvec.crossProduct(endvec);
AcGeVector3d arcRef=ellNorm.perpVector();
ellNorm.negate();
double angStart= startvec.angleTo(arcRef,ellNorm);
double angEnd = endvec.angleTo(arcRef,ellNorm);

0 Likes