13 : group(group), pts(pts), local_z(zrange), global_z(), rendered_cells()
63 return (min + (max - min) / 2.0);
83 return (min + (max - min) / 2.0);
123 FOR_EACH (block_it, (*cell_it)->GetBlocks(layer)) {
125 touchers.insert(&(*block_it)->group->mod);
145 FOR_EACH (block_it, (*cell_it)->GetBlocks(layer)) {
146 Block *testblock = *block_it;
186 (*it)->RemoveBlock(
this, layer);
205 const size_t pt_count =
pts.size();
206 for (
size_t i = 0; i < pt_count; ++i) {
221 point_int_t a(floor(mpt1.
x / cellwidth), floor(mpt1.
y / cellheight));
222 point_int_t b(floor(mpt2.
x / cellwidth), floor(mpt2.
y / cellheight));
226 bool steep = abs(b.
y - a.
y) > abs(b.
x - a.
x);
237 double dydx = (double)(b.
y - a.
y) / (double)(b.
x - a.
x);
239 for (
int x = a.
x; x <= b.
x; ++x) {
241 if (!(floor(y) >= 0))
243 if (!(floor(y) < (int)width))
247 if (!(x < (
int)height))
252 if (!(x < (
int)width))
254 if (!(floor(y) >= 0))
256 if (!(floor(y) < (int)height))
261 data[(int)floor(y) + (x * width)] = 1;
263 data[x + ((int)floor(y) * width)] = 1;
283 glBegin(GL_QUAD_STRIP);
299 glVertex2f(it->x, it->y);
311 const size_t pt_count = wf->
ReadInt(entity,
"points", 0);
314 for (
size_t p = 0; p < pt_count; ++p) {
315 snprintf(key,
sizeof(key),
"point[%d]", (
int)p);
318 wf->
ReadTuple(entity, key, 0, 2,
"ll", &pt.
x, &pt.
y);
345 while (angle < -M_PI)
374 assert(2 <= pts.size());
375 for (
unsigned i = 0, n = pts.size(); i < n; ++i) {
376 unsigned j = (i + 1) % n;
377 vs.push_back(
point_t(pts[j].x - pts[i].x, pts[j].y - pts[i].y));
379 assert(vs.size() == pts.size());
390 for (
unsigned i = 0, n = vs.size(); i < n; ++i) {
391 unsigned j = (i + 1) % n;
416 std::reverse(ps.begin(), ps.end());
Bounds local_z
z extent in local coords.
void swap(int &a, int &b)
static radians_t angle_change(point_t v1, point_t v2)
util; How much was v1 rotated to get to v2?
static bool is_canonical_winding(vector< point_t > const &ps)
Util.
uint64_t updates
the number of simulated time steps executed so far
double max
largest value in range, initially zero
Pose GetGlobalPose() const
The Stage library uses its own namespace.
Block(BlockGroup *group, const std::vector< point_t > &pts, const Bounds &zrange)
int ReadTuple(const int entity, const char *name, const unsigned int first, const unsigned int num, const char *format,...)
double min
smallest value in range, initially zero
void Map(unsigned int layer)
std::vector< point_int_t > LocalToPixels(const std::vector< point_t > &local) const
void SetCenter(double x, double y)
void DrawSolid(bool topview)
meters_t z
location in 3 axes
static void canonicalize_winding(vector< point_t > &pts)
void Load(Worldfile *wf, int entity)
Bounds global_z
z extent in global coordinates.
std::vector< point_t > pts
points defining a polygon.
void SetCenterY(double y)
bool IsRelated(const Model *testmod) const
void SetZ(double min, double max)
static void pi_ize(radians_t &angle)
util; puts angle into -pi/2, pi/2
static vector< point_t > find_vectors(vector< point_t > const &pts)
util; find vectors between adjacent points, pts[next] - pts[cur]
void AddPoint(meters_t x, meters_t y)
class Stg::Model::Visibility vis
void AppendTouchingModels(std::set< Model *> &touchers)
void Rasterize(uint8_t *data, unsigned int width, unsigned int height, meters_t cellwidth, meters_t cellheight)
Stg::Model::RasterVis rastervis
static void positivize(radians_t &angle)
util; puts angle into [0, 2pi)
std::vector< Cell * > rendered_cells[2]
World * world
Pointer to the world in which this model exists.
void Translate(double x, double y)
int ReadInt(int entity, const char *name, int value)
static radians_t angles_sum(vector< point_t > const &vs)
void SetCenterX(double y)
void MapPoly(const std::vector< point_int_t > &poly, Block *block, unsigned int layer)
BlockGroup * group
The BlockGroup to which this Block belongs.
void UnMap(unsigned int layer)