예제 #1
0
파일: Model.java 프로젝트: Robo3D/GCodeInfo
  Layer startLayer(float z, Layer prevLayer) {
    // if (LayerOpen)
    //	return null;

    // Z-Lift support
    if (prevLayer != null && z == prevLayer.getZPosition()) return prevLayer;

    // Layer lay = layer.get(z);
    Layer lay = null;
    int fanspeed = 0;
    float bedtemp = 0;
    float extemp = 0;
    float lh = z;
    if (prevLayer != null) {
      if (prevLayer.isPrinted()) {
        lh = (z - prevLayer.getZPosition());
      }
      fanspeed = prevLayer.getFanspeed();
      bedtemp = prevLayer.getBedtemp();
      extemp = prevLayer.getExttemp();
    }
    lay = new Layer(z, layercount, Constants.round2digits(lh));
    lay.setUnit(unit); // remember last unit
    lay.setFanspeed(fanspeed);
    lay.setBedtemp(bedtemp);
    lay.setExttemp(extemp);
    // layer.put(z, lay);
    layer.add(lay);
    layercount++;

    // System.out.println("Add Layer:"+z);
    // LayerOpen = true;
    return lay;
  }
예제 #2
0
파일: Model.java 프로젝트: Robo3D/GCodeInfo
  void endLayer(Layer lay) {
    //	time += lay.getTime();
    timeaccel += lay.getTimeAccel();
    distance += lay.getDistance();
    traveldistance += lay.getTraveldistance();

    // Count layers which are visited only
    if (!lay.isPrinted()) {
      notprintedLayers++;
      //	lay.setLayerheight(0); // Layer not printed
    } else {
      // calculate dimensions
      boundaries[0] = Math.max(lay.getBoundaries()[0], boundaries[0]);
      boundaries[1] = Math.min(lay.getBoundaries()[1], boundaries[1]);
      boundaries[2] = Math.max(lay.getBoundaries()[2], boundaries[2]);
      boundaries[3] = Math.min(lay.getBoundaries()[3], boundaries[3]);
      boundaries[4] = Math.max(lay.getBoundaries()[4], boundaries[4]);
      dimension[0] = Constants.round2digits(boundaries[0] - boundaries[1]);
      dimension[1] = Constants.round2digits(boundaries[2] - boundaries[3]);
      dimension[2] = Constants.round2digits(boundaries[4]);

      extrusion = extrusion + lay.getExtrusion();

      avgLayerHeight = avgLayerHeight + lay.getLayerheight(); // first printed layer
      avgbedtemp = avgbedtemp + lay.getBedtemp();
      avgextemp = avgextemp + lay.getExttemp();
      //			System.out.println("Layer:"+lay.getNumber()+"Bedtemp:"+lay.getBedtemp()+"
      // AVG:"+avgbedtemp);
    }

    // Summarize Speed values
    float sp = lay.getSpeed(Speed.SPEED_ALL_AVG);
    if (sp != Float.NaN && sp > 0) {
      // average speed is relative to distance / divide by distance later
      avgspeed += (sp * lay.getDistance());
    }
    // Print/extrude only
    maxprintspeed = Math.max(maxprintspeed, lay.getSpeed(Speed.SPEED_PRINT_MAX));
    if (lay.getSpeed(Speed.SPEED_PRINT_MIN) != 0) {
      minprintspeed = Math.min(minprintspeed, lay.getSpeed(Speed.SPEED_PRINT_MIN));
    }
    sp = lay.getSpeed(Speed.SPEED_TRAVEL_AVG);
    if (sp != Float.NaN && sp > 0) {
      avgtravelspeed += sp * lay.getTraveldistance();
    }

    // Update Speed Analysis for model ... combine layer data
    for (Iterator<Float> iterator = lay.getSpeedAnalysisT().keySet().iterator();
        iterator.hasNext(); ) {
      float speedkey = iterator.next();
      SpeedEntry timespeedlay = lay.getSpeedAnalysisT().get(speedkey);
      SpeedEntry speedsum = SpeedAnalysisT.get(speedkey);
      if (speedsum != null) {
        speedsum.addTime(timespeedlay.getTime());
        speedsum.addDistance(timespeedlay.getDistance());
        speedsum.setPrint(timespeedlay.getType());
        speedsum.addLayers(lay.getNumber());
      } else {
        SpeedEntry sped = new SpeedEntry(speedkey, timespeedlay.getTime(), lay.getNumber());
        sped.addDistance(timespeedlay.getDistance());
        sped.setPrint(timespeedlay.getType());
        SpeedAnalysisT.put(speedkey, sped);
      }
    }
    // Assume that unit is only set once
    unit = lay.getUnit();
    //	LayerOpen = false;
  }