bool Clipping::SutherlandHodgmanPolygonClip(Object* p){
    auto &input = p->getNCoords();
    Coordinates tmp;

    clipLeft(input, tmp);
    clipRight(tmp, input);
    clipBottom(input, tmp);
    clipTop(tmp, input);

    return (input.size() != 0);
}
예제 #2
0
void BodyContour::clipBottom(int x, int& y, int imageHeight) const
{
  clipBottom(x, y);

  //clippedY can be outside the image
  if(y < 0)
  {
    y = 0;
  }
  else if(y >= imageHeight)
  {
    y = imageHeight  - 1;
  }
}
bool Clipping::SutherlandHodgmanPolygonClip(Object* p){
    auto input = p->getNCoords();
    Coordinates tmp;
    Coordinates output;

    clipLeft(input, tmp);
    clipRight(tmp, output);
    clipTop(output, tmp);
    clipBottom(tmp, output);

    if(output.size() == 0)
        return false;

    p->setNCoord(output);
    return true;
}
void Triangle2HeightField::clipTriangleAgainstHeightField(const osg::Vec2d& v1, const osg::Vec2d& v2, const osg::Vec2d& v3,
                                                          std::vector<osg::Vec2d>& result)
{
  std::vector<osg::Vec2d>& in = result;
  in.clear();
  in.push_back(v1);
  in.push_back(v2);
  in.push_back(v3);
  std::vector<osg::Vec2d> out;
  clipRight(in, out, _heightField->getNumColumns()-1);
  in.clear();
  clipLeft(out, in, 0);
  out.clear();
  clipTop(in, out, _heightField->getNumRows()-1);
  in.clear();
  clipBottom(out, in, 0);
}
예제 #5
0
void BodyContour::draw() const
{
  DECLARE_DEBUG_DRAWING("representation:BodyContour", "drawingOnImage");
  DECLARE_DEBUG_DRAWING("representation:BodyContour:maxY", "drawingOnImage");
  COMPLEX_DRAWING("representation:BodyContour",
  {
    for(std::vector<Line>::const_iterator i = lines.begin(); i != lines.end(); ++i)
      LINE("representation:BodyContour", i->p1.x, i->p1.y, i->p2.x, i->p2.y, 1,
           Drawings::ps_solid, ColorRGBA(255, 0, 255));

    for(int x = 0; x < cameraResolution.x; x += 10)
    {
      int y = cameraResolution.y;
      clipBottom(x, y);
      LINE("representation:BodyContour", x, y, x, cameraResolution.y, 1,
           Drawings::ps_solid, ColorRGBA(255, 0, 255));
    }
  });
예제 #6
0
	bool Clipper::clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw)
	{
		if(clipFlagsOr & CLIP_FRUSTUM)
		{
			if(clipFlagsOr & CLIP_NEAR)   clipNear(polygon);
			if(polygon.n >= 3) {
			if(clipFlagsOr & CLIP_FAR)    clipFar(polygon);
			if(polygon.n >= 3) {
			if(clipFlagsOr & CLIP_LEFT)   clipLeft(polygon);
			if(polygon.n >= 3) {
			if(clipFlagsOr & CLIP_RIGHT)  clipRight(polygon);
			if(polygon.n >= 3) {
			if(clipFlagsOr & CLIP_TOP)    clipTop(polygon);
			if(polygon.n >= 3) {
			if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon);
			}}}}}
		}

		return polygon.n >= 3;
	}