<?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 use the Geometry::StripPolygon2D()? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174361#M6054</link>
    <description>OK, I have solved it.&lt;BR /&gt;
&lt;BR /&gt;
Just clear all settings about the infos.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot for Ralph Wessel.</description>
    <pubDate>Tue, 20 Jul 2010 05:00:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-07-20T05:00:14Z</dc:date>
    <item>
      <title>How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174353#M6046</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I Created a polygon as the example.&lt;BR /&gt;The Geometry::ValidatePolygon2DData (&amp;amp;polygon) returns NoError;&lt;BR /&gt;The Geometry::CheckPolygon2DDataIntegrity (polygon) also returns NoError.&lt;BR /&gt;However when executing Geometry::StripPolygon2D(&amp;amp;cutline1,&amp;amp;cutline2, &amp;amp;polygon, &amp;amp;arPolygons, &amp;amp;wrcode), it crashed!&lt;BR /&gt;&lt;BR /&gt;Why? And is there any example about to using these functions?&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;Geometry::Init();
	HalfPlane2DData cutline1, cutline2;
	BNZeroMemory(&amp;amp;cutline1, sizeof(HalfPlane2DData));
	BNZeroMemory(&amp;amp;cutline2, sizeof(HalfPlane2DData));
	cutline2.ca = cutline1.ca = 1;
	cutline2.cb = cutline1.cb = 0;
	cutline1.cc = 1;
	cutline2.cc = 2;
	cutline1.sizeOfInhEdgeInfo = cutline2.sizeOfInhEdgeInfo = sizeof(long);

	Geometry::Polygon2DData polygon;
	long defaultVertexInfo = 0;
	long defaultInhEdgeInfo = 0;
	long defaultUniqEdgeInfo = 0;
	long defaultContourInfo = 0;
	long defaultUniqPolygonInfo = 0;

	Geometry::InitPolygon2DData (&amp;amp;polygon,
		sizeof (long), reinterpret_cast&amp;lt;GSPtr&amp;gt; (&amp;amp;defaultVertexInfo),        // vertex informations
		sizeof (long), reinterpret_cast&amp;lt;GSPtr&amp;gt; (&amp;amp;defaultInhEdgeInfo),       // edge informations
		sizeof (long), reinterpret_cast&amp;lt;GSPtr&amp;gt; (&amp;amp;defaultUniqEdgeInfo),      // edge informations
		sizeof (long), reinterpret_cast&amp;lt;GSPtr&amp;gt; (&amp;amp;defaultContourInfo),       // contour informations
		sizeof (long),
		sizeof (long), reinterpret_cast&amp;lt;GSPtr&amp;gt; (&amp;amp;defaultUniqPolygonInfo));  // polyogn informations

	polygon.nContours = 1;
	polygon.contourEnds = reinterpret_cast&amp;lt;UIndex**&amp;gt; (BMhAll ((polygon.nContours+1) * sizeof (UIndex)));
	polygon.contourInfos = BMhAll ((polygon.nContours+1) * sizeof (long));
	(*polygon.contourEnds)[0] = 0; // not used, must be zero
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.contourInfos)[0]   = 'C-uu';
	(*polygon.contourEnds)[1] = 5;  // index of the last vertex in the first (main) contour
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.contourInfos)[1]   = 'C-01';

	polygon.nVertices = 5;  // first vertices of contours is duplicated in the last (but do not count the unused)
	polygon.vertices      = reinterpret_cast&amp;lt;Coord**&amp;gt; (BMhAll ((polygon.nVertices + 1) * sizeof (Coord)));
	polygon.vertexInfos   = BMhAll ((polygon.nVertices + 1) * sizeof (long));
	polygon.inhEdgeInfos  = BMhAll ((polygon.nVertices + 1) * sizeof (long));
	polygon.uniqEdgeInfos = BMhAll ((polygon.nVertices + 1) * sizeof (long));
	(*polygon.vertices)[0] = Geometry::SetCoord ( 0.0,  0.0); // not used, must be zero
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[0]   = 'V-uu';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[0]  = 'I-uu';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[0] = 'U-uu';

	(*polygon.vertices)[1] = Geometry::SetCoord (0, 0);
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[1]   = 'V-01';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[1]  = 'I-01';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[1] = 'U-01';

	(*polygon.vertices)[2] = Geometry::SetCoord (3, 0);
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[2]   = 'V-02';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[2]  = 'I-02';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[2] = 'U-02';

	(*polygon.vertices)[3] = Geometry::SetCoord (3, 2);
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[3]   = 'V-03';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[3]  = 'I-03';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[3] = 'U-03';

	(*polygon.vertices)[4] = Geometry::SetCoord (0, 2);
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[4]   = 'V-04';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[4]  = 'I-04';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[4] = 'U-04';

	(*polygon.vertices)[5] = Geometry::SetCoord (0, 0);
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.vertexInfos)[5]   = 'V-05';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.inhEdgeInfos)[5]  = 'I-05';
	reinterpret_cast&amp;lt;long*&amp;gt;(*polygon.uniqEdgeInfos)[5] = 'U-05';
	

	polygon.nArcs = 0;

	GSErr gserr = Geometry::ValidatePolygon2DData (&amp;amp;polygon);

	// Check for safety
	gserr = Geometry::CheckPolygon2DDataIntegrity (polygon);

	GS::VAArray&amp;lt;Geometry::Polygon2DData&amp;gt; arPolygons;
	Int32 wrcode;
	bool bStat = Geometry::StripPolygon2D(&amp;amp;cutline1,&amp;amp;cutline2, &amp;amp;polygon, &amp;amp;arPolygons, &amp;amp;wrcode);

	// Clean-up
	gserr = Geometry::FreePolygon2DData (&amp;amp;polygon);

	Geometry::Free();
