-
-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix problem with extra line segments on multipoint intersections (#2640)
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...c/test/java/com/willwinder/ugs/nbp/designer/io/gcode/toolpaths/LaserFillToolPathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.willwinder.ugs.nbp.designer.io.gcode.toolpaths; | ||
|
||
import com.willwinder.ugs.nbp.designer.entities.cuttable.Path; | ||
import com.willwinder.ugs.nbp.designer.io.gcode.path.GcodePath; | ||
import com.willwinder.ugs.nbp.designer.io.gcode.path.Segment; | ||
import com.willwinder.ugs.nbp.designer.io.gcode.path.SegmentType; | ||
import com.willwinder.ugs.nbp.designer.model.Settings; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static com.willwinder.ugs.nbp.designer.io.gcode.path.SegmentType.LINE; | ||
import static com.willwinder.ugs.nbp.designer.io.gcode.path.SegmentType.MOVE; | ||
import static com.willwinder.ugs.nbp.designer.io.gcode.path.SegmentType.SEAM; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class LaserFillToolPathTest { | ||
|
||
@Test | ||
public void fillToolPathShouldNotConnectThePointEdgesWithALineSegment() { | ||
Path path = new Path(); | ||
path.setPasses(1); | ||
path.moveTo(0,0); | ||
path.lineTo(0, 1); | ||
path.lineTo(1, 1); | ||
path.lineTo(1, 0); | ||
path.lineTo(0.5, 0.5); | ||
path.lineTo(0,0); | ||
path.close(); | ||
|
||
Settings settings = new Settings(); | ||
settings.setMaxSpindleSpeed(10000); | ||
|
||
LaserFillToolPath toolPath = new LaserFillToolPath(settings, path); | ||
toolPath.setStartDepth(0); | ||
toolPath.setTargetDepth(0); | ||
|
||
GcodePath gcodePath = toolPath.toGcodePath(); | ||
List<Segment> segments = gcodePath.getSegments(); | ||
assertEquals(SEAM, segments.get(0).type); | ||
assertSegment(segments.get(1), MOVE, 1, 0.2); | ||
assertSegment(segments.get(2), LINE, 0.8, 0.2); | ||
assertSegment(segments.get(3), MOVE, 0.2, 0.2); | ||
assertSegment(segments.get(4), LINE, 0.0, 0.2); | ||
} | ||
|
||
private void assertSegment(Segment segment, SegmentType segmentType, double x, double y) { | ||
assertEquals(segmentType, segment.getType()); | ||
assertEquals(x, segment.getPoint().getX(), 0.01); | ||
assertEquals(y, segment.getPoint().getY(), 0.01); | ||
} | ||
} |