Subversion Repositories spk

Rev

Rev 1 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 114
Line 4... Line 4...
4
 
4
 
5
  it acts as kind of Search Tree but not binary search tree
5
  it acts as kind of Search Tree but not binary search tree
6
 
6
 
7
  the map itself is created by linked list consisting of p_node objects.
7
  the map itself is created by linked list consisting of p_node objects.
8
  p_node means "point node" although it does not contain any point.
8
  p_node means "point node" although it does not contain any point.
9
  pp_node means "point point node" because it does contain bob_dom_point :)
9
  pp_node means "point point node" because it does contain bob_dom_vertex :)
10
 
10
 
11
  if you add a point into this map:
11
  if you add a point into this map:
12
 
12
 
13
  - I will take the X coordinate
13
  - I will take the X coordinate
14
  - I will take its 1th byte (left most) of the coordinate and try to find it in list.
14
  - I will take its 1st byte (left most) of the coordinate and try to find it in the list.
15
  Either I will find it or I will add new p_node object.
15
  Either I will find it or I will add new p_node object.
16
  - I will take the 2nd byte and try to find it in the previously returned p_node which
16
  - I will take the 2nd byte and try to find it in the previously returned p_node which
17
  is now the "base"
17
  is now the "base"
18
  - I will continue with the remaining 3 bytes
18
  - I will continue with the remaining 3 bytes
19
  - I will repeat this for Y and Z coordinates
19
  - I will repeat this for Y and Z coordinates
Line 52... Line 52...
52
		};
52
		};
53
 
53
 
54
		struct pp_node : public p_node
54
		struct pp_node : public p_node
55
		{
55
		{
56
			int index;
56
			int index;
57
			bob_dom_point *pnt;
57
			bob_vertex *pnt;
58
			pp_node() { pnt=0; index=0; }
58
			pp_node() { pnt=0; index=0; }
59
		};
59
		};
60
 
60
 
61
		p_node m_root;
61
		p_node m_root;
62
 
62
 
Line 107... Line 107...
107
			}
107
			}
108
			delete old;
108
			delete old;
109
		}
109
		}
110
 
110
 
111
	private:
111
	private:
112
		typedef ext::array<bob_dom_point*> point_array;
112
		typedef ext::array<bob_vertex*> point_array;
113
		typedef ext::array<int> int_array;
113
		typedef ext::array<int> int_array;
114
		typedef ext::simple_list<int> int_list;
114
		typedef ext::simple_list<int> int_list;
115
 
115
 
116
		point_array m_points; // all points
116
		point_array m_points; // all points
117
		int_array m_indexes; // converted indexes
117
		int_array m_indexes; // converted indexes
Line 128... Line 128...
128
 
128
 
129
			public:
129
			public:
130
				point_rec(const pp_node *node) { m_node=node; }
130
				point_rec(const pp_node *node) { m_node=node; }
131
				point_rec(const point_rec& other) { m_node=other.m_node; }
131
				point_rec(const point_rec& other) { m_node=other.m_node; }
132
 
132
 
133
				bob_dom_point * operator *() { return m_node->pnt; }
133
				bob_vertex * operator *() { return m_node->pnt; }
134
		};
134
		};
135
 
135
 
136
		class point_bucket
136
		class point_bucket
137
		{
137
		{
138
			private:
138
			private:
Line 163... Line 163...
163
						;;
163
						;;
164
					return point_rec((const pp_node*)n);
164
					return point_rec((const pp_node*)n);
165
				}
165
				}
166
		};
166
		};
167
	private:
167
	private:
168
		point_bucket _addPoint(bob_dom_point *pnt)
168
		point_bucket _addPoint(bob_vertex *pnt)
169
		{
169
		{
170
			p_node *n;
170
			p_node *n;
171
			int v;
171
			int v;
172
			v=pnt->x;
172
			v=pnt->x;
173
			n=&m_root;
173
			n=&m_root;
Line 195... Line 195...
195
			return point_bucket((pp_node*)n->child);
195
			return point_bucket((pp_node*)n->child);
196
		}
196
		}
