diff --git a/build.gradle b/build.gradle index 97154fa..51500bd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,10 @@ apply plugin: 'java' +apply plugin: 'maven' +apply plugin: 'signing' + +group = 'net.ricebean.tools.pointcloud' +archivesBaseName = "PointCloudCrust" +version = '0.1' repositories { jcenter() @@ -7,3 +13,68 @@ repositories { dependencies { testCompile 'junit:junit:4.12' } + +artifacts { + archives jar + + archives javadocJar + archives sourcesJar +} + +signing { + sign configurations.archives +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from tasks.javadoc.destinationDir +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' +} + +uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.project { + name 'PointCloudCrust' + packaging 'jar' + // optionally artifactId can be defined here + description 'Implementation of the PointCloudCrust Algorithm.' + url 'https://github.com/ricebean-net/PointCloudCrust' + + scm { + connection 'scm:git@github.com:ricebean-net/PointCloudCrust.git' + developerConnection 'scm:git@github.com:ricebean-net/PointCloudCrust.git' + url 'https://github.com/ricebean-net/PointCloudCrust.git' + } + + licenses { + license { + name 'The Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'meixi' + name 'Stefan Meissner' + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustFactory.java b/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustFactory.java new file mode 100644 index 0000000..e4f27c2 --- /dev/null +++ b/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustFactory.java @@ -0,0 +1,20 @@ +package net.ricebean.tools.pointcloud; + +import net.ricebean.tools.pointcloud.model.Vector; + +import java.util.List; + +/** + * Factory class for getting an PointCloudCrust implementation. + */ +public class PointCloudCrustFactory { + + /** + * Get a new instance of the PointCloudCrust Algorithm. + * @param pointCloud The point cloud for initializing. + * @return A initialized instance of the point cloud crust. + */ + public static PointCloudCrust newInstance(List pointCloud) { + return new PointCloudCrustImpl(pointCloud); + } +} diff --git a/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustImpl.java b/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustImpl.java index fb227d9..a6da2ec 100644 --- a/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustImpl.java +++ b/src/main/java/net/ricebean/tools/pointcloud/PointCloudCrustImpl.java @@ -12,7 +12,7 @@ * * @Author: Stefan Meissner */ -public class PointCloudCrustImpl implements PointCloudCrust { +class PointCloudCrustImpl implements PointCloudCrust { private final Vector[] pointCloud; @@ -28,7 +28,7 @@ private PointCloudCrustImpl() { * * @param pointCloud The point cloud. */ - public PointCloudCrustImpl(List pointCloud) { + PointCloudCrustImpl(List pointCloud) { this.pointCloud = pointCloud.toArray(new Vector[]{}); } @@ -41,13 +41,10 @@ public PointCloudCrustImpl(List pointCloud) { @Override public List computeCrustTriangles(float radius) { - // iterate over all triangles - long startTime = System.currentTimeMillis(); - List triangles = new ArrayList<>(pointCloud.length); - - IntStream.range(0, pointCloud.length).forEach(corner_1 -> { + // iterate over all triangles + IntStream.range(0, pointCloud.length).parallel().forEach(corner_1 -> { for (int corner_2 = corner_1 + 1; corner_2 < pointCloud.length; corner_2++) { for (int corner_3 = corner_2 + 1; corner_3 < pointCloud.length; corner_3++) { @@ -72,19 +69,8 @@ public List computeCrustTriangles(float radius) { } } } - - System.out.println( - String.format( - "Compute point %d of %d. - Triangles found: %d", - corner_1, - pointCloud.length, - triangles.size()) - ); }); - System.out.println("Time: " + (System.currentTimeMillis() - startTime) + " ms"); - System.out.println("Number of Triangles: " + triangles.size()); - return triangles; } diff --git a/src/test/java/net/ricebean/tools/pointcloud/PointCloudCrustImplTest.java b/src/test/java/net/ricebean/tools/pointcloud/PointCloudCrustImplTest.java index 557f96e..f0579d0 100644 --- a/src/test/java/net/ricebean/tools/pointcloud/PointCloudCrustImplTest.java +++ b/src/test/java/net/ricebean/tools/pointcloud/PointCloudCrustImplTest.java @@ -296,7 +296,8 @@ private void csvOutput(List pointCloud, List triangles) throws // point cloud if (pointCloud.size() > i) { Vector v = pointCloud.get(i); - bw.write(String.format("%f\t%f\t%f\t%s\t", v.getX(), v.getY(), v.getZ(), v.getName())); + String color = "#cccccc"; + bw.write(String.format("%f\t%f\t%f\t%s\t%s\t", v.getX(), v.getY(), v.getZ(), v.getName(), color)); } else { bw.write("\t\t\t"); } @@ -304,13 +305,12 @@ private void csvOutput(List pointCloud, List triangles) throws // triangles if (triangles.size() > i) { Triangle t = triangles.get(i); - bw.write(String.format("%d\t%d\t%d\t", t.getCorner_1(), t.getCorner_2(), t.getCorner_3())); + String color = "#cccccc"; // computeColorFromLab(triangle); + bw.write(String.format("%d\t%d\t%d\t%s\t", t.getCorner_1(), t.getCorner_2(), t.getCorner_3(), color)); } else { bw.write("\t\t\t"); } - bw.write("#cccccc\t2"); - // new line bw.newLine(); }