@@ -473,7 +473,7 @@ public CSG setManipulator(javafx.scene.transform.Affine m) {
473473 * @return the mesh
474474 * @throws ColinearPointsException
475475 */
476- public MeshView getMesh () throws ColinearPointsException {
476+ public MeshView getMesh () {
477477 if (getCurrentMeshView () != null )
478478 return getCurrentMeshView ();
479479 setCurrentMeshView (newMesh ());
@@ -486,7 +486,7 @@ public MeshView getMesh() throws ColinearPointsException {
486486 * @return the mesh
487487 * @throws ColinearPointsException
488488 */
489- public MeshView newMesh () throws ColinearPointsException {
489+ public MeshView newMesh () {
490490
491491 MeshContainer meshContainer = toJavaFXMesh (null );
492492
@@ -1047,16 +1047,24 @@ public CSG union(CSG csg) {
10471047 * @return a csg consisting of the polygons of this csg and the specified csg
10481048 * @throws ColinearPointsException
10491049 */
1050- public CSG dumbUnion (CSG csg ) throws ColinearPointsException {
1050+ public CSG dumbUnion (CSG csg ) {
10511051 // boolean tri = triangulated && csg.triangulated;
10521052 CSG result = this .clone ();
10531053 CSG other = csg .clone ();
10541054
1055- ArrayList <Polygon > polygonsFromMesh = result .generatePolygonsFromMesh ();
1056- polygonsFromMesh .addAll (other .generatePolygonsFromMesh ());
1057- bounds = null ;
1058- // result.triangulated = tri;
1059- return new CSG (polygonsFromMesh ).historySync (csg ).historySync (this );
1055+ ArrayList <Polygon > polygonsFromMesh ;
1056+ try {
1057+ polygonsFromMesh = result .generatePolygonsFromMesh ();
1058+ polygonsFromMesh .addAll (other .generatePolygonsFromMesh ());
1059+ bounds = null ;
1060+ // result.triangulated = tri;
1061+ return new CSG (polygonsFromMesh ).historySync (csg ).historySync (this );
1062+ } catch (ColinearPointsException e ) {
1063+ // TODO Auto-generated catch block
1064+ e .printStackTrace ();
1065+ return this ;
1066+ }
1067+
10601068 }
10611069
10621070 /**
@@ -1126,12 +1134,7 @@ public CSG union(List<CSG> incoming) {
11261134 if (dumb == null ) {
11271135 dumb = test ;
11281136 } else
1129- try {
1130- dumb = dumb .dumbUnion (test );
1131- } catch (ColinearPointsException e ) {
1132- // TODO Auto-generated catch block
1133- e .printStackTrace ();
1134- }
1137+ dumb = dumb .dumbUnion (test );
11351138 }
11361139
11371140 }
@@ -1166,12 +1169,7 @@ else if (solid == null && hole != null)
11661169 else
11671170 result = solid .difference (hole );
11681171 if (dumb != null ) {
1169- try {
1170- result = result .dumbUnion (dumb );
1171- } catch (ColinearPointsException e ) {
1172- // TODO Auto-generated catch block
1173- e .printStackTrace ();
1174- }
1172+ result = result .dumbUnion (dumb );
11751173 }
11761174 return result ;
11771175 }
@@ -1410,12 +1408,7 @@ private CSG _unionNoOpt(CSG csg) {
14101408 // TODO Auto-generated catch block
14111409 e .printStackTrace ();
14121410 }
1413- try {
1414- return dumbUnion (csg );
1415- } catch (ColinearPointsException e ) {
1416- e .printStackTrace ();
1417- return this ;
1418- }
1411+ return dumbUnion (csg );
14191412 }
14201413
14211414 /**
@@ -2545,7 +2538,7 @@ public CSG color(Color c) {
25452538 * @return the specified string builder
25462539 * @throws ColinearPointsException
25472540 */
2548- public StringBuilder toObjString (StringBuilder sb ) throws ColinearPointsException {
2541+ public StringBuilder toObjString (StringBuilder sb ) {
25492542 triangulate (true );
25502543 sb .append ("# Group" ).append ("\n " );
25512544 sb .append ("g v3d.csg\n " );
@@ -2568,20 +2561,25 @@ public PolygonStruct(PropertyStorage storage, List<Integer> indices, String mate
25682561
25692562 sb .append ("\n # Vertices\n " );
25702563
2571- for (Polygon p : generatePolygonsFromMesh ()) {
2572- List <Integer > polyIndices = new ArrayList <>();
2564+ try {
2565+ for (Polygon p : generatePolygonsFromMesh ()) {
2566+ List <Integer > polyIndices = new ArrayList <>();
25732567
2574- p .getVertices ().stream ().forEach ((v ) -> {
2575- if (!vertices .contains (v )) {
2576- vertices .add (v );
2577- v .toObjString (sb );
2578- polyIndices .add (vertices .size ());
2579- } else {
2580- polyIndices .add (vertices .indexOf (v ) + 1 );
2581- }
2582- });
2583- indices .add (new PolygonStruct (getStorage (), polyIndices , " " ));
2568+ p .getVertices ().stream ().forEach ((v ) -> {
2569+ if (!vertices .contains (v )) {
2570+ vertices .add (v );
2571+ v .toObjString (sb );
2572+ polyIndices .add (vertices .size ());
2573+ } else {
2574+ polyIndices .add (vertices .indexOf (v ) + 1 );
2575+ }
2576+ });
2577+ indices .add (new PolygonStruct (getStorage (), polyIndices , " " ));
25842578
2579+ }
2580+ } catch (ColinearPointsException e ) {
2581+ // TODO Auto-generated catch block
2582+ e .printStackTrace ();
25852583 }
25862584 HashMap <Vertex , Integer > mapping = new HashMap <Vertex , Integer >();
25872585 HashMap <Transform , Vertex > mappingTF = new HashMap <>();
@@ -2633,7 +2631,7 @@ public PolygonStruct(PropertyStorage storage, List<Integer> indices, String mate
26332631 * @return this csg in OBJ string format
26342632 * @throws ColinearPointsException
26352633 */
2636- public String toObjString () throws ColinearPointsException {
2634+ public String toObjString () {
26372635 StringBuilder sb = new StringBuilder ();
26382636 return toObjString (sb ).toString ();
26392637 }
@@ -2714,7 +2712,7 @@ public CSG transformed(Transform transform) {
27142712 * @throws ColinearPointsException
27152713 */
27162714 // TODO finish experiment (20.7.2014)
2717- public MeshContainer toJavaFXMesh (CadInteractionEvent interact ) throws ColinearPointsException {
2715+ public MeshContainer toJavaFXMesh (CadInteractionEvent interact ) {
27182716
27192717 return toJavaFXMeshSimple (interact );
27202718
@@ -2740,9 +2738,15 @@ public MeshContainer toJavaFXMesh(CadInteractionEvent interact) throws ColinearP
27402738 * @return the CSG as JavaFX triangle mesh
27412739 * @throws ColinearPointsException
27422740 */
2743- public MeshContainer toJavaFXMeshSimple (CadInteractionEvent interact ) throws ColinearPointsException {
2741+ public MeshContainer toJavaFXMeshSimple (CadInteractionEvent interact ) {
27442742
2745- return CSGtoJavafx .meshFromPolygon (generatePolygonsFromMesh ());
2743+ try {
2744+ return CSGtoJavafx .meshFromPolygon (generatePolygonsFromMesh ());
2745+ } catch (ColinearPointsException e ) {
2746+ // TODO Auto-generated catch block
2747+ e .printStackTrace ();
2748+ return CSGtoJavafx .meshFromPolygon (new ArrayList <>());
2749+ }
27462750 }
27472751
27482752 /**
@@ -3772,20 +3776,14 @@ public int getPrintBedIndex() {
37723776 }
37733777
37743778 public static CSG text (String text , double height , double fontSize ) {
3775- try {
3776- return text (text , height , fontSize , Font .getDefault ().getName ());
3777- } catch (ColinearPointsException e ) {
3778- // TODO Auto-generated catch block
3779- e .printStackTrace ();
3780- return new CSG ();
3781- }
3779+ return text (text , height , fontSize , Font .getDefault ().getName ());
37823780 }
37833781
37843782 public static CSG text (String text , double height ) {
37853783 return text (text , height , 30 );
37863784 }
37873785
3788- public static CSG text (String text , double height , double fontSize , String fontType ) throws ColinearPointsException {
3786+ public static CSG text (String text , double height , double fontSize , String fontType ) {
37893787 javafx .scene .text .Font font = new javafx .scene .text .Font (fontType , fontSize );
37903788 if (!font .getName ().toLowerCase ().contains (fontType .toLowerCase ())) {
37913789 String options = "" ;
@@ -4439,4 +4437,15 @@ public String getUniqueId() {
44394437 return uniqueId ;
44404438 }
44414439
4440+ public Vector3d vertexAt (int i ) {
4441+ return vertexAt (vertices , i );
4442+ }
4443+
4444+ public List <Vector3d > getPoints () {
4445+ List <Vector3d > points = new ArrayList <Vector3d >();
4446+ for (int i =0 ;i <vertCount ;i ++)
4447+ points .add (vertexAt (i ));
4448+ return points ;
4449+ }
4450+
44424451}
0 commit comments