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

Merge branch '302-release-2024-02-00' into 'master'

Resolve "Release 2024.02.00"

Closes #302

See merge request grp-fidentis/analyst2!324
parents 8aebf8a7 4a522c30
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import cz.fidentis.analyst.data.mesh.MeshModel;

import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * This interface provides services that instantiates a human face.
@@ -34,6 +35,19 @@ public interface HumanFaceFactory {
        return create(file, true);
    }

    /**
     * Recover human face from serialized dump file. As the dump file can contain additional
     * objects, e.g., camera, it is supposed that the given input stream is set to a human face object.
     *
     * @param in A dump file as object input stream
     * @return The instance of the human face
     * @throws IOException If reading fails
     * @throws ClassNotFoundException If there is no human face in the stream
     */
    static HumanFace create(ObjectInputStream in) throws IOException, ClassNotFoundException {
        return (HumanFace) in.readObject();
    }

    /**
     * Creates a human face from existing mesh model. The mesh model is stored directly (not copied).
     *
+11 −12
Original line number Diff line number Diff line
@@ -2,10 +2,13 @@ package cz.fidentis.analyst.data.face.impl;

import com.google.common.eventbus.EventBus;
import cz.fidentis.analyst.Logger;
import cz.fidentis.analyst.data.face.HumanFace;
import cz.fidentis.analyst.data.face.HumanFaceEvent;
import cz.fidentis.analyst.data.face.HumanFaceListener;
import cz.fidentis.analyst.data.face.HumanFaceState;
import cz.fidentis.analyst.data.kdtree.KdTree;
import cz.fidentis.analyst.data.landmarks.Landmark;
import cz.fidentis.analyst.data.landmarks.LandmarksIO;
import cz.fidentis.analyst.data.mesh.MeshFacet;
import cz.fidentis.analyst.data.mesh.MeshIO;
import cz.fidentis.analyst.data.mesh.MeshModel;
import cz.fidentis.analyst.data.octree.Octree;
@@ -13,10 +16,6 @@ import cz.fidentis.analyst.data.shapes.Box;
import cz.fidentis.analyst.data.shapes.Glyph;
import cz.fidentis.analyst.data.shapes.Plane;
import cz.fidentis.analyst.data.shapes.SurfaceMask;
import cz.fidentis.analyst.data.face.HumanFace;
import cz.fidentis.analyst.data.face.HumanFaceEvent;
import cz.fidentis.analyst.data.face.HumanFaceListener;
import cz.fidentis.analyst.data.face.HumanFaceState;

import java.io.File;
import java.io.IOException;
@@ -77,9 +76,7 @@ public class HumanFaceImpl implements HumanFace {
        meshModel.simplifyModel();
        this.id = file.getCanonicalPath();

        meshModel.getFacets().stream()
                .filter(f -> !f.hasVertexNormals())
                .forEach(MeshFacet::calculateVertexNormals);
        meshModel.estimateMissingVertexNormals();

        eventBus = new EventBus();

@@ -173,7 +170,7 @@ public class HumanFaceImpl implements HumanFace {

    @Override
    public List<Landmark> getAllLandmarks() {
        return featurePoints == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(featurePoints);
        return featurePoints == null ? Collections.emptyList() : Collections.unmodifiableList(featurePoints);
    }
    
    @Override
@@ -208,7 +205,7 @@ public class HumanFaceImpl implements HumanFace {
    @Override
    public String getShortName() {
        String name = id.substring(0, id.lastIndexOf('.')); // remove extension
        name = name.substring(name.lastIndexOf(File.separatorChar) + 1, name.length());
        name = name.substring(name.lastIndexOf(File.separatorChar) + 1);
        return name;
    }

@@ -279,8 +276,10 @@ public class HumanFaceImpl implements HumanFace {
        this.symmetryPlane = state.symmetryPlane();
        this.kdTree = state.kdTree();
        this.octree = state.octree();
        if (this.featurePoints != null) {
            this.featurePoints.clear();
            this.featurePoints = state.featurePoints();
        }
        this.boundingBox = state.boundingBox();
        this.glyphs = state.glyphs();
    }
+2 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class HumanFaceMemoryManagerImpl implements HumanFaceMemoryManager {
                HumanFaceMemoryManagerImpl.kryo = new Kryo();
                HumanFaceMemoryManagerImpl.kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
                HumanFaceMemoryManagerImpl.kryo.register(HumanFace.class);
                HumanFaceMemoryManagerImpl.kryo.register(HumanFaceImpl.class);
                MeshFactory.registerClassesInKryo(kryo);
                HumanFaceMemoryManagerImpl.kryo.register(Box.class);
                HumanFaceMemoryManagerImpl.kryo.register(Plane.class);
@@ -340,7 +341,7 @@ public class HumanFaceMemoryManagerImpl implements HumanFaceMemoryManager {
        */
        
        try (Input in = new Input(new FileInputStream(dumpFile))) {
            return kryo.readObject(in, HumanFace.class);
            return kryo.readObject(in, HumanFaceImpl.class);
        } catch(Exception ex) {
            throw new IOException(ex);
        }
+0 −1
Original line number Diff line number Diff line
@@ -185,5 +185,4 @@
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <groupId>cz.fidentis</groupId>
</project>
+4 −4
Original line number Diff line number Diff line
@@ -61,9 +61,9 @@ public class PlaneManipulationPanel extends JPanel {
        setBackground(Color.LIGHT_GRAY);
        setBorder(new EmptyBorder(5, 5, 5, 5));
        this.addMouseListener(mouseListener);
        spinSlider.getSpinner().setMinimumSize(new Dimension(45, 20));
        spinSlider.getSpinner().setPreferredSize(new Dimension(48, 20));
        spinSlider.getSpinner().setMaximumSize(new Dimension(50, 20));
        spinSlider.getSpinner().setMinimumSize(new Dimension(45, 25));
        spinSlider.getSpinner().setPreferredSize(new Dimension(48, 25));
        spinSlider.getSpinner().setMaximumSize(new Dimension(50, 25));
    }
    
    public DrawableCuttingPlane getCurrentPlane() {
@@ -298,7 +298,7 @@ public class PlaneManipulationPanel extends JPanel {

    private void initCheckBox() {
        visibilityCheckBox = new JCheckBox();
        visibilityCheckBox.setText("Show");
        visibilityCheckBox.setText("Show in 3D");
        visibilityCheckBox.addMouseListener(mouseListener);
        visibilityCheckBox.addItemListener(checkBoxSelectionListener);
    }
Loading