<?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: What's wrong? in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11089850#M2644</link>
    <description>&lt;P&gt;Have a look at the code in curveChain.cpp in the attached ZIP. &lt;BR /&gt;I think it is effective and understandable.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 10:04:30 GMT</pubDate>
    <dc:creator>tbrammer</dc:creator>
    <dc:date>2022-04-07T10:04:30Z</dc:date>
    <item>
      <title>What's wrong?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11071152#M2641</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;static void MSDDMyGroupMyCommand0 () {
	ads_name ss;
	resbuf *rbList = acutBuildList(RTDXF0, _T("LWPOLYLINE"),RTNONE);
	if (RTNORM != acedSSGet(NULL, NULL, NULL, rbList, ss))
	{
		acutRelRb(rbList);
		return;
	}
	acutRelRb(rbList);

	Adesk::Int32 nSSLength = 0;
	acedSSLength(ss, &amp;amp;nSSLength);
	vector&amp;lt;AcGePoint2dArray&amp;gt; Ptss;
	AcGePoint2dArray ptstemp;
	for (Adesk::Int32 i = 0; i &amp;lt; nSSLength; i++)
	{
		ads_name ent;
		acedSSName(ss, i, ent);
		AcDbObjectId objId;
		acdbGetObjectId(objId, ent);
		GetAcDb2dPolyPoints(objId,ptstemp);
		Ptss.push_back(ptstemp);
	}
	vector&amp;lt;vector&amp;lt;AcGePoint2dArray&amp;gt;&amp;gt; ptsu,ptsn;
	GetConnected(Ptss, ptsu,ptsn);
	acedSSFree(ss);

	acutPrintf(_T("\n Enclosed area: %d "),ptsu.size());
	acutPrintf(_T("\nOpen area: %d "),ptsn.size());
}


static void GetConnected(vector&amp;lt;AcGePoint2dArray&amp;gt; Ptss, vector&amp;lt;vector&amp;lt;AcGePoint2dArray&amp;gt;&amp;gt; &amp;amp;VPtss, vector&amp;lt;vector&amp;lt;AcGePoint2dArray&amp;gt;&amp;gt; &amp;amp;VtempC)
{
	while (Ptss.size() &amp;gt; 0)
	{
		vector&amp;lt;AcGePoint2dArray&amp;gt; tempY,tempN,tempC;

		AcGePoint2d sta = Ptss.back().first();   
		AcGePoint2d end = Ptss.back().last();
		tempY.push_back(Ptss.back());
		Ptss.pop_back();
		tempN.clear();

		bool TN=true;
		while ((sta.distanceTo(end) &amp;gt; 1e-7) &amp;amp;&amp;amp; TN)
		{
			int stalen = (int)Ptss.size();
			for (Adesk::Int32 i = 0; i &amp;lt; Ptss.size(); i++)
			{
				AcGePoint2d sta1 = Ptss.at(i).first();   
				AcGePoint2d end1 = Ptss.at(i).last();
				double kk1 = sta.distanceTo(sta1);
				double kk2 = sta.distanceTo(end1);

				if ( kk1 &amp;lt;= 1e-7 || kk2 &amp;lt;= 1e-7 )
				{
					if  ( bool kk = (kk1 &amp;lt;= 1e-7))
					{
						Ptss.at(i).reverse();	
						sta = Ptss.at(i).at(0);
						tempY.push_back(Ptss.at(i));
                                                Ptss.removeat(i);
						 
					}
					if ( bool kk = (kk2 &amp;lt;= 1e-7))
					{
						sta = Ptss.at(i).at(0);
						tempY.push_back(Ptss.at(i));
						  Ptss.removeat(i);
					}
				} 
				else
				{
					tempN.push_back(Ptss.at(i));
				}

			} //for end
			int entlen = (int)Ptss.size();

	 
		}//(sta.distanceTo(end)!= 1e-7) end
		VPtss.push_back(tempY);
		Ptss=tempN;
	}//while(Ptss.size() &amp;gt; 0) end
}

	static void  GetAcDb2dPolyPoints(AcDbObjectId id, AcGePoint2dArray &amp;amp;ptas)
{
	AcDbEntity *pEnt = NULL;
	acdbOpenObject(pEnt, id, AcDb::kForWrite);
	if (pEnt-&amp;gt;isKindOf(AcDbPolyline::desc()))
	{
		AcDbPolyline *pPline=AcDbPolyline::cast(pEnt);
		int num =pPline-&amp;gt;numVerts();
		AcGePoint2d pt;
		for (int i=0;i&amp;lt;num;i++)
		{		
			pPline-&amp;gt;getPointAt(i,pt);
			ptas.append(pt);
		}
		pPline-&amp;gt;close();
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 00:16:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11071152#M2641</guid>
      <dc:creator>463017170</dc:creator>
      <dc:date>2022-04-05T00:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11083507#M2642</link>
      <description>&lt;P&gt;I can't compile your code because of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;static void GetConnected(vector&amp;lt;AcGePoint2dArray&amp;gt; Ptss,...)
   Ptss.removeat(i);  // std::removeat() doesn't exist
   // Ptss.erase(Ptss.begin() + i); // possible solution with std::vector&amp;lt;&amp;gt;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suppose that &lt;FONT face="courier new,courier"&gt;vector&amp;lt;&amp;gt;&lt;/FONT&gt; is meant to be &lt;FONT face="courier new,courier"&gt;std::vector&amp;lt;&amp;gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;If I fix the code as mentioned in the comment above I run into an infinite loop in &lt;FONT face="courier new,courier"&gt;GetConnected(..)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;because the loop&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;while ((sta.distanceTo(end) &amp;gt; 1e-7) &amp;amp;&amp;amp; TN)&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; is never left if there is no matching curve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think there is no reason to retrieve &lt;U&gt;all&lt;/U&gt; polyline points. You only need start-and endpoint if the curve isn't closed.&lt;/P&gt;
&lt;P&gt;Use &lt;FONT face="courier new,courier"&gt;bool AcDbCurve::isClosed()&lt;/FONT&gt;&amp;nbsp;and if the curve isn't close get the start/endpoint with&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;AcDbCurve::getStartPoint(pStart)&lt;/FONT&gt; and&amp;nbsp; &lt;FONT face="courier new,courier"&gt;AcDbCurve::getEndPoint(pEnd)&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend not to use the 2D-points from &lt;FONT face="courier new,courier"&gt;pPline-&amp;gt;getPointAt(i, pt)&lt;/FONT&gt;. These 2D points refer to the ECS of the polyline. If you happen to find polylines with different ECS it makes no sense to compare the 2D points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 08:11:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11083507#M2642</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-04-05T08:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11083719#M2643</link>
      <description>&lt;P&gt;Thank you for your help. I've changed it. I just don't know if there is a faster way?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 09:54:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11083719#M2643</guid>
      <dc:creator>463017170</dc:creator>
      <dc:date>2022-04-05T09:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11089850#M2644</link>
      <description>&lt;P&gt;Have a look at the code in curveChain.cpp in the attached ZIP. &lt;BR /&gt;I think it is effective and understandable.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 10:04:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11089850#M2644</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-04-07T10:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11090121#M2645</link>
      <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:59:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/what-s-wrong/m-p/11090121#M2645</guid>
      <dc:creator>463017170</dc:creator>
      <dc:date>2022-04-07T11:59:39Z</dc:date>
    </item>
  </channel>
</rss>

