Commit e71cfc26 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '202-move-project-related-logic-into-the-project-module' into 'master'

Resolve "Move project-related logic into the Project module"

Closes #202

See merge request grp-fidentis/analyst2!218
parents 3f5ff965 a10d47f3
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -104,11 +104,6 @@
            <artifactId>HumanFace</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>Project</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>MeshModel</artifactId>
+4 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import cz.fidentis.analyst.core.ProgressDialog;
import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.face.HumanFaceFactory;
import cz.fidentis.analyst.distance.HausdorffDistance;
import java.nio.file.Path;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -53,7 +53,7 @@ public class ApproxHausdorffDistTask extends SimilarityTask {
    @Override
    protected Void doInBackground() throws Exception {
        HumanFaceFactory factory = getControlPanel().getHumanFaceFactory();
        List<Path> faces = getControlPanel().getFacePaths();
        List<File> faces = getControlPanel().getFacePaths();
        
        totalTime.start();
        
@@ -64,7 +64,7 @@ public class ApproxHausdorffDistTask extends SimilarityTask {
        //   - It is never dumped from memory to disk because we use MRU
        //   - Even if dumped, the face keeps in the mempry until we hold the pointer to it
        loadTime.start();
        String templateFaceId = factory.loadFace(faces.get(templateFaceIndex).toFile());
        String templateFaceId = factory.loadFace(faces.get(templateFaceIndex));
        HumanFace templateFace = factory.getFace(templateFaceId);
        loadTime.stop();
        
@@ -82,7 +82,7 @@ public class ApproxHausdorffDistTask extends SimilarityTask {
            if (i != templateFaceIndex) {
                
                loadTime.start();
                String faceId = factory.loadFace(faces.get(i).toFile());
                String faceId = factory.loadFace(faces.get(i));
                HumanFace face = factory.getFace(faceId);
                loadTime.stop();
                
+7 −8
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import cz.fidentis.analyst.events.HumanFaceListener;
import cz.fidentis.analyst.core.ProgressDialog;
import cz.fidentis.analyst.project.ProjectTopComp;
import cz.fidentis.analyst.drawables.DrawableFace;
import cz.fidentis.analyst.face.TaskFacesProxy;
import cz.fidentis.analyst.rendering.RenderingMode;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
@@ -16,8 +17,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.SwingWorker;
@@ -40,12 +39,12 @@ public class BatchAction extends ControlPanelAction implements HumanFaceListener
     * Constructor.
     *
     * @param canvas OpenGL canvas
     * @param faces Paths to faces
     * @param faces Faces processed by current analytical task
     * @param topControlPanel Top component for placing control panels
     */
    public BatchAction(Canvas canvas, JTabbedPane topControlPanel, List<Path> faces) {
        super(canvas, topControlPanel);
        this.controlPanel = new BatchPanel(this, faces);
    public BatchAction(Canvas canvas, TaskFacesProxy faces, JTabbedPane topControlPanel) {
        super(canvas, faces, topControlPanel);
        this.controlPanel = new BatchPanel(this, faces.getFaceFiles());
        
        // Place control panel to the topControlPanel
        topControlPanel.addTab(controlPanel.getName(), controlPanel.getIcon(), controlPanel);
@@ -198,8 +197,8 @@ public class BatchAction extends ControlPanelAction implements HumanFaceListener
                        if (distances[i][j] != distances[j][i]) {
                            Logger.print("SIMILARITY ERROR for face " + i + " and " + j);
                        }
                        w.write(getShortName(controlPanel.getFacePaths().get(i).toFile()) + ";");
                        w.write(getShortName(controlPanel.getFacePaths().get(j).toFile()) + ";");
                        w.write(getShortName(controlPanel.getFacePaths().get(i)) + ";");
                        w.write(getShortName(controlPanel.getFacePaths().get(j)) + ";");
                        w.write(String.format("%.8f", distances[i][j]) + ";");
                        w.write(String.format("%.8f", distances[j][i]) + ";");
                        if (distances[i][j] > distances[j][i]) {
+8 −9
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -22,6 +21,7 @@ import org.openide.filesystems.FileChooserBuilder;

/**
 * A control panel for bath (N:N) processing.
 * It uses it's own {@code HumanFaceFactory} to handle processed faces.
 *
 * @author Radek Oslejsek
 */
@@ -41,7 +41,7 @@ public class BatchPanel extends ControlPanel {
    public static final String ICON = "registration28x28.png";
    public static final String NAME = "Batch Processing";

    private final List<Path> paths = new ArrayList<>();
    private final List<File> paths = new ArrayList<>();
    private final HumanFaceFactory factory = new HumanFaceFactory();
    private boolean haveAvgFace = false;

@@ -51,7 +51,7 @@ public class BatchPanel extends ControlPanel {
     * @param faces Paths to faces
     * @throws IllegalArgumentException if the {@code faces} argument is empty or missing
     */
    public BatchPanel(ActionListener action, List<Path> faces) {
    public BatchPanel(ActionListener action, List<File> faces) {
        this.setName(NAME);

        initComponents();
@@ -125,8 +125,7 @@ public class BatchPanel extends ControlPanel {
            return null;
        }

        //Logger.print("AAA " + paths.get(jComboBox1.getSelectedIndex()).toString());
        String id = factory.loadFace(paths.get(jComboBox1.getSelectedIndex()).toFile());
        String id = factory.loadFace(paths.get(jComboBox1.getSelectedIndex()));
        return factory.getFace(id);
    }

@@ -157,10 +156,10 @@ public class BatchPanel extends ControlPanel {

        // the logic:
        if (face != null && haveAvgFace) {
            paths.set(0, new File(face.getPath()).toPath()); // replace path
            paths.set(0, new File(face.getPath())); // replace path
            // do nothing with the combobox
        } else if (face != null && !haveAvgFace) {
            paths.add(0, new File(face.getPath()).toPath());
            paths.add(0, new File(face.getPath()));
            items.add(0, "Average face");
        } else if (face == null && haveAvgFace) {
        } else {
@@ -179,7 +178,7 @@ public class BatchPanel extends ControlPanel {
     * Returns paths to faces to be processed
     * @return paths to faces to be processed
     */
    public List<Path> getFacePaths() {
    public List<File> getFacePaths() {
        return Collections.unmodifiableList(paths);
    }

@@ -302,7 +301,7 @@ public class BatchPanel extends ControlPanel {

        if (file != null) {
            try {
                String id = factory.loadFace(paths.get(0).toFile()); // first face is average
                String id = factory.loadFace(paths.get(0)); // first face is average
                new MeshObjExporter(factory.getFace(id).getMeshModel()).exportModelToObj(file);
            } catch (IOException ex) {
                Logger.print(ex.toString());
+4 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import cz.fidentis.analyst.core.ProgressDialog;
import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.face.HumanFaceFactory;
import cz.fidentis.analyst.distance.HausdorffDistance;
import java.nio.file.Path;
import java.io.File;
import java.util.List;

/**
@@ -34,7 +34,7 @@ public class CompleteHausdorffDistTask extends SimilarityTask {
    @Override
    protected Void doInBackground() throws Exception {
        HumanFaceFactory factory = getControlPanel().getHumanFaceFactory();
        List<Path> faces = getControlPanel().getFacePaths();
        List<File> faces = getControlPanel().getFacePaths();

        factory.setReuseDumpFile(true); // it's safe because no changes are made to models 
        factory.setStrategy(HumanFaceFactory.Strategy.MRU);
@@ -43,7 +43,7 @@ public class CompleteHausdorffDistTask extends SimilarityTask {
        
        int counter = 0;
        for (int i = 0; i < faces.size(); i++) {
            String priFaceId = factory.loadFace(faces.get(i).toFile());
            String priFaceId = factory.loadFace(faces.get(i));
            
            for (int j = i; j < faces.size(); j++) { // starts with "i"!
                
@@ -54,7 +54,7 @@ public class CompleteHausdorffDistTask extends SimilarityTask {
                // (Re-)load the primary face (it could be dumped in the meantime) and load the second face
                loadTime.start();
                HumanFace priFace = factory.getFace(priFaceId); 
                String secFaceId = factory.loadFace(faces.get(j).toFile());
                String secFaceId = factory.loadFace(faces.get(j));
                HumanFace secFace = factory.getFace(secFaceId);
                loadTime.stop();
                
Loading