blob: b1be8bf62d87e989fbdb95cb200569e0d43071f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// Copyright 2006-2007 Nanorex, Inc. See LICENSE file for details.
/*
Name: bucket.h
Author: Oleksandr Shevchenko
Description: class for bucket representation
*/
#if !defined(BUCKET_INCLUDED)
#define BUCKET_INCLUDED
#include "container.h"
#include "triple.h"
class Bucket
{
public:
//------------------------------------------------------------------------
// Constructor
//
// empty bucket
//
Bucket(int l, int m, int n);
//------------------------------------------------------------------------
// Add
//
// add points to bucket
//
void Add(const Container<Triple> & points);
//------------------------------------------------------------------------
// Duplicate
//
// find duplicate points
//
void Duplicate(const Container<Triple> & points, int * ia);
private:
//------------------------------------------------------------------------
// Index()
//
// calculate index
//
inline void Index(const Triple & p);
//------------------------------------------------------------------------
// Size()
//
// calculate array size
//
inline int Size() const;
//------------------------------------------------------------------------
// Value()
//
// calculate array value
//
inline int Value(int i) const;
//------------------------------------------------------------------------
// mI
int mI; // index i
//------------------------------------------------------------------------
// mJ
int mJ; // index j
//------------------------------------------------------------------------
// mK
int mK; // index k
//------------------------------------------------------------------------
// mL
int mL; // size x
//------------------------------------------------------------------------
// mM
int mM; // size y
//------------------------------------------------------------------------
// mN
int mN; // size z
//------------------------------------------------------------------------
// mA
Container<int> *** mA; // array for bucket
//------------------------------------------------------------------------
// mB
Container<int> ** mB; // array for bucket
//------------------------------------------------------------------------
// mC
Container<int> * mC; // array for bucket
};
//----------------------------------------------------------------------------
// Index()
inline void Bucket::Index(const Triple & p)
{
// calculate index for point p
mI = int(mL * (p.X() + 1) / 2);
if ( mI < 0) mI = 0;
if ( mI >= mL) mI = mL - 1;
mJ = int(mM * (p.Y() + 1) / 2);
if ( mJ < 0) mJ = 0;
if ( mJ >= mM) mJ = mM - 1;
mK = int(mN * (p.Z() + 1) / 2);
if ( mK < 0) mK = 0;
if ( mK >= mN) mK = mN - 1;
}
//----------------------------------------------------------------------------
// Size()
inline int Bucket::Size() const
{
return mA[mI][mJ][mK].Size();
}
//----------------------------------------------------------------------------
// Value()
inline int Bucket::Value(int i) const
{
return mA[mI][mJ][mK][i];
}
#endif // BUCKET_INCLUDED
|