Пример #1
0
static void FillPolyPolygonRaw(GC gc, Drawable drawable, Rect clip, Point offset,
	const Point *vertices, int vertex_count,
	const int *subpolygon_counts, int subpolygon_count_count)
{
	enum { MAX_VERTEX_COUNT = 10000 };

	if(subpolygon_count_count == 1 && vertex_count <= MAX_VERTEX_COUNT) {
		Buffer<XPoint> out_points(vertex_count);
		const Point *in = vertices;
		for(XPoint *out = out_points, *end = out + vertex_count; out < end; out++, in++)
		{
			out -> x = (short)(in -> x + offset.x);
			out -> y = (short)(in -> y + offset.y);
		}
		XFillPolygon(Xdisplay, drawable, gc,
			out_points, vertex_count, Nonconvex, CoordModeOrigin);
	}
	else {
		Vector<Point> split_vertices;
		ASSERT(sizeof(XPoint) <= sizeof(Point)); // modify algorithm when not
		Vector<int> split_counts;
		SplitPolygon(vertices, vertex_count, subpolygon_counts, subpolygon_count_count,
			split_vertices, split_counts, clip);
		const Point *sv = split_vertices.Begin();
		XPoint *dv = reinterpret_cast<XPoint *>(split_vertices.Begin());
		for(const int *sc = split_counts.Begin(), *se = split_counts.End(); sc < se; sc++) {
			for(XPoint *db = dv, *de = dv + *sc; db < de; db++, sv++) {
				db -> x = (short)(sv -> x + offset.x);
				db -> y = (short)(sv -> y + offset.y);
			}
			XFillPolygon(Xdisplay, drawable, gc, dv, *sc, Nonconvex, CoordModeOrigin);
		}
	}
}
Пример #2
0
void
diy::detail::KDTreeSamplingPartition<Block,Point>::
enqueue_exchange(Block* b, const diy::ReduceProxy& srp, int dim, const Samples& samples) const
{
    int         lid  = srp.master()->lid(srp.gid());
    RCLink*     link = static_cast<RCLink*>(srp.master()->link(lid));

    int k = srp.out_link().size();

    if (k == 0)        // final round; nothing needs to be sent; this is actually redundant
        return;

    // pick split points
    float split = samples[0];

    // subset and enqueue
    std::vector< std::vector<Point> > out_points(srp.out_link().size());
    for (size_t i = 0; i < (b->*points_).size(); ++i)
    {
      float x = (b->*points_)[i][dim];
      int loc = x < split ? 0 : 1;
      out_points[loc].push_back((b->*points_)[i]);
    }
    int pos = -1;
    for (int i = 0; i < k; ++i)
    {
      if (srp.out_link().target(i).gid == srp.gid())
      {
        (b->*points_).swap(out_points[i]);
        pos = i;
      }
      else
        srp.enqueue(srp.out_link().target(i), out_points[i]);
    }
    if (pos == 0)
        link->core().max[dim] = split;
    else
        link->core().min[dim] = split;
}