Skip to content

Commit f8ecee5

Browse files
Better infill (#904)
* Obey margin limits like everyone else * activate hints * 7.78.4 * Update Changelog.md * square distance check is faster. * constants should be named. * cleaning * drop file adds to recent files * better infill * better error logging * 7.78.5
1 parent 6d0f2d8 commit f8ecee5

19 files changed

Lines changed: 145 additions & 136 deletions

File tree

Changelog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## 7.78.5
11+
12+
### Added
13+
- Drag + drop a file now adds that file to the "Recent Files" list.
14+
15+
### Fixed
16+
- Infill of closed loops should now be properly filled. Was occasionally failing the in/out test and creating a mess.
17+
- MickeyMoe1992 now properly obeys the margin limits, same as the other converters.
18+
- Render hints are now forced to enable antialiasing, etc.
19+
20+
## 7.78.3
21+
22+
### Added
23+
- Added Generator "Registration Marks"
24+
- Added "Zoom to fit machine"
25+
26+
### Removed
27+
- Hid the Donatello panel at startup for a less confusing new user experience.
28+
1029
## 7.78.0
1130

1231
### Added

pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.marginallyclever</groupId>
88
<artifactId>Makelangelo</artifactId>
9-
<version>7.78.3</version>
9+
<version>7.78.5</version>
1010
<name>Makelangelo</name>
1111
<description>Makelangelo Software is a Java program that prepares art for CNC plotters. It is especially designed for the Makelangelo Robot.
1212
It pairs really well with Marlin-polargraph, the code in the brain of the robot that receives instructions and moves the motors.</description>
@@ -364,6 +364,11 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
364364
<artifactId>jssc</artifactId>
365365
<version>2.9.5</version>
366366
</dependency>
367+
<dependency>
368+
<groupId>org.scijava</groupId>
369+
<artifactId>native-lib-loader</artifactId>
370+
<version>2.5.0</version>
371+
</dependency>
367372
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
368373
<dependency>
369374
<groupId>org.apache.httpcomponents</groupId>
@@ -386,7 +391,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
386391
<dependency>
387392
<groupId>org.apache.commons</groupId>
388393
<artifactId>commons-compress</artifactId>
389-
<version>1.26.1</version>
394+
<version>1.28.0</version>
390395
</dependency>
391396
<!-- https://mvnrepository.com/artifact/de.sciss/jrpicam -->
392397
<dependency>
@@ -428,7 +433,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
428433
<dependency>
429434
<groupId>commons-validator</groupId>
430435
<artifactId>commons-validator</artifactId>
431-
<version>1.7</version>
436+
<version>1.10.1</version>
432437
</dependency>
433438
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-xml -->
434439
<dependency>
@@ -542,12 +547,12 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
542547
<dependency>
543548
<groupId>ch.qos.logback</groupId>
544549
<artifactId>logback-core</artifactId>
545-
<version>1.5.18</version>
550+
<version>1.5.27</version>
546551
</dependency>
547552
<dependency>
548553
<groupId>ch.qos.logback</groupId>
549554
<artifactId>logback-classic</artifactId>
550-
<version>1.5.18</version>
555+
<version>1.5.27</version>
551556
</dependency>
552557
<!-- donatello -->
553558
<dependency>

src/main/java/com/marginallyclever/convenience/ColorHSB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.awt.*;
44

55
/**
6-
* HSB color class. Each component is 0...1
6+
* {@link ColorHSB} stores a color by its Hue, Saturation, and Brightness. Each component is 0...1
77
*
88
* @author Dan Royer
99
* @since 2022-08-31

src/main/java/com/marginallyclever/convenience/ColorPalette.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ public void addColor(Color c) {
4242
*/
4343
@Deprecated(forRemoval = true)
4444
public void removeColor(Color c) {
45-
for (final Iterator<Color> colorsIterator = colors.iterator(); colorsIterator.hasNext(); ) {
46-
final Color nextColor = colorsIterator.next();
47-
if (nextColor.equals(c)) {
48-
colorsIterator.remove();
49-
}
50-
}
45+
colors.removeIf(nextColor -> nextColor.equals(c));
5146
}
5247

5348

src/main/java/com/marginallyclever/convenience/ColorRGB.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*
1111
* @author Dan Royer
1212
*/
13-
@Deprecated
1413
public class ColorRGB {
1514
public int red;
1615
public int green;

src/main/java/com/marginallyclever/makelangelo/MainFrame.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.marginallyclever.convenience.FileAccess;
1010
import com.marginallyclever.donatello.Donatello;
1111
import com.marginallyclever.donatello.nodefactorypanel.NodeFactoryPanel;
12-
import com.marginallyclever.makelangelo.actions.ZoomToFitMachineAction;
1312
import com.marginallyclever.makelangelo.applicationsettings.MetricsPreferences;
1413
import com.marginallyclever.makelangelo.donatelloimpl.DockableEditNodePanel;
1514
import com.marginallyclever.makelangelo.donatelloimpl.DonatelloDropTarget;
@@ -367,4 +366,8 @@ public PlotterSettingsManager getPlotterSettingsManager() {
367366
public void onPlotterSettingsUpdate(PlotterSettings lastSelectedProfile) {
368367
previewPanel.onPlotterSettingsUpdate(lastSelectedProfile);
369368
}
369+
370+
public RecentFiles getRecentFiles() {
371+
return mainMenuBar.getRecentFiles();
372+
}
370373
}

src/main/java/com/marginallyclever/makelangelo/makeart/imageconverter/Converter_Mickeymoe1992.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import javax.vecmath.Point2d;
1414
import java.awt.*;
15+
import java.awt.geom.Rectangle2D;
1516
import java.util.Arrays;
1617
import java.util.PriorityQueue;
1718

@@ -70,28 +71,31 @@ public void start(Paper paper, TransformedImage image) {
7071
FilterDesaturate bw = new FilterDesaturate(myImage);
7172
img = bw.filter();
7273

74+
double d = Math.max(0.1,turtle.getDiameter());
7375
// use fast marching method to compute arrival times
7476
if(recalculateFFM) {
75-
ffm = computeArrivalTimes();
77+
ffm = computeArrivalTimes(d);
7678
}
7779

80+
Rectangle2D.Double rect = myPaper.getMarginRectangle();
81+
px = rect.getMinX();
82+
py = rect.getMinY();
83+
7884
turtle = new Turtle();
7985
turtle.setStroke(Color.BLACK,settings.getDouble(PlotterSettings.DIAMETER));
80-
px = myPaper.getMarginRectangle().getMinX();
81-
py = myPaper.getMarginRectangle().getMinY();
8286

83-
extractContours(ffm, minSpacing);
87+
extractContours(ffm, minSpacing,d);
8488

89+
//CropTurtle.run(turtle,rect);
8590
fireConversionFinished();
86-
recalculateFFM=true;
8791
}
8892

8993
/**
9094
* Extract iso-contours for the given levels from a scalar field.
9195
* @param T scalar field (arrival times)
9296
* @param spacing spacing between contours
9397
*/
94-
public void extractContours(double[][] T, double spacing) {
98+
public void extractContours(double[][] T, double spacing,double d) {
9599
int h = T[0].length;
96100

97101
// Find min and max values in T
@@ -115,6 +119,7 @@ public void extractContours(double[][] T, double spacing) {
115119
for (double level = min; level <= max; level += step) {
116120
turtle = new Turtle(Color.BLACK,settings.getDouble(PlotterSettings.DIAMETER));
117121
marchingSquares(T,level);
122+
turtle.scale(d,d);
118123
var result = reorderHelper.splitAndReorderTurtle(turtle);
119124
sum.add(result);
120125
}
@@ -274,9 +279,8 @@ public int compareTo(Node o) {
274279
* Computes the arrival times using the Fast Marching Method (FMM).
275280
* @return
276281
*/
277-
public double[][] computeArrivalTimes() {
282+
public double[][] computeArrivalTimes(double d) {
278283
var rect = myPaper.getMarginRectangle();
279-
double d = Math.max(0.1,turtle.getDiameter());
280284
int w = (int)Math.ceil(rect.getWidth()/d);
281285
int h = (int)Math.ceil(rect.getHeight()/d);
282286
int minX = (int)rect.getMinX();

src/main/java/com/marginallyclever/makelangelo/makeart/imagefilter/FilterScale.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public TransformedImage filter() {
3131
for (int y = 0; y < h; ++y) {
3232
for (int x = 0; x < w; ++x) {
3333
ColorRGB diff = new ColorRGB(aa.getRGB(x, y));
34-
diff.red = (int)Math.max(0,Math.min(255,diff.red * scale));
35-
diff.green = (int)Math.max(0,Math.min(255,diff.green * scale));
36-
diff.blue = (int)Math.max(0,Math.min(255,diff.blue * scale));
34+
diff.red = (int) Math.clamp(diff.red * scale, 0, 255);
35+
diff.green = (int) Math.clamp(diff.green * scale, 0, 255);
36+
diff.blue = (int) Math.clamp(diff.blue * scale, 0, 255);
3737
rr.setRGB(x, y, diff.toInt());
3838
}
3939
}

src/main/java/com/marginallyclever/makelangelo/makeart/io/LoadSVG.java

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,7 @@ private void parsePolylineElement(Element pathNodes) {
195195
}
196196

197197
myTurtle.add(t);
198-
if(isFilled(element)) {
199-
var filler = new InfillTurtle();
200-
filler.setPenDiameter(myTurtle.getDiameter());
201-
myTurtle.add(filler.run(t));
202-
}
198+
if(isFilled(element)) fillTurtle(t);
203199
}
204200

205201
/**
@@ -402,11 +398,13 @@ private void parseRectElement(Element element) {
402398
arcTurtle(t, x1,y2, rx,ry, Math.PI * -1.5,Math.PI * -1.0,m);
403399
arcTurtle(t, x1,y1, rx,ry, Math.PI * -1.0,Math.PI * -0.5,m);
404400
myTurtle.add(t);
405-
if(isFilled(element)) {
406-
var filler = new InfillTurtle();
407-
filler.setPenDiameter(myTurtle.getDiameter());
408-
myTurtle.add(filler.run(t));
409-
}
401+
if(isFilled(element)) fillTurtle(t);
402+
}
403+
404+
private void fillTurtle(Turtle t) {
405+
var filler = new InfillTurtle();
406+
filler.setPenDiameter(myTurtle.getDiameter());
407+
myTurtle.add(filler.run(t));
410408
}
411409

412410
/**
@@ -457,11 +455,7 @@ private void parseCircleElement(Element element) {
457455
//logger.debug("circ={}", circ);
458456
printEllipse(t, m, cx, cy, r, r, circ);
459457
myTurtle.add(t);
460-
if(isFilled(element)) {
461-
var filler = new InfillTurtle();
462-
filler.setPenDiameter(myTurtle.getDiameter());
463-
myTurtle.add(filler.run(t));
464-
}
458+
if(isFilled(element)) fillTurtle(t);
465459
}
466460

467461
private void parseEllipseElement(Element element) {
@@ -482,11 +476,7 @@ private void parseEllipseElement(Element element) {
482476
steps = Math.min(60,steps);
483477
printEllipse(t, m, cx, cy, rx, ry, steps);
484478
myTurtle.add(t);
485-
if(isFilled(element)) {
486-
var filler = new InfillTurtle();
487-
filler.setPenDiameter(myTurtle.getDiameter());
488-
myTurtle.add(filler.run(t));
489-
}
479+
if(isFilled(element)) fillTurtle(t);
490480
}
491481

492482
private void printEllipse(Turtle t, Matrix3d m, double cx, double cy, double rx, double ry, double steps) {
@@ -533,11 +523,7 @@ private void parsePathElement(Element paths) throws Exception {
533523
}
534524
}
535525
myTurtle.add(t);
536-
if(isFilled(element)) {
537-
var filler = new InfillTurtle();
538-
filler.setPenDiameter(myTurtle.getDiameter());
539-
myTurtle.add(filler.run(t));
540-
}
526+
if(isFilled(element)) fillTurtle(t);
541527
}
542528

543529
private void doCubicCurveAbs(SVGPathSeg item, Matrix3d m,Turtle t) {

0 commit comments

Comments
 (0)