Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/decimation #10

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Processing/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<public-packages>
<package>cz.fidentis.gui</package>
<package>cz.fidentis.processing.comparison.surfaceComparison</package>
<package>cz.fidentis.processing.decimation</package>
<package>cz.fidentis.processing.exportProcessing</package>
<package>cz.fidentis.processing.featurePoints</package>
<package>cz.fidentis.processing.fileUtils</package>
Expand Down
53 changes: 53 additions & 0 deletions Processing/src/cz/fidentis/processing/decimation/Edge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.processing.decimation;

/**
* Simple wrapper that identifies a valid pair for edge collapse.
* @author Marek Zuzi
*/
public class Edge {
private int from;
private int to;

public Edge(int from, int to) {
this.from = from;
this.to = to;
}

public int getFrom() {
return from;
}

public int getTo() {
return to;
}

@Override
public int hashCode() {
int hash = 5;
int addition = from + to;
hash = 73 * hash + addition;
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Edge other = (Edge) obj;
return (this.from == other.from && this.to == other.to) || (this.from == other.to && this.to == other.from);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.processing.decimation;

import java.util.Comparator;
import java.util.Map;

/**
*
* @author Marek Zuzi
*/
public class EdgeComparator implements Comparator<Edge> {
private static final double EPS = 0.00001d;
private Map<Edge, Double> weights;

public EdgeComparator(Map<Edge, Double> weights) {
this.weights = weights;
}



@Override
public int compare(Edge o1, Edge o2) {
double w1 = weights.get(o1);
double w2 = weights.get(o2);

if(Math.abs(w1 - w2) < EPS) {
return 0;
}

if(w1 < w1) {
return 1;
} else {
return -1;
}
}
}
Loading