source: trunk/packages/vizservers/nanovis/BucketSort.h @ 2804

Last change on this file since 2804 was 2798, checked in by ldelgass, 12 years ago

Add emacs mode magic line in preparation for indentation cleanup

  • 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#ifndef __BUCKETSORT_H_
3#define __BUCKETSORT_H_
4
5#include <vector>
6#include <list>
7#include "Vector3.h"
8#include "Mat4x4.h"
9#include "PCASplit.h"
10
11namespace PCA {
12
13class ClusterList {
14public :
15        Cluster* data;
16        ClusterList* next;
17public :
18        ClusterList(Cluster* d, ClusterList* n)
19                : data(d), next(n)
20        {}
21
22        ClusterList()
23                : data(0), next(0)
24        {}
25
26        ~ClusterList()
27        {
28                //if (next) delete next;
29        }
30};
31
32class BucketSort {
33        ClusterList** _buffer;
34        int _size;
35        int _count;
36
37        int _memChuckSize;
38        bool _memChunckUsedFlag;
39        ClusterList* _memChunck;
40       
41        float _invMaxLength;
42private :
43        //void _sort(Cluster* cluster, const Matrix4& cameraMat, int level);
44        void _sort(Cluster* cluster, const Mat4x4& cameraMat, int level);
45public :
46        BucketSort(int maxSize)
47        {
48                _size = maxSize;
49                _buffer = new ClusterList*[maxSize];
50                memset(_buffer, 0, _size * sizeof(ClusterList*));
51
52                _memChuckSize = 1000000;
53                _memChunck = new ClusterList[_memChuckSize];
54
55                _invMaxLength = 1.0f / 4.0f;
56        }
57
58        ~BucketSort()
59        {
60                delete [] _buffer;
61                delete [] _memChunck;
62        }
63
64        int getSize() const { return _size; }
65        int getSortedItemCount() const { return _count; }
66        void init();
67        //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, float maxLength);
68        //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, int level);
69        void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level);
70        void addBucket(Cluster* cluster, float ratio);
71        ClusterList** getBucket() { return _buffer; }
72};
73
74}
75
76#endif
Note: See TracBrowser for help on using the repository browser.