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;
}
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;
}
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;
}
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);
}
Aggregations