Skip to content

Commit

Permalink
Backed out unsuccessful collapse-triangle methods; also, some small u…
Browse files Browse the repository at this point in the history
…pdates
  • Loading branch information
gwlucastrig committed Sep 25, 2018
1 parent 465718c commit dc665e4
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 425 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ For your convenience, a copy of both the laszip4j and the Commons math
packages are included with the Tinfour download.

### What version of Java is required for Tinfour? ###
Most of the Tinfour code compiles under Java 7, but some of the
utility classes required Java 8. The laszip4j library used to
read compressed lidar files also requires Java 8.
libraries requires Java 8.
Tinfour is compiled under Java 8.

### Configuring Tinfour in an IDE ###
Configuring Tinfour in an IDE is pretty simple:
Expand All @@ -126,6 +123,14 @@ Configuring Tinfour in an IDE is pretty simple:
of this option is not as critical as it once was.

### Current Work ###
Early in the Tinfour project, I made the mistake of including
compiled binaries (jar files) in the code tree. Over time, pull requests have grown
quite large. I am currently setting up a new approach in which I will move
the binaries into the Github Release feature and remove them from the main software
download.

The most recent addition to the Tinfour package is support for Voronoi Diagrams.

The current focus of Tinfour development is polishing aspects
of the Constrained Delaunay Triangulation (CDT) implementation. The CDT
is a technique for representing discontinuities in a Triangulated Irregular Network.
Expand Down
24 changes: 11 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@


