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

Added rendering mode icons

parent 6aa7c19e
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
package cz.fidentis.analyst.visitors.kdtree;

import cz.fidentis.analyst.kdtree.KdTree;
import cz.fidentis.analyst.kdtree.KdTreeVisitor;
import cz.fidentis.analyst.mesh.core.CornerTableRow;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.mesh.core.MeshFacetImpl;
import cz.fidentis.analyst.mesh.core.MeshPoint;
import cz.fidentis.analyst.mesh.core.MeshPointImpl;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import static org.junit.jupiter.api.Assertions.assertEquals;
+24 −54
Original line number Diff line number Diff line
package cz.fidentis.analyst.gui.rndtoolbar;

import com.jogamp.opengl.GL2;
import cz.fidentis.analyst.gui.canvas.Canvas;
import cz.fidentis.analyst.gui.scene.DrawableMesh;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import org.openide.awt.Actions;
import org.openide.awt.DropDownButtonFactory;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;

/**
 * Rendering toolbar.
 * Generic rendering toolbar with common tools.
 * 
 * @author Radek Oslejsek
 */
@@ -39,15 +26,18 @@ public class RenderingToolBar extends JToolBar {
    public static final String RENDERING_MODE_BUTTON_ICON = "wireframe28x28.png";
    public static final String BACKGROUND_BUTTON_ICON = "background28x28.png";
    public static final String REFLECTIONS_BUTTON_ICON = "reflections28x28.png";
    public static final String SMOOT_BUTTON_ICON = "smooth-tri28x28.png";
    public static final String WIREFRAME_BUTTON_ICON = "wireframe-tri28x28.png";
    public static final String POINTS_BUTTON_ICON = "points-tri28x28.png";
    
    private final Canvas canvas;
    
    public RenderingToolBar(Canvas canvas) {
        this.canvas = canvas;
        initToolBar();
        initBackgroundButton();
        initReflectionsButton();
        initRenderingModeButton();
        addRenderingModeButton();
        addBackgroundButton();
        addReflectionsButton();
    }
    
    private void initToolBar() {
@@ -56,32 +46,34 @@ public class RenderingToolBar extends JToolBar {
        setFloatable(false);
    }
    
    private void initRenderingModeButton() {
    private void addRenderingModeButton() {
        JPopupMenu popup = new JPopupMenu();
        
        JMenuItem menuItem1 = new JMenuItem(new SmoothRenderingAction(canvas));
        JMenuItem menuItem2 = new JMenuItem(new WireframeRenderingAction(canvas));
        JMenuItem menuItem3 = new JMenuItem(new PointCloudRenderingAction(canvas));
        
        //menuItem1.setIcon(defaultIcon);
        menuItem1.setText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.smooth.text"));
        menuItem2.setText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.wireframe.text"));
        menuItem3.setText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.pointcloud.text"));
        menuItem1.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.SMOOT_BUTTON_ICON)));
        menuItem2.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.WIREFRAME_BUTTON_ICON)));
        menuItem3.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.POINTS_BUTTON_ICON)));

        menuItem1.setToolTipText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.smooth.text"));
        menuItem2.setToolTipText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.wireframe.text"));
        menuItem3.setToolTipText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.pointcloud.text"));
        
        popup.add(menuItem1);
        popup.add(menuItem2);
        popup.add(menuItem3);
        
        popup.setLayout(new GridLayout(1,0));

        // The button that will display the default action and the
        // dropdown arrow
        JButton button = DropDownButtonFactory.createDropDownButton(
                new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), 
                popup);
        
        URL icon = getClass().getResource("/" + RenderingToolBar.RENDERING_MODE_BUTTON_ICON);
        if (icon != null) {
            button.setIcon(new ImageIcon(icon));
        }
        button.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.RENDERING_MODE_BUTTON_ICON)));
        
        //Mnemonics.setLocalizedText(button, NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.renderingmode.text"));
        button.setToolTipText(NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.renderingmode.text"));
@@ -90,13 +82,10 @@ public class RenderingToolBar extends JToolBar {
        add(button);
    }
    
    private void initBackgroundButton() {
    private void addBackgroundButton() {
        JToggleButton button = new JToggleButton();
        button.setAction(new BackgroundAction(canvas));
        URL icon = getClass().getResource("/" + RenderingToolBar.BACKGROUND_BUTTON_ICON);
        if (icon != null) {
            button.setIcon(new ImageIcon(icon));
        }
        button.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.BACKGROUND_BUTTON_ICON)));
        //Mnemonics.setLocalizedText(button, NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.background.text"));
        button.setFocusable(false);
       // button.setText(null);
