From d652dbb67d9b349151b28859bbab0b300f4cdef1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 22 Dec 2019 15:35:20 -0500 Subject: [PATCH] Adding an optional creation fo stack traces to speed up CSG opperations --- src/main/java/eu/mihosoft/vrl/v3d/CSG.java | 49 +++++++++++-------- .../neuronrobotics/javacad/build.properties | 2 +- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/mihosoft/vrl/v3d/CSG.java b/src/main/java/eu/mihosoft/vrl/v3d/CSG.java index 1893dec7..18328e86 100644 --- a/src/main/java/eu/mihosoft/vrl/v3d/CSG.java +++ b/src/main/java/eu/mihosoft/vrl/v3d/CSG.java @@ -140,6 +140,8 @@ public class CSG implements IuserAPI{ private ArrayList slicePlanes=null; private ArrayList exportFormats=null; + private static boolean useStackTraces=true; + private static ICSGProgress progressMoniter=new ICSGProgress() { @Override public void progressUpdate(int currentIndex, int finalIndex, String type, CSG intermediateShape) { @@ -151,13 +153,9 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, CSG in * Instantiates a new csg. */ public CSG() { - this(true); - } - - public CSG(boolean makeException) { storage = new PropertyStorage(); - if (makeException) { + if (useStackTraces) { // This is the trace for where this csg was created addStackTrace(new Exception()); } @@ -1998,26 +1996,28 @@ private void addStackTrace(Exception creationEventStackTrace2) { } public CSG historySync(CSG dyingCSG) { - this.addCreationEventStringList(dyingCSG.getCreationEventStackTraceList()); - Set params = dyingCSG.getParameters(); - for (String param : params) { - boolean existing = false; - for (String s : this.getParameters()) { - if (s.contentEquals(param)) - existing = true; - } - if (!existing) { - Parameter vals = CSGDatabase.get(param); - if (vals != null) - this.setParameter(vals, dyingCSG.getMapOfparametrics().get(param)); + if(useStackTraces) { + this.addCreationEventStringList(dyingCSG.getCreationEventStackTraceList()); + Set params = dyingCSG.getParameters(); + for (String param : params) { + boolean existing = false; + for (String s : this.getParameters()) { + if (s.contentEquals(param)) + existing = true; + } + if (!existing) { + Parameter vals = CSGDatabase.get(param); + if (vals != null) + this.setParameter(vals, dyingCSG.getMapOfparametrics().get(param)); + } } + this.setColor(dyingCSG.getColor()); } - this.setColor(dyingCSG.getColor()); return this; } public CSG addCreationEventStringList(ArrayList incoming) { - + if(useStackTraces) for (String s : incoming) { addCreationEventString(s); } @@ -2026,7 +2026,7 @@ public CSG addCreationEventStringList(ArrayList incoming) { } public CSG addCreationEventString(String thisline) { - + if(useStackTraces) { boolean dupLine = false; for (String s : groovyFileLines) { if (s.contentEquals(thisline)) { @@ -2037,6 +2037,7 @@ public CSG addCreationEventString(String thisline) { if (!dupLine) { groovyFileLines.add(thisline); } + } return this; } @@ -2279,5 +2280,13 @@ public static int getNumFacesInOffset() { public static void setNumFacesInOffset(int numFacesInOffset) { CSG.numFacesInOffset = numFacesInOffset; } + + public static boolean isUseStackTraces() { + return useStackTraces; + } + + public static void setUseStackTraces(boolean useStackTraces) { + CSG.useStackTraces = useStackTraces; + } } diff --git a/src/main/resources/com/neuronrobotics/javacad/build.properties b/src/main/resources/com/neuronrobotics/javacad/build.properties index f5eb74f7..134b064b 100644 --- a/src/main/resources/com/neuronrobotics/javacad/build.properties +++ b/src/main/resources/com/neuronrobotics/javacad/build.properties @@ -1,4 +1,4 @@ app.name=JavaCad -app.version=0.21.0 +app.version=0.22.0