Copiste
0.1
Main Page
Related Pages
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
Friends
Pages
include
gui
quadtree.h
1
/*
2
* This file is part of Copiste.
3
*
4
* Copiste is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* Copiste is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with Copiste. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef INCLUDED_QUADTREEH
19
#define INCLUDED_QUADTREEH
20
21
#include "algo/corpus.h"
22
23
#include <list>
24
26
class
QuadNode
27
{
28
public
:
30
QuadNode
(
int
e = -1);
32
QuadNode
(
QuadNode
* a,
QuadNode
* b,
QuadNode
*c,
QuadNode
*d);
33
35
~QuadNode
();
36
38
bool
isLeaf
();
39
41
int
elem
;
43
QuadNode
*
hl
;
44
QuadNode
* hr;
45
QuadNode
* ll;
46
QuadNode
* lr;
47
};
48
49
class
QuadTree
50
{
51
public
:
53
QuadTree
();
54
56
~QuadTree
();
57
59
struct
rect
60
{
61
double
x;
62
double
y;
63
double
w;
64
double
h;
65
};
66
typedef
struct
rect
rect
;
67
69
void
create
(
Corpus
*c,
rect
view);
70
72
int
nearest
(
double
x,
double
y);
73
74
75
private
:
77
std::list<int> separate(std::list<int> l,
QuadTree::rect
view);
78
80
QuadNode
* createNode(std::list<int> points,
QuadTree::rect
view);
81
83
bool
isInRect(
double
x,
double
y,
rect
r);
84
86
int
nodeSearch(
QuadNode
*node,
rect
view,
double
x,
double
y);
87
89
QuadNode
* mRoot;
90
92
Corpus
* mCorpus;
93
95
rect
mViewport;
96
};
97
98
#endif
99
Generated on Sun Sep 2 2012 09:48:30 for Copiste by
1.8.1.1