root/trunk/spatialindex.hh

Revision 1, 3.1 kB (checked in by poillubo, 2 years ago)

* initial import

Line 
1 /*
2  *  RoxTS
3  *  spatialindex.hh
4  *  Copyright (C) 2006  VERRIER AnaĆ«l
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #ifndef SPATIALINDEX_HH
22 #define SPATIALINDEX_HH
23
24 #include <cassert>
25 #include <cmath>
26 #include <set>
27 #include <vector>
28
29 #include "item.hh"
30 #include "resourceitem.hh"
31 #include "utils.hh"
32
33 using namespace std;
34
35 class SpatialIndex
36 {
37   // Attributes
38   private:
39     static vector<vector<Item *> > items;
40     static vector<vector<ResourceItem *> > resourceitems;
41     static uint16 height;
42     static uint16 width;
43   // Operations
44   private:
45     SpatialIndex();
46     static bool matchGivenItemProfile(Item * item, Player * p, bool player_eq, GenderName g, bool gender_eq, SubGenderName sg, bool subgender_eq);
47     static bool matchGivenResourceItemProfile(ResourceItem * resourceitem, ResourceName rn, bool resourcetype_eq);
48   public:
49     static void init(uint16 height, uint16 width);
50     static void clear();
51     static void setTile(uint16 x, uint16 y, Item * item);
52     static set<Item *> getItemTile(uint16 x, uint16 y, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true);
53     static set<Item *> getItemRect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true);
54     static set<Item *> getItemSquare(uint16 x, uint16 y, uint16 side, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true);
55     static set<Item *> getItemDisc(uint16 x, uint16 y, uint16 radius, Player * p = NULL, bool player_eq = true, GenderName g = GNULL, bool gender_eq = true, SubGenderName sg = SGNULL, bool subgender_eq = true);
56
57     static void setTile(uint16 x, uint16 y, ResourceItem * resourceitem);
58     static set<ResourceItem *> getResourceItemTile(uint16 x, uint16 y, ResourceName rn = RNULL, bool resourcetype_eq = true);
59     static set<ResourceItem *> getResourceItemRect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, ResourceName rn = RNULL, bool resourcetype_eq = true);
60     static set<ResourceItem *> getResourceItemSquare(uint16 x, uint16 y, uint16 side, ResourceName rn = RNULL, bool resourcetype_eq = true);
61     static set<ResourceItem *> getResourceItemDisc(uint16 x, uint16 y, uint16 radius, ResourceName rn = RNULL, bool resourcetype_eq = true);
62 };
63
64 #endif
Note: See TracBrowser for help on using the browser.