Commit 83ec7a7c authored by Jakub Kolman's avatar Jakub Kolman
Browse files

Merge branch 'master' into issue-38/procrustes-superimposition

parents 7428bd66 a216b006
Loading
Loading
Loading
Loading
+3 −32
Original line number Diff line number Diff line
package cz.fidentis.analyst;

import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.mesh.events.MeshEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * This class encapsulates data for a "comparison project", i.e., a project 
 * enabling analysts to compare and investigate human faces.
@@ -16,37 +18,6 @@ public class Project {
    //private HumanFace primaryFace;
    private List<HumanFace> faces = new ArrayList<>();
    
    
    /**
     * Returns primary face
     * 
     * @return HumanFace primary face 
     
    public HumanFace getPrimaryFace() {
        return primaryFace;
    }

    /**
     * Sets new primary face
     * 
     * @param primaryFace which will be new primary face
     * @throws IllegalArgumentException when argument primaryFace is null
     
    public void setPrimaryFace(HumanFace primaryFace) {
        if (primaryFace == null) {
            throw new IllegalArgumentException("Primary face is null");
        }
        this.primaryFace = primaryFace;
    }
    
    /**
     * Removes primary face and sets primaryFace attribute to null
     
    public void removePrimaryFace() {
        this.primaryFace = null;
    }*/


    /**
     * Returns list of HumanFace secondary faces
     * 
+14 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Observable;
//import org.nustaq.serialization.FSTConfiguration;
//import org.nustaq.serialization.FSTObjectInput;
//import org.nustaq.serialization.FSTObjectOutput;
@@ -50,7 +51,7 @@ import java.util.Objects;
 * 
 * @author Radek Oslejsek
 */
public class HumanFace implements MeshListener, Serializable {
public class HumanFace extends Observable implements MeshListener, Serializable {
    
    private MeshModel meshModel;
    
@@ -116,6 +117,8 @@ public class HumanFace implements MeshListener, Serializable {
     */
    public void registerListener(MeshListener listener) {
        eventBus.register(listener);
        setChanged();
        notifyObservers(this);
    }
    
    /**
@@ -125,6 +128,8 @@ public class HumanFace implements MeshListener, Serializable {
     */
    public void unregisterListener(MeshListener listener) {
        eventBus.unregister(listener);
        setChanged();
        notifyObservers(this);        
    }

    /**
@@ -182,6 +187,8 @@ public class HumanFace implements MeshListener, Serializable {
     */
    public void setFeaturePoints(List<FeaturePoint> points) {
        featurePoints = points;
        setChanged();
        notifyObservers(this);
    }
    
    /**
@@ -193,6 +200,8 @@ public class HumanFace implements MeshListener, Serializable {
     */
    public void loadFeaturePoints(String path, String fileName) throws IOException {
        featurePoints = FeaturePointImportService.importFeaturePoints(path, fileName);
        setChanged();
        notifyObservers(this);
    }
    
    /**
@@ -253,6 +262,8 @@ public class HumanFace implements MeshListener, Serializable {
    public KdTree computeKdTree(boolean recompute) {
        if (kdTree == null || recompute) {
            kdTree = new KdTree(new ArrayList<>(meshModel.getFacets()));
            setChanged();
            notifyObservers(this);
        }
        return kdTree;
    }
@@ -264,6 +275,8 @@ public class HumanFace implements MeshListener, Serializable {
    public KdTree removeKdTree() {
        KdTree ret = this.kdTree;
        this.kdTree = null;
        setChanged();
        notifyObservers(this);
        return ret;
    }

+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ public class RandomStrategy extends UndersamplingStrategy {
    /**
     * Constructor for PERCENTAGE undersampling type.
     * 
     * @param perc Percentage - a value in (0.0, 1.0&gtl
     * @param perc Percentage - a value in (0.0, 1.0&gt;
     * @throws IllegalArgumentException if the input parameter is wrong
     */
    public RandomStrategy(double perc) {
+59 −0
Original line number Diff line number Diff line
package cz.fidentis.analyst.visitors.mesh;

import cz.fidentis.analyst.mesh.MeshVisitor;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.mesh.core.MeshTriangle;

import javax.vecmath.Point3d;
import java.util.ArrayList;
import java.util.List;

/**
 * A visitor that calculates the cross-section of a face and a cutting plane.
 * <p>
 * This visitor is thread-safe.
 * </p>
 *
 * @author Dominik Racek
 */
public class CrossSection extends MeshVisitor {
    private List<Point3d> points;
    private MeshFacet plane;

    /**
     *  Constructor
     * @param plane the cutting plane
     */
    public CrossSection(MeshFacet plane) {
        this.plane = plane;
        this.points = new ArrayList<>();
    }

    @Override
    public void visitMeshFacet(MeshFacet facet) {
        //TODO Dont check every triangle, find first and then check it's neighbors and new neighbors and so on
        synchronized (this) {
            Point3d last = null;
            for (MeshTriangle tri : facet) {
                if (tri.checkIntersectionWithPlane(plane)) {
                    Point3d p = tri.getVertex1();

                    // Check for duplicates
                    if (last != null) {
                        if (last == p) {
                            continue;
                        }
                    }

                    points.add(p);
                    last = p;
                }
            }
        }

    }

    public List<Point3d> getPoints() {
        return points;
    }
}
+18 −0
Original line number Diff line number Diff line
package cz.fidentis.analyst.core;

import cz.fidentis.analyst.symmetry.PolylinePanel;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
@@ -729,4 +731,20 @@ public class ControlPanelBuilder {
        
        return scrollPane;
    }

    /**
     * Adds a polyline panel with profile curves
     *
     * @param panel Panel to be added
     */
    public void addPolylinePanel(PolylinePanel panel) {
        GridBagConstraints c = new GridBagConstraints();
        c.gridwidth = GridBagConstraints.RELATIVE;
        c.gridy = row;
        c.gridx = col;
        c.insets = new Insets(10, 10, 0, 0);

        controlPanel.add(panel, c);
    }

}
Loading