<?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: ACAPI_3D_DecomposePgon in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67426#M7919</link>
    <description>&lt;BLOCKQUOTE&gt;stefan wrote:&lt;BR /&gt;Thanks again!&lt;BR /&gt;
&lt;BR /&gt;
Now, do I need to allocate memory myself or is that the responsability of the DecomposPgn function?&lt;BR /&gt;
&lt;BR /&gt;
And lastly, I'm still struggling on getting access to the actual array that should be referenced by the cpoly.&lt;BR /&gt;
&lt;BR /&gt;
Would *cpoly&lt;N&gt; give me acces to it? Or do I need to cast it to a (GSHandle*) and then work through the handle?&lt;BR /&gt;

&lt;/N&gt;&lt;/BLOCKQUOTE&gt;

You dont need to allocate memory, but you need to release the memory ( kill the handle ).&lt;BR /&gt;
&lt;BR /&gt;
You can access it as (*cpoly)&lt;N&gt; or to create a pointer for easy using like&lt;BR /&gt;
long* poly = *cpoly;&lt;BR /&gt;
and then use it just poly&lt;N&gt;&lt;BR /&gt;
&lt;BR /&gt;
PS: Actually the handle should be locked if you did the pointer like poly ( above ), but it seem it is not required for MacOSX now and I think it was never need for Win.&lt;/N&gt;&lt;/N&gt;</description>
    <pubDate>Thu, 25 Nov 2004 10:46:36 GMT</pubDate>
    <dc:creator>Oleg</dc:creator>
    <dc:date>2004-11-25T10:46:36Z</dc:date>
    <item>
      <title>ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67423#M7916</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I've done it again... I've relooked at my Radiance exporter and am stumbling on the decomposition of the Archicad polygon into a set of valid convex polygons.&lt;BR /&gt;&lt;BR /&gt;I think it is a strictly C++ question, but the sparse documentation leaves me not much choice.&lt;BR /&gt;&lt;BR /&gt;The docs tell me:
&lt;BLOCKQUOTE&gt;ACAPI_3D_DecomposePgon(long ipgon, long ***cpoly)&lt;BR /&gt;This function is used to decompose a polygon into convex polygons.&lt;BR /&gt;The polygon is defined by ipgon index.&lt;BR /&gt;The decomposed polygon is returned in the cpoly long array,&lt;BR /&gt;which contains the following values: &lt;BR /&gt;[-n], [-m1], i1, i2, ... i(m1), [-m2], j1, j2, ... j(m2)...&lt;/BLOCKQUOTE&gt;
And now the question:&lt;BR /&gt;Do I need to set up an array for the function to fill, or does the function allocates memory itself? I hate code that uses more then one * after eachother &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;When I try the following, it compiles and runs, but somehow the array seems to be gone... Or at least the cpoly is pointing to nowhere:
&lt;PRE&gt;//j is allready referencing the current polygon
long * Verts = new long[100]; // array of 100 longs (seems stupid)
long ** cpoly = &amp;amp;Verts; // a pointer to this array
GSErrCode TriangulationError = ACAPI_3D_DecomposePgon(j, &amp;amp;cpoly);&lt;/PRE&gt;
When I do this, Archicad goes through, but I cannot do anything with the results... Do I miss something? Do I need to allocate memory? Or do I need an array with pointers to longs? Or is it actually an array of verts?&lt;BR /&gt;&lt;BR /&gt;The documentation is rather vague and unfortunately I have no working example available...&lt;BR /&gt;&lt;BR /&gt;(If I should go back to my first C++-class, then please tell me so)&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Dec 2022 21:30:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67423#M7916</guid>
      <dc:creator>stefan</dc:creator>
      <dc:date>2022-12-13T21:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67424#M7917</link>
      <description>cpoly is a pointer to handle.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;long** cpoly=0; // this is handle
bool ok = ACAPI_3D_DecomposePgon( id, &amp;amp;cpoly ) == NoError;
... and after using 
BMhKill((GSHandle*)&amp;amp;cpoly );
&lt;/PRE&gt;

PS: One more open source renderer for you &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_wink.gif" style="display : inline;" /&gt;  &lt;A href="http://www.cs.berkeley.edu/~okan/Pixie/pixie.htm" target="_blank"&gt;http://www.cs.berkeley.edu/~okan/Pixie/pixie.htm&lt;/A&gt;</description>
      <pubDate>Wed, 24 Nov 2004 17:12:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67424#M7917</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2004-11-24T17:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67425#M7918</link>
      <description>Thanks again!&lt;BR /&gt;
