File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
src/main/java/eu/mihosoft/jcsg Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ plugins {
22 id ' application'
33 id ' java'
44 id ' maven-publish'
5- id ' net.nemerosa.versioning' version ' 1.5.0 '
6- id ' com.jfrog.bintray' version ' 1.6 '
5+ id ' net.nemerosa.versioning' version ' 2.6.1 '
6+ id ' com.jfrog.bintray' version ' 1.7.2 '
77}
88
99sourceCompatibility = ' 1.8'
@@ -13,7 +13,7 @@ sourceCompatibility = '1.8'
1313// repairHeaders.licenseHeaderText = new File(projectDir,'./license-template.txt')
1414
1515task wrapper (type : Wrapper , description : ' Creates and deploys the Gradle wrapper to the current directory.' ) {
16- gradleVersion = ' 4.0 '
16+ gradleVersion = ' 4.6 '
1717}
1818
1919if (! hasProperty(' mainClass' )) {
Original file line number Diff line number Diff line change 11group = eu.mihosoft.vrl.jcsg
2- version = 0.5.7-SNAPSHOT
2+ version = 0.5.7
Original file line number Diff line number Diff line change @@ -272,6 +272,38 @@ public StringBuilder toStlString(StringBuilder sb) {
272272 return sb ;
273273 }
274274
275+ /**
276+ * Returns a triangulated version of this polygon.
277+ *
278+ * @return triangles
279+ */
280+ public List <Polygon > toTriangles () {
281+
282+ List <Polygon > result = new ArrayList <>();
283+
284+ if (this .vertices .size () >= 3 ) {
285+
286+ // TODO: improve the triangulation?
287+ //
288+ // If our polygon has more vertices, create
289+ // multiple triangles:
290+ Vertex firstVertexStl = this .vertices .get (0 );
291+ for (int i = 0 ; i < this .vertices .size () - 2 ; i ++) {
292+
293+ // create triangle
294+ Polygon polygon = Polygon .fromPoints (
295+ firstVertexStl .pos ,
296+ this .vertices .get (i + 1 ).pos ,
297+ this .vertices .get (i + 2 ).pos
298+ );
299+
300+ result .add (polygon );
301+ }
302+ }
303+
304+ return result ;
305+ }
306+
275307 /**
276308 * Translates this polygon.
277309 *
You can’t perform that action at this time.
0 commit comments