Search in sources :

Example 1 with GcodePath

use of com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath in project Universal-G-Code-Sender by winder.

the class AbstractToolPath method toGcodePath.

protected GcodePath toGcodePath(List<List<PartialPosition>> coordinateList) {
    GcodePath gcodePath = new GcodePath();
    if (!coordinateList.isEmpty()) {
        coordinateList.forEach(cl -> {
            if (!cl.isEmpty()) {
                addSafeHeightSegmentTo(gcodePath, cl.get(0));
                gcodePath.addSegment(SegmentType.POINT, cl.get(0));
                cl.forEach(c -> gcodePath.addSegment(SegmentType.LINE, c));
            }
        });
        addSafeHeightSegment(gcodePath);
    }
    return gcodePath;
}
Also used : GcodePath(com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath)

Example 2 with GcodePath

use of com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath in project Universal-G-Code-Sender by winder.

the class DrillCenterToolPath method toGcodePath.

@Override
public GcodePath toGcodePath() {
    Point2D center = source.getCenter();
    PartialPosition centerPosition = PartialPosition.builder().setX(center.getX()).setY(center.getY()).setUnits(UnitUtils.Units.MM).build();
    GcodePath gcodePath = new GcodePath();
    addSafeHeightSegmentTo(gcodePath, centerPosition);
    double currentDepth = getStartDepth() - getDepthPerPass();
    while (currentDepth < getTargetDepth()) {
        currentDepth += getDepthPerPass();
        if (currentDepth > getTargetDepth()) {
            currentDepth = getTargetDepth();
        }
        final double depth = -currentDepth;
        gcodePath.addSegment(SegmentType.POINT, PartialPosition.builder().copy(centerPosition).setZ(depth).build());
        gcodePath.addSegment(SegmentType.POINT, PartialPosition.builder().copy(centerPosition).setZ(0d).build());
    }
    addSafeHeightSegment(gcodePath);
    return gcodePath;
}
Also used : Point2D(java.awt.geom.Point2D) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodePath(com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath)

Example 3 with GcodePath

use of com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath in project Universal-G-Code-Sender by winder.

the class SimpleGcodeRouter method getGcodePathFromCuttables.

private GcodePath getGcodePathFromCuttables(List<Cuttable> cuttables) {
    GcodePath gcodePath = new GcodePath();
    int index = 0;
    for (Cuttable cuttable : cuttables) {
        index++;
        gcodePath.addSegment(new Segment(" " + cuttable.getName() + " - " + cuttable.getCutType().getName() + " (" + index + "/" + cuttables.size() + ")"));
        switch(cuttable.getCutType()) {
            case POCKET:
                PocketToolPath simplePocket = new PocketToolPath(cuttable);
                simplePocket.setStartDepth(cuttable.getStartDepth());
                simplePocket.setTargetDepth(cuttable.getTargetDepth());
                simplePocket.setToolDiameter(toolDiameter);
                simplePocket.setDepthPerPass(depthPerPass);
                simplePocket.setSafeHeight(safeHeight);
                simplePocket.setStepOver(toolStepOver);
                gcodePath.appendGcodePath(simplePocket.toGcodePath());
                break;
            case OUTSIDE_PATH:
                OutlineToolPath simpleOutsidePath = new OutlineToolPath(cuttable);
                simpleOutsidePath.setOffset(toolDiameter / 2d);
                simpleOutsidePath.setStartDepth(cuttable.getStartDepth());
                simpleOutsidePath.setTargetDepth(cuttable.getTargetDepth());
                simpleOutsidePath.setToolDiameter(toolDiameter);
                simpleOutsidePath.setDepthPerPass(depthPerPass);
                simpleOutsidePath.setSafeHeight(safeHeight);
                gcodePath.appendGcodePath(simpleOutsidePath.toGcodePath());
                break;
            case INSIDE_PATH:
                OutlineToolPath simpleInsidePath = new OutlineToolPath(cuttable);
                simpleInsidePath.setOffset(-toolDiameter / 2d);
                simpleInsidePath.setStartDepth(cuttable.getStartDepth());
                simpleInsidePath.setTargetDepth(cuttable.getTargetDepth());
                simpleInsidePath.setToolDiameter(toolDiameter);
                simpleInsidePath.setDepthPerPass(depthPerPass);
                simpleInsidePath.setSafeHeight(safeHeight);
                gcodePath.appendGcodePath(simpleInsidePath.toGcodePath());
                break;
            case ON_PATH:
                OutlineToolPath simpleOnPath = new OutlineToolPath(cuttable);
                simpleOnPath.setStartDepth(cuttable.getStartDepth());
                simpleOnPath.setTargetDepth(cuttable.getTargetDepth());
                simpleOnPath.setToolDiameter(toolDiameter);
                simpleOnPath.setDepthPerPass(depthPerPass);
                simpleOnPath.setSafeHeight(safeHeight);
                gcodePath.appendGcodePath(simpleOnPath.toGcodePath());
                break;
            case CENTER_DRILL:
                DrillCenterToolPath drillToolPath = new DrillCenterToolPath(cuttable);
                drillToolPath.setStartDepth(cuttable.getStartDepth());
                drillToolPath.setTargetDepth(cuttable.getTargetDepth());
                drillToolPath.setToolDiameter(toolDiameter);
                drillToolPath.setDepthPerPass(depthPerPass);
                drillToolPath.setSafeHeight(safeHeight);
                gcodePath.appendGcodePath(drillToolPath.toGcodePath());
                break;
            default:
        }
    }
    return gcodePath;
}
Also used : DrillCenterToolPath(com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.DrillCenterToolPath) GcodePath(com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath) Cuttable(com.willwinder.ugs.nbp.designer.entities.cuttable.Cuttable) OutlineToolPath(com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.OutlineToolPath) Segment(com.willwinder.ugs.nbp.designer.io.gcode.path.Segment) PocketToolPath(com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.PocketToolPath)

