Last change
on this file since 3597 was
3502,
checked in by ldelgass, 11 years ago
|
Add basic VTK structured points reader to nanovis, update copyright dates.
|
-
Property svn:eol-style set to
native
|
File size:
1.5 KB
|
Rev | Line | |
---|
[2798] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
[3502] | 2 | /* |
---|
| 3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
| 4 | * |
---|
| 5 | */ |
---|
[2822] | 6 | #ifndef BUCKETSORT_H |
---|
| 7 | #define BUCKETSORT_H |
---|
[2096] | 8 | |
---|
| 9 | #include <vector> |
---|
| 10 | #include <list> |
---|
[3492] | 11 | |
---|
| 12 | #include <vrmath/Matrix4x4d.h> |
---|
| 13 | |
---|
[2096] | 14 | #include "PCASplit.h" |
---|
| 15 | |
---|
| 16 | namespace PCA { |
---|
| 17 | |
---|
[3492] | 18 | class ClusterList |
---|
| 19 | { |
---|
[2096] | 20 | public : |
---|
[2822] | 21 | ClusterList(Cluster *d, ClusterList *n) : |
---|
| 22 | data(d), next(n) |
---|
| 23 | {} |
---|
[2096] | 24 | |
---|
[2822] | 25 | ClusterList() : |
---|
| 26 | data(0), next(0) |
---|
| 27 | {} |
---|
[2096] | 28 | |
---|
[2822] | 29 | ~ClusterList() |
---|
| 30 | { |
---|
| 31 | //if (next) delete next; |
---|
| 32 | } |
---|
[3492] | 33 | |
---|
| 34 | Cluster *data; |
---|
| 35 | ClusterList *next; |
---|
[2096] | 36 | }; |
---|
| 37 | |
---|
[3492] | 38 | class BucketSort |
---|
| 39 | { |
---|
[2822] | 40 | public: |
---|
| 41 | BucketSort(int maxSize) |
---|
| 42 | { |
---|
| 43 | _size = maxSize; |
---|
| 44 | _buffer = new ClusterList*[maxSize]; |
---|
| 45 | memset(_buffer, 0, _size * sizeof(ClusterList*)); |
---|
[2096] | 46 | |
---|
[2822] | 47 | _memChuckSize = 1000000; |
---|
| 48 | _memChunck = new ClusterList[_memChuckSize]; |
---|
[2096] | 49 | |
---|
[2822] | 50 | _invMaxLength = 1.0f / 4.0f; |
---|
| 51 | } |
---|
[2096] | 52 | |
---|
[2822] | 53 | ~BucketSort() |
---|
| 54 | { |
---|
| 55 | delete [] _buffer; |
---|
| 56 | delete [] _memChunck; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | int getSize() const |
---|
| 60 | { return _size; } |
---|
| 61 | |
---|
| 62 | int getSortedItemCount() const |
---|
| 63 | { return _count; } |
---|
| 64 | |
---|
| 65 | void init(); |
---|
| 66 | |
---|
[3492] | 67 | void sort(ClusterAccel* cluster, const vrmath::Matrix4x4d& cameraMat, int level); |
---|
[2822] | 68 | |
---|
| 69 | void addBucket(Cluster* cluster, float ratio); |
---|
| 70 | |
---|
| 71 | ClusterList **getBucket() |
---|
| 72 | { return _buffer; } |
---|
[3492] | 73 | |
---|
| 74 | private: |
---|
| 75 | void _sort(Cluster *cluster, const vrmath::Matrix4x4d& cameraMat, int level); |
---|
| 76 | |
---|
| 77 | ClusterList **_buffer; |
---|
| 78 | int _size; |
---|
| 79 | int _count; |
---|
| 80 | |
---|
| 81 | int _memChuckSize; |
---|
| 82 | bool _memChunckUsedFlag; |
---|
| 83 | ClusterList *_memChunck; |
---|
| 84 | |
---|
| 85 | float _invMaxLength; |
---|
[2096] | 86 | }; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.