Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZipImageFileProcessor #272

Merged
merged 3 commits into from
Oct 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.area515.resinprinter.job;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
Expand All @@ -16,7 +13,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.locks.ReentrantLock;

import javax.imageio.ImageIO;
import javax.script.ScriptEngine;
import javax.script.ScriptException;

Expand All @@ -39,7 +35,6 @@
import org.area515.resinprinter.slice.StlError;
import org.area515.util.Log4jTimer;
import org.area515.util.TemplateEngine;
import org.fourthline.cling.support.avtransport.callback.GetTransportInfo;

public abstract class AbstractPrintFileProcessor<G,E> implements PrintFileProcessor<G,E>{
private static final Logger logger = LogManager.getLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.area515.resinprinter.server.HostProperties;
import org.area515.resinprinter.server.Main;

import org.area515.resinprinter.services.CustomizerService;

public class PrintJobManager {
private static final Logger logger = LogManager.getLogger();
private static PrintJobManager INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.TreeMap;
import java.util.concurrent.Future;

import javax.script.ScriptException;

import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -45,35 +43,41 @@ public boolean acceptsFile(File processingFile) {
public JobStatus processFile(PrintJob printJob) throws Exception {
try {
DataAid dataAid = initializeJobCacheWithDataAid(printJob);

SortedMap<String, File> imageFiles = findImages(printJob.getJobFile());

printJob.setTotalSlices(imageFiles.size());

performHeader(dataAid);

Iterator<File> imgIter = imageFiles.values().iterator();

// Preload first image then loop
// Iterate the image stack up to the slice index requested by the customizer
if (imgIter.hasNext()) {
File imageFile = null;
int sliceIndex = dataAid.customizer.getNextSlice();
while (imgIter.hasNext() && sliceIndex > 0) {
sliceIndex--;
imgIter.next();
}

}

// Preload first image then loop
if (imgIter.hasNext()) {
File imageFile = imgIter.next();

Future<RenderedData> prepareImage = Main.GLOBAL_EXECUTOR.submit(new SimpleImageRenderer(dataAid, this, imageFile));
boolean slicePending = true;

do {

JobStatus status = performPreSlice(dataAid, null);
if (status != null) {
return status;
}

RenderedData imageData = prepareImage.get();
dataAid.cache.setCurrentRenderingPointer(imageFile);

if (imgIter.hasNext()) {
imageFile = imgIter.next();
prepareImage = Main.GLOBAL_EXECUTOR.submit(new SimpleImageRenderer(dataAid, this, imageFile));
Expand All @@ -88,12 +92,23 @@ public JobStatus processFile(PrintJob printJob) throws Exception {
}
} while (slicePending);
}

return performFooter(dataAid);
} finally {
clearDataAid(printJob);
}
}

@Override
public Double getBuildAreaMM(PrintJob processingFile) {
DataAid aid = super.getDataAid(processingFile);

if (aid.cache.getCurrentArea() == null) {
return null;
}

return aid.cache.getCurrentArea() / (aid.xPixelsPerMM * aid.yPixelsPerMM);
}

@Override
public BufferedImage renderPreviewImage(DataAid dataAid) throws SliceHandlingException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.area515.resinprinter.job.render;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.awt.image.WritableRaster;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.locks.Lock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public Object getCurrentRenderingPointer() {
}

public void setCurrentRenderingPointer(Object pointer) {
currentImagePointer = (Boolean)pointer;
currentImagePointer = pointer;
}
}