Skip to content
Snippets Groups Projects
Commit 10d197ac authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '144-fix-batch-mode-rendering-of-avg-face' into 'master'

Resolve "Fix batch mode rendering of AVG face"

Closes #144

See merge request grp-fidentis/analyst2!154
parents b5cd9492 12b00022
No related branches found
No related tags found
No related merge requests found
...@@ -102,7 +102,7 @@ public class AvgFaceConstructor extends KdTreeVisitor { ...@@ -102,7 +102,7 @@ public class AvgFaceConstructor extends KdTreeVisitor {
//moveDir.sub(closestPoints.get(i)); //moveDir.sub(closestPoints.get(i));
Vector3d moveDir = new Vector3d(closestPoints.get(i)); Vector3d moveDir = new Vector3d(closestPoints.get(i));
moveDir.sub(myFacet.getVertex(i).getPosition()); 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); transformations.get(myFacet).add(moveDir);
} else { } else {
transformations.get(myFacet).get(i).add(moveDir); transformations.get(myFacet).get(i).add(moveDir);
......
...@@ -31,8 +31,8 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { ...@@ -31,8 +31,8 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
private final ProgressDialog progressDialog; private final ProgressDialog progressDialog;
private final BatchPanel controlPanel; private final BatchPanel controlPanel;
private final Canvas canvas; private final Canvas canvas;
private int firstFaceIndex = -1; private int avgFaceSceneIndex = -1;
private int icpFaceIndex = -1; private int icpFaceSceneIndex = -1;
private final Stopwatch totalTime = new Stopwatch("Total computation time:\t"); private final Stopwatch totalTime = new Stopwatch("Total computation time:\t");
private final Stopwatch avgFaceComputationTime = new Stopwatch("AVG face 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> { ...@@ -94,7 +94,6 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
if (computeICP) {// ICP registration: if (computeICP) {// ICP registration:
icpComputationTime.start(); icpComputationTime.start();
UndersamplingStrategy uStrategy = (undersampling == 100) ? new NoUndersampling() : new RandomStrategy(undersampling);
IcpTransformer icp = new IcpTransformer( IcpTransformer icp = new IcpTransformer(
avgFace.getMeshModel(), avgFace.getMeshModel(),
100, 100,
...@@ -135,13 +134,13 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { ...@@ -135,13 +134,13 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
if (isCancelled()) { if (isCancelled()) {
avgFace = null; avgFace = null;
} }
if (canvas != null && firstFaceIndex >= 0) { if (canvas != null && avgFaceSceneIndex >= 0) {
canvas.getScene().setDrawableFace(firstFaceIndex, null); // remove from scene canvas.getScene().setDrawableFace(avgFaceSceneIndex, null); // remove from scene
firstFaceIndex = -1; avgFaceSceneIndex = -1;
} }
if (canvas != null && icpFaceIndex >= 0) { if (canvas != null && icpFaceSceneIndex >= 0) {
canvas.getScene().setDrawableFace(icpFaceIndex, null); // remove from scene canvas.getScene().setDrawableFace(icpFaceSceneIndex, null); // remove from scene
icpFaceIndex = -1; icpFaceSceneIndex = -1;
} }
if (canvas != null) { if (canvas != null) {
canvas.getCamera().initLocation(); canvas.getCamera().initLocation();
...@@ -152,27 +151,24 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> { ...@@ -152,27 +151,24 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
protected void process(List<HumanFace> chunks) { protected void process(List<HumanFace> chunks) {
chunks.stream().forEach(f -> { chunks.stream().forEach(f -> {
if (canvas != null) { if (canvas != null) {
if (firstFaceIndex == -1) { if (icpFaceSceneIndex == -1) { // first rendering
firstFaceIndex = canvas.getScene().getFreeIndex(); avgFaceSceneIndex = canvas.getScene().getFreeIndex();
// locate the camera to the best angle: // locate the camera to the best angle:
canvas.getCamera().initLocation(); canvas.getCamera().initLocation();
canvas.getCamera().rotate(10, -80); canvas.getCamera().rotate(10, -80);
canvas.getCamera().move(40, 20); canvas.getCamera().move(40, 20);
canvas.getScene().setDrawableFace(firstFaceIndex, f); canvas.getScene().setDrawableFace(avgFaceSceneIndex, avgFace);
//canvas.getScene().getDrawableFace(firstFaceIndex).setTransparency(0.4f); canvas.getScene().getDrawableFace(avgFaceSceneIndex).setRenderMode(GL2.GL_POINT);
//canvas.getScene().getDrawableFace(firstFaceIndex).setColor(DrawableFace.SKIN_COLOR_PRIMARY); canvas.getScene().getDrawableFace(avgFaceSceneIndex).setTransparency(0.7f);
canvas.getScene().getDrawableFace(firstFaceIndex).setRenderMode(GL2.GL_POINT);
canvas.getScene().getDrawableFace(firstFaceIndex).setTransparency(0.7f); icpFaceSceneIndex = canvas.getScene().getFreeIndex();
} 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(icpFaceSceneIndex, f);
canvas.getScene().getDrawableFace(icpFaceSceneIndex).setTransparency(0.5f);
canvas.getScene().getDrawableFace(icpFaceSceneIndex).setColor(DrawableFace.SKIN_COLOR_SECONDARY);
canvas.renderScene(); canvas.renderScene();
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment