Fix each test and added READMEs
This commit is contained in:
9
application/visualizer/Test1/README.md
Normal file
9
application/visualizer/Test1/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `chunks` in the current working directory,
|
||||||
|
filled with mAABB file that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The mAABB file format contains an arbitrary number of AABBs, with one line per each:
|
||||||
|
`<min-x> <min-y> <min-z> <max-x> <max-y> <max-z>`
|
||||||
|
|
||||||
|
This program should be ran via the command line with `java -jar`. It will process the
|
||||||
|
first file it finds and print out each plane and the associated properties with each one.
|
||||||
@@ -182,7 +182,7 @@ public class MeshTest {
|
|||||||
|
|
||||||
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
||||||
this.xmin = xmin;
|
this.xmin = xmin;
|
||||||
this.ymax = ymin;
|
this.ymin = ymin;
|
||||||
this.zmin = zmin;
|
this.zmin = zmin;
|
||||||
|
|
||||||
this.xmax = xmax;
|
this.xmax = xmax;
|
||||||
|
|||||||
15
application/visualizer/Test2/README.md
Normal file
15
application/visualizer/Test2/README.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Test 2
|
||||||
|
This test requires a directory called `chunks` in the current working directory,
|
||||||
|
filled with mAABB files that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The mAABB file format contains an arbitrary number of AABBs, with one line per each:
|
||||||
|
`<min-x> <min-y> <min-z> <max-x> <max-y> <max-z>`
|
||||||
|
|
||||||
|
This program is a visual application. It will process the first file it finds, and
|
||||||
|
convert the group of AABBs to planes. It will then mesh each individual plane and
|
||||||
|
allow the user to browse:
|
||||||
|
- The final tesselated plane
|
||||||
|
- A wireframe of the tesselated plane
|
||||||
|
- A wireframe of the tesselated plane with chain calculation
|
||||||
|
- Each triangle of the final product
|
||||||
|
- The tesselation by-product values
|
||||||
@@ -150,7 +150,7 @@ public class MeshingTest2 extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// final List< Plane > planes = mesh( new File( CHUNK_DIR, "world,-10,-10" ) );
|
// final List< Plane > planes = mesh( new File( CHUNK_DIR, "world,10,-6" ) );
|
||||||
// masterPlanes.add( planes.get( 27 ) );
|
// masterPlanes.add( planes.get( 27 ) );
|
||||||
// masterPlanes.addAll( planes );
|
// masterPlanes.addAll( planes );
|
||||||
|
|
||||||
|
|||||||
9
application/visualizer/Test3/README.md
Normal file
9
application/visualizer/Test3/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `chunks` in the current working directory,
|
||||||
|
filled with mAABB files that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The mAABB file format contains an arbitrary number of AABBs, with one line per each:
|
||||||
|
`<min-x> <min-y> <min-z> <max-x> <max-y> <max-z>`
|
||||||
|
|
||||||
|
This program should be ran via the command line with `java -jar`. It will tesselate all
|
||||||
|
the files it can find as fast as possible, then output the time results.
|
||||||
@@ -237,7 +237,7 @@ public class MeshingTest3 {
|
|||||||
|
|
||||||
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
||||||
this.xmin = xmin;
|
this.xmin = xmin;
|
||||||
this.ymax = ymin;
|
this.ymin = ymin;
|
||||||
this.zmin = zmin;
|
this.zmin = zmin;
|
||||||
|
|
||||||
this.xmax = xmax;
|
this.xmax = xmax;
|
||||||
|
|||||||
10
application/visualizer/Test4/README.md
Normal file
10
application/visualizer/Test4/README.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `chunks` in the current working directory,
|
||||||
|
filled with mAABB file that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
This test will create a directory called `chunk_models` containing `ply2` files.
|
||||||
|
|
||||||
|
The mAABB file format contains an arbitrary number of AABBs, with one line per each:
|
||||||
|
`<min-x> <min-y> <min-z> <max-x> <max-y> <max-z>`
|
||||||
|
|
||||||
|
This program should be ran via the command line with `java -jar`. It will tesselate each
|
||||||
|
file and save them in `ply2` format in the `chunk_models` directory. This will take a while.
|
||||||
@@ -43,7 +43,7 @@ public class MeshingTest4 {
|
|||||||
System.out.println( "Found " + CHUNK_DIR.list().length + " files" );
|
System.out.println( "Found " + CHUNK_DIR.list().length + " files" );
|
||||||
|
|
||||||
// Omega mesh time
|
// Omega mesh time
|
||||||
// omegaMesh( CHUNK_DIR, new File( MODEL_DIR, "omega.ply" ) );
|
// omegaMesh( CHUNK_DIR, new File( MODEL_DIR, "omega" ) );
|
||||||
|
|
||||||
final long allStart = System.currentTimeMillis();
|
final long allStart = System.currentTimeMillis();
|
||||||
final AtomicInteger index = new AtomicInteger( 0 );
|
final AtomicInteger index = new AtomicInteger( 0 );
|
||||||
@@ -55,7 +55,9 @@ public class MeshingTest4 {
|
|||||||
|
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final List< Plane > planes = mesh( f, builder );
|
final List< Plane > planes = mesh( f, builder );
|
||||||
savePly2( new File( MODEL_DIR, f.getName() + ".ply" ), planes.parallelStream().flatMap( p -> process( p ).parallelStream().map( p::convert ) ).collect( Collectors.toSet() ) );
|
Collection< Facet > facets = planes.parallelStream().flatMap( p -> process( p ).parallelStream().map( p::convert ) ).collect( Collectors.toSet() );
|
||||||
|
savePly2( new File( MODEL_DIR, f.getName() + ".ply" ), facets );
|
||||||
|
saveStl( new File( MODEL_DIR, f.getName() + ".stl" ), facets );
|
||||||
|
|
||||||
final long time = System.currentTimeMillis() - start;
|
final long time = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
@@ -70,10 +72,14 @@ public class MeshingTest4 {
|
|||||||
// final File file = CHUNK_DIR.listFiles()[ i ];
|
// final File file = CHUNK_DIR.listFiles()[ i ];
|
||||||
// System.out.println( ( i + 1 ) + "/" + CHUNK_DIR.listFiles().length + ":\tMeshing " + file );
|
// System.out.println( ( i + 1 ) + "/" + CHUNK_DIR.listFiles().length + ":\tMeshing " + file );
|
||||||
// final long start = System.currentTimeMillis();
|
// final long start = System.currentTimeMillis();
|
||||||
// final List< Plane > planes = mesh( file );
|
// final StringBuilder builder = new StringBuilder();
|
||||||
// savePly2( new File( MODEL_DIR, file.getName() + ".ply" ), planes.parallelStream().flatMap( p -> process( p ).parallelStream().map( p::convert ) ).collect( Collectors.toSet() ) );
|
// final List< Plane > planes = mesh( file, builder );
|
||||||
|
// System.out.println( builder.toString() );
|
||||||
|
// Collection< Facet > facets = planes.parallelStream().flatMap( p -> process( p ).parallelStream().map( p::convert ) ).collect( Collectors.toSet() );
|
||||||
|
// savePly2( new File( MODEL_DIR, file.getName() + ".ply" ), facets );
|
||||||
|
// saveStl( new File( MODEL_DIR, file.getName() + ".stl" ), facets );
|
||||||
// long time = System.currentTimeMillis() - start;
|
// long time = System.currentTimeMillis() - start;
|
||||||
//
|
|
||||||
// System.out.println( "\tTook " + time + "ms" );
|
// System.out.println( "\tTook " + time + "ms" );
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
@@ -185,6 +191,30 @@ public class MeshingTest4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void saveStl( final File file, Collection< Facet > facets ) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
|
if ( file.exists() ) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
try ( PrintWriter writer = new PrintWriter( file ) ) {
|
||||||
|
writer.println( "solid test" );
|
||||||
|
for ( Facet f : facets ) {
|
||||||
|
writer.println( "facet normal " + f.normal.getX() + " " + f.normal.getY() + " " + f.normal.getZ() );
|
||||||
|
writer.println( "outer loop" );
|
||||||
|
for ( Vector3d p : f.points ) {
|
||||||
|
writer.println( "vertex " + p.getX() + " " + p.getY() + " " + p.getZ() );
|
||||||
|
}
|
||||||
|
writer.println( "endloop" );
|
||||||
|
writer.println( "endfacet" );
|
||||||
|
}
|
||||||
|
writer.println( "endsolid test");
|
||||||
|
} catch ( FileNotFoundException e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void omegaMesh( final File directory, final File output ) {
|
private static void omegaMesh( final File directory, final File output ) {
|
||||||
final List< AABB > allBoxes = new ArrayList< AABB >();
|
final List< AABB > allBoxes = new ArrayList< AABB >();
|
||||||
for ( int i = 0; i < directory.listFiles().length; ++i ) {
|
for ( int i = 0; i < directory.listFiles().length; ++i ) {
|
||||||
@@ -206,11 +236,13 @@ public class MeshingTest4 {
|
|||||||
System.out.println( "Starting to mesh " + builder.planes.size() + " planes" );
|
System.out.println( "Starting to mesh " + builder.planes.size() + " planes" );
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final AtomicInteger counter = new AtomicInteger();
|
final AtomicInteger counter = new AtomicInteger();
|
||||||
savePly2( output, builder.planes.parallelStream().flatMap( p -> {
|
Collection< Facet > resultFacets = builder.planes.parallelStream().flatMap( p -> {
|
||||||
final Stream< Facet > facets = process( p ).parallelStream().map( p::convert );
|
final Stream< Facet > facets = process( p ).parallelStream().map( p::convert );
|
||||||
System.out.println( "Finished " + counter.incrementAndGet() + "/" + builder.planes.size() );
|
System.out.println( "Finished " + counter.incrementAndGet() + "/" + builder.planes.size() );
|
||||||
return facets;
|
return facets;
|
||||||
} ).collect( Collectors.toSet() ) );
|
} ).collect( Collectors.toSet() );
|
||||||
|
savePly2( new File( output.getAbsolutePath() + ".ply" ), resultFacets );
|
||||||
|
saveStl( new File( output.getAbsolutePath() + ".stl" ), resultFacets );
|
||||||
System.out.println( "\tTook " + ( System.currentTimeMillis() - start ) + "ms" );
|
System.out.println( "\tTook " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +425,7 @@ public class MeshingTest4 {
|
|||||||
|
|
||||||
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
AABB( double xmin, double ymin, double zmin, double xmax, double ymax, double zmax ) {
|
||||||
this.xmin = xmin;
|
this.xmin = xmin;
|
||||||
this.ymax = ymin;
|
this.ymin = ymin;
|
||||||
this.zmin = zmin;
|
this.zmin = zmin;
|
||||||
|
|
||||||
this.xmax = xmax;
|
this.xmax = xmax;
|
||||||
|
|||||||
16
application/visualizer/Test5/README.md
Normal file
16
application/visualizer/Test5/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `facets` in the current working directory,
|
||||||
|
filled with facet files that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The facet file format contains an arbitrary number of facets, with each facet following
|
||||||
|
the given format:
|
||||||
|
```
|
||||||
|
<vertex-count> <normal-x> <normal-y> <normal-z>
|
||||||
|
<vertex-x> <vertex-y> <vertex-z>
|
||||||
|
...
|
||||||
|
```
|
||||||
|
The intial line of the vertex count and normals are followed by an extra line for each
|
||||||
|
vertex, containing the x, y and z coordinates of that vertex.
|
||||||
|
|
||||||
|
This program should be ran via the command line with `java -jar`. It will tesselate all
|
||||||
|
the files it can find as fast as possible, then output the time results.
|
||||||
22
application/visualizer/Test6/README.md
Normal file
22
application/visualizer/Test6/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `facets` in the current working directory,
|
||||||
|
filled with facet files that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The facet file format contains an arbitrary number of facets, with each facet following
|
||||||
|
the given format:
|
||||||
|
```
|
||||||
|
<vertex-count> <normal-x> <normal-y> <normal-z>
|
||||||
|
<vertex-x> <vertex-y> <vertex-z>
|
||||||
|
...
|
||||||
|
```
|
||||||
|
The intial line of the vertex count and normals are followed by an extra line for each
|
||||||
|
vertex, containing the x, y and z coordinates of that vertex.
|
||||||
|
|
||||||
|
This program is a visual application. It will process the first file it finds, and
|
||||||
|
convert the group of AABBs to planes. It will then mesh each individual plane and
|
||||||
|
allow the user to browse:
|
||||||
|
- The final tesselated plane
|
||||||
|
- A wireframe of the tesselated plane
|
||||||
|
- A wireframe of the tesselated plane with chain calculation
|
||||||
|
- Each triangle of the final product
|
||||||
|
- The tesselation by-product values
|
||||||
16
application/visualizer/Test7/README.md
Normal file
16
application/visualizer/Test7/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Test 1
|
||||||
|
This test requires a directory called `polygons` in the current working directory,
|
||||||
|
filled with polygon files that follow the naming convention: `<string>,<int>,<int>`.
|
||||||
|
|
||||||
|
The polygon file format contains an arbitrary number of 2d polygons, with each polygon
|
||||||
|
following the given format:
|
||||||
|
```
|
||||||
|
<vertex-count>
|
||||||
|
<vertex-x> <vertex-y>
|
||||||
|
...
|
||||||
|
```
|
||||||
|
The intial line of the vertex count are followed by an extra line for each
|
||||||
|
vertex, containing the x and y coordinates of that vertex.
|
||||||
|
|
||||||
|
This program should be ran via the command line with `java -jar`. It will tesselate all
|
||||||
|
the files it can find as fast as possible, then output the time results.
|
||||||
@@ -66,7 +66,7 @@ public class Plane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches( Vector3d normal, Vector3d point ) {
|
public boolean matches( Vector3d normal, Vector3d point ) {
|
||||||
return Math.abs( this.normal.dot( normal ) ) > 0.99 && Math.abs( new Vector3d( this.point ).subtract( point ).dot( normal ) ) < 0.01;
|
return Math.abs( this.normal.dot( normal ) ) > 0.999 && Math.abs( new Vector3d( this.point ).subtract( point ).dot( normal ) ) < 0.00001;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Matrix3d getProjectionMatrix() {
|
private Matrix3d getProjectionMatrix() {
|
||||||
|
|||||||
@@ -131,6 +131,24 @@ public class Vector3d {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Vector3d other = (Vector3d) obj;
|
||||||
|
if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
|
||||||
|
return false;
|
||||||
|
if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
|
||||||
|
return false;
|
||||||
|
if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Vector3d{x=" + x + ",y=" + y + ",z=" + z + "}";
|
return "Vector3d{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||||
|
|||||||
@@ -481,6 +481,8 @@ public class Mesh< T extends Region > {
|
|||||||
for ( final HalfEdge edge : vertex ) {
|
for ( final HalfEdge edge : vertex ) {
|
||||||
// Resolve any intersections belonging to this edge which are still
|
// Resolve any intersections belonging to this edge which are still
|
||||||
// being scanned, but only if it's a new edge
|
// being scanned, but only if it's a new edge
|
||||||
|
// This is incredibly slow the more edges that are available at the current position...
|
||||||
|
// TODO Need to speed this up
|
||||||
if ( !scannedEdges.contains( edge ) && !scannedVertices.contains( edge.getDest() ) ) {
|
if ( !scannedEdges.contains( edge ) && !scannedVertices.contains( edge.getDest() ) ) {
|
||||||
resolveEdgeIntersections( vertexSet, scannedEdges, edge );
|
resolveEdgeIntersections( vertexSet, scannedEdges, edge );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user