diff --git a/build.gradle b/build.gradle index 959deb75..883988c3 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,8 @@ plugins { id 'application' id 'java' id 'maven-publish' - id 'net.nemerosa.versioning' version '1.5.0' - id 'com.jfrog.bintray' version '1.6' + id 'net.nemerosa.versioning' version '2.6.1' + id 'com.jfrog.bintray' version '1.7.2' } sourceCompatibility = '1.8' @@ -13,7 +13,7 @@ sourceCompatibility = '1.8' //repairHeaders.licenseHeaderText = new File(projectDir,'./license-template.txt') task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') { - gradleVersion = '4.0' + gradleVersion = '4.6' } if (!hasProperty('mainClass')) { diff --git a/gradle.properties b/gradle.properties index d6c234ff..5e990126 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group = eu.mihosoft.vrl.jcsg -version = 0.5.7-SNAPSHOT +version = 0.5.7 diff --git a/src/main/java/eu/mihosoft/jcsg/Polygon.java b/src/main/java/eu/mihosoft/jcsg/Polygon.java index 32a41866..22170b44 100644 --- a/src/main/java/eu/mihosoft/jcsg/Polygon.java +++ b/src/main/java/eu/mihosoft/jcsg/Polygon.java @@ -272,6 +272,38 @@ public StringBuilder toStlString(StringBuilder sb) { return sb; } + /** + * Returns a triangulated version of this polygon. + * + * @return triangles + */ + public List toTriangles() { + + List result = new ArrayList<>(); + + if (this.vertices.size() >= 3) { + + // TODO: improve the triangulation? + // + // If our polygon has more vertices, create + // multiple triangles: + Vertex firstVertexStl = this.vertices.get(0); + for (int i = 0; i < this.vertices.size() - 2; i++) { + + // create triangle + Polygon polygon = Polygon.fromPoints( + firstVertexStl.pos, + this.vertices.get(i + 1).pos, + this.vertices.get(i + 2).pos + ); + + result.add(polygon); + } + } + + return result; + } + /** * Translates this polygon. *