Last change
on this file since 3502 was
3502,
checked in by ldelgass, 12 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
|
Line | |
---|
1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | */ |
---|
6 | #ifndef BUCKETSORT_H |
---|
7 | #define BUCKETSORT_H |
---|
8 | |
---|
9 | #include <vector> |
---|
10 | #include <list> |
---|
11 | |
---|
12 | #include <vrmath/Matrix4x4d.h> |
---|
13 | |
---|
14 | #include "PCASplit.h" |
---|
15 | |
---|
16 | namespace PCA { |
---|
17 | |
---|
18 | class ClusterList |
---|
19 | { |
---|
20 | public : |
---|
21 | ClusterList(Cluster *d, ClusterList *n) : |
---|
22 | data(d), next(n) |
---|
23 | {} |
---|
24 | |
---|
25 | ClusterList() : |
---|
26 | data(0), next(0) |
---|
27 | {} |
---|
28 | |
---|
29 | ~ClusterList() |
---|
30 | { |
---|
31 | //if (next) delete next; |
---|
32 | } |
---|
33 | |
---|
34 | Cluster *data; |
---|
35 | ClusterList *next; |
---|
36 | }; |
---|
37 | |
---|
38 | class BucketSort |
---|
39 | { |
---|
40 | public: |
---|
41 | BucketSort(int maxSize) |
---|
42 | { |
---|
43 | _size = maxSize; |
---|
44 | _buffer = new ClusterList*[maxSize]; |
---|
45 | memset(_buffer, 0, _size * sizeof(ClusterList*)); |
---|
46 | |
---|
47 | _memChuckSize = 1000000; |
---|
48 | _memChunck = new ClusterList[_memChuckSize]; |
---|
49 | |
---|
50 | _invMaxLength = 1.0f / 4.0f; |
---|
51 | } |
---|
52 | |
---|
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 | |
---|
67 | void sort(ClusterAccel* cluster, const vrmath::Matrix4x4d& cameraMat, int level); |
---|
68 | |
---|
69 | void addBucket(Cluster* cluster, float ratio); |
---|
70 | |
---|
71 | ClusterList **getBucket() |
---|
72 | { return _buffer; } |
---|
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; |
---|
86 | }; |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.