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

Last change on this file since 3492 was 3492, checked in by ldelgass, 6 years ago

Fix camera reset for nanovis. Includes refactoring of vector/matrix classes
in nanovis to consolidate into vrmath library. Also add preliminary canonical
view control to clients for testing.

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