197
 
197
 
198
	public:
198
	public:
199
		typedef point_array::iterator iterator;
199
		typedef point_array::iterator iterator;
-
 
200
		typedef point_array::const_iterator const_iterator;
200
		typedef int_list::const_iterator const_index_iterator;
201
		typedef int_list::const_iterator const_index_iterator;
201
 
202
 
202
		iterator begin() { return m_points.begin(); }
203
		iterator begin() { return m_points.begin(); }
203
		iterator end() { return m_points.end(); }
204
		iterator end() { return m_points.end(); }
-
 
205
		
-
 
206
		const_iterator begin() const { return m_points.begin(); }
-
 
207
		const_iterator end() const { return m_points.end(); }
204
 
208
 
205
		const_index_iterator indexBegin() const { return m_uniqueIndexes.begin(); }
209
		const_index_iterator indexBegin() const { return m_uniqueIndexes.begin(); }
206
		const_index_iterator indexEnd() const { return m_uniqueIndexes.end(); }
210
		const_index_iterator indexEnd() const { return m_uniqueIndexes.end(); }
207
 
211
 
208
		//>>>>>>>>>>>>>
212
		//>>>>>>>>>>>>>
Line 217... Line 221...
217
			m_indexes.resize(size);
221
			m_indexes.resize(size);
218
			m_pointSize=0;
222
			m_pointSize=0;
219
			m_compCount=0;
223
			m_compCount=0;
220
		}
224
		}
221
 
225
 
222
		void addPoint(bob_dom_point * pnt)
226
		void addPoint(bob_vertex * pnt)
223
		{
227
		{
224
			point_bucket pb=_addPoint(pnt);
228
			point_bucket pb=_addPoint(pnt);
225
 
229
 
226
			if(pb.size() == 1){
230
			if(pb.size() == 1){
227
				pb.index((int)m_uniqueIndexes.size());
231
				pb.index((int)m_uniqueIndexes.size());
Line 251... Line 255...
251
			m_pointSize=0;
255
			m_pointSize=0;
252
 
256
 
253
			m_unique_it=m_uniqueIndexes.end();
257
			m_unique_it=m_uniqueIndexes.end();
254
		}
258
		}
255
 
259
 
256
		bob_dom_point * operator[](int idx) { return m_points[idx]; }
260
		bob_vertex * operator[](int idx) { return m_points[idx]; }
257
		const bob_dom_point * operator[](int idx) const { return m_points[idx]; }
261
		const bob_vertex * operator[](int idx) const { return m_points[idx]; }
258
 
262
 
259
		int uniqueIndex(int idx) const { return (size_t)idx < m_points.size() ? m_indexes[idx] : -1; }
263
		int uniqueIndex(int idx) const { return (size_t)idx < m_points.size() ? m_indexes[idx] : -1; }
260
 
264
 
261
		size_t pointsSize() const { return m_points.size(); }
265
		size_t pointsSize() const { return m_points.size(); }
262
		size_t uniquePointsSize() const { return m_uniqueIndexes.size(); }
266
		size_t uniquePointsSize() const { return m_uniqueIndexes.size(); }
263
 
267
 
264
		bob_dom_point * nextUniquePoint()
268
		bob_vertex * nextUniquePoint()
265
		{
269
		{
266
			++m_unique_it;
270
			++m_unique_it;
267
			bob_dom_point *p=(m_unique_it!=m_uniqueIndexes.end() ? m_points[*m_unique_it] : 0);
271
			bob_vertex *p=(m_unique_it!=m_uniqueIndexes.end() ? m_points[*m_unique_it] : 0);
268
			return p;
272
			return p;
269
		}
273
		}
270
};
274
};
271
 
275
 
272
#endif // !defined(BOB_POINT_MAP_INCLUDED)
276
#endif // !defined(BOB_POINT_MAP_INCLUDED)