diff --git a/GUI/src/main/java/cz/fidentis/analyst/canvas/Canvas.java b/GUI/src/main/java/cz/fidentis/analyst/canvas/Canvas.java index 001a7633341b3066de64afedf5b0145949daf469..ff729528a902657c1baaf1e22ff3b2fc6e7cf357 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/canvas/Canvas.java +++ b/GUI/src/main/java/cz/fidentis/analyst/canvas/Canvas.java @@ -8,6 +8,8 @@ import cz.fidentis.analyst.scene.Camera; import cz.fidentis.analyst.scene.Scene; import cz.fidentis.analyst.scene.SceneRenderer; import java.awt.BorderLayout; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -30,9 +32,9 @@ public class Canvas extends JPanel { private final MouseRotationListener manipulator; // GUI elements: - private final JLayeredPane layeredPane; - private final JPanel canvasPanel; - private final ControlButtons controlButtonsPanel; + private JLayeredPane layeredPane; + private JPanel canvasPanel; + private ControlButtons controlButtonsPanel; private GLCanvas glCanvas; @@ -44,23 +46,7 @@ public class Canvas extends JPanel { listener = new CanvasListener(this); manipulator = new MouseRotationListener(this); - setLayout(new BorderLayout()); - - initGLCanvas(); - canvasPanel = getCanvasPanel(); - canvasPanel.add(glCanvas); - - controlButtonsPanel = getButtonsPanel(this); - - layeredPane = getLayeredPane(); - layeredPane.add(canvasPanel, 1); - //layeredPane.setLayer(controlButtonsPanel, JLayeredPane.MODAL_LAYER); - layeredPane.add(controlButtonsPanel, 0); - add(layeredPane, BorderLayout.CENTER); - - setDarkBackground(true); - - validate(); + initComponents(); } /** @@ -158,28 +144,40 @@ public class Canvas extends JPanel { return ret; } - private JLayeredPane getLayeredPane() { - JLayeredPane pane = new JLayeredPane(); - pane.addComponentListener(new java.awt.event.ComponentAdapter() { - @Override - public void componentResized(java.awt.event.ComponentEvent evt) { - canvasPanel.setBounds(0, 0, layeredPane.getWidth(), layeredPane.getHeight()); - glCanvas.setBounds(layeredPane.getX(), layeredPane.getY(), layeredPane.getWidth(), layeredPane.getHeight()); - } + private void initComponents() { + setLayout(new BorderLayout()); + + initGLCanvas(); + canvasPanel = new JPanel(); + canvasPanel.setLayout(new BorderLayout()); + canvasPanel.add(glCanvas); + + controlButtonsPanel = getButtonsPanel(this); + + layeredPane = new JLayeredPane(); + layeredPane.add(canvasPanel, 1); + layeredPane.add(controlButtonsPanel, 0); + add(layeredPane, BorderLayout.CENTER); + + setDarkBackground(true); + + addComponentListener(new ComponentAdapter() { @Override - public void componentShown(java.awt.event.ComponentEvent evt) { + public void componentResized(ComponentEvent e) { canvasPanel.setBounds(0, 0, layeredPane.getWidth(), layeredPane.getHeight()); glCanvas.setBounds(layeredPane.getX(), layeredPane.getY(), layeredPane.getWidth(), layeredPane.getHeight()); + /* + OutputWindow.print("Canvas resized event: "); + OutputWindow.print("- Canvas: " + getWidth() + "x" + getHeight()); + OutputWindow.print("- Layered Pane: " + layeredPane.getWidth() + "x" + layeredPane.getHeight()); + OutputWindow.print("- Canvas Panel: " + canvasPanel.getWidth() + "x" + canvasPanel.getHeight()); + OutputWindow.print("- GL Canvas: " + glCanvas.getWidth() + "x" + glCanvas.getHeight()); + OutputWindow.print("- Parent1: " + getParent().getWidth() + "x" + getParent().getHeight()); + OutputWindow.print("- Parent2: " + getParent().getParent().getWidth() + "x" + getParent().getParent().getHeight()); + OutputWindow.print("- Parent3: " + getParent().getParent().getParent().getWidth() + "x" + getParent().getParent().getParent().getHeight()); + */ } }); - return pane; - } - - private JPanel getCanvasPanel() { - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.setBounds(0, 0, 0, 0); - return panel; } private void initGLCanvas() { @@ -193,10 +191,9 @@ public class Canvas extends JPanel { // enables glCanvas to react to events glCanvas.requestFocusInWindow(); - glCanvas.setSize(getWidth() - getInsets().left - getInsets().right, getHeight() - getInsets().top - getInsets().bottom); + //glCanvas.setSize(getWidth() - getInsets().left - getInsets().right, getHeight() - getInsets().top - getInsets().bottom); glCanvas.addGLEventListener(listener); - glCanvas.addMouseListener(manipulator); glCanvas.addMouseMotionListener(manipulator); glCanvas.addMouseWheelListener(manipulator); diff --git a/GUI/src/main/java/cz/fidentis/analyst/canvas/CanvasListener.java b/GUI/src/main/java/cz/fidentis/analyst/canvas/CanvasListener.java index 21f9e7110aaa830b1cd3d2c5d9433153573c0b67..d99a737131edc12be52c93ab9c50c1b342e6a4d7 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/canvas/CanvasListener.java +++ b/GUI/src/main/java/cz/fidentis/analyst/canvas/CanvasListener.java @@ -38,13 +38,15 @@ public class CanvasListener implements GLEventListener { @Override public void display(GLAutoDrawable glad) { - //System.out.println("CanvasListener.display " + this.toString()); canvas.getSceneRenderer().renderScene(canvas.getCamera(), canvas.getScene().getAllDrawables()); + //OutputWindow.print("3D canvas has been rendered, window size " + // + canvas.getWidth() + "x" + canvas.getHeight() + // +", GL canvas size " + canvas.getGLCanvas().getWidth() + "x" + canvas.getGLCanvas().getHeight() + //); } @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { - //System.out.println("CanvasListener.reshape"); canvas.getSceneRenderer().setViewport(x, y, width, height); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/FaceToFaceTab.java b/GUI/src/main/java/cz/fidentis/analyst/core/FaceToFaceTab.java index d5bb4b699fadf5bc04f86ffbe68e3645bd3c928d..68f23c23acc5e58515f25d89171e7fb664ebc8aa 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/core/FaceToFaceTab.java +++ b/GUI/src/main/java/cz/fidentis/analyst/core/FaceToFaceTab.java @@ -4,7 +4,10 @@ import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.toolbar.FaceToFaceToolBar; import cz.fidentis.analyst.toolbar.RenderingToolBar; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import javax.swing.GroupLayout; +import javax.swing.JScrollPane; import javax.swing.LayoutStyle; import org.openide.windows.TopComponent; @@ -18,6 +21,7 @@ public class FaceToFaceTab extends TopComponent { private final Canvas canvas ; private final FaceToFaceToolBar renderingToolBar; private final TopControlPanel controlPanel; + private final JScrollPane scrollPane; /** * Constructor. @@ -30,8 +34,19 @@ public class FaceToFaceTab extends TopComponent { canvas.initScene(primary, secondary); controlPanel = new TopControlPanel(); renderingToolBar = new FaceToFaceToolBar(canvas, controlPanel); + + scrollPane = new JScrollPane(controlPanel); + setName(name); initComponents(); + + // change the height so that it corresponds to the height of the OpenGL window + canvas.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + scrollPane.setSize(ControlPanel.CONTROL_PANEL_WIDTH, canvas.getHeight()); + } + }); } @Override @@ -50,7 +65,7 @@ public class FaceToFaceTab extends TopComponent { .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(renderingToolBar, GroupLayout.PREFERRED_SIZE, RenderingToolBar.WIDTH, GroupLayout.PREFERRED_SIZE) .addComponent( - controlPanel, + scrollPane, ControlPanel.CONTROL_PANEL_WIDTH, ControlPanel.CONTROL_PANEL_WIDTH, ControlPanel.CONTROL_PANEL_WIDTH @@ -63,7 +78,7 @@ public class FaceToFaceTab extends TopComponent { .addGroup(layout.createBaselineGroup(true, true) .addComponent(canvas) .addComponent(renderingToolBar) - .addComponent(controlPanel) + .addComponent(scrollPane) )) ); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java b/GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java index e1b2aa8bc26296203000fa86cf8d16d7d5647139..97821f99a03040957817f8c841b18ba6cb74a244 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java +++ b/GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java @@ -16,56 +16,58 @@ import org.openide.windows.WindowManager; */ public class OutputWindow { - private final JTextArea textArea; + private static JTextArea textArea; private long lastTime = System.currentTimeMillis(); - private static OutputWindow instance; - protected OutputWindow() { - TopComponent outputWin = WindowManager.getDefault().findTopComponent("output"); - textArea = new JTextArea(); - JScrollPane sp = new JScrollPane(textArea); - outputWin.add(sp, BorderLayout.CENTER); + initTextArea(); } /** - * Prints the message. The duration indicator is set to [+00:00:000] + * Prints the message. * * @param msg Message to be printed */ public static void print(String msg) { - instance().textArea.setText(instance().textArea.getText() + JTextArea ta = initTextArea(); + ta.setText(ta.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) - + " [+00:00:000]: " + + " [duration unknown]: " + msg.trim() + System.lineSeparator() ); } /** - * Resets the stopwatch for the duration calculation. + * Starts measuring of some operation. + * Call {@link #printDuration(java.lang.String)} on returned OutputWindow + * to print the measured duration. + * + * @return An object used to print measured duration and message */ - public static void resetStopwatch() { - instance().lastTime = System.currentTimeMillis(); + public static OutputWindow measureTime() { + OutputWindow ret = new OutputWindow(); + ret.lastTime = System.currentTimeMillis(); + return ret; } /** * Prints the message about an operation and the duration of the operation. * The duration is computed as the difference between current system time and - * the time of calling {@link #resetStopwatch()}. The difference is measured in + * the time of calling {@link #measureTime()}. The time difference is measured in * milliseconds and printed as [+mm:ss.SSS] where mm=minutes, ss=seconds, * and SSS=milliseconds. * * @param msg Message to be printed */ - public static void printDuration(String msg) { - Duration duration = Duration.ofMillis(System.currentTimeMillis() - instance().lastTime); - instance().textArea.setText(instance().textArea.getText() + public void printDuration(String msg) { + Duration duration = Duration.ofMillis(System.currentTimeMillis() - lastTime); + textArea.setText(textArea.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) - + " [+" + + " [duration " + String.format( - "%d:%02d.%03d", + "%02d:%02d.%03d", duration.toMinutes(), duration.toSecondsPart(), duration.toMillisPart()) @@ -75,11 +77,13 @@ public class OutputWindow { ); } - protected static OutputWindow instance() { - if (instance == null) { - instance = new OutputWindow(); + protected static JTextArea initTextArea() { + if (textArea == null) { + TopComponent outputWin = WindowManager.getDefault().findTopComponent("output"); + textArea = new JTextArea(); + JScrollPane sp = new JScrollPane(textArea); + outputWin.add(sp, BorderLayout.CENTER); } - return instance; + return textArea; } - } diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java index 2ab22b914c96b6e63f0ee93e85502e48a377cfda..69a4278f247e92cf6c738f3436ce50f10ebea846 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java +++ b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java @@ -470,10 +470,10 @@ public final class ProjectTopComp extends TopComponent { if (file == null) { System.out.print("No file chosen."); } else { - OutputWindow.resetStopwatch(); + OutputWindow out = OutputWindow.measureTime(); String faceId = HumanFaceFactory.instance().loadFace(file); HumanFace face = HumanFaceFactory.instance().getFace(faceId); - OutputWindow.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); + out.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); try { // simple hack: diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/SingleFaceTab.java b/GUI/src/main/java/cz/fidentis/analyst/core/SingleFaceTab.java index 61629541e2a4f6ea468f6b5cfb9f76d463d56bba..110c601f7a893b1cafb962d0a42673bbefd2f2b8 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/core/SingleFaceTab.java +++ b/GUI/src/main/java/cz/fidentis/analyst/core/SingleFaceTab.java @@ -4,7 +4,10 @@ import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.toolbar.RenderingToolBar; import cz.fidentis.analyst.toolbar.SingleFaceToolBar; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import javax.swing.GroupLayout; +import javax.swing.JScrollPane; import javax.swing.LayoutStyle; import org.openide.windows.TopComponent; @@ -18,6 +21,7 @@ public final class SingleFaceTab extends TopComponent { private final Canvas canvas; private final RenderingToolBar renderingToolBar; private final TopControlPanel controlPanel; + private final JScrollPane scrollPane; /** * Constructor. @@ -29,8 +33,19 @@ public final class SingleFaceTab extends TopComponent { canvas.initScene(face); controlPanel = new TopControlPanel(); renderingToolBar = new SingleFaceToolBar(canvas, controlPanel); + + scrollPane = new JScrollPane(controlPanel); + setName(name); initComponents(); + + // change the height so that it corresponds to the height of the OpenGL window + canvas.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + scrollPane.setSize(ControlPanel.CONTROL_PANEL_WIDTH, canvas.getHeight()); + } + }); } @Override @@ -49,7 +64,7 @@ public final class SingleFaceTab extends TopComponent { .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(renderingToolBar, GroupLayout.PREFERRED_SIZE, RenderingToolBar.WIDTH, GroupLayout.PREFERRED_SIZE) .addComponent( - controlPanel, + scrollPane, ControlPanel.CONTROL_PANEL_WIDTH, ControlPanel.CONTROL_PANEL_WIDTH, ControlPanel.CONTROL_PANEL_WIDTH @@ -62,7 +77,7 @@ public final class SingleFaceTab extends TopComponent { .addGroup(layout.createBaselineGroup(true, true) .addComponent(canvas) .addComponent(renderingToolBar) - .addComponent(controlPanel) + .addComponent(scrollPane) )) ); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/curvature/CurvatureAction.java b/GUI/src/main/java/cz/fidentis/analyst/curvature/CurvatureAction.java index ae1518f87aeec8cb6f52824e8b8d384166542d7e..c745c98cfa174fe6a7d062a004121c18ce69c6ef 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/curvature/CurvatureAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/curvature/CurvatureAction.java @@ -2,6 +2,7 @@ package cz.fidentis.analyst.curvature; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.ControlPanelAction; +import cz.fidentis.analyst.core.OutputWindow; import cz.fidentis.analyst.visitors.mesh.Curvature; import java.awt.event.ActionEvent; import javax.swing.JComboBox; @@ -63,8 +64,13 @@ public class CurvatureAction extends ControlPanelAction { protected void setHeatmap() { if (visitor == null) { // compute missing curvature + OutputWindow out = OutputWindow.measureTime(); this.visitor = new Curvature(); getPrimaryDrawableFace().getModel().compute(visitor); + out.printDuration("Computation of curvature for a model with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); } switch (this.curvatureType) { diff --git a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java index 192d585741e74fdc759076fe676272069eb0c70d..0263a00518c5916bc163d1ad75fed7176ac75102 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java @@ -5,6 +5,7 @@ import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.LoadedActionEvent; import cz.fidentis.analyst.core.ControlPanelAction; import cz.fidentis.analyst.core.ControlPanelBuilder; +import cz.fidentis.analyst.core.OutputWindow; import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePointType; import cz.fidentis.analyst.mesh.core.MeshFacet; @@ -265,12 +266,19 @@ public class DistanceAction extends ControlPanelAction { throw new UnsupportedOperationException(strategy); } + OutputWindow out = OutputWindow.measureTime(); this.visitor = new HausdorffDistancePrioritized(getPrimaryDrawableFace().getModel(), featurePoints, useStrategy, relativeDist, true); getSecondaryDrawableFace().getHumanFace().accept(visitor); + out.printDuration("Computation of Hausdorff distance for models with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + "/" + + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); } /** diff --git a/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java b/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java index fedce712bdc90d87c371fe68b8f14aa1954854dc..91456ffbbb89846fce0e6d227375be1e7d6ceee2 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/distance/DistancePanel.java @@ -3,10 +3,12 @@ package cz.fidentis.analyst.distance; import cz.fidentis.analyst.core.ControlPanel; import cz.fidentis.analyst.core.ControlPanelBuilder; import cz.fidentis.analyst.core.LoadedActionEvent; +import cz.fidentis.analyst.core.TopControlPanel; import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePointType; import cz.fidentis.analyst.scene.DrawableFeaturePoints; import cz.fidentis.analyst.symmetry.SymmetryPanel; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -25,6 +27,7 @@ import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.KeyStroke; @@ -210,8 +213,9 @@ public class DistancePanel extends ControlPanel { fpBuilder.addLine(); } - builder.addScrollPane(featurePointsPanel) - .setBorder(BorderFactory.createTitledBorder("Feature points")); + JScrollPane sp = builder.addScrollPane(featurePointsPanel); + sp.setBorder(BorderFactory.createTitledBorder("Feature points")); + sp.setPreferredSize(new Dimension(TopControlPanel.WIDTH, 200)); builder.addLine(); builder.addButton("Select all", (ActionEvent ae) -> { @@ -258,8 +262,8 @@ public class DistancePanel extends ControlPanel { builder.addLine(); builder.addOptionText(""); - builder.addOptionText("Hausdorff distance"); - builder.addOptionText("Weighted Hasudorff distance"); + builder.addOptionText("Hausdorff dist."); + builder.addOptionText("Weighted H. dist."); builder.addLine(); builder.addOptionText("Average"); @@ -318,14 +322,14 @@ public class DistancePanel extends ControlPanel { */ public void updateHausdorffDistanceStats(DoubleSummaryStatistics hausdorffDistance, DoubleSummaryStatistics weightedHausdorffDistance) { - avgHD.setText(Double.toString(hausdorffDistance.getAverage())); - avgHDWeight.setText(Double.toString(weightedHausdorffDistance.getAverage())); + avgHD.setText(String.format("%.4f", hausdorffDistance.getAverage())); + avgHDWeight.setText(String.format("%.4f", weightedHausdorffDistance.getAverage())); - maxHD.setText(Double.toString(hausdorffDistance.getMax())); - maxHDWeight.setText(Double.toString(weightedHausdorffDistance.getMax())); + maxHD.setText(String.format("%.4f", hausdorffDistance.getMax())); + maxHDWeight.setText(String.format("%.4f", weightedHausdorffDistance.getMax())); - minHD.setText(Double.toString(hausdorffDistance.getMin())); - minHDWeight.setText(Double.toString(weightedHausdorffDistance.getMin())); + minHD.setText(String.format("%.4f", hausdorffDistance.getMin())); + minHDWeight.setText(String.format("%.4f", weightedHausdorffDistance.getMin())); } /** @@ -337,7 +341,7 @@ public class DistancePanel extends ControlPanel { public void updateFeaturePointWeights(Map<FeaturePointType, Double> featurePointWeights) { featurePointStats.forEach((fpType, fpWeightLabel) -> { final Double fpWeight = featurePointWeights.get(fpType); - fpWeightLabel.setText(fpWeight == null ? "" : Double.toString(fpWeight)); + fpWeightLabel.setText(fpWeight == null ? "" : String.format("%.3f", fpWeight)); }); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java index 7cc5713639cd4392010b0f9fa7328a1a15ddbc11..c5a72da396397c0b800fcc7d7fcf4e409cae19d8 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java @@ -2,6 +2,7 @@ package cz.fidentis.analyst.registration; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.ControlPanelAction; +import cz.fidentis.analyst.core.OutputWindow; import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.icp.IcpTransformation; @@ -257,6 +258,8 @@ public class RegistrationAction extends ControlPanelAction { } protected void applyICP() { + OutputWindow out = OutputWindow.measureTime(); + IcpTransformer visitor = new IcpTransformer(getPrimaryDrawableFace().getModel(), maxIterations, scale, error, undersampling); getSecondaryDrawableFace().getModel().compute(visitor); // NOTE: the secondary face is physically transformed for (List<IcpTransformation> trList: visitor.getTransformations().values()) { @@ -268,6 +271,13 @@ public class RegistrationAction extends ControlPanelAction { } } } + + out.printDuration("Computation of ICP for models with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + "/" + + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); } /** @@ -296,6 +306,8 @@ public class RegistrationAction extends ControlPanelAction { * otherwise set color to default */ private void calculateFeaturePoints() { + OutputWindow.print("Calculation of feature points"); + if (getPrimaryDrawableFace() == null) { // scene not yet initiated return; } @@ -334,11 +346,20 @@ public class RegistrationAction extends ControlPanelAction { } private void calculateHausdorffDistance() { + OutputWindow out = OutputWindow.measureTime(); + HumanFace primFace = getScene().getHumanFace(0); primFace.computeKdTree(false); HausdorffDistance hd = new HausdorffDistance(primFace.getKdTree(), HausdorffDistance.Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, true); getScene().getHumanFace(1).getMeshModel().compute(hd); + out.printDuration("Computation of Hausdorff distance for models with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + "/" + + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); + double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; double sum = 0; @@ -446,8 +467,17 @@ public class RegistrationAction extends ControlPanelAction { } if (hdVisitor == null) { + OutputWindow out = OutputWindow.measureTime(); + this.hdVisitor = new HausdorffDistance(getPrimaryDrawableFace().getModel(), useStrategy, relativeDist, true); getSecondaryDrawableFace().getModel().compute(hdVisitor); + + out.printDuration("Computation of Hausdorff distance for models with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + "/" + + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); } getSecondaryDrawableFace().setHeatMap(hdVisitor.getDistances()); diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java b/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java index 49914874310f842b8080dee11d88037e75cef07c..7307d5afe9fe12edf8feab2b9a7c7ae7523323cf 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/SceneRenderer.java @@ -60,7 +60,6 @@ public class SceneRenderer { gl.glEnable(GL2.GL_BLEND); // enable transparency gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); - } /** @@ -86,7 +85,8 @@ public class SceneRenderer { * @param height Height */ public void setViewport(int x, int y, int width, int height) { - + //OutputWindow out = OutputWindow.measureTime(); + if (height == 0) { height = 1; // to avoid division by 0 in aspect ratio below } @@ -96,18 +96,20 @@ public class SceneRenderer { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); - - glu.gluPerspective(65, width / (float) height, 5.0f, 1500.0f); + glu.gluPerspective(50, width / (float) height, 5.0f, 1500.0f); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); - gl.glTranslatef(0.0f, 0.0f, -40.0f); + + //out.printDuration("GL viewport set to " + width + "x" + height); } /** * Renders drawable objects. */ public void renderScene(Camera camera, Collection<Drawable> drawables) { + //OutputWindow out = OutputWindow.measureTime(); clearScene(); // light backface @@ -131,6 +133,8 @@ public class SceneRenderer { } gl.glFlush(); + + //out.printDuration("Scene rendering"); } /** @@ -166,32 +170,6 @@ public class SceneRenderer { return faces; } - /** - * Renders feature points - * - * @param obj Model used to get his feature points - */ - /* - private void renderFeaturePoints(DrawableFace obj) { - for (int i = 0; i < obj.getFeaturePoints().size(); i++) { - Color color = obj.getFeaturePointsColor().get(i); - FeaturePoint point = obj.getFeaturePoints().get(i); - gl.glPushMatrix(); - gl.glTranslated(point.getX(), point.getY(), point.getZ()); - float[] rgba = {color.getRed() / 255f, color.getGreen() / 255f, - color.getBlue() / 255f , obj.getTransparency()}; - gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, rgba, 0); - GLUquadric center = glu.gluNewQuadric(); - glu.gluQuadricDrawStyle(center, GLU.GLU_FILL); - glu.gluQuadricNormals(center, GLU.GLU_FLAT); - glu.gluQuadricOrientation(center, GLU.GLU_OUTSIDE); - glu.gluSphere(center, 3f, 16, 16); - glu.gluDeleteQuadric(center); - gl.glPopMatrix(); - } - } - */ - /** * Clears the scene and prepares it for the re-drawing. */ diff --git a/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java b/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java index babb5907c9a501ad8897483f61e35ca4392777ee..f48946047f820e7b836aef2f1a040ee952cef520 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/symmetry/SymmetryAction.java @@ -2,6 +2,7 @@ package cz.fidentis.analyst.symmetry; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.ControlPanelAction; +import cz.fidentis.analyst.core.OutputWindow; import cz.fidentis.analyst.scene.DrawablePlane; import java.awt.event.ActionEvent; import javax.swing.JTabbedPane; @@ -57,10 +58,17 @@ public class SymmetryAction extends ControlPanelAction { } private void recomputeSymmetryPlane() { + OutputWindow out = OutputWindow.measureTime(); + SymmetryEstimator se = new SymmetryEstimator(controlPanel.getSymmetryConfig()); getPrimaryDrawableFace().getModel().compute(se); DrawablePlane plane = new DrawablePlane(se.getSymmetryPlaneMesh(), se.getSymmetryPlane()); getCanvas().getScene().setDrawableSymmetryPlane(0, plane); + + out.printDuration("Computation of Hausdorff distance for models with " + + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + + " vertices" + ); } }