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

Last change on this file since 3362 was 2822, checked in by ldelgass, 12 years ago

Const correctness fixes, pass vector/matrix objects by reference, various
formatting and style cleanups, don't spam syslog and uncomment openlog() call.
Still needs to be compiled with -DWANT_TRACE to get tracing, but now trace
output will be output to file in /tmp.

  • Property svn:eol-style set to native
File size: 1.4 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 Mat4x4& cameraMat, int level);
44public:
45    BucketSort(int maxSize)
46    {
47        _size = maxSize;
48        _buffer = new ClusterList*[maxSize];
49        memset(_buffer, 0, _size * sizeof(ClusterList*));
50
51        _memChuckSize = 1000000;
52        _memChunck = new ClusterList[_memChuckSize];
53
54        _invMaxLength = 1.0f / 4.0f;
55    }
56
57    ~BucketSort()
58    {
59        delete [] _buffer;
60        delete [] _memChunck;
61    }
62
63    int getSize() const
64    { return _size; }
65
66    int getSortedItemCount() const
67    { return _count; }
68
69    void init();
70
71    void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level);
72
73    void addBucket(Cluster* cluster, float ratio);
74
75    ClusterList **getBucket()
76    { return _buffer; }
77};
78
79}
80
81#endif
Note: See TracBrowser for help on using the repository browser.