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; } }
void Model::MakeSupportPolygons(Layer * layer, // lower -> will change const Layer * layerabove, // upper double widen) { const double distance = settings.GetExtrudedMaterialWidth(layer->thickness); // vector<Poly> tosupport = Clipping::getOffset(layerabove->GetToSupportPolygons(), // distance/2.); //vector<Poly> tosupport = Clipping::getMerged(layerabove->GetToSupportPolygons(), // distance); vector<Poly> tosupport = layerabove->GetToSupportPolygons(); Clipping clipp; clipp.addPolys(layerabove->GetSupportPolygons(), subject); clipp.addPolys(tosupport, subject); clipp.addPolys(layer->GetPolygons(), clip); clipp.setZ(layer->getZ()); vector<Poly> spolys = clipp.subtract(CL::pftNonZero,CL::pftEvenOdd); if (widen != 0) // widen from layer to layer spolys = clipp.getOffset(spolys, widen * layer->thickness); spolys = clipp.getMerged(spolys,distance); layer->setSupportPolygons(spolys); }
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); } }
// 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; }