vertex_t data_accessor_t::get_vertex_by_id(vertex_id_t id) const
{
  details::raw_vertex_t * raw_v = raw_vertex_by_id(id);
  if (raw_v == NULL)
    return vertex_t();
  else
    return vertex_t(id, vertex_data_t(raw_v->lon, raw_v->lat));
}
Esempio n. 2
0
int PolygonSplitter::addVertex(double x, double y)
{
	// Check vertex doesn't exist
	for (unsigned a = 0; a < vertices.size(); a++)
	{
		if (vertices[a].x == x && vertices[a].y == y)
			return a;
	}

	// Add vertex
	vertices.push_back(vertex_t(x, y));
	vertices.back().distance = 999999;
	return vertices.size() - 1;
}
Esempio n. 3
0
void GLShapeRenderer::renderPolygon(LKSurface& Surface, const XShape& shape, Brush& brush, const ScreenProjection& _Proj) {
  /*
   OpenGL cannot draw complex polygons so we need to use a Tessallator to draw the polygon using a GL_TRIANGLE_FAN
   */  
#ifdef USE_GLSL
  OpenGL::solid_shader->Use();
#endif
  
  brush.Bind();
    
  std::unique_ptr<const GLBlend> blend; 
  if(!brush.IsOpaque()) {
    blend = std::make_unique<const GLBlend>(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  }
  
  curr_LabelPos = clipRect.GetBottomRight();
  
  const shapeObj& shp = shape.shape;

  gluTessBeginPolygon(tess, this );
  for (int j = 0; j < shp.numlines; j++) {
    gluTessBeginContour(tess);
    for (int i = 0; i < shp.line[j].numpoints; i++) {
      const RasterPoint pt = _Proj.LonLat2Screen(shp.line[j].point[i]);
      if (!noLabel &&  (pt.x<=curr_LabelPos.x)) {
        curr_LabelPos = pt;
      }  
      vertex_t& vertex = *(pointers.insert(pointers.end(), vertex_t({{(GLdouble)pt.x, (GLdouble)pt.y, 0.}})));
      gluTessVertex(tess, vertex.data(), vertex.data());
    }
    gluTessEndContour(tess);
  }
  gluTessEndPolygon(tess);
  
  if(shape.HasLabel() && clipRect.IsInside(curr_LabelPos)) {
    shape.renderSpecial(Surface, curr_LabelPos.x, curr_LabelPos.y, clipRect);
  }
  
  pointers.clear();
}
Esempio n. 4
0
void GLShapeRenderer::polygonCombine(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], void **outData) {  
  auto It = pointers.insert(pointers.end(), vertex_t({{coords[0], coords[1], coords[2]}}));
  *outData = It->data();
}