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

Fixed name and minor refactoring

parent dc79931f
No related branches found
No related tags found
No related merge requests found
package cz.fidentis.analyst.symmetry; package cz.fidentis.analyst.symmetry;
/** /**
*
* @author Natália Bebjaková
* *
* Respresents plane with added atribute - votes, that play role * Respresents plane with added atribute - votes, that play role
* in decision about symmetry estimate of the 3D model * in decision about symmetry estimate of the 3D model
*
* @author Natalia Bebjakova
*
*/ */
public class AproxSymmetryPlane extends Plane implements Comparable<AproxSymmetryPlane> { public class ApproxSymmetryPlane extends Plane implements Comparable<ApproxSymmetryPlane> {
public Integer votes; public int votes;
/** /**
* returns number of votes that were given to plane while computing the symmetry * returns number of votes that were given to plane while computing the symmetry
* *
* @return Number of votes * @return Number of votes
*/ */
public Integer getVotes() { public int getVotes() {
return votes; return votes;
} }
/** /**
* * Constructor.
* @param plane Original plane without votes * @param plane Original plane without votes
* @param votes number of votes given to the plane * @param votes number of votes given to the plane
* @throws IllegalArgumentExpcption if the @code{plane} argument is null
*/ */
public AproxSymmetryPlane(Plane plane, int votes) { public ApproxSymmetryPlane(Plane plane, int votes) {
super(plane.a, plane.b, plane.c, plane.d); super(plane);
this.votes = votes; this.votes = votes;
} }
...@@ -36,7 +38,7 @@ public class AproxSymmetryPlane extends Plane implements Comparable<AproxSymmetr ...@@ -36,7 +38,7 @@ public class AproxSymmetryPlane extends Plane implements Comparable<AproxSymmetr
* @return number that decides which plane has more votes * @return number that decides which plane has more votes
*/ */
@Override @Override
public int compareTo(AproxSymmetryPlane other) { public int compareTo(ApproxSymmetryPlane other) {
return this.votes.compareTo(other.votes); return Integer.compare(votes, other.votes);
} }
} }
...@@ -27,6 +27,21 @@ public class Plane { ...@@ -27,6 +27,21 @@ public class Plane {
this.d = d; this.d = d;
} }
/**
* Copy constructor.
* @param plane original plane
* @throws IllegalArgumentExpcption if the @code{plane} argument is null
*/
public Plane(Plane plane) {
if (plane == null) {
throw new IllegalArgumentException();
}
a = plane.a;
b = plane.b;
c = plane.c;
d = plane.d;
}
/** /**
* Normalize the plane * Normalize the plane
*/ */
......
...@@ -122,7 +122,7 @@ public class SymmetryEstimator { ...@@ -122,7 +122,7 @@ public class SymmetryEstimator {
UIManager.put("ProgressMonitor.progressText", "Counting symmetry..."); UIManager.put("ProgressMonitor.progressText", "Counting symmetry...");
ArrayList<AproxSymmetryPlane> planes = new ArrayList<>(); ArrayList<ApproxSymmetryPlane> planes = new ArrayList<>();
//List<Vector3d> normals = calculateNormals(); //List<Vector3d> normals = calculateNormals();
if (!facet.hasVertexNormals()) { if (!facet.hasVertexNormals()) {
facet.calculateVertexNormals(); facet.calculateVertexNormals();
...@@ -209,7 +209,7 @@ public class SymmetryEstimator { ...@@ -209,7 +209,7 @@ public class SymmetryEstimator {
config.getMinNormAngleCos(), config.getMinNormAngleCos(),
boundingBox.getMaxDiag() * config.getMaxRelDistance()); boundingBox.getMaxDiag() * config.getMaxRelDistance());
planes.add(new AproxSymmetryPlane(newPlane, currentVotes)); planes.add(new ApproxSymmetryPlane(newPlane, currentVotes));
if (currentVotes > lastVotes) { if (currentVotes > lastVotes) {
lastVotes = currentVotes; lastVotes = currentVotes;
...@@ -225,7 +225,7 @@ public class SymmetryEstimator { ...@@ -225,7 +225,7 @@ public class SymmetryEstimator {
} }
Collections.sort(planes); Collections.sort(planes);
ArrayList<AproxSymmetryPlane> finalPlanes = new ArrayList<>(); ArrayList<ApproxSymmetryPlane> finalPlanes = new ArrayList<>();
for (int i = 0; i < planes.size(); i++) { for (int i = 0; i < planes.size(); i++) {
if (planes.get(i).votes == lastVotes){ if (planes.get(i).votes == lastVotes){
finalPlanes.add(planes.get(i)); finalPlanes.add(planes.get(i));
......
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