14 const std::vector<point_t>& pts,
23 local_z( zmin, zmax ),
25 inherit_color( inherit_color ),
81 if( it->y > max ) max = it->y;
82 if( it->y < min ) min = it->y;
86 return( min + (max - min)/2.0 );
96 if( it->x > max ) max = it->x;
97 if( it->x < min ) min = it->x;
101 return( min + (max - min)/2.0 );
146 FOR_EACH( block_it, (*cell_it)->GetBlocks(layer) )
149 touchers.insert( (*block_it)->mod );
171 FOR_EACH( block_it, (*cell_it)->GetBlocks(layer) )
173 Block* testblock = *block_it;
179 if( (testmod != this->
mod) &&
202 if(
mpts.size() == 0 )
229 #include <functional> 234 (*it)->RemoveBlock(
this, layer );
289 floor( mpt1.
y / cellheight ));
291 floor( mpt2.
y / cellheight ) );
293 bool steep = abs( b.
y-a.
y ) > abs( b.
x-a.
x );
306 double dydx = (double) (b.
y - a.
y) / (double) (b.
x - a.
x);
308 for(
int x=a.
x; x<=b.
x; ++x)
312 if( ! (floor(y) >= 0) )
continue;
313 if( ! (floor(y) < (int)width) )
continue;
314 if( ! (x >= 0) )
continue;
315 if( ! (x < (
int)height) )
continue;
319 if( ! (x >= 0) )
continue;
320 if( ! (x < (
int)width) )
continue;
321 if( ! (floor(y) >= 0) )
continue;
322 if( ! (floor(y) < (int)height) )
continue;
326 data[ (int)floor(y) + (x * width)] = 1;
328 data[ x + ((int)floor(y) * width)] = 1;
338 glBegin( GL_POLYGON);
347 glBegin(GL_QUAD_STRIP);
364 glVertex2f( it->x, it->y );
403 snprintf(key,
sizeof(key),
"point[%d]", (
int)p );
406 wf->
ReadTuple( entity, key, 0, 2,
"ll", &pt.
x, &pt.
y );
415 const std::string& colorstr = wf->
ReadString( entity,
"color",
"" );
435 while (angle < 0) angle += 2 * M_PI;
442 while (angle < -M_PI) angle += 2 * M_PI;
443 while (M_PI < angle) angle -= 2 * M_PI;
467 assert(2 <= pts.size());
468 for (
unsigned i = 0, n = pts.size(); i < n; ++i)
470 unsigned j = (i + 1) % n;
471 vs.push_back(
point_t(pts[j].x - pts[i].x, pts[j].y - pts[i].y));
473 assert(vs.size() == pts.size());
483 for (
unsigned i = 0, n = vs.size(); i < n; ++i)
485 unsigned j = (i + 1) % n;
498 bool bCanon = 0 < sum;
514 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
The Stage library uses its own namespace.
std::vector< point_t > mpts
cache of this->pts in model coordindates
Block(Model *mod, const std::vector< point_t > &pts, meters_t zmin, meters_t zmax, Color color, bool inherit_color, bool wheel)
const std::string ReadString(int entity, const char *name, const std::string &value)
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)
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)
bool IsRelated(const Model *testmod) const
std::vector< point_t > pts
points defining a polygonx
Pose GetGlobalPose() const
std::vector< point_int_t > LocalToPixels(const std::vector< point_t > &local) const
void SetCenterY(double y)
void SetZ(double min, double max)
void AppendTouchingModels(std::set< Model * > &touchers)
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 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]
void InvalidateModelPointCache()
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)
const point3_t & GetOffset()
size_t pt_count
the number of points
point_t BlockPointToModelMeters(const point_t &bpt)
Model * mod
model to which this block belongs
void MapPoly(const std::vector< point_int_t > &poly, Block *block, unsigned int layer)
void BuildDisplayList(Model *mod)
void UnMap(unsigned int layer)