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 
28 
29 namespace SimRasterize
30 {
31 
32 /**
33  * Represents the set of cells (i,j) where i0 <= i < i1
34  */
35 struct Span
36 {
39  i16 j;
40 };
41 
42 typedef std::vector<Span> Spans;
43 
44 /**
45  * Converts an ObstructionSquare @p shape (a rotated rectangle),
46  * expanded by the given @p clearance,
47  * into a list of spans of cells that are strictly inside the shape.
48  */
49 void RasterizeRectWithClearance(Spans& spans,
51  entity_pos_t clearance, entity_pos_t cellSize);
52 
53 }
54 
55 #endif // INCLUDED_HELPER_RASTERIZE
A simple fixed-point number class.
Definition: Fixed.h:119
i16 i1
Definition: Rasterize.h:38
Definition: Rasterize.h:29
i16 i0
Definition: Rasterize.h:37
i16 j
Definition: Rasterize.h:39
std::vector< Span > Spans
Definition: Rasterize.h:42
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:25
Represents the set of cells (i,j) where i0 <= i < i1.
Definition: Rasterize.h:35
int16_t i16
Definition: types.h:33
Entity coordinate types.
Standard representation for all types of shapes, for use with geometry processing code...
Definition: ICmpObstructionManager.h:66