&lt;/PRE&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;Action Log:
00	0x4C3FBFAC	0x7EF40001	0x34346D56	0x21965DF8

Exception code: C0000005 ACCESS_VIOLATION reading location: 00000000
Fault address:  78145478 01:00014478 MSVCR80.dll

Registers:
EAX:00000004
EBX:00000000
ECX:00000001
EDX:00000000
ESI:00000000
EDI:067FB0B0
CS:EIP:001B:78145478
SS:ESP:0023:0013DEB8  EBP:0013DEC0
DS:0023  ES:0023  FS:003B  GS:0000
Flags:00010297

Floating point Registers:
CTRL:027F  STAT:0120  TAGS:FFFF
CS:EIP:001B:4ECE7F3F
DS:EDO:0023:0013DF10
Cr0NpxState:00000000

ST(0) = --------- EMPTY ---------- [0013FD30E1842010] [0]
ST(1) = --------- EMPTY ---------- [8FEEEEEEEEF14000] [1]
ST(2) = --------- EMPTY ---------- [8000000000000000] [2]
ST(3) = --------- EMPTY ---------- [8FEEEEEEEEF14000] [3]
ST(4) = --------- EMPTY ---------- [DFA978332BE29000] [4]
ST(5) = --------- EMPTY ---------- [0000000000000000] [5]
ST(6) = --------- EMPTY ---------- [9A15DD19337E7800] [6]
ST(7) = --------- EMPTY ---------- [FF83BC80661B2800] [7]

Disassembly
 (FAULT is at memmove + 344 bytes)

        78145450 8B448EE8         mov     eax,[esi+ecx*4-0x18]   ds:4E104CEC=E88F4489
        78145454 89448FE8         mov     [edi+ecx*4-0x18],eax   ds:4E104CEC=EC8E448B
        78145458 8B448EEC         mov     eax,[esi+ecx*4-0x14]   ds:4E104CEC=EC8F4489
        7814545C 89448FEC         mov     [edi+ecx*4-0x14],eax   ds:4E104CEC=F08E448B
        78145460 8B448EF0         mov     eax,[esi+ecx*4-0x10]   ds:4E104CEC=F08F4489
        78145464 89448FF0         mov     [edi+ecx*4-0x10],eax   ds:4E104CEC=F48E448B
        78145468 8B448EF4         mov     eax,[esi+ecx*4-0xC]    ds:4E104CEC=F48F4489
        7814546C 89448FF4         mov     [edi+ecx*4-0xC],eax    ds:4E104CEC=F88E448B
        78145470 8B448EF8         mov     eax,[esi+ecx*4-0x8]    ds:4E104CEC=F88F4489
        78145474 89448FF8         mov     [edi+ecx*4-0x8],eax    ds:4E104CEC=FC8E448B
FAULT -&amp;gt;78145478 8B448EFC         mov     eax,[esi+ecx*4-0x4]    ds:4E104CEC=FC8F4489
        7814547C 89448FFC         mov     [edi+ecx*4-0x4],eax    ds:4E104CEC=008D048D
        78145480 8D048D00000000   lea     eax,[00000000+ecx*4]   ds:00000001=????????
        78145487 03F0             add     esi,eax
        78145489 03F8             add     edi,eax
        7814548B FF249594541478                                  ds:00000000=????????
                                  jmp     dword ptr [memmove+0x174 (78145494)+edx*4]
        78145492 8BFF             mov     edi,edi
        78145494 A4               movsb                 ds:00000000=?? es:067FB0B0=B8
        78145495 54               push    esp
        78145496 1478             adc     al,0x78
        78145498 AC               lodsb                                ds:00000000=??
        78145499 54               push    esp


