示例#1
0
vector<Poly> Clipping::getOffset(const Poly &poly, double distance,
				 JoinType jtype, double miterdist)
{
  CL::Polygons cpolys(1); cpolys[0]=getClipperPolygon(poly);
  CL::Polygons offset = CLOffset(cpolys, CL_FACTOR*distance, CLType(jtype), miterdist);
  return getPolys(offset, poly.getZ(), poly.getExtrusionFactor());
}
示例#2
0
void Infill::addInfillPoly(Poly p)
{
  // Poly *zigzagpoly = NULL;
  switch (type) {
  // case ZigzagInfill: // take parallel lines and connect ends
  //   zigzagpoly = new Poly(p.getZ(),extrusionfactor);
  case BridgeInfill:
  case ParallelInfill:
    { // make lines instead of closed polygons
      Vector2d l,rotl;
      double sina = sin(-angle);
      double cosa = cos(-angle);
      // use the lines that have the angle of this Infill
      for (uint i=0; i < p.size() ; i+=1 )
  	{
  	  l = (p.getVertexCircular(i+1) - p.getVertexCircular(i));     
	  // rotate with neg. infill angle and see whether it's 90° as infill lines
	  rotl = Vector2d(l.x*cosa-l.y*sina, 
			  l.y*cosa+l.x*sina);
	  if (abs(rotl.x) < 0.1 && abs(rotl.y) > 0.1)
  	    {
	      // if (zigzagpoly) {
	      // 	zigzagpoly->addVertex(p.getVertexCircular(i+i%2));
	      // 	zigzagpoly->addVertex(p.getVertexCircular(i+1+i%2));
	      // } else
	      {
		Poly newpoly(p.getZ(), extrusionfactor);
		newpoly.vertices.push_back(p.getVertexCircular(i));
		newpoly.vertices.push_back(p.getVertexCircular(i+1));
		infillpolys.push_back(newpoly);
	      }
  	    }
	  // else
	  //   if (zigzagpoly) {
	  //     zigzagpoly->addVertex(p.getVertexCircular(i));	      
	  //   }
  	}
      // if (zigzagpoly) {
      // 	cerr << zigzagpoly->size()<< endl;
      // 	if (zigzagpoly->size()>0)
      // 	  infillpolys.push_back(*zigzagpoly);
      // 	else delete zigzagpoly;
      // 	cerr << infillpolys.size()<< endl;
      // }
    } 
    break;
  default:
    {
      p.setExtrusionFactor(extrusionfactor);
      infillpolys.push_back(p);
    }
  }
}
示例#3
0
void Clipping::addPoly(const Poly &poly, PolyType type)
{
  clpr.AddPolygon(getClipperPolygon(poly),CLType(type));
  lastZ = poly.getZ();
  lastExtrF = poly.getExtrusionFactor();
}