Author:Akos Somorjai
Posted: Sun Dec 18, 2016 11:40 am (GMT+1)
Ian,
Here comes a sample which shows how to do that with the help of the Geometry module.
Regards, Akos
Posted: Sun Dec 18, 2016 11:40 am (GMT+1)
Ralph Wessel wrote: | ||
You could facet the arc edges to the required level of precision first. |
Ian,
Here comes a sample which shows how to do that with the help of the Geometry module.
Code: |
#include "GenArc2DData.h" #include "Ellipse2DData.h" /*----------------------------------------------------------** ** Gets the current ARCHICAD settings for arc division ** **----------------------------------------------------------*/ static double GetMaxDiff () { double maxDiff = EPS; if (ACAPI_Environment (APIEnv_GetExportToleranceID, &maxDiff) != NoError) { API_MagicWandInfo mwi = {0}; if (ACAPI_Environment (APIEnv_GetMagicWandSetsID, &mwi) != NoError) maxDiff = EPS; else maxDiff = mwi.arcDiff; } return maxDiff; } /*----------------------------------------------------------** ** Divides an arc according to the currect AC settings ** **----------------------------------------------------------*/ static GSErrCode DivideArc (const API_Coord& orig, double r, double begAng, double endAng, bool reflected, double ratio, bool elliptic, USize * nCo, Coord** hCo) { GenArc genArc; if (elliptic) { genArc.SetToEllipseArc (Geometry::Ellipse ((const Coord &)orig, r, ratio, 0.0), begAng, endAng, reflected); } else { genArc.SetToCircleArc ((const Coord &)orig, r, begAng, endAng, reflected); } Geometry::DivideEllArcToCo (genArc, GetMaxDiff (), hCo, nCo); return NoError; } /*----------------------------------------------------------** ** Writes out a Circular/Elliptic Arc, divided ** **----------------------------------------------------------*/ static GSErrCode DWF_WrDividedArc (const API_Coord& orig, double r, double begAng, double endAng, bool reflected = false, double ratio = 1.0, bool elliptic = false) { USize nCo = 0; Coord **hCo = reinterpret_cast<Coord **> (BMhAll (0)); GSErrCode lastErr = DivideArc (orig, r, begAng, endAng, reflected, ratio, elliptic, &nCo, hCo); if (lastErr != NoError) { BMhFree ((GSHandle) hCo); return lastErr; } // ... BMhFree ((GSHandle) hCo); return lastErr; } |
Regards, Akos