Call stack:
0x78145478!MSVCR80.dll + 87160 (memmove + 344 bytes)
0x4E05FDB3!GSRoot.dll + 64947 (BNCopyMemory + 24 bytes)
0x4ECE05FF!Geometry.dll + 132607 (Geometry::GetCurve2DDataEndDirection + 13429 bytes)
0x4ECE0FCE!Geometry.dll + 135118 (Geometry::GetCurve2DDataEndDirection + 15940 bytes)
0x4ECE1147!Geometry.dll + 135495 (Geometry::StripPolygon2D + 70 bytes)
&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 09:31:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174353#M6046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-03T09:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174354#M6047</link>
      <description>&lt;BLOCKQUOTE&gt;wcyoot wrote:&lt;BR /&gt;when executing Geometry::StripPolygon2D(&amp;amp;cutline1,&amp;amp;cutline2, &amp;amp;polygon, &amp;amp;arPolygons, &amp;amp;wrcode), it crashed! Why?&lt;/BLOCKQUOTE&gt;
It's difficult to say from the crash report alone. Can you post the essentials of the code that created the polygon, leading up to the point where it crashes?&lt;BR /&gt;
&lt;BR /&gt;
Also, I would try to eliminate the possibility that the real problem lies elsewhere in your code, i.e. that an earlier problem has corrupted data structures etc. Make a test case that does just this operation and nothing else. If that works, look for a problem elsewhere in your code.</description>
      <pubDate>Fri, 16 Jul 2010 16:58:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174354#M6047</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2010-07-16T16:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174355#M6048</link>
      <description>I have post the code.&lt;BR /&gt;
&lt;BR /&gt;
I just created a simple polygon as a box:(0,0),(3,0),(3,2),(0,2)&lt;BR /&gt;
and the strips : x = 1, x = 2.&lt;BR /&gt;
&lt;BR /&gt;
it crashed in Geometry::StripPolygon2D().</description>
      <pubDate>Mon, 19 Jul 2010 08:06:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174355#M6048</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-19T08:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174356#M6049</link>
      <description>There is something wrong in these codes!</description>
      <pubDate>Mon, 19 Jul 2010 08:09:22 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174356#M6049</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-19T08:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174357#M6050</link>
      <description>&lt;BLOCKQUOTE&gt;wcyoot wrote:&lt;BR /&gt;I have post the code.&lt;/BLOCKQUOTE&gt;
Where?&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;&lt;B&gt;Edit:&lt;/B&gt; I see - you posted it in the original message.&lt;E&gt;&lt;/E&gt;</description>
      <pubDate>Mon, 19 Jul 2010 08:46:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174357#M6050</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2010-07-19T08:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174358#M6051</link>
      <description>&lt;BLOCKQUOTE&gt;wcyoot wrote:&lt;BR /&gt;However when executing Geometry::StripPolygon2D(&amp;amp;cutline1,&amp;amp;cutline2, &amp;amp;polygon, &amp;amp;arPolygons, &amp;amp;wrcode), it crashed! Why?
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	HalfPlane2DData cutline1, cutline2;
	cutline1.sizeOfInhEdgeInfo = cutline2.sizeOfInhEdgeInfo = sizeof(long);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
I notice that you set &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;sizeOfInhEdgeInfo&lt;E&gt;&lt;/E&gt; for the &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;HalfPlane2DData&lt;E&gt;&lt;/E&gt; to a non-zero value, but don't populate &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;inhEdgeInfo&lt;E&gt;&lt;/E&gt; with anything? I can't say for certain, but that looks like a potential problem.</description>
      <pubDate>Mon, 19 Jul 2010 10:06:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174358#M6051</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2010-07-19T10:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174359#M6052</link>
      <description>Oh，I have no idea about how to set the HalfPlane2DData. there is no example.&lt;BR /&gt;
&lt;BR /&gt;
Can you tell me ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Mon, 19 Jul 2010 12:10:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174359#M6052</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-19T12:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174360#M6053</link>
      <description>&lt;BLOCKQUOTE&gt;wcyoot wrote:&lt;BR /&gt;Oh，I have no idea about how to set the HalfPlane2DData. there is no example. Can you tell me ?&lt;/BLOCKQUOTE&gt;
Unfortunately, no. I don't use any of these methods or classes because:&lt;UL&gt;&lt;LI&gt;1. They lack documentation and/or examples;&lt;BR /&gt;
&lt;BR /&gt;
2. I started developing add-ons before they were available, and was forced to write my own.&lt;/LI&gt;&lt;/UL&gt;I will eventually shift to the API classes/methods when the documentation is complete. You may be able to work it out by trial and error. I suggest setting &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;sizeOfInhEdgeInfo&lt;E&gt;&lt;/E&gt; to zero first. I'm guessing this data is not strictly essential for the operation.</description>
      <pubDate>Mon, 19 Jul 2010 19:13:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174360#M6053</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2010-07-19T19:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Geometry::StripPolygon2D()?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174361#M6054</link>
      <description>OK, I have solved it.&lt;BR /&gt;
&lt;BR /&gt;
Just clear all settings about the infos.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot for Ralph Wessel.</description>
      <pubDate>Tue, 20 Jul 2010 05:00:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-use-the-Geometry-StripPolygon2D/m-p/174361#M6054</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-20T05:00:14Z</dc:date>
    </item>
  </channel>
</rss>

