Pyrogenesis  trunk
Rasterize.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. 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 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_HELPER_RASTERIZE
19 #define INCLUDED_HELPER_RASTERIZE
20 
21 /**
22  * @file
23  * Helper functions related to rasterizing geometric shapes to grids.
24  */
25 
27 
28 namespace SimRasterize
29 {
30 
31 /**
32  * Represents the set of cells (i,j) where i0 <= i < i1
33  */
34 struct Span
35 {
38  i16 j;
39 };
40 
41 typedef std::vector<Span> Spans;
42 
43 /**
44  * Converts an ObstructionSquare @p shape (a rotated rectangle),
45  * expanded by the given @p clearance,
46  * into a list of spans of cells that are strictly inside the shape.
47  */
48 void RasterizeRectWithClearance(Spans& spans,
50  entity_pos_t clearance, entity_pos_t cellSize);
51 
52 }
53 
54 #endif // INCLUDED_HELPER_RASTERIZE
A simple fixed-point number class.
Definition: Fixed.h:115
i16 i1
Definition: Rasterize.h:37
Definition: Rasterize.h:28
i16 i0
Definition: Rasterize.h:36
i16 j
Definition: Rasterize.h:38
std::vector< Span > Spans
Definition: Rasterize.h:41
void RasterizeRectWithClearance(Spans &spans, const ICmpObstructionManager::ObstructionSquare &shape, entity_pos_t clearance, entity_pos_t cellSize)
Converts an ObstructionSquare shape (a rotated rectangle), expanded by the given clearance, into a list of spans of cells that are strictly inside the shape.
Definition: Rasterize.cpp:24
Represents the set of cells (i,j) where i0 <= i < i1.
Definition: Rasterize.h:34
int16_t i16
Definition: types.h:33
Standard representation for all types of shapes, for use with geometry processing code...
Definition: ICmpObstructionManager.h:224