Example #1
0
void Layer::CalcInfill (int normalfilltype, int fullfilltype,
			int supportfilltype, int decorfilltype,
			double InfillDistance, 	double FullInfillDistance,
			double InfillRotation, 	double InfillRotationPrLayer,
			double DecorInfillDistance, double DecorInfillRotation, 
			bool ShellOnly, // only infill for fullfill (vertical shells)
			bool DisplayDebuginFill)
{
  // relative extrusion for skins:
  double skinfillextrf = 1./skins/skins; 

  //cerr <<"infill "<< normalfilltype << " - " <<fullfilltype<< endl;
  normalInfill = new Infill(this,1.);
  normalInfill->setName("normal");
  //cout << "new "; normalInfill->printinfo();
  fullInfill = new Infill(this,1.);
  fullInfill->setName("full");
  bridgeInfill = new Infill(this,1.);
  bridgeInfill->setName("bridge");
  //cout << "new " ;fullInfill->printinfo();
  skinFullInfills.clear();
  supportInfill = new Infill(this,0.5); // thinner walls for support
  supportInfill->setName("support");
  decorInfill = new Infill(this,1.);
  decorInfill->setName("decor");

  double rot = (InfillRotation + (double)LayerNo*InfillRotationPrLayer)/180.0*M_PI;
  //cerr << fillPolygons.size();
  if (!ShellOnly)
    normalInfill->addInfill(Z, fillPolygons, (InfillType)normalfilltype, 
			    InfillDistance, FullInfillDistance, rot);
  
  fullInfill->addInfill(Z, fullFillPolygons, (InfillType)fullfilltype,
			FullInfillDistance, FullInfillDistance, rot);

  decorInfill->addInfill(Z, decorPolygons, (InfillType)decorfilltype,
			 DecorInfillDistance, DecorInfillDistance,
			 DecorInfillRotation/180.0*M_PI);
  
  //  cerr << LayerNo << ": "<<bridgePolygons.size() << " = " << bridge_angles.size() << endl;
  
  assert(bridge_angles.size() == bridgePolygons.size());
  for (uint b=0; b<bridgePolygons.size(); b++){
    bridgeInfill->addInfill(Z, bridgePolygons[b], BridgeInfill,
			    FullInfillDistance, FullInfillDistance, bridge_angles[b]+M_PI/2);
  }
  if (skins>1) {
    double skindistance = FullInfillDistance/skins;
    for (uint s = 0; s<skins; s++){
      double drot = rot + InfillRotationPrLayer/180.0*M_PI*s;
      double sz = Z-thickness + (s+1)*thickness/skins;
      //cerr << Z << " : " << skins << " - "<< s << " - " << sz << " - " << thickness <<endl;
      Infill *inf = new Infill(this, skinfillextrf);
      inf->setName("skin");
      inf->addInfill(sz, skinFullFillPolygons, (InfillType)fullfilltype,
		     skindistance, skindistance, drot);
      skinFullInfills.push_back(inf);
    }
  }
  supportInfill->addInfill(Z, supportPolygons, (InfillType)supportfilltype, 
			   1.*InfillDistance, 1.*InfillDistance, 0);
}
Example #2
0
void Layer::CalcInfill (const Settings &settings)
{
  // inFill distances in real mm:
  // for full polys/layers:
  double fullInfillDistance=0;
  double infillDistance=0; // normal fill
  double altInfillDistance=0;
  double altInfillPercent=settings.get_double("Slicing","InfillPercent");
  double normalInfilldist=0;
  bool shellOnly = !settings.get_boolean("Slicing","DoInfill");
  fullInfillDistance = settings.GetInfillDistance(thickness, 100);

  if (settings.get_double("Slicing","InfillPercent") == 0)
    shellOnly = true;
  else
    infillDistance = settings.GetInfillDistance(thickness,altInfillPercent);
  int altinfill = settings.get_integer("Slicing","AltInfillLayers");
  normalInfilldist = infillDistance;
  if ( altinfill != 0  && LayerNo % altinfill == 0 && altInfillPercent != 0) {
    altInfillDistance = settings.GetInfillDistance(thickness,
						   settings.get_double("Slicing","AltInfillPercent"));
    normalInfilldist = altInfillDistance;
  }
  // first layers:
  if (LayerNo < (int)settings.get_integer("Slicing","FirstLayersNum")) {
    double first_infdist =
      fullInfillDistance * (1.+settings.get_double("Slicing","FirstLayersInfillDist"));
    normalInfilldist   = max(normalInfilldist,   first_infdist);
    fullInfillDistance = max(fullInfillDistance, first_infdist);
  }
  // relative extrusion for skins:
  double skinfillextrf = settings.get_double("Slicing","FullFillExtrusion")/skins/skins;
  normalInfill = new Infill(this,settings.get_double("Slicing","NormalFillExtrusion"));
  normalInfill->setName("normal");
  fullInfill = new Infill(this,settings.get_double("Slicing","FullFillExtrusion"));
  fullInfill->setName("full");
  skirtInfill = new Infill(this,settings.get_double("Slicing","FullFillExtrusion"));
  skirtInfill->setName("skirt");
  skinFullInfills.clear();
  supportInfill = new Infill(this,settings.get_double("Slicing","SupportExtrusion"));
  supportInfill->setName("support");
  decorInfill = new Infill(this,1.);
  decorInfill->setName("decor");
  thinInfill = new Infill(this, 1.);
  thinInfill->setName("thin");

  double rot = (settings.get_double("Slicing","InfillRotation"),
		+ (double)LayerNo*settings.get_double("Slicing","InfillRotationPrLayer"))/180.0*M_PI;
  if (!shellOnly)
    normalInfill->addPolys(Z, fillPolygons, (InfillType)settings.get_integer("Slicing","NormalFilltype"),
			   normalInfilldist, fullInfillDistance, rot);

  if (settings.get_boolean("Slicing","FillSkirt")) {
    vector<Poly> skirtFill;
    Clipping clipp;
    clipp.addPolys(skirtPolygons, subject);
    clipp.addPolys(*GetOuterShell(), clip);
    clipp.addPolys(supportPolygons, clip);
    skirtFill = clipp.subtract();
    skirtFill = Clipping::getOffset(skirtFill, -fullInfillDistance);
    skirtInfill->addPolys(Z, skirtFill, (InfillType)settings.get_integer("Slicing","FullFilltype"),
			  fullInfillDistance, fullInfillDistance, rot);
  }

  fullInfill->addPolys(Z, fullFillPolygons, (InfillType)settings.get_integer("Slicing","FullFilltype"),
		       fullInfillDistance, fullInfillDistance, rot);

  decorInfill->addPolys(Z, decorPolygons, (InfillType)settings.get_integer("Slicing","DecorFilltype"),
			settings.get_double("Slicing","DecorInfillDistance"),
			settings.get_double("Slicing","DecorInfillDistance"),
			settings.get_double("Slicing","DecorInfillRotation")/180.0*M_PI);

  assert(bridge_angles.size() >= bridgePolygons.size());
  bridgeInfills.resize(bridgePolygons.size());
  for (uint b=0; b < bridgePolygons.size(); b++){
    bridgeInfills[b] = new Infill(this, settings.get_double("Slicing","BridgeExtrusion"));
    bridgeInfills[b]->addPoly(Z, bridgePolygons[b], BridgeInfill,
			      fullInfillDistance, fullInfillDistance,
			      bridge_angles[b]+M_PI/2);
  }

  if (skins>1) {
    double skindistance = fullInfillDistance/skins;
    for (uint s = 0; s<skins; s++){
      double drot = rot + settings.get_double("Slicing","InfillRotationPrLayer")/180.0*M_PI*s;
      double sz = Z-thickness + (s+1)*thickness/skins;
      Infill *inf = new Infill(this, skinfillextrf);
      inf->setName("skin");
      inf->addPolys(sz, skinFullFillPolygons, (InfillType)settings.get_integer("Slicing","FullFilltype"),
		    skindistance, skindistance, drot);
      skinFullInfills.push_back(inf);
    }
  }
  supportInfill->addPolys(Z, supportPolygons,
			  (InfillType)settings.get_integer("Slicing","SupportFilltype"),
			  settings.get_double("Slicing","SupportInfillDistance"),
			  settings.get_double("Slicing","SupportInfillDistance"), 0);

  thinInfill->addPolys(Z, thinPolygons, ThinInfill,
		       fullInfillDistance, fullInfillDistance, 0);
}