Skip to content

Commit

Permalink
Adding an optional creation fo stack traces to speed up CSG opperations
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Dec 22, 2019
1 parent 39de40b commit d652dbb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
49 changes: 29 additions & 20 deletions src/main/java/eu/mihosoft/vrl/v3d/CSG.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public class CSG implements IuserAPI{
private ArrayList<Transform> slicePlanes=null;
private ArrayList<String> 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) {
Expand All @@ -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());
}
Expand Down Expand Up @@ -1998,26 +1996,28 @@ private void addStackTrace(Exception creationEventStackTrace2) {
}

public CSG historySync(CSG dyingCSG) {
this.addCreationEventStringList(dyingCSG.getCreationEventStackTraceList());
Set<String> 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<String> 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<String> incoming) {

if(useStackTraces)
for (String s : incoming) {
addCreationEventString(s);
}
Expand All @@ -2026,7 +2026,7 @@ public CSG addCreationEventStringList(ArrayList<String> incoming) {
}

public CSG addCreationEventString(String thisline) {

if(useStackTraces) {
boolean dupLine = false;
for (String s : groovyFileLines) {
if (s.contentEquals(thisline)) {
Expand All @@ -2037,6 +2037,7 @@ public CSG addCreationEventString(String thisline) {
if (!dupLine) {
groovyFileLines.add(thisline);
}
}

return this;
}
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app.name=JavaCad
app.version=0.21.0
app.version=0.22.0


0 comments on commit d652dbb

Please sign in to comment.