diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java.orig b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java.orig deleted file mode 100644 index 99b8d147b9d3671c32cd58f07c22e250cff710a7..0000000000000000000000000000000000000000 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java.orig +++ /dev/null @@ -1,202 +0,0 @@ -package cz.fidentis.analyst.visitors.mesh; - -import cz.fidentis.analyst.mesh.MeshVisitor; -import cz.fidentis.analyst.mesh.core.MeshFacet; -import cz.fidentis.analyst.mesh.core.MeshPoint; -import cz.fidentis.analyst.mesh.core.MeshPointImpl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.vecmath.Vector3d; - -/** - * This visitor finds the distance between the given 3D point and a mesh facet. - * The minimal distance is computed between the 3D point and triangles of the mesh facet. - * This method is more precise, but slower. - * <p> - * The visitor returns the minimal distance and the closest triangle. - * However, a single visitor can be applied to multiple mesh facets. - * If closest point lies on the boundary edge (the edge "shared" by two independet - * mesh facets), then the visitor has to include both facets in result. In case of - * "shared" vertex more than two facets could be included. - * Therefore, the visitor returns a list of closest facets instead of just a single facet. - * <ul> - * <li>{@code MeshFacet f = getClosestFacets().get(i)} gives you the i-th closest facet.</li> - * <li>{@code int n = getClosestTriangles().get(i)} gives you the index of the closest - * triangle in the i-th facet.</li> - * <li>Then you can use the methods of {@link cz.fidentis.analyst.mesh.core.MeshFacet} and - * {@link cz.fidentis.analyst.mesh.core.CornerTable} to retrieve topological details - * of the triangle.</li> - * </ul> - * This visitor is thread-safe. A single instance of the visitor can be used - * to inspect multiple mesh models or facets simultaneously. - * </p> - * - * @author Matej Lukes - * @author Radek Oslejsek -*/ -public class DistanceToTrianglesVisitor extends MeshVisitor { - - private boolean relativeDist; - private MeshPoint myPoint; - private int sign = 1; - - private double distance = Double.POSITIVE_INFINITY; - private final List<MeshFacet> closestFacets = new ArrayList<>(); - private final List<Integer> closestTriangles = new ArrayList<>(); - - /** - * @param point A 3D point from which distance is computed. Must not be {@code null} - * @param relativeDistance If {@true}, the visitor calculates the distances with respect - * to the normals of the 3D point (the normal has to be present), - * i.e., we can get negative distance. - * @param concurrently If {@code true} and this visitor is thread-safe, then - * the visitor is applied concurrently on multiple mesh facets. - * @throws IllegalArgumentException if some parametr is wrong - */ - public DistanceToTrianglesVisitor(MeshPoint point, boolean relativeDistance, boolean concurrently) { - super(concurrently); - if (point == null) { - throw new IllegalArgumentException("point"); - } - if (point.getNormal() == null && relativeDistance) { - throw new IllegalArgumentException("normal required for relative distance"); - } - this.myPoint = point; - this.relativeDist = relativeDistance; - } - - /** - * @param point A 3D point from which distance is computed. Must not be {@code null} - * @param concurrently If {@code true} and this visitor is thread-safe, then - * the visitor is applied concurrently on multiple mesh facets. - * @throws IllegalArgumentException if some parametr is wrong - */ - public DistanceToTrianglesVisitor(Vector3d point, boolean concurrently) { - this (new MeshPointImpl(point, null, null), false, concurrently); - } - - @Override - protected void visitMeshFacet(MeshFacet facet) { - Vector3d my = myPoint.getPosition(); - - DistanceToVerticesVisitor vis = new DistanceToVerticesVisitor(myPoint, relativeDist, false); - facet.accept(vis); - - List<MeshFacet> clFacets = vis.getClosestFacets(); - List<Integer> clVertices = vis.getClosestVertices(); - - for (int i = 0; i < clVertices.size(); i++) { // for all found closest vertices - MeshFacet closestF = clFacets.get(i); - int closestI = clVertices.get(i); - - Vector3d projection = closestF.getClosestAdjacentPoint(my, closestI); - Vector3d aux = new Vector3d(projection); - aux.sub(myPoint.getPosition()); - - double dist = aux.length(); - - synchronized (this) { - if (dist > distance) { - continue; - } - if (dist < distance) { // new closest point - sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1; - distance = dist; - closestFacets.clear(); - closestTriangles.clear(); - closestFacets.add(closestF); - closestTriangles.add(closestI); - } else { // the same distance - if (!closestFacets.contains(closestF)) { - closestFacets.add(closestF); - closestTriangles.add(closestI); - } - } - } - } - } - - /** - * Returns distance to the closest mesh point. - * - * @return distance to the closest mesh point, - * {@code Double.POSITIVE_INFINITY} if no distance has been calculated - */ - public double getDistance() { - return relativeDist ? sign * distance : distance; - } - - /** - * Returns indeces to the closest elements (points or triangles) of corresponding facet. - * - * @return indeces to the closest elements (points or triangles) of corresponding facet, - * {@code null} if no search has been performed - */ - public List<Integer> getClosestTriangles() { - return Collections.unmodifiableList(closestTriangles); - } - - /** - * Returns the closest mesh facets (containing the closest mesh points). - * - * @return the closest mesh facets - */ - public List<MeshFacet> getClosestFacets() { - return Collections.unmodifiableList(closestFacets); - } - - /** - * Returns {@code true} if the distance is computed as relative - * (with possibly negative values). - * - * @return {@code true} if the distance is computed as relative. - */ - public boolean usesRelativeDist() { - return relativeDist; - } - -<<<<<<< HEAD - @Override - public MeshVisitor clone() { - return new DistanceToTrianglesVisitor(myPoint, relativeDist, concurrently()); - } - - - /** - * Computes the minimal distance and if the mesh point is closer that - * the closest point found so far, then updates the visitor's state. - * - * @param pointOnSurface Point on the mesh facet (either mesh vertex or projection point) - * @param facet Mesh facet - * @param index Index of the mesh vertex or triangle in the mesh facet (depending on the distance strategy) - */ - protected void checkAndUpdateDistance(Vector3d pointOnSurface, MeshFacet facet, int index) { - Vector3d aux = new Vector3d(pointOnSurface); - aux.sub(myPoint.getPosition()); - sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1; - double dist = aux.length(); - - synchronized (this) { - if (dist > distance) { - return; - } - - if (dist < distance) { // new closest point - distance = dist; - closestFacets.clear(); - closestTriangles.clear(); - closestFacets.add(facet); - closestTriangles.add(index); - } else { // the same distance - if (!closestFacets.contains(facet)) { - closestFacets.add(facet); - closestTriangles.add(index); - } - } - } - } - -======= ->>>>>>> 9ed9d37f9816981263615da1a66840742a79bf5f -} diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java.orig b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java.orig deleted file mode 100644 index 84c63356f8787e16c14fd0755541f9830d7dd109..0000000000000000000000000000000000000000 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java.orig +++ /dev/null @@ -1,199 +0,0 @@ -package cz.fidentis.analyst.visitors.mesh; - -import cz.fidentis.analyst.mesh.MeshVisitor; -import cz.fidentis.analyst.mesh.core.MeshFacet; -import cz.fidentis.analyst.mesh.core.MeshPoint; -import cz.fidentis.analyst.mesh.core.MeshPointImpl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.vecmath.Vector3d; - -/** - * This visitor finds the distance between the given 3D point and a mesh facet. - * The minimal distance is computed between the 3D point and - * vertices of the mesh facet. - * <p> - * The visitor returns the minimal distance and the closest vertex. - * However, a single visitor can be applied to multiple mesh facets. - * If closest vertex is boudary between neighbouring mesh facets (multiple - * facets have a vertex with the same coordinates), then the visitor has to - * include all these facets in result. Therefore, the visitor returns - * a list of closest facets instead of just a single facet. - * </p> - * <p> - * <ul> - * <li>{@code MeshFacet f = getClosestFacets().get(i)} gives you the i-th closest facet.</li> - * <li>{@code int n = getClosestVertices().get(i)} gives you the index of the closest - * vertex in the i-th facet.</li> - * <li>Then you can use the methods of {@link cz.fidentis.analyst.mesh.core.MeshFacet} and - * {@link cz.fidentis.analyst.mesh.core.CornerTable} to retrieve topological details - * of the vertex.</li> - * </ul> - * </p> - * <p> - * This visitor is thread-safe. A single instance of the visitor can be used - * to inspect multiple mesh models or facets simultaneously. - * </p> - * - * @author Matej Lukes - * @author Radek Oslejsek - */ -public class DistanceToVerticesVisitor extends MeshVisitor { - - private boolean relativeDist; - private MeshPoint myPoint; - private int sign = 1; - - private double distance = Double.POSITIVE_INFINITY; - private final List<MeshFacet> closestFacets = new ArrayList<>(); - private final List<Integer> closestVertices = new ArrayList<>(); - - /** - * @param point A 3D point from which distance is computed. Must not be {@code null} - * @param relativeDistance If {@true}, the visitor calculates the distances with respect - * to the normals of the 3D point (the normal has to be present), - * i.e., we can get negative distance. - * @param concurrently If {@code true} and this visitor is thread-safe, then - * the visitor is applied concurrently on multiple mesh facets. - * @throws IllegalArgumentException if some parametr is wrong - */ - public DistanceToVerticesVisitor(MeshPoint point, boolean relativeDistance, boolean concurrently) { - super(concurrently); - if (point == null) { - throw new IllegalArgumentException("point"); - } - if (point.getNormal() == null && relativeDistance) { - throw new IllegalArgumentException("normal required for relative distance"); - } - this.myPoint = point; - this.relativeDist = relativeDistance; - } - - /** - * @param point A 3D point from which distance is computed. Must not be {@code null} - * @param concurrently If {@code true} and this visitor is thread-safe, then - * the visitor is applied concurrently on multiple mesh facets. - * @throws IllegalArgumentException if some parametr is wrong - */ - public DistanceToVerticesVisitor(Vector3d point, boolean concurrently) { - this (new MeshPointImpl(point, null, null), false, concurrently); - } - - @Override - protected void visitMeshFacet(MeshFacet facet) { - List<MeshPoint> vertices = facet.getVertices(); - for (int i = 0; i < vertices.size(); i++) { - - Vector3d pointOnSurface = vertices.get(i).getPosition(); - Vector3d aux = new Vector3d(pointOnSurface); - aux.sub(myPoint.getPosition()); - double dist = aux.length(); - - synchronized (this) { - if (dist > distance) { - continue; - } - if (dist < distance) { // new closest point - distance = dist; - sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1; - closestFacets.clear(); - closestVertices.clear(); - closestFacets.add(facet); - closestVertices.add(i); - } else { // the same distance - if (!closestFacets.contains(facet)) { - closestFacets.add(facet); - closestVertices.add(i); - } - } - } - } - } - - /** - * Returns distance to the closest mesh point. - * - * @return distance to the closest mesh point, - * {@code Double.POSITIVE_INFINITY} if no distance has been calculated - */ - public double getDistance() { - return relativeDist ? sign * distance : distance; - } - - /** - * Returns indeces to the closest elements (points or triangles) of corresponding facet. - * - * @return indeces to the closest elements (points or triangles) of corresponding facet, - * {@code null} if no search has been performed - */ - public List<Integer> getClosestVertices() { - return Collections.unmodifiableList(closestVertices); - } - - /** - * Returns the closest mesh facets (containing the closest mesh points). - * - * @return the closest mesh facets - */ - public List<MeshFacet> getClosestFacets() { - return Collections.unmodifiableList(closestFacets); - } - - /** - * Returns {@code true} if the distance is computed as relative - * (with possibly negative values). - * - * @return {@code true} if the distance is computed as relative. - */ - public boolean usesRelativeDist() { - return relativeDist; - } - -<<<<<<< HEAD - @Override - public MeshVisitor clone() { - return new DistanceToVerticesVisitor(myPoint, relativeDist, concurrently()); - } - - - /*********************************************************** - * PROTECTED METHODS - ***********************************************************/ - - /** - * Computes the minimal distance and if the mesh point is closer that - * the closest point found so far, then updates the visitor's state. - * - * @param pointOnSurface Point on the mesh facet (either mesh vertex or projection point) - * @param facet Mesh facet - * @param index Index of the mesh vertex or triangle in the mesh facet (depending on the distance strategy) - */ - protected void checkAndUpdateDistance(Vector3d pointOnSurface, MeshFacet facet, int index) { - Vector3d aux = new Vector3d(pointOnSurface); - aux.sub(myPoint.getPosition()); - double dist = aux.length(); - - synchronized (this) { - if (dist > distance) { - return; - } - - if (dist < distance) { // new closest point - distance = dist; - sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1; - closestFacets.clear(); - closestVertices.clear(); - closestFacets.add(facet); - closestVertices.add(index); - } else { // the same distance - if (!closestFacets.contains(facet)) { - closestFacets.add(facet); - closestVertices.add(index); - } - } - } - } -======= ->>>>>>> 9ed9d37f9816981263615da1a66840742a79bf5f -} diff --git a/MeshModel/src/main/java/cz/fidentis/analyst/kdtree/KdTreeVisitor.java.orig b/MeshModel/src/main/java/cz/fidentis/analyst/kdtree/KdTreeVisitor.java.orig deleted file mode 100644 index 6facda6d2cb2b8f6d0ad87f71583396a58cc7e1f..0000000000000000000000000000000000000000 --- a/MeshModel/src/main/java/cz/fidentis/analyst/kdtree/KdTreeVisitor.java.orig +++ /dev/null @@ -1,137 +0,0 @@ -package cz.fidentis.analyst.kdtree; - -import java.util.concurrent.Callable; - -/** -<<<<<<< HEAD - * A functor. When instantiated, it can be gradually applied to multiple k-d trees. - * It inspects the state of the tree one by one, and (cumulatevely) computes results. - * <p> - * Implement this interface whenever you want to define new algorithm over a k-d tree. - * </p> - * <p> - * The visitor can be instatiated either as sequential and concurrent. - * The {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} inspection method - * of a sequential visitor is applied immediately. On the contrary, if the - * visitor is concurrent and thread-safe, then the method only stores the inpected - * k-d tree for later concurrent inspection. To trigger the tree inspection, - * a {@link java.util.concurrent.ExecutorService} has to be used calling - * the {@link cz.fidentis.analyst.mesh.mesh.MeshVisitor#call} method asynchronously - * and then waiting for the results of all triggered visitors. - * </p> - * <p> - * All visitors have to be cloneable. A returned clone represents a visitor in - * the initial state, i.e., only the configuration options provided to the constructor - * are cloned while the computation state is set to initial values. - * </p> - * -======= - * A functional object. When instantiated, it can be applied to multiple KD trees. - * It inspects the state of the KD tree one by one, and (cumulatevely) computes results. - * <p> - * Implement this interface whenever you want to define new algorithm over a KD tree. - * </p> - * <p> - * The visitor can be instatiated either as sequential or concurrent. - * The {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} inspection method - * of a sequential visitor is applied immediately. On the contrary, if the - * visitor is concurrent and thread-safe, then the method only stores the inspected - * KD tree for later concurrent inspection. To trigger the tree inspection, - * a {@link java.util.concurrent.ExecutorService} has to be used to call - * the {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#call} method asynchronously - * and then wait for results of all triggered visitors. - * </p> - * ->>>>>>> 9ed9d37f9816981263615da1a66840742a79bf5f - * @author Daniel Schramm - */ -public abstract class KdTreeVisitor implements Callable<KdTreeVisitor>, Cloneable { - - private final boolean concurrently; - - /** - * KD tree stored temporarily for later cuncurrent inspection via - * the {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} method. - */ - private KdTree kdTree; - - /** - * Constructor. - * - * @param concurrently If {@code true} and the visitor is thread-safe, then - * the visitor is created as concurent - * (the {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} is not executed - * immediately but postponed for concurrent asynchronous execution). - * Otherwise, the visitor is created as sequential - * (the {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} is executed immediately.) - */ - public KdTreeVisitor(boolean concurrently) { - this.concurrently = concurrently; - } - - /** - * Returns {@code true} if the implementation is thread-safe and then - * <b>a single visitor instance</b> can be applied to multiple KD trees simultaneously. - * If the visitor is not thread-safe, the concurrent inspection - * via the {@link cz.fidentis.analyst.kdtree.KdTreeVisitor#visit} - * is still possible, but with multiple visitor instances - one for each tree. - * <p> - * Thread-safe implementation means that any read or write from/to the visitor's - * state is implemented as {@code synchronized}. - * </p> - * - * @return {@code true} if the implementation is thread-safe. - */ - public boolean isThreadSafe() { - return true; - } - - /** - * Returns {@code true} if this visitor is to be applied concurrently, i.e., - * if the concurrency parameter was set and the visitor is thread-safe. - * - * @return {@code true} if this visitor is to be applied concurrently, i.e., - * if the concurrency parameter was set and the visitor is thread-safe. - */ - public boolean concurrently() { - return this.concurrently && isThreadSafe(); - } - - /** - * The inspection method to be implememted by specific visitors. - * - * @param kdTree KD tree to be visited - */ - protected abstract void visitKdTree(KdTree kdTree); - - /** - * The main visitation method, either invoked immediately (if the visitor - * was created a sequentional) or postponed to later parallel execution - * (if the visitor is thread-safe and has been created a concurrent). - * - * @param kdTree KD tree to be visited - */ - public void visit(KdTree kdTree) { - if (concurrently && isThreadSafe()) { - this.kdTree = kdTree; - } else { - visitKdTree(kdTree); - } - } - - @Override - public KdTreeVisitor call() throws Exception { - visitKdTree(kdTree); - return this; - } - - /** - * Creates and returns a copy of this visitor. A returned clone represents a visitor in - * the initial state, i.e., only the configuration options provided to the constructor - * are cloned while the computation state is set to initial values. - * - * @return - */ - @Override - public abstract Object clone(); -} diff --git a/MeshModel/src/main/java/cz/fidentis/analyst/mesh/MeshVisitor.java.orig b/MeshModel/src/main/java/cz/fidentis/analyst/mesh/MeshVisitor.java.orig deleted file mode 100644 index 40018b8d972edd5814c2283634b97cb94295cece..0000000000000000000000000000000000000000 --- a/MeshModel/src/main/java/cz/fidentis/analyst/mesh/MeshVisitor.java.orig +++ /dev/null @@ -1,131 +0,0 @@ -package cz.fidentis.analyst.mesh; - -import cz.fidentis.analyst.mesh.core.MeshFacet; -import java.util.concurrent.Callable; - -/** - * A functor. When instantiated, it can be gradually applied to multiple mesh facets. - * It inspects the state of the mesh facets one by one, and (cumulatevely) computes results. - * <p> - * Implement this interface whenever you want to define new algorithm over a mesh. - * </p> - * <p> -<<<<<<< HEAD - * The visitor can be instatiated either as sequential and concurrent. - * The {@link cz.fidentis.analyst.mesh.MeshVisitor#visit} inspection method - * of a sequential visitor is applied immediately. On the contrary, if the - * visitor is concurrent and thread-safe, then the method only stores the inpected - * mesh facet for later concurrent inspection. To trigger the facet inspection, - * a {@link java.util.concurrent.ExecutorService} has to be used calling - * the {@link cz.fidentis.analyst.mesh.mesh.MeshVisitor#call} method asynchronously - * and then waiting for the results of all triggered visitors. - * </p> - * <p> - * All visitors have to be cloneable. A returned clone represents a visitor in - * the initial state, i.e., only the configuration options provided to the constructor - * are cloned while the computation state is set to initial values. -======= - * The visitor can be instatiated either as sequential or concurrent. - * The {@link cz.fidentis.analyst.mesh.mesh.MeshVisitor#visit} inspection method - * of a sequential visitor is applied immediately. On the contrary, if the - * visitor is concurrent and thread-safe, then the method only stores the inspected - * mesh facet for later concurrent inspection. To trigger the facet inspection, - * a {@link java.util.concurrent.ExecutorService} has to be used to call - * the {@link cz.fidentis.analyst.mesh.MeshVisitor#call} method asynchronously - * and then wait for results of all triggered visitors. ->>>>>>> 9ed9d37f9816981263615da1a66840742a79bf5f - * </p> - * - * @author Radek Oslejsek - */ -public abstract class MeshVisitor implements Callable<MeshVisitor>, Cloneable { - - private boolean concurrently; - - /** - * Facet stored temporarily for later cuncurrent inspection via - * the {@link cz.fidentis.analyst.mesh.MeshVisitor#call} method. - */ - private MeshFacet facet; - - - /** - * Constructor. - * - * @param concurrently If {@code true} and the visitor is thread-safe, then - * the visitor is created as concurent - * (the {@link cz.fidentis.analyst.mesh.MeshVisitor#visit} is not executed - * immediately but postponed for concurrent asynchronous execution). - * Otherwise, the visitor is created as sequential - * (the {@link cz.fidentis.analyst.mesh.MeshVisitor#visit} is executed immediately.) - */ - public MeshVisitor(boolean concurrently) { - this.concurrently = concurrently; - } - - /** - * Returns {@code true} if the implementation is thread-safe and then - * <b>a single visitor instance</b> can be applied to multiple mesh facets simultaneously. - * If the visitor is not thread-safe, the concurrent inspection - * via the {@link cz.fidentis.analyst.mesh.MeshVisitor#visit} - * is still possible, but with multiple visitor instances - one for each facet. - * <p> - * Thread-safe implementation means that any read or write from/to the visitor's - * state is implemented as {@code synchronized}. - * </p> - * - * @return {@code true} if the implementation is thread-safe. - */ - public boolean isThreadSafe() { - return true; - } - - /** - * Returns {@code true} if this visitor is to be applied concurrently, i.e., - * if the concurrency parameter was set and the visitor is thread-safe. - * - * @return {@code true} if this visitor is to be applied concurrently, i.e., - * if the concurrency parameter was set and the visitor is thread-safe. - */ - public boolean concurrently() { - return this.concurrently && isThreadSafe(); - } - - /** - * The inspection method to be implememted by specific visitors. - * - * @param facet Mesh facet to be visited. - */ - protected abstract void visitMeshFacet(MeshFacet facet); - - /** - * The main visitation method, either invoked immediately (if the visitor - * was created a sequentional) or postponed to later parallel execution - * (if the visitor is thread-safe and has been created a concurrent). - * - * @param facet Mesh facet to be visited. - */ - public void visit(MeshFacet facet) { - if (concurrently && isThreadSafe()) { - this.facet = facet; - } else { - visitMeshFacet(facet); - } - } - - @Override - public MeshVisitor call() throws Exception { - visitMeshFacet(facet); - return this; - } - - /** - * Creates and returns a copy of this visitor. A returned clone represents a visitor in - * the initial state, i.e., only the configuration options provided to the constructor - * are cloned while the computation state is set to initial values. - * - * @return - */ - @Override - public abstract MeshVisitor clone(); -}