opennurbs_array.cpp
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs.h"   // openNURBS declarations of functions that perform simple calculations
00018 
00019 ON_2dPointArray::ON_2dPointArray() 
00020 {}
00021 
00022 ON_2dPointArray::ON_2dPointArray(int c) 
00023                 : ON_SimpleArray<ON_2dPoint>(c) 
00024 {}
00025 
00026 ON_2dPointArray::ON_2dPointArray(const ON_2dPointArray& src) 
00027                 : ON_SimpleArray<ON_2dPoint>(src)
00028 {}
00029 
00030 bool ON_2dPointArray::GetBBox( // returns true if successful
00031        double boxmin[2],
00032        double boxmax[2],
00033        int bGrowBox
00034        ) const
00035 {
00036   return ON_GetPointListBoundingBox( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00037 }
00038 
00039 bool ON_2dPointArray::Transform( const ON_Xform& xform )
00040 {
00041   return ON_TransformPointList( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, xform );
00042 }
00043 
00044 bool ON_2dPointArray::SwapCoordinates( int i, int j )
00045 {
00046   return ON_SwapPointListCoordinates( Count(), 2, (m_a) ? &m_a[0].x : 0, i, j );
00047 }
00048 
00049 ON_2dPointArray& ON_2dPointArray::operator=(const ON_2dPointArray& src)
00050 {
00051   if ( this != &src ) {
00052     ON_SimpleArray<ON_2dPoint>::operator=(src);
00053   }
00054   return *this;
00055 }
00056 
00057 ON_3dPointArray::ON_3dPointArray() 
00058 {}
00059 
00060 ON_3dPointArray::ON_3dPointArray(int c) : ON_SimpleArray<ON_3dPoint>(c) 
00061 {}
00062 
00063 ON_3dPointArray::ON_3dPointArray(const ON_SimpleArray<ON_3dPoint>& src) 
00064                 : ON_SimpleArray<ON_3dPoint>(src)
00065 {}
00066 
00067 ON_3dPointArray::ON_3dPointArray(const ON_SimpleArray<ON_3fPoint>& src) 
00068 {
00069   *this = src;
00070 }
00071 
00072 ON_BoundingBox ON_3dPointArray::BoundingBox() const
00073 {
00074   ON_BoundingBox bbox;
00075   GetBoundingBox(bbox);
00076   return bbox;
00077 }
00078 
00079 bool ON_3dPointArray::GetBoundingBox( 
00080   ON_BoundingBox& bbox,
00081   int bGrowBox
00082   ) const
00083 {
00084   return GetBBox( &bbox.m_min.x, &bbox.m_max.x, bGrowBox );
00085 }
00086 
00087 bool ON_3dPointArray::GetBBox( // returns true if successful
00088        double boxmin[3],
00089        double boxmax[3],
00090        int bGrowBox
00091        ) const
00092 {
00093   return ON_GetPointListBoundingBox( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00094 }
00095 
00096 bool ON_3dPointArray::Transform( const ON_Xform& xform )
00097 {
00098   return ON_TransformPointList( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, xform );
00099 }
00100 
00101 bool ON_3dPointArray::SwapCoordinates( int i, int j )
00102 {
00103   return ON_SwapPointListCoordinates( Count(), 3, (m_a) ? &m_a[0].x : 0, i, j );
00104 }
00105 
00106 
00107 bool ON_3dPointArray::Rotate(
00108       double sin_angle,
00109       double cos_angle,
00110       const ON_3dVector& axis_of_rotation,
00111       const ON_3dPoint& center_of_rotation
00112       )
00113 {
00114   const int count = m_count;
00115   ON_Xform rot;
00116   rot.Rotation( sin_angle, cos_angle, axis_of_rotation, center_of_rotation );
00117   ON_SimpleArray<int> fix_index(128);
00118   int i;
00119   for ( i = 0; i < count; i++ ) {
00120     if ( m_a[i] == center_of_rotation )
00121       fix_index.Append(i);
00122   }
00123   const bool rc = Transform( rot );
00124   for ( i = 0; i < fix_index.Count(); i++ ) {
00125     m_a[fix_index[i]] = center_of_rotation;
00126   }
00127   return rc;
00128 }
00129 
00130 bool ON_3dPointArray::Rotate(
00131       double angle_in_radians,
00132       const ON_3dVector& axis_of_rotation,
00133       const ON_3dPoint& center_of_rotation
00134       )
00135 {
00136   return Rotate( sin(angle_in_radians), cos(angle_in_radians), axis_of_rotation, center_of_rotation );
00137 }
00138 
00139 bool ON_3dPointArray::Translate(
00140       const ON_3dVector& delta
00141       )
00142 {
00143   int i;
00144   for (i=0;i<m_count;i++)
00145     m_a[i]+=delta;
00146   return (m_count>0)?true:false;
00147 }
00148 
00149 
00150 ON_3dPointArray& ON_3dPointArray::operator=(const ON_3dPointArray& src)
00151 {
00152   if ( this != &src ) {
00153     ON_SimpleArray<ON_3dPoint>::operator=(src);
00154   }
00155   return *this;
00156 }
00157 
00158 
00159 ON_3dPointArray& ON_3dPointArray::operator=(const ON_SimpleArray<ON_3fPoint>& src)
00160 {
00161   Create( 3, false, src.Count(), 3, (const float*)src.Array() );
00162   return *this;
00163 }
00164 
00165 
00166 bool ON_3dPointArray::Create( 
00167   int point_dimension,
00168   int bRational,
00169   int point_count,
00170   int point_stride,
00171   const double* points
00172   )
00173 {
00174   bool rc = false;
00175   if (     point_dimension >= 2 && point_dimension <= 3 
00176         && point_count>0 && points 
00177         && point_stride >= bRational?(point_dimension+1):point_dimension )
00178   {
00179     rc = true;
00180     int i;
00181     ON_3dPoint q(0.0,0.0,0.0);
00182     ON_4dPoint h(0.0,0.0,0.0,1.0);
00183     m_count = 0;
00184     SetCapacity(point_count);
00185     SetCount(point_count);
00186     if ( bRational )
00187     {
00188       for ( i = 0; i < point_count; i++ )
00189       {
00190         h.x = points[0];
00191         h.y = points[1];
00192         if ( point_dimension == 3 )
00193           h.z = points[2];
00194         h.w = points[point_dimension];
00195         m_a[i] = h;
00196         points += point_stride;
00197       }
00198     }
00199     else
00200     {
00201       for ( i = 0; i < point_count; i++ )
00202       {
00203         q.x = points[0];
00204         q.y = points[1];
00205         if ( point_dimension == 3 )
00206           q.z = points[2];
00207         m_a[i] = q;
00208         points += point_stride;
00209       }
00210     }
00211   }
00212   else
00213     Destroy();
00214   return rc;
00215 }
00216 
00217 
00218 bool ON_3dPointArray::Create( 
00219   int point_dimension,
00220   int bRational,
00221   int point_count,
00222   int point_stride,
00223   const float* points
00224   )
00225 {
00226   bool rc = false;
00227   if (     point_dimension >= 2 && point_dimension <= 3 
00228         && point_count>0 && points 
00229         && point_stride >= bRational?(point_dimension+1):point_dimension )
00230   {
00231     rc = true;
00232     int i;
00233     ON_3dPoint q(0.0,0.0,0.0);
00234     ON_4dPoint h(0.0,0.0,0.0,1.0);
00235     m_count = 0;
00236     SetCapacity(point_count);
00237     SetCount(point_count);
00238     if ( bRational )
00239     {
00240       for ( i = 0; i < point_count; i++ )
00241       {
00242         h.x = points[0];
00243         h.y = points[1];
00244         if ( point_dimension == 3 )
00245           h.z = points[2];
00246         h.w = points[point_dimension];
00247         m_a[i] = h;
00248         points += point_stride;
00249       }
00250     }
00251     else
00252     {
00253       for ( i = 0; i < point_count; i++ )
00254       {
00255         q.x = points[0];
00256         q.y = points[1];
00257         if ( point_dimension == 3 )
00258           q.z = points[2];
00259         m_a[i] = q;
00260         points += point_stride;
00261       }
00262     }
00263   }
00264   else
00265     Destroy();
00266   return rc;
00267 }
00268 
00269 
00270 
00271 ON_4dPointArray::ON_4dPointArray() 
00272 {}
00273 
00274 ON_4dPointArray::ON_4dPointArray(int c) : ON_SimpleArray<ON_4dPoint>(c) 
00275 {}
00276 
00277 ON_4dPointArray::ON_4dPointArray(const ON_4dPointArray& src) : ON_SimpleArray<ON_4dPoint>(src)
00278 {}
00279 
00280 bool ON_4dPointArray::Transform( const ON_Xform& xform )
00281 {
00282   return ON_TransformPointList( 3, true, Count(), 4, (m_a) ? &m_a[0].x : 0, xform );
00283 }
00284 
00285 bool ON_4dPointArray::SwapCoordinates( int i, int j )
00286 {
00287   return ON_SwapPointListCoordinates( Count(), 4, (m_a) ? &m_a[0].x : 0, i, j );
00288 }
00289 
00290 ON_4dPointArray& ON_4dPointArray::operator=(const ON_4dPointArray& src)
00291 {
00292   if ( this != &src ) {
00293     ON_SimpleArray<ON_4dPoint>::operator=(src);
00294   }
00295   return *this;
00296 }
00297 
00298 ON_2dVectorArray::ON_2dVectorArray() 
00299 {}
00300 
00301 ON_2dVectorArray::ON_2dVectorArray(int c) : ON_SimpleArray<ON_2dVector>(c) 
00302 {}
00303 
00304 ON_2dVectorArray::ON_2dVectorArray(const ON_2dVectorArray& src) : ON_SimpleArray<ON_2dVector>(src)
00305 {}
00306 
00307 bool ON_2dVectorArray::GetBBox( // returns true if successful
00308        double boxmin[2],
00309        double boxmax[2],
00310        int bGrowBox
00311        ) const
00312 {
00313   return ON_GetPointListBoundingBox( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00314 }
00315 
00316 bool ON_2dVectorArray::Transform( const ON_Xform& xform )
00317 {
00318   return ON_TransformPointList( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, xform );
00319 }
00320 
00321 bool ON_2dVectorArray::SwapCoordinates( int i, int j )
00322 {
00323   return ON_SwapPointListCoordinates( Count(), 2, (m_a) ? &m_a[0].x : 0, i, j );
00324 }
00325 
00326 ON_2dVectorArray& ON_2dVectorArray::operator=(const ON_2dVectorArray& src)
00327 {
00328   if ( this != &src ) {
00329     ON_SimpleArray<ON_2dVector>::operator=(src);
00330   }
00331   return *this;
00332 }
00333 
00334 ON_3dVectorArray::ON_3dVectorArray() 
00335 {}
00336 
00337 ON_3dVectorArray::ON_3dVectorArray(int c) : ON_SimpleArray<ON_3dVector>(c) 
00338 {}
00339 
00340 ON_3dVectorArray::ON_3dVectorArray(const ON_3dVectorArray& src) : ON_SimpleArray<ON_3dVector>(src)
00341 {}
00342 
00343 bool ON_3dVectorArray::GetBBox(
00344        double boxmin[3],
00345        double boxmax[3],
00346        bool bGrowBox
00347        ) const
00348 {
00349   return ON_GetPointListBoundingBox( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00350 }
00351 
00352 bool ON_3dVectorArray::Transform( const ON_Xform& xform )
00353 {
00354   return ON_TransformPointList( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, xform );
00355 }
00356 
00357 bool ON_3dVectorArray::SwapCoordinates( int i, int j )
00358 {
00359   return ON_SwapPointListCoordinates( Count(), 3, (m_a) ? &m_a[0].x : 0, i, j );
00360 }
00361 
00362 ON_3dVectorArray& ON_3dVectorArray::operator=(const ON_3dVectorArray& src)
00363 {
00364   if ( this != &src ) {
00365     ON_SimpleArray<ON_3dVector>::operator=(src);
00366   }
00367   return *this;
00368 }
00369 
00373 ON_2fPointArray::ON_2fPointArray() 
00374 {}
00375 
00376 ON_2fPointArray::ON_2fPointArray(int c) 
00377                 : ON_SimpleArray<ON_2fPoint>(c) 
00378 {}
00379 
00380 ON_2fPointArray::ON_2fPointArray(const ON_2fPointArray& src) 
00381                 : ON_SimpleArray<ON_2fPoint>(src)
00382 {}
00383 
00384 bool ON_2fPointArray::GetBBox( // returns true if successful
00385        float boxmin[2],
00386        float boxmax[2],
00387        int bGrowBox
00388        ) const
00389 {
00390   return ON_GetPointListBoundingBox( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00391 }
00392 
00393 bool ON_2fPointArray::Transform( const ON_Xform& xform )
00394 {
00395   return ON_TransformPointList( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, xform );
00396 }
00397 
00398 bool ON_2fPointArray::SwapCoordinates( int i, int j )
00399 {
00400   return ON_SwapPointListCoordinates( Count(), 2, (m_a) ? &m_a[0].x : 0, i, j );
00401 }
00402 
00403 ON_2fPointArray& ON_2fPointArray::operator=(const ON_2fPointArray& src)
00404 {
00405   if ( this != &src ) {
00406     ON_SimpleArray<ON_2fPoint>::operator=(src);
00407   }
00408   return *this;
00409 }
00410 
00411 
00412 ON_3fPointArray::ON_3fPointArray() 
00413 {}
00414 
00415 ON_3fPointArray::ON_3fPointArray(int c) : ON_SimpleArray<ON_3fPoint>(c)
00416 {}
00417 
00418 ON_3fPointArray::ON_3fPointArray(const ON_3fPointArray& src) : ON_SimpleArray<ON_3fPoint>(src)
00419 {}
00420 
00421 bool ON_3fPointArray::GetBBox( // returns true if successful
00422        float boxmin[3],
00423        float boxmax[3],
00424        int bGrowBox
00425        ) const
00426 {
00427   return ON_GetPointListBoundingBox( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00428 }
00429 
00430 bool ON_3fPointArray::Transform( const ON_Xform& xform )
00431 {
00432   return ON_TransformPointList( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, xform );
00433 }
00434 
00435 bool ON_3fPointArray::SwapCoordinates( int i, int j )
00436 {
00437   return ON_SwapPointListCoordinates( Count(), 3, (m_a) ? &m_a[0].x : 0, i, j );
00438 }
00439 
00440 ON_3fPointArray& ON_3fPointArray::operator=(const ON_3fPointArray& src)
00441 {
00442   if ( this != &src ) {
00443     ON_SimpleArray<ON_3fPoint>::operator=(src);
00444   }
00445   return *this;
00446 }
00447 
00448 ON_4fPointArray::ON_4fPointArray() 
00449 {}
00450 
00451 ON_4fPointArray::ON_4fPointArray(int c) : ON_SimpleArray<ON_4fPoint>(c) 
00452 {}
00453 
00454 ON_4fPointArray::ON_4fPointArray(const ON_4fPointArray& src) : ON_SimpleArray<ON_4fPoint>(src)
00455 {}
00456 
00457 bool ON_4fPointArray::Transform( const ON_Xform& xform )
00458 {
00459   return ON_TransformPointList( 3, true, Count(), 4, (m_a) ? &m_a[0].x : 0, xform );
00460 }
00461 
00462 bool ON_4fPointArray::SwapCoordinates( int i, int j )
00463 {
00464   return ON_SwapPointListCoordinates( Count(), 4, (m_a) ? &m_a[0].x : 0, i, j );
00465 }
00466 
00467 ON_4fPointArray& ON_4fPointArray::operator=(const ON_4fPointArray& src)
00468 {
00469   if ( this != &src ) {
00470     ON_SimpleArray<ON_4fPoint>::operator=(src);
00471   }
00472   return *this;
00473 }
00474 
00475 ON_2fVectorArray::ON_2fVectorArray() 
00476 {}
00477 
00478 ON_2fVectorArray::ON_2fVectorArray(int c) : ON_SimpleArray<ON_2fVector>(c) 
00479 {}
00480 
00481 ON_2fVectorArray::ON_2fVectorArray(const ON_2fVectorArray& src) : ON_SimpleArray<ON_2fVector>(src)
00482 {}
00483 
00484 bool ON_2fVectorArray::GetBBox(
00485        float boxmin[2],
00486        float boxmax[2],
00487        bool bGrowBox
00488        ) const
00489 {
00490   return ON_GetPointListBoundingBox( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00491 }
00492 
00493 bool ON_2fVectorArray::Transform( const ON_Xform& xform )
00494 {
00495   return ON_TransformPointList( 2, false, Count(), 2, (m_a) ? &m_a[0].x : 0, xform );
00496 }
00497 
00498 bool ON_2fVectorArray::SwapCoordinates( int i, int j )
00499 {
00500   return ON_SwapPointListCoordinates( Count(), 2, (m_a) ? &m_a[0].x : 0, i, j );
00501 }
00502 
00503 ON_2fVectorArray& ON_2fVectorArray::operator=(const ON_2fVectorArray& src)
00504 {
00505   if ( this != &src ) {
00506     ON_SimpleArray<ON_2fVector>::operator=(src);
00507   }
00508   return *this;
00509 }
00510 
00511 ON_3fVectorArray::ON_3fVectorArray() 
00512 {}
00513 
00514 ON_3fVectorArray::ON_3fVectorArray(int c) : ON_SimpleArray<ON_3fVector>(c) 
00515 {}
00516 
00517 ON_3fVectorArray::ON_3fVectorArray(const ON_3fVectorArray& src) : ON_SimpleArray<ON_3fVector>(src)
00518 {}
00519 
00520 bool ON_3fVectorArray::GetBBox( // returns true if successful
00521        float boxmin[3],
00522        float boxmax[3],
00523        int bGrowBox
00524        ) const
00525 {
00526   return ON_GetPointListBoundingBox( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, boxmin, boxmax, bGrowBox );
00527 }
00528 
00529 bool ON_3fVectorArray::Transform( const ON_Xform& xform )
00530 {
00531   return ON_TransformPointList( 3, false, Count(), 3, (m_a) ? &m_a[0].x : 0, xform );
00532 }
00533 
00534 bool ON_3fVectorArray::SwapCoordinates( int i, int j )
00535 {
00536   return ON_SwapPointListCoordinates( Count(), 3, (m_a) ? &m_a[0].x : 0, i, j );
00537 }
00538 
00539 ON_3fVectorArray& ON_3fVectorArray::operator=(const ON_3fVectorArray& src)
00540 {
00541   if ( this != &src ) {
00542     ON_SimpleArray<ON_3fVector>::operator=(src);
00543   }
00544   return *this;
00545 }
00546 
00547 ON_UuidPair::ON_UuidPair()
00548 {
00549   memset(this,0,sizeof(*this));
00550 }
00551 
00552 int ON_UuidPair::CompareFirstUuid(const class ON_UuidPair* a,const class ON_UuidPair* b)
00553 {
00554   if (!a)
00555   {
00556     return (b) ? -1 : 0;
00557   }
00558   if (!b)
00559   {
00560     return 1;
00561   }
00562   return ON_UuidCompare(a->m_uuid[0],b->m_uuid[0]);
00563 }
00564 
00565 int ON_UuidPair::CompareSecondUuid(const class ON_UuidPair* a,const class ON_UuidPair* b)
00566 {
00567   if (!a)
00568   {
00569     return (b) ? -1 : 0;
00570   }
00571   if (!b)
00572   {
00573     return 1;
00574   }
00575   return ON_UuidCompare(a->m_uuid[1],b->m_uuid[1]);
00576 }
00577 
00578 int ON_UuidPair::Compare(const class ON_UuidPair* a,const class ON_UuidPair* b)
00579 {
00580   int i;
00581   if (!a)
00582   {
00583     return (b) ? -1 : 0;
00584   }
00585   if (!b)
00586   {
00587     return 1;
00588   }
00589   if ( 0 == (i = ON_UuidCompare(a->m_uuid[0],b->m_uuid[0])) )
00590   {
00591     i = ON_UuidCompare(a->m_uuid[1],b->m_uuid[1]);
00592   }
00593   return i;
00594 }
00595 
00596 ON_UuidList::ON_UuidList() 
00597                      : ON_SimpleArray<ON_UUID>(32),
00598                        m_sorted_count(0),
00599                        m_removed_count(0)
00600 {
00601 }
00602 
00603 ON_UuidList::ON_UuidList(int capacity) 
00604                      : ON_SimpleArray<ON_UUID>(capacity),
00605                        m_sorted_count(0),
00606                        m_removed_count(0)
00607 {
00608 }
00609 
00610 ON_UuidList::~ON_UuidList()
00611 {
00612   m_sorted_count = 0;
00613   m_removed_count = 0;
00614 }
00615 
00616 ON_UuidList::ON_UuidList(const ON_UuidList& src) 
00617                      : ON_SimpleArray<ON_UUID>(src),
00618                        m_sorted_count(src.m_sorted_count),
00619                        m_removed_count(src.m_removed_count)
00620 {
00621 }
00622 
00623 ON_UuidList& ON_UuidList::operator=(const ON_UuidList& src)
00624 {
00625   if ( this != &src)
00626   {
00627     ON_SimpleArray<ON_UUID>::operator=(src);
00628     m_sorted_count = src.m_sorted_count;
00629     m_removed_count = src.m_removed_count;
00630   }
00631   return *this;
00632 }
00633 
00634 
00635 bool ON_UuidList::AddUuid(ON_UUID uuid, bool bCheckForDupicates)
00636 {
00637   bool rc = bCheckForDupicates ? !FindUuid(uuid) : true;
00638   if (rc)
00639   {
00640     Append(uuid);
00641   }
00642   return rc;
00643 }
00644 
00645 int ON_UuidList::Count() const
00646 {
00647   return m_count - m_removed_count;
00648 }
00649 
00650 int ON_UuidList::CompareUuid(const ON_UUID* a, const ON_UUID* b)
00651 {
00652   return memcmp(a,b,sizeof(*a));
00653 }
00654 
00655 void ON_UuidList::SortHelper()
00656 {
00657   if ( m_sorted_count < m_count || m_removed_count > 0 )
00658   {
00659     // clean up array
00660     QuickSort(ON_UuidList::CompareUuid);
00661     while ( m_count > 0 && ON_max_uuid == m_a[m_count-1] )
00662     {
00663       m_count--;
00664     }
00665     m_removed_count = 0;
00666     m_sorted_count = m_count;
00667   }
00668 }
00669 const ON_UUID* ON_UuidList::Array() const
00670 {
00671   const ON_UUID* array = 0;
00672   if ( m_count > m_removed_count )
00673   {
00674     const_cast<ON_UuidList*>(this)->SortHelper();
00675     if (m_count > 0 && m_sorted_count == m_count && 0 == m_removed_count )
00676       array = m_a;
00677   }
00678   return array;
00679 }
00680 
00681 void ON_UuidList::Empty()
00682 {
00683   m_count = 0;
00684   m_sorted_count = 0;
00685   m_removed_count = 0;
00686 }
00687 
00688 void ON_UuidList::Destroy()
00689 {
00690   ON_SimpleArray<ON_UUID>::Destroy();
00691   m_count = 0;
00692   m_sorted_count = 0;
00693   m_removed_count = 0;
00694 }
00695 
00696 void ON_UuidList::Reserve(int capacity)
00697 {
00698   ON_SimpleArray<ON_UUID>::Reserve(capacity);
00699 }
00700 
00701 bool ON_UuidList::RemoveUuid(ON_UUID uuid)
00702 {
00703   ON_UUID* p = SearchHelper(&uuid);
00704   if ( 0 != p )
00705   {
00706     *p = ON_max_uuid;
00707     m_removed_count++;
00708   }
00709   return (0!=p);
00710 }
00711 
00712 void ON_UuidList::Compact()
00713 {
00714   SortHelper();
00715   SetCapacity(m_count);
00716 }
00717 
00718 bool ON_UuidList::Write( class ON_BinaryArchive& archive ) const
00719 {
00720   bool rc = archive.BeginWrite3dmChunk( TCODE_ANONYMOUS_CHUNK, 1, 0 );
00721   if (rc)
00722   {
00723     const_cast<ON_UuidList*>(this)->SortHelper();
00724     rc = archive.WriteArray( *this );
00725     if ( !archive.EndWrite3dmChunk() )
00726       rc = false;
00727   }
00728   return rc;
00729 }
00730 
00731 bool ON_UuidList::Read( class ON_BinaryArchive& archive )
00732 {
00733   m_count = 0;
00734   m_removed_count = 0;
00735   m_sorted_count = 0;
00736   int major_version = 0;
00737   int minor_version = 0;
00738   bool rc = archive.BeginRead3dmChunk( TCODE_ANONYMOUS_CHUNK, 
00739                                        &major_version, 
00740                                        &minor_version );
00741   if (rc)
00742   {
00743     if ( 1 != major_version )
00744       rc = false;
00745 
00746     if (rc)
00747       rc = archive.ReadArray( *this );
00748 
00749     if ( !archive.EndRead3dmChunk() )
00750       rc = false;
00751   }
00752 
00753   SortHelper();
00754 
00755   return rc;
00756 }
00757 
00758 
00759 bool ON_UuidList::FindUuid(ON_UUID uuid) const
00760 {
00761   return (0!=SearchHelper(&uuid));
00762 }
00763 
00764 ON_UUID* ON_UuidList::SearchHelper(const ON_UUID* uuid) const
00765 {
00766   if ( m_count - m_sorted_count > 8 || m_removed_count > 0 )
00767   {
00768     // time to resort the array so that the speedy
00769     // bsearch() can be used to find uuids
00770     const_cast<ON_UuidList*>(this)->SortHelper();
00771   }
00772 
00773   ON_UUID* p = (m_sorted_count > 0 )
00774              ? (ON_UUID*)bsearch( uuid, m_a, m_sorted_count, sizeof(m_a[0]), 
00775                                   (int(*)(const void*,const void*))ON_UuidList::CompareUuid ) 
00776              : 0;
00777 
00778   if (0 == p)
00779   {
00780     // do a slow search on the last m_count-m_sort_count elements
00781     // in the array.
00782     int i;
00783     for ( i = m_sorted_count; i < m_count; i++ )
00784     {
00785       if ( 0 == ON_UuidList::CompareUuid(uuid,m_a+i) )
00786       {
00787         p = m_a+i;
00788         break;
00789       }
00790     }
00791   }
00792 
00793   return p;
00794 }
00795 
00796 
00797 
00798 ON_UuidIndexList::ON_UuidIndexList() 
00799                      : ON_SimpleArray<ON_UuidIndex>(32),
00800                        m_sorted_count(0),
00801                        m_removed_count(0)
00802 {
00803 }
00804 
00805 ON_UuidIndexList::ON_UuidIndexList(int capacity) 
00806                      : ON_SimpleArray<ON_UuidIndex>(capacity>32?capacity:32),
00807                        m_sorted_count(0),
00808                        m_removed_count(0)
00809 {
00810 }
00811 
00812 ON_UuidIndexList::~ON_UuidIndexList()
00813 {
00814   m_sorted_count = 0;
00815   m_removed_count = 0;
00816 }
00817 
00818 ON_UuidIndexList::ON_UuidIndexList(const ON_UuidIndexList& src) 
00819                      : ON_SimpleArray<ON_UuidIndex>(src),
00820                        m_sorted_count(src.m_sorted_count),
00821                        m_removed_count(src.m_removed_count)
00822 {
00823 }
00824 
00825 ON_UuidIndexList& ON_UuidIndexList::operator=(const ON_UuidIndexList& src)
00826 {
00827   if ( this != &src)
00828   {
00829     ON_SimpleArray<ON_UuidIndex>::operator=(src);
00830     m_sorted_count = src.m_sorted_count;
00831     m_removed_count = src.m_removed_count;
00832   }
00833   return *this;
00834 }
00835 
00836 bool ON_UuidIndexList::AddUuidIndex(ON_UUID uuid, int index, bool bCheckForDupicates)
00837 {
00838   bool rc = bCheckForDupicates ? !FindUuid(uuid,NULL) : true;
00839   if (rc)
00840   {
00841     if ( ON_max_uuid == uuid )
00842       rc = 0;
00843     else
00844     {
00845       ON_UuidIndex& ui = AppendNew();
00846       ui.m_id = uuid;
00847       ui.m_i = index;
00848     }
00849   }
00850   return rc;
00851 }
00852 
00853 int ON_UuidIndexList::Count() const
00854 {
00855   return m_count - m_removed_count;
00856 }
00857 
00858 void ON_UuidIndexList::Empty()
00859 {
00860   m_count = 0;
00861   m_sorted_count = 0;
00862   m_removed_count = 0;
00863 }
00864 
00865 void ON_UuidIndexList::Reserve( int capacity )
00866 {
00867   if( m_capacity < capacity )
00868     SetCapacity( capacity );
00869 }
00870 
00871 bool ON_UuidIndexList::RemoveUuid(ON_UUID uuid)
00872 {
00873   ON_UuidIndex* p = SearchHelper(&uuid);
00874   if ( 0 != p )
00875   {
00876     p->m_id = ON_max_uuid;
00877     m_removed_count++;
00878     unsigned int i = (unsigned int)(p - m_a);
00879     if ( i < m_sorted_count )
00880       m_sorted_count = i;
00881   }
00882   return (0!=p);
00883 }
00884 
00885 static
00886 int compar_uuidindex_uuid(const ON_UuidIndex* a, const ON_UuidIndex* b)
00887 {
00888   return ON_UuidList::CompareUuid(&a->m_id,&b->m_id);
00889 }
00890 
00891 bool ON_UuidIndexList::FindUuid(ON_UUID uuid, int* index) const
00892 {
00893   const ON_UuidIndex* ui = SearchHelper(&uuid);
00894   if (ui && index)
00895   {
00896     *index = ui->m_i;
00897   }
00898   return (0!=ui);
00899 }
00900 
00901 bool ON_UuidIndexList::FindUuidIndex(ON_UUID uuid, int index) const
00902 {
00903   const ON_UuidIndex* ui = SearchHelper(&uuid);
00904   if (ui && index != ui->m_i)
00905   {
00906     ui = 0;
00907   }
00908   return (0!=ui);
00909 }
00910 
00911 
00912 
00913 
00914 
00915 ON_UuidPairList::ON_UuidPairList() 
00916 : ON_SimpleArray<ON_UuidPair>(32)
00917 , m_sorted_count(0)
00918 , m_removed_count(0)
00919 {
00920 }
00921 
00922 ON_UuidPairList::ON_UuidPairList(int capacity) 
00923 : ON_SimpleArray<ON_UuidPair>(capacity>32?capacity:32)
00924 , m_sorted_count(0)
00925 , m_removed_count(0)
00926 {
00927 }
00928 
00929 ON_UuidPairList::~ON_UuidPairList()
00930 {
00931   m_sorted_count = 0;
00932   m_removed_count = 0;
00933 }
00934 
00935 ON_UuidPairList::ON_UuidPairList(const ON_UuidPairList& src) 
00936 : ON_SimpleArray<ON_UuidPair>(src)
00937 , m_sorted_count(src.m_sorted_count)
00938 , m_removed_count(src.m_removed_count)
00939 {
00940 }
00941 
00942 ON_UuidPairList& ON_UuidPairList::operator=(const ON_UuidPairList& src)
00943 {
00944   if ( this != &src)
00945   {
00946     ON_SimpleArray<ON_UuidPair>::operator=(src);
00947     m_sorted_count = src.m_sorted_count;
00948     m_removed_count = src.m_removed_count;
00949   }
00950   return *this;
00951 }
00952 
00953 bool ON_UuidPairList::AddPair(ON_UUID id1, ON_UUID id2, bool bCheckForDupicates)
00954 {
00955   bool rc = bCheckForDupicates ? !FindId1(id1,0) : true;
00956   if (rc)
00957   {
00958     if ( ON_max_uuid == id1 && ON_max_uuid == id2 )
00959     {
00960       // The value pair (ON_max_uuid,ON_max_uuid) is used
00961       // to mark removed elements.
00962       rc = false;
00963     }
00964     else
00965     {
00966       ON_UuidPair& ui = AppendNew();
00967       ui.m_uuid[0] = id1;
00968       ui.m_uuid[1] = id2;
00969     }
00970   }
00971   return rc;
00972 }
00973 
00974 int ON_UuidPairList::Count() const
00975 {
00976   return m_count - m_removed_count;
00977 }
00978 
00979 void ON_UuidPairList::Empty()
00980 {
00981   m_count = 0;
00982   m_sorted_count = 0;
00983   m_removed_count = 0;
00984 }
00985 
00986 
00987 void ON_UuidPairList::Reserve( int capacity )
00988 {
00989   if( m_capacity < capacity )
00990     SetCapacity( capacity );
00991 }
00992 
00993 bool ON_UuidPairList::RemovePair(ON_UUID id1)
00994 {
00995   ON_UuidPair* p = SearchHelper(&id1);
00996   if ( 0 != p )
00997   {
00998     p->m_uuid[0] = ON_max_uuid;
00999     p->m_uuid[1] = ON_max_uuid;
01000     m_removed_count++;
01001     unsigned int i = (unsigned int)(p - m_a);
01002     if ( i < m_sorted_count )
01003       m_sorted_count = i;
01004   }
01005   return (0!=p);
01006 }
01007 
01008 bool ON_UuidPairList::RemovePair(ON_UUID id1, ON_UUID id2)
01009 {
01010   ON_UuidPair* p = SearchHelper(&id1);
01011   if ( 0 != p && p->m_uuid[1] == id2)
01012   {
01013     p->m_uuid[0] = ON_max_uuid;
01014     p->m_uuid[1] = ON_max_uuid;
01015     m_removed_count++;
01016     unsigned int i = (unsigned int)(p - m_a);
01017     if ( i < m_sorted_count )
01018       m_sorted_count = i;
01019   }
01020   return (0!=p);
01021 }
01022 
01023 static
01024 int compar_uuidpair_id1(const ON_UuidPair* a, const ON_UuidPair* b)
01025 {
01026   return ON_UuidList::CompareUuid(&a->m_uuid[0],&b->m_uuid[0]);
01027 }
01028 
01029 static
01030 int compar_uuidpair_id1id2(const ON_UuidPair* a, const ON_UuidPair* b)
01031 {
01032   int i;
01033   if ( 0 == (i = ON_UuidList::CompareUuid(&a->m_uuid[0],&b->m_uuid[0])) )
01034     i = ON_UuidList::CompareUuid(&a->m_uuid[1],&b->m_uuid[1]);
01035   return i;
01036 }
01037 
01038 bool ON_UuidPairList::FindId1(ON_UUID id1, ON_UUID* id2) const
01039 {
01040   const ON_UuidPair* ui = SearchHelper(&id1);
01041   if (ui && id2)
01042   {
01043     *id2 = ui->m_uuid[1];
01044   }
01045   return (0!=ui);
01046 }
01047 
01048 bool ON_UuidPairList::FindPair(ON_UUID id1, ON_UUID id2) const
01049 {
01050   const ON_UuidPair* ui = SearchHelper(&id1);
01051   if (ui && id2 != ui->m_uuid[1])
01052   {
01053     ui = 0;
01054   }
01055   return (0!=ui);
01056 }
01057 
01058 int ON_UuidPairList::GetId1s(
01059     ON_SimpleArray<ON_UUID>& uuid_list
01060     ) const
01061 {
01062   const int count0 = uuid_list.Count();
01063   int i;
01064   uuid_list.Reserve(uuid_list.Count() + m_count - m_removed_count);
01065   for ( i = 0; i < m_count; i++ )
01066   {
01067     if ( ON_max_uuid == m_a[i].m_uuid[0] && ON_max_uuid == m_a[i].m_uuid[1] )
01068       continue;
01069     uuid_list.Append(m_a[i].m_uuid[0]);
01070   }
01071   return uuid_list.Count() - count0;
01072 }
01073 
01074 void ON_UuidPairList::ImproveSearchSpeed()
01075 {
01076   if ( ((unsigned int)m_count) > m_sorted_count )
01077   {
01078     QuickSort(compar_uuidpair_id1id2);
01079     if ( m_removed_count > 0 )
01080     {
01081       // cull removed items.  These get sorted to the
01082       // end because the removed uuid is the largest
01083       // possible uuid.
01084       ON_UuidPair removed_uuid;
01085       removed_uuid.m_uuid[0] = ON_max_uuid;
01086       removed_uuid.m_uuid[1] = ON_max_uuid;
01087       while ( m_count > 0 && !compar_uuidpair_id1id2(&removed_uuid,m_a+(m_count-1)))
01088       {
01089         m_count--;
01090       }
01091       m_removed_count = 0;
01092     }
01093     m_sorted_count = m_count;
01094   }
01095 }
01096 
01097 ON_UuidPair* ON_UuidPairList::SearchHelper(const ON_UUID* id1) const
01098 {
01099   if ( m_count - m_sorted_count > 8 || m_removed_count > 0 )
01100   {
01101     // time to resort the array so that the speedy
01102     // bsearch() can be used to find uuids
01103     const_cast<ON_UuidPairList*>(this)->ImproveSearchSpeed();
01104   }
01105 
01106   // NOTE: 
01107   //   The pair (ON_max_uuid,ON_max_uuid) never appears in the sorted portion of the array.
01108   ON_UuidPair* p = (m_sorted_count > 0 )
01109                    ? (ON_UuidPair*)bsearch( id1, m_a, m_sorted_count, 
01110                                         sizeof(m_a[0]), 
01111                                         (int(*)(const void*,const void*))compar_uuidpair_id1 ) 
01112                    : 0;
01113 
01114   if (0 == p)
01115   {
01116     // do a slow search on the last m_count-m_sort_count elements
01117     // in the array.
01118     int i;
01119     for ( i = m_sorted_count; i < m_count; i++ )
01120     {
01121       if (    0 == ON_UuidList::CompareUuid(id1,&m_a[i].m_uuid[0]) 
01122            && (ON_max_uuid != m_a[i].m_uuid[0] || ON_max_uuid != m_a[i].m_uuid[1])
01123          )
01124       {
01125         p = m_a+i;
01126         break;
01127       }
01128     }
01129   }
01130 
01131   return p;
01132 }
01133 
01134 void ON_UuidList::RemapUuids( const ON_SimpleArray<ON_UuidPair>& uuid_remap )
01135 {
01136   if( m_count > 0 && uuid_remap.Count() > 0 )
01137   {
01138     bool bRemapped = false;
01139     int i, j;
01140     for ( i = 0; i < m_count; i++ )
01141     {
01142       j = uuid_remap.BinarySearch( (const ON_UuidPair*)&m_a[i], ON_UuidPair::CompareFirstUuid );
01143       if ( j >= 0 )
01144       {
01145         if ( ON_max_uuid == m_a[i] )
01146           continue;
01147         m_sorted_count = 0;
01148         bRemapped = true;
01149         m_a[i] = uuid_remap[j].m_uuid[1];
01150         if ( ON_max_uuid == m_a[i] )
01151           m_removed_count++;
01152       }
01153     }
01154 
01155     if ( bRemapped )
01156     {
01157       m_sorted_count = 0;
01158       SortHelper();
01159       for ( i = m_count-1; i > 0; i-- )
01160       {
01161         if ( m_a[i] == m_a[i-1] )
01162         {
01163           Remove(i);
01164           m_sorted_count--;
01165         }
01166       }
01167     }
01168   }
01169 }
01170 
01171 int ON_UuidList::GetUuids(
01172     ON_SimpleArray<ON_UUID>& uuid_list
01173     ) const
01174 {
01175   const int count0 = uuid_list.Count();
01176   int i;
01177   uuid_list.Reserve(uuid_list.Count() + (m_count-m_removed_count));
01178   for ( i = 0; i < m_count; i++ )
01179   {
01180     if ( ON_max_uuid == m_a[i] )
01181       continue;
01182     uuid_list.Append(m_a[i]);
01183   }
01184   return uuid_list.Count() - count0;
01185 }
01186 
01187 int ON_UuidIndexList::GetUuids(
01188     ON_SimpleArray<ON_UUID>& uuid_list
01189     ) const
01190 {
01191   const int count0 = uuid_list.Count();
01192   int i;
01193   uuid_list.Reserve(uuid_list.Count() + m_count);
01194   for ( i = 0; i < m_count; i++ )
01195   {
01196     if ( ON_max_uuid == m_a[i].m_id )
01197       continue;
01198     uuid_list.Append(m_a[i].m_id);
01199   }
01200   return uuid_list.Count() - count0;
01201 }
01202 
01203 void ON_UuidIndexList::ImproveSearchSpeed()
01204 {
01205   if ( ((unsigned int)m_count) > m_sorted_count )
01206   {
01207     QuickSort(compar_uuidindex_uuid);
01208     if ( m_removed_count > 0 )
01209     {
01210       // cull removed items.  These get sorted to the
01211       // end because the removed uuid is the largest
01212       // possible uuid.
01213       ON_UuidIndex removed_uuid;
01214       removed_uuid.m_id = ON_max_uuid;
01215       removed_uuid.m_i = 0;
01216       while ( m_count > 0 && !compar_uuidindex_uuid(&removed_uuid,m_a+(m_count-1)))
01217       {
01218         m_count--;
01219       }
01220       m_removed_count = 0;
01221     }
01222     m_sorted_count = m_count;
01223   }
01224 }
01225 
01226 ON_UuidIndex* ON_UuidIndexList::SearchHelper(const ON_UUID* uuid) const
01227 {
01228   if ( m_count - m_sorted_count > 8 || m_removed_count > 0 )
01229   {
01230     // time to resort the array so that the speedy
01231     // bsearch() can be used to find uuids
01232     const_cast<ON_UuidIndexList*>(this)->ImproveSearchSpeed();
01233   }
01234 
01235   ON_UuidIndex* p = (m_sorted_count > 0 )
01236                    ? (ON_UuidIndex*)bsearch( uuid, m_a, m_sorted_count, 
01237                                         sizeof(m_a[0]), 
01238                                         (int(*)(const void*,const void*))compar_uuidindex_uuid ) 
01239                    : 0;
01240   if (0 == p)
01241   {
01242     // do a slow search on the last m_count-m_sort_count elements
01243     // in the array.
01244     int i;
01245     for ( i = m_sorted_count; i < m_count; i++ )
01246     {
01247       if ( 0 == ON_UuidList::CompareUuid(uuid,&m_a[i].m_id) )
01248       {
01249         p = m_a+i;
01250         break;
01251       }
01252     }
01253   }
01254 
01255   return p;
01256 }
01257 
01258 ON_2dexMap::ON_2dexMap() : m_bSorted(0)
01259 {}
01260 
01261 ON_2dexMap::ON_2dexMap(int capacity) 
01262             : ON_SimpleArray<ON_2dex>(capacity), 
01263             m_bSorted(0)
01264 {}
01265 
01266 ON_2dexMap::~ON_2dexMap()
01267 {}
01268 
01269 int ON_2dexMap::Count() const
01270 {
01271   return m_count;
01272 }
01273 
01274 const ON_2dex* ON_2dexMap::Array() const
01275 {
01276   return m_a;
01277 }
01278 
01279 void ON_2dexMap::Reserve(int capacity )
01280 {
01281   ON_SimpleArray<ON_2dex>::Reserve(capacity);
01282 }
01283 
01284 ON_2dex ON_2dexMap::operator[](int i) const
01285 {
01286   return m_a[i];
01287 }
01288 
01289 void ON_2dexMap::Create(int count, int i0, int j)
01290 {
01291   if ( count <= 0 )
01292   {
01293     m_count = 0;
01294   }
01295   else
01296   {
01297     ON_SimpleArray<ON_2dex>::Reserve(count);
01298     m_count = count;
01299     ON_2dex* a = m_a;
01300     ON_2dex d;
01301     d.j = j;
01302     count += i0;
01303     for ( d.i = i0; d.i < count; d.i++ )
01304     {
01305       *a++ = d;
01306     }
01307   }
01308   m_bSorted = true;
01309 }
01310 
01311 
01312 const ON_2dex* ON_BinarySearch2dexArray( int key_i, const ON_2dex* base, size_t nel )
01313 {
01314   if (nel > 0 && base )
01315   {
01316     size_t i;
01317     int base_i;
01318 
01319     // The end tests are not necessary, but they
01320     // seem to provide overall speed improvement
01321     // for the types of searches that call this
01322     // function.
01323 
01324     // 26 January 2012 Dale Lear
01325     //   Part of the fix for http://dev.mcneel.com/bugtrack/?q=97693
01326     //   When the values of key_i and base[].i are large,
01327     //   key_i - base[].i suffers from integer overflow
01328     //   and the difference can not be use to compare
01329     //   magnitudes.
01330 
01331     base_i = base[0].i;
01332     if ( key_i < base_i )
01333       return 0;
01334     if ( key_i == base_i )
01335       return base;
01336 
01337     base_i = base[nel-1].i;
01338     if ( key_i > base_i )
01339       return 0;
01340     if ( key_i == base_i )
01341       return (base + (nel-1));
01342 
01343     while ( nel > 0 )
01344     {
01345       i = nel/2;
01346       base_i = base[i].i;
01347       if ( key_i < base_i )
01348       {
01349         nel = i;
01350       }
01351       else if ( key_i > base_i )
01352       {
01353         i++;
01354         base += i;
01355         nel -= i;
01356       }
01357       else
01358       {
01359         return base+i;
01360       }
01361     }
01362   }
01363   return 0;
01364 }
01365 
01366 static
01367 int compare_2dex_i(const void* a, const void* b)
01368 {
01369   const int ai = *((const int*)a);
01370   const int bi = *((const int*)b);
01371   if ( ai < bi )
01372     return -1;
01373   if ( ai > bi )
01374     return 1;
01375   return 0;
01376 }
01377 
01378 const ON_2dex* ON_2dexMap::Find2dex(int i) const
01379 {
01380   const ON_2dex* e = 0;
01381   if ( m_count > 0 )
01382   {
01383     if ( !m_bSorted )
01384     {
01385       ON_qsort(m_a,m_count,sizeof(m_a[0]),compare_2dex_i);
01386       const_cast<ON_2dexMap*>(this)->m_bSorted = true;
01387     }
01388     e = ON_BinarySearch2dexArray(i,m_a,m_count);
01389   }
01390   return e;
01391 }
01392 
01393 int ON_2dexMap::FindIndex( int i, int not_found_rc) const
01394 {
01395   const ON_2dex* e = Find2dex(i);
01396   return e ? e->j : not_found_rc;
01397 }
01398 
01399 bool ON_2dexMap::AddIndex(  int i, int j )
01400 {
01401   bool rc = (0 == Find2dex(i));
01402   if ( rc )
01403   {
01404     ON_2dex& d = AppendNew();
01405     d.i = i;
01406     d.j = j;
01407     m_bSorted = ( m_count < 2 || (m_bSorted && m_a[m_count-2].i < i) );
01408   }
01409   return rc;
01410 }
01411 
01412 bool ON_2dexMap::SetIndex( int i, int j )
01413 {
01414   ON_2dex* e = const_cast<ON_2dex*>(Find2dex(i));
01415   if ( e )
01416   {
01417     e->j = j;
01418   }
01419   return (0!=e);
01420 }
01421 
01422 void ON_2dexMap::SetOrAddIndex( int i, int j )
01423 {
01424   ON_2dex* e = const_cast<ON_2dex*>(Find2dex(i));
01425   if ( e )
01426   {
01427     e->j = j;
01428   }
01429   else
01430   {
01431     ON_2dex& d = AppendNew();
01432     d.i = i;
01433     d.j = j;
01434     m_bSorted = ( m_count < 2 || (m_bSorted && m_a[m_count-2].i < i) );
01435   }
01436 }
01437 
01438 bool ON_2dexMap::RemoveIndex( int i )
01439 {
01440   const ON_2dex* e = Find2dex(i);
01441   if (e)
01442   {
01443     int n = (int)(m_a-e);
01444     for( m_count--; n < m_count; n++ )
01445       m_a[n] = m_a[n+1];
01446   }
01447   return (0 != e);
01448 }
01449 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:59