<!-- PMD to run this, you will have to set up the PMD class path first.
this configuration assumes it is in a parallel folder.
this configuration assumes it is in a parallel folder.
<path id="pmd.classpath">
<fileset dir="../pmd-bin-5.4.1/lib">
<include name="*.jar"/>
Expand All @@ -95,19 +95,17 @@
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
<target name="pmd">
<pmd rulesetfiles="pmd_ruleset.xml" >
<formatter type="net.sourceforge.pmd.renderers.HTMLRenderer" toFile="pmd_results.html"/>
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${testsrc.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
<pmd rulesetfiles="pmd_ruleset.xml" >
<formatter type="net.sourceforge.pmd.renderers.HTMLRenderer" toFile="pmd_results.html"/>
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${testsrc.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
-->



</project>
Binary file modified dist/Tinfour-1.0.jar
Binary file not shown.
Binary file modified dist/TinfourViewer-1.0.jar
Binary file not shown.
160 changes: 0 additions & 160 deletions src/main/java/tinfour/semivirtual/SemiVirtualIncrementalTin.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.Iterator;
import java.util.List;
import tinfour.common.BootstrapUtility;
import tinfour.common.Circumcircle;
import tinfour.common.GeometricOperations;
import tinfour.common.IConstraint;
import tinfour.common.IIncrementalTin;
Expand All @@ -53,7 +52,6 @@
import tinfour.common.Thresholds;
import tinfour.common.TriangleCount;
import tinfour.common.Vertex;
import tinfour.common.VertexAdjustment;
import tinfour.common.VertexMergerGroup;
import tinfour.edge.QuadEdgeConstants;

Expand Down Expand Up @@ -2522,162 +2520,4 @@ private Vertex getMatchingVertex(Vertex v) {
return null;
}

/**
* Provides a means to remove very skinny triangles from the perimeter of a
* Delaunay Triangulation by adjusting the coordinates of the interior vertex
* so that it lies directly on the outer edge of the perimeter. The perimeter
* edge is replaced by two edges. The original vertex is replaced by a
* VertexAdjustment object.
* <p>
* A triangle is considered "skinny" if the ratio of the circumcircle radius
* divided by the longest edge exceeds a specified threshold value.
* <p>
* This method should be used with great caution because it has the effect of
* changing the geometry of the input vertices. In testing with a ratio of 30,
* and a set of random vertices, the mean non-zero adjustment was about 0.002
* times the average length of the triangle edges.
*
* @param thresholdRatio the threshold for adjustment
*/
public void collaspsePerimeterTriangles(double thresholdRatio) {
if (!isBootstrapped()) {
throw new IllegalStateException(
"Unable to collapse triangles, TIN is not bootstrapped");
}
if (isLocked) {
if (isDisposed) {
throw new IllegalStateException(
"Unable to collapse triangles after a call to dispose()");
} else {
throw new IllegalStateException(
"Unable to collapse triangles, TIN is locked");
}
}
Circumcircle cCircle = new Circumcircle();
List<IQuadEdge> perimeter = getPerimeter();
for (IQuadEdge p : perimeter) {
Vertex A = p.getA();
Vertex B = p.getB();
Vertex C = p.getForward().getB();
double aLen = A.getDistance(B);
double bLen = B.getDistance(C);
double cLen = C.getDistance(A);
double maxLen = aLen > bLen ? aLen : bLen;
maxLen = cLen > maxLen ? cLen : maxLen;
cCircle.compute(A, B, C);
double test = cCircle.getRadius() / maxLen;
if (test > thresholdRatio) {
collapsePerimeterEdge((SemiVirtualEdge) p);
}
}

}

/**
* Provides a means to remove very skinny triangles from the perimeter of a
* Delaunay Triangulation by adjusting the coordinates of the interior vertex
* so that it lies directly on the outer edge of the perimeter. The perimeter
* edge is replaced by two edges. The original vertex is replaced by a
* VertexAdjustment object.
* <p>
* This method should be used with great caution because it has the effect of
* changing the geometry of the input vertices. In particular, it is possible
* that this operation may result in a non-Delaunay triangle.
*
* @param e the perimeter edge
* @return true if the edge was adjusted; otherwise false
*/
@SuppressWarnings("PMD.CompareObjectsWithEquals")
boolean collapsePerimeterEdge(SemiVirtualEdge e) {
SemiVirtualEdge f = e.getForward();
SemiVirtualEdge r = e.getReverse();
SemiVirtualEdge d = e.getDual();
SemiVirtualEdge df = d.getForward();
SemiVirtualEdge dr = d.getReverse();
if (df.getB() != null) {
throw new IllegalArgumentException("Specification is not a perimeter edge");
}

Vertex A = e.getA();
Vertex B = f.getA();
Vertex C = r.getA();
double xA = B.getX() - A.getX();
double yA = B.getY() - A.getY();
double a = e.getLength();
xA /= a;
yA /= a;
double xC = C.getX() - A.getX();
double yC = C.getY() - A.getY();
double s = xA * xC + yA * yC;
if (s <= 0 || s >= 1) {
return false;
}
double x = A.getX() + s * xA;
double y = A.getY() + s * yA;
VertexAdjustment X = new VertexAdjustment(x, y, C);
// This block of diagnostic code was intended to evaluate
// the magnitude of the coordinate adjustment by dividing the
// distance moved by the average length of triangle sides.
// double bLen = B.getDistance(C);
// double cLen = C.getDistance(A);
// double mLen = (a+bLen+cLen)/3.0;
// double delta = X.getDistance(C);
// System.out.println("Delta/mean(len)= "+(delta/mLen));

// The following tests to see if the resulting vertex change
// would result in a non-Delaunay triangle. Even though a triangle
// with a very large radius is removed, it's circumcircle was
// placed far to the exterior of the triangulation and so did not
// cover any interior vertices. However, the two adjusted triangles
// will be placed to the interior of the triangulation and may include
// circumcircles that include interior vertices.
SemiVirtualEdge rdr = r.getReverseFromDual();
Vertex P = rdr.getA();
if (P != null) {
for (IQuadEdge w : rdr.pinwheel()) {
Vertex T = w.getB();
if (T != null && T != A && T != C) {
double test = geoOp.inCircle(A, X, P, T);
if (test > 0) {
return false;
}
}
}
}

SemiVirtualEdge fdr = f.getReverseFromDual();
Vertex Q = fdr.getA();
if (Q != null) {
for (IQuadEdge w : rdr.pinwheel()) {
Vertex T = w.getB();
if (T != null && T != B && T != Q) {
double test = geoOp.inCircle(X, B, Q, T);
if (test > 0) {
return false;
}
}
}
}

edgePool.deallocateEdge(e);
SemiVirtualEdge n = edgePool.allocateEdge(X, null);
SemiVirtualEdge nd = n.getDual();
r.setForward(df);
df.setForward(nd);
nd.setForward(r);
f.setForward(n);
n.setForward(dr);
dr.setForward(f);
r.setVertices(X, A);
f.setVertices(B, X);
for (IQuadEdge spoke : r.pinwheel()) {
SemiVirtualEdge q = (SemiVirtualEdge) spoke;
q.setVertices(X, q.getB());
}

//IIntegrityCheck ic = this.getIntegrityCheck();
//boolean status = ic.inspect();
//ic.printSummary(System.out);
return true;
}
}
Loading

0 comments on commit dc665e4

Please sign in to comment.