Skip to content
Snippets Groups Projects
Commit 9137500d authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Constructor adapted to accept set of feature point types

parent cb4bb77b
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -41,7 +41,7 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
private final HausdorffDistance distanceVisitor; private final HausdorffDistance distanceVisitor;
private final FeaturePointType featurePointType; private final Set<FeaturePointType> featurePointTypes;
private final Map<MeshFacet, List<Double>> priorities = new HashMap<>(); private final Map<MeshFacet, List<Double>> priorities = new HashMap<>();
...@@ -50,7 +50,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -50,7 +50,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* *
* @param mainFacets Facets to which distance from the visited human face's facets is to be computed. * @param mainFacets Facets to which distance from the visited human face's facets is to be computed.
* Must not be {@code null}. * Must not be {@code null}.
* @param featurePoint Feature point according to which the Hausdorff distances will be prioritized * @param featurePoints Feature points according to which the Hausdorff distances will be prioritized.
* Must not be {@code null}.
* @param strategy Strategy of the computation of distance * @param strategy Strategy of the computation of distance
* @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect * @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect
* to the normal vectors of source facets (normal vectors have to present), * to the normal vectors of source facets (normal vectors have to present),
...@@ -58,16 +59,20 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -58,16 +59,20 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores * @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores
* @throws IllegalArgumentException if some parameter is wrong * @throws IllegalArgumentException if some parameter is wrong
*/ */
public HausdorffDistancePrioritized(Set<MeshFacet> mainFacets, FeaturePointType featurePoint, Strategy strategy, boolean relativeDistance, boolean parallel) { public HausdorffDistancePrioritized(Set<MeshFacet> mainFacets, Set<FeaturePointType> featurePoints, Strategy strategy, boolean relativeDistance, boolean parallel) {
distanceVisitor = new HausdorffDistance(mainFacets, strategy, relativeDistance, parallel); distanceVisitor = new HausdorffDistance(mainFacets, strategy, relativeDistance, parallel);
featurePointType = featurePoint; if (featurePoints == null) {
throw new IllegalArgumentException("featurePoints");
}
featurePointTypes = featurePoints;
} }
/** /**
* Constructor. * Constructor.
* *
* @param mainFacet Primary facet to which distance from the visited human face's facets is to be computed. Must not be {@code null}. * @param mainFacet Primary facet to which distance from the visited human face's facets is to be computed. Must not be {@code null}.
* @param featurePoint Feature point according to which the Hausdorff distances will be prioritized * @param featurePoints Feature points according to which the Hausdorff distances will be prioritized.
* Must not be {@code null}.
* @param strategy Strategy of the computation of distance * @param strategy Strategy of the computation of distance
* @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect * @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect
* to the normal vectors of source facets (normal vectors have to present), * to the normal vectors of source facets (normal vectors have to present),
...@@ -75,8 +80,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -75,8 +80,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores * @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores
* @throws IllegalArgumentException if some parameter is wrong * @throws IllegalArgumentException if some parameter is wrong
*/ */
public HausdorffDistancePrioritized(MeshFacet mainFacet, FeaturePointType featurePoint, Strategy strategy, boolean relativeDistance, boolean parallel) { public HausdorffDistancePrioritized(MeshFacet mainFacet, Set<FeaturePointType> featurePoints, Strategy strategy, boolean relativeDistance, boolean parallel) {
this(new HashSet<>(Collections.singleton(mainFacet)), featurePoint, strategy, relativeDistance, parallel); this(new HashSet<>(Collections.singleton(mainFacet)), featurePoints, strategy, relativeDistance, parallel);
} }
/** /**
...@@ -84,7 +89,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -84,7 +89,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* *
* @param mainModel The mesh model with primary facets to which distance from the visited human face's facets is to be computed. * @param mainModel The mesh model with primary facets to which distance from the visited human face's facets is to be computed.
* Must not be {@code null} or empty. * Must not be {@code null} or empty.
* @param featurePoint Feature point according to which the Hausdorff distances will be prioritized * @param featurePoints Feature points according to which the Hausdorff distances will be prioritized.
* Must not be {@code null}.
* @param strategy Strategy of the computation of distance * @param strategy Strategy of the computation of distance
* @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect * @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect
* to the normal vectors of source facets (normal vectors have to present), * to the normal vectors of source facets (normal vectors have to present),
...@@ -92,15 +98,16 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -92,15 +98,16 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores * @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores
* @throws IllegalArgumentException if some parameter is wrong * @throws IllegalArgumentException if some parameter is wrong
*/ */
public HausdorffDistancePrioritized(MeshModel mainModel, FeaturePointType featurePoint, Strategy strategy, boolean relativeDistance, boolean parallel) { public HausdorffDistancePrioritized(MeshModel mainModel, Set<FeaturePointType> featurePoints, Strategy strategy, boolean relativeDistance, boolean parallel) {
this(new HashSet<>(mainModel.getFacets()), featurePoint, strategy, relativeDistance, parallel); this(new HashSet<>(mainModel.getFacets()), featurePoints, strategy, relativeDistance, parallel);
} }
/** /**
* Constructor. * Constructor.
* *
* @param face Human face to which distance from other human faces is to be computed. Must not be {@code null}. * @param face Human face to which distance from other human faces is to be computed. Must not be {@code null}.
* @param featurePoint Feature point according to which the Hausdorff distances will be prioritized * @param featurePoints Feature points according to which the Hausdorff distances will be prioritized.
* Must not be {@code null}.
* @param strategy Strategy of the computation of distance * @param strategy Strategy of the computation of distance
* @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect * @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect
* to the normal vectors of source facets (normal vectors have to present), * to the normal vectors of source facets (normal vectors have to present),
...@@ -108,8 +115,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -108,8 +115,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores * @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores
* @throws IllegalArgumentException if some parameter is wrong * @throws IllegalArgumentException if some parameter is wrong
*/ */
public HausdorffDistancePrioritized(HumanFace face, FeaturePointType featurePoint, Strategy strategy, boolean relativeDistance, boolean parallel) { public HausdorffDistancePrioritized(HumanFace face, Set<FeaturePointType> featurePoints, Strategy strategy, boolean relativeDistance, boolean parallel) {
this(face.getMeshModel(), featurePoint, strategy, relativeDistance, parallel); this(face.getMeshModel(), featurePoints, strategy, relativeDistance, parallel);
} }
/** /**
...@@ -117,7 +124,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -117,7 +124,8 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* *
* @param mainKdTree The KD tree to which distance from the visited human face's facets is to be computed. * @param mainKdTree The KD tree to which distance from the visited human face's facets is to be computed.
* Must not be {@code null}. * Must not be {@code null}.
* @param featurePoint Feature point according to which the Hausdorff distances will be prioritized * @param featurePoints Feature points according to which the Hausdorff distances will be prioritized.
* Must not be {@code null}.
* @param strategy Strategy of the computation of distance * @param strategy Strategy of the computation of distance
* @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect * @param relativeDistance If {@code true}, then the visitor calculates the relative distances with respect
* to the normal vectors of source facets (normal vectors have to present), * to the normal vectors of source facets (normal vectors have to present),
...@@ -125,13 +133,16 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -125,13 +133,16 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
* @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores * @param parallel If {@code true}, then the algorithm runs concurrently utilizing all CPU cores
* @throws IllegalArgumentException if some parameter is wrong * @throws IllegalArgumentException if some parameter is wrong
*/ */
public HausdorffDistancePrioritized(KdTree mainKdTree, FeaturePointType featurePoint, Strategy strategy, boolean relativeDistance, boolean parallel) { public HausdorffDistancePrioritized(KdTree mainKdTree, Set<FeaturePointType> featurePoints, Strategy strategy, boolean relativeDistance, boolean parallel) {
distanceVisitor = new HausdorffDistance(mainKdTree, strategy, relativeDistance, parallel); distanceVisitor = new HausdorffDistance(mainKdTree, strategy, relativeDistance, parallel);
featurePointType = featurePoint; if (featurePoints == null) {
throw new IllegalArgumentException("featurePoints");
}
featurePointTypes = featurePoints;
} }
public FeaturePointType getFeaturePointType() { public Set<FeaturePointType> getFeaturePointTypes() {
return featurePointType; return Collections.unmodifiableSet(featurePointTypes);
} }
/** /**
...@@ -220,23 +231,27 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor { ...@@ -220,23 +231,27 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
@Override @Override
public void visitHumanFace(HumanFace humanFace) { public void visitHumanFace(HumanFace humanFace) {
humanFace.getMeshModel().compute(distanceVisitor, inParallel()); throw new UnsupportedOperationException();
// TODO TEMPORARY BEGIN
final FeaturePoint featurePoint = humanFace.getFeaturePoints().get(featurePointType.getType()); // Needs to be updated for multiple feature points
final PrioritySphere priorityVisitor = new PrioritySphere(featurePoint.getPosition(), computeSphereRadius(humanFace)); // humanFace.getMeshModel().compute(distanceVisitor, inParallel());
humanFace.getMeshModel().compute(priorityVisitor, inParallel()); //
// final FeaturePoint featurePoint = humanFace.getFeaturePoints().get(featurePointTypes.getType());
synchronized(this) { // final PrioritySphere priorityVisitor = new PrioritySphere(featurePoint.getPosition(), computeSphereRadius(humanFace));
// Retrieve results from the visitor's internal structure // humanFace.getMeshModel().compute(priorityVisitor, inParallel());
priorities.putAll(priorityVisitor.getPriorities()); //
} // synchronized(this) {
// // Retrieve results from the visitor's internal structure
// priorities.putAll(priorityVisitor.getPriorities());
// }
// TODO TEMPORARY END
} }
private double computeSphereRadius(HumanFace humanFace) { private double computeSphereRadius(HumanFace humanFace) {
// TODO TEMPORARY // TODO TEMPORARY BEGIN
// Sphere radius needs to be computed dynamically. // Sphere radius needs to be computed dynamically.
// The best way to compute the right radius should be thought out in more depth. // The best way to compute the right radius should be thought out in more depth.
return 1; return 1;
// TODO TEMPORARY // TODO TEMPORARY END
} }
} }
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