<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to triangulate arcs in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250496#M5062</link>
    <description>Akos,&lt;BR /&gt;
&lt;BR /&gt;
According to the API doc, ACAPI_Goodies (APIAny_TriangulatePolyID, ...) only accept polygons that has no arc segments. The code snippet on that page also shows it skips over nArcs &amp;gt; 0. I was just wondering if there are functions/methods that I missed looking through the samples that handles triangulation of arcs. &lt;BR /&gt;
&lt;BR /&gt;
Cheers,&lt;BR /&gt;
Ian</description>
    <pubDate>Wed, 14 Dec 2016 19:56:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-12-14T19:56:45Z</dc:date>
    <item>
      <title>How to triangulate arcs</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250494#M5060</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;I'm new to Archicad and am looking into a bug whereby shell objects doesn't appear ( I suspect because there isn't an implementation to handle arcs/shell). The original implementer of our archicad codebase left so I'm picking up the pieces so to say. &lt;BR /&gt;&lt;BR /&gt;From what I can tell, we are using ACPI_Goodies(API_RegularizePolyID) to triangulate Archicad primitives. I did fix the case for APIERR_IRREGULARPOLY by using API_RegularizedPolyID. However I'm still seeing error APIERR_REFUSEDPAR return by APIAny_TriangulatePolyID due to arc since the function only accept polygons w/o arc segments. I was just wondering if someone could point me towards tutorial/sample codes/ or how to go about triangulating arcs? &lt;BR /&gt;&lt;BR /&gt;Thanks in advance, &lt;BR /&gt;Ian&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Jul 2023 19:02:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250494#M5060</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-12T19:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to triangulate arcs</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250495#M5061</link>
      <description>&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;Hello, &lt;BR /&gt;
 &lt;BR /&gt;
I'm new to Archicad and am looking into a bug whereby shell objects doesn't appear ( I suspect  because there isn't an implementation to handle arcs/shell). The original implementer of our archicad codebase left so I'm picking up the pieces so to say.  &lt;BR /&gt;
 &lt;BR /&gt;
From what I can tell, we are using ACPI_Goodies(API_RegularizePolyID) to triangulate Archicad primitives. I did fix the case for APIERR_IRREGULARPOLY by using API_RegularizedPolyID. However I'm still seeing error APIERR_REFUSEDPAR return by APIAny_TriangulatePolyID due to arc since the function only accept polygons w/o arc segments. I was just wondering if someone could point me towards tutorial/sample codes/ or how to go about triangulating arcs? &lt;BR /&gt;
 &lt;BR /&gt;
Thanks in advance, &lt;BR /&gt;
Ian&lt;/BLOCKQUOTE&gt;

Hello Ian,&lt;BR /&gt;
&lt;BR /&gt;
I would take a look at ACAPI_Goodies (APIAny_TriangulatePolyID, ...).&lt;BR /&gt;
&lt;BR /&gt;
Best, Akos</description>
      <pubDate>Wed, 14 Dec 2016 08:10:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250495#M5061</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2016-12-14T08:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to triangulate arcs</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250496#M5062</link>
      <description>Akos,&lt;BR /&gt;
&lt;BR /&gt;
According to the API doc, ACAPI_Goodies (APIAny_TriangulatePolyID, ...) only accept polygons that has no arc segments. The code snippet on that page also shows it skips over nArcs &amp;gt; 0. I was just wondering if there are functions/methods that I missed looking through the samples that handles triangulation of arcs. &lt;BR /&gt;
&lt;BR /&gt;
Cheers,&lt;BR /&gt;
Ian</description>
      <pubDate>Wed, 14 Dec 2016 19:56:45 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250496#M5062</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-14T19:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to triangulate arcs</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250497#M5063</link>
      <description>&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;According to the API doc, ACAPI_Goodies (APIAny_TriangulatePolyID, ...) only accept polygons that has no arc segments. The code snippet on that page also shows it skips over nArcs &amp;gt; 0. I was just wondering if there are functions/methods that I missed looking through the samples that handles triangulation of arcs.&lt;/BLOCKQUOTE&gt;
You could facet the arc edges to the required level of precision first.</description>
      <pubDate>Thu, 15 Dec 2016 10:51:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250497#M5063</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2016-12-15T10:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to triangulate arcs</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250498#M5064</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;IanTr wrote:&lt;BR /&gt;According to the API doc, ACAPI_Goodies (APIAny_TriangulatePolyID, ...) only accept polygons that has no arc segments. The code snippet on that page also shows it skips over nArcs &amp;gt; 0. I was just wondering if there are functions/methods that I missed looking through the samples that handles triangulation of arcs.&lt;/BLOCKQUOTE&gt;
You could facet the arc edges to the required level of precision first.&lt;/BLOCKQUOTE&gt;

Ian,&lt;BR /&gt;
&lt;BR /&gt;
Here comes a sample which shows how to do that with the help of the Geometry module.&lt;BR /&gt;

&lt;PRE&gt;#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, &amp;amp;maxDiff) != NoError) {
		API_MagicWandInfo	mwi = {0};
		if (ACAPI_Environment (APIEnv_GetMagicWandSetsID, &amp;amp;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&amp;amp; 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 &amp;amp;)orig, r, ratio, 0.0), begAng, endAng, reflected);
	} else {
		genArc.SetToCircleArc ((const Coord &amp;amp;)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&amp;amp; orig, double r,
									  double begAng, double endAng, bool reflected = false,
									  double ratio = 1.0, bool elliptic = false)
{
	USize	nCo = 0;
	Coord	**hCo = reinterpret_cast&amp;lt;Coord **&amp;gt; (BMhAll (0));
	GSErrCode lastErr = DivideArc (orig, r, begAng, endAng, reflected, ratio, elliptic, &amp;amp;nCo, hCo);
	if (lastErr != NoError) {
		BMhFree ((GSHandle) hCo);
		return lastErr;
	}

	// ...

	BMhFree ((GSHandle) hCo);

	return lastErr;
}&lt;/PRE&gt;

Regards, Akos</description>
      <pubDate>Sun, 18 Dec 2016 10:40:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-triangulate-arcs/m-p/250498#M5064</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2016-12-18T10:40:49Z</dc:date>
    </item>
  </channel>
</rss>

