QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_array.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_ARRAY_INC_)
17#define ON_ARRAY_INC_
18
19class ON_2dPointArray;
20class ON_3dPointArray;
21class ON_4dPointArray;
22
25
26class ON_2fPointArray;
27class ON_3fPointArray;
28class ON_4fPointArray;
29
32
34//
35// The ON_SimpleArray<> template is more efficient than the
36// ON_ClassArray<> template, but ON_SimpleArray<> should not
37// be used for arrays of classes that require explicit
38// construction, destruction, or copy operators.
39//
40// By default, ON_SimpleArray<> uses onrealloc() to manage
41// the dynamic array memory. If you want to use something
42// besides onrealloc() to manage the array memory, then override
43// ON_SimpleArray::Realloc().
44
45template <class T> class ON_SimpleArray
46{
47public:
48 // construction ////////////////////////////////////////////////////////
49
50 // These constructors create an array that uses onrealloc() to manage
51 // the array memory.
53 ON_SimpleArray( int ); // int = initial capacity
54
55 // Copy constructor
57
58 virtual
60
61 // Assignment operator
62 virtual
64
65 // emergency bailout ///////////////////////////////////////////////////
66 void EmergencyDestroy(void); // call only when memory used by this array
67 // may have become invalid for reasons beyond
68 // your control. EmergencyDestroy() zeros
69 // anything that could possibly cause
70 // ~ON_SimpleArray() to crash.
71
72 // query ///////////////////////////////////////////////////////////////
73
74 int Count() const; // number of elements in array
75
76 int Capacity() const; // capacity of array
77
78 unsigned int SizeOfArray() const; // amount of memory in the m_a[] array
79
80 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
81
82 T& operator[]( int ); // grows array if index >= Capacity()
83
84 const T& operator[]( int ) const; // The const operator[] does not
85 // check for a valid index. Caller
86 // is responsible for making sure
87 // that the index is > 0 and < Capacity().
88
89 operator T*(); // The cast operators return a pointer
90 operator const T*() const; // to the array. If Count() is zero,
91 // this pointer is NULL.
92
93 T* First();
94 const T* First() const; // returns NULL if count = 0
95
96 T* At( int );
97 const T* At( int ) const; // returns NULL if index < 0 or index >= count
98
99 T* Last();
100 const T* Last() const; // returns NULL if count = 0
101
102
103 // array operations ////////////////////////////////////////////////////
104
105 T& AppendNew(); // Most efficient way to add a new element
106 // to the array. Increases count by 1.
107
108 void Append( const T& ); // Append copy of element.
109 // Increments count by 1.
110
111 void Append( int, const T* ); // Append copy of an array T[count]
112
113
114 void Insert( int, const T& ); // Insert copy of element. Uses
115 // memmove() to perform any
116 // necessary moving.
117 // Increases count by 1.
118
119 void Remove(); // Removes last element. Decrements
120 // count by 1. Does not change capacity.
121
122 virtual
123 void Remove( int ); // Removes element. Uses memmove() to
124 // perform any necessary shifting.
125 // Decrements count by 1. Does not change
126 // capacity
127
128 void Empty(); // Sets count to 0, leaves capacity untouched.
129
130 void Reverse(); // reverse order
131
132 void Swap(int,int); // swap elements i and j
133
135 // Search( e ) does a SLOW search of the array starting at array[0]
136 // and returns the index "i" of the first element that satisfies
137 // e == array[i]. (== is really memcmp()). If the search is not
138 // successful, then Search() returns -1. For Search(T) to work
139 // correctly, T must be a simple type. Use Search(p,compare())
140 // for Ts that are structs/classes that contain pointers. Search()
141 // is only suitable for performing infrequent searchs of small
142 // arrays. Sort the array and use BinarySearch() for performing
143 // efficient searches.
144 int Search( const T& ) const;
145
147 // Search( p, compare ) does a SLOW search of the array starting
148 // at array[0] and returns the index "i" of the first element
149 // that satisfies compare(p,&array[i])==0. If the search is not
150 // successful, then Search() returns -1. Search() is only suitable
151 // for performing infrequent searches of small arrays. Sort the
152 // array and use BinarySearch() for performing efficient searches.
153 // See Also: ON_CompareIncreasing<T> and ON_CompareDeccreasing<T>
154 int Search( const T*, int (*)(const T*,const T*) ) const;
155
157 // BinarySearch( p, compare ) does a fast search of a sorted array
158 // and returns the smallest index "i" of the element that satisifies
159 // 0==compare(p,&array[i]). If the search is successful,
160 // BinarySearch() returns the index of the element (>=0).
161 // If the search is not successful, BinarySearch() returns -1. Use
162 // HeapSort( compare ) or QuickSort( compare ) to sort the array.
163 // See Also: ON_CompareIncreasing<T> and ON_CompareDeccreasing<T>
164 int BinarySearch( const T*, int (*)(const T*,const T*) ) const;
165
167 // Sorts the array using the heap sort algorithm.
168 bool HeapSort( int (*)(const T*,const T*) );
169
171 // Sorts the array using the quick sort algorithm.
172 // See Also: ON_CompareIncreasing<T> and ON_CompareDeccreasing<T>
173 bool QuickSort( int (*)(const T*,const T*) );
174
176 // Sort() computes fills in the index[] array so that
177 // array[index[i]] <= array[index[i+1]]. The array is not
178 // modified
179 bool Sort( ON::sort_algorithm, int* /* index[] */ , int (*)(const T*,const T*) ) const;
180
181 /*
182 Description:
183 Sort() fills in the index[] array so that
184 array[index[i]] <= array[index[i+1]].
185 The array is not modified.
186
187 Parameters:
188 sa - [in] ON::heap_sort or ON::quick_sort
189 index - [out] an array of length Count() that is returned with
190 some permutation of (0,1,...,Count()-1).
191 compare - [in] compare function compare(a,b,p) should return
192 <0 if a<b, 0, if a==b, and >0 if a>b.
193 p - [in] pointer passed as third argument to compare.
194
195 Returns:
196 true if successful
197 */
198 bool Sort(
199 ON::sort_algorithm, // sa
200 int*, // index[]
201 int (*)(const T*,const T*,void*), // int compare(const T*,const T*,void* p)
202 void* // p
203 ) const;
204
206 // Permutes the array so that output[i] = input[index[i]].
207 // The index[] array should be a permutation of (0,...,Count()-1).
208 bool Permute( const int* /*index[]*/ );
209
211 // Zeros all array memory.
212 // Count and capacity are not changed.
213 void Zero();
214
216 // Sets all bytes in array memory to value.
217 // Count and capacity are not changed.
218 void MemSet(unsigned char);
219
220 // memory managment ////////////////////////////////////////////////////
221
222 void Reserve( int ); // increase capacity to at least the requested value
223
224 void Shrink(); // remove unused capacity
225
226 void Destroy(); // onfree any memory and set count and capacity to zero
227
228 // low level memory managment //////////////////////////////////////////
229
230 // By default, ON_SimpleArray<> uses onrealloc() to manage
231 // the dynamic array memory. If you want to use something
232 // besides onrealloc() to manage the array memory, then override
233 // Realloc(). The T* Realloc(ptr, capacity) should do the following:
234 //
235 // 1) If ptr and capacity are zero, return NULL.
236 // 2) If ptr is NULL, an capacity > 0, allocate a memory block of
237 // capacity*sizeof(T) bytes and return a pointer to this block.
238 // If the allocation request fails, return NULL.
239 // 3) If ptr is not NULL and capacity is 0, free the memory block
240 // pointed to by ptr and return NULL.
241 // 4) If ptr is not NULL and capacity > 0, then reallocate the memory
242 // block and return a pointer to the reallocated block. If the
243 // reallocation request fails, return NULL.
244 //
245 // NOTE WELL:
246 // Microsoft's VC 6.0 realloc() contains a bug that can cause
247 // crashes and should be avoided. See MSDN Knowledge Base article
248 // ID Q225099 for more information.
249 virtual
250 T* Realloc(T*,int); // (re)allocated capacity*sizeof(T) bytes
251
252 T* Array(); // The Array() function return the
253
254 const T* Array() const; // m_a pointer value.
255
256 void SetCount( int ); // If value is <= Capacity(), then
257 // sets count to specified value.
258
259 void SetCapacity( int ); // Shrink/grows capacity. If value
260 // is < current Count(), then count
261 // is reduced to value.
262 //
263
264 int NewCapacity() const; // When the dynamic array needs to grow,
265 // this calculates the new value for m_capacity.
266
267 /*
268 Returns:
269 A pointer to the array and zeros out this class.
270 The returned pointer is on the heap and must be
271 deallocated by calling onfree().
272 */
273 T* KeepArray();
274
275 /*
276 Description:
277 Expert user tool to set m_a = T.
278 Parameters:
279 T* pointer - [in]
280 m_a is set to T*. It is critical that the pointer
281 be one returned by onmalloc(sz), where
282 sz >= Capacity()*sizeof(T[0]);
283 */
284 void SetArray(T*);
285
286protected:
287 // implimentation //////////////////////////////////////////////////////
288 void Move( int /* dest index*/, int /* src index */, int /* element count*/ );
289 T* m_a; // pointer to array memory
290 int m_count; // 0 <= m_count <= m_capacity
291 int m_capacity; // actual length of m_a[]
292};
293
294
296//
297
298#if defined(ON_DLL_TEMPLATE)
299// This stuff is here because of a limitation in the way Microsoft
300// handles templates and DLLs. See Microsoft's knowledge base
301// article ID Q168958 for details.
302#pragma warning( push )
303#pragma warning( disable : 4231 )
304
305ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<bool>;
306ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<char>;
307ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned char>;
308ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<short>;
309ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned short>;
310ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<int>;
311ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned int>;
312ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<float>;
313ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<double>;
314
315ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<bool*>;
316ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<char*>;
317ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned char*>;
318ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<short*>;
319ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned short*>;
320ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<int*>;
321ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<unsigned int*>;
322ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<float*>;
323ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<double*>;
324
325ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_2dPoint>;
326ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3dPoint>;
327ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_4dPoint>;
328ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_2dVector>;
329ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3dVector>;
330
331ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_2fPoint>;
332ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3fPoint>;
333ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_4fPoint>;
334ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_2fVector>;
335ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3fVector>;
336
337ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Color>;
338ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_SurfaceCurvature>;
339ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Interval>;
340
341ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_2dex>;
342ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3dex>;
343
344ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_COMPONENT_INDEX>;
345#pragma warning( pop )
346#endif
347
348
350//
351
353{
354public:
355 // see ON_SimpleArray class definition comments for constructor documentation
357 ON_2dPointArray(int);
359 ON_2dPointArray& operator=( const ON_2dPointArray& );
360
361 bool GetBBox( // returns true if successful
362 double boxmin[2],
363 double boxmax[2],
364 int bGrowBox = false // true means grow box
365 ) const;
366
367 bool Transform( const ON_Xform& );
368 bool SwapCoordinates(int,int);
369};
370
371
373//
374
376{
377public:
378 // see ON_SimpleArray class definition comments for constructor documentation
380 ON_2fPointArray(int);
382 ON_2fPointArray& operator=( const ON_2fPointArray& );
383
384 bool GetBBox( // returns true if successful
385 float boxmin[2],
386 float boxmax[2],
387 int bGrowBox = false // true means grow box
388 ) const;
389 bool Transform( const ON_Xform& );
390 bool SwapCoordinates(int,int);
391};
392
393
395//
396
398{
399public:
400 // see ON_SimpleArray class definition comments for constructor documentation
402 ON_3dPointArray(int);
404 ON_3dPointArray& operator=( const ON_3dPointArray& );
406 ON_3dPointArray& operator=( const ON_SimpleArray<ON_3fPoint>& );
407
408 // Description:
409 // Create 3d point list
410 // Parameters:
411 // point_dimension - [in] dimension of input points (2 or 3)
412 // bRational - [in] true if points are in homogenous rational form
413 // point_count - [in] number of points
414 // point_stride - [in] number of doubles to skip between points
415 // points - [in] array of point coordinates
416 bool Create(
417 int point_dimension,
418 int bRational,
419 int point_count,
420 int point_stride,
421 const double* points
422 );
423
424 // Description:
425 // Create 3d point list
426 // Parameters:
427 // point_dimension - [in] dimension of input points (2 or 3)
428 // bRational - [in] true if points are in homogenous rational form
429 // point_count - [in] number of points
430 // point_stride - [in] number of doubles to skip between points
431 // points - [in] array of point coordinates
432 bool Create(
433 int point_dimension,
434 int bRational,
435 int point_count,
436 int point_stride,
437 const float* points
438 );
439
440 // Description:
441 // Get 3d axis aligned bounding box.
442 // Returns:
443 // 3d bounding box of point list.
444 ON_BoundingBox BoundingBox() const;
445
446 // Description:
447 // Get 3d axis aligned bounding box or the union
448 // of the input box with the point list's bounding box.
449 // Parameters:
450 // bbox - [in/out] 3d axis aligned bounding box
451 // bGrowBox - [in] (default=false)
452 // If true, then the union of the input bbox and the
453 // point list's bounding box is returned in bbox.
454 // If false, the point list's bounding box is returned in bbox.
455 // Returns:
456 // true if successful.
457 bool GetBoundingBox(
458 ON_BoundingBox& bbox,
459 int bGrowBox = false
460 ) const;
461
462 // Description:
463 // Get axis aligned bounding box.
464 // Parameters:
465 // boxmin - [in/out] array of 3 doubles
466 // boxmax - [in/out] array of 3 doubles
467 // bGrowBox - [in] (default=false)
468 // If true, then the union of the input bounding box and the
469 // object's bounding box is returned.
470 // If false, the object's bounding box is returned.
471 // Returns:
472 // true if object has bounding box and calculation was successful
473 bool GetBBox(
474 double boxmin[3],
475 double boxmax[3],
476 int bGrowBox = false
477 ) const;
478
479 /*
480 Description:
481 Get tight bounding box of the point list.
482 Parameters:
483 tight_bbox - [in/out] tight bounding box
484 bGrowBox -[in] (default=false)
485 If true and the input tight_bbox is valid, then returned
486 tight_bbox is the union of the input tight_bbox and the
487 tight bounding box of the point list.
488 xform -[in] (default=NULL)
489 If not NULL, the tight bounding box of the transformed
490 point list is calculated. The point list is not modified.
491 Returns:
492 True if the returned tight_bbox is set to a valid
493 bounding box.
494 */
495 bool GetTightBoundingBox(
496 ON_BoundingBox& tight_bbox,
497 int bGrowBox = false,
498 const ON_Xform* xform = 0
499 ) const;
500
501 // Description:
502 // Transform points by applying xform to each point.
503 // Parameters:
504 // xform - [in] transformation matrix
505 // Returns:
506 // true if successful.
507 bool Transform(
508 const ON_Xform& xform
509 );
510
511 // Description:
512 // Swaps point coordinate values with indices i and j.
513 // Parameters:
514 // i - [in] coordinate index
515 // j - [in] coordinate index
516 // Returns:
517 // true if successful.
518 // Example:
519 // The call SwapCoordinates(0,2) would swap the x and z
520 // coordinates of each point in the array.
521 bool SwapCoordinates(
522 int i,
523 int j
524 );
525
526 // Description:
527 // Rotate points about a center and axis. A positive angle
528 // results in a counter-clockwise rotation about the axis
529 // of rotation.
530 // Parameters:
531 // sin_angle - [in] sine of rotation angle
532 // cos_angle - [in] cosine of rotation angle
533 // axis_of_rotation - [in] axis of rotation
534 // center_of_rotation - [in] center (fixed point) of rotation
535 // Returns:
536 // true if successful.
537 bool Rotate(
538 double sin_angle,
539 double cos_angle,
540 const ON_3dVector& axis_of_rotation,
541 const ON_3dPoint& center_of_rotation
542 );
543
544 // Description:
545 // Rotate points about a center and axis. A positive angle
546 // results in a counter-clockwise rotation about the axis
547 // of rotation.
548 // Parameters:
549 // angle - [in] angle in radians. Polsine of rotation angle
550 // cos_angle - [in] cosine of rotation angle
551 // axis_of_rotation - [in] axis of rotation
552 // center_of_rotation - [in] center (fixed point) of rotation
553 // Returns:
554 // true if successful.
555 bool Rotate(
556 double angle_in_radians,
557 const ON_3dVector& axis_of_rotation,
558 const ON_3dPoint& center_of_rotation
559 );
560
561 // Description:
562 // Translate a polyline
563 // Parameters:
564 // delta - [in] translation vectorsine of rotation angle
565 // Returns:
566 // true if successful.
567 bool Translate(
568 const ON_3dVector& delta
569 );
570
571 /*
572 Description:
573 Get the index of the point in the array that is closest
574 to P.
575 Parameters:
576 P - [in]
577 closest_point_index - [out]
578 maximum_distance - [in] optional distance constraint.
579 If maximum_distance > 0, then only points Q with
580 |P-Q| <= maximum_distance are returned.
581 Returns:
582 True if a point is found; in which case *closest_point_index
583 is the index of the point. False if no point is found
584 or the input is not valid.
585 See Also:
586 ON_GetClosestPointInPointList
587 ON_PointCloud::GetClosestPoint
588 */
589 bool GetClosestPoint(
590 ON_3dPoint P,
591 int* closest_point_index,
592 double maximum_distance = 0.0
593 ) const;
594
595};
596
597
599//
600
602{
603public:
604 // see ON_SimpleArray class definition comments for constructor documentation
606 ON_3fPointArray(int);
608 ON_3fPointArray& operator=( const ON_3fPointArray& );
609
610 bool GetBBox(
611 float boxmin[3],
612 float boxmax[3],
613 int bGrowBox = false
614 ) const;
615
616 bool Transform( const ON_Xform& );
617
618 bool SwapCoordinates(int,int);
619};
620
621
623//
624
626{
627public:
628 // see ON_SimpleArray class definition comments for constructor documentation
630 ON_4dPointArray(int);
632 ON_4dPointArray& operator=( const ON_4dPointArray& );
633
634 bool Transform( const ON_Xform& );
635 bool SwapCoordinates(int,int);
636};
637
638
640//
641
643{
644public:
645 // see ON_SimpleArray class definition comments for constructor documentation
647 ON_4fPointArray(int);
649 ON_4fPointArray& operator=( const ON_4fPointArray& );
650
651 bool Transform( const ON_Xform& );
652 bool SwapCoordinates(int,int);
653};
654
655
657//
658
660{
661public:
662 // see ON_SimpleArray class definition comments for constructor documentation
664 ON_2dVectorArray(int);
666 ON_2dVectorArray& operator=( const ON_2dVectorArray& );
667
668 bool GetBBox(
669 double boxmin[2],
670 double boxmax[2],
671 int bGrowBox = false
672 ) const;
673
674 bool Transform( const ON_Xform& );
675 bool SwapCoordinates(int,int);
676};
677
678
680//
681
683{
684public:
685 // see ON_SimpleArray class definition comments for constructor documentation
687 ON_2fVectorArray(int);
689 ON_2fVectorArray& operator=( const ON_2fVectorArray& );
690
691 bool GetBBox(
692 float boxmin[2],
693 float boxmax[2],
694 bool = false
695 ) const;
696
697 bool Transform( const ON_Xform& );
698 bool SwapCoordinates(int,int);
699};
700
701
703//
704
706{
707public:
709 ON_3dVectorArray(int);
711 ON_3dVectorArray& operator=( const ON_3dVectorArray& );
712
713 bool GetBBox(
714 double boxmin[3],
715 double boxmax[3],
716 bool bGrowBow = false
717 ) const;
718
719 bool Transform( const ON_Xform& );
720 bool SwapCoordinates(int,int);
721};
722
724//
725
727{
728public:
730 ON_3fVectorArray(int);
732 ON_3fVectorArray& operator=( const ON_3fVectorArray& );
733
734 bool GetBBox(
735 float boxmin[3],
736 float boxmax[3],
737 int bGrowBox = false
738 ) const;
739
740 bool Transform( const ON_Xform& );
741 bool SwapCoordinates(int,int);
742};
743
745//
746// The ON_ClassArray<> template is designed to be used with
747// classes that require non-trivial construction or destruction.
748// Any class used with the ON_ClassArray<> template must have a
749// robust operator=().
750//
751// By default, ON_ClassArray<> uses onrealloc() to manage
752// the dynamic array memory. If you want to use something
753// besides onrealloc() to manage the array memory, then override
754// ON_ClassArray::Realloc(). In practice this means that if your
755// class has members with back-pointers, then you cannot use
756// it in the defaule ON_ClassArray. See ON_ObjectArray
757// for an example.
758//
759template <class T> class ON_ClassArray
760{
761public:
762 // construction ////////////////////////////////////////////////////////
763 ON_ClassArray();
764 ON_ClassArray( int ); // int = initial capacity
765
766 // Copy constructor
768
769 virtual
770 ~ON_ClassArray(); // override for struct member deallocation, etc.
771
772 // Assignment operator
773 ON_ClassArray<T>& operator=( const ON_ClassArray<T>& );
774
775 // emergency bailout ///////////////////////////////////////////////////
776 void EmergencyDestroy(void); // call only when memory used by this array
777 // may have become invalid for reasons beyond
778 // your control. EmergencyDestroy() zeros
779 // anything that could possibly cause
780 // ~ON_ClassArray() to crash.
781
782 // query ///////////////////////////////////////////////////////////////
783
784 int Count() const; // number of elements in array
785
786 int Capacity() const; // capacity of array
787
788 unsigned int SizeOfArray() const; // amount of memory in the m_a[] array
789
790 T& operator[]( int ); // grows array if index >= Capacity()
791
792 const T& operator[]( int ) const; // The const operator[] does not
793 // check for a valid index. Caller
794 // is responsible for making sure
795 // that the index is > 0 and < Capacity().
796
797 operator T*(); // The cast operators return a pointer
798 operator const T*() const; // to the array. If Count() is zero,
799 // this pointer is NULL.
800 T* First();
801 const T* First() const; // returns NULL if count = 0
802
803 T* At( int );
804 const T* At( int ) const; // returns NULL if index < 0 or index >= count
805
806 T* Last();
807 const T* Last() const; // returns NULL if count = 0
808
809
810 // array operations ////////////////////////////////////////////////////
811
812 T& AppendNew(); // Most efficient way to add a new class
813 // to the array. Increases count by 1.
814
815 void Append( const T& ); // Append copy of element.
816 // Increments count by 1.
817
818 void Append( int, const T*); // Append copy of an array T[count]
819
820 void Insert( int, const T& ); // Insert copy of element. Uses
821 // memmove() to perform any
822 // necessary moving.
823 // Increases count by 1.
824
825 void Remove(); // Removes last element. Decrements
826 // count by 1. Does not change capacity.
827
828 void Remove( int ); // Removes element. Uses memmove() to
829 // perform any necessary shifting.
830 // Decrements count by 1. Does not change
831 // capacity
832
833 void Empty(); // Sets count to 0, leaves capacity untouched.
834
835 void Reverse(); // reverse order
836
837 void Swap(int,int); // swap elements i and j
838
840 // Search( p, compare ) does a SLOW search of the array starting
841 // at array[0] and returns the index "i" of the first element
842 // that satisfies compare(p,&array[i])==0. If the search is not
843 // successful, then Search() returns -1. Search() is only suitable
844 // for performing infrequent searches of small arrays. Sort the
845 // array and use BinarySearch() for performing efficient searches.
846 int Search( const T*, int (*)(const T*,const T*) ) const;
847
849 // BinarySearch( p, compare ) does a fast search of a sorted array
850 // and returns the smallest index "i" of the element that satisifies
851 // 0==compare(p,&array[i]). If the search is successful,
852 // BinarySearch() returns the index of the element (>=0).
853 // If the search is not successful, BinarySearch() returns -1. Use
854 // HeapSort( compare ) or QuickSort( compare ) to sort the array.
855 // See Also: ON_CompareIncreasing<T> and ON_CompareDeccreasing<T>
856 int BinarySearch( const T*, int (*)(const T*,const T*) ) const;
857
859 // Sorts the array using the heap sort algorithm.
860 // See Also: ON_CompareIncreasing<T> and ON_CompareDeccreasing<T>
861 virtual
862 bool HeapSort( int (*)(const T*,const T*) );
863
865 // Sorts the array using the heap sort algorithm.
866 virtual
867 bool QuickSort( int (*)(const T*,const T*) );
868
870 // Sort() computes fills in the index[] array so that
871 // array[index[i]] <= array[index[i+1]]. The array is not
872 // modified
873 bool Sort( ON::sort_algorithm, int* /* index[] */ , int (*)(const T*,const T*) ) const;
874
875 /*
876 Description:
877 Sort() fills in the index[] array so that
878 array[index[i]] <= array[index[i+1]].
879 The array is not modified.
880
881 Parameters:
882 sa - [in] ON::heap_sort or ON::quick_sort
883 index - [out] an array of length Count() that is returned with
884 some permutation of (0,1,...,Count()-1).
885 compare - [in] compare function compare(a,b,p) should return
886 <0 if a<b, 0, if a==b, and >0 if a>b.
887 p - [in] pointer passed as third argument to compare.
888
889 Returns:
890 true if successful
891 */
892 bool Sort(
893 ON::sort_algorithm, // sa
894 int*, // index[]
895 int (*)(const T*,const T*,void*), // int compare(const T*,const T*,void* p)
896 void* // p
897 ) const;
898
900 // Permutes the array so that output[i] = input[index[i]].
901 // The index[] array should be a permutation of (0,...,Count()-1).
902 bool Permute( const int* /*index[]*/ );
903
905 // Destroys all elements and fills them with values
906 // set by the defualt constructor.
907 // Count and capacity are not changed.
908 void Zero();
909
910 // memory managment /////////////////////////////////////////////////
911
912 void Reserve( int ); // increase capacity to at least the requested value
913
914 void Shrink(); // remove unused capacity
915
916 void Destroy(); // onfree any memory and set count and capacity to zero
917
918 // low level memory managment ///////////////////////////////////////
919
920 // By default, ON_ClassArray<> uses onrealloc() to manage
921 // the dynamic array memory. If you want to use something
922 // besides onrealloc() to manage the array memory, then override
923 // Realloc(). The T* Realloc(ptr, capacity) should do the following:
924 //
925 // 1) If ptr and capacity are zero, return NULL.
926 // 2) If ptr is NULL, an capacity > 0, allocate a memory block of
927 // capacity*sizeof(T) bytes and return a pointer to this block.
928 // If the allocation request fails, return NULL.
929 // 3) If ptr is not NULL and capacity is 0, free the memory block
930 // pointed to by ptr and return NULL.
931 // 4) If ptr is not NULL and capacity > 0, then reallocate the memory
932 // block and return a pointer to the reallocated block. If the
933 // reallocation request fails, return NULL.
934 //
935 // NOTE WELL:
936 // Microsoft's VC 6.0 realloc() contains a bug that can cause
937 // crashes and should be avoided. See MSDN Knowledge Base article
938 // ID Q225099 for more information.
939 virtual
940 T* Realloc(T*,int); // (re)allocated capacity*sizeof(T) bytes
941
942 T* Array(); // The Array() function return the
943
944 const T* Array() const; // m_a pointer value.
945
946 void SetCount( int ); // If value is <= Capacity(), then
947 // sets count to specified value.
948
949 void SetCapacity( int ); // Shrink/grows capacity. If value
950 // is < current Count(), then count
951 // is reduced to value.
952
953 int NewCapacity() const; // When the dynamic array needs to grow,
954 // this calculates the new value for m_capacity.
955
956 T* KeepArray(); // returns pointer to array and zeros
957 // out this class. Caller is responsible
958 // for calling destructor on each element
959 // and then using onfree() to release array
960 // memory. E.g.,
961 //
962 // for (int i=capacity;i>=0;i--) {
963 // array[i].~T();
964 // }
965 // onfree(array);
966
967 /*
968 Description:
969 Expert user tool to set m_a = T.
970 Parameters:
971 T* pointer - [in]
972 m_a is set to T*. It is critical that the pointer
973 be one returned by onmalloc(sz), where
974 sz >= Capacity()*sizeof(T[0]);
975 */
976 void SetArray(T*);
977
978protected:
979 // implimentation //////////////////////////////////////////////////////
980 void Move( int /* dest index*/, int /* src index */, int /* element count*/ );
981 void ConstructDefaultElement(T*);
982 void DestroyElement(T&);
983 T* m_a; // pointer to array memory
984 int m_count; // 0 <= m_count <= m_capacity
985 int m_capacity; // actual length of m_a[]
986};
987
988
989/*
990Description:
991 ON_Object array is used to store lists of classes that are
992 derived from ON_Object. It differs from ON_ClassArray in
993 that the virtual ON_Object::MemoryRelocate function is called
994 when growing the dynamic array requires changing the location
995 of the memory buffer used to store the elements in the array.
996*/
997template <class T> class ON_ObjectArray : public ON_ClassArray<T>
998{
999public:
1000 ON_ObjectArray();
1001 ~ON_ObjectArray(); // override for struct member deallocation, etc.
1002 ON_ObjectArray( int ); // int = initial capacity
1004 ON_ObjectArray<T>& operator=( const ON_ObjectArray<T>& );
1005
1006 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
1007
1008 // virtual ON_ClassArray<T> override that
1009 // calls MemoryRelocate on each element after
1010 // the reallocation.
1011 T* Realloc(T*,int);
1012
1013 // virtual ON_ClassArray<T> override that
1014 // calls MemoryRelocate on each element after
1015 // the heap sort.
1016 bool HeapSort( int (*)(const T*,const T*) );
1017
1018 // virtual ON_ClassArray<T> override that
1019 // calls MemoryRelocate on each element after
1020 // the quick sort.
1021 bool QuickSort( int (*)(const T*,const T*) );
1022};
1023
1025{
1026public:
1027 /*
1028 Description:
1029 Compares m_uuid[0] and ignores m_uuid[1]
1030 */
1031 static
1032 int CompareFirstUuid(const class ON_UuidPair*,const class ON_UuidPair*);
1033
1034 /*
1035 Description:
1036 Compares m_uuid[1] and ignores m_uuid[0]
1037 */
1038 static
1039 int CompareSecondUuid(const class ON_UuidPair*,const class ON_UuidPair*);
1040
1041 /*
1042 Description:
1043 Compares m_uuid[0] first and then m_uuid[1].
1044 */
1045 static
1046 int Compare(const class ON_UuidPair*,const class ON_UuidPair*);
1047
1048 ON_UuidPair();
1049 ON_UUID m_uuid[2];
1050};
1051
1052#if defined(ON_DLL_TEMPLATE)
1053
1054// This stuff is here because of a limitation in the way Microsoft
1055// handles templates and DLLs. See Microsoft's knowledge base
1056// article ID Q168958 for details.
1057#pragma warning( push )
1058#pragma warning( disable : 4231 )
1059ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_UUID>;
1060ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_UuidIndex>;
1061ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_DisplayMaterialRef>;
1062ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_LinetypeSegment>;
1063ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_UuidPair>;
1064ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_PlaneEquation>;
1065ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_SimpleArray<int> >;
1066#pragma warning( pop )
1067
1068#endif
1069
1070
1071/*
1072Description:
1073 The ON_UuidList class provides a tool to efficiently
1074 maintain a list of uuids and determine if a uuid is
1075 in the list. This class is based on the premise that
1076 there are no duplicate uuids in the list.
1077*/
1078class ON_CLASS ON_UuidList : private ON_SimpleArray<ON_UUID>
1079{
1080public:
1081 ON_UuidList();
1082 ON_UuidList(int capacity);
1083 ~ON_UuidList();
1084 ON_UuidList(const ON_UuidList& src);
1085 ON_UuidList& operator=(const ON_UuidList& src);
1086
1087 /*
1088 Description:
1089 Fast uuid compare. Not necessarily the same
1090 as ON_UuidCompare().
1091 */
1092 static
1093 int CompareUuid( const ON_UUID* a, const ON_UUID* b );
1094
1095 /*
1096 Returns:
1097 Number of active uuids in the list.
1098 */
1099 int Count() const;
1100
1101 /*
1102 Returns:
1103 Array of uuids in the list. Sorted with
1104 respect to ON_UuidList::CompareUuid().
1105 Remarks:
1106 Calling AddUuid() may grow the dynamic array
1107 and make the pointer invalid.
1108 */
1109 const ON_UUID* Array() const;
1110
1111 /*
1112 Description:
1113 Provides an efficient way to empty a list so that it
1114 can be used again.
1115 */
1116 void Empty();
1117
1118 /*
1119 Description:
1120 Destroy list. If list will be reused, Empty() is more
1121 efficient.
1122 */
1123 void Destroy();
1124
1125 void Reserve(int capacity);
1126
1127 /*
1128 Description:
1129 Makes the uuid list as efficent as possible in both search
1130 speed and memory usage. Use Compact() when a uuid list
1131 will be in use but is not likely to be modifed. A list
1132 that has been compacted can still be modified.
1133 */
1134 void Compact();
1135
1136 /*
1137 Description:
1138 Adds a uuid to the list.
1139 Parameters:
1140 uuid - [in] id to add.
1141 bCheckForDupicates - [in] if true, then the uuid
1142 is not added if it is already in the list.
1143 If you are certain that the uuid is not in the
1144 list and you are going to have a large list of uuids,
1145 then setting bCheckForDupicates=false will
1146 speed up the addition of uuids.
1147 Returns:
1148 True if uuid was added. False if uuid was not added
1149 because it is already in the collection.
1150 */
1151 bool AddUuid(ON_UUID uuid, bool bCheckForDupicates=true);
1152
1153 /*
1154 Description:
1155 Removes a uuid from the list.
1156 Parameters:
1157 uuid - [in] id to remove
1158 Returns:
1159 True if uuid was in the list and was removed.
1160 False if uuid was not in the list.
1161 */
1162 bool RemoveUuid(ON_UUID uuid);
1163
1164 /*
1165 Description:
1166 Determine if a uuid is in the list.
1167 Returns:
1168 True if uuid is in the list.
1169 */
1170 bool FindUuid(ON_UUID uuid) const;
1171
1172 /*
1173 Description:
1174 Saves the uuid list in an archive.
1175 Parameters:
1176 archive - [in] archive to write to.
1177 Returns:
1178 true if write was successful.
1179 */
1180 bool Write(
1181 class ON_BinaryArchive& archive
1182 ) const;
1183
1184 /*
1185 Description:
1186 Read the uuid list from an archive.
1187 Parameters:
1188 archive - [in] archive to read from.
1189 Returns:
1190 true if the read was successful.
1191 */
1192 bool Read(
1193 class ON_BinaryArchive& archive
1194 );
1195
1196 /*
1197 Description:
1198 Append the uuids in this class to uuid_list.
1199 Parameters:
1200 uuid_list - [in/out]
1201 Returns:
1202 Number of uuids added to uuid_list.
1203 */
1204 int GetUuids(
1205 ON_SimpleArray<ON_UUID>& uuid_list
1206 ) const;
1207
1208 /*
1209 Description:
1210 This tool is used in rare situations when the object ids
1211 stored in the uuid list need to be remapped.
1212 Parameters:
1213 uuid_remap - [in]
1214 Is it critical that uuid_remap[] be sorted with respect
1215 to ON_UuidPair::CompareFirstUuid.
1216 */
1217 void RemapUuids(
1218 const ON_SimpleArray<ON_UuidPair>& uuid_remap
1219 );
1220
1221private:
1222 void SortHelper();
1223 ON_UUID* SearchHelper(const ON_UUID*) const;
1226};
1227
1228/*
1229Description:
1230 The ON_UuidList class provides a tool
1231 to efficiently maintain a list of uuid-index
1232 pairs and determine if a uuid is in the list.
1233 This class is based on the premise that there are
1234 no duplicate uuids in the list.
1235*/
1236class ON_CLASS ON_UuidIndexList : private ON_SimpleArray<ON_UuidIndex>
1237{
1238public:
1240 ON_UuidIndexList(int capacity);
1244
1245 /*
1246 Returns:
1247 Number of active uuids in the list.
1248 */
1249 int Count() const;
1250
1251 /*
1252 Description:
1253 Provides an efficient way to empty a list so that it
1254 can be used again.
1255 */
1256 void Empty();
1257
1258 void Reserve( int capacity );
1259
1260 /*
1261 Description:
1262 Adds a uuid-index pair to the list.
1263 Parameters:
1264 uuid - [in] id to add.
1265 bCheckForDupicates - [in] if true, then the uuid
1266 is not added if it is already in the list.
1267 If you are certain that the uuid is not in the list
1268 and you have a have a large collection of uuids,
1269 then setting bCheckForDupicates=false will
1270 speed up the addition of uuids.
1271 Returns:
1272 True if uuid was added. False if uuid was not added
1273 because it is already in the collection.
1274 */
1275 bool AddUuidIndex(
1276 ON_UUID uuid,
1277 int index,
1278 bool bCheckForDupicates=true);
1279
1280 /*
1281 Description:
1282 Removes an element with a matching uuid from the list.
1283 Parameters:
1284 uuid - [in] id to remove
1285 Returns:
1286 True if an element was removed. False if the uuid
1287 was not in the list.
1288 */
1289 bool RemoveUuid(
1290 ON_UUID uuid
1291 );
1292
1293 /*
1294 Description:
1295 Removes every element with a matching uuid-index pair from
1296 the list.
1297 Parameters:
1298 uuid - [in] id to remove
1299 index - [in] index value
1300 Returns:
1301 True if an element was removed. False if the uuid-index
1302 pair does not appear in the list.
1303 */
1305 ON_UUID uuid,
1306 int index
1307 );
1308
1309 /*
1310 Description:
1311 Determine if an element with a uuid is in the list.
1312 Parameters:
1313 index - [out] if not NULL and a matching uuid is found,
1314 then *index is set to the value of the index.
1315 Returns:
1316 True if an element was found. Returns false if
1317 the uuid is not in the list.
1318 */
1319 bool FindUuid(ON_UUID uuid, int* index=NULL) const;
1320
1321 /*
1322 Description:
1323 Determine if a uuid-index pair is in the list.
1324 Returns:
1325 True if the uuid-index pair is in the list.
1326 Returns false if the uuid-index pair is not
1327 in the list.
1328 */
1329 bool FindUuidIndex(ON_UUID uuid, int index) const;
1330
1331 /*
1332 Description:
1333 Saves the uuid-index list in an archive.
1334 Parameters:
1335 archive - [in] archive to write to.
1336 Returns:
1337 true if write was successful.
1338 */
1339 bool Write(
1340 class ON_BinaryArchive& archive
1341 ) const;
1342
1343 /*
1344 Description:
1345 Read the uuid-index list from an archive.
1346 Parameters:
1347 archive - [in] archive to read from.
1348 Returns:
1349 true if the read was successful.
1350 */
1351 bool Read(
1352 class ON_BinaryArchive& archive
1353 );
1354
1355 /*
1356 Description:
1357 Append the uuids in this class to uuid_list.
1358 Parameters:
1359 uuid_list - [in/out]
1360 Returns:
1361 Number of uuids added to uuid_list.
1362 */
1363 int GetUuids(
1364 ON_SimpleArray<ON_UUID>& uuid_list
1365 ) const;
1366
1367
1368private:
1369 ON_UuidIndex* SearchHelper(const ON_UUID*) const;
1372};
1373
1374class ON_CLASS ON_2dexMap : private ON_SimpleArray<ON_2dex>
1375{
1376public:
1377 ON_2dexMap();
1378 ON_2dexMap(int capacity);
1379 ~ON_2dexMap();
1380
1381 int Count() const;
1382
1383 void Reserve(int capacity);
1384
1385 const ON_2dex* Array() const;
1386
1387 ON_2dex operator[](int i) const;
1388
1389 /*
1390 Description:
1391 Creates an index map with the values
1392 (i0,j),...,(i0+count-1,j)
1393 Parameters:
1394 count - [in]
1395 number of elements
1396 i0 - [in]
1397 i value of first element
1398 j - [in]
1399 j value for all elements
1400 */
1401 void Create(int count, int i0, int j);
1402
1403 /*
1404 Description:
1405 Searches for an element with a matching i
1406 and returns its j value. If no matching
1407 element is found, then not_found_rc is returned.
1408 Parameters:
1409 i - [in]
1410 value of i to search for
1411 not_found_rc - [in]
1412 value to return if there is not a match.
1413 Returns:
1414 j value
1415 */
1416 int FindIndex(
1417 int i,
1418 int not_found_rc
1419 ) const;
1420
1421 /*
1422 Description:
1423 Adds and element (i,j). If there is already an entry with
1424 value (i,*), then no element is added.
1425 Parameters:
1426 i - [in]
1427 i - [in]
1428 Returns:
1429 True if and element it added.
1430 */
1431 bool AddIndex(
1432 int i,
1433 int j
1434 );
1435
1436 /*
1437 Description:
1438 Searches for an element (i,*) and sets its j value to j.
1439 If there is no element with a matching i, then false
1440 is returned.
1441 Parameters:
1442 i - [in]
1443 j - [in]
1444 Returns:
1445 True if and element exists and was set.
1446 */
1447 bool SetIndex(
1448 int i,
1449 int j
1450 );
1451
1452 /*
1453 Description:
1454 If an element (i,*) exists, its j value is set. Otherwise
1455 a new element with value (i,j) is added.
1456 Parameters:
1457 i - [in]
1458 j - [in]
1459 */
1460 void SetOrAddIndex(
1461 int i,
1462 int j
1463 );
1464
1465 /*
1466 Description:
1467 If an element (i,*) exists, it is removed. If there is
1468 not an element with a matching i value, then false
1469 is returned.
1470 Parameters:
1471 i - [in]
1472 Returns:
1473 True if the element was removed
1474 */
1475 bool RemoveIndex(
1476 int i
1477 );
1478
1479 const ON_2dex* Find2dex(int i) const;
1480
1481private:
1483};
1484
1485/*
1486Description:
1487 Compare function for Sort and Search methods.
1488Returns:
1489 -1 if *a < *b is true
1490 1 if *b < *a is true
1491 0 if niether *a <*b nor *b<*a is true
1492Details:
1493 Use this template functions to sort ON_SimpleArray and
1494 ON_ClassArray objects into increasing order. The elements
1495 of the arrays must be a type with an operator < defined.
1496 In particular it works with built in types like double,
1497 int and pointers.
1498Example:
1499
1500 ON_SimpleArray<int> A;
1501 A = ...;
1502 // Sort A in increasing order
1503 A.QuickSort( ON_CompareIncreasing<double> );
1504
1505See Also:
1506 ON_CompareDecreasing
1507*/
1508template< class T>
1509static
1510int ON_CompareIncreasing( const T* a, const T* b);
1511
1512/*
1513Description:
1514 Compare function for Sort and Search methods.
1515Returns:
1516 -1 if *b < *a is true
1517 1 if *a < *b is true
1518 0 if niether *a < *b nor *b < *a is true
1519Details:
1520 Use this template functions to sort ON_SimpleArray and
1521 ON_ClassArray objects into decreasing order. The elements
1522 of the arrays must be a type with an operator < defined.
1523 In particular it works with built in types like double,
1524 int and pointers.
1525Example:
1526
1527 class C
1528 {
1529 public:
1530 ...
1531 bool operator<(const C&) const;
1532 };
1533 ...
1534 ON_ClassArray<C> A;
1535 A = ...;
1536 // Sort A in descrasing order
1537 A.QuickSort( ON_CompareDecreasing<C> );
1538
1539See Also:
1540 ON_CompareIncreasing
1541*/
1542template< class T>
1543static
1544int ON_CompareDecreasing( const T* a, const T* b);
1545
1546
1547// definitions of the template functions are in a different file
1548// so that Microsoft's developer studio's autocomplete utility
1549// will work on the template functions.
1550#include "opennurbs_array_defs.h"
1551
1552
1553#endif
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_array.h:353
Definition opennurbs_array.h:660
Definition opennurbs_array.h:1375
bool m_bSorted
Definition opennurbs_array.h:1482
Definition opennurbs_array.h:376
Definition opennurbs_array.h:683
Definition opennurbs_array.h:398
Definition opennurbs_point.h:403
Definition opennurbs_array.h:706
Definition opennurbs_point.h:931
Definition opennurbs_array.h:602
Definition opennurbs_array.h:727
Definition opennurbs_array.h:626
Definition opennurbs_array.h:643
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_array.h:760
int m_capacity
Definition opennurbs_array.h:985
T * m_a
Definition opennurbs_array.h:983
int m_count
Definition opennurbs_array.h:984
Definition opennurbs_array.h:998
Definition opennurbs_array.h:46
void Shrink()
Definition opennurbs_array_defs.h:555
void Zero()
Definition opennurbs_array_defs.h:530
T * Last()
Definition opennurbs_array_defs.h:240
void Append(const T &)
Definition opennurbs_array_defs.h:285
T * At(int)
Definition opennurbs_array_defs.h:228
int m_capacity
Definition opennurbs_array.h:291
int m_count
Definition opennurbs_array.h:290
void SetCount(int)
Definition opennurbs_array_defs.h:569
void Insert(int, const T &)
Definition opennurbs_array_defs.h:329
void Destroy()
Definition opennurbs_array_defs.h:561
void Swap(int, int)
Definition opennurbs_array_defs.h:385
T * m_a
Definition opennurbs_array.h:289
T & operator[](int)
Definition opennurbs_array_defs.h:157
int NewCapacity() const
Definition opennurbs_array_defs.h:606
bool Sort(ON::sort_algorithm, int *, int(*)(const T *, const T *)) const
Definition opennurbs_array_defs.h:486
void SetArray(T *)
Definition opennurbs_array_defs.h:209
ON_SimpleArray()
Definition opennurbs_array_defs.h:68
unsigned int SizeOfArray() const
Definition opennurbs_array_defs.h:145
bool HeapSort(int(*)(const T *, const T *))
Definition opennurbs_array_defs.h:462
void EmergencyDestroy(void)
Definition opennurbs_array_defs.h:123
void Empty()
Definition opennurbs_array_defs.h:361
void Reverse()
Definition opennurbs_array_defs.h:369
bool QuickSort(int(*)(const T *, const T *))
Definition opennurbs_array_defs.h:474
void Move(int, int, int)
Definition opennurbs_array_defs.h:254
void Reserve(int)
Definition opennurbs_array_defs.h:548
void MemSet(unsigned char)
Definition opennurbs_array_defs.h:538
void SetCapacity(int)
Definition opennurbs_array_defs.h:576
ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
Definition opennurbs_array_defs.h:151
int Search(const T &) const
Definition opennurbs_array_defs.h:395
void Remove()
Definition opennurbs_array_defs.h:345
virtual T * Realloc(T *, int)
Definition opennurbs_array_defs.h:62
bool Permute(const int *)
Definition opennurbs_array_defs.h:514
int Count() const
Definition opennurbs_array_defs.h:133
virtual ON_SimpleArray< T > & operator=(const ON_SimpleArray< T > &)
Definition opennurbs_array_defs.h:101
T & AppendNew()
Definition opennurbs_array_defs.h:273
T * First()
Definition opennurbs_array_defs.h:216
T * Array()
Definition opennurbs_array_defs.h:187
int BinarySearch(const T *, int(*)(const T *, const T *)) const
Definition opennurbs_array_defs.h:416
int Capacity() const
Definition opennurbs_array_defs.h:139
virtual ~ON_SimpleArray()
Definition opennurbs_array_defs.h:95
T * KeepArray()
Definition opennurbs_array_defs.h:199
Definition opennurbs_uuid.h:31
Definition opennurbs_array.h:1237
int m_removed_count
Definition opennurbs_array.h:1371
bool Write(class ON_BinaryArchive &archive) const
int m_sorted_count
Definition opennurbs_array.h:1370
bool Read(class ON_BinaryArchive &archive)
bool RemoveUuidIndex(ON_UUID uuid, int index)
Definition opennurbs_array.h:1079
int m_sorted_count
Definition opennurbs_array.h:1224
int m_removed_count
Definition opennurbs_array.h:1225
Definition opennurbs_array.h:1025
Definition opennurbs_xform.h:28
Reverses all selected entities which support reversing (lines, arcs, splines).
Definition Reverse.js:11
Rotates selected entities.
Definition Rotate.js:11
Translates (moves or copies) selected entities.
Definition Translate.js:11
static int ON_CompareDecreasing(const T *a, const T *b)
static int ON_CompareIncreasing(const T *a, const T *b)
#define ON_CLASS
Definition opennurbs_defines.h:91
static bool SearchHelper(const ON_RTreeNode *a_node, const ON_RTreeBBox *a_rect, ON_RTreeSearchResultCallback &a_result)
Definition opennurbs_rtree.cpp:1863
#define NULL
Definition opennurbs_system.h:256
unsigned int ON__UINT32
Definition opennurbs_system.h:326
Definition opennurbs_defines.h:249