Exemplo n.º 1
0
// add full fill and subtract them from normal fill polys
void Layer::addFullPolygons(const vector<Poly> &newpolys, bool decor)
{
  if (newpolys.size()==0) return;
  Clipping clipp;
  clipp.clear();
  // full fill only where already normal fill
  clipp.addPolys(fillPolygons,subject);
  if (decor) clipp.addPolys(fullFillPolygons,subject);
  clipp.addPolys(newpolys,clip);
  clipp.setZ(Z);
  vector<Poly> inter = clipp.intersect();
  vector<Poly> normals = clipp.subtractMerged(thickness/2.);
  if (decor) {//  && LayerNo != 0) // no decor on base layers
    decorPolygons.insert(decorPolygons.end(), inter.begin(), inter.end());
    Clipping clipp;
    clipp.addPolys(fullFillPolygons,subject);
    clipp.addPolys(inter,clip);
    clipp.setZ(Z);
    setFullFillPolygons(clipp.subtract());
  }
  else {
    fullFillPolygons.insert(fullFillPolygons.end(),inter.begin(),inter.end());
  }

  setNormalFillPolygons(normals);
  //  mergeFullPolygons(false); // done separately
}
Exemplo n.º 2
0
void Layer::calcBridgeAngles(const Layer *layerbelow) {
  bridge_angles.resize(bridgePolygons.size());
  Clipping clipp;
  vector<Poly> polysbelow = *(layerbelow->GetInnerShell());//clipp.getOffset(polygons,3*thickness);
  bridgePillars.resize(bridgePolygons.size());
  for (uint i=0; i<bridgePolygons.size(); i++)
    {
      // intersect bridge poly with polygons below (=pillars of bridge)
      clipp.clear();
      clipp.addPolys(polysbelow,subject);
      clipp.addPolys(clipp.getOffset(bridgePolygons[i].outer,thickness),clip);
      bridgePillars[i] = clipp.intersect();

      // TODO detect circular bridges -> rotating infill?

      // get average direction of the mutual connections of all the intersections
      Vector2d dir(0,0);
      for (uint p=0; p<bridgePillars[i].size(); p++){
	for (uint q=p+1; q<bridgePillars[i].size(); q++){
	  // Vector2d p1,p2;
	  // bridgePillars[i][q].shortestConnectionSq(bridgePillars[i][p], p1,p2);
	  // dir += (p2-p1);
	  dir += bridgePillars[i][q].center - bridgePillars[i][p].center;
	}
      }
      //cerr << pillars.size() << " - " << dir << endl;
      bridge_angles[i] = atan2(dir.y(),dir.x());
      if (bridge_angles[i]<0) bridge_angles[i]+=M_PI;
    }
}
Exemplo n.º 3
0
// add bridge polys and substract them from normal and full fill polys 
void Layer::addBridgePolygons(const vector<Poly> newpolys) 
{
  if (newpolys.size()==0) return;
  bridgePolygons.clear();
  Clipping clipp;
  clipp.clear();
  clipp.addPolys(fillPolygons,subject); 
  clipp.addPolys(newpolys,clip);
  vector<Poly> inter = clipp.intersect();
  bridgePolygons= inter;//.insert(bridgePolygons.end(),inter.begin(),inter.end());
  clipp.clear();
  clipp.addPolys(fillPolygons,subject);  
  clipp.addPolys(inter,clip);
  setNormalFillPolygons(clipp.substract());
  mergeFullPolygons(true);
}
Exemplo n.º 4
0
// add full fill and substract them from normal fill polys 
void Layer::addFullPolygons(const vector<Poly> newpolys, bool decor) 
{
  if (newpolys.size()==0) return;
  Clipping clipp;
  clipp.clear();
  // full fill only where already normal fill
  clipp.addPolys(fillPolygons,subject); 
  clipp.addPolys(newpolys,clip);
  vector<Poly> inter = clipp.intersect();
  if (decor)
    decorPolygons.insert(decorPolygons.end(),inter.begin(),inter.end());
  else
    fullFillPolygons.insert(fullFillPolygons.end(),inter.begin(),inter.end());

  //substract from normal fills
  clipp.clear();
  clipp.addPolys(fillPolygons,subject);  
  clipp.addPolys(inter,clip);
  setNormalFillPolygons(clipp.substract());
  mergeFullPolygons(false);
}
Exemplo n.º 5
0
void Layer::calcBridgeAngles(const Layer *layerbelow) {
  bridge_angles.resize(bridgePolygons.size());
  Clipping clipp;
  vector<Poly> polysbelow = layerbelow->polygons;//clipp.getOffset(polygons,3*thickness);
  for (uint i=0; i<bridgePolygons.size(); i++) 
    {
      // intersect bridge poly with polygons below (=pillars of bridge)
      clipp.clear();
      clipp.addPolys(polysbelow,subject); 
      clipp.addPolys(clipp.getOffset(bridgePolygons[i],2*thickness),clip); 
      vector<Poly> pillars = clipp.intersect();
      // get average direction of the connection lines of all the intersections
      Vector2d dir(0,0);
      for (uint p=0; p<pillars.size(); p++){
	for (uint q=p+1; q<pillars.size(); q++){
	  dir+=pillars[q].center-pillars[p].center;
	}
      }
      //cerr << pillars.size() << " - " << dir << endl;
      bridge_angles[i] = atan2(dir.y,dir.x);
    }
}
Exemplo n.º 6
0
// these are used for the bridge polys of the layer above 
vector <double> Layer::getBridgeRotations(const vector<Poly> polys) const{
  vector<double> angles; angles.resize(polys.size());
  Clipping clipp;
  vector<Poly> offset = polygons;//clipp.getOffset(polygons,3*thickness);
  for (uint i=0; i<polys.size(); i++) 
    {
      // intersect bridge poly with polygons below (=pillars of bridge)
      clipp.clear();
      clipp.addPolys(offset,subject); 
      clipp.addPolys(clipp.getOffset(polys[i],2*thickness),clip); 
      vector<Poly> pillars = clipp.intersect();
      // get average direction of the connection lines of all the intersections
      Vector2d dir(0,0);
      for (uint p=0; p<pillars.size(); p++){
	for (uint q=p+1; q<pillars.size(); q++){
	  dir+=pillars[q].center-pillars[p].center;
	}
      }
      //cerr << pillars.size() << " - " << dir << endl;
      angles[i] = atan2(dir.y,dir.x);
    }
  return angles;
}