<?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: AcGePoint3d sorting in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3598230#M14405</link>
    <description>&lt;P&gt;That appears to have fixed it. Thanks to both of you. I thought I was passing in the address just because it was an array. Pretty embarrassing, but no telling how much time it saved me. Thanks again!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2012 14:04:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-08-28T14:04:10Z</dc:date>
    <item>
      <title>AcGePoint3d sorting</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597182#M14402</link>
      <description>&lt;P&gt;Probably more of a C++ question than ARX, and I'm sorry ahead of time, but can anyone tell me what is going wrong here? The code below will compile and run when I pass in an AcGePoint3dArray of several points, but the array is unchanged after it runs...&lt;/P&gt;&lt;PRE&gt;int pointSortByX(const void *p1, const void *p2){
	return ((AcGePoint3d*)p1)-&amp;gt;x - ((AcGePoint3d*)p2)-&amp;gt;x;}

int pointSortByY(const void *p1, const void *p2){
	return ((AcGePoint3d*)p1)-&amp;gt;y - ((AcGePoint3d*)p2)-&amp;gt;y;}

void sortPoints(AcGePoint3dArray allIntersPts)
{
	/*the first two elements are the start and endpoints. Use them to determine
	if the array should be sorted by x or y values. */
	
	double distInX = abs(allIntersPts.at(0).x - allIntersPts.at(1).x);
	double distInY = abs(allIntersPts.at(0).y - allIntersPts.at(1).y);
	
	//if the line is more vertical, then sort by the y-coords
	if(distInY &amp;gt; distInX)
		std::qsort(allIntersPts.asArrayPtr(), allIntersPts.length(), sizeof(AcGePoint3d), pointSortByY);
	//else the line is more horizontal, then sort by the x-coords
	else
		std::qsort(allIntersPts.asArrayPtr(), allIntersPts.length(), sizeof(AcGePoint3d), pointSortByX);
	return;
}


AcGePoint3dArray allIntersPts;
/*code to append some points*/
acutPrintf(_T("\nBefore sort:"));
		for(int i = 0; i &amp;lt; allIntersPts.logicalLength(); i++)
			acutPrintf(_T("\n%d: %.3f, %.3f"), i, allIntersPts.at(i).x, allIntersPts.at(i).y);

sortPoints(allIntersPts);

acutPrintf(_T("\nAfter sort:"));
		for(int i = 0; i &amp;lt; allIntersPts.logicalLength(); i++)
			acutPrintf(_T("\n%d: %.3f, %.3f"), i, allIntersPts.at(i).x, allIntersPts.at(i).y);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;TIA,&lt;/P&gt;&lt;P&gt;Ralph Gaston&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 20:12:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597182#M14402</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-27T20:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: AcGePoint3d sorting</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597362#M14403</link>
      <description>&lt;P&gt;You need to pass the array by reference so that you are operating on the original array not a copy.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 22:44:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597362#M14403</guid>
      <dc:creator>artc2</dc:creator>
      <dc:date>2012-08-27T22:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: AcGePoint3d sorting</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597364#M14404</link>
      <description>&lt;P&gt;It looks like you intended to pass&amp;nbsp; the argument to sortPoints() by reference instead of by value.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 22:45:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3597364#M14404</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2012-08-27T22:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: AcGePoint3d sorting</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3598230#M14405</link>
      <description>&lt;P&gt;That appears to have fixed it. Thanks to both of you. I thought I was passing in the address just because it was an array. Pretty embarrassing, but no telling how much time it saved me. Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 14:04:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acgepoint3d-sorting/m-p/3598230#M14405</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-28T14:04:10Z</dc:date>
    </item>
  </channel>
</rss>

