Skip to content

Commit

Permalink
Further clean up
Browse files Browse the repository at this point in the history
Implementation of the factory pattern.
  • Loading branch information
meiXXI committed Jan 22, 2017
1 parent 8c3d6a8 commit 6cd7fa0
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 22 deletions.
71 changes: 71 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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:[email protected]:ricebean-net/PointCloudCrust.git'
developerConnection 'scm:[email protected]: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'
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Vector> pointCloud) {
return new PointCloudCrustImpl(pointCloud);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @Author: Stefan Meissner
*/
public class PointCloudCrustImpl implements PointCloudCrust {
class PointCloudCrustImpl implements PointCloudCrust {

private final Vector[] pointCloud;

Expand All @@ -28,7 +28,7 @@ private PointCloudCrustImpl() {
*
* @param pointCloud The point cloud.
*/
public PointCloudCrustImpl(List<Vector> pointCloud) {
PointCloudCrustImpl(List<Vector> pointCloud) {
this.pointCloud = pointCloud.toArray(new Vector[]{});
}

Expand All @@ -41,13 +41,10 @@ public PointCloudCrustImpl(List<Vector> pointCloud) {
@Override
public List<Triangle> computeCrustTriangles(float radius) {

// iterate over all triangles
long startTime = System.currentTimeMillis();

List<Triangle> 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++) {

Expand All @@ -72,19 +69,8 @@ public List<Triangle> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,21 @@ private void csvOutput(List<Vector> pointCloud, List<Triangle> 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");
}

// 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();
}
Expand Down

0 comments on commit 6cd7fa0

Please sign in to comment.