diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/IcpVisitor.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/IcpVisitor.java index 4a9658f688b502e841cbe7989b7b7a745d3d38e2..e300ec44d5110308d5673d514c92e3dbbe8e261e 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/IcpVisitor.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/IcpVisitor.java @@ -64,7 +64,7 @@ public class IcpVisitor extends MeshVisitor { */ private final KdTree primaryKdTree; - private final ReductionStrategy reductionStrategy; + private final UndersamplingStrategy reductionStrategy; /** * Constructor. @@ -77,10 +77,10 @@ public class IcpVisitor extends MeshVisitor { * @param scale If {@code true}, then the scale factor is also computed. * @param error Acceptable error. A number bugger than or equal to zero. * When reached, then the ICP stops. Reasonable number seems to be 0.05. - * @param strategy One of the reduction strategies. If {@code null}, then {@link NoReductionStrategy} is used. + * @param strategy One of the reduction strategies. If {@code null}, then {@link NoUndersampling} is used. * @throws IllegalArgumentException if some parameter is wrong */ - public IcpVisitor(MeshFacet mainFacet, int maxIteration, boolean scale, double error, ReductionStrategy strategy) { + public IcpVisitor(MeshFacet mainFacet, int maxIteration, boolean scale, double error, UndersamplingStrategy strategy) { this(new HashSet<>(Collections.singleton(mainFacet)), maxIteration, scale, error, strategy); if (mainFacet == null) { throw new IllegalArgumentException("mainFacet"); @@ -98,10 +98,10 @@ public class IcpVisitor extends MeshVisitor { * @param scale If {@code true}, then the scale factor is also computed. * @param error Acceptable error. A number bugger than or equal to zero. * When reached, then the ICP stops. Reasonable number seems to be 0.05. - * @param strategy One of the reduction strategies. If {@code null}, then {@link NoReductionStrategy} is used. + * @param strategy One of the reduction strategies. If {@code null}, then {@link NoUndersampling} is used. * @throws IllegalArgumentException if some parameter is wrong */ - public IcpVisitor(Set<MeshFacet> mainFacets, int maxIteration, boolean scale, double error, ReductionStrategy strategy) { + public IcpVisitor(Set<MeshFacet> mainFacets, int maxIteration, boolean scale, double error, UndersamplingStrategy strategy) { if (mainFacets == null) { throw new IllegalArgumentException("mainFacets"); } @@ -115,7 +115,7 @@ public class IcpVisitor extends MeshVisitor { this.error = error; this.maxIteration = maxIteration; this.scale = scale; - this.reductionStrategy = (strategy == null) ? new NoReductionStrategy() : strategy; + this.reductionStrategy = (strategy == null) ? new NoUndersampling() : strategy; } /** @@ -129,10 +129,10 @@ public class IcpVisitor extends MeshVisitor { * @param scale If {@code true}, then the scale factor is also computed. * @param error Acceptable error. A number bugger than or equal to zero. * When reached, then the ICP stops. Reasonable number seems to be 0.05. - * @param strategy One of the reduction strategies. If {@code null}, then {@link NoReductionStrategy} is used. + * @param strategy One of the reduction strategies. If {@code null}, then {@link NoUndersampling} is used. * @throws IllegalArgumentException if some parameter is wrong */ - public IcpVisitor(MeshModel mainModel, int maxIteration, boolean scale, double error, ReductionStrategy strategy) { + public IcpVisitor(MeshModel mainModel, int maxIteration, boolean scale, double error, UndersamplingStrategy strategy) { this(new HashSet<>(mainModel.getFacets()), maxIteration, scale, error, strategy); if (mainModel.getFacets().isEmpty()) { throw new IllegalArgumentException("mainModel"); @@ -149,10 +149,10 @@ public class IcpVisitor extends MeshVisitor { * Reasonable number seems to be 10. * @param scale If {@code true}, then the scale factor is also computed. * @param error Acceptable error. A number bugger than or equal to zero. When reached, then the ICP stops. - * @param strategy One of the reduction strategies. If {@code null}, then {@link NoReductionStrategy} is used. + * @param strategy One of the reduction strategies. If {@code null}, then {@link NoUndersampling} is used. * @throws IllegalArgumentException if some parameter is wrong */ - public IcpVisitor(KdTree primaryKdTree, int maxIteration, boolean scale, double error, ReductionStrategy strategy) { + public IcpVisitor(KdTree primaryKdTree, int maxIteration, boolean scale, double error, UndersamplingStrategy strategy) { if (primaryKdTree == null) { throw new IllegalArgumentException("primaryKdTree"); } @@ -166,7 +166,7 @@ public class IcpVisitor extends MeshVisitor { this.error = error; this.maxIteration = maxIteration; this.scale = scale; - this.reductionStrategy = (strategy == null) ? new NoReductionStrategy() : strategy; + this.reductionStrategy = (strategy == null) ? new NoUndersampling() : strategy; } /** @@ -243,7 +243,7 @@ public class IcpVisitor extends MeshVisitor { true // parallel computation ); - MeshFacet reducedFacet = new ReducedMeshFacet(transformedFacet, reductionStrategy); + MeshFacet reducedFacet = new UndersampledMeshFacet(transformedFacet, reductionStrategy); int currentIteration = 0; IcpTransformation transformation = null; diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/NoReductionStrategy.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/NoUndersampling.java similarity index 69% rename from Comparison/src/main/java/cz/fidentis/analyst/icp/NoReductionStrategy.java rename to Comparison/src/main/java/cz/fidentis/analyst/icp/NoUndersampling.java index eaa87eeeb0de264c6341222576f5c71d36e9eace..4d228bbf967e6202d0ad42a6cdea159f1f3a3cdf 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/NoReductionStrategy.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/NoUndersampling.java @@ -4,11 +4,11 @@ import cz.fidentis.analyst.mesh.core.MeshPoint; import java.util.List; /** - * No reduction strategy. The triangular mesh keeps unchanged. + * No undersampling. The triangular mesh keeps unchanged. * * @author Radek Oslejsek */ -public class NoReductionStrategy extends ReductionStrategy { +public class NoUndersampling extends UndersamplingStrategy { @Override public List<MeshPoint> reduceMeshVertices(List<MeshPoint> meshPoints) { diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/RandomReductionStrategy.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/RandomStrategy.java similarity index 85% rename from Comparison/src/main/java/cz/fidentis/analyst/icp/RandomReductionStrategy.java rename to Comparison/src/main/java/cz/fidentis/analyst/icp/RandomStrategy.java index 8faed2b750c90c5b0c231bcf9cf72471df96ade0..e30e885ed6185d977d660f73a1afb2f705857de8 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/RandomReductionStrategy.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/RandomStrategy.java @@ -9,29 +9,29 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; /** - * Random reduction strategy when the mesh vertices are selected randomly. + * Random undersampling when the mesh vertices to be removed are selected randomly. * * @author Radek Oslejsek */ -public class RandomReductionStrategy extends ReductionStrategy { +public class RandomStrategy extends UndersamplingStrategy { /** - * Constructor for PERCENTAGE reduction type. + * Constructor for PERCENTAGE undersampling type. * * @param perc Percentage - a value in (0.0, 1.0> * @throws IllegalArgumentException if the input parameter is wrong */ - public RandomReductionStrategy(double perc) { + public RandomStrategy(double perc) { super(perc); } /** - * Constructor for PERCENTAGE reduction type. + * Constructor for PERCENTAGE undersampling type. * * @param max Maximal number of vertices. Must be bigger than zero * @throws IllegalArgumentException if the input parameter is wrong */ - public RandomReductionStrategy(int max) { + public RandomStrategy(int max) { super(max); } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/ReducedMeshFacet.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/UndersampledMeshFacet.java similarity index 91% rename from Comparison/src/main/java/cz/fidentis/analyst/icp/ReducedMeshFacet.java rename to Comparison/src/main/java/cz/fidentis/analyst/icp/UndersampledMeshFacet.java index 81fac838337d58ce26ae76ef7ac9f0776cc30b4c..cfc107929215cadbd1788f84644b6a5f89a94894 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/ReducedMeshFacet.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/UndersampledMeshFacet.java @@ -12,12 +12,12 @@ import javax.vecmath.Point3d; /** * Fast adapter to the MeshFacet which reduces number of vertices used for the ICP computation. - * The reduction is driven by the reduction strategy. Most of MeshFacet methods - * are not usable. + * The reduction is driven by the undersampling strategy. The most of the original + * MeshFacet methods are not usable anymore. * * @author Radek Oslejsek */ -public class ReducedMeshFacet extends MeshFacetImpl { +public class UndersampledMeshFacet extends MeshFacetImpl { private final List<MeshPoint> reducedVertices; @@ -25,9 +25,9 @@ public class ReducedMeshFacet extends MeshFacetImpl { * Constructor. * * @param origFacet Original facet - * @param strategy Reduction strategy + * @param strategy Undersampling strategy */ - public ReducedMeshFacet(MeshFacet origFacet, ReductionStrategy strategy) { + public UndersampledMeshFacet(MeshFacet origFacet, UndersamplingStrategy strategy) { if (origFacet == null) { throw new IllegalArgumentException("origFacet"); } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/ReductionStrategy.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/UndersamplingStrategy.java similarity index 54% rename from Comparison/src/main/java/cz/fidentis/analyst/icp/ReductionStrategy.java rename to Comparison/src/main/java/cz/fidentis/analyst/icp/UndersamplingStrategy.java index 78ce7e6a15bddcc1e2f11dd420b689e710a3ad2f..bb7a8a5ca417f350ce466d8be7847cdc6ae74f7c 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/ReductionStrategy.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/UndersamplingStrategy.java @@ -4,63 +4,63 @@ import cz.fidentis.analyst.mesh.core.MeshPoint; import java.util.List; /** - * Simplification strategies for the reduction of the size of triangle meshes used - * to accelerate ICP computation. + * Undersampling strategies used to reduce the size of triangle meshes and then + * accelerate ICP computation. * * @author Radek Oslejsek */ -public abstract class ReductionStrategy { +public abstract class UndersamplingStrategy { /** - * If some simplification strategy is used, then this configuration parameter + * If undersamoling is used, then this configuration parameter * encodes whether the reduction of mesh size is expressed as the percentage * of the original size (number of vertices) or as the maximal number of vertices * to be used. * * @author Radek Oslejsek */ - public enum ReductionType { + public enum UndersamplingType { PERCENTAGE, MAX_VERTICES }; - private final ReductionType reductionType; - private final double reductionLimit; + private final UndersamplingType undersamplingType; + private final double undersamplingLimit; /** - * Constructor for no reduction strategy. + * Constructor for no undersampling. */ - public ReductionStrategy() { - this.reductionType = null; - this.reductionLimit = 0.0; + public UndersamplingStrategy() { + this.undersamplingType = null; + this.undersamplingLimit = 0.0; } /** - * Constructor for PERCENTAGE reduction type. + * Constructor for PERCENTAGE undersampling type. * * @param perc Percentage - a value in (0.0, 1.0> * @throws IllegalArgumentException if the input parameter is wrong */ - public ReductionStrategy(double perc) { + public UndersamplingStrategy(double perc) { if (perc <= 0.0 || perc > 1) { throw new IllegalArgumentException("perc"); } - this.reductionType = ReductionType.PERCENTAGE; - this.reductionLimit = perc; + this.undersamplingType = UndersamplingType.PERCENTAGE; + this.undersamplingLimit = perc; } /** - * Constructor for PERCENTAGE reduction type. + * Constructor for PERCENTAGE undersampling type. * * @param max Maximal number of vertices. Must be bigger than zero * @throws IllegalArgumentException if the input parameter is wrong */ - public ReductionStrategy(int max) { + public UndersamplingStrategy(int max) { if (max <= 0) { throw new IllegalArgumentException("max"); } - this.reductionType = ReductionType.MAX_VERTICES; - this.reductionLimit = max; + this.undersamplingType = UndersamplingType.MAX_VERTICES; + this.undersamplingLimit = max; } /** @@ -72,17 +72,17 @@ public abstract class ReductionStrategy { public abstract List<MeshPoint> reduceMeshVertices(List<MeshPoint> meshPoints); /** - * Returns number of vertices to be returned after reduction. + * Returns number of vertices to be returned after undersampling. * * @param origVertices Original number of vertices - * @return number of vertices to be returned after reduction. + * @return number of vertices to be returned after undersampling. */ protected int getMaxVertices(int origVertices) { - switch (this.reductionType) { + switch (this.undersamplingType) { case PERCENTAGE: - return (int) (origVertices * this.reductionLimit); + return (int) (origVertices * this.undersamplingLimit); case MAX_VERTICES: - return Math.max((int) this.reductionLimit, origVertices); + return Math.max((int) this.undersamplingLimit, origVertices); default: return 0; } diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java index 1e67a462a263d6bb99c6c4969bce8b02f89b6382..4a3bf204468e6f88b6bb01778c99e32d5b010384 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java @@ -15,7 +15,7 @@ import com.jogamp.opengl.GLAutoDrawable; import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX; import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION_MATRIX; import cz.fidentis.analyst.icp.IcpVisitor; -import cz.fidentis.analyst.icp.RandomReductionStrategy; +import cz.fidentis.analyst.icp.RandomStrategy; //import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshModel; @@ -86,7 +86,7 @@ public class RegistrationGLEventListener extends GeneralGLEventListener{ primaryModel = model; } else { - IcpVisitor icpVisitor = new IcpVisitor(primaryModel, 10, true, 0.05, new RandomReductionStrategy(0.5)); + IcpVisitor icpVisitor = new IcpVisitor(primaryModel, 10, true, 0.05, new RandomStrategy(0.5)); for (MeshFacet f: model.getFacets()) { icpVisitor.visitMeshFacet(f); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java b/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java index 4a671cd2e1670541817c92727bd1d07948a48ca9..5ad8764032295a95dfef655c84e41e54ed8e4250 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java +++ b/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java @@ -4,8 +4,8 @@ import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFacePrivilegedCache; import cz.fidentis.analyst.icp.Icp; import cz.fidentis.analyst.icp.IcpVisitor; -import cz.fidentis.analyst.icp.NoReductionStrategy; -import cz.fidentis.analyst.icp.RandomReductionStrategy; +import cz.fidentis.analyst.icp.NoUndersampling; +import cz.fidentis.analyst.icp.RandomStrategy; import cz.fidentis.analyst.kdtree.KdTree; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.symmetry.Config; diff --git a/GUI/src/main/java/cz/fidentis/analyst/tests/IcpTests.java b/GUI/src/main/java/cz/fidentis/analyst/tests/IcpTests.java index 8c7f52f0016704f7c5109303a00ca51fa6adccfa..54d1102a4bec004a983997b7c7ae2f19685a1d30 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/tests/IcpTests.java +++ b/GUI/src/main/java/cz/fidentis/analyst/tests/IcpTests.java @@ -4,9 +4,9 @@ import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFacePrivilegedCache; import cz.fidentis.analyst.icp.IcpTransformation; import cz.fidentis.analyst.icp.IcpVisitor; -import cz.fidentis.analyst.icp.NoReductionStrategy; -import cz.fidentis.analyst.icp.RandomReductionStrategy; -import cz.fidentis.analyst.icp.ReductionStrategy; +import cz.fidentis.analyst.icp.NoUndersampling; +import cz.fidentis.analyst.icp.RandomStrategy; +import cz.fidentis.analyst.icp.UndersamplingStrategy; import cz.fidentis.analyst.kdtree.KdTree; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshModel; @@ -55,7 +55,7 @@ public class IcpTests { System.out.println("Number of files: " + faces.size()); System.out.println("File cache stats: " + fileCache); - ReductionStrategy strategy = new NoReductionStrategy(); + UndersamplingStrategy strategy = new NoUndersampling(); //ReductionStrategy strategy = new RandomReductionStrategy(0.5); System.out.println(); System.out.println("ICP " + strategy + ":"); @@ -71,7 +71,7 @@ public class IcpTests { System.out.println("Average iterations: " + (double) counter / trans.size()); } - private static Map<MeshFacet, List<IcpTransformation>> register(KdTree kdTree, List<HumanFace> faces, ReductionStrategy strategy) throws IOException { + private static Map<MeshFacet, List<IcpTransformation>> register(KdTree kdTree, List<HumanFace> faces, UndersamplingStrategy strategy) throws IOException { IcpVisitor icpVisitor = new IcpVisitor(kdTree, 10, true, 0.05, strategy); for (HumanFace face: faces) { for (MeshFacet facet: face.getMeshModel().getFacets()) {