Example 4 with GcodePath

use of com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath in project Universal-G-Code-Sender by winder.

the class DrillCenterToolPathTest method drillCenterShouldDrillInCenterOfShape.

@Test
public void drillCenterShouldDrillInCenterOfShape() {
    Rectangle rectangle = new Rectangle();
    rectangle.setSize(new Size(15, 15));
    rectangle.setPosition(new Point2D.Double(10, 10));
    DrillCenterToolPath drillCenterToolPath = new DrillCenterToolPath(rectangle);
    drillCenterToolPath.setDepthPerPass(10);
    drillCenterToolPath.setTargetDepth(10);
    GcodePath gcodePath = drillCenterToolPath.toGcodePath();
    assertEquals(8, gcodePath.getSegments().size());
    assertEquals(SegmentType.MOVE, gcodePath.getSegments().get(0).type);
    assertEquals(SegmentType.MOVE, gcodePath.getSegments().get(1).type);
    assertEquals(SegmentType.MOVE, gcodePath.getSegments().get(2).type);
    assertEquals(SegmentType.POINT, gcodePath.getSegments().get(3).type);
    assertEquals(0, gcodePath.getSegments().get(3).point.getZ(), 0.01);
    assertEquals(SegmentType.POINT, gcodePath.getSegments().get(4).type);
    assertEquals(17.5, gcodePath.getSegments().get(4).point.getX(), 0.01);
    assertEquals(17.5, gcodePath.getSegments().get(4).point.getY(), 0.01);
    assertEquals(0, gcodePath.getSegments().get(4).point.getZ(), 0.01);
    assertEquals(SegmentType.POINT, gcodePath.getSegments().get(5).type);
    assertEquals(-10, gcodePath.getSegments().get(5).point.getZ(), 0.01);
    assertEquals(SegmentType.POINT, gcodePath.getSegments().get(6).type);
    assertEquals(0, gcodePath.getSegments().get(6).point.getZ(), 0.01);
    assertEquals(SegmentType.MOVE, gcodePath.getSegments().get(7).type);
}
Also used : Point2D(java.awt.geom.Point2D) GcodePath(com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath) Size(com.willwinder.ugs.nbp.designer.model.Size) Rectangle(com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle) Test(org.junit.Test)

Aggregations

GcodePath (com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath)4 Point2D (java.awt.geom.Point2D)2 Cuttable (com.willwinder.ugs.nbp.designer.entities.cuttable.Cuttable)1 Rectangle (com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle)1 Segment (com.willwinder.ugs.nbp.designer.io.gcode.path.Segment)1 DrillCenterToolPath (com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.DrillCenterToolPath)1 OutlineToolPath (com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.OutlineToolPath)1 PocketToolPath (com.willwinder.ugs.nbp.designer.io.gcode.toolpaths.PocketToolPath)1 Size (com.willwinder.ugs.nbp.designer.model.Size)1 PartialPosition (com.willwinder.universalgcodesender.model.PartialPosition)1 Test (org.junit.Test)1