&lt;BR /&gt;
Now, do I need to allocate memory myself or is that the responsability of the DecomposPgn function?&lt;BR /&gt;
&lt;BR /&gt;
And lastly, I'm still struggling on getting access to the actual array that should be referenced by the cpoly.&lt;BR /&gt;
&lt;BR /&gt;
Would *cpoly&lt;N&gt; give me acces to it? Or do I need to cast it to a (GSHandle*) and then work through the handle?&lt;BR /&gt;
&lt;BR /&gt;
----&lt;BR /&gt;
&lt;BR /&gt;
Bytheway... the Pixie renderer seems nice. And (in contrast with BMRT) the source is included, so it might be possible to link that to an executable. This did work more or less with BMRT, but only single-threaded, not debug and it also gave library conflicts. So I gave up that time.&lt;/N&gt;</description>
      <pubDate>Thu, 25 Nov 2004 10:16:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67425#M7918</guid>
      <dc:creator>stefan</dc:creator>
      <dc:date>2004-11-25T10:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67426#M7919</link>
      <description>&lt;BLOCKQUOTE&gt;stefan wrote:&lt;BR /&gt;Thanks again!&lt;BR /&gt;
&lt;BR /&gt;
Now, do I need to allocate memory myself or is that the responsability of the DecomposPgn function?&lt;BR /&gt;
&lt;BR /&gt;
And lastly, I'm still struggling on getting access to the actual array that should be referenced by the cpoly.&lt;BR /&gt;
&lt;BR /&gt;
Would *cpoly&lt;N&gt; give me acces to it? Or do I need to cast it to a (GSHandle*) and then work through the handle?&lt;BR /&gt;

&lt;/N&gt;&lt;/BLOCKQUOTE&gt;

You dont need to allocate memory, but you need to release the memory ( kill the handle ).&lt;BR /&gt;
&lt;BR /&gt;
You can access it as (*cpoly)&lt;N&gt; or to create a pointer for easy using like&lt;BR /&gt;
long* poly = *cpoly;&lt;BR /&gt;
and then use it just poly&lt;N&gt;&lt;BR /&gt;
&lt;BR /&gt;
PS: Actually the handle should be locked if you did the pointer like poly ( above ), but it seem it is not required for MacOSX now and I think it was never need for Win.&lt;/N&gt;&lt;/N&gt;</description>
      <pubDate>Thu, 25 Nov 2004 10:46:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67426#M7919</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2004-11-25T10:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67427#M7920</link>
      <description>OK, I'm starting to see the light now...&lt;BR /&gt;
&lt;BR /&gt;
For convex polygons, ACAPI_3D_DecomposePgon doesn't give an error, but returns the cpoly as NULL. Then I don't need it.&lt;BR /&gt;
&lt;BR /&gt;
When cpoly != NULL I can step through the array as follows:
&lt;PRE&gt;long n = (*cpoly)[0] * -1; // number of sub-polygons
if (n &amp;gt; 0)
{
	for (long poly = 0; poly &amp;lt; n; ++poly)
	{
		++count;
		long m = (*cpoly)[count] * -1; // number of vertices in current subpolygon
		if (m &amp;gt; 0)
		{
			// get indices to the vertices
			for (long vert = 0; vert &amp;lt; m; ++vert)
			{
				++count;
				long vertindex = (*cpoly)[count];
				// get the actual vertex
				component.header.typeID = API_VertID;
				component.header.index  = vertindex;
				err = ACAPI_3D_GetComponent (&amp;amp;component);
				if (err == NoError)
				{
					double xx, yy, zz;
					xx = component.vert.x;
					yy = component.vert.y;
					zz = component.vert.z;
					// transform it into world coordinates
					Geometry::TMPoint(&amp;amp;tranmat_struct, &amp;amp;xx, &amp;amp;yy, &amp;amp;zz);
					// export...
				} // end if no error getting vertex
			} // end for vert
		} // end if m &amp;gt; 0
	} // end for poly
} // end if n &amp;gt; 0&lt;/PRE&gt;
Well, one step closer to heaven &lt;E&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/E&gt;</description>
      <pubDate>Thu, 25 Nov 2004 10:52:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67427#M7920</guid>
      <dc:creator>stefan</dc:creator>
      <dc:date>2004-11-25T10:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_3D_DecomposePgon</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67428#M7921</link>
      <description>Not quite...&lt;BR /&gt;
&lt;BR /&gt;
The vertex-index that is retrieved from the cpoly-array is a 0-based index while ArchiCAD uses 1-based indices to get to the real component.vert !&lt;BR /&gt;
&lt;BR /&gt;
So you have to do the following:
&lt;PRE&gt;long vertindex = (*cpoly)[count];
vertindex +=1;&lt;/PRE&gt;
before you get the actual vertex (API_VertID)&lt;BR /&gt;
&lt;BR /&gt;
Is this a bug? Or are they falling in their own booby-traps?</description>
      <pubDate>Thu, 25 Nov 2004 15:59:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-3D-DecomposePgon/m-p/67428#M7921</guid>
      <dc:creator>stefan</dc:creator>
      <dc:date>2004-11-25T15:59:34Z</dc:date>
    </item>
  </channel>
</rss>

