/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef OD_SR_CONIC_SECTION_ELLIPSE_HELPERS #define OD_SR_CONIC_SECTION_ELLIPSE_HELPERS struct OdSrPixelPoint64; namespace OdSrConicSectionEllipseHelpers { enum OctantStatus { NotDrawn, ParticularlyDrawnInsideBorders, ParticularlyDrawnOutsideBorders, ParticularlyDrawnWithStartingInFirstBorder, ParticularlyDrawnWithStoppingInFirstBorder, FullyDrawn }; inline double wrapAngle(double angle) { return angle - Oda2PI * floor(angle / Oda2PI); } inline int determineOctant(double angle, bool isStart) { #define ThreePi4 OdaPI2 + OdaPI4 #define FivePi4 OdaPI + OdaPI4 #define ThreePi2 OdaPI + OdaPI2 #define SevenPi4 ThreePi2 + OdaPI4 angle = wrapAngle(angle); if (isStart) { if (angle >= 0 && angle < OdaPI4) return 0; else if (angle >= OdaPI4 && angle < OdaPI2) return 1; else if (angle >= OdaPI2 && angle < ThreePi4) return 2; else if (angle >= ThreePi4 && angle < OdaPI) return 3; else if (angle >= OdaPI && angle < FivePi4) return 4; else if (angle >= FivePi4 && angle < ThreePi2) return 5; else if (angle >= ThreePi2 && angle < SevenPi4) return 6; else if (angle >= SevenPi4 && angle <= Oda2PI) return 7; } if (angle > 0 && angle <= OdaPI4) return 0; else if (angle > OdaPI4 && angle <= OdaPI2) return 1; else if (angle > OdaPI2 && angle <= ThreePi4) return 2; else if (angle > ThreePi4 && angle <= OdaPI) return 3; else if (angle > OdaPI && angle <= FivePi4) return 4; else if (angle > FivePi4 && angle <= ThreePi2) return 5; else if (angle > ThreePi2 && angle <= SevenPi4) return 6; else if (angle > SevenPi4 && angle <= Oda2PI) return 7; #undef ThreePi4 #undef FivePi4 #undef ThreePi2 #undef SevenPi4 return -1; } OdInt64 GetOctant(OdInt64 dfdx, OdInt64 dfdy); OdInt64 CalcOctant(OdSrPixelPoint64 origin, OdSrPixelPoint64 point, OdInt64 A, OdInt64 B, OdInt64 C, OdInt64 D, OdInt64 E, OdInt64 F); OdInt64 CalcPixelCount(OdInt64 octant, OdInt64 x1, OdInt64 y1, OdInt64 x2, OdInt64 y2); OctantStatus getOctantStatus(OdInt64 octant, OdInt64 octantStart, OdInt64 octantEnd, OdInt64 octantOrigin, OdInt64 x, OdInt64 y, OdSrPixelPoint64 start, OdSrPixelPoint64 end, double startAngle, double endAngle, OdInt64& borderFirst, OdInt64& borderSecond); bool checkPixelToBeDrawn(OctantStatus status, OdInt64 pixelCounter, OdInt64 borderFirst, OdInt64 borderSecond); }; #endif //OD_SR_CONIC_SECTION_ELLIPSE_HELPERS