From 12b00022d7832960b6b5710df3767e8c70e13e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20O=C5=A1lej=C5=A1ek?= <oslejsek@fi.muni.cz> Date: Tue, 18 Jan 2022 06:46:02 +0100 Subject: [PATCH] Resolve "Fix batch mode rendering of AVG face" --- .../visitors/kdtree/AvgFaceConstructor.java | 2 +- .../cz/fidentis/analyst/batch/IcpTask.java | 42 +++++++++---------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/AvgFaceConstructor.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/AvgFaceConstructor.java index 10739916..ff112a6d 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/AvgFaceConstructor.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/AvgFaceConstructor.java @@ -102,7 +102,7 @@ public class AvgFaceConstructor extends KdTreeVisitor { //moveDir.sub(closestPoints.get(i)); Vector3d moveDir = new Vector3d(closestPoints.get(i)); moveDir.sub(myFacet.getVertex(i).getPosition()); - if (transformations.get(myFacet).size() < myFacet.getNumTriangles()) { // First inspected facet + if (transformations.get(myFacet).size() < myFacet.getNumberOfVertices()) { // First inspected facet transformations.get(myFacet).add(moveDir); } else { transformations.get(myFacet).get(i).add(moveDir); diff --git a/GUI/src/main/java/cz/fidentis/analyst/batch/IcpTask.java b/GUI/src/main/java/cz/fidentis/analyst/batch/IcpTask.java index e25a5000..3d9d3f50 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/batch/IcpTask.java +++ b/GUI/src/main/java/cz/fidentis/analyst/batch/IcpTask.java @@ -31,8 +31,8 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { private final ProgressDialog progressDialog; private final BatchPanel controlPanel; private final Canvas canvas; - private int firstFaceIndex = -1; - private int icpFaceIndex = -1; + private int avgFaceSceneIndex = -1; + private int icpFaceSceneIndex = -1; private final Stopwatch totalTime = new Stopwatch("Total computation time:\t"); private final Stopwatch avgFaceComputationTime = new Stopwatch("AVG face computation time:\t"); @@ -94,7 +94,6 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { if (computeICP) {// ICP registration: icpComputationTime.start(); - UndersamplingStrategy uStrategy = (undersampling == 100) ? new NoUndersampling() : new RandomStrategy(undersampling); IcpTransformer icp = new IcpTransformer( avgFace.getMeshModel(), 100, @@ -135,13 +134,13 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { if (isCancelled()) { avgFace = null; } - if (canvas != null && firstFaceIndex >= 0) { - canvas.getScene().setDrawableFace(firstFaceIndex, null); // remove from scene - firstFaceIndex = -1; + if (canvas != null && avgFaceSceneIndex >= 0) { + canvas.getScene().setDrawableFace(avgFaceSceneIndex, null); // remove from scene + avgFaceSceneIndex = -1; } - if (canvas != null && icpFaceIndex >= 0) { - canvas.getScene().setDrawableFace(icpFaceIndex, null); // remove from scene - icpFaceIndex = -1; + if (canvas != null && icpFaceSceneIndex >= 0) { + canvas.getScene().setDrawableFace(icpFaceSceneIndex, null); // remove from scene + icpFaceSceneIndex = -1; } if (canvas != null) { canvas.getCamera().initLocation(); @@ -152,27 +151,24 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { protected void process(List<HumanFace> chunks) { chunks.stream().forEach(f -> { if (canvas != null) { - if (firstFaceIndex == -1) { - firstFaceIndex = canvas.getScene().getFreeIndex(); + if (icpFaceSceneIndex == -1) { // first rendering + avgFaceSceneIndex = canvas.getScene().getFreeIndex(); // locate the camera to the best angle: canvas.getCamera().initLocation(); canvas.getCamera().rotate(10, -80); canvas.getCamera().move(40, 20); - canvas.getScene().setDrawableFace(firstFaceIndex, f); - //canvas.getScene().getDrawableFace(firstFaceIndex).setTransparency(0.4f); - //canvas.getScene().getDrawableFace(firstFaceIndex).setColor(DrawableFace.SKIN_COLOR_PRIMARY); - canvas.getScene().getDrawableFace(firstFaceIndex).setRenderMode(GL2.GL_POINT); - canvas.getScene().getDrawableFace(firstFaceIndex).setTransparency(0.7f); - } else { - if (icpFaceIndex == -1) { - icpFaceIndex = canvas.getScene().getFreeIndex(); - } - canvas.getScene().setDrawableFace(icpFaceIndex, f); - canvas.getScene().getDrawableFace(icpFaceIndex).setTransparency(0.5f); - canvas.getScene().getDrawableFace(icpFaceIndex).setColor(DrawableFace.SKIN_COLOR_SECONDARY); + canvas.getScene().setDrawableFace(avgFaceSceneIndex, avgFace); + canvas.getScene().getDrawableFace(avgFaceSceneIndex).setRenderMode(GL2.GL_POINT); + canvas.getScene().getDrawableFace(avgFaceSceneIndex).setTransparency(0.7f); + + icpFaceSceneIndex = canvas.getScene().getFreeIndex(); } + + canvas.getScene().setDrawableFace(icpFaceSceneIndex, f); + canvas.getScene().getDrawableFace(icpFaceSceneIndex).setTransparency(0.5f); + canvas.getScene().getDrawableFace(icpFaceSceneIndex).setColor(DrawableFace.SKIN_COLOR_SECONDARY); canvas.renderScene(); } }); -- GitLab