@@ -104,13 +93,10 @@ public class RenderingToolBar extends JToolBar {
        add(button);
    }
    
    private void initReflectionsButton() {
    private void addReflectionsButton() {
        JToggleButton button = new JToggleButton();
        button.setAction(new ReflectionsAction(canvas));
        URL icon = getClass().getResource("/" + RenderingToolBar.REFLECTIONS_BUTTON_ICON);
        if (icon != null) {
            button.setIcon(new ImageIcon(icon));
        }
        button.setIcon(new ImageIcon(getClass().getResource("/" + RenderingToolBar.REFLECTIONS_BUTTON_ICON)));
        //Mnemonics.setLocalizedText(button, NbBundle.getMessage(RenderingToolBar.class, "RenderingToolBar.background.text"));
        button.setFocusable(false);
       // button.setText(null);
@@ -118,20 +104,4 @@ public class RenderingToolBar extends JToolBar {
        add(button);
    }
 

    /*
    private void reflectionsButtonClicked(MouseEvent evt) {
        boolean on = buttons.get(Button.REFLECTIONS).isSelected();
        for (DrawableMesh dm: canvas.getScene().getDrawables()) {
            if (on) {
                dm.setHighlights(Color.BLACK);
                buttons.get(Button.REFLECTIONS).setSelected(false);
            } else {
                dm.setHighlights(REFLECTIONS_COLOR);
                buttons.get(Button.REFLECTIONS).setSelected(true);
            }
        }
        canvas.renderScene();
    }
*/
}
+4 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package cz.fidentis.analyst.tests;
import cz.fidentis.analyst.BatchProcessor;
import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.face.HumanFaceFactory;
import cz.fidentis.analyst.icp.NoUndersampling;
import cz.fidentis.analyst.icp.RandomStrategy;
import cz.fidentis.analyst.icp.UndersamplingStrategy;
import cz.fidentis.analyst.kdtree.KdTree;
@@ -23,6 +24,7 @@ public class BatchTests {
    private static final String primaryFacePath = dataDir + "/average-boy-17-20/average_boy_17-20.obj";
    //private static final String primaryFacePath = dataDir + "/average-girl-17-20/average_girl_17-20.obj";
    //private static final String primaryFacePath = "../../analyst-data/basic-models/02.obj";
    //private static final String primaryFacePath = dataDir + "/07/00007_01_ECA.obj";
    private static final String templateFacePath = dataDir + "template.obj";
    
    /**
@@ -59,8 +61,8 @@ public class BatchTests {
        printTimes(startTime, endTime, faceIDs.size());
        
        //////////////////////////////////////////////
        //UndersamplingStrategy strategy = new NoUndersampling();
        UndersamplingStrategy strategy = new RandomStrategy(0.5);
        UndersamplingStrategy strategy = new NoUndersampling();
        //UndersamplingStrategy strategy = new RandomStrategy(0.5);
        System.out.println();
        System.out.println("ICP registration with " + strategy + ":");
        startTime = System.currentTimeMillis();
+76 −0
Original line number Diff line number Diff line
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.fidentis.analyst.tests;

import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.icp.IcpTransformer;
import cz.fidentis.analyst.icp.NoUndersampling;
import cz.fidentis.analyst.kdtree.KdTree;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author oslejsek
 */
public class ICPTest {
    
    private static final String dataDir = "../../analyst-data/multi-scan-models-anonymized-fixed/";
    
    private static String[] faceFiles = new String[] {
        dataDir + "02/00002_01_ECA.obj",
        dataDir + "04/00004_01_ECA.obj",
        dataDir + "06/00006_01_ECA.obj",
        dataDir + "07/00007_01_ECA.obj",
        dataDir + "10/00010_01_ECA.obj"
    };
    
    private static int tests = 0;
    private static int iters = 0;
    
    public static void main(String[] args) throws IOException {
        long time = 0;
        for (int i = 0; i < faceFiles.length; i++) {
            time += test(i);
        }
        System.out.println("tests: " + tests);
        System.out.println("iters: " + iters);
        System.out.println("time: " + time + " ms");
        System.out.println("AVG iters: " + ((double)iters/tests));
        System.out.println("AVG time: " + ((double)time/tests) + " ms");
    }
    
    public static long test(int index) throws IOException {
        List<HumanFace> faces = new ArrayList<>();
        for (int i = 0; i < faceFiles.length; i++) {
            faces.add(new HumanFace(new File(faceFiles[i])));
        }
        HumanFace prim = faces.remove(index);
        KdTree primKdTree = prim.computeKdTree(true);
        
        
        System.out.println();
        System.out.println(prim.getId());            
        long startTime = System.currentTimeMillis();
        for (HumanFace sec: faces) {
            tests++;
            IcpTransformer icpTransformer = new IcpTransformer(primKdTree, 10, false, 0.05, new NoUndersampling());
            System.out.println(sec.getId());
            sec.getMeshModel().compute(icpTransformer);
            
            for (MeshFacet f: icpTransformer.getTransformations().keySet()) {
                //System.out.println("AAA"+icpTransformer.getTransformations().get(f).size());
                iters += icpTransformer.getTransformations().get(f).size();
            }
        }
        long endTime = System.currentTimeMillis();
        
        return endTime - startTime;
    }
}
+986 B
Loading image diff...
Loading