From 2bd52f055432d639157cc2598db93d7bb9982a2e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 20 Jul 2024 18:09:34 -0400 Subject: [PATCH 001/635] Adding the Openscad runner --- .../bowlerstudio/scripting/BlenderLoader.java | 10 +-- .../scripting/DownloadManager.java | 18 ++++ .../bowlerstudio/scripting/FreecadLoader.java | 2 +- .../scripting/OpenSCADLoader.java | 87 +++++++++++++++++++ 4 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index 6aae7f81..a2dd6f85 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -50,15 +50,7 @@ public static void toBlenderFile(CSG stlIn,File blenderfile) throws IOException toBlenderFile(stl, blenderfile); } - public static File getTmpSTL(CSG stlIn) throws IOException { - String name = stlIn.getName(); - if(name.length()==0) - name="CSG_EXPORT"; - File stl = File.createTempFile(name, ".stl"); - stl.deleteOnExit(); - FileUtil.write(Paths.get(stl.getAbsolutePath()), stlIn.toStlString()); - return stl; - } + public static void toBlenderFile(File incoming,File blenderfile) { System.out.println("Converting to Blender file before loading"); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 60e4fc35..aeeb99a3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -3,6 +3,8 @@ import org.apache.commons.exec.*; import org.apache.commons.exec.environment.EnvironmentUtils; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.sanitizeString; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; @@ -55,6 +57,8 @@ import com.google.gson.reflect.TypeToken; import com.neuronrobotics.video.OSUtil; +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.FileUtil; //import javafx.scene.control.Alert; import javafx.scene.control.Button; //import javafx.scene.control.ButtonType; @@ -69,6 +73,20 @@ public class DownloadManager { private static String bindir = System.getProperty("user.home") + delim()+"bin"+delim()+"BowlerStudioInstall"+delim(); private static int ev = 0; private static String cmd = ""; + public static String sanitizeString(String s) { + if(s.contains(" ")) + s=s.replace(' ', '_'); + return s; + } + public static File getTmpSTL(CSG stlIn) throws IOException { + String name = stlIn.getName(); + if(name.length()==0) + name="CSG_EXPORT"; + File stl = File.createTempFile(sanitizeString(name), ".stl"); + stl.deleteOnExit(); + FileUtil.write(Paths.get(stl.getAbsolutePath()), stlIn.toStlString()); + return stl; + } private static IApprovalForDownload approval = new IApprovalForDownload() { @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index 04634b10..78c52bf2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -105,7 +105,7 @@ public static void addCSGToFreeCAD(File freecadModel,CSG incoming) throws IOExce addCSGToFreeCAD(freecadModel,incoming,incoming.getSlicePlanes()); } public static void addCSGToFreeCAD(File freecadModel,CSG toSlice, List slicePlanes) throws IOException { - File tmp = BlenderLoader.getTmpSTL(toSlice); + File tmp =getTmpSTL(toSlice); String name = toSlice.getName(); if(name.length()==0) { name="CSG_TO_FREECAD"; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java new file mode 100644 index 00000000..40587a50 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java @@ -0,0 +1,87 @@ +package com.neuronrobotics.bowlerstudio.scripting; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; + +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; + +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.FileUtil; +import eu.mihosoft.vrl.v3d.STL; +import javafx.scene.paint.Color; + +public class OpenSCADLoader implements IScriptingLanguage { + + @Override + public Object inlineScriptRun(File code, ArrayList args) throws Exception { + File stl = File.createTempFile(sanitizeString(code.getName()), ".stl"); + stl.deleteOnExit(); + toSTLFile(code,stl); + CSG back = Vitamins.get(stl,true); + back.setColor(Color.YELLOW); + return back; + } + + @Override + public Object inlineScriptRun(String code, ArrayList args) throws Exception { + throw new RuntimeException("Blender can not run from a string"); + } + + @Override + public String getShellType() { + return "Blender"; + } + + @Override + public ArrayList getFileExtenetion() { + ArrayList ext = new ArrayList<>(); + ext.add("scad"); + ext.add("SCad"); + + return ext; + } + + + + + public static void toSTLFile(File openscadfile,File stlout) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + File exe = getConfigExecutable("openscad", null); + + ArrayList args = new ArrayList<>(); + + if(stlout.exists()) + stlout.delete(); + args.add(exe.getAbsolutePath()); + args.add("-o"); + args.add(stlout.getAbsolutePath()); + args.add(openscadfile.getAbsolutePath()); + legacySystemRun(null, stlout.getAbsoluteFile().getParentFile(), System.out, args); + } + @Override + public String getDefaultContents() { + return "cube([3, 2, 1]);"; + } + + @Override + public boolean getIsTextFile() { + return true; + } + + public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + OpenSCADLoader loader = new OpenSCADLoader(); + + // create test file + File testblend = new File("test.scad"); + if(!testblend.exists()) + loader.getDefaultContents(testblend); + toSTLFile(testblend, new File("testscad.stl")); + } + +} From e84e08247ae528525ea91e36c1a9ea9237a62898 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 20 Jul 2024 18:13:29 -0400 Subject: [PATCH 002/635] https://github.com/CommonWealthRobotics/BowlerStudio/issues/406 --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 8465cfec..acde22e2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -149,6 +149,7 @@ public class ScriptingEngine {// this subclasses boarder pane for the widgets addScriptingLanguage(new BlenderLoader()); addScriptingLanguage(new FreecadLoader()); addScriptingLanguage(new FXMLBowlerLoader()); + addScriptingLanguage(new OpenSCADLoader()); } public static void setWorkspace(File file) { From 9f3128b46a54b77a2516d9b8ba6b5135b1f0ae56 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 20 Jul 2024 18:15:47 -0400 Subject: [PATCH 003/635] https://github.com/CommonWealthRobotics/BowlerStudio/issues/406 --- .../neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java index 40587a50..dfc9c55c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java @@ -36,7 +36,7 @@ public Object inlineScriptRun(String code, ArrayList args) throws Except @Override public String getShellType() { - return "Blender"; + return "OpenSCAD"; } @Override From 18a34f7d0a72d1f0130257b0b8a0b47bbb5f4fc5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 23 Jul 2024 11:41:25 -0400 Subject: [PATCH 004/635] Adding a platform wrapping for the exit --- src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index f534b7b1..3af0b0d9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -472,7 +472,7 @@ private static void processUIOpening(Object ret) { newStage.setOnCloseRequest(event -> { // Exit the JVM when the window is closed future.complete(true); - Platform.exit(); + BowlerKernel.runLater(()->Platform.exit()); }); FontSizeManager.addListener(fontNum -> { int tmp = fontNum - 10; From 89228770c142281b60aeee7bfb3cc6ae756d26a0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 24 Jul 2024 21:58:31 -0400 Subject: [PATCH 005/635] Adding flatten to the returns of the scripts --- .../scripting/ScriptingEngine.java | 35 ++++++++++++++++++- .../bowlerstudio/vitamins/Vitamins.java | 9 +---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index acde22e2..e51f5282 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -6,6 +6,7 @@ import com.neuronrobotics.sdk.util.ThreadUtil; import com.neuronrobotics.video.OSUtil; +import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -92,7 +93,39 @@ public class ScriptingEngine {// this subclasses boarder pane for the widgets /** * */ - + public static void flatten(ArrayList flat, Object o) { + if(CSG.class.isInstance(o)) + flat.add((CSG)o); + if(List.class.isInstance(o)) { + for(Object ob:(List)o) { + flatten(flat,ob); + } + } + + } + private static void flatenInterna(Object o, Class type,ArrayList flattened){ + if(type.isInstance(o)) + flattened.add((T)o); + if(List.class.isInstance(o)) { + for(Object ob:(List)o) { + flatenInterna(o,type,flattened); + } + } + if(Map.class.isInstance(o)) { + Map m=(Map)o; + for(Object key:m.keySet()) { + flatenInterna(m.get(key),type,flattened); + flatenInterna(key,type,flattened); + } + } + } + public static List flaten(String git,String file, Class type) throws Exception{ + ArrayList flattened = new ArrayList(); + Object o =gitScriptRun(git, file); + flatenInterna(o,type,flattened); + return flattened; + } + private static final ArrayList logListeners = new ArrayList<>(); private static boolean printProgress = true; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 23778874..bc34e378 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -157,14 +157,7 @@ public static boolean isGitURL(String text2) { return true; } public static void flatten(ArrayList flat, Object o) { - if(CSG.class.isInstance(o)) - flat.add((CSG)o); - if(List.class.isInstance(o)) { - for(Object ob:(List)o) { - flatten(flat,ob); - } - } - + ScriptingEngine.flatten(flat, o); } public static CSG get(String type, String id) throws Exception { From 82bf7c695b3bc8233782dcdbba1e534e4318bb03 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 24 Jul 2024 21:58:46 -0400 Subject: [PATCH 006/635] Adding basic cadoodle files --- .../scripting/cadoodle/AddFromScript.java | 37 +++++++++++++++++++ .../scripting/cadoodle/CaDoodleFile.java | 37 +++++++++++++++++++ .../cadoodle/ICaDoodleOpperation.java | 10 +++++ 3 files changed, 84 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java new file mode 100644 index 00000000..dea1a4cd --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -0,0 +1,37 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +import eu.mihosoft.vrl.v3d.CSG; + +public class AddFromScript implements ICaDoodleOpperation { + private String gitULR = ""; + private String fileRel = ""; + + public void set(String git, String f) { + gitULR = git; + fileRel = f; + } + + @Override + public String getType() { + return "AddObject"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming); + try { + back.addAll(ScriptingEngine.flaten(gitULR, fileRel, CSG.class)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return back; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java new file mode 100644 index 00000000..2bcd39c7 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -0,0 +1,37 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.io.File; +import java.util.ArrayList; + +import com.google.gson.annotations.Expose; + +public class CaDoodleFile { + private ArrayList opperations = new ArrayList(); + private int currentIndex =0; + private String projectName ="NoName"; + @Expose (serialize = false, deserialize = false) + private File self; + + public void addOpperation(ICaDoodleOpperation op) { + if(currentIndex != opperations.size()) { + opperations=(ArrayList) opperations.subList(0, currentIndex); + } + opperations.add(op); + currentIndex++; + } + public void back() { + if(currentIndex>0) + currentIndex-=1; + } + public void forward() { + if(currentIndex process(List incoming); +} From d03e69a0a5eb6c7e939b17052171cae9b3147068 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 01:03:16 -0400 Subject: [PATCH 007/635] Adding Basic CaDoodle workflow and test --- Test.doodle | 41 +++++++ java-bowler | 2 +- .../scripting/cadoodle/AddFromScript.java | 52 +++++++- .../scripting/cadoodle/CaDoodleFile.java | 111 ++++++++++++++++-- .../ICaDoodleOperationAdapterFactory.java | 74 ++++++++++++ .../cadoodle/ICaDoodleOpperation.java | 1 + .../scripting/cadoodle/MoveCenter.java | 62 ++++++++++ .../junit/bowler/TestCaDoodleWorkflow.java | 92 +++++++++++++++ 8 files changed, 423 insertions(+), 12 deletions(-) create mode 100644 Test.doodle create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java create mode 100644 test/java/src/junit/bowler/TestCaDoodleWorkflow.java diff --git a/Test.doodle b/Test.doodle new file mode 100644 index 00000000..00d92ac6 --- /dev/null +++ b/Test.doodle @@ -0,0 +1,41 @@ +{ + "opperations": [ + { + "type": "AddFromScript", + "data": { + "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", + "fileRel": "cube.groovy", + "name": "PlxM1JCvwFX1onkW6Akd" + } + }, + { + "type": "AddFromScript", + "data": { + "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", + "fileRel": "cube.groovy", + "name": "mFGR3AvDwYLbzcrAHGWO" + } + }, + { + "type": "MoveCenter", + "data": { + "location": { + "x": 100.0, + "y": 0.0, + "z": 0.0, + "rotation": { + "w": 1.0, + "x": 0.0, + "y": 0.0, + "z": 0.0 + } + }, + "names": [ + "mFGR3AvDwYLbzcrAHGWO" + ] + } + } + ], + "currentIndex": 3, + "projectName": "A Test Project" +} \ No newline at end of file diff --git a/java-bowler b/java-bowler index f0c79d20..b30018f9 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit f0c79d2083d993f5721d608b295e813ab5098c3f +Subproject commit b30018f94c91ac52da0927910917e46b7a47a596 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index dea1a4cd..28624c1e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -2,23 +2,57 @@ import java.util.ArrayList; import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; +import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import eu.mihosoft.vrl.v3d.CSG; public class AddFromScript implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) private String gitULR = ""; + @Expose (serialize = true, deserialize = true) private String fileRel = ""; + @Expose (serialize = true, deserialize = true) + private String name=null; + @Expose (serialize = false, deserialize = false) + private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + @Expose (serialize = false, deserialize = false) + private static final int STRING_LENGTH = 20; + private int nameIndex = 0; - public void set(String git, String f) { + public static String generateRandomString() { + Random random = new Random(); + StringBuilder stringBuilder = new StringBuilder(STRING_LENGTH); + + for (int i = 0; i < STRING_LENGTH; i++) { + int randomIndex = random.nextInt(CHAR_POOL.length()); + stringBuilder.append(CHAR_POOL.charAt(randomIndex)); + } + + return stringBuilder.toString(); + } + public AddFromScript set(String git, String f) { gitULR = git; fileRel = f; + return this; } @Override public String getType() { - return "AddObject"; + return "Add Object"; + } + + private String getOrderedName() { + if(name==null) { + name=generateRandomString(); + } + if(nameIndex==0) + return name; + nameIndex++; + return name+"_"+nameIndex; } @Override @@ -26,7 +60,19 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); try { - back.addAll(ScriptingEngine.flaten(gitULR, fileRel, CSG.class)); + back.addAll(ScriptingEngine + .flaten(gitULR, fileRel, CSG.class) + .stream() + .map(csg->{ + return csg + .moveToCenterX() + .moveToCenterY() + .toZMin() + .syncProperties(csg) + .setName(getOrderedName()); + }) + .collect(Collectors.toCollection(ArrayList::new)) + ); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 2bcd39c7..b6f9d98d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -1,37 +1,132 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; +import org.apache.commons.io.FileUtils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; +import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +import eu.mihosoft.vrl.v3d.CSG; public class CaDoodleFile { + @Expose (serialize = true, deserialize = true) private ArrayList opperations = new ArrayList(); + @Expose (serialize = true, deserialize = true) private int currentIndex =0; + @Expose (serialize = true, deserialize = true) private String projectName ="NoName"; @Expose (serialize = false, deserialize = false) private File self; + @Expose (serialize = false, deserialize = false) + private List currentState = new ArrayList(); + @Expose (serialize = false, deserialize = false) + private HashMap> cache =new HashMap>(); + private static Type TT_CaDoodleFile = new TypeToken() {}.getType(); + private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() + .excludeFieldsWithoutExposeAnnotation() + .registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) + .create(); - public void addOpperation(ICaDoodleOpperation op) { - if(currentIndex != opperations.size()) { - opperations=(ArrayList) opperations.subList(0, currentIndex); + public List addOpperation(ICaDoodleOpperation op) { + if(currentIndex != getOpperations().size()) { + for(int i=currentIndex;i back = cache.remove(getOpperations().get(i)); + back.clear(); + } + List subList = (List) getOpperations().subList(0, currentIndex); + ArrayList newList=new ArrayList(); + newList.addAll(subList); + setOpperations(newList); + } + try { + List process = op.process(getCurrentState()); + cache.put(op,process); + setCurrentState(process); + currentIndex++; + getOpperations().add(op); + }catch(Exception ex) { + ex.printStackTrace(); } - opperations.add(op); - currentIndex++; + return currentState; } public void back() { if(currentIndex>0) currentIndex-=1; + updateCurrentFromCache(); + } + private void updateCurrentFromCache() { + setCurrentState(cache.get(getOpperations().get(currentIndex-1))); } public void forward() { - if(currentIndex getCurrentState() { + return currentState; + } + private void setCurrentState(List currentState) { + this.currentState = currentState; + } + public String getProjectName() { + return projectName; + } + public CaDoodleFile setProjectName(String projectName) { + this.projectName = projectName; + return this; + } + public String toJson() { + return gson.toJson(this); + } + public File save() throws IOException { + File ret = self==null?File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"):self; + String contents = toJson(); + FileUtils.write(ret, contents,StandardCharsets.UTF_8, false); + return ret; + } + public static CaDoodleFile fromJsonString(String content ) throws Exception { + CaDoodleFile file =gson.fromJson(content, TT_CaDoodleFile); + file.initialize(); + return file; + } + private void initialize() { + for(int i=0;i process = op.process(getCurrentState()); + cache.put(op,process); + } + updateCurrentFromCache(); + } + public static CaDoodleFile fromFile(File f) throws Exception { + String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); + CaDoodleFile file =fromJsonString(content); + file.setSelf(f); + return file; + } + public ArrayList getOpperations() { + return opperations; + } + public void setOpperations(ArrayList opperations) { + this.opperations = opperations; } - } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java new file mode 100644 index 00000000..50621742 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -0,0 +1,74 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import com.google.gson.*; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; +import com.google.gson.*; +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class ICaDoodleOperationAdapterFactory implements TypeAdapterFactory { + private final Map> typeRegistry = new HashMap<>(); + private final Map, String> classRegistry = new HashMap<>(); + + public ICaDoodleOperationAdapterFactory() { + registerType("MoveCenter", MoveCenter.class); + registerType("AddFromScript", AddFromScript.class); + } + + private void registerType(String typeName, Class clazz) { + typeRegistry.put(typeName, clazz); + classRegistry.put(clazz, typeName); + } + + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ICaDoodleOpperation.class.isAssignableFrom(type.getRawType())) { + return null; + } + + final TypeAdapter jsonElementAdapter = gson.getAdapter(JsonElement.class); + + return new TypeAdapter() { + @Override + public void write(JsonWriter out, T value) throws IOException { + JsonObject jsonObject = new JsonObject(); + String typeName = classRegistry.get(value.getClass()); + if (typeName == null) { + throw new JsonParseException("Unknown class: " + value.getClass()); + } + jsonObject.addProperty("type", typeName); + @SuppressWarnings("unchecked") + TypeAdapter delegateAdapter = (TypeAdapter) gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get((Class) value.getClass())); + JsonElement dataElement = delegateAdapter.toJsonTree(value); + jsonObject.add("data", dataElement); + jsonElementAdapter.write(out, jsonObject); + } + + @Override + public T read(JsonReader in) throws IOException { + JsonObject jsonObject = jsonElementAdapter.read(in).getAsJsonObject(); + JsonElement typeElement = jsonObject.get("type"); + JsonElement dataElement = jsonObject.get("data"); + String typeName = typeElement.getAsString(); + Class clazz = typeRegistry.get(typeName); + if (clazz == null) { + throw new JsonParseException("Unknown type: " + typeName); + } + TypeAdapter delegateAdapter = gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get(clazz)); + return (T) delegateAdapter.fromJsonTree(dataElement); + } + }.nullSafe(); + } + + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java index ce36a79a..74d1afe7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java @@ -5,6 +5,7 @@ import eu.mihosoft.vrl.v3d.CSG; public interface ICaDoodleOpperation { + public String getType(); public List process(List incoming); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java new file mode 100644 index 00000000..98bb6478 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -0,0 +1,62 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class MoveCenter implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private TransformNR location=new TransformNR(); + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "Move Center"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming + .stream() + .map(csg->{ + for(String name:names) { + if(csg.getName().contentEquals(name)) + return csg + .transformed(TransformFactory.nrToCSG(location)) + .setName(name) + .syncProperties(csg) + ; + } + return csg; + }) + .collect(Collectors.toCollection(ArrayList::new)) + ); + return back; + } + + public TransformNR getLocation() { + return location; + } + + public MoveCenter setLocation(TransformNR location) { + this.location = location; + return this; + } + + public List getNames() { + return names; + } + + public MoveCenter setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java new file mode 100644 index 00000000..37b3a3f3 --- /dev/null +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -0,0 +1,92 @@ +package junit.bowler; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.junit.Test; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +import java.lang.reflect.Type; + +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AddFromScript; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; +import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class TestCaDoodleWorkflow { + + @Test + public void test() throws Exception { + CaDoodleFile cf = new CaDoodleFile() + .setSelf(new File("Test.doodle")) + .setProjectName("A Test Project"); + + String jsonContent = cf.toJson(); + System.out.println(jsonContent); + + AddFromScript cube1 = new AddFromScript() + .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", + "cube.groovy"); + AddFromScript cube2 = new AddFromScript() + .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", + "cube.groovy"); + Listback= cf.addOpperation(cube1); + if(back.size()!=1) + fail("Adding a cube should have added one!"); + String nameOne = back.get(0).getName(); + back=cf.addOpperation(cube2); + if(back.size()!=2) + fail("Adding a cube should have added one more!"); + String nameTwo = back.get(1).getName(); + if(nameOne.contentEquals(nameTwo)) + fail("Names must be unique!"); + System.out.println("Name one : "+nameOne ); + System.out.println("Name two : "+nameTwo ); + double distaance =100; + MoveCenter move = new MoveCenter() + .setLocation(new TransformNR(distaance,0,0)) + .setNames(Arrays.asList(nameTwo)) + ; + back= cf.addOpperation(move); + if(back.size()!=2) + fail("Same number of objects after"); + if(back.get(1).getCenterX()!=distaance) + fail("Move failed "); + if(back.get(0).getCenterX()!=0) + fail("Move misapplied "); + jsonContent = cf.toJson(); + System.out.println(jsonContent); + cf.save(); + CaDoodleFile loaded = CaDoodleFile.fromFile(cf.getSelf()); + if(!MoveCenter.class.isInstance(loaded.getOpperations().get(2))) { + fail("Third Opperation is supposed to be a move"); + } + if(!AddFromScript.class.isInstance(loaded.getOpperations().get(1))) { + fail(" Opperation is supposed to be a AddFromScript"); + } + if(!AddFromScript.class.isInstance(loaded.getOpperations().get(0))) { + fail(" Opperation is supposed to be a AddFromScript"); + } + loaded.back(); + MoveCenter move2 = new MoveCenter() + .setLocation(new TransformNR(distaance,distaance,0)) + .setNames(Arrays.asList(nameOne)) + ; + loaded.addOpperation(move2); + System.out.println(loaded.toJson()); + + } + +} From ad931c66ef745878bf3ec59dc712e62243a6e611 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 01:45:29 -0400 Subject: [PATCH 008/635] Testing of loading and running working --- Test.doodle | 6 +++--- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 +++++--- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Test.doodle b/Test.doodle index 00d92ac6..88e2dc10 100644 --- a/Test.doodle +++ b/Test.doodle @@ -5,7 +5,7 @@ "data": { "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", "fileRel": "cube.groovy", - "name": "PlxM1JCvwFX1onkW6Akd" + "name": "fvxUXExNhwoeh8mmqcNi" } }, { @@ -13,7 +13,7 @@ "data": { "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", "fileRel": "cube.groovy", - "name": "mFGR3AvDwYLbzcrAHGWO" + "name": "nRGnXBRBA9C9dJNBJBWY" } }, { @@ -31,7 +31,7 @@ } }, "names": [ - "mFGR3AvDwYLbzcrAHGWO" + "nRGnXBRBA9C9dJNBJBWY" ] } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b6f9d98d..4c5c6651 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -68,7 +68,9 @@ public void back() { updateCurrentFromCache(); } private void updateCurrentFromCache() { - setCurrentState(cache.get(getOpperations().get(currentIndex-1))); + ICaDoodleOpperation key = getOpperations().get(currentIndex-1); + List currentState2 = cache.get(key); + setCurrentState(currentState2); } public void forward() { if(currentIndex process = op.process(getCurrentState()); - cache.put(op,process); + currentState= op.process(getCurrentState()); + cache.put(op,currentState); } updateCurrentFromCache(); } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 37b3a3f3..17fe67cf 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -84,9 +84,12 @@ public void test() throws Exception { .setLocation(new TransformNR(distaance,distaance,0)) .setNames(Arrays.asList(nameOne)) ; - loaded.addOpperation(move2); + back=loaded.addOpperation(move2); System.out.println(loaded.toJson()); - + if(back.get(0).getCenterX()!=distaance) + fail("Move failed "); + if(back.get(0).getCenterY()!=distaance) + fail("Move failed "); } } From e83112e7b91b3808c42b64c965e72c7d2cf9f73b Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 01:50:23 -0400 Subject: [PATCH 009/635] Adding the additional rotation --- Test.doodle | 6 +++--- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Test.doodle b/Test.doodle index 88e2dc10..98b76968 100644 --- a/Test.doodle +++ b/Test.doodle @@ -5,7 +5,7 @@ "data": { "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", "fileRel": "cube.groovy", - "name": "fvxUXExNhwoeh8mmqcNi" + "name": "zu1WPjdXeyheDVK1QyZI" } }, { @@ -13,7 +13,7 @@ "data": { "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", "fileRel": "cube.groovy", - "name": "nRGnXBRBA9C9dJNBJBWY" + "name": "TlCcuz1rTbXYOjQRljDX" } }, { @@ -31,7 +31,7 @@ } }, "names": [ - "nRGnXBRBA9C9dJNBJBWY" + "TlCcuz1rTbXYOjQRljDX" ] } } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 17fe67cf..593f594b 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -84,6 +84,11 @@ public void test() throws Exception { .setLocation(new TransformNR(distaance,distaance,0)) .setNames(Arrays.asList(nameOne)) ; + MoveCenter move3 = new MoveCenter() + .setLocation(new TransformNR(0,0,0,new RotationNR(0,45,0))) + .setNames(Arrays.asList(nameOne)) + ; + back=loaded.addOpperation(move3); back=loaded.addOpperation(move2); System.out.println(loaded.toJson()); if(back.get(0).getCenterX()!=distaance) From 0aa05ed0b243d71a36be396d8f591ad1ab004d99 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 01:51:35 -0400 Subject: [PATCH 010/635] ignore the doodle file --- .gitignore | 1 + Test.doodle | 41 ----------------------------------------- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 Test.doodle diff --git a/.gitignore b/.gitignore index e36658e5..db79a34f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ physicsTest /test*.stl /test.blend1 /test.* +*.doodle diff --git a/Test.doodle b/Test.doodle deleted file mode 100644 index 98b76968..00000000 --- a/Test.doodle +++ /dev/null @@ -1,41 +0,0 @@ -{ - "opperations": [ - { - "type": "AddFromScript", - "data": { - "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", - "fileRel": "cube.groovy", - "name": "zu1WPjdXeyheDVK1QyZI" - } - }, - { - "type": "AddFromScript", - "data": { - "gitULR": "https://github.com/madhephaestus/CaDoodle-Example-Objects.git", - "fileRel": "cube.groovy", - "name": "TlCcuz1rTbXYOjQRljDX" - } - }, - { - "type": "MoveCenter", - "data": { - "location": { - "x": 100.0, - "y": 0.0, - "z": 0.0, - "rotation": { - "w": 1.0, - "x": 0.0, - "y": 0.0, - "z": 0.0 - } - }, - "names": [ - "TlCcuz1rTbXYOjQRljDX" - ] - } - } - ], - "currentIndex": 3, - "projectName": "A Test Project" -} \ No newline at end of file From e946d1ed10e0f0a0233207f47328dde70c915061 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 10:50:53 -0400 Subject: [PATCH 011/635] Updating the JCSG core to use the --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index a6ad60b1..4d6a33d0 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit a6ad60b1a722898c4ed761437d031817ec7a42a8 +Subproject commit 4d6a33d0142e7016745cf2a1c1b5d1954565b897 diff --git a/build.gradle b/build.gradle index c37148d2..753ec968 100755 --- a/build.gradle +++ b/build.gradle @@ -226,7 +226,7 @@ api 'org.slf4j:slf4j-simple:1.6.1' //compile group: 'com.neuronrobotics', name:'GithubPasswordManager', version:'0.6.1' //compile "com.neuronrobotics:JavaCad:0.14.0" //compile project('JCSG') -api 'com.neuronrobotics:JavaCad:1.1.1' +api 'com.neuronrobotics:JavaCad:1.2.9' //compile "com.neuronrobotics:CHDK-PTP-Java:0.5.3-SNAPSHOT" //compile "com.neuronrobotics:java-bowler:3.25.4" From 884147911c5238fa61578f135f3e17957f8bbe22 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 10:50:53 -0400 Subject: [PATCH 012/635] Updating the JCSG core to use the From a2f32f381e202129d970d9f24a7a2777d3d071f4 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 11:16:25 -0400 Subject: [PATCH 013/635] Adding the updated TransformNR api --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index b30018f9..79b257a3 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit b30018f94c91ac52da0927910917e46b7a47a596 +Subproject commit 79b257a3d7ee6bc45a1e54162849d0307d482490 From 9daf56ff08190c1e1367627e92154fc7c2d05682 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 11:51:49 -0400 Subject: [PATCH 014/635] Adding the group clear opperation --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 4d6a33d0..786a9323 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4d6a33d0142e7016745cf2a1c1b5d1954565b897 +Subproject commit 786a9323a8b8e412c866a715f8afd27bf13556aa diff --git a/build.gradle b/build.gradle index 753ec968..f39dffd5 100755 --- a/build.gradle +++ b/build.gradle @@ -226,7 +226,7 @@ api 'org.slf4j:slf4j-simple:1.6.1' //compile group: 'com.neuronrobotics', name:'GithubPasswordManager', version:'0.6.1' //compile "com.neuronrobotics:JavaCad:0.14.0" //compile project('JCSG') -api 'com.neuronrobotics:JavaCad:1.2.9' +api 'com.neuronrobotics:JavaCad:1.3.0' //compile "com.neuronrobotics:CHDK-PTP-Java:0.5.3-SNAPSHOT" //compile "com.neuronrobotics:java-bowler:3.25.4" From e31a3a757409b2875588110355d639cf688957b3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 12:21:51 -0400 Subject: [PATCH 015/635] Adding Group,ungroup Hole and solid setting --- .../scripting/cadoodle/AddFromScript.java | 2 +- .../scripting/cadoodle/Group.java | 70 +++++++++++++++++++ .../ICaDoodleOperationAdapterFactory.java | 5 ++ .../scripting/cadoodle/ToHole.java | 39 +++++++++++ .../scripting/cadoodle/ToSolid.java | 39 +++++++++++ .../scripting/cadoodle/UnGroup.java | 55 +++++++++++++++ .../junit/bowler/TestCaDoodleWorkflow.java | 20 +++++- 7 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 28624c1e..645de19a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -20,7 +20,7 @@ public class AddFromScript implements ICaDoodleOpperation { @Expose (serialize = false, deserialize = false) private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; @Expose (serialize = false, deserialize = false) - private static final int STRING_LENGTH = 20; + private static final int STRING_LENGTH = 40; private int nameIndex = 0; public static String generateRandomString() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java new file mode 100644 index 00000000..263e66c7 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -0,0 +1,70 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Group implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Expose (serialize = true, deserialize = true) + public String groupID=null; + @Override + public String getType() { + return "Group"; + } + + @Override + public List process(List incoming) { + ArrayList holes = new ArrayList(); + ArrayList solids = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + if(c.isHole()) { + holes.add(c); + }else + solids.add(c); + c.setGroupMembership(getGroupID()); + c.setIsGroupResult(false); + } + } + } + CSG result =null; + if(holes.size()>0&&solids.size()==0) { + result = CSG.unionAll(holes); + result.setIsHole(true); + + }else { + CSG holecutter = CSG.unionAll(holes); + CSG solid = CSG.unionAll(solids); + result=solid.difference(holecutter); + result.setIsHole(false); + } + result.setIsGroupResult(true); + result.setName(getGroupID()); + back.add(result); + return back; + } + + public List getNames() { + return names; + } + + public Group setNames(List names) { + this.names = names; + return this; + } + + public String getGroupID() { + if(groupID==null) + groupID=AddFromScript.generateRandomString(); + return groupID; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 50621742..d733197e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -23,6 +23,11 @@ public class ICaDoodleOperationAdapterFactory implements TypeAdapterFactory { public ICaDoodleOperationAdapterFactory() { registerType("MoveCenter", MoveCenter.class); registerType("AddFromScript", AddFromScript.class); + registerType("ToSolid", ToSolid.class); + registerType("ToHole", ToHole.class); + registerType("Group", Group.class); + registerType("UnGroup", UnGroup.class); + } private void registerType(String typeName, Class clazz) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java new file mode 100644 index 00000000..ad2cb125 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class ToHole implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "To Hole"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsHole(true); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public ToHole setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java new file mode 100644 index 00000000..e2cab62c --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class ToSolid implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "To Solid"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsHole(false); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public ToSolid setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java new file mode 100644 index 00000000..f8c6010d --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -0,0 +1,55 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class UnGroup implements ICaDoodleOpperation { + @Expose(serialize = true, deserialize = true) + private List names = new ArrayList(); + + @Override + public String getType() { + return "Un-Group"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming); + ArrayList results = new ArrayList(); + for (CSG csg : back) { + if (csg.isGroupResult()) { + for (String name : names) { + if (csg.getName().contentEquals(name)) { + results.add(csg); + } + if (csg.isInGroup()) { + if (csg.getGroupMembership().contentEquals(name)) { + // release this object from the group + csg.setGroupMembership(null); + } + } + } + } + } + for(CSG c:results) { + // remove the group results from the list of parts + back.remove(c); + } + return back; + } + + public List getNames() { + return names; + } + + public UnGroup setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 593f594b..65ac6251 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -19,7 +19,9 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AddFromScript; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Group; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -54,7 +56,7 @@ public void test() throws Exception { fail("Names must be unique!"); System.out.println("Name one : "+nameOne ); System.out.println("Name two : "+nameTwo ); - double distaance =100; + double distaance =10; MoveCenter move = new MoveCenter() .setLocation(new TransformNR(distaance,0,0)) .setNames(Arrays.asList(nameTwo)) @@ -67,7 +69,7 @@ public void test() throws Exception { if(back.get(0).getCenterX()!=0) fail("Move misapplied "); jsonContent = cf.toJson(); - System.out.println(jsonContent); + //System.out.println(jsonContent); cf.save(); CaDoodleFile loaded = CaDoodleFile.fromFile(cf.getSelf()); if(!MoveCenter.class.isInstance(loaded.getOpperations().get(2))) { @@ -90,11 +92,23 @@ public void test() throws Exception { ; back=loaded.addOpperation(move3); back=loaded.addOpperation(move2); - System.out.println(loaded.toJson()); if(back.get(0).getCenterX()!=distaance) fail("Move failed "); if(back.get(0).getCenterY()!=distaance) fail("Move failed "); + ToHole hole= new ToHole().setNames(Arrays.asList(nameOne)); + back=loaded.addOpperation(hole); + Group group = new Group().setNames(Arrays.asList(nameOne,nameTwo)); + back=loaded.addOpperation(group); + if(back.size()!=3) + fail("Group Failed "); + String before = loaded.toJson(); + loaded=CaDoodleFile.fromJsonString(before); + String after =loaded.toJson(); + if(!before.contentEquals(after)) + fail("Load and export mismatch"); + System.out.println(after); + } } From e51d0afad2211d4a7422b200aeb804289a1a51ab Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 14:14:28 -0400 Subject: [PATCH 016/635] Adding Resize to workflow for CaDoodle --- .../ICaDoodleOperationAdapterFactory.java | 9 +-- .../scripting/cadoodle/Resize.java | 76 +++++++++++++++++++ .../junit/bowler/TestCaDoodleWorkflow.java | 14 ++++ 3 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index d733197e..665f64af 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -5,13 +5,6 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; -import com.google.gson.*; -import com.google.gson.reflect.TypeToken; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -27,7 +20,7 @@ public ICaDoodleOperationAdapterFactory() { registerType("ToHole", ToHole.class); registerType("Group", Group.class); registerType("UnGroup", UnGroup.class); - + registerType("Resize", Resize.class); } private void registerType(String typeName, Class clazz) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java new file mode 100644 index 00000000..18131320 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -0,0 +1,76 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Resize implements ICaDoodleOpperation { + + @Expose(serialize = true, deserialize = true) + private List names = new ArrayList(); + + @Expose(serialize = true, deserialize = true) + private TransformNR height = null; + @Expose(serialize = true, deserialize = true) + private TransformNR rightFront = null; + @Expose(serialize = true, deserialize = true) + private TransformNR leftRear = null; + + @Override + public String getType() { + return "Resize"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming.stream().map(starting -> { + for (String name : names) { + if (starting.getName().contentEquals(name)) { + return performResize(starting, name); + } + } + return starting; + }).collect(Collectors.toCollection(ArrayList::new))); + return back; + } + + private CSG performResize(CSG starting, String name) { + CSG resizeUp = starting.scaleToMeasurmentZ(height.getZ()) + .toZMin() + .movez(starting.getMinZ()); + double xdimen = rightFront.getX()-leftRear.getX(); + double ydimen = rightFront.getY()-leftRear.getY(); + resizeUp=resizeUp.scaleToMeasurmentX(xdimen) + .scaleToMeasurmentY(ydimen); + resizeUp=resizeUp + .toXMin() + .toYMin() + .movex(leftRear.getX()) + .movey(rightFront.getY()); + return resizeUp; + } + + public Resize setResize(TransformNR h, TransformNR rf, TransformNR lr) { + height = h; + rightFront = rf; + leftRear = lr; + return this; + } + + public List getNames() { + return names; + } + + public Resize setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 65ac6251..c16854d8 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -21,6 +21,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Group; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Resize; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -102,6 +103,19 @@ public void test() throws Exception { back=loaded.addOpperation(group); if(back.size()!=3) fail("Group Failed "); + String groupName = back.get(2).getName(); + System.out.println("Group Name : "+groupName); + TransformNR height = new TransformNR(0,0,40); + TransformNR rightFront = new TransformNR(40,10,0); + TransformNR leftRear = new TransformNR(-10,80,0); + Resize resize = new Resize() + .setResize(height, rightFront, leftRear) + .setNames(Arrays.asList(groupName)) + ; + back = loaded.addOpperation(resize); + + + String before = loaded.toJson(); loaded=CaDoodleFile.fromJsonString(before); String after =loaded.toJson(); From 42b76592dd1b5809da5e23e29d0bb1c09b010f4e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 14:27:28 -0400 Subject: [PATCH 017/635] Updating the API to add lock and hide --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 786a9323..1b537664 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 786a9323a8b8e412c866a715f8afd27bf13556aa +Subproject commit 1b53766455745c41d971612579748e57c1543c80 diff --git a/build.gradle b/build.gradle index f39dffd5..814cb14e 100755 --- a/build.gradle +++ b/build.gradle @@ -226,7 +226,7 @@ api 'org.slf4j:slf4j-simple:1.6.1' //compile group: 'com.neuronrobotics', name:'GithubPasswordManager', version:'0.6.1' //compile "com.neuronrobotics:JavaCad:0.14.0" //compile project('JCSG') -api 'com.neuronrobotics:JavaCad:1.3.0' +api 'com.neuronrobotics:JavaCad:1.4.0' //compile "com.neuronrobotics:CHDK-PTP-Java:0.5.3-SNAPSHOT" //compile "com.neuronrobotics:java-bowler:3.25.4" From 8d4b5cddcfd0ba95329fd73e61d04685e0b8e1c6 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 14:45:20 -0400 Subject: [PATCH 018/635] Adding Mirror --- .../scripting/cadoodle/Mirror.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java new file mode 100644 index 00000000..c3b72604 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -0,0 +1,77 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Mirror implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private TransformNR location=new TransformNR(); + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + + @Override + public String getType() { + return "Move Center"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming + .stream() + .map(csg->{ + for(String name:names) { + if(csg.getName().contentEquals(name)) + return mirror(csg, name) + ; + } + return csg; + }) + .collect(Collectors.toCollection(ArrayList::new)) + ); + return back; + } + + private CSG mirror(CSG csg, String name) { + CSG centered=csg.moveToCenter(); + if(location.getX()>0) { + centered=centered.mirrorx(); + } + if(location.getY()>0) { + centered=centered.mirrory(); + } + if(location.getZ()>0) { + centered=centered.mirrorz(); + } + return centered + .move(csg.getCenter()) + .setName(name) + .syncProperties(csg); + } + + public TransformNR getLocation() { + return location; + } + + public Mirror setLocation(TransformNR location) { + this.location = location; + return this; + } + + public List getNames() { + return names; + } + + public Mirror setNames(List names) { + this.names = names; + return this; + } + +} From d257ddcfada01e9ed6d6cdb6afa0b37eb8355b7e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 15:06:44 -0400 Subject: [PATCH 019/635] Adding Allignment opperation --- .../scripting/cadoodle/Allign.java | 120 ++++++++++++++++++ .../scripting/cadoodle/AllignmentX.java | 7 + .../scripting/cadoodle/AllignmentY.java | 7 + .../scripting/cadoodle/AllignmentZ.java | 7 + 4 files changed, 141 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java new file mode 100644 index 00000000..6393714c --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -0,0 +1,120 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Allign implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Expose (serialize = true, deserialize = true) + public AllignmentZ z=null; + @Expose (serialize = true, deserialize = true) + public AllignmentY y=null; + @Expose (serialize = true, deserialize = true) + public AllignmentX x=null; + @Override + public String getType() { + return "Allign"; + } + + @Override + public List process(List incoming) { + ArrayList toMove = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); + CSG reference=null; + for(CSG c: incoming) { + String name = names.get(0); + if(name.contentEquals(c.getName())) { + back.remove(c); + reference=c; + } + } + for(CSG c: back) { + for(String name:names) + if(name.contentEquals(c.getName())) { + back.remove(c); + toMove.add(c); + } + } + for(CSG c:toMove) { + if(z!=null) { + switch(z) { + case BottomAllign: + back.add( c.toZMin() + .movez(reference.getMinZ())); + break; + case Center: + back.add( c.moveToCenterZ() + .movez(reference.getCenterZ())); + break; + case TopAllign: + back.add( c.toZMax() + .movez(reference.getMaxZ())); + break; + default: + break; + } + } + if(x!=null) { + switch(x) { + case Back: + back.add( c.toXMin() + .movex(reference.getMinX())); + break; + case Center: + back.add( c.moveToCenterX() + .movex(reference.getCenterX())); + break; + case Front: + back.add( c.toXMax() + .movex(reference.getMaxX())); + break; + default: + break; + + } + } + if(y!=null) { + switch(y) { + case Center: + back.add( c.moveToCenterY() + .movey(reference.getCenterY())); + break; + case Left: + back.add( c.toYMax() + .movey(reference.getMaxY())); + break; + case Right: + back.add( c.toYMin() + .movey(reference.getMinY())); + break; + default: + break; + + } + } + } + return back; + } + + public List getNames() { + return names; + } + + public Allign setNames(List names) { + this.names = names; + return this; + } + public Allign setAllignParams(AllignmentX X, AllignmentY Y,AllignmentZ Z) { + x=X; + y=Y; + z=Z; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java new file mode 100644 index 00000000..54c33bb5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public enum AllignmentX { + Back, + Front, + Center, +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java new file mode 100644 index 00000000..bd34269c --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public enum AllignmentY { + Right, + Left, + Center, +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java new file mode 100644 index 00000000..5dc69111 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public enum AllignmentZ { + TopAllign, + BottomAllign, + Center, +} From e2ca7bfc47f874b69f28991c5df1479ddead8c14 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 15:09:26 -0400 Subject: [PATCH 020/635] Show,hide,lock,unlock --- .../bowlerstudio/scripting/cadoodle/Hide.java | 39 +++++++++++++++++++ .../bowlerstudio/scripting/cadoodle/Lock.java | 39 +++++++++++++++++++ .../bowlerstudio/scripting/cadoodle/Show.java | 39 +++++++++++++++++++ .../scripting/cadoodle/UnLock.java | 39 +++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java new file mode 100644 index 00000000..2c5b6690 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Hide implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "Hide"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsHide(true); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public Hide setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java new file mode 100644 index 00000000..2ac84430 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Lock implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "Lock"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsLock(true); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public Lock setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java new file mode 100644 index 00000000..1d10ce65 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Show implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "Show"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsHide(false); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public Show setNames(List names) { + this.names = names; + return this; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java new file mode 100644 index 00000000..5c2c7669 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -0,0 +1,39 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.CSG; + +public class UnLock implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Override + public String getType() { + return "Un-Lock"; + } + + @Override + public List process(List incoming) { + for(CSG c: incoming) { + for(String name:names) { + if(name.contentEquals(c.getName())) { + c.setIsLock(false); + } + } + } + return incoming; + } + + public List getNames() { + return names; + } + + public UnLock setNames(List names) { + this.names = names; + return this; + } + +} From dff90e85484cb3146447d65becb748a88c1265b0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 15:46:01 -0400 Subject: [PATCH 021/635] Adding the parser mapping --- .../scripting/cadoodle/Delete.java | 55 ++++++++++++++++ .../ICaDoodleOperationAdapterFactory.java | 17 +++-- .../scripting/cadoodle/Paste.java | 65 +++++++++++++++++++ 3 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java new file mode 100644 index 00000000..dd3a0422 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -0,0 +1,55 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Delete implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private TransformNR location=new TransformNR(); + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + + @Override + public String getType() { + return "Delete"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming); + for(CSG c:incoming) { + for(String s:names) { + if(s.contentEquals(c.getName())) { + back.remove(c); + } + } + } + return back; + } + + public TransformNR getLocation() { + return location; + } + + public Delete setLocation(TransformNR location) { + this.location = location; + return this; + } + + public List getNames() { + return names; + } + + public Delete setNames(List names) { + this.names = names; + return this; + } +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 665f64af..4cc3b6c1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -14,13 +14,22 @@ public class ICaDoodleOperationAdapterFactory implements TypeAdapterFactory { private final Map, String> classRegistry = new HashMap<>(); public ICaDoodleOperationAdapterFactory() { - registerType("MoveCenter", MoveCenter.class); registerType("AddFromScript", AddFromScript.class); - registerType("ToSolid", ToSolid.class); - registerType("ToHole", ToHole.class); + registerType("Allign", Allign.class); + registerType("Delete", Delete.class); registerType("Group", Group.class); - registerType("UnGroup", UnGroup.class); + registerType("Hide", Hide.class); + registerType("Lock", Lock.class); + registerType("Mirror", Mirror.class); + registerType("MoveCenter", MoveCenter.class); + registerType("Paste", Paste.class); registerType("Resize", Resize.class); + registerType("Show", Show.class); + registerType("ToHole", ToHole.class); + registerType("ToSolid", ToSolid.class); + registerType("UnGroup", UnGroup.class); + registerType("UnLock", UnLock.class); + } private void registerType(String typeName, Class clazz) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java new file mode 100644 index 00000000..fe5b69e8 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -0,0 +1,65 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class Paste implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private TransformNR location=new TransformNR(); + @Expose (serialize = true, deserialize = true) + private List names = new ArrayList(); + @Expose (serialize = true, deserialize = true) + public String paste=null; + @Override + public String getType() { + return "Paste"; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming); + int index=0; + for(CSG c:incoming) { + for(String s:names) { + if(s.contentEquals(c.getName())) { + CSG newOne = c.clone().movex(10); + String name = getPaserID()+(index==0?"":"_"+index); + newOne.setName(name); + back.add(newOne); + } + } + } + return back; + } + + public TransformNR getLocation() { + return location; + } + + public Paste setLocation(TransformNR location) { + this.location = location; + return this; + } + + public List getNames() { + return names; + } + + public Paste setNames(List names) { + this.names = names; + return this; + } + public String getPaserID() { + if(paste==null) + paste=AddFromScript.generateRandomString(); + return paste; + } +} From af50b674e87e94d0d04990044c264daaaf62d097 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 15:54:16 -0400 Subject: [PATCH 022/635] Add color setting to the SOlid set --- .../bowlerstudio/scripting/cadoodle/ToSolid.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index e2cab62c..231e3300 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -6,10 +6,13 @@ import com.google.gson.annotations.Expose; import eu.mihosoft.vrl.v3d.CSG; +import javafx.scene.paint.Color; public class ToSolid implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); + @Expose (serialize = true, deserialize = true) + private Color color = null; @Override public String getType() { return "To Solid"; @@ -21,6 +24,9 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { c.setIsHole(false); + if(color!=null) { + c.setColor(color); + } } } } @@ -36,4 +42,13 @@ public ToSolid setNames(List names) { return this; } + public Color getColor() { + return color; + } + + public ToSolid setColor(Color color) { + this.color = color; + return this; + } + } From 9669f77906617678a9a9dfcf2a0fb343ffccfe95 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 16:06:27 -0400 Subject: [PATCH 023/635] Adding CaDoodle file loader --- .../bowlerstudio/BowlerKernel.java | 6 ++ .../scripting/CaDoodleLoader.java | 76 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 3af0b0d9..fa75c956 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -50,7 +50,9 @@ import com.neuronrobotics.bowlerstudio.creature.IgenerateBed; import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager; import com.neuronrobotics.bowlerstudio.printbed.PrintBedManager; +import com.neuronrobotics.bowlerstudio.scripting.CaDoodleLoader; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; @@ -514,6 +516,10 @@ private static void processReturnedObjects(Object ret, ArrayList csgBits) { if (CSG.class.isInstance(ret)) { csgBits.add((CSG) ret); } + if(CaDoodleFile.class.isInstance(ret)) { + processReturnedObjects(CaDoodleLoader.process((CaDoodleFile)ret), csgBits); + return; + } if (MobileBase.class.isInstance(ret)) { MobileBase ret2 = (MobileBase) ret; MobileBaseCadManager m = MobileBaseCadManager.get(ret2); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java new file mode 100644 index 00000000..f2ddfc35 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -0,0 +1,76 @@ +package com.neuronrobotics.bowlerstudio.scripting; + +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; + +import eu.mihosoft.vrl.v3d.CSG; + +public class CaDoodleLoader implements IScriptingLanguage { + @Override + public Object inlineScriptRun(File code, ArrayList args) throws Exception { + CaDoodleFile loaded = CaDoodleFile.fromFile(code); + return process(loaded); + } + + @Override + public Object inlineScriptRun(String code, ArrayList args) throws Exception { + CaDoodleFile loaded = CaDoodleFile.fromJsonString(code); + return process(loaded); + } + + public static Object process(CaDoodleFile loaded) { + List incoming = loaded.getCurrentState(); + ArrayList back = new ArrayList(); + back.addAll(incoming); + for(CSG c: incoming) { + if(c.isInGroup()) { + back.remove(c); + } + if(c.isHide()) { + back.remove(c); + } + } + return back; + } + + @Override + public String getShellType() { + return "CaDoodle"; + } + + @Override + public boolean getIsTextFile() { + return true; + } + + /** + * Get the contents of an empty file + * + * @return + */ + public String getDefaultContents() { + return "{\n" + + " \"opperations\": [],\n" + + " \"currentIndex\": 0,\n" + + " \"projectName\": \"A Test Project\"\n" + + "}"; + } + + @Override + public ArrayList getFileExtenetion() { + return new ArrayList<>(Arrays.asList("doodle","cadoodle")); + } +} From 5218ac88ec1acd853e4dbd9601de380021f9ebf2 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 16:19:15 -0400 Subject: [PATCH 024/635] Adding loader to engine --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index e51f5282..98f26625 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -183,6 +183,7 @@ public static List flaten(String git,String file, Class type) throws E addScriptingLanguage(new FreecadLoader()); addScriptingLanguage(new FXMLBowlerLoader()); addScriptingLanguage(new OpenSCADLoader()); + addScriptingLanguage(new CaDoodleLoader()); } public static void setWorkspace(File file) { From 84f0dd4c877deb8ee275e69b07a0b414624593b1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 16:26:57 -0400 Subject: [PATCH 025/635] Adding save to the test --- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index c16854d8..4de7b439 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -121,6 +121,7 @@ public void test() throws Exception { String after =loaded.toJson(); if(!before.contentEquals(after)) fail("Load and export mismatch"); + loaded.save(); System.out.println(after); } From 92da43e5eea7d7a4fa04871d102c5578f266eb11 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 16:27:41 -0400 Subject: [PATCH 026/635] updating the saver --- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 4de7b439..07ee0e9c 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -121,6 +121,7 @@ public void test() throws Exception { String after =loaded.toJson(); if(!before.contentEquals(after)) fail("Load and export mismatch"); + loaded.setSelf(cf.getSelf()); loaded.save(); System.out.println(after); From f42da28403f4a9e4c800b4e7ae9f5249ac23aa57 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 17:55:32 -0400 Subject: [PATCH 027/635] Replace CSG objectes with new configurations --- .../scripting/cadoodle/CaDoodleFile.java | 10 ++++++++-- .../bowlerstudio/scripting/cadoodle/Group.java | 13 ++++++++++--- .../bowlerstudio/scripting/cadoodle/Hide.java | 13 +++++++++++-- .../bowlerstudio/scripting/cadoodle/Lock.java | 13 +++++++++++-- .../bowlerstudio/scripting/cadoodle/Show.java | 13 +++++++++++-- .../bowlerstudio/scripting/cadoodle/ToHole.java | 13 +++++++++++-- .../bowlerstudio/scripting/cadoodle/ToSolid.java | 16 +++++++++++----- .../bowlerstudio/scripting/cadoodle/UnLock.java | 13 +++++++++++-- 8 files changed, 84 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4c5c6651..8c8e29e2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -63,20 +63,26 @@ public List addOpperation(ICaDoodleOpperation op) { return currentState; } public void back() { - if(currentIndex>0) + if(isBackAvailible()) currentIndex-=1; updateCurrentFromCache(); } + public boolean isBackAvailible() { + return currentIndex>1; + } private void updateCurrentFromCache() { ICaDoodleOpperation key = getOpperations().get(currentIndex-1); List currentState2 = cache.get(key); setCurrentState(currentState2); } public void forward() { - if(currentIndex process(List incoming) { ArrayList holes = new ArrayList(); ArrayList solids = new ArrayList(); ArrayList back = new ArrayList(); + ArrayList replace = new ArrayList(); back.addAll(incoming); - for(CSG c: incoming) { + for(CSG csg: incoming) { for(String name:names) { - if(name.contentEquals(c.getName())) { - if(c.isHole()) { + if(name.contentEquals(csg.getName())) { + replace.add(csg); + CSG c=csg.clone().syncProperties(csg).setName(name); + if(csg.isHole()) { holes.add(c); }else solids.add(c); c.setGroupMembership(getGroupID()); c.setIsGroupResult(false); + back.add(c); } } } + for(CSG c:replace) { + back.remove(c); + } CSG result =null; if(holes.size()>0&&solids.size()==0) { result = CSG.unionAll(holes); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 2c5b6690..362b12c7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -17,14 +17,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsHide(true); + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsHide(true); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index 2ac84430..b09f5f35 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -17,14 +17,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsLock(true); + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsLock(true); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 1d10ce65..1b02bcd2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -17,14 +17,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsHide(false); + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsHide(false); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index ad2cb125..c4f642d5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -17,14 +17,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsHole(true); + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsHole(true); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 231e3300..2821ba97 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -20,17 +20,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsHole(false); - if(color!=null) { - c.setColor(color); - } + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsHole(false); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index 5c2c7669..0082961a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -17,14 +17,23 @@ public String getType() { @Override public List process(List incoming) { + ArrayList replace = new ArrayList(); + ArrayList back = new ArrayList(); + back.addAll(incoming); for(CSG c: incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { - c.setIsLock(false); + replace.add(c); + CSG b=c.clone().syncProperties(c); + b.setIsLock(false); + back.add(b); } } } - return incoming; + for(CSG c:replace) { + back.remove(c); + } + return back; } public List getNames() { From f3b230645d284a4cb0171893d91445ce8e7acb97 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 17:58:30 -0400 Subject: [PATCH 028/635] ensure the resize operation doesnt accdentally break the scaling --- .../bowlerstudio/scripting/cadoodle/Resize.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 18131320..7a886dbe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -42,13 +42,13 @@ public List process(List incoming) { } private CSG performResize(CSG starting, String name) { - CSG resizeUp = starting.scaleToMeasurmentZ(height.getZ()) + CSG resizeUp = starting.scaleToMeasurmentZ(Math.abs(height.getZ())) .toZMin() .movez(starting.getMinZ()); double xdimen = rightFront.getX()-leftRear.getX(); double ydimen = rightFront.getY()-leftRear.getY(); - resizeUp=resizeUp.scaleToMeasurmentX(xdimen) - .scaleToMeasurmentY(ydimen); + resizeUp=resizeUp.scaleToMeasurmentX(Math.abs(xdimen)) + .scaleToMeasurmentY(Math.abs(ydimen)); resizeUp=resizeUp .toXMin() .toYMin() From e01172bc97259a5c0fa5622a6b641f672d28cabd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 18:13:58 -0400 Subject: [PATCH 029/635] adding git to API --- GithubPasswordManager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GithubPasswordManager b/GithubPasswordManager index eda3dc60..37ede193 160000 --- a/GithubPasswordManager +++ b/GithubPasswordManager @@ -1 +1 @@ -Subproject commit eda3dc602e1bd50d2340fc9477b76476158c6921 +Subproject commit 37ede193e8f847fab565dd1969cc2ea879486198 From 03182ef85b7575696d6d11718cc53beb2bdf486e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 19:38:57 -0400 Subject: [PATCH 030/635] toSolod sets color --- .../bowlerstudio/scripting/cadoodle/ToSolid.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 2821ba97..3fbffc69 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -29,6 +29,9 @@ public List process(List incoming) { replace.add(c); CSG b=c.clone().syncProperties(c); b.setIsHole(false); + if(color!=null) { + b.setColor(color); + } back.add(b); } } From f4a70527db0b615814d41e40667e5dd97ecd276a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 25 Jul 2024 20:02:50 -0400 Subject: [PATCH 031/635] updateing the toSolid --- .../scripting/cadoodle/ToSolid.java | 29 ++++++++++++++----- .../junit/bowler/TestCaDoodleWorkflow.java | 7 ++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 3fbffc69..af25bb5a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -12,7 +12,16 @@ public class ToSolid implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) - private Color color = null; + private double r=1.0; + @Expose (serialize = true, deserialize = true) + private double g=0; + @Expose (serialize = true, deserialize = true) + private double b=0; + @Expose (serialize = true, deserialize = true) + private double a=1.0; + @Expose (serialize = true, deserialize = true) + private boolean useColor=false; + @Override public String getType() { return "To Solid"; @@ -27,12 +36,12 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); - b.setIsHole(false); - if(color!=null) { - b.setColor(color); + CSG t=c.clone().syncProperties(c); + t.setIsHole(false); + if(useColor) { + t.setColor(getColor()); } - back.add(b); + back.add(t); } } } @@ -52,11 +61,15 @@ public ToSolid setNames(List names) { } public Color getColor() { - return color; + return new Color(r,g,b,a); } public ToSolid setColor(Color color) { - this.color = color; + r=color.getRed(); + g=color.getGreen(); + b=color.getBlue(); + a=color.getOpacity(); + useColor=true; return this; } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 07ee0e9c..75dfd977 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -23,10 +23,12 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Resize; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToSolid; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import javafx.scene.paint.Color; public class TestCaDoodleWorkflow { @@ -113,7 +115,10 @@ public void test() throws Exception { .setNames(Arrays.asList(groupName)) ; back = loaded.addOpperation(resize); - + ToSolid solid = new ToSolid() + .setNames(Arrays.asList(groupName)) + .setColor(Color.BLUE); + back = loaded.addOpperation(solid); String before = loaded.toJson(); From cb0845db6aca7fc4ed3795d7c35d60f341844035 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 26 Jul 2024 10:57:14 -0400 Subject: [PATCH 032/635] Adding state change listener to the CaDoodle core workflow --- .../scripting/cadoodle/CaDoodleFile.java | 56 ++++++++++++++++--- .../cadoodle/ICaDoodleStateUpdate.java | 9 +++ 2 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8c8e29e2..92d7d48c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -22,12 +22,13 @@ import eu.mihosoft.vrl.v3d.CSG; public class CaDoodleFile { + public static final String NO_NAME = "NoName"; @Expose (serialize = true, deserialize = true) private ArrayList opperations = new ArrayList(); @Expose (serialize = true, deserialize = true) private int currentIndex =0; @Expose (serialize = true, deserialize = true) - private String projectName ="NoName"; + private String projectName =NO_NAME; @Expose (serialize = false, deserialize = false) private File self; @Expose (serialize = false, deserialize = false) @@ -39,6 +40,22 @@ public class CaDoodleFile { .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) .create(); + private ArrayList listeners = new ArrayList(); + + public CaDoodleFile clearListeners() { + listeners.clear(); + return this; + } + public CaDoodleFile removeListener(ICaDoodleStateUpdate l) { + if(listeners.contains(l)) + listeners.remove(l); + return this; + } + public CaDoodleFile addListener(ICaDoodleStateUpdate l) { + if(!listeners.contains(l)) + listeners.add(l); + return this; + } public List addOpperation(ICaDoodleOpperation op) { if(currentIndex != getOpperations().size()) { @@ -71,10 +88,13 @@ public boolean isBackAvailible() { return currentIndex>1; } private void updateCurrentFromCache() { - ICaDoodleOpperation key = getOpperations().get(currentIndex-1); + ICaDoodleOpperation key = currentOpperation(); List currentState2 = cache.get(key); setCurrentState(currentState2); } + private ICaDoodleOpperation currentOpperation() { + return getOpperations().get(currentIndex-1); + } public void forward() { if(isForwardAvailible()) currentIndex+=1; @@ -95,6 +115,13 @@ public List getCurrentState() { } private void setCurrentState(List currentState) { this.currentState = currentState; + for(ICaDoodleStateUpdate l:listeners) { + try { + l.onUpdate(currentState, currentOpperation()); + }catch(Throwable e){ + e.printStackTrace(); + } + } } public String getProjectName() { return projectName; @@ -112,11 +139,7 @@ public File save() throws IOException { FileUtils.write(ret, contents,StandardCharsets.UTF_8, false); return ret; } - public static CaDoodleFile fromJsonString(String content ) throws Exception { - CaDoodleFile file =gson.fromJson(content, TT_CaDoodleFile); - file.initialize(); - return file; - } + private void initialize() { for(int i=0;i getOpperations() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java new file mode 100644 index 00000000..f205c5a9 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -0,0 +1,9 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.List; + +import eu.mihosoft.vrl.v3d.CSG; + +public interface ICaDoodleStateUpdate { + public void onUpdate(List currentState, ICaDoodleOpperation source ); +} From 4a0dbee4bd000cf7d0697543f753872c338756a8 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 26 Jul 2024 11:22:16 -0400 Subject: [PATCH 033/635] Add the cadoodle file to the update interface --- .../scripting/cadoodle/CaDoodleFile.java | 12 ++++++------ .../scripting/cadoodle/ICaDoodleStateUpdate.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 92d7d48c..09fd709f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -71,7 +71,7 @@ public List addOpperation(ICaDoodleOpperation op) { try { List process = op.process(getCurrentState()); cache.put(op,process); - setCurrentState(process); + setCurrentState(process,op); currentIndex++; getOpperations().add(op); }catch(Exception ex) { @@ -90,7 +90,7 @@ public boolean isBackAvailible() { private void updateCurrentFromCache() { ICaDoodleOpperation key = currentOpperation(); List currentState2 = cache.get(key); - setCurrentState(currentState2); + setCurrentState(currentState2,key); } private ICaDoodleOpperation currentOpperation() { return getOpperations().get(currentIndex-1); @@ -113,11 +113,11 @@ public CaDoodleFile setSelf(File self) { public List getCurrentState() { return currentState; } - private void setCurrentState(List currentState) { + private void setCurrentState(List currentState, ICaDoodleOpperation op) { this.currentState = currentState; for(ICaDoodleStateUpdate l:listeners) { try { - l.onUpdate(currentState, currentOpperation()); + l.onUpdate(currentState,op,this); }catch(Throwable e){ e.printStackTrace(); } @@ -143,8 +143,8 @@ public File save() throws IOException { private void initialize() { for(int i=0;i currentState, ICaDoodleOpperation source ); + public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); } From fb814b2909a68bcdf8c0c550b4bc65cc802fdd83 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 26 Jul 2024 14:16:14 -0400 Subject: [PATCH 034/635] Apply move and resize to all members of a group --- .../scripting/cadoodle/MoveCenter.java | 3 +- .../scripting/cadoodle/Resize.java | 73 ++++++++++++++----- .../scripting/cadoodle/UnGroup.java | 29 ++++---- .../junit/bowler/TestCaDoodleWorkflow.java | 8 +- 4 files changed, 78 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 98bb6478..3caaa3f3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -27,7 +27,8 @@ public List process(List incoming) { .stream() .map(csg->{ for(String name:names) { - if(csg.getName().contentEquals(name)) + if(csg.getName().contentEquals(name)|| + ( csg.isInGroup() && csg.getGroupMembership().contentEquals(name) ) ) return csg .transformed(TransformFactory.nrToCSG(location)) .setName(name) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 7a886dbe..85e46ac1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -9,6 +9,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class Resize implements ICaDoodleOpperation { @@ -30,31 +31,65 @@ public String getType() { @Override public List process(List incoming) { ArrayList back = new ArrayList(); - back.addAll(incoming.stream().map(starting -> { - for (String name : names) { - if (starting.getName().contentEquals(name)) { - return performResize(starting, name); + back.addAll(incoming); + for(CSG c:incoming) { + for(String name:names) { + if(c.getName().contentEquals(name)) { + performResize(c, name,back); } } - return starting; - }).collect(Collectors.toCollection(ArrayList::new))); + } + return back; } - private CSG performResize(CSG starting, String name) { - CSG resizeUp = starting.scaleToMeasurmentZ(Math.abs(height.getZ())) - .toZMin() - .movez(starting.getMinZ()); - double xdimen = rightFront.getX()-leftRear.getX(); - double ydimen = rightFront.getY()-leftRear.getY(); - resizeUp=resizeUp.scaleToMeasurmentX(Math.abs(xdimen)) - .scaleToMeasurmentY(Math.abs(ydimen)); + private void performResize(CSG starting, String name,ArrayList back) { + back.remove(starting); + ArrayList groupConstituants = new ArrayList(); + if(starting.isGroupResult()) { + for(CSG c:back) { + if(c.isInGroup()) { + if(c.getGroupMembership().contentEquals(name)) { + groupConstituants.add(c); + } + } + } + } + double zScale = Math.abs(height.getZ()); + CSG resizeUp = starting.scaleToMeasurmentZ(zScale); + double zMove = -resizeUp.getMinZ()+starting.getMinZ(); + resizeUp=resizeUp + .movez(zMove); + double xdimen = Math.abs(rightFront.getX()-leftRear.getX()); + double ydimen = Math.abs(rightFront.getY()-leftRear.getY()); + resizeUp=scaleToMeasurmentXY(resizeUp,xdimen,ydimen); + double xMove=-resizeUp.getMinX()+leftRear.getX(); + double yMove = -resizeUp.getMinY()+rightFront.getY(); resizeUp=resizeUp - .toXMin() - .toYMin() - .movex(leftRear.getX()) - .movey(rightFront.getY()); - return resizeUp; + .movex(xMove) + .movey(yMove); + back.removeAll(groupConstituants); + for(CSG c:groupConstituants) { + CSG gc = c.scaleToMeasurmentZ(zScale); + gc=gc + .movez(-gc.getMinZ()+c.getMinZ()); + gc=scaleToMeasurmentXY(gc,xdimen,ydimen); + gc=gc + .movex(xMove) + .movey(yMove); + gc.syncProperties(c).setName(c.getName()); + back.add(gc); + } + + back.add( resizeUp.syncProperties(starting).setName(name)); + } + + private CSG scaleToMeasurmentXY(CSG inc,double x, double y) { + double scalex = x/ inc.getTotalX(); + double scaley = y/ inc.getTotalY(); + + Transform scale = new Transform().scale(scalex,scaley,1); + return inc.moveToCenter().transformed(scale).move(inc.getCenter().transformed(scale)); } public Resize setResize(TransformNR h, TransformNR rf, TransformNR lr) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index f8c6010d..28600022 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -20,26 +20,27 @@ public String getType() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - ArrayList results = new ArrayList(); - for (CSG csg : back) { - if (csg.isGroupResult()) { - for (String name : names) { + + for (CSG csg : incoming) { + for (String name : names) { + if (csg.isGroupResult()) if (csg.getName().contentEquals(name)) { - results.add(csg); + back.remove(csg); } - if (csg.isInGroup()) { - if (csg.getGroupMembership().contentEquals(name)) { - // release this object from the group - csg.setGroupMembership(null); - } + if (csg.isInGroup()) { + if (csg.getGroupMembership().contentEquals(name)) { + // release this object from the group + CSG readd= csg.clone().syncProperties(csg).setName(csg.getName()); + + readd.setGroupMembership(null); + back.remove(csg); + back.add(readd); } } + } } - for(CSG c:results) { - // remove the group results from the list of parts - back.remove(c); - } + return back; } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 75dfd977..c0cacca5 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -24,6 +24,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Resize; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToSolid; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.UnGroup; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -119,8 +120,13 @@ public void test() throws Exception { .setNames(Arrays.asList(groupName)) .setColor(Color.BLUE); back = loaded.addOpperation(solid); + UnGroup ug = new UnGroup().setNames(Arrays.asList(groupName)); + back = loaded.addOpperation(ug); - + Group g = new Group().setNames(Arrays.asList(nameOne,nameTwo)); + back = loaded.addOpperation(g); + + String before = loaded.toJson(); loaded=CaDoodleFile.fromJsonString(before); String after =loaded.toJson(); From 487e88275d5feb9ef0afc715fcaab834d4d78acf Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 26 Jul 2024 14:22:06 -0400 Subject: [PATCH 035/635] use a uniform scale transform for all items --- .../scripting/cadoodle/Resize.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 85e46ac1..8041370d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -56,13 +56,20 @@ private void performResize(CSG starting, String name,ArrayList back) { } } double zScale = Math.abs(height.getZ()); - CSG resizeUp = starting.scaleToMeasurmentZ(zScale); + Number scaleValue = zScale/ starting.getTotalZ(); + + Transform scaleZ =new Transform().scaleZ(scaleValue.doubleValue()); + CSG resizeUp = starting.transformed(scaleZ); double zMove = -resizeUp.getMinZ()+starting.getMinZ(); resizeUp=resizeUp .movez(zMove); double xdimen = Math.abs(rightFront.getX()-leftRear.getX()); double ydimen = Math.abs(rightFront.getY()-leftRear.getY()); - resizeUp=scaleToMeasurmentXY(resizeUp,xdimen,ydimen); + double scalex = xdimen/ resizeUp.getTotalX(); + double scaley = ydimen/ resizeUp.getTotalY(); + + Transform scale = new Transform().scale(scalex,scaley,1); + resizeUp=resizeUp.transformed(scale); double xMove=-resizeUp.getMinX()+leftRear.getX(); double yMove = -resizeUp.getMinY()+rightFront.getY(); resizeUp=resizeUp @@ -70,10 +77,10 @@ private void performResize(CSG starting, String name,ArrayList back) { .movey(yMove); back.removeAll(groupConstituants); for(CSG c:groupConstituants) { - CSG gc = c.scaleToMeasurmentZ(zScale); + CSG gc = c.transformed(scaleZ); gc=gc .movez(-gc.getMinZ()+c.getMinZ()); - gc=scaleToMeasurmentXY(gc,xdimen,ydimen); + gc=gc.transformed(scale); gc=gc .movex(xMove) .movey(yMove); @@ -83,14 +90,11 @@ private void performResize(CSG starting, String name,ArrayList back) { back.add( resizeUp.syncProperties(starting).setName(name)); } - - private CSG scaleToMeasurmentXY(CSG inc,double x, double y) { - double scalex = x/ inc.getTotalX(); - double scaley = y/ inc.getTotalY(); - - Transform scale = new Transform().scale(scalex,scaley,1); - return inc.moveToCenter().transformed(scale).move(inc.getCenter().transformed(scale)); - } +// +// private CSG scaleToMeasurmentXY(CSG inc,double x, double y) { +// +// return inc.moveToCenter().transformed(scale).move(inc.getCenter().transformed(scale)); +// } public Resize setResize(TransformNR h, TransformNR rf, TransformNR lr) { height = h; From c6ad63f376c66e530ef26fb06048c87ed47e63b2 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 26 Jul 2024 15:15:13 -0400 Subject: [PATCH 036/635] adding hole to the last step to check texture loading --- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index c0cacca5..c64a088a 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -125,7 +125,9 @@ public void test() throws Exception { Group g = new Group().setNames(Arrays.asList(nameOne,nameTwo)); back = loaded.addOpperation(g); - + + ToHole h= new ToHole().setNames(Arrays.asList(back.get(2).getName())); + back=loaded.addOpperation(h); String before = loaded.toJson(); loaded=CaDoodleFile.fromJsonString(before); From d39e5056ec2468e6a6d88e5e953bf809cf9a6b41 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 09:08:33 -0400 Subject: [PATCH 037/635] formatting build.gradle --- JCSG | 2 +- build.gradle | 281 ++++++++++++++++----------------------------------- 2 files changed, 87 insertions(+), 196 deletions(-) diff --git a/JCSG b/JCSG index 1b537664..a97352df 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 1b53766455745c41d971612579748e57c1543c80 +Subproject commit a97352df5b2882cd98c3afbd1da10b9d6eb2121b diff --git a/build.gradle b/build.gradle index 814cb14e..dfb83599 100755 --- a/build.gradle +++ b/build.gradle @@ -124,11 +124,11 @@ repositories { url 'https://mlt.jfrog.io/artifactory/mlt-mvn-releases-local/' } maven { url 'https://repo.maven.apache.org/maven2/' } - + maven { url 'https://repo1.maven.org/maven2/'} -//https://jcenter.bintray.com< + //https://jcenter.bintray.com< maven { url 'https://jcenter.bintray.com/'} - + //jcenter() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } //maven { url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } @@ -136,235 +136,129 @@ repositories { //com.neuronrobotics hosting point maven { url 'https://oss.sonatype.org/content/repositories/staging/' } - maven { - url "https://repo.myrobotlab.org/artifactory/myrobotlab/" - content { - includeGroup("de.dfki.mary") - } - } + maven { + url "https://repo.myrobotlab.org/artifactory/myrobotlab/" + content { + includeGroup("de.dfki.mary") + } + } maven { url 'https://maven-central.storage-download.googleapis.com/repos/central/data/'} maven {url 'https://repo.jenkins-ci.org/public/'} - // maven { - // url "https://dl.bintray.com/ihmcrobotics/maven-release/" - // content { - // includeGroup("us.ihmc") - // } - // } - // maven { - // url "https://dl.bintray.com/ihmcrobotics/maven-vendor/" - // content { - // includeGroup("us.ihmc.thirdparty.jinput") - // } - // } } dependencies { + api 'com.neuronrobotics:JavaCad:1.4.1' + api project('java-bowler') + api project('GithubPasswordManager:GithubPasswordManager') + //compile group: "de.swirtz", name: "ktsRunner", version: "0.0.7" -api 'us.ihmc:jinput:2.0.6-ihmc2' -api group: 'us.ihmc', name: 'ihmc-native-library-loader', version: '1.3.1' -//implementation 'net.java.jinput:jinput:2.0.10' // pegged to Java 17, no MacOS m1 support until java updated -//implementation 'net.java.jinput:jinput:2.0.10:natives-all' + api 'us.ihmc:jinput:2.0.6-ihmc2' + api group: 'us.ihmc', name: 'ihmc-native-library-loader', version: '1.3.1' -api 'com.google.crypto.tink:tink:1.3.0-rc1' + api 'com.google.crypto.tink:tink:1.3.0-rc1' -api group: 'org.json', name: 'json', version: '20180813' + api group: 'org.json', name: 'json', version: '20180813' -api 'gov.nist.math:jama:1.0.2' + api 'gov.nist.math:jama:1.0.2' -api group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.6' + api group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.6' -api group: 'org.reactfx', name: 'reactfx', version: '2.0-SNAPSHOT' + api group: 'org.reactfx', name: 'reactfx', version: '2.0-SNAPSHOT' -// https://mvnrepository.com/artifact/org.apache.groovy/groovy -api group: 'org.apache.groovy', name: 'groovy', version: '4.0.22' -//make grapes work -api group: 'org.apache.ivy', name: 'ivy', version: '2.5.1' + // https://mvnrepository.com/artifact/org.apache.groovy/groovy + api group: 'org.apache.groovy', name: 'groovy', version: '4.0.22' + //make grapes work + api group: 'org.apache.ivy', name: 'ivy', version: '2.5.1' //compile group: 'org.controlsfx', name: 'controlsfx', version: '8.0.6' -api group: 'commons-lang', name: 'commons-lang', version: '2.6' -api group: 'commons-codec', name: 'commons-codec', version: '1.7' - - + api group: 'commons-lang', name: 'commons-lang', version: '2.6' + api group: 'commons-codec', name: 'commons-codec', version: '1.7' // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit - implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.13.1.202206130422-r' + api group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.13.1.202206130422-r' // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit.ssh.apache - implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit.ssh.apache', version: '5.13.1.202206130422-r' - + api group: 'org.eclipse.jgit', name: 'org.eclipse.jgit.ssh.apache', version: '5.13.1.202206130422-r' // https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5 -api group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.2.1' + api group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.2.1' + + api group: 'com.squareup.okhttp', name: 'okhttp-urlconnection', version: '2.0.0' + api group: 'org.mockito', name: 'mockito-all', version: '1.9.5' + api group: 'com.infradna.tool', name: 'bridge-method-injector', version: '1.14' + api 'com.miglayout:miglayout-swing:4.2' + api 'commons-io:commons-io:2.6' + api group:'org.python',name:'jython',version:'2.5.3' + api group:'org.python',name:'jython-standalone',version:'2.5.2' + api 'org.clojure:clojure:1.8.0' + // jetty server + api "org.eclipse.jetty:jetty-server:9.0.2.v20130417" + api "org.eclipse.jetty:jetty-servlet:9.0.2.v20130417" + api "org.eclipse.jetty:jetty-servlets:9.0.2.v20130417" + api "org.eclipse.jetty:jetty-webapp:9.0.2.v20130417" + api "javax.servlet:javax.servlet-api:3.1.0" + api group: 'java3d', name: 'vecmath', version: '1.3.1' + api 'org.slf4j:slf4j-simple:1.6.1' -api group: 'com.squareup.okhttp', name: 'okhttp-urlconnection', version: '2.0.0' -api group: 'org.mockito', name: 'mockito-all', version: '1.9.5' -api group: 'com.infradna.tool', name: 'bridge-method-injector', version: '1.14' + api group:'de.huxhorn.sulky', name:'de.huxhorn.sulky.3rdparty.jlayer', version:'1.0' + api 'com.google.code.gson:gson:2.5' + api 'org.jsoup:jsoup:1.8.3' + api 'org.apache.httpcomponents:httpclient:4.5.1' -api 'com.miglayout:miglayout-swing:4.2' -api 'commons-io:commons-io:2.6' -api group:'org.python',name:'jython',version:'2.5.3' -api group:'org.python',name:'jython-standalone',version:'2.5.2' -api 'org.clojure:clojure:1.8.0' - // jetty server -api "org.eclipse.jetty:jetty-server:9.0.2.v20130417" -api "org.eclipse.jetty:jetty-servlet:9.0.2.v20130417" -api "org.eclipse.jetty:jetty-servlets:9.0.2.v20130417" -api "org.eclipse.jetty:jetty-webapp:9.0.2.v20130417" -api "javax.servlet:javax.servlet-api:3.1.0" - - - //compile 'org.clojure:tools.nrepl:0.2.10' - //compile "overtone:overtone:0.9.1" - //compile "edu.cmu.sphinx:sphinx4-core:5prealpha-SNAPSHOT" - //compile "edu.cmu.sphinx:sphinx4-data:5prealpha-SNAPSHOT" -api group: 'java3d', name: 'vecmath', version: '1.3.1' -api 'org.slf4j:slf4j-simple:1.6.1' - - - //compile group: 'com.neuronrobotics', name:'GithubPasswordManager', version:'0.6.1' - //compile "com.neuronrobotics:JavaCad:0.14.0" - //compile project('JCSG') -api 'com.neuronrobotics:JavaCad:1.4.0' - - //compile "com.neuronrobotics:CHDK-PTP-Java:0.5.3-SNAPSHOT" - //compile "com.neuronrobotics:java-bowler:3.25.4" -api project('java-bowler') -api project('GithubPasswordManager:GithubPasswordManager') - //compile fileTree (dir: ':java-bowler/libs/', includes: ['*.jar']) - //compile fileTree (dir: '../java-bowler/build/libs/', includes: ['nrsdk-3.23.3-jar-with-dependencies.jar']) - //compile fileTree (dir: '../JCSG/build/libs/', includes: ['JavaCad-0.8.2.jar']) - //compile "com.neuronroboticsp:WalnutiQ:2.3.3" - - - /* - String basedir =System.getenv("OPENCV_DIR")+"/java/opencv-249.jar"; - if(isWindows()){ - basedir =System.getenv("OPENCV_DIR")+"\\..\\..\\java\\opencv-249.jar"; - println("OPENCV_DIR="+basedir); - compile files(basedir) - } - if(isOSX()){ - basedir =System.getenv("OPENCV_DIR")+"../../java/opencv-249.jar"; - println("OPENCV_DIR="+basedir); - if(System.getenv("OPENCV_DIR")!=null) - compile files(basedir) - else - //If you set your OPENCV_DIR environment variable, then we wouldnt have to do hacky things - compile files('/Applications/BowlerStudio.app/Contents/MacOS/opencv249build/bin/opencv-249.jar') - } - if(isLinux()){ - //compile files('/usr/share/java/opencv-249.jar') - if(new File("/usr/share/OpenCV/java/").exists()){ - System.out.println("Using the legacy opencv dir ") - compile fileTree (dir: '/usr/share/OpenCV/java/', includes: ['*opencv-24*.jar']) - }else{ - compile fileTree (dir: '/usr/share/java/', includes: ['*opencv-24*.jar']) - } - } - */ - //compile group: 'jfree', name: 'jfreechart', version: '1.0.12' - //compile group: 'jexcelapi', name: 'jxl', version: '2.4.2' - //compile group: 'com.google.zxing', name: 'zxing-parent', version: '3.2.0' - //compile group:'com.github.ellzord', name:'JALSE', version:'1.0.9' - -api group:'de.huxhorn.sulky', name:'de.huxhorn.sulky.3rdparty.jlayer', version:'1.0' - //compile("org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE") - -api 'com.google.code.gson:gson:2.5' -api 'org.jsoup:jsoup:1.8.3' -api 'org.apache.httpcomponents:httpclient:4.5.1' - //compile 'cz.advel.jbullet:jbullet:20101010-1' - //compile 'org.bubblecloud.jbullet:jbullet:2.72.2.4'// jars local because mave repo for this went down - //compile "alda:alda:1.0.0-rc14" - - //Deep Learning 4 j and dependancies - /* - compile 'org.deeplearning4j:deeplearning4j-core:0.4-rc3.8' - //compile 'org.nd4j:nd4j-x86:0.4-rc3.8' - compile 'org.deeplearning4j:deeplearning4j-nlp:0.4-rc3.8' - compile 'org.deeplearning4j:deeplearning4j-ui:0.4-rc3.8' - //compile 'com.google.guava:guava:19.0' - compile 'org.nd4j:canova-nd4j-image:0.0.0.14' - compile 'org.nd4j:canova-nd4j-codec:0.0.0.14' - compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.1' - */ - // JScience: - //compile 'org.jscience:jscience:4.3.1' - - //compile 'javax.media:jmf:2.1.1e' - - //Weka - //compile 'nz.ac.waikato.cms.weka:weka-stable:3.6.13' - - //Firmata -api 'com.github.kurbatov:firmata4j:2.3.4.1' + api 'com.github.kurbatov:firmata4j:2.3.4.1' testImplementation 'junit:junit:4.10' -//api fileTree (dir: 'libs', includes: ['*.jar']) - // https://mvnrepository.com/artifact/com.github.stephengold/jbullet api group: 'com.github.stephengold', name: 'jbullet', version: '1.0.3' - - implementation('de.dfki.mary:voice-cmu-slt-hsmm:5.2.1') - { + + implementation('de.dfki.mary:voice-cmu-slt-hsmm:5.2.1') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' exclude group: 'gov.nist.math', module: 'Jampack' } - implementation('de.dfki.mary:voice-dfki-poppy-hsmm:5.2') - { + implementation('de.dfki.mary:voice-dfki-poppy-hsmm:5.2') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' exclude group: 'gov.nist.math', module: 'Jampack' } -// implementation('de.dfki.mary:voice-cmu-awb-time:5.2') -// { -// exclude group: 'commons-io', module: 'commons-io' -// } - implementation('de.dfki.mary:voice-dfki-prudence-hsmm:5.2') - { + + implementation('de.dfki.mary:voice-dfki-prudence-hsmm:5.2') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' exclude group: 'gov.nist.math', module: 'Jampack' } - implementation('de.dfki.mary:voice-dfki-spike-hsmm:5.2') - { + implementation('de.dfki.mary:voice-dfki-spike-hsmm:5.2') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' exclude group: 'gov.nist.math', module: 'Jampack' } - implementation('de.dfki.mary:voice-cmu-rms-hsmm:5.2') - { - exclude group: 'commons-io', module: 'commons-io' - - exclude group: 'com.twmacinta', module: 'fast-md5' - exclude group: 'gov.nist.math', module: 'Jampack' - } - implementation('de.dfki.mary:voice-dfki-obadiah-hsmm:5.2') - { - exclude group: 'commons-io', module: 'commons-io' - - exclude group: 'com.twmacinta', module: 'fast-md5' - exclude group: 'gov.nist.math', module: 'Jampack' - } - implementation('de.dfki.mary:voice-cmu-rms-hsmm:5.2') - { - exclude group: 'commons-io', module: 'commons-io' - - exclude group: 'com.twmacinta', module: 'fast-md5' - exclude group: 'gov.nist.math', module: 'Jampack' - } - implementation('de.dfki.mary:voice-cmu-bdl-hsmm:5.2') - { - exclude group: 'commons-io', module: 'commons-io' - - exclude group: 'com.twmacinta', module: 'fast-md5' - exclude group: 'gov.nist.math', module: 'Jampack' - } - implementation('de.dfki.mary:marytts-lang-en:5.2.1') - { + implementation('de.dfki.mary:voice-cmu-rms-hsmm:5.2') { + exclude group: 'commons-io', module: 'commons-io' + + exclude group: 'com.twmacinta', module: 'fast-md5' + exclude group: 'gov.nist.math', module: 'Jampack' + } + implementation('de.dfki.mary:voice-dfki-obadiah-hsmm:5.2') { + exclude group: 'commons-io', module: 'commons-io' + + exclude group: 'com.twmacinta', module: 'fast-md5' + exclude group: 'gov.nist.math', module: 'Jampack' + } + implementation('de.dfki.mary:voice-cmu-rms-hsmm:5.2') { + exclude group: 'commons-io', module: 'commons-io' + + exclude group: 'com.twmacinta', module: 'fast-md5' + exclude group: 'gov.nist.math', module: 'Jampack' + } + implementation('de.dfki.mary:voice-cmu-bdl-hsmm:5.2') { + exclude group: 'commons-io', module: 'commons-io' + + exclude group: 'com.twmacinta', module: 'fast-md5' + exclude group: 'gov.nist.math', module: 'Jampack' + } + implementation('de.dfki.mary:marytts-lang-en:5.2.1') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' exclude group: 'gov.nist.math', module: 'Jampack' @@ -391,8 +285,7 @@ api 'com.github.kurbatov:firmata4j:2.3.4.1' // https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.5' // https://mvnrepository.com/artifact/com.alphacephei/vosk - implementation( 'com.alphacephei:vosk:0.3.38') - { + implementation( 'com.alphacephei:vosk:0.3.38') { exclude group: 'net.java.dev.jna', module: 'jna' } // Add OpenCV @@ -404,7 +297,7 @@ api 'com.github.kurbatov:firmata4j:2.3.4.1' implementation 'org.apache.commons:commons-compress:1.26.2' // Addiing advance system execution for advanced editors implementation 'org.apache.commons:commons-exec:1.3' - + implementation 'org.tukaani:xz:1.9' implementation 'org.brotli:dec:0.1.2' // Add this for Brotli support // Add 7z native bindings @@ -412,8 +305,6 @@ api 'com.github.kurbatov:firmata4j:2.3.4.1' implementation 'net.sf.sevenzipjbinding:sevenzipjbinding-all-platforms:16.02-2.01' // inkscape loading implementation group: 'org.apache.xmlgraphics', name: 'batik-all', version: '1.17' - - } @@ -457,13 +348,13 @@ archivesBaseName = "bowler-script-kernel" task javadocJar(type: Jar) { if (project == rootProject) - classifier = 'javadoc' + classifier = 'javadoc' from javadoc } task sourcesJar(type: Jar) { if (project == rootProject) - classifier = 'sources' + classifier = 'sources' from sourceSets.main.allSource } From 40166cdc8ed0a342300e6340bbb072593a986968 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 10:26:12 -0400 Subject: [PATCH 038/635] https://github.com/CommonWealthRobotics/BowlerStudio/issues/372#issuecomment-2256066891 --- .../scripting/ScriptingEngine.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 98f26625..e8a3f299 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -390,6 +390,7 @@ public static boolean isUrlAlreadyOpen(String URL) { */ public static Git openGit(Repository localRepo) { + try { Object[] keySet; synchronized(gitOpenTimeout) { @@ -424,6 +425,11 @@ public static Git openGit(Repository localRepo) { gitOpenTimeout.put(git, makeTimeoutThread(git)); return git; + }catch(Throwable t) { + new IssueReportingExceptionHandler().except(t); + throw new RuntimeException(t); + + } } /** @@ -1909,25 +1915,20 @@ public static boolean checkOwner(String url) { } public static boolean checkOwner(File currentFile) { + Git git; try { - Git git; - try { - git = locateGit(currentFile); - } catch (Exception e1) { - - return false; - } - boolean owned; - try { - owned = checkOwner(git); - } catch (Throwable t) { - owned = false; - } - closeGit(git); - return owned; - } catch (Throwable t) { + git = locateGit(currentFile); + } catch (Throwable e1) { return false; } + boolean owned; + try { + owned = checkOwner(git); + } catch (Throwable t) { + owned = false; + } + closeGit(git); + return owned; } private static boolean checkOwner(Git git) { From 8c018e69e011f4eff168a73df0b295e5176c301c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 11:56:01 -0400 Subject: [PATCH 039/635] Adding simplication of meshes --- .../bowlerstudio/scripting/BlenderLoader.java | 39 +++++++++++++++++-- .../util/GeometrySimplification.java | 32 +++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index a2dd6f85..ca4ece25 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -51,19 +51,19 @@ public static void toBlenderFile(CSG stlIn,File blenderfile) throws IOException } - public static void toBlenderFile(File incoming,File blenderfile) { + public static void toBlenderFile(File stl,File blenderfile) { System.out.println("Converting to Blender file before loading"); File stlIn; try { - stlIn = File.createTempFile(incoming.getName(), ".stl"); + stlIn = File.createTempFile(stl.getName(), ".stl"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } stlIn.deleteOnExit(); - scaleStl(incoming,stlIn,0.001); + scaleStl(stl,stlIn,0.001); File dir = stlIn.getAbsoluteFile().getParentFile(); try { @@ -99,6 +99,39 @@ public static void scaleStl(File incoming, File outgoing, double scale) { e.printStackTrace(); } } + public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { + File stl = DownloadManager.getTmpSTL(incoming); + remeshSTLFile(stl, MMVoxel); + CSG back = Vitamins.get(stl,true); + return back.syncProperties(incoming).setName(incoming.getName()); + } + public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { + File blend = File.createTempFile(stlout.getName(), ".blend"); + blend.deleteOnExit(); + toBlenderFile(stlout, blend); + remeshToSTLFile(blend, stlout, MMVoxel); + } + public static void remeshToSTLFile(File blenderfile,File stlout,double MMVoxel) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + File exe = getConfigExecutable("blender", null); + File export = ScriptingEngine.fileFromGit( + "https://github.com/CommonWealthRobotics/blender-bowler-cli.git", + "remesh.py"); + ArrayList args = new ArrayList<>(); + + if(stlout.exists()) + stlout.delete(); + args.add(exe.getAbsolutePath()); + + args.add("--background"); + args.add("--python"); + args.add(export.getAbsolutePath()); + args.add("--"); + args.add(blenderfile.getAbsolutePath()); + args.add(""+(MMVoxel/1000.0)); + args.add(stlout.getAbsolutePath()); + legacySystemRun(null, stlout.getAbsoluteFile().getParentFile(), System.out, args); + scaleStl(stlout,stlout,1000.0); + } public static void toSTLFile(File blenderfile,File stlout) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { File exe = getConfigExecutable("blender", null); File export = ScriptingEngine.fileFromGit( diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java new file mode 100644 index 00000000..2454561d --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -0,0 +1,32 @@ +package com.neuronrobotics.bowlerstudio.util; + +import java.io.File; + +import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; + +import eu.mihosoft.vrl.v3d.CSG; + +public class GeometrySimplification { + /** + * Re-mesh the CSG to a voxelated mesh + * @param incoming the incoming CSG + * @param MMVoxel the mm dimentions of the voxel + * @return a re-meshed CSG + * @throws Exception + */ + public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { + return BlenderLoader.remesh(incoming, MMVoxel); + } + /** + * RE-mesh an STL file in place + * This modifys the original STL + * @param stlout the file in which he STL is stored + * @param MMVoxel the mm dimention of the voxels + * @throws Exception + */ + public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { + BlenderLoader.remeshSTLFile(stlout, MMVoxel); + } +} From 9f3198a138148c053defb4a359cd2014e472cefa Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 12:17:13 -0400 Subject: [PATCH 040/635] testing the blender remeshing --- .../bowlerstudio/scripting/BlenderLoader.java | 2 +- .../bowlerstudio/util/GeometrySimplification.java | 3 --- test/java/src/junit/bowler/BlenderLoadingTest.java | 7 +++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index ca4ece25..a795cf72 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -107,7 +107,7 @@ public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { } public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { File blend = File.createTempFile(stlout.getName(), ".blend"); - blend.deleteOnExit(); + blend.delete(); toBlenderFile(stlout, blend); remeshToSTLFile(blend, stlout, MMVoxel); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java index 2454561d..15e4754b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -3,9 +3,6 @@ import java.io.File; import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader; -import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; -import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; - import eu.mihosoft.vrl.v3d.CSG; public class GeometrySimplification { diff --git a/test/java/src/junit/bowler/BlenderLoadingTest.java b/test/java/src/junit/bowler/BlenderLoadingTest.java index de97fbbd..26468d9d 100644 --- a/test/java/src/junit/bowler/BlenderLoadingTest.java +++ b/test/java/src/junit/bowler/BlenderLoadingTest.java @@ -5,8 +5,10 @@ import org.junit.Test; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.util.GeometrySimplification; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Cube; public class BlenderLoadingTest { @@ -18,6 +20,11 @@ public void test() throws Exception { if(loaded.getPolygons().size()!=12) fail("Failed to load polygon!"); System.out.println("Blender file loaded num polys: "+loaded.getPolygons().size()); + CSG cube = new Cube(100).toCSG(); + CSG remeshed = GeometrySimplification.remesh(cube, 10.0); + if(remeshed.getPolygons().size()!=1452) + fail("Blender failed to remesh"); + System.out.println("Remeshing produced: "+remeshed.getPolygons().size()); } } From e904b89247324a3233ae1631b8e153934930a89f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 18:17:40 -0400 Subject: [PATCH 041/635] fix a bug with grouping all solids --- .../bowlerstudio/scripting/cadoodle/Group.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index c4fc9b2a..f24fd72b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -48,9 +48,13 @@ public List process(List incoming) { result.setIsHole(true); }else { - CSG holecutter = CSG.unionAll(holes); - CSG solid = CSG.unionAll(solids); - result=solid.difference(holecutter); + + CSG holecutter =null; + if(holes.size()>0) + holecutter=CSG.unionAll(holes); + result = CSG.unionAll(solids); + if(holecutter!=null) + result=result.difference(holecutter); result.setIsHole(false); } result.setIsGroupResult(true); From 9a5ab7e2c805a029203227ca236103d36100a698 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 21:30:44 -0400 Subject: [PATCH 042/635] Updating the Javacad version --- JCSG | 2 +- build.gradle | 2 +- .../scripting/cadoodle/Group.java | 1 - .../scripting/cadoodle/Paste.java | 29 +++++++++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/JCSG b/JCSG index a97352df..0b907ec3 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit a97352df5b2882cd98c3afbd1da10b9d6eb2121b +Subproject commit 0b907ec3cf53aa62a5338b6403b6d3b2f57dfb70 diff --git a/build.gradle b/build.gradle index dfb83599..9ba443b0 100755 --- a/build.gradle +++ b/build.gradle @@ -148,7 +148,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.4.1' + api 'com.neuronrobotics:JavaCad:1.5.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index f24fd72b..56ee49c0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -48,7 +48,6 @@ public List process(List incoming) { result.setIsHole(true); }else { - CSG holecutter =null; if(holes.size()>0) holecutter=CSG.unionAll(holes); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index fe5b69e8..b0f48630 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -27,19 +27,38 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); int index=0; - for(CSG c:incoming) { + for (int i = 0; i < incoming.size(); i++) { + CSG c = incoming.get(i); for(String s:names) { if(s.contentEquals(c.getName())) { - CSG newOne = c.clone().movex(10); - String name = getPaserID()+(index==0?"":"_"+index); - newOne.setName(name); - back.add(newOne); + index = copyPasteMoved(back, index, c); + if(c.isGroupResult()) { + String groupName = c.getName(); + for(int j=0;j back, int index, CSG c) { + CSG newOne = c.clone().movex(10); + String name = getPaserID()+(index==0?"":"_"+index); + index++; + newOne.syncProperties(c).setName(name); + back.add(newOne); + return index; + } + public TransformNR getLocation() { return location; } From 0ea9d3a02e29eeeff688b6bd181f5beb44f1a108 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 29 Jul 2024 22:14:21 -0400 Subject: [PATCH 043/635] working ungroup and group with the new API --- .../scripting/cadoodle/Group.java | 5 +-- .../scripting/cadoodle/MoveCenter.java | 2 +- .../scripting/cadoodle/Paste.java | 8 +++- .../scripting/cadoodle/Resize.java | 2 +- .../scripting/cadoodle/UnGroup.java | 4 +- .../junit/bowler/TestCaDoodleWorkflow.java | 45 +++++++++++++++++-- 6 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 56ee49c0..be8c2f9a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -33,8 +33,7 @@ public List process(List incoming) { holes.add(c); }else solids.add(c); - c.setGroupMembership(getGroupID()); - c.setIsGroupResult(false); + c.addGroupMembership(getGroupID()); back.add(c); } } @@ -56,7 +55,7 @@ public List process(List incoming) { result=result.difference(holecutter); result.setIsHole(false); } - result.setIsGroupResult(true); + result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); back.add(result); return back; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 3caaa3f3..5b6be942 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -28,7 +28,7 @@ public List process(List incoming) { .map(csg->{ for(String name:names) { if(csg.getName().contentEquals(name)|| - ( csg.isInGroup() && csg.getGroupMembership().contentEquals(name) ) ) + ( csg.isInGroup() && csg.checkGroupMembership(name) ) ) return csg .transformed(TransformFactory.nrToCSG(location)) .setName(name) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index b0f48630..2589a11e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -34,12 +34,18 @@ public List process(List incoming) { index = copyPasteMoved(back, index, c); if(c.isGroupResult()) { String groupName = c.getName(); + CSG newGroupResult= back.get(back.size()-1); + newGroupResult.removeIsGroupResult(groupName); + newGroupResult.addIsGroupResult(newGroupResult.getName()); for(int j=0;j back) { if(starting.isGroupResult()) { for(CSG c:back) { if(c.isInGroup()) { - if(c.getGroupMembership().contentEquals(name)) { + if(c.checkGroupMembership(name)) { groupConstituants.add(c); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 28600022..a181128b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -28,11 +28,11 @@ public List process(List incoming) { back.remove(csg); } if (csg.isInGroup()) { - if (csg.getGroupMembership().contentEquals(name)) { + if (csg.checkGroupMembership(name)) { // release this object from the group CSG readd= csg.clone().syncProperties(csg).setName(csg.getName()); - readd.setGroupMembership(null); + readd.removeGroupMembership(name); back.remove(csg); back.add(readd); } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index c64a088a..f0623847 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -21,6 +21,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Group; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Paste; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Resize; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToSolid; @@ -44,10 +45,10 @@ public void test() throws Exception { AddFromScript cube1 = new AddFromScript() .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", - "cube.groovy"); + "sphere.groovy"); AddFromScript cube2 = new AddFromScript() .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", - "cube.groovy"); + "sphere.groovy"); Listback= cf.addOpperation(cube1); if(back.size()!=1) fail("Adding a cube should have added one!"); @@ -106,6 +107,18 @@ public void test() throws Exception { back=loaded.addOpperation(group); if(back.size()!=3) fail("Group Failed "); + if(!back.get(0).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(!back.get(1).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(back.get(2).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(!back.get(2).isGroupResult()) { + fail("THis should not be in a group anymore"); + } String groupName = back.get(2).getName(); System.out.println("Group Name : "+groupName); TransformNR height = new TransformNR(0,0,40); @@ -122,10 +135,36 @@ public void test() throws Exception { back = loaded.addOpperation(solid); UnGroup ug = new UnGroup().setNames(Arrays.asList(groupName)); back = loaded.addOpperation(ug); + if(back.get(0).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(back.get(1).isInGroup()) { + fail("THis should not be in a group anymore"); + } Group g = new Group().setNames(Arrays.asList(nameOne,nameTwo)); back = loaded.addOpperation(g); - + String newGroupName = back.get(back.size()-1).getName(); + Paste paste = new Paste().setNames(Arrays.asList(newGroupName)); + back = loaded.addOpperation(paste); + ArrayList selectAll = new ArrayList(); + for(CSG c:back) { + if(c.isGroupResult()) + selectAll.add(c.getName()); + } + back = loaded.addOpperation(new UnGroup().setNames(selectAll)); + if(back.get(0).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(back.get(1).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(back.get(2).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(back.get(3).isInGroup()) { + fail("THis should not be in a group anymore"); + } ToHole h= new ToHole().setNames(Arrays.asList(back.get(2).getName())); back=loaded.addOpperation(h); From 6e5ee442acf09893bf4fe55398a6a47364cbec35 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 11:10:59 -0400 Subject: [PATCH 044/635] Fixing the dataa bleed of cloned hashsets instead of cloned content of hash sets --- JCSG | 2 +- build.gradle | 2 +- .../junit/bowler/TestCaDoodleWorkflow.java | 23 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/JCSG b/JCSG index 0b907ec3..ffcae268 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 0b907ec3cf53aa62a5338b6403b6d3b2f57dfb70 +Subproject commit ffcae268e16de0734687f47d5d0f10d53d291817 diff --git a/build.gradle b/build.gradle index 9ba443b0..5a56bb9d 100755 --- a/build.gradle +++ b/build.gradle @@ -148,7 +148,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.5.0' + api 'com.neuronrobotics:JavaCad:1.5.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index f0623847..a292ee1c 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -105,6 +105,7 @@ public void test() throws Exception { back=loaded.addOpperation(hole); Group group = new Group().setNames(Arrays.asList(nameOne,nameTwo)); back=loaded.addOpperation(group); + List cacheOfGroup = loaded.getCurrentState(); if(back.size()!=3) fail("Group Failed "); if(!back.get(0).isInGroup()) { @@ -117,7 +118,7 @@ public void test() throws Exception { fail("THis should not be in a group anymore"); } if(!back.get(2).isGroupResult()) { - fail("THis should not be in a group anymore"); + fail("THis should be aa group result"); } String groupName = back.get(2).getName(); System.out.println("Group Name : "+groupName); @@ -176,6 +177,26 @@ public void test() throws Exception { loaded.setSelf(cf.getSelf()); loaded.save(); System.out.println(after); + + for(int i=0;i<3;i++) { + loaded.back(); + } + List goBackResult = loaded.getCurrentState(); + if(goBackResult.size()!=3) { + fail(" Number of elements after back incorrect!"); + } + if(!back.get(0).isInGroup()) { + fail("This should be in a group"); + } + if(!back.get(1).isInGroup()) { + fail("This should be in a group"); + } + if(back.get(2).isInGroup()) { + fail("THis should not be in a group anymore"); + } + if(!back.get(2).isGroupResult()) { + fail("THis should be a group result"); + } } From 480fa1214846862d51a392809c584273b16bf398 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 11:16:11 -0400 Subject: [PATCH 045/635] JavaCad bugfix --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index ffcae268..e8bc0bd3 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit ffcae268e16de0734687f47d5d0f10d53d291817 +Subproject commit e8bc0bd36b6d079012a6b84c585dd81478755a26 diff --git a/build.gradle b/build.gradle index 5a56bb9d..1be7720a 100755 --- a/build.gradle +++ b/build.gradle @@ -148,7 +148,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.5.1' + api 'com.neuronrobotics:JavaCad:1.5.2' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 92c668be0c72308b7bffe21c4655fd9c2d63f89c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 12:21:11 -0400 Subject: [PATCH 046/635] Unit Test to test going back and valiting the results --- JCSG | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 40 +++++++++----- .../junit/bowler/TestCaDoodleWorkflow.java | 53 +++++++++++-------- 3 files changed, 60 insertions(+), 35 deletions(-) diff --git a/JCSG b/JCSG index e8bc0bd3..92f2826a 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e8bc0bd36b6d079012a6b84c585dd81478755a26 +Subproject commit 92f2826a1cba0e24fc6fa48da72d01563422b6c9 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 09fd709f..f0365178 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -20,6 +20,7 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.PropertyStorage; public class CaDoodleFile { public static final String NO_NAME = "NoName"; @@ -31,8 +32,8 @@ public class CaDoodleFile { private String projectName =NO_NAME; @Expose (serialize = false, deserialize = false) private File self; - @Expose (serialize = false, deserialize = false) - private List currentState = new ArrayList(); +// @Expose (serialize = false, deserialize = false) +// private List currentState = new ArrayList(); @Expose (serialize = false, deserialize = false) private HashMap> cache =new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() {}.getType(); @@ -70,14 +71,21 @@ public List addOpperation(ICaDoodleOpperation op) { } try { List process = op.process(getCurrentState()); - cache.put(op,process); - setCurrentState(process,op); + storeResultInCache(op, process); + setCurrentState(op); currentIndex++; getOpperations().add(op); }catch(Exception ex) { ex.printStackTrace(); } - return currentState; + return getCurrentState(); + } + private void storeResultInCache(ICaDoodleOpperation op, List process) { + ArrayList cachedCopy = new ArrayList(); + for(CSG c:process) { + cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName())); + } + cache.put(op,cachedCopy); } public void back() { if(isBackAvailible()) @@ -89,8 +97,8 @@ public boolean isBackAvailible() { } private void updateCurrentFromCache() { ICaDoodleOpperation key = currentOpperation(); - List currentState2 = cache.get(key); - setCurrentState(currentState2,key); + System.out.println("Current opperation results: "+key.getType()); + setCurrentState(key); } private ICaDoodleOpperation currentOpperation() { return getOpperations().get(currentIndex-1); @@ -111,13 +119,15 @@ public CaDoodleFile setSelf(File self) { return this; } public List getCurrentState() { - return currentState; + if(currentIndex==0) + return new ArrayList(); + return cache.get(currentOpperation()); } - private void setCurrentState(List currentState, ICaDoodleOpperation op) { - this.currentState = currentState; + private void setCurrentState(ICaDoodleOpperation op) { + for(ICaDoodleStateUpdate l:listeners) { try { - l.onUpdate(currentState,op,this); + l.onUpdate(getCurrentState(),op,this); }catch(Throwable e){ e.printStackTrace(); } @@ -141,11 +151,15 @@ public File save() throws IOException { } private void initialize() { + int indexStarting = currentIndex; + currentIndex=0; for(int i=0;i cacheOfGroup = loaded.getCurrentState(); if(back.size()!=3) fail("Group Failed "); if(!back.get(0).isInGroup()) { @@ -143,17 +142,24 @@ public void test() throws Exception { fail("THis should not be in a group anymore"); } - Group g = new Group().setNames(Arrays.asList(nameOne,nameTwo)); - back = loaded.addOpperation(g); - String newGroupName = back.get(back.size()-1).getName(); - Paste paste = new Paste().setNames(Arrays.asList(newGroupName)); - back = loaded.addOpperation(paste); + + back = loaded.addOpperation( + new Group() + .setNames(Arrays.asList(nameOne,nameTwo)) + ); + List cacheOfGroup = loaded.getCurrentState(); + + String newGroupName = cacheOfGroup.get(cacheOfGroup.size()-1).getName(); + + back = loaded.addOpperation( + new Paste().setNames(Arrays.asList(newGroupName))); ArrayList selectAll = new ArrayList(); for(CSG c:back) { if(c.isGroupResult()) selectAll.add(c.getName()); } - back = loaded.addOpperation(new UnGroup().setNames(selectAll)); + back = loaded.addOpperation( + new UnGroup().setNames(selectAll)); if(back.get(0).isInGroup()) { fail("THis should not be in a group anymore"); } @@ -168,35 +174,40 @@ public void test() throws Exception { } ToHole h= new ToHole().setNames(Arrays.asList(back.get(2).getName())); back=loaded.addOpperation(h); - - String before = loaded.toJson(); - loaded=CaDoodleFile.fromJsonString(before); - String after =loaded.toJson(); - if(!before.contentEquals(after)) - fail("Load and export mismatch"); - loaded.setSelf(cf.getSelf()); loaded.save(); - System.out.println(after); for(int i=0;i<3;i++) { loaded.back(); } List goBackResult = loaded.getCurrentState(); + back=goBackResult; if(goBackResult.size()!=3) { fail(" Number of elements after back incorrect!"); } - if(!back.get(0).isInGroup()) { - fail("This should be in a group"); - } - if(!back.get(1).isInGroup()) { - fail("This should be in a group"); - } if(back.get(2).isInGroup()) { fail("THis should not be in a group anymore"); } if(!back.get(2).isGroupResult()) { fail("THis should be a group result"); } + if(!back.get(0).isInGroup()) { + fail("This should be in a group"); + } + if(!back.get(1).isInGroup()) { + fail("This should be in a group"); + } + + String before = loaded.toJson(); + loaded=CaDoodleFile.fromJsonString(before); + String after =loaded.toJson(); + if(!before.contentEquals(after)) + fail("Load and export mismatch"); + loaded.setSelf(cf.getSelf()); + + System.out.println(after); + + + } From 27d9e67a787355b889c6d3667819103c557972cc Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 12:48:53 -0400 Subject: [PATCH 047/635] make the process opperation into a function to ensure uniformity --- .../scripting/cadoodle/CaDoodleFile.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f0365178..f6017cbd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -57,7 +57,21 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { listeners.add(l); return this; } - + private void initialize() { + int indexStarting = currentIndex; + currentIndex=0; + for(int i=0;i addOpperation(ICaDoodleOpperation op) { if(currentIndex != getOpperations().size()) { for(int i=currentIndex;i addOpperation(ICaDoodleOpperation op) { setOpperations(newList); } try { - List process = op.process(getCurrentState()); - storeResultInCache(op, process); - setCurrentState(op); - currentIndex++; getOpperations().add(op); + process(op); }catch(Exception ex) { ex.printStackTrace(); } @@ -150,18 +161,7 @@ public File save() throws IOException { return ret; } - private void initialize() { - int indexStarting = currentIndex; - currentIndex=0; - for(int i=0;i Date: Tue, 30 Jul 2024 14:11:56 -0400 Subject: [PATCH 048/635] Adding the import from file opperation --- .../scripting/cadoodle/AddFromFile.java | 65 +++++++++++++++++++ .../ICaDoodleOperationAdapterFactory.java | 1 + 2 files changed, 66 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java new file mode 100644 index 00000000..68e641ca --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -0,0 +1,65 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +import eu.mihosoft.vrl.v3d.CSG; + +public class AddFromFile implements ICaDoodleOpperation { + @Expose (serialize = true, deserialize = true) + private String fileLocation=null; + @Expose (serialize = true, deserialize = true) + private String name=null; + private int nameIndex = 0; + public AddFromFile set(File source) { + fileLocation=source.getAbsolutePath(); + return this; + } + + @Override + public String getType() { + return "Add Object"; + } + + private String getOrderedName() { + if(name==null) { + name=AddFromScript.generateRandomString(); + } + if(nameIndex==0) + return name; + nameIndex++; + return name+"_"+nameIndex; + } + + @Override + public List process(List incoming) { + ArrayList back = new ArrayList(); + back.addAll(incoming); + try { + back.addAll(ScriptingEngine + .flaten(new File(fileLocation), CSG.class) + .stream() + .map(csg->{ + return csg + .moveToCenterX() + .moveToCenterY() + .toZMin() + .syncProperties(csg) + .setName(getOrderedName()); + }) + .collect(Collectors.toCollection(ArrayList::new)) + ); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return back; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 4cc3b6c1..426e982a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -14,6 +14,7 @@ public class ICaDoodleOperationAdapterFactory implements TypeAdapterFactory { private final Map, String> classRegistry = new HashMap<>(); public ICaDoodleOperationAdapterFactory() { + registerType("AddFromFile", AddFromFile.class); registerType("AddFromScript", AddFromScript.class); registerType("Allign", Allign.class); registerType("Delete", Delete.class); From 6704d5f00167c079e15b3366e96799fe700d67e7 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 14:12:08 -0400 Subject: [PATCH 049/635] Add a Hull option for later ;) --- .../bowlerstudio/scripting/cadoodle/Group.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index be8c2f9a..4f14caa4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -12,6 +12,8 @@ public class Group implements ICaDoodleOpperation { private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) public String groupID=null; + @Expose (serialize = true, deserialize = true) + public boolean hull=false; @Override public String getType() { return "Group"; @@ -51,6 +53,9 @@ public List process(List incoming) { if(holes.size()>0) holecutter=CSG.unionAll(holes); result = CSG.unionAll(solids); + if(hull) { + result=result.hull(); + } if(holecutter!=null) result=result.difference(holecutter); result.setIsHole(false); @@ -76,4 +81,9 @@ public String getGroupID() { return groupID; } + public Group setHull(boolean hull) { + this.hull = hull; + return this; + } + } From 369f8618857eb0d1ba62bea7f11631e9b3664b12 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 14:12:19 -0400 Subject: [PATCH 050/635] Add the duplicate behavior option --- .../bowlerstudio/scripting/cadoodle/Paste.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 2589a11e..85762452 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -17,6 +17,8 @@ public class Paste implements ICaDoodleOpperation { private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) public String paste=null; + @Expose (serialize = true, deserialize = true) + public double offset=10; @Override public String getType() { return "Paste"; @@ -57,7 +59,7 @@ public List process(List incoming) { } private int copyPasteMoved(ArrayList back, int index, CSG c) { - CSG newOne = c.clone().movex(10); + CSG newOne = c.clone().movex(offset); String name = getPaserID()+(index==0?"":"_"+index); index++; newOne.syncProperties(c).setName(name); @@ -87,4 +89,9 @@ public String getPaserID() { paste=AddFromScript.generateRandomString(); return paste; } + + public Paste setOffset(double offset) { + this.offset = offset; + return this; + } } From 72b717df4a84a14cbbb0ccf2c7954ea6e3ac0e66 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 14:12:31 -0400 Subject: [PATCH 051/635] add a flatten from file option --- .../bowlerstudio/scripting/ScriptingEngine.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index e8a3f299..9d5f7630 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -103,7 +103,7 @@ public static void flatten(ArrayList flat, Object o) { } } - private static void flatenInterna(Object o, Class type,ArrayList flattened){ + public static void flatenInterna(Object o, Class type,ArrayList flattened){ if(type.isInstance(o)) flattened.add((T)o); if(List.class.isInstance(o)) { @@ -125,7 +125,12 @@ public static List flaten(String git,String file, Class type) throws E flatenInterna(o,type,flattened); return flattened; } - + public static List flaten(File f, Class type) throws Exception{ + ArrayList flattened = new ArrayList(); + Object o =inlineFileScriptRun(f, null); + flatenInterna(o,type,flattened); + return flattened; + } private static final ArrayList logListeners = new ArrayList<>(); private static boolean printProgress = true; From 52438867554dd897695bf86b865cb0c3e0912357 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 14:13:00 -0400 Subject: [PATCH 052/635] Use the explicate nname to ensure the same object is made a hole each time --- test/java/src/junit/bowler/TestCaDoodleWorkflow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index b5673f35..cbe8f095 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -172,7 +172,7 @@ public void test() throws Exception { if(back.get(3).isInGroup()) { fail("THis should not be in a group anymore"); } - ToHole h= new ToHole().setNames(Arrays.asList(back.get(2).getName())); + ToHole h= new ToHole().setNames(Arrays.asList(nameTwo)); back=loaded.addOpperation(h); loaded.save(); @@ -196,6 +196,8 @@ public void test() throws Exception { if(!back.get(1).isInGroup()) { fail("This should be in a group"); } + + loaded.save(); String before = loaded.toJson(); loaded=CaDoodleFile.fromJsonString(before); From 5e6c424daecf6b13bb21b3e999bed07dba533539 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 17:17:08 -0400 Subject: [PATCH 053/635] Adding tessalation --- JCSG | 2 +- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/JCSG b/JCSG index 92f2826a..70c3c23f 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 92f2826a1cba0e24fc6fa48da72d01563422b6c9 +Subproject commit 70c3c23f339dd5fd81d3a08fba4252a393862f7d diff --git a/build.gradle b/build.gradle index 1be7720a..3c51aec2 100755 --- a/build.gradle +++ b/build.gradle @@ -148,7 +148,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.5.2' + api 'com.neuronrobotics:JavaCad:1.5.3' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f6017cbd..d6c2fa9e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -7,6 +7,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Random; @@ -93,7 +94,11 @@ public List addOpperation(ICaDoodleOpperation op) { } private void storeResultInCache(ICaDoodleOpperation op, List process) { ArrayList cachedCopy = new ArrayList(); + HashSet names = new HashSet<>(); for(CSG c:process) { + if(names.contains(c.getName())) + throw new RuntimeException("There can not be 2 objects with the same name after an opperation!"); + names.add(c.getName()); cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName())); } cache.put(op,cachedCopy); @@ -154,7 +159,7 @@ public CaDoodleFile setProjectName(String projectName) { public String toJson() { return gson.toJson(this); } - public File save() throws IOException { + public synchronized File save() throws IOException { File ret = self==null?File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"):self; String contents = toJson(); FileUtils.write(ret, contents,StandardCharsets.UTF_8, false); From 666f1304567716bf5aa5624e5f0d9c9d775758a3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 17:53:56 -0400 Subject: [PATCH 054/635] Adding thread synchronization around the file save --- .../scripting/cadoodle/CaDoodleFile.java | 15 +++++--- .../scripting/cadoodle/MoveCenter.java | 36 +++++++++---------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index d6c2fa9e..43e8ab25 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -159,11 +159,16 @@ public CaDoodleFile setProjectName(String projectName) { public String toJson() { return gson.toJson(this); } - public synchronized File save() throws IOException { - File ret = self==null?File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"):self; - String contents = toJson(); - FileUtils.write(ret, contents,StandardCharsets.UTF_8, false); - return ret; + public File save() throws IOException { + + if(self==null){ + self=File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); + } + synchronized(self) { + String contents = toJson(); + FileUtils.write(self, contents,StandardCharsets.UTF_8, false); + } + return self; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 5b6be942..53876a3b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -11,10 +11,11 @@ import eu.mihosoft.vrl.v3d.CSG; public class MoveCenter implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private TransformNR location=new TransformNR(); - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) + private TransformNR location = new TransformNR(); + @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); + @Override public String getType() { return "Move Center"; @@ -23,22 +24,19 @@ public String getType() { @Override public List process(List incoming) { ArrayList back = new ArrayList(); - back.addAll(incoming - .stream() - .map(csg->{ - for(String name:names) { - if(csg.getName().contentEquals(name)|| - ( csg.isInGroup() && csg.checkGroupMembership(name) ) ) - return csg - .transformed(TransformFactory.nrToCSG(location)) - .setName(name) - .syncProperties(csg) - ; - } - return csg; - }) - .collect(Collectors.toCollection(ArrayList::new)) - ); + for (CSG csg : incoming) { + CSG tmpToAdd = csg; + for (String name : names) { + if ( csg.getName().contentEquals(name) || + (csg.isInGroup() && csg.checkGroupMembership(name))) { + tmpToAdd=csg + .transformed(TransformFactory.nrToCSG(location)) + .syncProperties(csg) + .setName(csg.getName()); + } + } + back.add(tmpToAdd); + } return back; } From 36b8869f3f6a9104da325730706c50590a5a80a8 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 18:32:36 -0400 Subject: [PATCH 055/635] Adding the capibility of regenerating the current opperation --- .../scripting/cadoodle/CaDoodleFile.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 43e8ab25..b7da1631 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -68,6 +68,11 @@ private void initialize() { currentIndex=indexStarting; updateCurrentFromCache(); } + public void regenerateCurrent() { + ICaDoodleOpperation op =currentOpperation(); + storeResultInCache(op, op.process(getPreviouState())); + setCurrentState(op); + } private void process(ICaDoodleOpperation op) { storeResultInCache(op, op.process(getCurrentState())); currentIndex++; @@ -116,7 +121,7 @@ private void updateCurrentFromCache() { System.out.println("Current opperation results: "+key.getType()); setCurrentState(key); } - private ICaDoodleOpperation currentOpperation() { + public ICaDoodleOpperation currentOpperation() { return getOpperations().get(currentIndex-1); } public void forward() { @@ -139,6 +144,11 @@ public List getCurrentState() { return new ArrayList(); return cache.get(currentOpperation()); } + public List getPreviouState() { + if(currentIndex<2) + return new ArrayList(); + return cache.get(getOpperations().get(currentIndex-2)); + } private void setCurrentState(ICaDoodleOpperation op) { for(ICaDoodleStateUpdate l:listeners) { @@ -199,4 +209,5 @@ public ArrayList getOpperations() { public void setOpperations(ArrayList opperations) { this.opperations = opperations; } + } From 81abd8c34d356f80c82cf9e29a7162f272a99a46 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 30 Jul 2024 19:05:29 -0400 Subject: [PATCH 056/635] print before loading --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b7da1631..2bb9621b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -197,10 +197,10 @@ public static CaDoodleFile fromFile(File f ) throws Exception{ return fromFile(f,null); } public static CaDoodleFile fromFile(File f,ICaDoodleStateUpdate listener ) throws Exception { + System.out.println("CaDoodle file loading from "+f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file =fromJsonString(content,listener); file.setSelf(f); - System.out.println("CaDoodle file loaded from "+f.getAbsolutePath()); return file; } public ArrayList getOpperations() { From bfa25c2f898e562db4d6f8aadfef8d29ebad46dd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 31 Jul 2024 11:28:07 -0400 Subject: [PATCH 057/635] switch to threadded opperation running with staandarized .join() to wait for opperation competion. --- .../scripting/cadoodle/CaDoodleFile.java | 106 ++++++++++++------ .../CadoodleConcurrencyException.java | 11 ++ .../junit/bowler/TestCaDoodleWorkflow.java | 48 +++++--- 3 files changed, 113 insertions(+), 52 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CadoodleConcurrencyException.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 2bb9621b..10550150 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -32,7 +32,7 @@ public class CaDoodleFile { @Expose (serialize = true, deserialize = true) private String projectName =NO_NAME; @Expose (serialize = false, deserialize = false) - private File self; + private File selfInternal; // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); @Expose (serialize = false, deserialize = false) @@ -43,7 +43,7 @@ public class CaDoodleFile { .registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) .create(); private ArrayList listeners = new ArrayList(); - + private Thread opperationRunner=null; public CaDoodleFile clearListeners() { listeners.clear(); return this; @@ -63,39 +63,68 @@ private void initialize() { currentIndex=0; for(int i=0;i { + ICaDoodleOpperation op = currentOpperation(); + storeResultInCache(op, op.process(getPreviouState())); + setCurrentState(op); + opperationRunner = null; + }); + opperationRunner.start(); + return opperationRunner; + } private void process(ICaDoodleOpperation op) { storeResultInCache(op, op.process(getCurrentState())); currentIndex++; setCurrentState(op); } - public List addOpperation(ICaDoodleOpperation op) { - if(currentIndex != getOpperations().size()) { - for(int i=currentIndex;i back = cache.remove(getOpperations().get(i)); - back.clear(); - } - List subList = (List) getOpperations().subList(0, currentIndex); - ArrayList newList=new ArrayList(); - newList.addAll(subList); - setOpperations(newList); + public boolean isOperationRunning() { + return opperationRunner!=null; + } + public Thread addOpperation(ICaDoodleOpperation op) throws CadoodleConcurrencyException { + if(isOperationRunning()){ + throw new CadoodleConcurrencyException("Do not add a new opperation while the previous one is processing"); } - try { - getOpperations().add(op); - process(op); - }catch(Exception ex) { - ex.printStackTrace(); + opperationRunner=new Thread(()->{ + if(currentIndex != getOpperations().size()) { + pruneForward(); + } + try { + getOpperations().add(op); + process(op); + }catch(Exception ex) { + ex.printStackTrace(); + } + opperationRunner=null; + }); + opperationRunner.start(); + return opperationRunner; + } + private void pruneForward() { + for(int i=currentIndex;i back = cache.remove(getOpperations().get(i)); + back.clear(); } - return getCurrentState(); + List subList = (List) getOpperations().subList(0, currentIndex); + ArrayList newList=new ArrayList(); + newList.addAll(subList); + setOpperations(newList); } private void storeResultInCache(ICaDoodleOpperation op, List process) { ArrayList cachedCopy = new ArrayList(); @@ -133,10 +162,18 @@ public boolean isForwardAvailible() { return currentIndex getCurrentState() { @@ -171,25 +208,25 @@ public String toJson() { } public File save() throws IOException { - if(self==null){ - self=File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); - } - synchronized(self) { + synchronized(getSelf()) { String contents = toJson(); - FileUtils.write(self, contents,StandardCharsets.UTF_8, false); + FileUtils.write(getSelf(), contents,StandardCharsets.UTF_8, false); } - return self; + return getSelf(); } public static CaDoodleFile fromJsonString(String content ) throws Exception{ - return fromJsonString(content, null); + return fromJsonString(content, null, null); } - public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate listener) throws Exception { + public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate listener, File self) throws Exception { CaDoodleFile file =gson.fromJson(content, TT_CaDoodleFile); if(listener!=null) { file.addListener(listener); } + if(self!=null) { + file.setSelf(self); + } file.initialize(); return file; } @@ -199,8 +236,7 @@ public static CaDoodleFile fromFile(File f ) throws Exception{ public static CaDoodleFile fromFile(File f,ICaDoodleStateUpdate listener ) throws Exception { System.out.println("CaDoodle file loading from "+f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); - CaDoodleFile file =fromJsonString(content,listener); - file.setSelf(f); + CaDoodleFile file =fromJsonString(content,listener,f); return file; } public ArrayList getOpperations() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CadoodleConcurrencyException.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CadoodleConcurrencyException.java new file mode 100644 index 00000000..dcd13289 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CadoodleConcurrencyException.java @@ -0,0 +1,11 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public class CadoodleConcurrencyException extends RuntimeException { + + private static final long serialVersionUID = -1210401639337288969L; + + public CadoodleConcurrencyException(String string) { + super(string); + } + +} diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index cbe8f095..c158825a 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -49,11 +49,13 @@ public void test() throws Exception { AddFromScript cube2 = new AddFromScript() .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", "sphere.groovy"); - Listback= cf.addOpperation(cube1); + cf.addOpperation(cube1).join(); + Listback= cf.getCurrentState(); if(back.size()!=1) fail("Adding a cube should have added one!"); String nameOne = back.get(0).getName(); - back=cf.addOpperation(cube2); + cf.addOpperation(cube2).join();; + back=cf.getCurrentState(); if(back.size()!=2) fail("Adding a cube should have added one more!"); String nameTwo = back.get(1).getName(); @@ -66,7 +68,8 @@ public void test() throws Exception { .setLocation(new TransformNR(distaance,0,0)) .setNames(Arrays.asList(nameTwo)) ; - back= cf.addOpperation(move); + cf.addOpperation(move).join();; + back=cf.getCurrentState(); if(back.size()!=2) fail("Same number of objects after"); if(back.get(1).getCenterX()!=distaance) @@ -95,16 +98,20 @@ public void test() throws Exception { .setLocation(new TransformNR(0,0,0,new RotationNR(0,45,0))) .setNames(Arrays.asList(nameOne)) ; - back=loaded.addOpperation(move3); - back=loaded.addOpperation(move2); + loaded.addOpperation(move3).join();; + back=loaded.getCurrentState(); + loaded.addOpperation(move2).join();; + back=loaded.getCurrentState(); if(back.get(0).getCenterX()!=distaance) fail("Move failed "); if(back.get(0).getCenterY()!=distaance) fail("Move failed "); ToHole hole= new ToHole().setNames(Arrays.asList(nameOne)); - back=loaded.addOpperation(hole); + loaded.addOpperation(hole).join();; + back=loaded.getCurrentState(); Group group = new Group().setNames(Arrays.asList(nameOne,nameTwo)); - back=loaded.addOpperation(group); + loaded.addOpperation(group).join();; + back=loaded.getCurrentState(); if(back.size()!=3) fail("Group Failed "); if(!back.get(0).isInGroup()) { @@ -128,13 +135,16 @@ public void test() throws Exception { .setResize(height, rightFront, leftRear) .setNames(Arrays.asList(groupName)) ; - back = loaded.addOpperation(resize); + loaded.addOpperation(resize).join();; + back=loaded.getCurrentState(); ToSolid solid = new ToSolid() .setNames(Arrays.asList(groupName)) .setColor(Color.BLUE); - back = loaded.addOpperation(solid); + loaded.addOpperation(solid).join();; + back=loaded.getCurrentState(); UnGroup ug = new UnGroup().setNames(Arrays.asList(groupName)); - back = loaded.addOpperation(ug); + loaded.addOpperation(ug).join();; + back=loaded.getCurrentState(); if(back.get(0).isInGroup()) { fail("THis should not be in a group anymore"); } @@ -143,23 +153,26 @@ public void test() throws Exception { } - back = loaded.addOpperation( + loaded.addOpperation( new Group() .setNames(Arrays.asList(nameOne,nameTwo)) - ); + ).join();; + back=loaded.getCurrentState(); List cacheOfGroup = loaded.getCurrentState(); String newGroupName = cacheOfGroup.get(cacheOfGroup.size()-1).getName(); - back = loaded.addOpperation( - new Paste().setNames(Arrays.asList(newGroupName))); + loaded.addOpperation( + new Paste().setNames(Arrays.asList(newGroupName))).join();; + back=loaded.getCurrentState(); ArrayList selectAll = new ArrayList(); for(CSG c:back) { if(c.isGroupResult()) selectAll.add(c.getName()); } - back = loaded.addOpperation( - new UnGroup().setNames(selectAll)); + loaded.addOpperation( + new UnGroup().setNames(selectAll)).join();; + back=loaded.getCurrentState(); if(back.get(0).isInGroup()) { fail("THis should not be in a group anymore"); } @@ -173,7 +186,8 @@ public void test() throws Exception { fail("THis should not be in a group anymore"); } ToHole h= new ToHole().setNames(Arrays.asList(nameTwo)); - back=loaded.addOpperation(h); + loaded.addOpperation(h).join();; + back=loaded.getCurrentState(); loaded.save(); for(int i=0;i<3;i++) { From ecfbea89c73a308547e9358190e298d09855c3d9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 31 Jul 2024 15:39:11 -0400 Subject: [PATCH 058/635] fixing the group color to use the incoming solids --- .../bowlerstudio/scripting/cadoodle/Group.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 4f14caa4..a7dfb954 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose; import eu.mihosoft.vrl.v3d.CSG; +import javafx.scene.paint.Color; public class Group implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) @@ -46,19 +47,26 @@ public List process(List incoming) { CSG result =null; if(holes.size()>0&&solids.size()==0) { result = CSG.unionAll(holes); + if(hull) + result=result.hull(); result.setIsHole(true); }else { CSG holecutter =null; - if(holes.size()>0) + if(holes.size()>0) { holecutter=CSG.unionAll(holes); + if(hull) + holecutter=holecutter.hull(); + } result = CSG.unionAll(solids); + Color c = result.getColor(); if(hull) { result=result.hull(); } if(holecutter!=null) result=result.difference(holecutter); result.setIsHole(false); + result.setColor(c); } result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); From 3509b271958f54ccf330d2733eff5f16284a225f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 31 Jul 2024 15:39:31 -0400 Subject: [PATCH 059/635] get a selected set of CSG's --- .../scripting/cadoodle/CaDoodleFile.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 10550150..6fa3c1ab 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -181,6 +181,18 @@ public List getCurrentState() { return new ArrayList(); return cache.get(currentOpperation()); } + public List getSelect(List selectedSnapshot) { + List cur = getCurrentState(); + ArrayList back =new ArrayList(); + for(CSG c:cur) { + for(String s:selectedSnapshot) { + if(c.getName().contentEquals(s)) { + back.add(c); + } + } + } + return back; + } public List getPreviouState() { if(currentIndex<2) return new ArrayList(); @@ -246,4 +258,5 @@ public void setOpperations(ArrayList opperations) { this.opperations = opperations; } + } From 2609317a65f788cf776c1719843fe480d08bae44 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 31 Jul 2024 15:59:25 -0400 Subject: [PATCH 060/635] adding tessellate methods --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 70c3c23f..208ee064 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 70c3c23f339dd5fd81d3a08fba4252a393862f7d +Subproject commit 208ee0640ec3f1c09125d327463b3c2373d3e139 diff --git a/build.gradle b/build.gradle index 3c51aec2..b202b374 100755 --- a/build.gradle +++ b/build.gradle @@ -148,7 +148,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.5.3' + api 'com.neuronrobotics:JavaCad:1.6.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 97bcc0aa49fd863b344bb5515c79fcf14bb8d400 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 1 Aug 2024 11:56:43 -0400 Subject: [PATCH 061/635] Make sure asset factory and configuration database do not rely on login before loading --- .../bowlerstudio/assets/AssetFactory.java | 4 +++ .../assets/ConfigurationDatabase.java | 35 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 07a16ae8..6c360aad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -33,6 +33,10 @@ public class AssetFactory { private AssetFactory() { } + static { + System.out.println("AssetFactory loaded"); + //new RuntimeException().printStackTrace(); + } public static FXMLLoader loadLayout(String file, boolean refresh) throws Exception { File fxmlFIle = loadFile(file); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 2c22875b..f5793420 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -159,8 +159,7 @@ public static void getDatabase() { database = Collections.synchronizedMap((HashMap>) ScriptingEngine.inlineFileScriptRun(loadFile, null)); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + // databse is empty } if (database == null) { @@ -179,23 +178,25 @@ public static File loadFile() { } catch (IOException e) { throw new RuntimeException(e.getMessage()); } - String username = PasswordManager.getLoginID(); - if(username!=null) - try { - File file =ScriptingEngine.fileFromGit("https://github.com/"+username+"/BowlerStudioConfiguration.git", "database.json"); - if(file.exists()) { - String contents= FileUtils.readFileToString(file, StandardCharsets.UTF_8); - try (PrintWriter out = new PrintWriter(f.getAbsolutePath())) { - out.println(contents); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if(!PasswordManager.isAnonMode()) { + String username = PasswordManager.getLoginID(); + if(username!=null) + try { + File file =ScriptingEngine.fileFromGit("https://github.com/"+username+"/BowlerStudioConfiguration.git", "database.json"); + if(file.exists()) { + String contents= FileUtils.readFileToString(file, StandardCharsets.UTF_8); + try (PrintWriter out = new PrintWriter(f.getAbsolutePath())) { + out.println(contents); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + } } return f; } From 969568fcdc358275bfe22cce0ea0b5d0efd0179d Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 2 Aug 2024 09:45:06 -0400 Subject: [PATCH 062/635] Add the SVG simplification to the Geom simplification --- .../bowlerstudio/scripting/FreecadLoader.java | 28 +---------- .../util/GeometrySimplification.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index 78c52bf2..02ccf8dd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -125,33 +125,7 @@ public static void addCSGToFreeCAD(File freecadModel,CSG toSlice, Listargs = Arrays.asList( - inkscape.getAbsolutePath(), - "--actions", - "\"select-all:all;path-simplify:threshold=" + threshhold+ ";;export-overwrite;export-do;quit-inkscape\"", - incoming.getAbsolutePath() - ); - legacySystemRun(null, inkscape.getAbsoluteFile().getParentFile(), System.out, args); - args = Arrays.asList( - inkscape.getAbsolutePath(), - "--export-plain-svg", - "--export-type=svg", - "--vacuum-defs", - "--export-filename="+svg.getAbsolutePath(), - incoming.getAbsolutePath() - ); - legacySystemRun(null, inkscape.getAbsoluteFile().getParentFile(), System.out, args); - return svg; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return incoming; - } + public static void addSVGToFreeCAD(File freecadModel,File SVG, Transform pose, String name, String bodyName) { TransformNR nr=TransformFactory.csgToNR(pose); RotationNR r=nr.getRotation(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java index 15e4754b..79a97c87 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -1,8 +1,14 @@ package com.neuronrobotics.bowlerstudio.util; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.legacySystemRun; + import java.io.File; +import java.util.Arrays; +import java.util.List; import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; + import eu.mihosoft.vrl.v3d.CSG; public class GeometrySimplification { @@ -26,4 +32,46 @@ public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { BlenderLoader.remeshSTLFile(stlout, MMVoxel); } + /** + * Simplify an SVG file + * @param incoming the incoming SVG file + * @param threshhold the threshhold value (default is 0.002 + * @return A new SVG file that is changed + */ + public static File simplifySVG(File incoming) { + return simplifySVG(incoming,0.002); + } + /** + * Simplify an SVG file + * @param incoming the incoming SVG file + * @param threshhold the threshhold value (default is 0.002 + * @return A new SVG file that is changed + */ + public static File simplifySVG(File incoming, double threshhold) { + try { + File inkscape = DownloadManager.getConfigExecutable("inkscape", null); + File svg = File.createTempFile(incoming.getName(), ".svg"); + List args = Arrays.asList( + inkscape.getAbsolutePath(), + "--actions", + "\"select-all:all;path-simplify:threshold=" + threshhold+ ";;export-overwrite;export-do;quit-inkscape\"", + incoming.getAbsolutePath() + ); + legacySystemRun(null, inkscape.getAbsoluteFile().getParentFile(), System.out, args); + args = Arrays.asList( + inkscape.getAbsolutePath(), + "--export-plain-svg", + "--export-type=svg", + "--vacuum-defs", + "--export-filename="+svg.getAbsolutePath(), + incoming.getAbsolutePath() + ); + legacySystemRun(null, inkscape.getAbsoluteFile().getParentFile(), System.out, args); + return svg; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return incoming; + } } From abf251f1fd45dbc089afb2c11d9f3b2a116ae558 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 10 Aug 2024 09:59:53 -0400 Subject: [PATCH 063/635] Move the random scrings to a seperaate class --- .../cadoodle/RandomStringFactory.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java new file mode 100644 index 00000000..fd2135a5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java @@ -0,0 +1,86 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.Random; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; + +public class RandomStringFactory { + @Expose (serialize = false, deserialize = false) + private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + @Expose (serialize = false, deserialize = false) + private static final int STRING_LENGTH = 40; + + public static String[] adjectives = { + "Effervescent", "Zestful", "Vivacious", "Ebullient", "Sprightly", + "Exuberant", "Jocund", "Mirthful", "Zippy", "Gleeful", + "Buoyant", "Chipper", "Peppy", "Perky", "Jaunty", + "Blithe", "Joyous", "Spirited", "Vibrant", "Lively", + "Zealous", "Jubilant", "Merry", "Elated", "Euphoric", + "Bubbly", "Chirpy", "Animated", "Bouncy", "Energetic", + "Frisky", "Sparkling", "Vivid", "Zappy", "Zippy", + "Snappy", "Peppy", "Effulgent", "Radiant", "Luminous", + "Beaming", "Glowing", "Incandescent", "Resplendent", "Lustrous", + "Glistening", "Scintillating", "Efflorescent", "Blooming", "Flourishing", + "Thriving", "Burgeoning", "Prolific", "Fecund", "Teeming", + "Abundant", "Plentiful", "Bountiful", "Copious", "Profuse", + "Exuberant", "Luxuriant", "Lush", "Verdant", "Fertile", + "Productive", "Fruitful", "Generative", "Creative", "Imaginative", + "Inventive", "Ingenious", "Clever", "Brilliant", "Dazzling", + "Bright", "Luminous", "Radiant", "Gleaming", "Glittering", + "Sparkling", "Twinkling", "Shimmering", "Glowing", "Beaming", + "Effulgent", "Refulgent", "Resplendent", "Splendid", "Magnificent", + "Majestic", "Grand", "Glorious", "Superb", "Marvelous", + "Wonderful", "Fantastic", "Fabulous", "Astounding", "Amazing" + }; + + public static String[] creaturesMachines = { + "Dragon", "Robot", "Unicorn", "Cyborg", "Griffin", + "Automaton", "Phoenix", "Mech", "Kraken", "Droid", + "Chimera", "Golem", "Pegasus", "Android", "Hydra", + "Centaur", "Drone", "Sphinx", "Exosuit", "Minotaur", + "Cyclops", "Hologram", "Werewolf", "Nanobot", "Gorgon", + "Replicant", "Banshee", "Hovercraft", "Basilisk", "Jetpack", + "Gargoyle", "Teleporter", "Manticore", "Forcefield", + "Submarine", "Cerberus", "Hoverboard", "Siren", "Skycycle", + "Yeti", "Hoverbike", "Sasquatch", "Hyperloop", "Thunderbird", + "Gyrocopter", "Leviathan", "Airship", "Behemoth", "Starship", + "Colossus", "Monowheel", "Titan", "Rocketship", "Gremlin", + "Hovercar", "Imp", "Zeppelin", "Ogre", "Monorail", + "Troll", "Bathyscaphe", "Gnome", "Segway", "Leprechaun", + "Hyperpod", "Fairy", "Gyrocar", "Elf", "Ornithopter", + "Wraith", "Hoversuit", "Specter", "Levitator", "Phantom", + "Telekinetic", "Goblin", "Gravicycle", "Dwarf", + "Jetbike", "Hobgoblin", "Ekranoplan", + "Aerotrain", "Sprite", "Maglev", "Aerosled", + "Cybertooth", "Ifrit", "Warpod", "Elemental", + "Hoversled", "Goliath", "Warpcraft", "Juggernaut", "Vortexer" + }; + + private static int index = ((Double) ConfigurationDatabase.get( + "CaDoodle", + "projectNameIndex", + (Math.random()*creaturesMachines.length))).intValue(); + + + public static String getNextRandomName() { + index++; + if(index>=creaturesMachines.length) + index=0; + ConfigurationDatabase.put("CaDoodle", "projectNameIndex", index); + return adjectives[(int) (Math.random()*adjectives.length)]+"_"+creaturesMachines[index]; + } + + public static String generateRandomString() { + Random random = new Random(); + StringBuilder stringBuilder = new StringBuilder(STRING_LENGTH); + + for (int i = 0; i < STRING_LENGTH; i++) { + int randomIndex = random.nextInt(CHAR_POOL.length()); + stringBuilder.append(CHAR_POOL.charAt(randomIndex)); + } + + return getNextRandomName()+"_"+stringBuilder.toString(); + } + +} From b82ca660468d5de6d3d4a0a2dcb0c110c7322d10 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 10 Aug 2024 10:01:13 -0400 Subject: [PATCH 064/635] Use recoursive resize and move for complex data structures --- .../scripting/cadoodle/MoveCenter.java | 39 +++++--- .../scripting/cadoodle/Resize.java | 88 +++++++++++++++++-- 2 files changed, 108 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 53876a3b..5656994b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -24,22 +25,36 @@ public String getType() { @Override public List process(List incoming) { ArrayList back = new ArrayList(); - for (CSG csg : incoming) { - CSG tmpToAdd = csg; - for (String name : names) { - if ( csg.getName().contentEquals(name) || - (csg.isInGroup() && csg.checkGroupMembership(name))) { - tmpToAdd=csg - .transformed(TransformFactory.nrToCSG(location)) - .syncProperties(csg) - .setName(csg.getName()); - } - } - back.add(tmpToAdd); + HashSet groupsProcessed = new HashSet(); + back.addAll(incoming); + for (String name : names) { + moveByName(name,back,groupsProcessed); } return back; } + private void moveByName(String name, ArrayList back, HashSet groupsProcessed) { + + for (int i = 0; i < back.size(); i++) { + CSG csg = back.get(i); + if ( csg.getName().contentEquals(name) || + (csg.isInGroup() && csg.checkGroupMembership(name))){ + groupsProcessed.add(name); + if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { + // composite group + moveByName(csg.getName(), back,groupsProcessed); + + } + // move it + CSG tmpToAdd = csg + .transformed(TransformFactory.nrToCSG(location)) + .syncProperties(csg) + .setName(csg.getName()); + back.set(i, tmpToAdd); + } + } + } + public TransformNR getLocation() { return location; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 665d0cc5..9110d64e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -1,6 +1,8 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -27,20 +29,90 @@ public class Resize implements ICaDoodleOpperation { public String getType() { return "Resize"; } + private class ResizeEvent{ + Transform scaleZ; + Transform scale; + double movez; + double movey; + double movex; + } @Override public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - for(CSG c:incoming) { - for(String name:names) { - if(c.getName().contentEquals(name)) { - performResize(c, name,back); + HashMap groupsProcessed = new HashMap<>(); + + for (String name : names) { + resizeByName(name,back,groupsProcessed); + } + return back; + } + + private void resizeByName(String name, ArrayList back, HashMap groupsProcessed) { + for (int i = 0; i < back.size(); i++) { + CSG starting = back.get(i); + if ( starting.getName().contentEquals(name) ){ + double zScale = Math.abs(height.getZ()); + double scalez = zScale/ starting.getTotalZ(); + + Transform scaleZ =new Transform().scaleZ(scalez); + CSG resizeUp = starting.transformed(scaleZ); + double zMove = -resizeUp.getMinZ()+starting.getMinZ(); + resizeUp=resizeUp + .movez(zMove); + double xdimen = Math.abs(rightFront.getX()-leftRear.getX()); + double ydimen = Math.abs(rightFront.getY()-leftRear.getY()); + double scalex = xdimen/ resizeUp.getTotalX(); + double scaley = ydimen/ resizeUp.getTotalY(); + + Transform scale = new Transform().scale(scalex,scaley,1); + resizeUp=resizeUp.transformed(scale); + double xMove=-resizeUp.getMinX()+leftRear.getX(); + double yMove = -resizeUp.getMinY()+rightFront.getY(); + resizeUp=resizeUp + .movex(xMove) + .movey(yMove); + resizeUp.syncProperties(starting).setName(name); + ResizeEvent ev = new ResizeEvent(); + ev.movex=xMove; + ev.movey=yMove; + ev.movez=zMove; + ev.scale=scale; + ev.scaleZ=scaleZ; + back.set(i, resizeUp); + groupsProcessed.put(name, ev); + + if(starting.isGroupResult()) { + processCompositMembers(name,back,groupsProcessed); + } + } + } + } + + + private void processCompositMembers(String name, ArrayList back, + HashMap groupsProcessed) { + for (int i = 0; i < back.size(); i++) { + CSG c = back.get(i); + if(c.isInGroup() && c.checkGroupMembership(name) ) { + + ResizeEvent ev =groupsProcessed.get(name); + CSG gc = c.transformed(ev.scaleZ); + gc=gc + .movez(ev.movez); + gc=gc.transformed(ev.scale); + gc=gc + .movex(ev.movex) + .movey(ev.movey); + gc.syncProperties(c).setName(c.getName()); + back.set(i, gc); + if(c.isInGroup() && c.isGroupResult()) { + groupsProcessed.put(c.getName(), ev); + processCompositMembers(c.getName(),back,groupsProcessed); } } } - - return back; } private void performResize(CSG starting, String name,ArrayList back) { @@ -75,6 +147,8 @@ private void performResize(CSG starting, String name,ArrayList back) { resizeUp=resizeUp .movex(xMove) .movey(yMove); + resizeUp.syncProperties(starting).setName(name); + back.removeAll(groupConstituants); for(CSG c:groupConstituants) { CSG gc = c.transformed(scaleZ); @@ -88,7 +162,7 @@ private void performResize(CSG starting, String name,ArrayList back) { back.add(gc); } - back.add( resizeUp.syncProperties(starting).setName(name)); + back.add( resizeUp); } // // private CSG scaleToMeasurmentXY(CSG inc,double x, double y) { From ef22b7dbbb7c085a0fe795b4dff58ffdfd95774d Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 10 Aug 2024 10:01:41 -0400 Subject: [PATCH 065/635] Use the new static class --- .../assets/ConfigurationDatabase.java | 1 + .../scripting/cadoodle/AddFromFile.java | 2 +- .../scripting/cadoodle/AddFromScript.java | 21 ++++--------------- .../scripting/cadoodle/Group.java | 2 +- .../ICaDoodleOperationAdapterFactory.java | 1 + .../scripting/cadoodle/Paste.java | 2 +- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index f5793420..a61eace2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -57,6 +57,7 @@ public static Set keySet(String name) { } public static boolean containsKey(String paramsKey, String string) { boolean containsKey = false; + getDatabase(); synchronized(database){ containsKey = ConfigurationDatabase.getParamMap(paramsKey).containsKey(string); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 68e641ca..e38a52d2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -29,7 +29,7 @@ public String getType() { private String getOrderedName() { if(name==null) { - name=AddFromScript.generateRandomString(); + name=RandomStringFactory.generateRandomString(); } if(nameIndex==0) return name; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 645de19a..4ce6a498 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -6,6 +6,7 @@ import java.util.stream.Collectors; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import eu.mihosoft.vrl.v3d.CSG; @@ -17,23 +18,9 @@ public class AddFromScript implements ICaDoodleOpperation { private String fileRel = ""; @Expose (serialize = true, deserialize = true) private String name=null; - @Expose (serialize = false, deserialize = false) - private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - @Expose (serialize = false, deserialize = false) - private static final int STRING_LENGTH = 40; + @Expose (serialize = true, deserialize = true) private int nameIndex = 0; - - public static String generateRandomString() { - Random random = new Random(); - StringBuilder stringBuilder = new StringBuilder(STRING_LENGTH); - - for (int i = 0; i < STRING_LENGTH; i++) { - int randomIndex = random.nextInt(CHAR_POOL.length()); - stringBuilder.append(CHAR_POOL.charAt(randomIndex)); - } - - return stringBuilder.toString(); - } + public AddFromScript set(String git, String f) { gitULR = git; fileRel = f; @@ -47,7 +34,7 @@ public String getType() { private String getOrderedName() { if(name==null) { - name=generateRandomString(); + name=RandomStringFactory.generateRandomString(); } if(nameIndex==0) return name; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index a7dfb954..f3582cff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -85,7 +85,7 @@ public Group setNames(List names) { public String getGroupID() { if(groupID==null) - groupID=AddFromScript.generateRandomString(); + groupID=RandomStringFactory.generateRandomString(); return groupID; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 426e982a..8ddcad04 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -73,6 +73,7 @@ public T read(JsonReader in) throws IOException { throw new JsonParseException("Unknown type: " + typeName); } TypeAdapter delegateAdapter = gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get(clazz)); + System.out.println("JSON Parsing "+typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } }.nullSafe(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 85762452..73340460 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -86,7 +86,7 @@ public Paste setNames(List names) { } public String getPaserID() { if(paste==null) - paste=AddFromScript.generateRandomString(); + paste=RandomStringFactory.generateRandomString(); return paste; } From 703869c407a2321dffda6551152cbe7fa419e49d Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 10 Aug 2024 13:17:24 -0400 Subject: [PATCH 066/635] Resize should just check the membership, alredy in a group from if above --- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 2 +- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 5656994b..2ad259a4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -51,7 +51,7 @@ private void moveByName(String name, ArrayList back, HashSet groups .syncProperties(csg) .setName(csg.getName()); back.set(i, tmpToAdd); - } + } } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 9110d64e..b3d9eacc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -107,7 +107,7 @@ private void processCompositMembers(String name, ArrayList back, .movey(ev.movey); gc.syncProperties(c).setName(c.getName()); back.set(i, gc); - if(c.isInGroup() && c.isGroupResult()) { + if( c.isGroupResult()) { groupsProcessed.put(c.getName(), ev); processCompositMembers(c.getName(),back,groupsProcessed); } From bb3f633ab90f21b6dc875ceea22c4d47f1fb3b2b Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 08:51:02 -0400 Subject: [PATCH 067/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 208ee064..e35c8c64 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 208ee0640ec3f1c09125d327463b3c2373d3e139 +Subproject commit e35c8c6470ae951d8811fcb8c64b45dae6ae9054 From 1b096e90135d1dfa5bcdca92dfc29d2398e4ea60 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 08:54:09 -0400 Subject: [PATCH 068/635] remove dead code --- .../scripting/cadoodle/Resize.java | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index b3d9eacc..e9ece5a7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -115,61 +115,6 @@ private void processCompositMembers(String name, ArrayList back, } } - private void performResize(CSG starting, String name,ArrayList back) { - back.remove(starting); - ArrayList groupConstituants = new ArrayList(); - if(starting.isGroupResult()) { - for(CSG c:back) { - if(c.isInGroup()) { - if(c.checkGroupMembership(name)) { - groupConstituants.add(c); - } - } - } - } - double zScale = Math.abs(height.getZ()); - Number scaleValue = zScale/ starting.getTotalZ(); - - Transform scaleZ =new Transform().scaleZ(scaleValue.doubleValue()); - CSG resizeUp = starting.transformed(scaleZ); - double zMove = -resizeUp.getMinZ()+starting.getMinZ(); - resizeUp=resizeUp - .movez(zMove); - double xdimen = Math.abs(rightFront.getX()-leftRear.getX()); - double ydimen = Math.abs(rightFront.getY()-leftRear.getY()); - double scalex = xdimen/ resizeUp.getTotalX(); - double scaley = ydimen/ resizeUp.getTotalY(); - - Transform scale = new Transform().scale(scalex,scaley,1); - resizeUp=resizeUp.transformed(scale); - double xMove=-resizeUp.getMinX()+leftRear.getX(); - double yMove = -resizeUp.getMinY()+rightFront.getY(); - resizeUp=resizeUp - .movex(xMove) - .movey(yMove); - resizeUp.syncProperties(starting).setName(name); - - back.removeAll(groupConstituants); - for(CSG c:groupConstituants) { - CSG gc = c.transformed(scaleZ); - gc=gc - .movez(-gc.getMinZ()+c.getMinZ()); - gc=gc.transformed(scale); - gc=gc - .movex(xMove) - .movey(yMove); - gc.syncProperties(c).setName(c.getName()); - back.add(gc); - } - - back.add( resizeUp); - } -// -// private CSG scaleToMeasurmentXY(CSG inc,double x, double y) { -// -// return inc.moveToCenter().transformed(scale).move(inc.getCenter().transformed(scale)); -// } - public Resize setResize(TransformNR h, TransformNR rf, TransformNR lr) { height = h; rightFront = rf; From 2ba7e9d3ec91e6f14fe4184a27bee32de59cedbd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 12:34:13 -0400 Subject: [PATCH 069/635] Refactor Manipulator to be just the manipulations not the managment of the geoms --- .../Bezier3d/CartesianManipulator.java | 13 ++-- .../{manipulation.java => Manipulation.java} | 62 ++++++++++--------- .../bowlerstudio/printbed/PrintBedObject.java | 8 ++- 3 files changed, 48 insertions(+), 35 deletions(-) rename src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/{manipulation.java => Manipulation.java} (81%) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java index 037d0372..ed328667 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java @@ -17,7 +17,7 @@ public class CartesianManipulator { CSG manip1 = new Cylinder(0, 5, 40, 10).toCSG().setColor(Color.BLUE); CSG manip2 = new Cylinder(0, 5, 40, 10).toCSG().roty(-90).setColor(Color.RED); CSG manip3 = new Cylinder(0, 5, 40, 10).toCSG().rotx(90).setColor(Color.GREEN); - private manipulation[] manipulationList = new manipulation[3]; + private Manipulation[] manipulationList = new Manipulation[3]; TransformNR globalPose; public CartesianManipulator(TransformNR globalPose) { @@ -25,9 +25,14 @@ public CartesianManipulator(TransformNR globalPose) { manip1.setMfg(incoming -> null); manip2.setMfg(incoming -> null); manip3.setMfg(incoming -> null); - manipulationList[0] = new manipulation(manipulationMatrix, new Vector3d(0, 0, 1), manip1, globalPose); - manipulationList[1] = new manipulation(manipulationMatrix, new Vector3d(0, 1, 0), manip3, globalPose); - manipulationList[2] = new manipulation(manipulationMatrix, new Vector3d(1, 0, 0), manip2, globalPose); + manipulationList[0] = new Manipulation(manipulationMatrix, new Vector3d(0, 0, 1), globalPose); + manipulationList[1] = new Manipulation(manipulationMatrix, new Vector3d(0, 1, 0), globalPose); + manipulationList[2] = new Manipulation(manipulationMatrix, new Vector3d(1, 0, 0), globalPose); + int i=0; + for(CSG manip:Arrays.asList(manip1,manip3,manip2)) { + manip.getStorage().set("manipulator", manipulationList[i++].map); + manip.setManipulator(manipulationMatrix); + } } public void addEventListener(Runnable r) { diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java similarity index 81% rename from src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/manipulation.java rename to src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 1f108085..c506e73c 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import javafx.scene.paint.Color; import java.util.HashMap; +import java.util.List; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.sdk.addons.kinematics.math.*; @@ -16,8 +17,8 @@ import javafx.scene.transform.Affine; import javafx.scene.paint.PhongMaterial; -public class manipulation { - HashMap, EventHandler> map = new HashMap<>(); +public class Manipulation { + public HashMap, EventHandler> map = new HashMap<>(); double startx = 0; double starty = 0; double newx = 0; @@ -31,14 +32,14 @@ public class manipulation { private ArrayList eventListeners = new ArrayList<>(); private ArrayList saveListeners = new ArrayList<>(); - private ArrayList dependants = new ArrayList<>(); + private ArrayList dependants = new ArrayList<>(); private Affine manipulationMatrix; private Vector3d orintation; - private CSG manip; + private List manip; private TransformNR globalPose; public TransformNR currentPose; - private PhongMaterial color;// = new PhongMaterial(getColor()); - private PhongMaterial highlight = new PhongMaterial(Color.GOLD); + //private PhongMaterial color;// = new PhongMaterial(getColor()); + //private PhongMaterial highlight = new PhongMaterial(Color.GOLD); private enum DragState { IDLE, Dragging @@ -52,7 +53,7 @@ public void addEventListener(Runnable r) { eventListeners.add(r); } - public void addDependant(manipulation r) { + public void addDependant(Manipulation r) { if (dependants.contains(r)) return; dependants.add(r); @@ -71,7 +72,7 @@ public void clearListeners() { } private void fireMove(TransformNR trans, TransformNR camFrame2) { - for (manipulation R : dependants) { + for (Manipulation R : dependants) { R.performMove(trans, camFrame2); } for (Runnable R : eventListeners) { @@ -86,12 +87,14 @@ private void fireSave() { } }).start(); } - - public manipulation(Affine mm, Vector3d o, CSG m, TransformNR p) { +// public manipulation(Affine mm, Vector3d o, CSG m, TransformNR p) { +// +// } + public Manipulation(Affine mm, Vector3d o, TransformNR p) { this.manipulationMatrix = mm; this.orintation = o; - this.manip = m; - color = new PhongMaterial(m.getColor()); + //this.manip = m; + //color = new PhongMaterial(m.getColor()); this.globalPose = p; currentPose = p.copy(); getUi().runLater(() -> { @@ -102,7 +105,12 @@ public manipulation(Affine mm, Vector3d o, CSG m, TransformNR p) { } }); - map.put(MouseEvent.ANY, new EventHandler() { + map.put(MouseEvent.ANY, getMouseEvents()); + + } + + private EventHandler getMouseEvents() { + return new EventHandler() { @Override public void handle(MouseEvent event) { String name = event.getEventType().getName(); @@ -119,22 +127,20 @@ public void handle(MouseEvent event) { case "MOUSE_MOVED": // ignore break; - case "MOUSE_ENTERED": - m.getMesh().setMaterial(highlight); - break; - case "MOUSE_EXITED": - if (state == DragState.IDLE) - m.getMesh().setMaterial(color); - break; +// case "MOUSE_ENTERED": +// m.getMesh().setMaterial(highlight); +// break; +// case "MOUSE_EXITED": +// if (state == DragState.IDLE) +// m.getMesh().setMaterial(color); +// break; default: // System.out.println("UNKNOWN! Mouse event "+name); break; } } - }); - manip.getStorage().set("manipulator", map); - manip.setManipulator(manipulationMatrix); + }; } private void pressed(MouseEvent event) { @@ -144,7 +150,7 @@ private void pressed(MouseEvent event) { depth = -1600 / getUi().getCamerDepth(); event.consume(); dragging = false; - for (manipulation R : dependants) { + for (Manipulation R : dependants) { R.camFrame = getUi().getCamerFrame(); R.depth = -1600 / getUi().getCamerDepth(); R.dragging = false; @@ -154,10 +160,10 @@ private void pressed(MouseEvent event) { private void release(MouseEvent event) { mouseRelease(event); - for (manipulation R : dependants) + for (Manipulation R : dependants) R.mouseRelease(event); state = DragState.IDLE; - manip.getMesh().setMaterial(color); + //manip.getMesh().setMaterial(color); } private void dragged(MouseEvent event) { @@ -193,7 +199,7 @@ private void setDragging(MouseEvent event) { starty = event.getScreenY(); } dragging = true; - for (manipulation R : dependants) { + for (Manipulation R : dependants) { R.setDragging(event); } } @@ -232,7 +238,7 @@ public static IInteractiveUIElementProvider getUi() { } public static void setUi(IInteractiveUIElementProvider ui) { - manipulation.ui = ui; + Manipulation.ui = ui; } public void set(double newX, double newY, double newZ) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java index 7cb0f5ab..ed23c441 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java @@ -3,7 +3,7 @@ import java.util.Arrays; import java.util.List; -import com.neuronrobotics.bowlerkernel.Bezier3d.manipulation; +import com.neuronrobotics.bowlerkernel.Bezier3d.Manipulation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -17,7 +17,7 @@ public class PrintBedObject { private double yMin; private CSG part; private String name; - private manipulation manip; + private Manipulation manip; private Affine affine = new Affine(); private TransformNR globalPose; public PrintBedObject(String name, CSG part, double xMax, double xMin, double yMax, double yMin, TransformNR startPose){ @@ -29,7 +29,9 @@ public PrintBedObject(String name, CSG part, double xMax, double xMin, double yM this.yMin = yMin; this.globalPose = startPose; - manip = new manipulation(affine, new Vector3d(1, 1, 0), part, startPose); + manip = new Manipulation(affine, new Vector3d(1, 1, 0), startPose); + part.getStorage().set("manipulator",manip.map); + part.setManipulator(affine); manip.addSaveListener(() -> System.out.println("Saving PrintBedObject "+name)); checkBounds(); } From 69c6890a9bac1a9c133eb04f387fcf733b1a1bbd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 13:54:17 -0400 Subject: [PATCH 070/635] Eliminate cached variables and replace them with direct getters from the source of truth --- .../bowlerkernel/Bezier3d/Manipulation.java | 99 +++++++++++-------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index c506e73c..7c61148f 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -24,9 +24,7 @@ public class Manipulation { double newx = 0; double newy = 0; double newz = 0; - TransformNR camFrame = null; boolean dragging = false; - double depth = 0; private static IInteractiveUIElementProvider ui = new IInteractiveUIElementProvider() { }; @@ -35,9 +33,8 @@ public class Manipulation { private ArrayList dependants = new ArrayList<>(); private Affine manipulationMatrix; private Vector3d orintation; - private List manip; - private TransformNR globalPose; - public TransformNR currentPose; + private TransformNR globalPose= new TransformNR(); + public TransformNR currentPose=new TransformNR(); //private PhongMaterial color;// = new PhongMaterial(getColor()); //private PhongMaterial highlight = new PhongMaterial(Color.GOLD); @@ -71,9 +68,9 @@ public void clearListeners() { eventListeners.clear(); } - private void fireMove(TransformNR trans, TransformNR camFrame2) { + private void fireMove(TransformNR trans) { for (Manipulation R : dependants) { - R.performMove(trans, camFrame2); + R.performMove(trans); } for (Runnable R : eventListeners) { R.run(); @@ -95,11 +92,11 @@ public Manipulation(Affine mm, Vector3d o, TransformNR p) { this.orintation = o; //this.manip = m; //color = new PhongMaterial(m.getColor()); - this.globalPose = p; + this.setGlobalPose(p); currentPose = p.copy(); getUi().runLater(() -> { try { - TransformFactory.nrToAffine(globalPose, manipulationMatrix); + TransformFactory.nrToAffine(getGlobalPose(), manipulationMatrix); } catch (Throwable t) { t.printStackTrace(); } @@ -109,7 +106,7 @@ public Manipulation(Affine mm, Vector3d o, TransformNR p) { } - private EventHandler getMouseEvents() { + public EventHandler getMouseEvents() { return new EventHandler() { @Override public void handle(MouseEvent event) { @@ -146,18 +143,19 @@ public void handle(MouseEvent event) { private void pressed(MouseEvent event) { state = DragState.Dragging; new Thread(() -> { - camFrame = getUi().getCamerFrame(); - depth = -1600 / getUi().getCamerDepth(); event.consume(); dragging = false; for (Manipulation R : dependants) { - R.camFrame = getUi().getCamerFrame(); - R.depth = -1600 / getUi().getCamerDepth(); + R.dragging = false; } }).start(); } + private double getDepthNow() { + return -1600 / getUi().getCamerDepth(); + } + private void release(MouseEvent event) { mouseRelease(event); for (Manipulation R : dependants) @@ -171,9 +169,14 @@ private void dragged(MouseEvent event) { setDragging(event); double deltx = (startx - event.getScreenX()); double delty = (starty - event.getScreenY()); - TransformNR trans = new TransformNR(deltx / depth, delty / depth, 0, new RotationNR()); - - performMove(trans, camFrame); + double d = deltx/ getDepthNow() ; + double y = delty/ getDepthNow() ; + if(Double.isFinite(y) && Double.isFinite(d)) { + TransformNR trans = new TransformNR(d, y, 0, new RotationNR()); + performMove(trans); + }else { + System.out.println("ERROR?"); + } }); event.consume(); } @@ -185,9 +188,9 @@ public boolean isMoving() { private void mouseRelease(MouseEvent event) { if (dragging) { dragging = false; - globalPose.setX(newx); - globalPose.setY(newy); - globalPose.setZ(newz); + getGlobalPose().setX(newx); + getGlobalPose().setY(newy); + getGlobalPose().setZ(newz); event.consume(); fireSave(); } @@ -204,24 +207,29 @@ private void setDragging(MouseEvent event) { } } - private void performMove(TransformNR trans, TransformNR camFrame2) { - TransformNR globalTMP = camFrame2.copy(); - globalTMP.setX(0); - globalTMP.setY(0); - globalTMP.setZ(0); - TransformNR global = globalTMP.times(trans); - newx = (global.getX() * orintation.x + globalPose.getX()); - newy = (global.getY() * orintation.y + globalPose.getY()); - newz = (global.getZ() * orintation.z + globalPose.getZ()); - global.setX(newx); - global.setY(newy); - global.setZ(newz); - - global.setRotation(new RotationNR()); - setGlobal(global); + private void performMove(TransformNR trans) { + TransformNR camerFrame = getUi().getCamerFrame(); + TransformNR globalTMP = camerFrame.copy(); + try { + globalTMP.setX(0); + globalTMP.setY(0); + globalTMP.setZ(0); + TransformNR global = globalTMP.times(trans); + newx = (global.getX() * orintation.x + getGlobalPose().getX()); + newy = (global.getY() * orintation.y + getGlobalPose().getY()); + newz = (global.getZ() * orintation.z + getGlobalPose().getZ()); + global.setX(newx); + global.setY(newy); + global.setZ(newz); + + global.setRotation(new RotationNR()); + setGlobal(global); + }catch(Throwable t) { + t.printStackTrace(); + } // System.out.println(" drag "+global.getX()+" , "+global.getY()+" , // "+global.getZ()+" "+deltx+" "+delty); - fireMove(trans, camFrame2); + fireMove(trans); } private void setGlobal(TransformNR global) { @@ -245,9 +253,9 @@ public void set(double newX, double newY, double newZ) { newx = newX; newy = newY; newz = newZ; - globalPose.setX(newX); - globalPose.setY(newY); - globalPose.setZ(newZ); + getGlobalPose().setX(newX); + getGlobalPose().setY(newY); + getGlobalPose().setZ(newZ); setGlobal(new TransformNR(newX, newY, newZ, new RotationNR())); for (Runnable R : eventListeners) { R.run(); @@ -255,4 +263,17 @@ public void set(double newX, double newY, double newZ) { } + public void reset() { + // TODO Auto-generated method stub + + } + + public TransformNR getGlobalPose() { + return globalPose; + } + + public void setGlobalPose(TransformNR globalPose) { + this.globalPose = globalPose; + } + } From 03be27b38fd4e56ad7155f2eb23ed7700f6b0df0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 14:39:14 -0400 Subject: [PATCH 071/635] Adding rounding to increments --- .../bowlerkernel/Bezier3d/Manipulation.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 7c61148f..e4b745ce 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -25,6 +25,7 @@ public class Manipulation { double newy = 0; double newz = 0; boolean dragging = false; + private double increment = 0.000001; private static IInteractiveUIElementProvider ui = new IInteractiveUIElementProvider() { }; @@ -54,6 +55,7 @@ public void addDependant(Manipulation r) { if (dependants.contains(r)) return; dependants.add(r); + } public void addSaveListener(Runnable r) { @@ -215,9 +217,9 @@ private void performMove(TransformNR trans) { globalTMP.setY(0); globalTMP.setZ(0); TransformNR global = globalTMP.times(trans); - newx = (global.getX() * orintation.x + getGlobalPose().getX()); - newy = (global.getY() * orintation.y + getGlobalPose().getY()); - newz = (global.getZ() * orintation.z + getGlobalPose().getZ()); + newx = round((global.getX() * orintation.x + getGlobalPose().getX())); + newy = round((global.getY() * orintation.y + getGlobalPose().getY())); + newz = round((global.getZ() * orintation.z + getGlobalPose().getZ())); global.setX(newx); global.setY(newy); global.setZ(newz); @@ -231,7 +233,10 @@ private void performMove(TransformNR trans) { // "+global.getZ()+" "+deltx+" "+delty); fireMove(trans); } - + private double round(double in) { + return Math.round(in / increment) * increment; + } + private void setGlobal(TransformNR global) { currentPose.setX(newx); currentPose.setY(newy); @@ -276,4 +281,12 @@ public void setGlobalPose(TransformNR globalPose) { this.globalPose = globalPose; } + public double getIncrement() { + return increment; + } + + public void setIncrement(double increment) { + this.increment = increment; + } + } From f73544104d374a6e07d4df85ec7ee70bfc2f8abb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 14:53:48 -0400 Subject: [PATCH 072/635] Add getter for current pose --- .../bowlerkernel/Bezier3d/CartesianManipulator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java index ed328667..42786f6d 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java @@ -50,15 +50,15 @@ public List get() { } public double getX() { - return manipulationList[2].currentPose.getX(); + return manipulationList[2].getCurrentPose().getX(); } public double getY() { - return manipulationList[1].currentPose.getY(); + return manipulationList[1].getCurrentPose().getY(); } public double getZ() { - return manipulationList[0].currentPose.getZ(); + return manipulationList[0].getCurrentPose().getZ(); } public void addDependant(CartesianManipulator r) { From 73bea6bbf3d84eadb0030fdda2c4c40f31d5e5bb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 14:54:02 -0400 Subject: [PATCH 073/635] getter for current pose --- .../bowlerkernel/Bezier3d/Manipulation.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index e4b745ce..454253e6 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -35,7 +35,7 @@ public class Manipulation { private Affine manipulationMatrix; private Vector3d orintation; private TransformNR globalPose= new TransformNR(); - public TransformNR currentPose=new TransformNR(); + private TransformNR currentPose=new TransformNR(); //private PhongMaterial color;// = new PhongMaterial(getColor()); //private PhongMaterial highlight = new PhongMaterial(Color.GOLD); @@ -95,7 +95,7 @@ public Manipulation(Affine mm, Vector3d o, TransformNR p) { //this.manip = m; //color = new PhongMaterial(m.getColor()); this.setGlobalPose(p); - currentPose = p.copy(); + setCurrentPose(p.copy()); getUi().runLater(() -> { try { TransformFactory.nrToAffine(getGlobalPose(), manipulationMatrix); @@ -226,11 +226,11 @@ private void performMove(TransformNR trans) { global.setRotation(new RotationNR()); setGlobal(global); + System.out.println(" drag "+global.getX()+" , "+global.getY()+" ,"+global.getZ()); + }catch(Throwable t) { t.printStackTrace(); } - // System.out.println(" drag "+global.getX()+" , "+global.getY()+" , - // "+global.getZ()+" "+deltx+" "+delty); fireMove(trans); } private double round(double in) { @@ -238,9 +238,9 @@ private double round(double in) { } private void setGlobal(TransformNR global) { - currentPose.setX(newx); - currentPose.setY(newy); - currentPose.setZ(newz); + getCurrentPose().setX(newx); + getCurrentPose().setY(newy); + getCurrentPose().setZ(newz); getUi().runLater(() -> { TransformFactory.nrToAffine(global, manipulationMatrix); }); @@ -289,4 +289,12 @@ public void setIncrement(double increment) { this.increment = increment; } + public TransformNR getCurrentPose() { + return currentPose; + } + + public void setCurrentPose(TransformNR currentPose) { + this.currentPose = currentPose; + } + } From 075cd2e480ef98123b107b836edd14057ec817ad Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 14:54:15 -0400 Subject: [PATCH 074/635] current pose geter --- .../bowlerstudio/printbed/PrintBedObject.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java index ed23c441..83cd2f47 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java @@ -47,15 +47,15 @@ public List get() { } public double getX() { - return manip.currentPose.getX(); + return manip.getCurrentPose().getX(); } public double getY() { - return manip.currentPose.getY(); + return manip.getCurrentPose().getY(); } public double getZ() { - return manip.currentPose.getZ(); + return manip.getCurrentPose().getZ(); } public void checkBounds() { double minYTest = part.getMinY()-yMin+globalPose.getY(); From 0d561e333a0d4c1b4e613515e5b5b9b2ae09e483 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 15:02:52 -0400 Subject: [PATCH 075/635] remove jcanetral --- GithubPasswordManager | 2 +- JCSG | 2 +- build.gradle | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/GithubPasswordManager b/GithubPasswordManager index 37ede193..cc34e23e 160000 --- a/GithubPasswordManager +++ b/GithubPasswordManager @@ -1 +1 @@ -Subproject commit 37ede193e8f847fab565dd1969cc2ea879486198 +Subproject commit cc34e23eebb200deaaf698a9eca0e3a2a0178669 diff --git a/JCSG b/JCSG index e35c8c64..3921b62d 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e35c8c6470ae951d8811fcb8c64b45dae6ae9054 +Subproject commit 3921b62d237083e9bba9e3ab73723e033b424ef0 diff --git a/build.gradle b/build.gradle index b202b374..e8e5adac 100755 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ buildscript { maven { url "https://repo1.maven.org/maven2/" }, - //jcenter(), mavenCentral(), maven { url "https://plugins.gradle.org/m2/" @@ -126,10 +125,7 @@ repositories { maven { url 'https://repo.maven.apache.org/maven2/' } maven { url 'https://repo1.maven.org/maven2/'} - //https://jcenter.bintray.com< - maven { url 'https://jcenter.bintray.com/'} - //jcenter() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } //maven { url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } maven { url 'https://oss.sonatype.org/content/repositories/releases/' } From 705f71e84655f16fb26fd61de580e98efdb0db43 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 15:05:20 -0400 Subject: [PATCH 076/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 3921b62d..61c0dca1 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 3921b62d237083e9bba9e3ab73723e033b424ef0 +Subproject commit 61c0dca19ff8f7d3a64cc41cb3f15d7f59db66f2 From b46cdca2ec71ed393cd4562f85bb481796cac1ce Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 12 Aug 2024 19:48:38 -0400 Subject: [PATCH 077/635] updating the build sources to use my mirror --- build.gradle | 26 ++++++++++++++----- .../bowlerkernel/Bezier3d/Manipulation.java | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index e8e5adac..29a70598 100755 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,8 @@ String getOsArch() { repositories { mavenCentral() maven { - url 'https://mlt.jfrog.io/artifactory/mlt-mvn-releases-local/' + url 'https://commonwealthrobotics.com/jcenter-mirror/' + allowInsecureProtocol = true } maven { url 'https://repo.maven.apache.org/maven2/' } @@ -140,6 +141,17 @@ repositories { } maven { url 'https://maven-central.storage-download.googleapis.com/repos/central/data/'} maven {url 'https://repo.jenkins-ci.org/public/'} + maven { + url "https://repo.jenkins-ci.org/releases/" + } + + maven { url "https://jitpack.io" } + maven { url "https://repo.eclipse.org/content/groups/releases/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://dl.bintray.com/dfki-lt/maven/" } + maven { url "https://raw.github.com/marytts/marytts/master/repository/" } + maven { url "https://repo.jenkins-ci.org/public/" } + } dependencies { @@ -147,6 +159,8 @@ dependencies { api 'com.neuronrobotics:JavaCad:1.6.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') + + //compile group: "de.swirtz", name: "ktsRunner", version: "0.0.7" api 'us.ihmc:jinput:2.0.6-ihmc2' @@ -209,11 +223,11 @@ dependencies { testImplementation 'junit:junit:4.10' api group: 'com.github.stephengold', name: 'jbullet', version: '1.0.3' - implementation('de.dfki.mary:voice-cmu-slt-hsmm:5.2.1') { - exclude group: 'commons-io', module: 'commons-io' - exclude group: 'com.twmacinta', module: 'fast-md5' - exclude group: 'gov.nist.math', module: 'Jampack' - } +// implementation('de.dfki.mary:voice-cmu-slt-hsmm:5.2.1') { +// exclude group: 'commons-io', module: 'commons-io' +// exclude group: 'com.twmacinta', module: 'fast-md5' +// exclude group: 'gov.nist.math', module: 'Jampack' +// } implementation('de.dfki.mary:voice-dfki-poppy-hsmm:5.2') { exclude group: 'commons-io', module: 'commons-io' exclude group: 'com.twmacinta', module: 'fast-md5' diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 454253e6..7e4dbdef 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -226,7 +226,7 @@ private void performMove(TransformNR trans) { global.setRotation(new RotationNR()); setGlobal(global); - System.out.println(" drag "+global.getX()+" , "+global.getY()+" ,"+global.getZ()); + //System.out.println(" drag "+global.getX()+" , "+global.getY()+" ,"+global.getZ()); }catch(Throwable t) { t.printStackTrace(); From cec9a95dad78a054ad77e5fed1c95a1de8d97135 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 14 Aug 2024 09:18:52 -0400 Subject: [PATCH 078/635] fixed the jumping of resized objects --- .../bowlerstudio/scripting/cadoodle/Resize.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index e9ece5a7..da19cb57 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -53,7 +53,7 @@ private void resizeByName(String name, ArrayList back, HashMap back, HashMap=rightFront.getY()) + throw new RuntimeException("Scale must be positive!"); + if(lr.getX()>=rightFront.getX()) + throw new RuntimeException("Scale must be positive!"); return this; } From 3fb461acec7a1a1b2b90422d694d0b66551f17aa Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 14 Aug 2024 12:03:02 -0400 Subject: [PATCH 079/635] Renaming the fields in resize to match reality --- .../scripting/cadoodle/Resize.java | 24 +++++++++---------- .../junit/bowler/TestCaDoodleWorkflow.java | 6 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index da19cb57..bd0ade33 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -21,9 +21,9 @@ public class Resize implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private TransformNR height = null; @Expose(serialize = true, deserialize = true) - private TransformNR rightFront = null; + private TransformNR leftFront = null; @Expose(serialize = true, deserialize = true) - private TransformNR leftRear = null; + private TransformNR rightRear = null; @Override public String getType() { @@ -61,15 +61,15 @@ private void resizeByName(String name, ArrayList back, HashMap back, } } - public Resize setResize(TransformNR h, TransformNR rf, TransformNR lr) { + public Resize setResize(TransformNR h, TransformNR lf, TransformNR rr) { height = h; - rightFront = rf; - leftRear = lr; - if(lr.getY()>=rightFront.getY()) - throw new RuntimeException("Scale must be positive!"); - if(lr.getX()>=rightFront.getX()) + leftFront = lf; + rightRear = rr; + if(rightRear.getY()>=leftFront.getY() && rightRear.getX()>=leftFront.getX()) + return setResize(h,rr,lf);// they were swapped, just fix it and move along + if(rightRear.getY()>=leftFront.getY() || rightRear.getX()>=leftFront.getX()) throw new RuntimeException("Scale must be positive!"); return this; } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index c158825a..6ec946f1 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -129,10 +129,10 @@ public void test() throws Exception { String groupName = back.get(2).getName(); System.out.println("Group Name : "+groupName); TransformNR height = new TransformNR(0,0,40); - TransformNR rightFront = new TransformNR(40,10,0); - TransformNR leftRear = new TransformNR(-10,80,0); + TransformNR leftFront = new TransformNR(40,80,0); + TransformNR rightRear = new TransformNR(-10,10,0); Resize resize = new Resize() - .setResize(height, rightFront, leftRear) + .setResize(height, leftFront, rightRear) .setNames(Arrays.asList(groupName)) ; loaded.addOpperation(resize).join();; From 737623acb4237e22b1cf16ab1aae1bf346528cdb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 14 Aug 2024 13:23:29 -0400 Subject: [PATCH 080/635] use the bounds of the selection to set the scaling factors --- .../scripting/cadoodle/Resize.java | 54 +++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index bd0ade33..8110e03f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -10,8 +10,10 @@ import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.Vector3d; public class Resize implements ICaDoodleOpperation { @@ -37,39 +39,73 @@ private class ResizeEvent{ double movex; } + public Bounds getSellectedBounds(List incoming) { + Vector3d min = null; + Vector3d max = null; + for (CSG c : incoming) { + Vector3d min2 = c.getBounds().getMin().clone(); + Vector3d max2 = c.getBounds().getMax().clone(); + if (min == null) + min = min2; + if (max == null) + max = max2; + if (min2.x < min.x) + min.x = min2.x; + if (min2.y < min.y) + min.y = min2.y; + if (min2.z < min.z) + min.z = min2.z; + if (max.x < max2.x) + max.x = max2.x; + if (max.y < max2.y) + max.y = max2.y; + if (max.z < max2.z) + max.z = max2.z; + } + + return new Bounds(min, max); + } @Override public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); HashMap groupsProcessed = new HashMap<>(); + ArrayList selected = new ArrayList(); + for(CSG c:incoming) + for (String name : names) { + if(c.getName().contentEquals(name)) { + selected.add(c); + } + } + Bounds b = getSellectedBounds(selected); for (String name : names) { - resizeByName(name,back,groupsProcessed); + resizeByName(name,back,groupsProcessed,b); } return back; } - private void resizeByName(String name, ArrayList back, HashMap groupsProcessed) { + private void resizeByName(String name, ArrayList back, HashMap groupsProcessed,Bounds bounds) { for (int i = 0; i < back.size(); i++) { CSG starting = back.get(i); if ( starting.getName().contentEquals(name) ){ - double zScale = Math.abs(height.getZ())-starting.getMinZ(); - double scalez = zScale/ starting.getTotalZ(); + double zScale = Math.abs(height.getZ())-bounds.getMin().z; + double scalez = zScale/ (bounds.getMax().z-bounds.getMin().z); Transform scaleZ =new Transform().scaleZ(scalez); CSG resizeUp = starting.transformed(scaleZ); - double zMove = -resizeUp.getMinZ()+starting.getMinZ(); + double zMove = -(bounds.getMin().z*scalez)+bounds.getMin().z; resizeUp=resizeUp .movez(zMove); double xdimen = Math.abs(leftFront.getX()-rightRear.getX()); double ydimen = Math.abs(leftFront.getY()-rightRear.getY()); - double scalex = xdimen/ resizeUp.getTotalX(); - double scaley = ydimen/ resizeUp.getTotalY(); + double scalex = xdimen/ (bounds.getMax().x-bounds.getMin().x); + double scaley = ydimen/ (bounds.getMax().y-bounds.getMin().y); Transform scale = new Transform().scale(scalex,scaley,1); resizeUp=resizeUp.transformed(scale); - double xMove=-resizeUp.getMinX()+rightRear.getX(); - double yMove = -resizeUp.getMinY()+rightRear.getY(); + double xMove=-(bounds.getMin().x*scalex)+rightRear.getX(); + double yMove = -(bounds.getMin().y*scaley)+rightRear.getY(); resizeUp=resizeUp .movex(xMove) .movey(yMove); From 57efe35f924a56f88bf55dceedffc2e8f3a43136 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 14 Aug 2024 15:29:25 -0400 Subject: [PATCH 081/635] process and oercenter rezice as a mirror --- .../bowlerkernel/Bezier3d/Manipulation.java | 37 +++++++++++-------- .../scripting/cadoodle/Resize.java | 22 ++++++++--- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 7e4dbdef..5e212a1f 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -167,20 +167,22 @@ private void release(MouseEvent event) { } private void dragged(MouseEvent event) { - getUi().runLater(() -> { - setDragging(event); - double deltx = (startx - event.getScreenX()); - double delty = (starty - event.getScreenY()); - double d = deltx/ getDepthNow() ; - double y = delty/ getDepthNow() ; - if(Double.isFinite(y) && Double.isFinite(d)) { - TransformNR trans = new TransformNR(d, y, 0, new RotationNR()); - performMove(trans); - }else { - System.out.println("ERROR?"); - } - }); - event.consume(); + if(state==DragState.Dragging) { + getUi().runLater(() -> { + setDragging(event); + double deltx = (startx - event.getScreenX()); + double delty = (starty - event.getScreenY()); + double d = deltx/ getDepthNow() ; + double y = delty/ getDepthNow() ; + if(Double.isFinite(y) && Double.isFinite(d)) { + TransformNR trans = new TransformNR(d, y, 0, new RotationNR()); + performMove(trans); + }else { + System.out.println("ERROR?"); + } + }); + event.consume(); + } } public boolean isMoving() { @@ -193,7 +195,8 @@ private void mouseRelease(MouseEvent event) { getGlobalPose().setX(newx); getGlobalPose().setY(newy); getGlobalPose().setZ(newz); - event.consume(); + if(event!=null) + event.consume(); fireSave(); } } @@ -297,4 +300,8 @@ public void setCurrentPose(TransformNR currentPose) { this.currentPose = currentPose; } + public void cancel() { + release(null); + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 8110e03f..e88955d2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -101,11 +101,23 @@ private void resizeByName(String name, ArrayList back, HashMap=leftFront.getY() && rightRear.getX()>=leftFront.getX()) return setResize(h,rr,lf);// they were swapped, just fix it and move along - if(rightRear.getY()>=leftFront.getY() || rightRear.getX()>=leftFront.getX()) - throw new RuntimeException("Scale must be positive!"); +// if(rightRear.getY()>=leftFront.getY() || rightRear.getX()>=leftFront.getX()) +// throw new RuntimeException("Scale must be positive!"); return this; } From 20b50a547228f8a4c259a8cfd34ab3c9487aea27 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 14 Aug 2024 15:34:22 -0400 Subject: [PATCH 082/635] resiz the height correctly --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index e88955d2..3a353e9a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -89,9 +89,10 @@ private void resizeByName(String name, ArrayList back, HashMap Date: Thu, 15 Aug 2024 10:33:19 -0400 Subject: [PATCH 083/635] adding to the options for constructiong a rotation --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 79b257a3..188a01f3 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 79b257a3d7ee6bc45a1e54162849d0307d482490 +Subproject commit 188a01f344ecef4eb4c64664fc85c2440964a041 From 666c6b1a03953013c4cae7c7ee06bd4856091232 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 15 Aug 2024 17:37:35 -0400 Subject: [PATCH 084/635] Adding a way to read the project name without processing the file --- .../scripting/cadoodle/CaDoodleFile.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6fa3c1ab..8867b233 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -184,6 +184,7 @@ public List getCurrentState() { public List getSelect(List selectedSnapshot) { List cur = getCurrentState(); ArrayList back =new ArrayList(); + if(cur!=null) for(CSG c:cur) { for(String s:selectedSnapshot) { if(c.getName().contentEquals(s)) { @@ -229,9 +230,9 @@ public File save() throws IOException { public static CaDoodleFile fromJsonString(String content ) throws Exception{ - return fromJsonString(content, null, null); + return fromJsonString(content, null, null,true); } - public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate listener, File self) throws Exception { + public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate listener, File self, boolean initialize) throws Exception { CaDoodleFile file =gson.fromJson(content, TT_CaDoodleFile); if(listener!=null) { file.addListener(listener); @@ -239,16 +240,23 @@ public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate l if(self!=null) { file.setSelf(self); } - file.initialize(); + if(initialize) + file.initialize(); return file; } public static CaDoodleFile fromFile(File f ) throws Exception{ return fromFile(f,null); } + public static String getProjectName(File f ) throws Exception{ + System.out.println("CaDoodle file reading from "+f.getAbsolutePath()); + String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); + CaDoodleFile file =fromJsonString(content,null,f,false); + return file.getProjectName(); + } public static CaDoodleFile fromFile(File f,ICaDoodleStateUpdate listener ) throws Exception { System.out.println("CaDoodle file loading from "+f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); - CaDoodleFile file =fromJsonString(content,listener,f); + CaDoodleFile file =fromJsonString(content,listener,f,true); return file; } public ArrayList getOpperations() { From fa3a372dedf2c653f445dd10cb3191d6b56b53e1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 16 Aug 2024 10:06:53 -0400 Subject: [PATCH 085/635] Make the names accessable from the outside so its possible to detect what new objects were created --- .../scripting/cadoodle/AddFromScript.java | 18 +++++++++++++++--- .../bowlerstudio/scripting/cadoodle/Paste.java | 9 +++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 4ce6a498..37f6daeb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.stream.Collectors; @@ -18,8 +19,10 @@ public class AddFromScript implements ICaDoodleOpperation { private String fileRel = ""; @Expose (serialize = true, deserialize = true) private String name=null; - @Expose (serialize = true, deserialize = true) + @Expose (serialize = false, deserialize = false) private int nameIndex = 0; + @Expose (serialize = false, deserialize = false) + private HashSet namesAdded = new HashSet<>(); public AddFromScript set(String git, String f) { gitULR = git; @@ -36,10 +39,15 @@ private String getOrderedName() { if(name==null) { name=RandomStringFactory.generateRandomString(); } + String result; if(nameIndex==0) - return name; + result= name; + else { + result= name+"_"+nameIndex; + } nameIndex++; - return name+"_"+nameIndex; + namesAdded.add(result); + return result; } @Override @@ -67,4 +75,8 @@ public List process(List incoming) { return back; } + public HashSet getNamesAdded() { + return namesAdded; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 73340460..8ca07a68 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -19,6 +20,9 @@ public class Paste implements ICaDoodleOpperation { public String paste=null; @Expose (serialize = true, deserialize = true) public double offset=10; + @Expose (serialize = false, deserialize = false) + public HashSet newNames = new HashSet(); + @Override public String getType() { return "Paste"; @@ -64,6 +68,7 @@ private int copyPasteMoved(ArrayList back, int index, CSG c) { index++; newOne.syncProperties(c).setName(name); back.add(newOne); + getNewNames().add(name); return index; } @@ -94,4 +99,8 @@ public Paste setOffset(double offset) { this.offset = offset; return this; } + + public HashSet getNewNames() { + return newNames; + } } From 401ac90c7cf64abfa60be4ef003c95d2099157a5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 16 Aug 2024 17:37:11 -0400 Subject: [PATCH 086/635] Adding the workplane to the cadoodle file --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8867b233..66333e2e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -19,6 +19,7 @@ import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; @@ -31,6 +32,8 @@ public class CaDoodleFile { private int currentIndex =0; @Expose (serialize = true, deserialize = true) private String projectName =NO_NAME; + @Expose (serialize = true, deserialize = true) + private TransformNR workplane =new TransformNR(); @Expose (serialize = false, deserialize = false) private File selfInternal; // @Expose (serialize = false, deserialize = false) @@ -265,6 +268,14 @@ public ArrayList getOpperations() { public void setOpperations(ArrayList opperations) { this.opperations = opperations; } + public TransformNR getWorkplane() { + if(workplane==null) + workplane=new TransformNR(); + return workplane; + } + public void setWorkplane(TransformNR workplane) { + this.workplane = workplane; + } } From e71f51c334cb4a00f096073fb0f347b63144a59f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 17 Aug 2024 09:24:13 -0400 Subject: [PATCH 087/635] update jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 61c0dca1..830f0aec 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 61c0dca19ff8f7d3a64cc41cb3f15d7f59db66f2 +Subproject commit 830f0aec34eccc345c61ac1398af7eae7ffddfe9 From 3c3ac9e03b69191dfc94b9e0a7259e45ccf1f60e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 17 Aug 2024 10:55:35 -0400 Subject: [PATCH 088/635] Adding an auto snapshot for images on buttons! --- .../bowlerstudio/creature/ThumbnailImage.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java new file mode 100644 index 00000000..d55897da --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -0,0 +1,123 @@ +package com.neuronrobotics.bowlerstudio.creature; + +import java.util.List; + +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.Bounds; +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Vector3d; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.SceneAntialiasing; +import javafx.scene.SnapshotParameters; +import javafx.scene.image.WritableImage; +import javafx.scene.paint.Color; +import javafx.scene.paint.PhongMaterial; +import javafx.scene.shape.MeshView; +import javafx.scene.transform.Transform; +import javafx.scene.PerspectiveCamera; +import javafx.embed.swing.SwingFXUtils; +import javafx.scene.transform.Affine; +import javafx.scene.transform.Rotate; + +public class ThumbnailImage { + public static Bounds getSellectedBounds(List incoming) { + Vector3d min = null; + Vector3d max = null; + for (CSG c : incoming) { + Vector3d min2 = c.getBounds().getMin().clone(); + Vector3d max2 = c.getBounds().getMax().clone(); + if (min == null) + min = min2; + if (max == null) + max = max2; + if (min2.x < min.x) + min.x = min2.x; + if (min2.y < min.y) + min.y = min2.y; + if (min2.z < min.z) + min.z = min2.z; + if (max.x < max2.x) + max.x = max2.x; + if (max.y < max2.y) + max.y = max2.y; + if (max.z < max2.z) + max.z = max2.z; + } + + return new Bounds(min, max); + } + public static WritableImage get(List csgList) { + // Create a group to hold all the meshes + Group root = new Group(); + + // Add all meshes to the group + Bounds b = getSellectedBounds(csgList); + + double yOffset = -b.getMin().y; + double xOffset = -b.getMin().x; + for (CSG csg : csgList) { + MeshView meshView = csg + .getMesh(); + if(csg.isHole()) { + PhongMaterial material = new PhongMaterial(); + material.setDiffuseColor(new Color(0.25,0.25,0.25,0.75)); + material.setSpecularColor(javafx.scene.paint.Color.WHITE); + meshView.setMaterial(material); + meshView.setOpacity(0.25); + } + root.getChildren().add(meshView); + } + + // Calculate the bounds of all CSGs combined + double totalz = b.getMax().z-b.getMin().z; + double totaly = b.getMax().y-b.getMin().y; + double totalx = b.getMax().x-b.getMin().x; + + // Create a perspective camera + PerspectiveCamera camera = new PerspectiveCamera(true); + + // Calculate camera position to fit all objects in view + double maxDimension = Math.max(totalx, + Math.max(totaly, totalz)); + double cameraDistance = maxDimension / Math.tan(Math.toRadians(camera.getFieldOfView() / 2))*0.8; + + TransformNR cameraPose = new TransformNR(xOffset, + yOffset, + - cameraDistance); + TransformNR rot = new TransformNR(new RotationNR(45,45,0)); + Affine af = TransformFactory.nrToAffine(rot.times(cameraPose)); + camera.getTransforms().add(af); + // Position the camera +// camera.setTranslateX(); +// camera.setTranslateY(); +// camera.setTranslateZ(); +// // Apply rotations to the root group instead of the camera +// root.getTransforms().addAll( +// new Rotate(-5, Rotate.Y_AXIS), +// new Rotate(-45, Rotate.X_AXIS) +// ); + // Create a scene with the group and camera + Scene scene = new Scene(root, 1000, 1000, true, SceneAntialiasing.BALANCED); + scene.setFill(Color.RED); + scene.setCamera(camera); + + // Set up snapshot parameters + SnapshotParameters params = new SnapshotParameters(); + params.setFill(Color.TRANSPARENT); + params.setCamera(camera); + params.setDepthBuffer(true); + params.setTransform(Transform.scale(1, 1)); + + // Create the WritableImage first + WritableImage snapshot = new WritableImage(1000, 1000); + + + root.snapshot(params, snapshot); + + return snapshot; + } +} From 31090dc63125663aaaf1834648fcefb0d4e5452e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 17 Aug 2024 12:16:06 -0400 Subject: [PATCH 089/635] set background to transparent --- .../bowlerstudio/creature/ThumbnailImage.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index d55897da..3cdec40f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -101,8 +101,9 @@ public static WritableImage get(List csgList) { // new Rotate(-45, Rotate.X_AXIS) // ); // Create a scene with the group and camera - Scene scene = new Scene(root, 1000, 1000, true, SceneAntialiasing.BALANCED); - scene.setFill(Color.RED); + int i = 1000; + Scene scene = new Scene(root, i, i, true, SceneAntialiasing.BALANCED); + scene.setFill(Color.TRANSPARENT); scene.setCamera(camera); // Set up snapshot parameters @@ -113,7 +114,7 @@ public static WritableImage get(List csgList) { params.setTransform(Transform.scale(1, 1)); // Create the WritableImage first - WritableImage snapshot = new WritableImage(1000, 1000); + WritableImage snapshot = new WritableImage(i, i); root.snapshot(params, snapshot); From f9ccbce2846f7a7747739b4dbca396c11f63966b Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 23 Aug 2024 15:45:47 -0400 Subject: [PATCH 090/635] Manipulator now has a settable frame of reference --- .../bowlerkernel/Bezier3d/IFrameProvider.java | 7 +++ .../bowlerkernel/Bezier3d/Manipulation.java | 51 ++++++++++++++----- 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/IFrameProvider.java diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/IFrameProvider.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/IFrameProvider.java new file mode 100644 index 00000000..9df2bd4d --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/IFrameProvider.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerkernel.Bezier3d; + +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +public interface IFrameProvider { + public TransformNR get(); +} diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 5e212a1f..0c3ca423 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -33,9 +33,10 @@ public class Manipulation { private ArrayList saveListeners = new ArrayList<>(); private ArrayList dependants = new ArrayList<>(); private Affine manipulationMatrix; - private Vector3d orintation; + private TransformNR orintation; private TransformNR globalPose= new TransformNR(); private TransformNR currentPose=new TransformNR(); + private IFrameProvider frameOfReference = ()->new TransformNR(); //private PhongMaterial color;// = new PhongMaterial(getColor()); //private PhongMaterial highlight = new PhongMaterial(Color.GOLD); @@ -91,7 +92,7 @@ private void fireSave() { // } public Manipulation(Affine mm, Vector3d o, TransformNR p) { this.manipulationMatrix = mm; - this.orintation = o; + this.orintation = new TransformNR(o.x, o.y, o.z); //this.manip = m; //color = new PhongMaterial(m.getColor()); this.setGlobalPose(p); @@ -172,10 +173,11 @@ private void dragged(MouseEvent event) { setDragging(event); double deltx = (startx - event.getScreenX()); double delty = (starty - event.getScreenY()); - double d = deltx/ getDepthNow() ; + double x = deltx/ getDepthNow() ; double y = delty/ getDepthNow() ; - if(Double.isFinite(y) && Double.isFinite(d)) { - TransformNR trans = new TransformNR(d, y, 0, new RotationNR()); + //System.out.println("Moved "+x+" "+y); + if(Double.isFinite(y) && Double.isFinite(x)) { + TransformNR trans = new TransformNR(x, y, 0, new RotationNR()); performMove(trans); }else { System.out.println("ERROR?"); @@ -214,18 +216,28 @@ private void setDragging(MouseEvent event) { private void performMove(TransformNR trans) { TransformNR camerFrame = getUi().getCamerFrame(); - TransformNR globalTMP = camerFrame.copy(); + TransformNR globalTMP = new TransformNR(camerFrame.getRotation()); try { - globalTMP.setX(0); - globalTMP.setY(0); - globalTMP.setZ(0); + TransformNR global = globalTMP.times(trans); - newx = round((global.getX() * orintation.x + getGlobalPose().getX())); - newy = round((global.getY() * orintation.y + getGlobalPose().getY())); - newz = round((global.getZ() * orintation.z + getGlobalPose().getZ())); + TransformNR wp = getFrameOfReference().copy(); + wp.setX(0); + wp.setY(0); + wp.setZ(0); + global=wp.inverse().times(global); + + newx = round((global.getX() * orintation.getX() )); + newy = round((global.getY() * orintation.getY() )); + newz = round((global.getZ() * orintation.getZ() )); + + TransformNR globalTrans = globalPose.copy().setRotation(new RotationNR()); global.setX(newx); global.setY(newy); global.setZ(newz); + global.setRotation(new RotationNR()); + TransformNR o =wp.times(global).times(wp.inverse()).setRotation(new RotationNR()); + global=globalTrans.times(o); + global.setRotation(new RotationNR()); setGlobal(global); @@ -279,6 +291,13 @@ public void reset() { public TransformNR getGlobalPose() { return globalPose; } + public TransformNR getGlobalPoseInReferenceFrame() { + TransformNR globalPose = getGlobalPose().copy(); + TransformNR wp = new TransformNR( getFrameOfReference() .getRotation()); + globalPose=wp.times(globalPose); + globalPose.setRotation(new RotationNR()); + return globalPose; + } public void setGlobalPose(TransformNR globalPose) { this.globalPose = globalPose; @@ -304,4 +323,12 @@ public void cancel() { release(null); } + public TransformNR getFrameOfReference() { + return frameOfReference.get(); + } + + public void setFrameOfReference(IFrameProvider frameOfReference) { + this.frameOfReference = frameOfReference; + } + } From 8e9436160dd62385a053c2cec5bcba5f64003c48 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 24 Aug 2024 07:27:41 -0400 Subject: [PATCH 091/635] helper to access reference frame data --- .../bowlerkernel/Bezier3d/Manipulation.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 0c3ca423..539d7eef 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -282,7 +282,18 @@ public void set(double newX, double newY, double newZ) { } } + public void setInReferenceFrame(double newX, double newY, double newZ) { + TransformNR inLocal = new TransformNR(newX, newY, newZ); + TransformNR wp = new TransformNR( getFrameOfReference() .getRotation()); + inLocal=wp.times(inLocal); + inLocal.setRotation(new RotationNR()); + //System.out.println(inLocal.toSimpleString()); + setGlobal(inLocal); + for (Runnable R : eventListeners) { + R.run(); + } + } public void reset() { // TODO Auto-generated method stub @@ -298,7 +309,13 @@ public TransformNR getGlobalPoseInReferenceFrame() { globalPose.setRotation(new RotationNR()); return globalPose; } - + public TransformNR getCurrentPoseInReferenceFrame() { + TransformNR globalPose = getCurrentPose().copy(); + TransformNR wp = new TransformNR( getFrameOfReference() .getRotation()); + globalPose=wp.times(globalPose); + globalPose.setRotation(new RotationNR()); + return globalPose; + } public void setGlobalPose(TransformNR globalPose) { this.globalPose = globalPose; } From 4441693fdadba06ab38abf4af1966f753c33528f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 24 Aug 2024 09:59:01 -0400 Subject: [PATCH 092/635] Adding the workplane to the workflow of resize Resize handles are always in the workplane frame of reference and the workplane is defined in the resize event --- .../scripting/cadoodle/Resize.java | 58 +++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 3a353e9a..ff0295b1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.creature.IMobileBaseUI; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -26,6 +27,10 @@ public class Resize implements ICaDoodleOpperation { private TransformNR leftFront = null; @Expose(serialize = true, deserialize = true) private TransformNR rightRear = null; + @Expose(serialize = true, deserialize = true) + private TransformNR workplane = new TransformNR(); + @Expose(serialize = false, deserialize = false) + private IMobileBaseUI debug; @Override public String getType() { @@ -42,7 +47,8 @@ private class ResizeEvent{ public Bounds getSellectedBounds(List incoming) { Vector3d min = null; Vector3d max = null; - for (CSG c : incoming) { + for (CSG i : incoming) { + CSG c=i.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); Vector3d min2 = c.getBounds().getMin().clone(); Vector3d max2 = c.getBounds().getMax().clone(); if (min == null) @@ -94,10 +100,21 @@ private void resizeByName(String name, ArrayList back, HashMap back, HashMap back, HashMap back, if(c.isInGroup() && c.checkGroupMembership(name) ) { ResizeEvent ev =groupsProcessed.get(name); - CSG gc = c.transformed(ev.scaleZ); + CSG transformed = c.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); + if(debug!=null) { + debug.setCsg(transformed, null); + } + CSG gc = transformed + .transformed(ev.scaleZ); gc=gc .movez(ev.movez); gc=gc.transformed(ev.scale); gc=gc .movex(ev.movex) - .movey(ev.movey); + .movey(ev.movey) + .transformed(TransformFactory.nrToCSG(getWorkplane())); gc.syncProperties(c).setName(c.getName()); back.set(i, gc); if( c.isGroupResult()) { @@ -168,6 +200,9 @@ public Resize setResize(TransformNR h, TransformNR lf, TransformNR rr) { height = h; leftFront = lf; rightRear = rr; + if(Math.abs(lf.getZ()-rr.getZ())>0.00001) { + throw new RuntimeException("The control points of the corners must be at the same Z value \n"+lf.toSimpleString()+"\n"+rr.toSimpleString()); + } if(rightRear.getY()>=leftFront.getY() && rightRear.getX()>=leftFront.getX()) return setResize(h,rr,lf);// they were swapped, just fix it and move along // if(rightRear.getY()>=leftFront.getY() || rightRear.getX()>=leftFront.getX()) @@ -183,5 +218,18 @@ public Resize setNames(List names) { this.names = names; return this; } + public TransformNR getWorkplane() { + if(workplane==null) + workplane=new TransformNR(); + return workplane; + } + public Resize setWorkplane(TransformNR workplane) { + this.workplane = workplane; + return this; + } + public Resize setDebugger(IMobileBaseUI engine) { + this.debug = engine; + return this; + } } From 29ceb4987ae064753a4d27f9f9e05150d6dfa330 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 24 Aug 2024 16:43:16 -0400 Subject: [PATCH 093/635] adding an external load\/initialize --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 66333e2e..9a8f1dc8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -61,7 +61,7 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { listeners.add(l); return this; } - private void initialize() { + public void initialize() { int indexStarting = currentIndex; currentIndex=0; for(int i=0;i getOpperations() { From 3ec1af89e5ab8190f432cd2c6fff02b17a09ec91 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 25 Aug 2024 14:17:23 -0400 Subject: [PATCH 094/635] Adding workplane feature to the allingn methods --- .../scripting/cadoodle/Allign.java | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 6393714c..ad7a1945 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -4,6 +4,8 @@ import java.util.List; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -16,6 +18,9 @@ public class Allign implements ICaDoodleOpperation { public AllignmentY y=null; @Expose (serialize = true, deserialize = true) public AllignmentX x=null; + @Expose (serialize = true, deserialize = true) + private TransformNR workplane=null; + @Override public String getType() { return "Allign"; @@ -31,7 +36,7 @@ public List process(List incoming) { String name = names.get(0); if(name.contentEquals(c.getName())) { back.remove(c); - reference=c; + reference=c.transformed(TransformFactory.nrToCSG(workplane).inverse()); } } for(CSG c: back) { @@ -41,19 +46,21 @@ public List process(List incoming) { toMove.add(c); } } - for(CSG c:toMove) { + for(CSG tmp:toMove) { + CSG c = tmp.transformed(TransformFactory.nrToCSG(workplane).inverse()); if(z!=null) { switch(z) { case BottomAllign: - back.add( c.toZMin() - .movez(reference.getMinZ())); + c=( c.toZMin() + .movez(reference.getMinZ()) + ); break; case Center: - back.add( c.moveToCenterZ() + c=( c.moveToCenterZ() .movez(reference.getCenterZ())); break; case TopAllign: - back.add( c.toZMax() + c=( c.toZMax() .movez(reference.getMaxZ())); break; default: @@ -63,15 +70,15 @@ public List process(List incoming) { if(x!=null) { switch(x) { case Back: - back.add( c.toXMin() + c=( c.toXMin() .movex(reference.getMinX())); break; case Center: - back.add( c.moveToCenterX() + c=( c.moveToCenterX() .movex(reference.getCenterX())); break; case Front: - back.add( c.toXMax() + c=( c.toXMax() .movex(reference.getMaxX())); break; default: @@ -82,22 +89,23 @@ public List process(List incoming) { if(y!=null) { switch(y) { case Center: - back.add( c.moveToCenterY() + c=( c.moveToCenterY() .movey(reference.getCenterY())); break; case Left: - back.add( c.toYMax() + c=( c.toYMax() .movey(reference.getMaxY())); break; case Right: - back.add( c.toYMin() - .movey(reference.getMinY())); + c= c.toYMin() + .movey(reference.getMinY()); break; default: break; } } + back.add(c.transformed(TransformFactory.nrToCSG(workplane))); } return back; } @@ -117,4 +125,15 @@ public Allign setAllignParams(AllignmentX X, AllignmentY Y,AllignmentZ Z) { return this; } + public TransformNR getWorkplane() { + if(workplane==null) + workplane= new TransformNR(); + return workplane; + } + + public Allign setWorkplane(TransformNR workplane) { + this.workplane = workplane; + return this; + } + } From b2a9239dfea09d8f485170166775f389440c85e1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 25 Aug 2024 16:21:39 -0400 Subject: [PATCH 095/635] apply transform and increase far clip --- .../bowlerstudio/creature/ThumbnailImage.java | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 3cdec40f..de372b1e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -22,6 +22,7 @@ import javafx.embed.swing.SwingFXUtils; import javafx.scene.transform.Affine; import javafx.scene.transform.Rotate; +import javafx.geometry.Rectangle2D; public class ThumbnailImage { public static Bounds getSellectedBounds(List incoming) { @@ -50,6 +51,7 @@ public static Bounds getSellectedBounds(List incoming) { return new Bounds(min, max); } + public static WritableImage get(List csgList) { // Create a group to hold all the meshes Group root = new Group(); @@ -57,40 +59,38 @@ public static WritableImage get(List csgList) { // Add all meshes to the group Bounds b = getSellectedBounds(csgList); - double yOffset = -b.getMin().y; - double xOffset = -b.getMin().x; + double yOffset = (b.getMax().y-b.getMin().y)/2; + double xOffset =(b.getMax().x -b.getMin().x)/2; for (CSG csg : csgList) { - MeshView meshView = csg - .getMesh(); - if(csg.isHole()) { - PhongMaterial material = new PhongMaterial(); - material.setDiffuseColor(new Color(0.25,0.25,0.25,0.75)); - material.setSpecularColor(javafx.scene.paint.Color.WHITE); - meshView.setMaterial(material); - meshView.setOpacity(0.25); + MeshView meshView = csg.getMesh(); + if (csg.isHole()) { + PhongMaterial material = new PhongMaterial(); + material.setDiffuseColor(new Color(0.25, 0.25, 0.25, 0.75)); + material.setSpecularColor(javafx.scene.paint.Color.WHITE); + meshView.setMaterial(material); + meshView.setOpacity(0.25); } root.getChildren().add(meshView); } // Calculate the bounds of all CSGs combined - double totalz = b.getMax().z-b.getMin().z; - double totaly = b.getMax().y-b.getMin().y; - double totalx = b.getMax().x-b.getMin().x; + double totalz = b.getMax().z - b.getMin().z; + double totaly = b.getMax().y - b.getMin().y; + double totalx = b.getMax().x - b.getMin().x; // Create a perspective camera PerspectiveCamera camera = new PerspectiveCamera(true); // Calculate camera position to fit all objects in view - double maxDimension = Math.max(totalx, - Math.max(totaly, totalz)); - double cameraDistance = maxDimension / Math.tan(Math.toRadians(camera.getFieldOfView() / 2))*0.8; - - TransformNR cameraPose = new TransformNR(xOffset, - yOffset, - - cameraDistance); - TransformNR rot = new TransformNR(new RotationNR(45,45,0)); - Affine af = TransformFactory.nrToAffine(rot.times(cameraPose)); - camera.getTransforms().add(af); + double maxDimension = Math.max(totalx, Math.max(totaly, totalz)); + double cameraDistance = (maxDimension / Math.tan(Math.toRadians(camera.getFieldOfView() / 2)))*0.9 ; + + TransformNR camoffset = new TransformNR(xOffset, yOffset, 0); + TransformNR camDist = new TransformNR(0, 0, -cameraDistance); + TransformNR rot = new TransformNR(new RotationNR(-155, 45, 0)); + + Affine af = TransformFactory.nrToAffine(camoffset.times(rot.times(camDist))); + camera.getTransforms().add(af); // Position the camera // camera.setTranslateX(); // camera.setTranslateY(); @@ -112,13 +112,16 @@ public static WritableImage get(List csgList) { params.setCamera(camera); params.setDepthBuffer(true); params.setTransform(Transform.scale(1, 1)); + // Set the near and far clip + camera.setNearClip(0.1); // Set the near clip plane + camera.setFarClip(9000.0); // Set the far clip plane + + + // Create the WritableImage first + WritableImage snapshot = new WritableImage(i, i); - // Create the WritableImage first - WritableImage snapshot = new WritableImage(i, i); - + root.snapshot(params, snapshot); - root.snapshot(params, snapshot); - - return snapshot; + return snapshot; } } From 5b6a21099438b0bc062f8ce068a3c5ae6f156cfd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 25 Aug 2024 16:40:49 -0400 Subject: [PATCH 096/635] thumbnail image seems to work --- .../bowlerstudio/creature/ThumbnailImage.java | 7 ++++--- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index de372b1e..f074a7b3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -61,8 +61,9 @@ public static WritableImage get(List csgList) { double yOffset = (b.getMax().y-b.getMin().y)/2; double xOffset =(b.getMax().x -b.getMin().x)/2; + double zCenter = (b.getMax().z -b.getMin().z)/2; for (CSG csg : csgList) { - MeshView meshView = csg.getMesh(); + MeshView meshView = csg.movez(-zCenter).getMesh(); if (csg.isHole()) { PhongMaterial material = new PhongMaterial(); material.setDiffuseColor(new Color(0.25, 0.25, 0.25, 0.75)); @@ -83,11 +84,11 @@ public static WritableImage get(List csgList) { // Calculate camera position to fit all objects in view double maxDimension = Math.max(totalx, Math.max(totaly, totalz)); - double cameraDistance = (maxDimension / Math.tan(Math.toRadians(camera.getFieldOfView() / 2)))*0.9 ; + double cameraDistance = (maxDimension / Math.tan(Math.toRadians(camera.getFieldOfView() / 2)))*0.8 ; TransformNR camoffset = new TransformNR(xOffset, yOffset, 0); TransformNR camDist = new TransformNR(0, 0, -cameraDistance); - TransformNR rot = new TransformNR(new RotationNR(-155, 45, 0)); + TransformNR rot = new TransformNR(new RotationNR(-150, 45, 0)); Affine af = TransformFactory.nrToAffine(camoffset.times(rot.times(camDist))); camera.getTransforms().add(af); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9a8f1dc8..49a139bf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -23,6 +23,9 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; + +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; public class CaDoodleFile { public static final String NO_NAME = "NoName"; @@ -62,6 +65,10 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { return this; } public void initialize() { + if(selfInternal!=null) { + File db = new File(selfInternal.getAbsoluteFile().getParent()+delim()+"CSGdatabase.json"); + CSGDatabase.setDbFile(db); + } int indexStarting = currentIndex; currentIndex=0; for(int i=0;i Date: Sun, 25 Aug 2024 17:02:13 -0400 Subject: [PATCH 097/635] Add argument of the unique nale of the script to the paraameters --- .../bowlerstudio/scripting/ScriptingEngine.java | 8 ++++---- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 8 +++++++- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 9d5f7630..33e51665 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -119,15 +119,15 @@ public static void flatenInterna(Object o, Class type,ArrayList flatte } } } - public static List flaten(String git,String file, Class type) throws Exception{ + public static List flaten(String git,String file, Class type, ArrayList args) throws Exception{ ArrayList flattened = new ArrayList(); - Object o =gitScriptRun(git, file); + Object o =gitScriptRun(git, file,args); flatenInterna(o,type,flattened); return flattened; } - public static List flaten(File f, Class type) throws Exception{ + public static List flaten(File f, Class type, ArrayList args) throws Exception{ ArrayList flattened = new ArrayList(); - Object o =inlineFileScriptRun(f, null); + Object o =inlineFileScriptRun(f, args); flatenInterna(o,type,flattened); return flattened; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index e38a52d2..f35ad245 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -2,6 +2,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.stream.Collectors; @@ -41,9 +42,14 @@ private String getOrderedName() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); + if(name==null) { + name=RandomStringFactory.generateRandomString(); + } try { + ArrayListargs = new ArrayList<>(); + args.addAll(Arrays.asList(name )); back.addAll(ScriptingEngine - .flaten(new File(fileLocation), CSG.class) + .flaten(new File(fileLocation), CSG.class,args) .stream() .map(csg->{ return csg diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 37f6daeb..0e719567 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Random; @@ -54,9 +55,14 @@ private String getOrderedName() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); + if(name==null) { + name=RandomStringFactory.generateRandomString(); + } try { + ArrayListargs = new ArrayList<>(); + args.addAll(Arrays.asList(name )); back.addAll(ScriptingEngine - .flaten(gitULR, fileRel, CSG.class) + .flaten(gitULR, fileRel, CSG.class,args) .stream() .map(csg->{ return csg From 876110ea334a08145a7e39a25c84495c51f1bd9e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 25 Aug 2024 19:25:02 -0400 Subject: [PATCH 098/635] Adding a starting location to the add object script --- .../scripting/cadoodle/AddFromFile.java | 17 +++++++++++++++++ .../scripting/cadoodle/AddFromScript.java | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index f35ad245..53f7c15e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -8,7 +8,9 @@ import java.util.stream.Collectors; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -17,6 +19,9 @@ public class AddFromFile implements ICaDoodleOpperation { private String fileLocation=null; @Expose (serialize = true, deserialize = true) private String name=null; + @Expose(serialize = true, deserialize = true) + private TransformNR location = null; + private int nameIndex = 0; public AddFromFile set(File source) { fileLocation=source.getAbsolutePath(); @@ -56,6 +61,7 @@ public List process(List incoming) { .moveToCenterX() .moveToCenterY() .toZMin() + .transformed(TransformFactory.nrToCSG( getLocation() )) .syncProperties(csg) .setName(getOrderedName()); }) @@ -68,4 +74,15 @@ public List process(List incoming) { return back; } + public TransformNR getLocation() { + if(location==null) + location=new TransformNR(); + return location; + } + + public AddFromFile setLocation(TransformNR location) { + this.location = location; + return this; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 0e719567..d766c31f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -9,7 +9,9 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -20,6 +22,9 @@ public class AddFromScript implements ICaDoodleOpperation { private String fileRel = ""; @Expose (serialize = true, deserialize = true) private String name=null; + @Expose(serialize = true, deserialize = true) + private TransformNR location =null; + @Expose (serialize = false, deserialize = false) private int nameIndex = 0; @Expose (serialize = false, deserialize = false) @@ -69,6 +74,7 @@ public List process(List incoming) { .moveToCenterX() .moveToCenterY() .toZMin() + .transformed(TransformFactory.nrToCSG( getLocation() )) .syncProperties(csg) .setName(getOrderedName()); }) @@ -85,4 +91,15 @@ public HashSet getNamesAdded() { return namesAdded; } + public TransformNR getLocation() { + if(location==null) + location=new TransformNR(); + return location; + } + + public AddFromScript setLocation(TransformNR location) { + this.location = location; + return this; + } + } From bfdc2cba06aca4cf3217fa1920e16c20fd05f680 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 27 Aug 2024 13:13:32 -0400 Subject: [PATCH 099/635] Adding a regeneration pathway for add scripts that include parameters --- .../scripting/cadoodle/AbstractAddFrom.java | 32 +++++++++++++++++ .../scripting/cadoodle/AddFromFile.java | 28 +++++++-------- .../scripting/cadoodle/AddFromScript.java | 34 +++++++------------ .../scripting/cadoodle/CaDoodleFile.java | 27 ++++++++++++++- 4 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java new file mode 100644 index 00000000..9972a346 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -0,0 +1,32 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.HashSet; + +import com.google.gson.annotations.Expose; + +public abstract class AbstractAddFrom { + @Expose (serialize = false, deserialize = false) + protected HashSet namesAdded = new HashSet<>(); + @Expose (serialize = false, deserialize = false) + protected int nameIndex = 0; + + public HashSet getNamesAdded() { + return namesAdded; + } + public abstract String getName(); + + public abstract void setName(String name); + + public String getOrderedName() { + if(getName()==null) { + setName(RandomStringFactory.generateRandomString()); + } + String result= getName(); + if(nameIndex!=0){ + result+= "_"+nameIndex; + } + nameIndex++; + namesAdded.add(result); + return result; + } +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 53f7c15e..4369093c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -14,7 +14,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class AddFromFile implements ICaDoodleOpperation { +public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private String fileLocation=null; @Expose (serialize = true, deserialize = true) @@ -22,7 +22,6 @@ public class AddFromFile implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private TransformNR location = null; - private int nameIndex = 0; public AddFromFile set(File source) { fileLocation=source.getAbsolutePath(); return this; @@ -33,26 +32,19 @@ public String getType() { return "Add Object"; } - private String getOrderedName() { - if(name==null) { - name=RandomStringFactory.generateRandomString(); - } - if(nameIndex==0) - return name; - nameIndex++; - return name+"_"+nameIndex; - } + @Override public List process(List incoming) { + nameIndex=0; ArrayList back = new ArrayList(); back.addAll(incoming); - if(name==null) { - name=RandomStringFactory.generateRandomString(); + if(getName()==null) { + setName(RandomStringFactory.generateRandomString()); } try { ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(name )); + args.addAll(Arrays.asList(getName() )); back.addAll(ScriptingEngine .flaten(new File(fileLocation), CSG.class,args) .stream() @@ -85,4 +77,12 @@ public AddFromFile setLocation(TransformNR location) { return this; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index d766c31f..0e060042 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -15,7 +15,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class AddFromScript implements ICaDoodleOpperation { +public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private String gitULR = ""; @Expose (serialize = true, deserialize = true) @@ -25,10 +25,8 @@ public class AddFromScript implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private TransformNR location =null; - @Expose (serialize = false, deserialize = false) - private int nameIndex = 0; - @Expose (serialize = false, deserialize = false) - private HashSet namesAdded = new HashSet<>(); + + public AddFromScript set(String git, String f) { gitULR = git; @@ -41,23 +39,10 @@ public String getType() { return "Add Object"; } - private String getOrderedName() { - if(name==null) { - name=RandomStringFactory.generateRandomString(); - } - String result; - if(nameIndex==0) - result= name; - else { - result= name+"_"+nameIndex; - } - nameIndex++; - namesAdded.add(result); - return result; - } @Override public List process(List incoming) { + nameIndex=0; ArrayList back = new ArrayList(); back.addAll(incoming); if(name==null) { @@ -87,9 +72,7 @@ public List process(List incoming) { return back; } - public HashSet getNamesAdded() { - return namesAdded; - } + public TransformNR getLocation() { if(location==null) @@ -101,5 +84,12 @@ public AddFromScript setLocation(TransformNR location) { this.location = location; return this; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 49a139bf..eacbb01a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -50,6 +50,7 @@ public class CaDoodleFile { .create(); private ArrayList listeners = new ArrayList(); private Thread opperationRunner=null; + private boolean regenerating; public CaDoodleFile clearListeners() { listeners.clear(); return this; @@ -84,7 +85,30 @@ public void initialize() { currentIndex=indexStarting; updateCurrentFromCache(); } - + public void regenerateFrom(ICaDoodleOpperation source) { + if(regenerating) + return; + regenerating = true; + System.out.println("Regenerating Object from "+source.getType()); + int opIndex = 0; + int size = opperations.size(); + for(int i=0;i Date: Tue, 27 Aug 2024 13:42:42 -0400 Subject: [PATCH 100/635] clear parametrics after grouping --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 4 ++-- .../bowlerstudio/scripting/cadoodle/Group.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index eacbb01a..f986e324 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -89,7 +89,7 @@ public void regenerateFrom(ICaDoodleOpperation source) { if(regenerating) return; regenerating = true; - System.out.println("Regenerating Object from "+source.getType()); + //System.out.println("Regenerating Object from "+source.getType()); int opIndex = 0; int size = opperations.size(); for(int i=0;i process(List incoming) { result.setIsHole(false); result.setColor(c); } + HashMap mapOfparametrics = result.getMapOfparametrics(); + if(mapOfparametrics!=null) + mapOfparametrics.clear(); result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); back.add(result); From e5b057c64159d5620e4ba4508a45c553d5b4c7f8 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 27 Aug 2024 16:34:29 -0400 Subject: [PATCH 101/635] Updateing JCSG --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 830f0aec..84c92a1a 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 830f0aec34eccc345c61ac1398af7eae7ffddfe9 +Subproject commit 84c92a1a941878bdc9a84ea55a54d910a2e41a79 diff --git a/build.gradle b/build.gradle index 29a70598..494debd0 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.0' + api 'com.neuronrobotics:JavaCad:1.6.4' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From d098ececeb9bc3504f0de9df0bc3882619d35193 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 27 Aug 2024 17:08:40 -0400 Subject: [PATCH 102/635] fixing the color for just the base CSG --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 84c92a1a..363c3e00 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 84c92a1a941878bdc9a84ea55a54d910a2e41a79 +Subproject commit 363c3e003ea15dc8175eb7b3d0a437e0488c5a85 diff --git a/build.gradle b/build.gradle index 494debd0..641d7f55 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.4' + api 'com.neuronrobotics:JavaCad:1.6.5' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From e8fa602966cd8c8a0ea0ee373bb2b0f2766b361f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 27 Aug 2024 17:54:48 -0400 Subject: [PATCH 103/635] obey the current index on exit from regenerate --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f986e324..a3159940 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -91,6 +91,7 @@ public void regenerateFrom(ICaDoodleOpperation source) { regenerating = true; //System.out.println("Regenerating Object from "+source.getType()); int opIndex = 0; + int endIndex = currentIndex; int size = opperations.size(); for(int i=0;i Date: Tue, 27 Aug 2024 17:55:45 -0400 Subject: [PATCH 104/635] only redisplay if the index is different --- .../scripting/cadoodle/CaDoodleFile.java | 231 ++++++++++-------- 1 file changed, 133 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a3159940..74517f49 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -29,89 +29,97 @@ public class CaDoodleFile { public static final String NO_NAME = "NoName"; - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) private ArrayList opperations = new ArrayList(); - @Expose (serialize = true, deserialize = true) - private int currentIndex =0; - @Expose (serialize = true, deserialize = true) - private String projectName =NO_NAME; - @Expose (serialize = true, deserialize = true) - private TransformNR workplane =new TransformNR(); - @Expose (serialize = false, deserialize = false) + @Expose(serialize = true, deserialize = true) + private int currentIndex = 0; + @Expose(serialize = true, deserialize = true) + private String projectName = NO_NAME; + @Expose(serialize = true, deserialize = true) + private TransformNR workplane = new TransformNR(); + @Expose(serialize = false, deserialize = false) private File selfInternal; // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); - @Expose (serialize = false, deserialize = false) - private HashMap> cache =new HashMap>(); - private static Type TT_CaDoodleFile = new TypeToken() {}.getType(); - private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation() - .registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) + @Expose(serialize = false, deserialize = false) + private HashMap> cache = new HashMap>(); + private static Type TT_CaDoodleFile = new TypeToken() { + }.getType(); + private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() + .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) .create(); private ArrayList listeners = new ArrayList(); - private Thread opperationRunner=null; + private Thread opperationRunner = null; private boolean regenerating; + public CaDoodleFile clearListeners() { listeners.clear(); return this; } + public CaDoodleFile removeListener(ICaDoodleStateUpdate l) { - if(listeners.contains(l)) + if (listeners.contains(l)) listeners.remove(l); return this; } + public CaDoodleFile addListener(ICaDoodleStateUpdate l) { - if(!listeners.contains(l)) + if (!listeners.contains(l)) listeners.add(l); return this; } + public void initialize() { - if(selfInternal!=null) { - File db = new File(selfInternal.getAbsoluteFile().getParent()+delim()+"CSGdatabase.json"); + if (selfInternal != null) { + File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); } int indexStarting = currentIndex; - currentIndex=0; - for(int i=0;i{ - if(currentIndex != getOpperations().size()) { + opperationRunner = new Thread(() -> { + if (currentIndex != getOpperations().size()) { pruneForward(); } try { getOpperations().add(op); process(op); - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } - opperationRunner=null; + opperationRunner = null; }); opperationRunner.start(); return opperationRunner; } + private void pruneForward() { - for(int i=currentIndex;i back = cache.remove(getOpperations().get(i)); back.clear(); } List subList = (List) getOpperations().subList(0, currentIndex); - ArrayList newList=new ArrayList(); + ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); } + private void storeResultInCache(ICaDoodleOpperation op, List process) { ArrayList cachedCopy = new ArrayList(); HashSet names = new HashSet<>(); - for(CSG c:process) { - if(names.contains(c.getName())) + for (CSG c : process) { + if (names.contains(c.getName())) throw new RuntimeException("There can not be 2 objects with the same name after an opperation!"); names.add(c.getName()); cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName())); } - cache.put(op,cachedCopy); + cache.put(op, cachedCopy); } + public void back() { - if(isBackAvailible()) - currentIndex-=1; + if (isBackAvailible()) + currentIndex -= 1; updateCurrentFromCache(); } + public boolean isBackAvailible() { - return currentIndex>1; + return currentIndex > 1; } + private void updateCurrentFromCache() { ICaDoodleOpperation key = currentOpperation(); - System.out.println("Current opperation results: "+key.getType()); + System.out.println("Current opperation results: " + key.getType()); setCurrentState(key); } + public ICaDoodleOpperation currentOpperation() { - return getOpperations().get(currentIndex-1); + return getOpperations().get(currentIndex - 1); } + public void forward() { - if(isForwardAvailible()) - currentIndex+=1; + if (isForwardAvailible()) + currentIndex += 1; updateCurrentFromCache(); } + public boolean isForwardAvailible() { - return currentIndex getCurrentState() { - if(currentIndex==0) + if (currentIndex == 0) return new ArrayList(); return cache.get(currentOpperation()); } + public List getSelect(List selectedSnapshot) { List cur = getCurrentState(); - ArrayList back =new ArrayList(); - if(cur!=null) - for(CSG c:cur) { - for(String s:selectedSnapshot) { - if(c.getName().contentEquals(s)) { - back.add(c); - } - } - } + ArrayList back = new ArrayList(); + if (cur != null) + for (CSG c : cur) { + for (String s : selectedSnapshot) { + if (c.getName().contentEquals(s)) { + back.add(c); + } + } + } return back; } + public List getPreviouState() { - if(currentIndex<2) + if (currentIndex < 2) return new ArrayList(); - return cache.get(getOpperations().get(currentIndex-2)); + return cache.get(getOpperations().get(currentIndex - 2)); } + private void setCurrentState(ICaDoodleOpperation op) { - for(ICaDoodleStateUpdate l:listeners) { + for (ICaDoodleStateUpdate l : listeners) { try { - l.onUpdate(getCurrentState(),op,this); - }catch(Throwable e){ + l.onUpdate(getCurrentState(), op, this); + } catch (Throwable e) { e.printStackTrace(); } } } + public String getProjectName() { return projectName; } + public CaDoodleFile setProjectName(String projectName) { this.projectName = projectName; return this; } + public String toJson() { return gson.toJson(this); } - public File save() throws IOException { - - synchronized(getSelf()) { - String contents = toJson(); - FileUtils.write(getSelf(), contents,StandardCharsets.UTF_8, false); + + public File save() throws IOException { + + synchronized (getSelf()) { + String contents = toJson(); + FileUtils.write(getSelf(), contents, StandardCharsets.UTF_8, false); } return getSelf(); } - - public static CaDoodleFile fromJsonString(String content ) throws Exception{ - return fromJsonString(content, null, null,true); + public static CaDoodleFile fromJsonString(String content) throws Exception { + return fromJsonString(content, null, null, true); } - public static CaDoodleFile fromJsonString(String content ,ICaDoodleStateUpdate listener, File self, boolean initialize) throws Exception { - CaDoodleFile file =gson.fromJson(content, TT_CaDoodleFile); - if(listener!=null) { + + public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate listener, File self, + boolean initialize) throws Exception { + CaDoodleFile file = gson.fromJson(content, TT_CaDoodleFile); + if (listener != null) { file.addListener(listener); } - if(self!=null) { + if (self != null) { file.setSelf(self); } - if(initialize) + if (initialize) file.initialize(); return file; } - public static CaDoodleFile fromFile(File f ) throws Exception{ - return fromFile(f,null,true); + + public static CaDoodleFile fromFile(File f) throws Exception { + return fromFile(f, null, true); } - public static String getProjectName(File f ) throws Exception{ - System.out.println("CaDoodle file reading from "+f.getAbsolutePath()); + + public static String getProjectName(File f) throws Exception { + System.out.println("CaDoodle file reading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); - CaDoodleFile file =fromJsonString(content,null,f,false); + CaDoodleFile file = fromJsonString(content, null, f, false); return file.getProjectName(); } - public static CaDoodleFile fromFile(File f,ICaDoodleStateUpdate listener,boolean initialize ) throws Exception { - System.out.println("CaDoodle file loading from "+f.getAbsolutePath()); + + public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boolean initialize) throws Exception { + System.out.println("CaDoodle file loading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); - CaDoodleFile file =fromJsonString(content,listener,f,initialize); + CaDoodleFile file = fromJsonString(content, listener, f, initialize); return file; } + public ArrayList getOpperations() { return opperations; } + public void setOpperations(ArrayList opperations) { this.opperations = opperations; } + public TransformNR getWorkplane() { - if(workplane==null) - workplane=new TransformNR(); + if (workplane == null) + workplane = new TransformNR(); return workplane; } + public void setWorkplane(TransformNR workplane) { this.workplane = workplane; } - - } From 771c51aaf3f697651edb26344da5d85557971f93 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 09:28:24 -0400 Subject: [PATCH 105/635] make the csg dataabase concurrent safe --- JCSG | 2 +- build.gradle | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 84 +++++++++++-------- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/JCSG b/JCSG index 363c3e00..0f7862a2 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 363c3e003ea15dc8175eb7b3d0a437e0488c5a85 +Subproject commit 0f7862a28eb43585920cb4cebc276b19730453fe diff --git a/build.gradle b/build.gradle index 641d7f55..15de30f6 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.5' + api 'com.neuronrobotics:JavaCad:1.6.6' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 74517f49..833996b4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -10,6 +10,7 @@ import java.util.HashSet; import java.util.List; import java.util.Random; +import java.util.concurrent.CopyOnWriteArrayList; import org.apache.commons.io.FileUtils; @@ -51,6 +52,7 @@ public class CaDoodleFile { private ArrayList listeners = new ArrayList(); private Thread opperationRunner = null; private boolean regenerating; + private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); public CaDoodleFile clearListeners() { listeners.clear(); @@ -90,39 +92,43 @@ public void initialize() { updateCurrentFromCache(); } - public void regenerateFrom(ICaDoodleOpperation source) { + public Thread regenerateFrom(ICaDoodleOpperation source) { if (regenerating) - return; - regenerating = true; - // System.out.println("Regenerating Object from "+source.getType()); - int opIndex = 0; - int endIndex = currentIndex; - int size = opperations.size(); - for (int i = 0; i < size; i++) { - ICaDoodleOpperation op = opperations.get(i); - if (source == op) { - opIndex = i; - break; + return opperationRunner; + opperationRunner = new Thread(() -> { + regenerating = true; + // System.out.println("Regenerating Object from "+source.getType()); + int opIndex = 0; + int endIndex = currentIndex; + int size = opperations.size(); + for (int i = 0; i < size; i++) { + ICaDoodleOpperation op = opperations.get(i); + if (source == op) { + opIndex = i; + break; + } } - } - currentIndex = opIndex; - for (; currentIndex < size;) { - currentIndex++; - // System.out.println("Regenerating "+currentIndex); - ICaDoodleOpperation op = opperations.get(currentIndex - 1); - storeResultInCache(op, op.process(getPreviouState())); - setCurrentState(op); - } - if (currentIndex != endIndex) { - currentIndex = endIndex; - updateCurrentFromCache(); - } - regenerating = false; + currentIndex = opIndex; + for (; currentIndex < size;) { + currentIndex++; + // System.out.println("Regenerating "+currentIndex); + ICaDoodleOpperation op = opperations.get(currentIndex - 1); + storeResultInCache(op, op.process(getPreviouState())); + setCurrentState(op); + } + if (currentIndex != endIndex) { + currentIndex = endIndex; + updateCurrentFromCache(); + } + regenerating = false; + }); + opperationRunner.start(); + return opperationRunner; } public Thread regenerateCurrent() { if (isOperationRunning()) { - throw new CadoodleConcurrencyException("Do not add a new opperation while the previous one is processing"); + return opperationRunner; } opperationRunner = new Thread(() -> { ICaDoodleOpperation op = currentOpperation(); @@ -145,19 +151,23 @@ public boolean isOperationRunning() { return opperationRunner != null; } - public Thread addOpperation(ICaDoodleOpperation op) throws CadoodleConcurrencyException { + public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { + toProcess.add(o); if (isOperationRunning()) { - throw new CadoodleConcurrencyException("Do not add a new opperation while the previous one is processing"); + return opperationRunner; } opperationRunner = new Thread(() -> { - if (currentIndex != getOpperations().size()) { - pruneForward(); - } - try { - getOpperations().add(op); - process(op); - } catch (Exception ex) { - ex.printStackTrace(); + while(toProcess.size()>0) { + ICaDoodleOpperation op=toProcess.remove(0); + if (currentIndex != getOpperations().size()) { + pruneForward(); + } + try { + getOpperations().add(op); + process(op); + } catch (Exception ex) { + ex.printStackTrace(); + } } opperationRunner = null; }); From c7e5cdc0fe5dff90ff3ca041ea77d0466e362ee8 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 10:13:37 -0400 Subject: [PATCH 106/635] Make the cadoodle file thread safe and able to accept multiple opperations without having to finish the current op before moving on --- .../scripting/cadoodle/CaDoodleFile.java | 77 ++++++++++++------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 833996b4..1eb9a5d2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -76,8 +76,8 @@ public void initialize() { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); } - int indexStarting = currentIndex; - currentIndex = 0; + int indexStarting = getCurrentIndex(); + setCurrentIndex(0); for (int i = 0; i < opperations.size(); i++) { ICaDoodleOpperation op = opperations.get(i); try { @@ -88,19 +88,26 @@ public void initialize() { return; } } - currentIndex = indexStarting; + setCurrentIndex(indexStarting); updateCurrentFromCache(); } public Thread regenerateFrom(ICaDoodleOpperation source) { - if (regenerating) + if (regenerating || isOperationRunning()) { + System.out.println("Opperation is running, ignoring regen"); return opperationRunner; + } + int endIndex = getCurrentIndex(); + int size = opperations.size(); + if (endIndex != size) { +// new Exception("Regenerationg from a position back in time " + endIndex + " but have " + size) +// .printStackTrace(); + } opperationRunner = new Thread(() -> { + opperationRunner.setName("Regeneration Thread"); regenerating = true; // System.out.println("Regenerating Object from "+source.getType()); int opIndex = 0; - int endIndex = currentIndex; - int size = opperations.size(); for (int i = 0; i < size; i++) { ICaDoodleOpperation op = opperations.get(i); if (source == op) { @@ -108,16 +115,16 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { break; } } - currentIndex = opIndex; - for (; currentIndex < size;) { - currentIndex++; + setCurrentIndex(opIndex); + for (; getCurrentIndex() < size;) { + setCurrentIndex(getCurrentIndex() + 1); // System.out.println("Regenerating "+currentIndex); - ICaDoodleOpperation op = opperations.get(currentIndex - 1); + ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); storeResultInCache(op, op.process(getPreviouState())); setCurrentState(op); } - if (currentIndex != endIndex) { - currentIndex = endIndex; + if (getCurrentIndex() != endIndex) { + setCurrentIndex(endIndex); updateCurrentFromCache(); } regenerating = false; @@ -131,6 +138,8 @@ public Thread regenerateCurrent() { return opperationRunner; } opperationRunner = new Thread(() -> { + opperationRunner.setName("regenerateCurrent Thread"); + ICaDoodleOpperation op = currentOpperation(); storeResultInCache(op, op.process(getPreviouState())); setCurrentState(op); @@ -143,23 +152,29 @@ public Thread regenerateCurrent() { private void process(ICaDoodleOpperation op) { storeResultInCache(op, op.process(getCurrentState())); - currentIndex++; + setCurrentIndex(getCurrentIndex() + 1); setCurrentState(op); } public boolean isOperationRunning() { + if (opperationRunner != null) + if (!opperationRunner.isAlive()) + opperationRunner = null; return opperationRunner != null; } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { toProcess.add(o); if (isOperationRunning()) { + return opperationRunner; } opperationRunner = new Thread(() -> { - while(toProcess.size()>0) { - ICaDoodleOpperation op=toProcess.remove(0); - if (currentIndex != getOpperations().size()) { + + while (toProcess.size() > 0) { + opperationRunner.setName("addOpperation Thread " + toProcess.size()); + ICaDoodleOpperation op = toProcess.remove(0); + if (getCurrentIndex() != getOpperations().size()) { pruneForward(); } try { @@ -176,14 +191,15 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc } private void pruneForward() { - for (int i = currentIndex; i < getOpperations().size(); i++) { + for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { List back = cache.remove(getOpperations().get(i)); back.clear(); } - List subList = (List) getOpperations().subList(0, currentIndex); + List subList = (List) getOpperations().subList(0, getCurrentIndex()); ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); + System.err.println("Pruning forward here!"); } private void storeResultInCache(ICaDoodleOpperation op, List process) { @@ -200,12 +216,12 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { public void back() { if (isBackAvailible()) - currentIndex -= 1; + setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); } public boolean isBackAvailible() { - return currentIndex > 1; + return getCurrentIndex() > 1; } private void updateCurrentFromCache() { @@ -215,17 +231,17 @@ private void updateCurrentFromCache() { } public ICaDoodleOpperation currentOpperation() { - return getOpperations().get(currentIndex - 1); + return getOpperations().get(getCurrentIndex() - 1); } public void forward() { if (isForwardAvailible()) - currentIndex += 1; + setCurrentIndex(getCurrentIndex() + 1); updateCurrentFromCache(); } public boolean isForwardAvailible() { - return currentIndex < getOpperations().size(); + return getCurrentIndex() < getOpperations().size(); } public File getSelf() { @@ -246,7 +262,7 @@ public CaDoodleFile setSelf(File self) { } public List getCurrentState() { - if (currentIndex == 0) + if (getCurrentIndex() == 0) return new ArrayList(); return cache.get(currentOpperation()); } @@ -266,9 +282,9 @@ public List getSelect(List selectedSnapshot) { } public List getPreviouState() { - if (currentIndex < 2) + if (getCurrentIndex() < 2) return new ArrayList(); - return cache.get(getOpperations().get(currentIndex - 2)); + return cache.get(getOpperations().get(getCurrentIndex() - 2)); } private void setCurrentState(ICaDoodleOpperation op) { @@ -358,4 +374,13 @@ public void setWorkplane(TransformNR workplane) { this.workplane = workplane; } + public int getCurrentIndex() { + return currentIndex; + } + + public void setCurrentIndex(int currentIndex) { + //new Exception("Current Index set to " + currentIndex).printStackTrace(); + this.currentIndex = currentIndex; + } + } From a9d0418f20f74357156351f70ac2df790d51df61 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 10:16:23 -0400 Subject: [PATCH 107/635] opperation runner should be set to null at the end of the thread --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1eb9a5d2..a530a205 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -128,6 +128,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { updateCurrentFromCache(); } regenerating = false; + opperationRunner=null; }); opperationRunner.start(); return opperationRunner; From 6224bc2a8cabb168cd7cf769f8d4e180931dc420 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 10:28:16 -0400 Subject: [PATCH 108/635] remove missing myrobotlab --- build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 15de30f6..66af967d 100755 --- a/build.gradle +++ b/build.gradle @@ -133,12 +133,12 @@ repositories { //com.neuronrobotics hosting point maven { url 'https://oss.sonatype.org/content/repositories/staging/' } - maven { - url "https://repo.myrobotlab.org/artifactory/myrobotlab/" - content { - includeGroup("de.dfki.mary") - } - } +// maven { +// url "https://repo.myrobotlab.org/artifactory/myrobotlab/" +// content { +// includeGroup("de.dfki.mary") +// } +// } maven { url 'https://maven-central.storage-download.googleapis.com/repos/central/data/'} maven {url 'https://repo.jenkins-ci.org/public/'} maven { From e579f611c3e1fb937e9e53095fc16030d1d710ca Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 11:36:06 -0400 Subject: [PATCH 109/635] refactored the allignment for th UI ease --- .../scripting/cadoodle/Allign.java | 26 +++++++++---------- .../{AllignmentX.java => Allignment.java} | 8 +++--- .../scripting/cadoodle/AllignmentY.java | 7 ----- .../scripting/cadoodle/AllignmentZ.java | 7 ----- 4 files changed, 17 insertions(+), 31 deletions(-) rename src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/{AllignmentX.java => Allignment.java} (52%) delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index ad7a1945..79338f90 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -13,11 +13,11 @@ public class Allign implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) - public AllignmentZ z=null; + public Allignment z=null; @Expose (serialize = true, deserialize = true) - public AllignmentY y=null; + public Allignment y=null; @Expose (serialize = true, deserialize = true) - public AllignmentX x=null; + public Allignment x=null; @Expose (serialize = true, deserialize = true) private TransformNR workplane=null; @@ -50,16 +50,16 @@ public List process(List incoming) { CSG c = tmp.transformed(TransformFactory.nrToCSG(workplane).inverse()); if(z!=null) { switch(z) { - case BottomAllign: + case negative: c=( c.toZMin() .movez(reference.getMinZ()) ); break; - case Center: + case middle: c=( c.moveToCenterZ() .movez(reference.getCenterZ())); break; - case TopAllign: + case positive: c=( c.toZMax() .movez(reference.getMaxZ())); break; @@ -69,15 +69,15 @@ public List process(List incoming) { } if(x!=null) { switch(x) { - case Back: + case negative: c=( c.toXMin() .movex(reference.getMinX())); break; - case Center: + case middle: c=( c.moveToCenterX() .movex(reference.getCenterX())); break; - case Front: + case positive: c=( c.toXMax() .movex(reference.getMaxX())); break; @@ -88,15 +88,15 @@ public List process(List incoming) { } if(y!=null) { switch(y) { - case Center: + case middle: c=( c.moveToCenterY() .movey(reference.getCenterY())); break; - case Left: + case positive: c=( c.toYMax() .movey(reference.getMaxY())); break; - case Right: + case negative: c= c.toYMin() .movey(reference.getMinY()); break; @@ -118,7 +118,7 @@ public Allign setNames(List names) { this.names = names; return this; } - public Allign setAllignParams(AllignmentX X, AllignmentY Y,AllignmentZ Z) { + public Allign setAllignParams(Allignment X, Allignment Y,Allignment Z) { x=X; y=Y; z=Z; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allignment.java similarity index 52% rename from src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java rename to src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allignment.java index 54c33bb5..e2759593 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentX.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allignment.java @@ -1,7 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; -public enum AllignmentX { - Back, - Front, - Center, +public enum Allignment { + positive, + negative, + middle, } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java deleted file mode 100644 index bd34269c..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentY.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.neuronrobotics.bowlerstudio.scripting.cadoodle; - -public enum AllignmentY { - Right, - Left, - Center, -} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java deleted file mode 100644 index 5dc69111..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AllignmentZ.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.neuronrobotics.bowlerstudio.scripting.cadoodle; - -public enum AllignmentZ { - TopAllign, - BottomAllign, - Center, -} From e79f17720ce1ffb9fb22a3904d460046b617c9f5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 30 Aug 2024 14:48:34 -0400 Subject: [PATCH 110/635] jcsg --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 0f7862a2..bf2b9926 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 0f7862a28eb43585920cb4cebc276b19730453fe +Subproject commit bf2b9926d7a66662549d6776d0362d186476181f diff --git a/build.gradle b/build.gradle index 66af967d..ddc7cf20 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.6' + api 'com.neuronrobotics:JavaCad:1.6.7' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 21c3ae4c91a65cc35c2569edf8930afe741d847f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 09:24:40 -0400 Subject: [PATCH 111/635] Add save event to the save listeners --- .../bowlerstudio/scripting/cadoodle/Allign.java | 9 +++++++++ .../scripting/cadoodle/CaDoodleFile.java | 16 ++++++++++++++++ .../scripting/cadoodle/ICaDoodleStateUpdate.java | 1 + 3 files changed, 26 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 79338f90..a38ddfed 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -25,6 +25,15 @@ public class Allign implements ICaDoodleOpperation { public String getType() { return "Allign"; } + + @Override + public String toString(){ + String string = getType()+" "+x+" "+y+" "+z; + for(String n:getNames()) { + string+=" "+n; + } + return string; + } @Override public List process(List incoming) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a530a205..4d5cd36c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -128,6 +128,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { updateCurrentFromCache(); } regenerating = false; + fireSaveSuggestion(); opperationRunner=null; }); opperationRunner.start(); @@ -144,6 +145,7 @@ public Thread regenerateCurrent() { ICaDoodleOpperation op = currentOpperation(); storeResultInCache(op, op.process(getPreviouState())); setCurrentState(op); + fireSaveSuggestion(); opperationRunner = null; }); opperationRunner.start(); @@ -185,6 +187,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc ex.printStackTrace(); } } + fireSaveSuggestion(); opperationRunner = null; }); opperationRunner.start(); @@ -219,6 +222,7 @@ public void back() { if (isBackAvailible()) setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); + fireSaveSuggestion(); } public boolean isBackAvailible() { @@ -239,6 +243,7 @@ public void forward() { if (isForwardAvailible()) setCurrentIndex(getCurrentIndex() + 1); updateCurrentFromCache(); + fireSaveSuggestion(); } public boolean isForwardAvailible() { @@ -298,6 +303,16 @@ private void setCurrentState(ICaDoodleOpperation op) { } } } + private void fireSaveSuggestion() { + + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onSaveSuggestion(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } public String getProjectName() { return projectName; @@ -373,6 +388,7 @@ public TransformNR getWorkplane() { public void setWorkplane(TransformNR workplane) { this.workplane = workplane; + fireSaveSuggestion(); } public int getCurrentIndex() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index e83cc08e..47058d42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -6,4 +6,5 @@ public interface ICaDoodleStateUpdate { public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); + public void onSaveSuggestion(); } From 6fb6d301df7a9270340f3bd1ea153008ac9355b6 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 10:33:18 -0400 Subject: [PATCH 112/635] use getter for workplane --- .../bowlerstudio/scripting/cadoodle/Allign.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index a38ddfed..e819dac6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -45,10 +45,11 @@ public List process(List incoming) { String name = names.get(0); if(name.contentEquals(c.getName())) { back.remove(c); - reference=c.transformed(TransformFactory.nrToCSG(workplane).inverse()); + reference=c.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); } } - for(CSG c: back) { + for (int i = 0; i < back.size(); i++) { + CSG c = back.get(i); for(String name:names) if(name.contentEquals(c.getName())) { back.remove(c); @@ -56,7 +57,7 @@ public List process(List incoming) { } } for(CSG tmp:toMove) { - CSG c = tmp.transformed(TransformFactory.nrToCSG(workplane).inverse()); + CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); if(z!=null) { switch(z) { case negative: @@ -114,7 +115,7 @@ public List process(List incoming) { } } - back.add(c.transformed(TransformFactory.nrToCSG(workplane))); + back.add(c.transformed(TransformFactory.nrToCSG(getWorkplane()))); } return back; } From cab473e739ee7b979a272ab61cdd6e31eb0e2b04 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 11:08:03 -0400 Subject: [PATCH 113/635] Allign needed to sync the properties between the generated objects --- .../scripting/cadoodle/Allign.java | 151 +++++++++++------- 1 file changed, 90 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index e819dac6..76f694f5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -41,83 +41,112 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); CSG reference=null; + CSG refProps =null; for(CSG c: incoming) { String name = names.get(0); if(name.contentEquals(c.getName())) { back.remove(c); + refProps=c; reference=c.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); } } - for (int i = 0; i < back.size(); i++) { - CSG c = back.get(i); - for(String name:names) + for(String name:names) + collectToMove(toMove, back, name); + for(CSG tmp:toMove) { + CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + c = performTransform(reference, c); + back.add(sync(c,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); + } + CSG transformed = reference.transformed(TransformFactory.nrToCSG(getWorkplane())); + back.add(sync(refProps,transformed)); + return back; + } + + private void collectToMove(ArrayList toMove, ArrayList back, String name) { + ArrayList toSearch = new ArrayList(); + toSearch.addAll(back); + for (int i = 0; i < toSearch.size(); i++) { + CSG c = toSearch.get(i); if(name.contentEquals(c.getName())) { back.remove(c); toMove.add(c); + if(c.isGroupResult()) { + for(int j=0;j getNames() { From e5f3c74740ca7d47ccfa29bb6e7a438a1f6a1ae0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 13:48:25 -0400 Subject: [PATCH 114/635] update the jcsg to allow for storage of bounds in json --- JCSG | 2 +- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/Allign.java | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index bf2b9926..58229861 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit bf2b9926d7a66662549d6776d0362d186476181f +Subproject commit 58229861481df73046940359e309a9e3c7bf3b51 diff --git a/build.gradle b/build.gradle index ddc7cf20..68e20938 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.7' + api 'com.neuronrobotics:JavaCad:1.6.8' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 76f694f5..f6b68a79 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -7,6 +7,7 @@ import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; public class Allign implements ICaDoodleOpperation { @@ -20,6 +21,8 @@ public class Allign implements ICaDoodleOpperation { public Allignment x=null; @Expose (serialize = true, deserialize = true) private TransformNR workplane=null; + @Expose (serialize = true, deserialize = true) + private Bounds bounds=null; @Override public String getType() { @@ -175,4 +178,13 @@ public Allign setWorkplane(TransformNR workplane) { return this; } + public Bounds getBounds() { + return bounds; + } + + public Allign setBounds(Bounds bounds) { + this.bounds = bounds; + return this; + } + } From 5640cbce8555338779475d4613466f9a253292bb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 21:45:33 -0400 Subject: [PATCH 115/635] storing the bounds in a seperate object and generating bounds as needed --- build.gradle | 2 +- .../scripting/cadoodle/Allign.java | 6 +- .../scripting/cadoodle/StoragbeBounds.java | 57 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/StoragbeBounds.java diff --git a/build.gradle b/build.gradle index 68e20938..ddc7cf20 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.8' + api 'com.neuronrobotics:JavaCad:1.6.7' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index f6b68a79..6a16ac11 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -22,7 +22,7 @@ public class Allign implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private TransformNR workplane=null; @Expose (serialize = true, deserialize = true) - private Bounds bounds=null; + private StoragbeBounds bounds=null; @Override public String getType() { @@ -179,11 +179,11 @@ public Allign setWorkplane(TransformNR workplane) { } public Bounds getBounds() { - return bounds; + return bounds.getBounds(); } public Allign setBounds(Bounds bounds) { - this.bounds = bounds; + this.bounds = new StoragbeBounds(bounds); return this; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/StoragbeBounds.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/StoragbeBounds.java new file mode 100644 index 00000000..9e438cc1 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/StoragbeBounds.java @@ -0,0 +1,57 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import com.google.gson.annotations.Expose; + +import eu.mihosoft.vrl.v3d.Bounds; +import eu.mihosoft.vrl.v3d.Vector3d; + +public class StoragbeBounds { + /** + * The x coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double minx; + + /** + * The y coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double miny; + + /** + * The z coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double minz; + /** + * The x coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double maxx; + + /** + * The y coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double maxy; + + /** + * The z coordinate. + */ + @Expose (serialize = true, deserialize = true) + public double maxz; + public StoragbeBounds(Bounds b) { + minx=b.getMin().x; + miny=b.getMin().y; + minz=b.getMin().z; + maxx=b.getMax().x; + maxy=b.getMax().y; + maxz=b.getMax().z; + } + public Bounds getBounds() { + Vector3d min = new Vector3d(minx, miny, minz); + Vector3d max = new Vector3d(maxx, maxy, maxz); + return new Bounds(min, max); + } + +} From a6c9c63fe2c2cf45fb392d67ecb484d8203a42e9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 31 Aug 2024 23:08:22 -0400 Subject: [PATCH 116/635] Allignment is synchronized correctly --- build.gradle | 2 +- .../scripting/cadoodle/Allign.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index ddc7cf20..6ed5360f 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.7' + api 'com.neuronrobotics:JavaCad:1.6.10' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 6a16ac11..210d402e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -22,7 +22,7 @@ public class Allign implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private TransformNR workplane=null; @Expose (serialize = true, deserialize = true) - private StoragbeBounds bounds=null; + public StoragbeBounds bounds=null; @Override public String getType() { @@ -55,13 +55,20 @@ public List process(List incoming) { } for(String name:names) collectToMove(toMove, back, name); + Bounds bounds2 ;// + if(bounds!=null) { + bounds2=bounds.getBounds(); + toMove.add(refProps); + }else { + CSG transformed = reference.transformed(TransformFactory.nrToCSG(getWorkplane())); + back.add(sync(refProps,transformed)); + bounds2 = reference.getBounds(); + } for(CSG tmp:toMove) { CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); - c = performTransform(reference, c); - back.add(sync(c,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); + c = performTransform(bounds2, c); + back.add(sync(tmp,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); } - CSG transformed = reference.transformed(TransformFactory.nrToCSG(getWorkplane())); - back.add(sync(refProps,transformed)); return back; } @@ -86,7 +93,7 @@ private void collectToMove(ArrayList toMove, ArrayList back, String na } } - private CSG performTransform(CSG reference, CSG incoming) { + private CSG performTransform(Bounds reference, CSG incoming) { CSG c = incoming; if(z!=null) { switch(z) { From 42235d9f147e73e71367e0b1097929656db17744 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 1 Sep 2024 09:54:27 -0400 Subject: [PATCH 117/635] only clear if the list exists --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4d5cd36c..f65d9c31 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -197,7 +197,8 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { List back = cache.remove(getOpperations().get(i)); - back.clear(); + if(back!=null) + back.clear(); } List subList = (List) getOpperations().subList(0, getCurrentIndex()); ArrayList newList = new ArrayList(); From 3165b07d663e99c9808e37935dd7a766c411d7ae Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 2 Sep 2024 10:48:09 -0400 Subject: [PATCH 118/635] with the names to prepend the shorter hash seems reasonable. --- .../bowlerstudio/scripting/cadoodle/RandomStringFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java index fd2135a5..bae1e6da 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java @@ -9,7 +9,7 @@ public class RandomStringFactory { @Expose (serialize = false, deserialize = false) private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; @Expose (serialize = false, deserialize = false) - private static final int STRING_LENGTH = 40; + private static final int STRING_LENGTH = 10; public static String[] adjectives = { "Effervescent", "Zestful", "Vivacious", "Ebullient", "Sprightly", From b0cdafc150611e0877ba4116ac67aaa72ee2c180 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 4 Sep 2024 13:11:56 -0400 Subject: [PATCH 119/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 58229861..1c49b973 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 58229861481df73046940359e309a9e3c7bf3b51 +Subproject commit 1c49b97396d99dc7d8f968b71cb9aa49aceecf20 From 22d511a2e51ccc534f2795e718e24a9cbd506904 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 7 Sep 2024 11:40:49 -0400 Subject: [PATCH 120/635] java-bowler --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 188a01f3..b61304b7 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 188a01f344ecef4eb4c64664fc85c2440964a041 +Subproject commit b61304b79dc69418852dfcc8cb5362be32202b67 From 82e1ab5c91c179d4b1b30f88ee0c4e43feba01fd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 7 Sep 2024 11:41:48 -0400 Subject: [PATCH 121/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 1c49b973..58229861 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 1c49b97396d99dc7d8f968b71cb9aa49aceecf20 +Subproject commit 58229861481df73046940359e309a9e3c7bf3b51 From 9aa042b03040e1e716b1f7dff51df33bbf8413cc Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 8 Sep 2024 11:04:18 -0400 Subject: [PATCH 122/635] refactored the current op getter and made public the save operation --- .../bowlerkernel/Bezier3d/Manipulation.java | 4 ++-- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 539d7eef..faa8b987 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -80,7 +80,7 @@ private void fireMove(TransformNR trans) { } } - private void fireSave() { + public void fireSave() { new Thread(() -> { for (Runnable R : saveListeners) { R.run(); @@ -287,7 +287,7 @@ public void setInReferenceFrame(double newX, double newY, double newZ) { TransformNR wp = new TransformNR( getFrameOfReference() .getRotation()); inLocal=wp.times(inLocal); inLocal.setRotation(new RotationNR()); - //System.out.println(inLocal.toSimpleString()); + //System.out.println("Setting in reference frame:"+inLocal.toSimpleString()); setGlobal(inLocal); for (Runnable R : eventListeners) { R.run(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f65d9c31..690510bb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -142,7 +142,7 @@ public Thread regenerateCurrent() { opperationRunner = new Thread(() -> { opperationRunner.setName("regenerateCurrent Thread"); - ICaDoodleOpperation op = currentOpperation(); + ICaDoodleOpperation op = getCurrentOpperation(); storeResultInCache(op, op.process(getPreviouState())); setCurrentState(op); fireSaveSuggestion(); @@ -231,12 +231,12 @@ public boolean isBackAvailible() { } private void updateCurrentFromCache() { - ICaDoodleOpperation key = currentOpperation(); + ICaDoodleOpperation key = getCurrentOpperation(); System.out.println("Current opperation results: " + key.getType()); setCurrentState(key); } - public ICaDoodleOpperation currentOpperation() { + public ICaDoodleOpperation getCurrentOpperation() { return getOpperations().get(getCurrentIndex() - 1); } @@ -271,7 +271,7 @@ public CaDoodleFile setSelf(File self) { public List getCurrentState() { if (getCurrentIndex() == 0) return new ArrayList(); - return cache.get(currentOpperation()); + return cache.get(getCurrentOpperation()); } public List getSelect(List selectedSnapshot) { From de1877bb22016d3519088540e206342f19fc44e5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Sep 2024 10:38:16 -0400 Subject: [PATCH 123/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 58229861..1c49b973 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 58229861481df73046940359e309a9e3c7bf3b51 +Subproject commit 1c49b97396d99dc7d8f968b71cb9aa49aceecf20 From 387cb9b05f4eee530caff7c6616d077c18da0731 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Sep 2024 13:50:44 -0400 Subject: [PATCH 124/635] close https://github.com/CommonWealthRobotics/BowlerStudio/issues/424 --- .../bowlerstudio/scripting/ScriptingEngine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 33e51665..185fdc7b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -1749,7 +1749,12 @@ public static File cloneRepo(String remoteURI, String branch) { try { checkout(remoteURI, branch); } catch (Exception e) { - throw new RuntimeException(e); + try { + // try the checkout with no branch specified + return cloneRepo(remoteURI,null); + } catch (Exception ex) { + throw new RuntimeException(e); + } } } From 84f9023b846efc56eef0d93f3a73c02d13ad1c52 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 09:05:24 -0400 Subject: [PATCH 125/635] only show items thaw would be visable --- .../bowlerstudio/creature/ThumbnailImage.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index f074a7b3..a30baac5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -29,6 +29,10 @@ public static Bounds getSellectedBounds(List incoming) { Vector3d min = null; Vector3d max = null; for (CSG c : incoming) { + if(c.isHide()) + continue; + if(c.isInGroup()) + continue; Vector3d min2 = c.getBounds().getMin().clone(); Vector3d max2 = c.getBounds().getMax().clone(); if (min == null) @@ -63,6 +67,10 @@ public static WritableImage get(List csgList) { double xOffset =(b.getMax().x -b.getMin().x)/2; double zCenter = (b.getMax().z -b.getMin().z)/2; for (CSG csg : csgList) { + if(csg.isHide()) + continue; + if(csg.isInGroup()) + continue; MeshView meshView = csg.movez(-zCenter).getMesh(); if (csg.isHole()) { PhongMaterial material = new PhongMaterial(); @@ -71,6 +79,7 @@ public static WritableImage get(List csgList) { meshView.setMaterial(material); meshView.setOpacity(0.25); } + root.getChildren().add(meshView); } From c1cdaae63752391f8253bb73b45782834d0cbb22 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 09:13:01 -0400 Subject: [PATCH 126/635] crisper images --- .../neuronrobotics/bowlerstudio/creature/ThumbnailImage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index a30baac5..8dd2f8ce 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -16,6 +16,7 @@ import javafx.scene.image.WritableImage; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; +import javafx.scene.shape.CullFace; import javafx.scene.shape.MeshView; import javafx.scene.transform.Transform; import javafx.scene.PerspectiveCamera; @@ -79,7 +80,7 @@ public static WritableImage get(List csgList) { meshView.setMaterial(material); meshView.setOpacity(0.25); } - + meshView.setCullFace(CullFace.BACK); root.getChildren().add(meshView); } From ff90181c862acd0fc1a8eff130cb96f4806b2de1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 09:34:36 -0400 Subject: [PATCH 127/635] transform objects by the kinematics on the way in --- .../bowlerstudio/creature/ThumbnailImage.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 8dd2f8ce..4b3b780b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -1,5 +1,6 @@ package com.neuronrobotics.bowlerstudio.creature; +import java.util.ArrayList; import java.util.List; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; @@ -57,7 +58,15 @@ public static Bounds getSellectedBounds(List incoming) { return new Bounds(min, max); } - public static WritableImage get(List csgList) { + public static WritableImage get(List c) { + ArrayList csgList=new ArrayList() ; + for(CSG cs:c) { + if(cs.getManipulator()!=null) { + TransformNR nr = TransformFactory.affineToNr(cs.getManipulator()); + csgList.add(cs.transformed(TransformFactory.nrToCSG(nr))); + }else + csgList.add(cs); + } // Create a group to hold all the meshes Group root = new Group(); From 809549e927e3d1a3fe4439d40e65ce5cdd32f811 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 09:57:16 -0400 Subject: [PATCH 128/635] sync the properties of the moved csg for viewing --- .../neuronrobotics/bowlerstudio/creature/ThumbnailImage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 4b3b780b..9479207f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -63,7 +63,7 @@ public static WritableImage get(List c) { for(CSG cs:c) { if(cs.getManipulator()!=null) { TransformNR nr = TransformFactory.affineToNr(cs.getManipulator()); - csgList.add(cs.transformed(TransformFactory.nrToCSG(nr))); + csgList.add(cs.transformed(TransformFactory.nrToCSG(nr)).syncProperties(cs)); }else csgList.add(cs); } From 228e0c45655ecbb59e3ac95b42be91c22a641bf7 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 10:22:54 -0400 Subject: [PATCH 129/635] move the save image into the cadoodle file --- .../bowlerstudio/creature/ThumbnailImage.java | 5 +- .../scripting/cadoodle/CaDoodleFile.java | 66 +++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 9479207f..2dc8acdc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -54,7 +54,10 @@ public static Bounds getSellectedBounds(List incoming) { if (max.z < max2.z) max.z = max2.z; } - + if(max==null) + max=new Vector3d(0,0,0); + if(min==null) + min=new Vector3d(0,0,0); return new Bounds(min, max); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 690510bb..54eb8dc2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -1,5 +1,6 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.lang.reflect.Type; @@ -12,12 +13,16 @@ import java.util.Random; import java.util.concurrent.CopyOnWriteArrayList; +import javax.imageio.ImageIO; +import javafx.scene.image.WritableImage; import org.apache.commons.io.FileUtils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.BowlerKernel; +import com.neuronrobotics.bowlerstudio.creature.ThumbnailImage; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -25,6 +30,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import javafx.embed.swing.SwingFXUtils; import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; @@ -53,6 +59,7 @@ public class CaDoodleFile { private Thread opperationRunner = null; private boolean regenerating; private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); + private javafx.scene.image.WritableImage img; public CaDoodleFile clearListeners() { listeners.clear(); @@ -90,6 +97,7 @@ public void initialize() { } setCurrentIndex(indexStarting); updateCurrentFromCache(); + } public Thread regenerateFrom(ICaDoodleOpperation source) { @@ -129,7 +137,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } regenerating = false; fireSaveSuggestion(); - opperationRunner=null; + opperationRunner = null; }); opperationRunner.start(); return opperationRunner; @@ -197,7 +205,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { List back = cache.remove(getOpperations().get(i)); - if(back!=null) + if (back != null) back.clear(); } List subList = (List) getOpperations().subList(0, getCurrentIndex()); @@ -304,6 +312,7 @@ private void setCurrentState(ICaDoodleOpperation op) { } } } + private void fireSaveSuggestion() { for (ICaDoodleStateUpdate l : listeners) { @@ -330,13 +339,51 @@ public String toJson() { public File save() throws IOException { - synchronized (getSelf()) { + synchronized (selfInternal) { String contents = toJson(); - FileUtils.write(getSelf(), contents, StandardCharsets.UTF_8, false); + FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); + File parent = selfInternal.getAbsoluteFile().getParentFile(); + File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); + setImage(null); + BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); + while (getImage() == null) + try { + Thread.sleep(16); + // System.out.println("Waiting for image to write"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + break; + } + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(getImage(), null); + try { + ImageIO.write(bufferedImage, "png", image); + // System.out.println("Thumbnail saved successfully to " + + // image.getAbsolutePath()); + } catch (IOException e) { + // System.err.println("Error saving image: " + e.getMessage()); + e.printStackTrace(); + } } + return getSelf(); } + public WritableImage loadImageFromFile() { + try { + File parent = selfInternal.getAbsoluteFile().getParentFile(); + File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); + BufferedImage bufferedImage = ImageIO.read(image); + if (bufferedImage != null) { + img = SwingFXUtils.toFXImage(bufferedImage, null); + } + } catch (IOException e) { + System.err.println("Error loading image: " + e.getMessage()); + e.printStackTrace(); + } + return img; + } + public static CaDoodleFile fromJsonString(String content) throws Exception { return fromJsonString(content, null, null, true); } @@ -397,8 +444,17 @@ public int getCurrentIndex() { } public void setCurrentIndex(int currentIndex) { - //new Exception("Current Index set to " + currentIndex).printStackTrace(); + // new Exception("Current Index set to " + currentIndex).printStackTrace(); this.currentIndex = currentIndex; } + public javafx.scene.image.WritableImage getImage() { + return img; + } + + public javafx.scene.image.WritableImage setImage(javafx.scene.image.WritableImage img) { + this.img = img; + return img; + } + } From f352cc674e654a97e4b5c2ecbca47f5b4153f4c1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 14 Sep 2024 10:35:59 -0400 Subject: [PATCH 130/635] faail safe with no image --- .../scripting/cadoodle/CaDoodleFile.java | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 54eb8dc2..1f1bcdf3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -345,16 +345,7 @@ public File save() throws IOException { File parent = selfInternal.getAbsoluteFile().getParentFile(); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); setImage(null); - BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); - while (getImage() == null) - try { - Thread.sleep(16); - // System.out.println("Waiting for image to write"); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - break; - } + loadingImageFromUIThread(); BufferedImage bufferedImage = SwingFXUtils.fromFXImage(getImage(), null); try { ImageIO.write(bufferedImage, "png", image); @@ -373,9 +364,13 @@ public WritableImage loadImageFromFile() { try { File parent = selfInternal.getAbsoluteFile().getParentFile(); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); - BufferedImage bufferedImage = ImageIO.read(image); - if (bufferedImage != null) { - img = SwingFXUtils.toFXImage(bufferedImage, null); + if(image.exists()) { + BufferedImage bufferedImage = ImageIO.read(image); + if (bufferedImage != null) { + img = SwingFXUtils.toFXImage(bufferedImage, null); + } + }else { + loadingImageFromUIThread(); } } catch (IOException e) { System.err.println("Error loading image: " + e.getMessage()); @@ -384,6 +379,19 @@ public WritableImage loadImageFromFile() { return img; } + private void loadingImageFromUIThread() { + BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); + while (getImage() == null) + try { + Thread.sleep(16); + // System.out.println("Waiting for image to write"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + break; + } + } + public static CaDoodleFile fromJsonString(String content) throws Exception { return fromJsonString(content, null, null, true); } @@ -396,8 +404,9 @@ public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate l } if (self != null) { file.setSelf(self); + file.loadImageFromFile(); } - if (initialize) + if (initialize) file.initialize(); return file; } From 81e416e0d1a7e5da0f5f68b024fed5476593f105 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 18 Sep 2024 16:12:37 -0400 Subject: [PATCH 131/635] loading the image --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1f1bcdf3..7c4b6adc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -97,7 +97,8 @@ public void initialize() { } setCurrentIndex(indexStarting); updateCurrentFromCache(); - + loadImageFromFile(); + } public Thread regenerateFrom(ICaDoodleOpperation source) { @@ -404,10 +405,10 @@ public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate l } if (self != null) { file.setSelf(self); - file.loadImageFromFile(); } - if (initialize) + if (initialize) { file.initialize(); + } return file; } From 421ccfdd17d2077d35afcb5c463eb689b79bf9d9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Wed, 18 Sep 2024 16:37:40 -0400 Subject: [PATCH 132/635] getter for the initialization percentage --- .../scripting/cadoodle/CaDoodleFile.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7c4b6adc..f9619cd0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -48,6 +48,9 @@ public class CaDoodleFile { private File selfInternal; // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); + @Expose(serialize = false, deserialize = false) + private + double percentInitialized=0; @Expose(serialize = false, deserialize = false) private HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { @@ -85,8 +88,10 @@ public void initialize() { } int indexStarting = getCurrentIndex(); setCurrentIndex(0); + setPercentInitialized(0); for (int i = 0; i < opperations.size(); i++) { ICaDoodleOpperation op = opperations.get(i); + setPercentInitialized(((double)i)/(double)opperations.size()); try { process(op); } catch (Throwable t) { @@ -98,6 +103,7 @@ public void initialize() { setCurrentIndex(indexStarting); updateCurrentFromCache(); loadImageFromFile(); + setPercentInitialized(1); } @@ -467,4 +473,12 @@ public javafx.scene.image.WritableImage setImage(javafx.scene.image.WritableImag return img; } + public double getPercentInitialized() { + return percentInitialized; + } + + public void setPercentInitialized(double percentInitialized) { + this.percentInitialized = percentInitialized; + } + } From f5b8d7ffb5420d57a2bc6777ba5ee9806d2fcc64 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 28 Sep 2024 08:32:35 -0400 Subject: [PATCH 133/635] add an event tof the completion of initialization --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 +++++++- .../scripting/cadoodle/ICaDoodleStateUpdate.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f9619cd0..f837bfee 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -104,7 +104,13 @@ public void initialize() { updateCurrentFromCache(); loadImageFromFile(); setPercentInitialized(1); - + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onInitializationDone(); + } catch (Throwable e) { + e.printStackTrace(); + } + } } public Thread regenerateFrom(ICaDoodleOpperation source) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index 47058d42..bde72a1a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -7,4 +7,5 @@ public interface ICaDoodleStateUpdate { public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); public void onSaveSuggestion(); + public void onInitializationDone(); } From 4c4b3eca501ddb7c40378cfb9f001374740ce222 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 28 Sep 2024 11:07:03 -0400 Subject: [PATCH 134/635] adding a cancle interface --- .../scripting/cadoodle/CaDoodleFile.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f837bfee..c5aff35f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -63,6 +63,22 @@ public class CaDoodleFile { private boolean regenerating; private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; + + public void close() { + for(ICaDoodleOpperation op:cache.keySet()) { + cache.get(op).clear(); + } + cache.clear(); + cache=null; + clearListeners(); + listeners=null; + toProcess.clear(); + toProcess=null; + img=null; + if(opperationRunner!=null) + opperationRunner.interrupt(); + opperationRunner=null; + } public CaDoodleFile clearListeners() { listeners.clear(); From 38cdb38347075fd9ca733e932596f8c63034b531 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 2 Oct 2024 11:43:57 -0400 Subject: [PATCH 135/635] failsafe getter for first item --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index c5aff35f..c3959cbe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -274,6 +274,8 @@ private void updateCurrentFromCache() { } public ICaDoodleOpperation getCurrentOpperation() { + if(getCurrentIndex()==0) + return getOpperations().get(0); return getOpperations().get(getCurrentIndex() - 1); } From 098772de114bc10bf39560478879ff179a1f7c25 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 5 Oct 2024 11:17:13 -0400 Subject: [PATCH 136/635] add a timestamp to the cadoodle file --- .../scripting/cadoodle/CaDoodleFile.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index c3959cbe..73e394c1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -41,6 +41,8 @@ public class CaDoodleFile { @Expose(serialize = true, deserialize = true) private int currentIndex = 0; @Expose(serialize = true, deserialize = true) + private long timeCreated = -1; + @Expose(serialize = true, deserialize = true) private String projectName = NO_NAME; @Expose(serialize = true, deserialize = true) private TransformNR workplane = new TransformNR(); @@ -505,4 +507,14 @@ public void setPercentInitialized(double percentInitialized) { this.percentInitialized = percentInitialized; } + public long getTimeCreated() throws IOException { + if(timeCreated<0) { + timeCreated=System.currentTimeMillis(); + save(); + } + return timeCreated; + } + + + } From 5380ab8611e1fab9491a774aa4dc5d098596c68e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 6 Oct 2024 18:48:19 -0400 Subject: [PATCH 137/635] Make the update curretn safe for new files --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 73e394c1..df98e4b3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -271,13 +271,15 @@ public boolean isBackAvailible() { private void updateCurrentFromCache() { ICaDoodleOpperation key = getCurrentOpperation(); + if(key==null) + return; System.out.println("Current opperation results: " + key.getType()); setCurrentState(key); } public ICaDoodleOpperation getCurrentOpperation() { if(getCurrentIndex()==0) - return getOpperations().get(0); + return null; return getOpperations().get(getCurrentIndex() - 1); } @@ -432,6 +434,10 @@ public static CaDoodleFile fromJsonString(String content) throws Exception { public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate listener, File self, boolean initialize) throws Exception { CaDoodleFile file = gson.fromJson(content, TT_CaDoodleFile); + if(file==null) { + file=new CaDoodleFile(); + file.setProjectName(RandomStringFactory.getNextRandomName()); + } if (listener != null) { file.addListener(listener); } From 3c4582460e4b11012fe3d84c7e6960abc6bdc20e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 7 Oct 2024 07:06:24 -0400 Subject: [PATCH 138/635] stableized the file loading --- .../scripting/cadoodle/CaDoodleFile.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index df98e4b3..4849aa4c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -159,8 +159,9 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setCurrentIndex(getCurrentIndex() + 1); // System.out.println("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); - storeResultInCache(op, op.process(getPreviouState())); - setCurrentState(op); + List process = op.process(getPreviouState()); + storeResultInCache(op, process); + setCurrentState(op,process); } if (getCurrentIndex() != endIndex) { setCurrentIndex(endIndex); @@ -182,8 +183,9 @@ public Thread regenerateCurrent() { opperationRunner.setName("regenerateCurrent Thread"); ICaDoodleOpperation op = getCurrentOpperation(); - storeResultInCache(op, op.process(getPreviouState())); - setCurrentState(op); + List process = op.process(getPreviouState()); + storeResultInCache(op, process); + setCurrentState(op,process); fireSaveSuggestion(); opperationRunner = null; }); @@ -193,9 +195,10 @@ public Thread regenerateCurrent() { } private void process(ICaDoodleOpperation op) { - storeResultInCache(op, op.process(getCurrentState())); + List process = op.process(getCurrentState()); + storeResultInCache(op, process); setCurrentIndex(getCurrentIndex() + 1); - setCurrentState(op); + setCurrentState(op,process); } public boolean isOperationRunning() { @@ -274,7 +277,7 @@ private void updateCurrentFromCache() { if(key==null) return; System.out.println("Current opperation results: " + key.getType()); - setCurrentState(key); + setCurrentState(key,getCurrentState()); } public ICaDoodleOpperation getCurrentOpperation() { @@ -314,7 +317,10 @@ public CaDoodleFile setSelf(File self) { public List getCurrentState() { if (getCurrentIndex() == 0) return new ArrayList(); - return cache.get(getCurrentOpperation()); + List list = cache.get(getCurrentOpperation()); + if(list==null) + list= new ArrayList(); + return list; } public List getSelect(List selectedSnapshot) { @@ -337,11 +343,10 @@ public List getPreviouState() { return cache.get(getOpperations().get(getCurrentIndex() - 2)); } - private void setCurrentState(ICaDoodleOpperation op) { - + private void setCurrentState(ICaDoodleOpperation op,List currentState) { for (ICaDoodleStateUpdate l : listeners) { try { - l.onUpdate(getCurrentState(), op, this); + l.onUpdate(currentState, op, this); } catch (Throwable e) { e.printStackTrace(); } @@ -437,6 +442,7 @@ public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate l if(file==null) { file=new CaDoodleFile(); file.setProjectName(RandomStringFactory.getNextRandomName()); + file.getTimeCreated(); } if (listener != null) { file.addListener(listener); @@ -513,10 +519,9 @@ public void setPercentInitialized(double percentInitialized) { this.percentInitialized = percentInitialized; } - public long getTimeCreated() throws IOException { + public long getTimeCreated() { if(timeCreated<0) { timeCreated=System.currentTimeMillis(); - save(); } return timeCreated; } From eba12efb2fb3d253ad19571c49e1040dbbad76d3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 7 Oct 2024 18:37:01 -0400 Subject: [PATCH 139/635] remove the regeneration engine while initializing --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4849aa4c..43ef1012 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -65,6 +65,7 @@ public class CaDoodleFile { private boolean regenerating; private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; + private boolean initializing; public void close() { for(ICaDoodleOpperation op:cache.keySet()) { @@ -100,6 +101,9 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { } public void initialize() { + if(initializing) + throw new RuntimeException("Can not initialize while initializing."); + initializing=true; if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); @@ -129,9 +133,12 @@ public void initialize() { e.printStackTrace(); } } + initializing=false; } public Thread regenerateFrom(ICaDoodleOpperation source) { + if(initializing) + return null; if (regenerating || isOperationRunning()) { System.out.println("Opperation is running, ignoring regen"); return opperationRunner; @@ -155,8 +162,9 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } } setCurrentIndex(opIndex); + for (; getCurrentIndex() < size;) { - setCurrentIndex(getCurrentIndex() + 1); + //setCurrentIndex(getCurrentIndex() + 1); // System.out.println("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); From affffd908d83b83a4e846950340116de1f037407 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 8 Oct 2024 10:15:06 -0400 Subject: [PATCH 140/635] un-break regenerate --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 43ef1012..422b15f0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -164,7 +164,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setCurrentIndex(opIndex); for (; getCurrentIndex() < size;) { - //setCurrentIndex(getCurrentIndex() + 1); + setCurrentIndex(getCurrentIndex() + 1); // System.out.println("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); From 1c6dd2e8520c8956aaea117e4d7b0a45b0f2dbb7 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 12 Oct 2024 09:13:10 -0400 Subject: [PATCH 141/635] adding file regeneration parameter --- .../scripting/cadoodle/AddFromFile.java | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 4369093c..83266d28 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -13,6 +13,8 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.IRegenerate; +import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) @@ -43,21 +45,20 @@ public List process(List incoming) { setName(RandomStringFactory.generateRandomString()); } try { - ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(getName() )); - back.addAll(ScriptingEngine - .flaten(new File(fileLocation), CSG.class,args) - .stream() - .map(csg->{ - return csg - .moveToCenterX() - .moveToCenterY() - .toZMin() - .transformed(TransformFactory.nrToCSG( getLocation() )) - .syncProperties(csg) - .setName(getOrderedName()); - }) - .collect(Collectors.toCollection(ArrayList::new)) +// ArrayListargs = new ArrayList<>(); +// args.addAll(Arrays.asList(getName() )); + ArrayList options = new ArrayList(); + StringParameter parameter = new StringParameter(name+"_CaDoodle_FileName", fileLocation, options); + ArrayList collect = new ArrayList<>(); + List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); + + for (int i = 0; i < flattenedCSGs.size(); i++) { + CSG csg = flattenedCSGs.get(i); + CSG processedCSG = processGiven(csg,i,parameter,getOrderedName()); + + collect.add(processedCSG); + } + back.addAll(collect ); } catch (Exception e) { // TODO Auto-generated catch block @@ -66,6 +67,32 @@ public List process(List incoming) { return back; } + private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { + CSG processedCSG = csg + .moveToCenterX() + .moveToCenterY() + .toZMin() + .transformed(TransformFactory.nrToCSG(getLocation())) + .syncProperties(csg) + .setRegenerate(new IRegenerate() { + @Override + public CSG regenerate(CSG previous) { + try { + List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); + CSG csg = flattenedCSGs.get(i); + return processGiven(csg,i,parameter,name); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + }) + .setName(name); + return processedCSG; + } + public TransformNR getLocation() { if(location==null) location=new TransformNR(); From 96a304eca5d418f22b4fdc8ace3f0fe5fc47977e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 12 Oct 2024 09:15:53 -0400 Subject: [PATCH 142/635] adding a failure return path --- .../scripting/cadoodle/AddFromFile.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 83266d28..02242bcd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -13,7 +13,6 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; -import eu.mihosoft.vrl.v3d.parametrics.IRegenerate; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { @@ -74,21 +73,16 @@ private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { .toZMin() .transformed(TransformFactory.nrToCSG(getLocation())) .syncProperties(csg) - .setRegenerate(new IRegenerate() { - @Override - public CSG regenerate(CSG previous) { - try { - List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); - CSG csg = flattenedCSGs.get(i); - return processGiven(csg,i,parameter,name); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return null; - } - }) + .setRegenerate(previous -> { + try { + List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); + CSG csg1 = flattenedCSGs.get(i); + return processGiven(csg1,i,parameter,name); + } catch (Exception e) { + e.printStackTrace(); + } + return previous; + }) .setName(name); return processedCSG; } From 217787416f993e729d243c3c9a28ffca25464db3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 12 Oct 2024 14:05:30 -0400 Subject: [PATCH 143/635] Loading the AddFromFile using the parametrics instead of a field in the object --- .../scripting/ScriptingEngine.java | 163 +++++++++--------- .../bowlerstudio/scripting/StlLoader.java | 2 +- .../scripting/cadoodle/AddFromFile.java | 41 +++-- 3 files changed, 112 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 185fdc7b..9b4182f7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -90,47 +90,51 @@ public class ScriptingEngine {// this subclasses boarder pane for the widgets // sake, because multiple inheritance is TOO // hard for java... private static final int TIME_TO_WAIT_BETWEEN_GIT_PULL = 100000; + /** * */ public static void flatten(ArrayList flat, Object o) { - if(CSG.class.isInstance(o)) - flat.add((CSG)o); - if(List.class.isInstance(o)) { - for(Object ob:(List)o) { - flatten(flat,ob); + if (CSG.class.isInstance(o)) + flat.add((CSG) o); + if (List.class.isInstance(o)) { + for (Object ob : (List) o) { + flatten(flat, ob); } } - + } - public static void flatenInterna(Object o, Class type,ArrayList flattened){ - if(type.isInstance(o)) - flattened.add((T)o); - if(List.class.isInstance(o)) { - for(Object ob:(List)o) { - flatenInterna(o,type,flattened); + + public static void flatenInterna(Object o, Class type, ArrayList flattened) { + if (type.isInstance(o)) + flattened.add((T) o); + else if (List.class.isInstance(o)) { + for (Object ob : (List) o) { + flatenInterna(ob, type, flattened); } - } - if(Map.class.isInstance(o)) { - Map m=(Map)o; - for(Object key:m.keySet()) { - flatenInterna(m.get(key),type,flattened); - flatenInterna(key,type,flattened); + } else if (Map.class.isInstance(o)) { + Map m = (Map) o; + for (Object key : m.keySet()) { + flatenInterna(m.get(key), type, flattened); + flatenInterna(key, type, flattened); } } } - public static List flaten(String git,String file, Class type, ArrayList args) throws Exception{ + + public static List flaten(String git, String file, Class type, ArrayList args) throws Exception { ArrayList flattened = new ArrayList(); - Object o =gitScriptRun(git, file,args); - flatenInterna(o,type,flattened); + Object o = gitScriptRun(git, file, args); + flatenInterna(o, type, flattened); return flattened; } - public static List flaten(File f, Class type, ArrayList args) throws Exception{ + + public static List flaten(File f, Class type, ArrayList args) throws Exception { ArrayList flattened = new ArrayList(); - Object o =inlineFileScriptRun(f, args); - flatenInterna(o,type,flattened); + Object o = inlineFileScriptRun(f, args); + flatenInterna(o, type, flattened); return flattened; } + private static final ArrayList logListeners = new ArrayList<>(); private static boolean printProgress = true; @@ -148,9 +152,8 @@ public static List flaten(File f, Class type, ArrayList args) "com.neuronrobotics.bowlerstudio.scripting", "com.neuronrobotics.bowlerstudio.tabs", "com.neuronrobotics.bowlerstudio.physics", "com.neuronrobotics.bowlerstudio.physics", "com.neuronrobotics.bowlerstudio.vitamins", "com.neuronrobotics.bowlerstudio.creature", - "com.neuronrobotics.bowlerstudio.threed","com.neuronrobotics.sdk.util.ThreadUtil", - "eu.mihosoft.vrl.v3d.Transform", - "com.neuronrobotics.bowlerstudio.vitamins.Vitamins" }; + "com.neuronrobotics.bowlerstudio.threed", "com.neuronrobotics.sdk.util.ThreadUtil", + "eu.mihosoft.vrl.v3d.Transform", "com.neuronrobotics.bowlerstudio.vitamins.Vitamins" }; private static HashMap filesRun = new HashMap<>(); @@ -173,7 +176,7 @@ public static List flaten(File f, Class type, ArrayList args) static { PasswordManager.hasNetwork(); - + addScriptingLanguage(new StlLoader()); addScriptingLanguage(new ClojureHelper()); addScriptingLanguage(new GroovyHelper()); addScriptingLanguage(new JythonHelper()); @@ -310,7 +313,8 @@ public void update(int completed) { } String str = format + "% " + stage + " " + reponame + " " + tasks + " of task " + type; if (timeofLastUpdate + 500 < System.currentTimeMillis()) { - if(printProgress)System.out.println(str); + if (printProgress) + System.out.println(str); timeofLastUpdate = System.currentTimeMillis(); } // System.err.println(str); @@ -333,7 +337,8 @@ public boolean isCancelled() { @Override public void endTask() { String string = "100% " + stage + " " + reponame + " " + type; - if(printProgress)System.out.println(string); + if (printProgress) + System.out.println(string); for (GitLogProgressMonitor l : logListeners) { l.onUpdate(string, e); } @@ -373,11 +378,11 @@ public static boolean isUrlAlreadyOpen(String URL) { if (URL == null) return false; Object[] keySet; - synchronized(gitOpenTimeout) { - keySet = gitOpenTimeout.keySet().toArray(); + synchronized (gitOpenTimeout) { + keySet = gitOpenTimeout.keySet().toArray(); } for (int i = 0; i < keySet.length; i++) { - Git g = (Git)keySet[i]; + Git g = (Git) keySet[i]; GitTimeoutThread t = gitOpenTimeout.get(g); if (t.ref.toLowerCase().contentEquals(URL.toLowerCase())) { // t.getException().printStackTrace(System.err); @@ -397,40 +402,40 @@ public static boolean isUrlAlreadyOpen(String URL) { public static Git openGit(Repository localRepo) { try { - Object[] keySet; - synchronized(gitOpenTimeout) { - keySet = gitOpenTimeout.keySet().toArray(); - } - for (int j = 0; j < keySet.length; j++) { - Object gO = keySet[j]; - Git g=(Git)gO; - if (g.getRepository().getDirectory().getAbsolutePath() - .contentEquals(localRepo.getDirectory().getAbsolutePath())) { - GitTimeoutThread t = gitOpenTimeout.get(g); - int i = 0; - while (gitOpenTimeout.containsKey(g)) { + Object[] keySet; + synchronized (gitOpenTimeout) { + keySet = gitOpenTimeout.keySet().toArray(); + } + for (int j = 0; j < keySet.length; j++) { + Object gO = keySet[j]; + Git g = (Git) gO; + if (g.getRepository().getDirectory().getAbsolutePath() + .contentEquals(localRepo.getDirectory().getAbsolutePath())) { + GitTimeoutThread t = gitOpenTimeout.get(g); + int i = 0; + while (gitOpenTimeout.containsKey(g)) { - System.out.println( - "Git is locked by other process, blocking " + localRepo.getDirectory().getAbsolutePath()); - System.out.println("Git locked " + t.ref); - if (i > 3) { - t.getException().printStackTrace(System.out); - System.out.println("Blocking process: "); + System.out.println("Git is locked by other process, blocking " + + localRepo.getDirectory().getAbsolutePath()); + System.out.println("Git locked " + t.ref); + if (i > 3) { + t.getException().printStackTrace(System.out); + System.out.println("Blocking process: "); - new Exception().printStackTrace(System.out); + new Exception().printStackTrace(System.out); + } + i++; + ThreadUtil.wait(1000); } - i++; - ThreadUtil.wait(1000); + break; } - break; } - } - Git git = new Git(localRepo); + Git git = new Git(localRepo); - gitOpenTimeout.put(git, makeTimeoutThread(git)); - return git; - }catch(Throwable t) { + gitOpenTimeout.put(git, makeTimeoutThread(git)); + return git; + } catch (Throwable t) { new IssueReportingExceptionHandler().except(t); throw new RuntimeException(t); @@ -594,7 +599,7 @@ public static void logout() throws IOException { } public static GitHub setupAnyonmous() throws IOException { - //ScriptingEngine.setAutoupdate(false); + // ScriptingEngine.setAutoupdate(false); return PasswordManager.setupAnyonmous(); } @@ -885,10 +890,10 @@ public static void commit(String id, String branch, String FileName, String cont @SuppressWarnings("deprecation") public static void commit(String id, String branch, String FileName, String content, String commitMessage, boolean flagNewFile, Git gitRef) throws Exception { - if(content !=null) - if("Binary File".contentEquals(content)){ - content=null; - } + if (content != null) + if ("Binary File".contentEquals(content)) { + content = null; + } if (PasswordManager.getUsername() == null) login(); if (!hasNetwork()) @@ -961,9 +966,9 @@ public static void commit(String id, String branch, String FileName, String cont public static void pushCodeToGit(String remoteURI, String branch, String FileName, String content, String commitMessage, boolean flagNewFile) throws Exception { waitForRepo(remoteURI, "push"); - if(content!=null) - if("Binary File".contentEquals(content)){ - content=null; + if (content != null) + if ("Binary File".contentEquals(content)) { + content = null; } commit(remoteURI, branch, FileName, content, commitMessage, flagNewFile); if (PasswordManager.getUsername() == null) @@ -1751,7 +1756,7 @@ public static File cloneRepo(String remoteURI, String branch) { } catch (Exception e) { try { // try the checkout with no branch specified - return cloneRepo(remoteURI,null); + return cloneRepo(remoteURI, null); } catch (Exception ex) { throw new RuntimeException(e); } @@ -1801,7 +1806,7 @@ public static Git locateGit(File f) throws IOException { } } - throw new RuntimeException("File "+f+" is not in a git repository"); + throw new RuntimeException("File " + f + " is not in a git repository"); } public static String getText(URL website) throws Exception { @@ -2419,22 +2424,22 @@ public static boolean isPrintProgress() { public static void setPrintProgress(boolean printProgress) { ScriptingEngine.printProgress = printProgress; } - - public static void ignore(String url,String filepattern) throws Exception { + + public static void ignore(String url, String filepattern) throws Exception { File ignorefile = fileFromGit(url, ".gitignore"); - String contents=""; - if(ignorefile.exists()) { + String contents = ""; + if (ignorefile.exists()) { BufferedReader reader; try { reader = new BufferedReader(new FileReader(ignorefile)); String line = reader.readLine(); while (line != null) { - if(line.contains(filepattern)) { - System.out.println(""+filepattern+" exists in "+ignorefile.getAbsolutePath()); + if (line.contains(filepattern)) { + System.out.println("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); reader.close(); return; } - contents+=line+"\n"; + contents += line + "\n"; // read next line line = reader.readLine(); } @@ -2443,8 +2448,8 @@ public static void ignore(String url,String filepattern) throws Exception { e.printStackTrace(); } } - contents+=filepattern; - pushCodeToGit(url, null, ".gitignore", contents, "Adding ignore for "+filepattern); + contents += filepattern; + pushCodeToGit(url, null, ".gitignore", contents, "Adding ignore for " + filepattern); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java index 39f9216f..84fc5bf0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java @@ -42,7 +42,7 @@ public String getDefaultContents() { @Override public ArrayList getFileExtenetion() { // TODO Auto-generated method stub - return new ArrayList<>(Arrays.asList("stl")); + return new ArrayList<>(Arrays.asList("stl","STL","Stl")); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 02242bcd..28f5b55c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -16,15 +16,15 @@ import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private String fileLocation=null; + @Expose (serialize = true, deserialize = true) private String name=null; @Expose(serialize = true, deserialize = true) private TransformNR location = null; - + private ArrayList options = new ArrayList(); + private StringParameter parameter=null; public AddFromFile set(File source) { - fileLocation=source.getAbsolutePath(); + getParameter().setStrValue(source.getAbsolutePath()); return this; } @@ -41,19 +41,17 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); if(getName()==null) { - setName(RandomStringFactory.generateRandomString()); + } try { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); - ArrayList options = new ArrayList(); - StringParameter parameter = new StringParameter(name+"_CaDoodle_FileName", fileLocation, options); ArrayList collect = new ArrayList<>(); - List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); - + List flattenedCSGs = ScriptingEngine.flaten(new File(getParameter().getStrValue()), CSG.class, null); + System.out.println("Initial Loading "+getParameter().getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); - CSG processedCSG = processGiven(csg,i,parameter,getOrderedName()); + CSG processedCSG = processGiven(csg,i,getParameter(),getOrderedName()); collect.add(processedCSG); } @@ -68,14 +66,16 @@ public List process(List incoming) { private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { CSG processedCSG = csg - .moveToCenterX() - .moveToCenterY() - .toZMin() +// .moveToCenterX() +// .moveToCenterY() +// .toZMin() .transformed(TransformFactory.nrToCSG(getLocation())) .syncProperties(csg) .setRegenerate(previous -> { try { - List flattenedCSGs = ScriptingEngine.flaten(new File(parameter.getStrValue()), CSG.class, null); + String fileLocation=parameter.getStrValue(); + System.out.println("Regenerating "+fileLocation); + List flattenedCSGs = ScriptingEngine.flaten(new File(fileLocation), CSG.class, null); CSG csg1 = flattenedCSGs.get(i); return processGiven(csg1,i,parameter,name); } catch (Exception e) { @@ -99,6 +99,9 @@ public AddFromFile setLocation(TransformNR location) { } public String getName() { + if(name==null) { + setName(RandomStringFactory.generateRandomString()); + } return name; } @@ -106,4 +109,14 @@ public void setName(String name) { this.name = name; } + public StringParameter getParameter() { + if(parameter==null) + setParameter(new StringParameter(getName()+"_CaDoodle_File_Location", "UnKnown", options)); + return parameter; + } + + public void setParameter(StringParameter parameter) { + this.parameter = parameter; + } + } From e2b8b5ed6b76c220b3573b3d27793a1737f7bb8e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 08:46:31 -0400 Subject: [PATCH 144/635] Loading SVG is more stable --- build.gradle | 2 +- .../bowlerstudio/scripting/SvgLoader.java | 13 +++++++++++-- .../scripting/cadoodle/AddFromFile.java | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 6ed5360f..48c2dd99 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.10' + api 'com.neuronrobotics:JavaCad:1.6.11' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index ab5e0256..376982dd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.List; +import com.neuronrobotics.bowlerstudio.util.GeometrySimplification; + import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.svg.SVGExporter; @@ -16,8 +18,15 @@ public class SvgLoader implements IScriptingLanguage { @Override public Object inlineScriptRun(File code, ArrayList args) throws Exception { - SVGLoad s = new SVGLoad(code.toURI()); - return run(s); + try { + SVGLoad s = new SVGLoad(code.toURI()); + return run(s); + }catch(Exception e) { + System.err.println("SVG had error, attempting to fix "+code.getAbsolutePath()); + File tmp=GeometrySimplification.simplifySVG(code); + SVGLoad s = new SVGLoad(tmp.toURI()); + return run(s); + } } @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 28f5b55c..ce7dce31 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -71,6 +71,7 @@ private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { // .toZMin() .transformed(TransformFactory.nrToCSG(getLocation())) .syncProperties(csg) + .setParameter(parameter) .setRegenerate(previous -> { try { String fileLocation=parameter.getStrValue(); @@ -111,7 +112,7 @@ public void setName(String name) { public StringParameter getParameter() { if(parameter==null) - setParameter(new StringParameter(getName()+"_CaDoodle_File_Location", "UnKnown", options)); + setParameter(new StringParameter(getName()+"_CaDoodle_File", "UnKnown", options)); return parameter; } From 27239093aacd05b4d1bc1ca784ff35100d2ecd65 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 12:09:26 -0400 Subject: [PATCH 145/635] updating javacad --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 48c2dd99..b2be5a08 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.6.11' + api 'com.neuronrobotics:JavaCad:1.7.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 18750056aa3d5011084865ff51b908476c393ae9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 13:56:18 -0400 Subject: [PATCH 146/635] add getter for thee file --- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b2be5a08..3b4c7a91 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.7.0' + api 'com.neuronrobotics:JavaCad:1.7.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index ce7dce31..9d909154 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -47,7 +47,7 @@ public List process(List incoming) { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); - List flattenedCSGs = ScriptingEngine.flaten(new File(getParameter().getStrValue()), CSG.class, null); + List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); System.out.println("Initial Loading "+getParameter().getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); @@ -64,6 +64,10 @@ public List process(List incoming) { return back; } + public File getFile() { + return new File(getParameter().getStrValue()); + } + private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { CSG processedCSG = csg // .moveToCenterX() From f22e1b675a01bf65dfa99adc91cca5bfbe787587 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 14:03:49 -0400 Subject: [PATCH 147/635] make getting a file availible to all loaders --- .../scripting/cadoodle/AbstractAddFrom.java | 2 ++ .../scripting/cadoodle/AddFromScript.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 9972a346..8464f1ee 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -1,5 +1,6 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.io.File; import java.util.HashSet; import com.google.gson.annotations.Expose; @@ -29,4 +30,5 @@ public String getOrderedName() { namesAdded.add(result); return result; } + public abstract File getFile(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 0e060042..92cb89e3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -1,5 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -7,6 +9,8 @@ import java.util.Random; import java.util.stream.Collectors; +import org.eclipse.jgit.api.errors.GitAPIException; + import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; @@ -92,4 +96,16 @@ public void setName(String name) { this.name = name; } + @Override + public File getFile() { + // TODO Auto-generated method stub + try { + return ScriptingEngine.fileFromGit(gitULR, fileRel); + } catch (GitAPIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + } From a7d5b3913650bf0164fa99e3cf2b660a6934b2fd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 14:51:29 -0400 Subject: [PATCH 148/635] Afd a getter and setter for regeenerate --- .../scripting/cadoodle/CaDoodleFile.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 422b15f0..4059c3a4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -139,7 +139,7 @@ public void initialize() { public Thread regenerateFrom(ICaDoodleOpperation source) { if(initializing) return null; - if (regenerating || isOperationRunning()) { + if (isRegenerating() || isOperationRunning()) { System.out.println("Opperation is running, ignoring regen"); return opperationRunner; } @@ -151,7 +151,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } opperationRunner = new Thread(() -> { opperationRunner.setName("Regeneration Thread"); - regenerating = true; + setRegenerating(true); // System.out.println("Regenerating Object from "+source.getType()); int opIndex = 0; for (int i = 0; i < size; i++) { @@ -175,7 +175,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setCurrentIndex(endIndex); updateCurrentFromCache(); } - regenerating = false; + setRegenerating(false); fireSaveSuggestion(); opperationRunner = null; }); @@ -534,6 +534,14 @@ public long getTimeCreated() { return timeCreated; } + public boolean isRegenerating() { + return regenerating; + } + + private void setRegenerating(boolean regenerating) { + this.regenerating = regenerating; + } + } From ffb335536ccc99ec19e95c7da92c944bae178567 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 20:45:16 -0400 Subject: [PATCH 149/635] make the export process public --- src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index fa75c956..7d15cb5f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -379,7 +379,7 @@ private static void finish(long startTime) { System.exit(0); } - private static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { + public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { processUIOpening(ret); if(baseWorkspaceFile!=null) System.out.println("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); From 0360f2f2699b03e6facfbd306a78af36031fdcf0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 14 Oct 2024 21:22:31 -0400 Subject: [PATCH 150/635] Make the export use the provided directory --- .../com/neuronrobotics/bowlerstudio/BowlerKernel.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 7d15cb5f..0dd6abd8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -243,7 +243,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } } if (startLoadingScripts) { - processReturnedObjectsStart(ret, null); + processReturnedObjectsStart(ret, new File(".")); finish(startTime); return; } @@ -391,8 +391,10 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, } }); + if (baseWorkspaceFile != null) { - File baseDirForFiles = new File("./manufacturing/"); + + File baseDirForFiles = new File(baseWorkspaceFile.getAbsolutePath()+"/manufacturing/"); if (baseDirForFiles.exists()) { // baseDirForFiles.mkdir(); File bomCSV = new File( @@ -422,6 +424,8 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, e.printStackTrace(); } } + }else { + baseDirForFiles.mkdirs(); } } ArrayList csgBits = new ArrayList<>(); @@ -435,7 +439,7 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, else { System.out.println("Exporting files without print bed"); } - new CadFileExporter().generateManufacturingParts(csgBits, new File(".")); + new CadFileExporter().generateManufacturingParts(csgBits, baseWorkspaceFile); } catch (Throwable t) { t.printStackTrace(); fail(); From 826409845f3df14d9815cdedd07ac5117a5086c6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 15 Oct 2024 13:26:11 -0400 Subject: [PATCH 151/635] Adding freecad and making the blender file be a composite file like SVG --- .../creature/CadFileExporter.java | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index a3520d40..6549af3c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -10,6 +10,7 @@ import org.apache.commons.io.FilenameUtils; import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader; +import com.neuronrobotics.bowlerstudio.scripting.FreecadLoader; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; @@ -82,7 +83,11 @@ public ArrayList generateManufacturingParts(List totalAssembly , File } int index=0; ArrayList svgParts = new ArrayList<>(); + ArrayList blendParts = new ArrayList<>(); + ArrayList freecadParts = new ArrayList<>(); String svgName =null; + String blendName=null; + String freecadName=null; String nameBase =""; for(CSG part: totalAssembly){ String name = part.getName(); @@ -109,10 +114,6 @@ public ArrayList generateManufacturingParts(List totalAssembly , File allCadStl.add(makeObj(nameBase,manufactured));// ui.setCsg(manufactured , null); } - if(format.toLowerCase().contains("blend")){ - allCadStl.add(makeBlender(nameBase,manufactured));// - ui.setCsg(manufactured , null); - } if(format.toLowerCase().contains("stl")){ allCadStl.add(makeStl(nameBase,manufactured));// default to stl ui.setCsg(manufactured , null); @@ -124,7 +125,22 @@ public ArrayList generateManufacturingParts(List totalAssembly , File svgParts.add(manufactured); ui.setAllCSG(svgParts , null); } - + if(format.toLowerCase().contains("blend")){ + //allCadStl.add(makeBlender(nameBase,manufactured));// + ui.setCsg(manufactured , null); + if(blendName==null){ + blendName =part.toString(); + } + blendParts.add(manufactured); + } + if(format.toLowerCase().contains("freecad")){ + //allCadStl.add(makeBlender(nameBase,manufactured));// + ui.setCsg(manufactured , null); + if(freecadName==null){ + freecadName =part.toString(); + } + freecadParts.add(manufactured); + } } } @@ -132,9 +148,22 @@ public ArrayList generateManufacturingParts(List totalAssembly , File if(svgParts.size()>0){ allCadStl.add(makeSvg(nameBase,svgParts));// default to stl } - + if(blendParts.size()>0){ + allCadStl.add(makeBlender(nameBase,blendParts));// default to stl + } + if(freecadParts.size()>0){ + allCadStl.add(makeFreecad(nameBase,freecadParts));// default to stl + } return allCadStl; } + private File makeFreecad(String nameBase,List current ) throws IOException{ + File blend = new File(nameBase + ".blend"); + System.out.println("Writing "+blend.getAbsolutePath()); + for(CSG tmp:current) + FreecadLoader.addCSGToFreeCAD( blend,tmp); + return blend; + } + private File makeStl(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".stl"); @@ -150,10 +179,11 @@ private File makeObj(String nameBase,CSG tmp ) throws IOException{ return stl; } - private File makeBlender(String nameBase,CSG tmp ) throws IOException{ + private File makeBlender(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".blend"); System.out.println("Writing "+blend.getAbsolutePath()); - BlenderLoader.toBlenderFile(tmp, blend); + for(CSG tmp:current) + BlenderLoader.toBlenderFile(tmp, blend); return blend; } From 653a5a7aca2688c4af4d5925d210270ca7a16b17 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 15 Oct 2024 13:40:15 -0400 Subject: [PATCH 152/635] correcting the file extension for the freecad files --- .../neuronrobotics/bowlerstudio/creature/CadFileExporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 6549af3c..02bb5480 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -157,7 +157,7 @@ public ArrayList generateManufacturingParts(List totalAssembly , File return allCadStl; } private File makeFreecad(String nameBase,List current ) throws IOException{ - File blend = new File(nameBase + ".blend"); + File blend = new File(nameBase + ".FCStd"); System.out.println("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) FreecadLoader.addCSGToFreeCAD( blend,tmp); From bbe65c45b9c2765438127c6f0b0481c53faf18e9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Oct 2024 10:54:10 -0400 Subject: [PATCH 153/635] Copy files into the working directory before loading --- .../scripting/cadoodle/AddFromFile.java | 121 ++++++++++++------ .../scripting/cadoodle/CaDoodleFile.java | 71 +++++----- 2 files changed, 120 insertions(+), 72 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 9d909154..592256df 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -1,6 +1,10 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -17,12 +21,13 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private String name=null; + @Expose(serialize = true, deserialize = true) + private String name = null; @Expose(serialize = true, deserialize = true) private TransformNR location = null; private ArrayList options = new ArrayList(); - private StringParameter parameter=null; + private StringParameter parameter = null; + public AddFromFile set(File source) { getParameter().setStrValue(source.getAbsolutePath()); return this; @@ -32,31 +37,28 @@ public AddFromFile set(File source) { public String getType() { return "Add Object"; } - - @Override public List process(List incoming) { - nameIndex=0; + nameIndex = 0; ArrayList back = new ArrayList(); back.addAll(incoming); - if(getName()==null) { - + if (getName() == null) { + } try { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); - System.out.println("Initial Loading "+getParameter().getStrValue()); + System.out.println("Initial Loading " + getParameter().getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { - CSG csg = flattenedCSGs.get(i); - CSG processedCSG = processGiven(csg,i,getParameter(),getOrderedName()); - - collect.add(processedCSG); + CSG csg = flattenedCSGs.get(i); + CSG processedCSG = processGiven(csg, i, getParameter(), getOrderedName()); + + collect.add(processedCSG); } - back.addAll(collect - ); + back.addAll(collect); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -64,37 +66,80 @@ public List process(List incoming) { return back; } + public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, String newBaseName) + throws IOException { + if (!sourceFile.exists()) { + throw new IOException("Source file does not exist: " + sourceFile.getAbsolutePath()); + } + + if (!targetDirectory.exists()) { + if (!targetDirectory.mkdirs()) { + throw new IOException("Failed to create target directory: " + targetDirectory.getAbsolutePath()); + } + } + + String fileName = sourceFile.getName(); + String fileExtension = ""; + int dotIndex = fileName.lastIndexOf('.'); + if (dotIndex > 0 && dotIndex < fileName.length() - 1) { + fileExtension = fileName.substring(dotIndex); + } + + String newFileName = newBaseName + fileExtension; + File targetFile = new File(targetDirectory, newFileName); + + Path sourcePath = sourceFile.toPath(); + Path targetPath = targetFile.toPath(); + + Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); + return targetFile; + } + public File getFile() { - return new File(getParameter().getStrValue()); + StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); + File file = new File(getParameter().getStrValue()); + String parentIncoming = file.getParentFile().getAbsolutePath(); + File parentFile = new File(loc.getStrValue()).getParentFile(); + String source = parentFile.getAbsolutePath(); + if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase())) { + File copied; + try { + copied = copyFileToNewDirectory(file,parentFile,getName()); + getParameter().setStrValue(copied.getAbsolutePath()); + return copied; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return file; } - private CSG processGiven(CSG csg,int i,StringParameter parameter,String name) { + private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() // .toZMin() - .transformed(TransformFactory.nrToCSG(getLocation())) - .syncProperties(csg) - .setParameter(parameter) - .setRegenerate(previous -> { - try { - String fileLocation=parameter.getStrValue(); - System.out.println("Regenerating "+fileLocation); - List flattenedCSGs = ScriptingEngine.flaten(new File(fileLocation), CSG.class, null); - CSG csg1 = flattenedCSGs.get(i); - return processGiven(csg1,i,parameter,name); - } catch (Exception e) { - e.printStackTrace(); - } - return previous; - }) - .setName(name); + .transformed(TransformFactory.nrToCSG(getLocation())).syncProperties(csg).setParameter(parameter) + .setRegenerate(previous -> { + try { + File file = getFile(); + String fileLocation = file.getAbsolutePath(); + System.out.println("Regenerating " + fileLocation); + List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); + CSG csg1 = flattenedCSGs.get(i); + return processGiven(csg1, i, parameter, name); + } catch (Exception e) { + e.printStackTrace(); + } + return previous; + }).setName(name); return processedCSG; } public TransformNR getLocation() { - if(location==null) - location=new TransformNR(); + if (location == null) + location = new TransformNR(); return location; } @@ -104,7 +149,7 @@ public AddFromFile setLocation(TransformNR location) { } public String getName() { - if(name==null) { + if (name == null) { setName(RandomStringFactory.generateRandomString()); } return name; @@ -115,8 +160,8 @@ public void setName(String name) { } public StringParameter getParameter() { - if(parameter==null) - setParameter(new StringParameter(getName()+"_CaDoodle_File", "UnKnown", options)); + if (parameter == null) + setParameter(new StringParameter(getName() + "_CaDoodle_File", "UnKnown", options)); return parameter; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4059c3a4..1102adbb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -30,6 +30,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import javafx.embed.swing.SwingFXUtils; import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; @@ -51,8 +52,7 @@ public class CaDoodleFile { // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); @Expose(serialize = false, deserialize = false) - private - double percentInitialized=0; + private double percentInitialized = 0; @Expose(serialize = false, deserialize = false) private HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { @@ -66,21 +66,21 @@ public class CaDoodleFile { private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; - + public void close() { - for(ICaDoodleOpperation op:cache.keySet()) { + for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); } cache.clear(); - cache=null; + cache = null; clearListeners(); - listeners=null; + listeners = null; toProcess.clear(); - toProcess=null; - img=null; - if(opperationRunner!=null) + toProcess = null; + img = null; + if (opperationRunner != null) opperationRunner.interrupt(); - opperationRunner=null; + opperationRunner = null; } public CaDoodleFile clearListeners() { @@ -101,19 +101,24 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { } public void initialize() { - if(initializing) + if (initializing) throw new RuntimeException("Can not initialize while initializing."); - initializing=true; + initializing = true; if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); + if (selfInternal != null) { + StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), + new ArrayList()); + loc.setStrValue(selfInternal.getAbsolutePath()); + } } int indexStarting = getCurrentIndex(); setCurrentIndex(0); setPercentInitialized(0); for (int i = 0; i < opperations.size(); i++) { ICaDoodleOpperation op = opperations.get(i); - setPercentInitialized(((double)i)/(double)opperations.size()); + setPercentInitialized(((double) i) / (double) opperations.size()); try { process(op); } catch (Throwable t) { @@ -133,11 +138,11 @@ public void initialize() { e.printStackTrace(); } } - initializing=false; + initializing = false; } public Thread regenerateFrom(ICaDoodleOpperation source) { - if(initializing) + if (initializing) return null; if (isRegenerating() || isOperationRunning()) { System.out.println("Opperation is running, ignoring regen"); @@ -162,14 +167,14 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } } setCurrentIndex(opIndex); - + for (; getCurrentIndex() < size;) { setCurrentIndex(getCurrentIndex() + 1); // System.out.println("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); storeResultInCache(op, process); - setCurrentState(op,process); + setCurrentState(op, process); } if (getCurrentIndex() != endIndex) { setCurrentIndex(endIndex); @@ -193,7 +198,7 @@ public Thread regenerateCurrent() { ICaDoodleOpperation op = getCurrentOpperation(); List process = op.process(getPreviouState()); storeResultInCache(op, process); - setCurrentState(op,process); + setCurrentState(op, process); fireSaveSuggestion(); opperationRunner = null; }); @@ -206,7 +211,7 @@ private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); setCurrentIndex(getCurrentIndex() + 1); - setCurrentState(op,process); + setCurrentState(op, process); } public boolean isOperationRunning() { @@ -282,14 +287,14 @@ public boolean isBackAvailible() { private void updateCurrentFromCache() { ICaDoodleOpperation key = getCurrentOpperation(); - if(key==null) + if (key == null) return; System.out.println("Current opperation results: " + key.getType()); - setCurrentState(key,getCurrentState()); + setCurrentState(key, getCurrentState()); } public ICaDoodleOpperation getCurrentOpperation() { - if(getCurrentIndex()==0) + if (getCurrentIndex() == 0) return null; return getOpperations().get(getCurrentIndex() - 1); } @@ -326,8 +331,8 @@ public List getCurrentState() { if (getCurrentIndex() == 0) return new ArrayList(); List list = cache.get(getCurrentOpperation()); - if(list==null) - list= new ArrayList(); + if (list == null) + list = new ArrayList(); return list; } @@ -351,7 +356,7 @@ public List getPreviouState() { return cache.get(getOpperations().get(getCurrentIndex() - 2)); } - private void setCurrentState(ICaDoodleOpperation op,List currentState) { + private void setCurrentState(ICaDoodleOpperation op, List currentState) { for (ICaDoodleStateUpdate l : listeners) { try { l.onUpdate(currentState, op, this); @@ -412,12 +417,12 @@ public WritableImage loadImageFromFile() { try { File parent = selfInternal.getAbsoluteFile().getParentFile(); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); - if(image.exists()) { + if (image.exists()) { BufferedImage bufferedImage = ImageIO.read(image); if (bufferedImage != null) { img = SwingFXUtils.toFXImage(bufferedImage, null); } - }else { + } else { loadingImageFromUIThread(); } } catch (IOException e) { @@ -447,8 +452,8 @@ public static CaDoodleFile fromJsonString(String content) throws Exception { public static CaDoodleFile fromJsonString(String content, ICaDoodleStateUpdate listener, File self, boolean initialize) throws Exception { CaDoodleFile file = gson.fromJson(content, TT_CaDoodleFile); - if(file==null) { - file=new CaDoodleFile(); + if (file == null) { + file = new CaDoodleFile(); file.setProjectName(RandomStringFactory.getNextRandomName()); file.getTimeCreated(); } @@ -527,9 +532,9 @@ public void setPercentInitialized(double percentInitialized) { this.percentInitialized = percentInitialized; } - public long getTimeCreated() { - if(timeCreated<0) { - timeCreated=System.currentTimeMillis(); + public long getTimeCreated() { + if (timeCreated < 0) { + timeCreated = System.currentTimeMillis(); } return timeCreated; } @@ -542,6 +547,4 @@ private void setRegenerating(boolean regenerating) { this.regenerating = regenerating; } - - } From c7f34393054d64bb032039bcf2042c65c37c5312 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Oct 2024 16:32:48 -0400 Subject: [PATCH 154/635] Changing the AddFromFile opperation to always use the copied in version of the file --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 592256df..f8d80bb5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -13,6 +13,7 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -101,17 +102,18 @@ public File getFile() { String parentIncoming = file.getParentFile().getAbsolutePath(); File parentFile = new File(loc.getStrValue()).getParentFile(); String source = parentFile.getAbsolutePath(); - if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase())) { + if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase()) && file.exists()) { File copied; try { copied = copyFileToNewDirectory(file,parentFile,getName()); getParameter().setStrValue(copied.getAbsolutePath()); - return copied; + file= copied; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } + file = new File(source+DownloadManager.delim()+file.getName()); return file; } From 08efd618009a83c4813b26d65ff2c26e306190fe Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Oct 2024 16:34:18 -0400 Subject: [PATCH 155/635] update the datebase with the new file location --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index f8d80bb5..dbb2f6c5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -106,7 +106,6 @@ public File getFile() { File copied; try { copied = copyFileToNewDirectory(file,parentFile,getName()); - getParameter().setStrValue(copied.getAbsolutePath()); file= copied; } catch (IOException e) { // TODO Auto-generated catch block @@ -114,6 +113,7 @@ public File getFile() { } } file = new File(source+DownloadManager.delim()+file.getName()); + getParameter().setStrValue(file.getAbsolutePath()); return file; } From d6f4a0d317d6e29a133fa7e083a366823bfe5fc8 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 19 Oct 2024 09:12:46 -0400 Subject: [PATCH 156/635] more elaborate MacOS temp structure to avoid the iCloud errors --- .../scripting/ScriptingEngine.java | 75 +++++++++++++++---- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 9b4182f7..80eb589f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -64,6 +64,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.text.DecimalFormat; import java.util.ArrayList; @@ -173,6 +174,10 @@ public static List flaten(File f, Class type, ArrayList args) // static IssueReportingExceptionHandler exp = new // IssueReportingExceptionHandler(); static HashMap gitOpenTimeout = new HashMap<>(); + + private static String delim; + + private static String appName="BowlerLauncher"; static { PasswordManager.hasNetwork(); @@ -552,24 +557,60 @@ public static void removeIGithubLoginListener(IGithubLoginListener l) { public static File getWorkspace() { if (workspace == null) { - String relative = FileSystemView.getFileSystemView().getDefaultDirectory().getPath(); - // https://github.com/CommonWealthRobotics/BowlerStudio/issues/378 - if (OSUtil.isOSX() || OSUtil.isLinux()) - if (!relative.endsWith("Documents")) { - relative = relative + "/Documents"; - } - if (OSUtil.isWindows()) { - if (!relative.endsWith("Documents")) { - relative = relative + "\\Documents"; - } - } - - File file = new File(relative + "/bowler-workspace/"); + File relative = getWorkingDirectory(); + File file = new File(relative.getAbsolutePath() + delim+ "bowler-workspace"+delim); file.mkdirs(); setWorkspace(file); } return workspace; } + public static void createSymlinkInDocuments(File appDataDir) throws IOException { + String userHome = System.getProperty("user.home"); + Path documentsDir = Paths.get(userHome, "Documents"); + Path symlinkPath = documentsDir.resolve(appDataDir.getName()); + + // Delete existing symlink if it exists + if (Files.exists(symlinkPath)) { + Files.delete(symlinkPath); + } + + // Create the symlink + Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); + System.out.println("Symlink created: " + symlinkPath); + } + public static File getWorkingDirectory() { + String relative = Paths.get(System.getProperty("user.home"), "Documents").toString(); + if(OSUtil.isOSX()) { + File appDataDir = new File(System.getProperty("user.home") + "/Library/Application Support/" + appName); + + if (!appDataDir.exists()) { + if (!appDataDir.mkdirs()) { + throw new RuntimeException("Failed to create app data directory"); + } + } + relative=appDataDir.getAbsolutePath(); + try { + createSymlinkInDocuments(appDataDir); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + delim = "/"; + if (OSUtil.isLinux()) + if (!relative.endsWith("Documents")) { + relative = relative+ delim+ "Documents"; + } + if (OSUtil.isWindows()) { + delim="\\"; + if (!relative.endsWith("Documents")) { + relative = relative +delim+ "Documents"; + } + } + File file = new File(relative + delim); + file.mkdirs(); + return file; + } public static String getShellType(String name) { for (IScriptingLanguage l : langauges.values()) { @@ -2452,4 +2493,12 @@ public static void ignore(String url, String filepattern) throws Exception { pushCodeToGit(url, null, ".gitignore", contents, "Adding ignore for " + filepattern); } + public static String getAppName() { + return appName; + } + + public static void setAppName(String appName) { + ScriptingEngine.appName = appName; + } + } From 2b0699887dc7cff28559c260238207254ecc7898 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 19 Oct 2024 12:08:35 -0400 Subject: [PATCH 157/635] ensure that the downloaded files report thier status back to the Splash --- .../scripting/DownloadManager.java | 38 +++++++++++++------ .../scripting/cadoodle/AddFromFile.java | 24 +++++++----- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index aeeb99a3..ca366639 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -95,6 +95,7 @@ public boolean get(String name, String url) { return true; } }; + private static GitLogProgressMonitor psudoSplash; public static Thread run(IExternalEditor editor, File dir, PrintStream out, List finalCommand) { return run(new HashMap(), editor, dir, out, finalCommand); @@ -275,10 +276,16 @@ public static Map getEnvironment(String exeType) { } public static File getRunExecutable(String exeType, IExternalEditor editor) { + while(!getExecutable(exeType, editor, "executable").exists()) { + new RuntimeException("Download or extraction failed, retrying").printStackTrace(); + } return getExecutable(exeType, editor, "executable"); } public static File getConfigExecutable(String exeType, IExternalEditor editor) { + while(!getExecutable(exeType, editor, "configExecutable").exists()) { + new RuntimeException("Download or extraction failed, retrying").printStackTrace(); + } return getExecutable(exeType, editor, "configExecutable"); } @@ -629,7 +636,7 @@ private static void extractItem(IInArchive inArchive, int index, String outputPa result = inArchive.extractSlow(index, new ISequentialOutStream() { public int write(byte[] data) throws SevenZipException { try { - System.out.println("Inflate 7z .. " + outputFile.getAbsolutePath()); + psudoSplash.onUpdate("Inflate 7z .. " + outputFile.getName(),null); fos.write(data); } catch (IOException e) { throw new SevenZipException("Error writing to file: " + e.getMessage()); @@ -735,12 +742,12 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc Files.createDirectories(outDir); } - try (FileInputStream fis = new FileInputStream(inputFile); - XZCompressorInputStream xzIn = new XZCompressorInputStream(fis); - TarArchiveInputStream tarIn = new TarArchiveInputStream(xzIn)) { - + try { + FileInputStream fis = new FileInputStream(inputFile); + XZCompressorInputStream xzIn = new XZCompressorInputStream(fis); + TarArchiveInputStream tarIn = new TarArchiveInputStream(xzIn); TarArchiveEntry entry; - while ((entry = tarIn.getNextTarEntry()) != null) { + while ((entry = tarIn.getNextEntry()) != null) { Path outPath = outDir.resolve(entry.getName()); if (entry.isSymbolicLink()) { @@ -764,7 +771,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc try (OutputStream out = Files.newOutputStream(outPath)) { byte[] buffer = new byte[1024]; int len; - System.out.println("Inflate Tar XZ " + outPath.toAbsolutePath()); + psudoSplash.onUpdate("Inflate Tar XZ " + outPath.getFileName(),null); while ((len = tarIn.read(buffer)) != -1) { out.write(buffer, 0, len); } @@ -778,6 +785,9 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc } } } + }catch(Throwable ex) { + ex.printStackTrace(); + //new File(inputFile).delete(); } } @@ -887,7 +897,7 @@ public static File download(String version, String downloadJsonURL, long sizeOfJ public void process(double percent) { if (System.currentTimeMillis() - timeSinceePrint > 1000) { timeSinceePrint = System.currentTimeMillis(); - System.out.println("Download "+filename+" percent " + (int) (percent * 100)); + psudoSplash.onUpdate((int) (percent * 100)+" % "+filename ,null); } // if(progress!=null) // Platform.runLater(() -> { @@ -910,16 +920,19 @@ public void process(double percent) { folder.mkdirs(); exe.createNewFile(); - byte dataBuffer[] = new byte[1024]; + byte dataBuffer[] = new byte[1024*1000]; int bytesRead; FileOutputStream fileOutputStream = new FileOutputStream(exe.getAbsoluteFile()); - while ((bytesRead = pis.read(dataBuffer, 0, 1024)) != -1) { + int chunks =0; + while ((bytesRead = pis.read(dataBuffer, 0, dataBuffer.length)) != -1) { fileOutputStream.write(dataBuffer, 0, bytesRead); + //psudoSplash.onUpdate((int) (chunks++)+" Kb " +filename , null); + } fileOutputStream.close(); pis.close(); System.out.println("Finished downloading " + filename); - System.out.println("Download percent " + (int) (1 * 100)); + psudoSplash.onUpdate((int) (1 * 100)+" % " +filename , null); } else { System.out.println("Not downloading, it existst " + filename); } @@ -969,5 +982,8 @@ public static IApprovalForDownload getApproval() { public static void setApproval(IApprovalForDownload approval) { DownloadManager.approval = approval; } + public static void addLogListener(GitLogProgressMonitor psudoSplash) { + DownloadManager.psudoSplash = psudoSplash; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index dbb2f6c5..f585c622 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -99,20 +99,24 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, public File getFile() { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File file = new File(getParameter().getStrValue()); - String parentIncoming = file.getParentFile().getAbsolutePath(); + File parentFileIncoming = file.getParentFile(); File parentFile = new File(loc.getStrValue()).getParentFile(); String source = parentFile.getAbsolutePath(); - if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase()) && file.exists()) { - File copied; - try { - copied = copyFileToNewDirectory(file,parentFile,getName()); - file= copied; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (parentFileIncoming != null) { + String parentIncoming = parentFileIncoming.getAbsolutePath(); + + if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase()) && file.exists()) { + File copied; + try { + copied = copyFileToNewDirectory(file, parentFile, getName()); + file = copied; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } - file = new File(source+DownloadManager.delim()+file.getName()); + file = new File(source + DownloadManager.delim() + file.getName()); getParameter().setStrValue(file.getAbsolutePath()); return file; } From 9ec6b59fb0fa53a561c0fa802a722b6caeda1561 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 20 Oct 2024 09:29:54 -0400 Subject: [PATCH 158/635] Adding a listener to the DownloadMnager that shows a splash while downloading --- .../scripting/DownloadManager.java | 32 +++++++++++++++++-- .../scripting/IDownloadManagerEvents.java | 6 ++++ .../scripting/ScriptingEngine.java | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/IDownloadManagerEvents.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index ca366639..db9cafd2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -73,6 +73,20 @@ public class DownloadManager { private static String bindir = System.getProperty("user.home") + delim()+"bin"+delim()+"BowlerStudioInstall"+delim(); private static int ev = 0; private static String cmd = ""; + private static IDownloadManagerEvents downloadEvents = new IDownloadManagerEvents() { + + @Override + public void startDownload() { + // TODO Auto-generated method stub + + } + + @Override + public void finishDownload() { + // TODO Auto-generated method stub + + } + }; public static String sanitizeString(String s) { if(s.contains(" ")) s=s.replace(' ', '_'); @@ -631,7 +645,7 @@ private static void extractItem(IInArchive inArchive, int index, String outputPa } ExtractOperationResult result; - + downloadEvents.startDownload(); try (FileOutputStream fos = new FileOutputStream(outputFile)) { result = inArchive.extractSlow(index, new ISequentialOutStream() { public int write(byte[] data) throws SevenZipException { @@ -645,7 +659,7 @@ public int write(byte[] data) throws SevenZipException { } }); } - + downloadEvents.finishDownload(); if (result == ExtractOperationResult.OK) { System.out.println("Extracted: " + path); } else { @@ -747,6 +761,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc XZCompressorInputStream xzIn = new XZCompressorInputStream(fis); TarArchiveInputStream tarIn = new TarArchiveInputStream(xzIn); TarArchiveEntry entry; + downloadEvents.startDownload(); while ((entry = tarIn.getNextEntry()) != null) { Path outPath = outDir.resolve(entry.getName()); @@ -786,9 +801,12 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc } } }catch(Throwable ex) { + downloadEvents.finishDownload(); ex.printStackTrace(); + throw ex; //new File(inputFile).delete(); } + downloadEvents.finishDownload(); } public static void untar(File tarFile, String dir) throws Exception { @@ -917,7 +935,7 @@ public void process(double percent) { pis.close(); throw new RuntimeException("No Application insalled"); } - + downloadEvents.startDownload(); folder.mkdirs(); exe.createNewFile(); byte dataBuffer[] = new byte[1024*1000]; @@ -933,6 +951,7 @@ public void process(double percent) { pis.close(); System.out.println("Finished downloading " + filename); psudoSplash.onUpdate((int) (1 * 100)+" % " +filename , null); + downloadEvents.finishDownload(); } else { System.out.println("Not downloading, it existst " + filename); } @@ -985,5 +1004,12 @@ public static void setApproval(IApprovalForDownload approval) { public static void addLogListener(GitLogProgressMonitor psudoSplash) { DownloadManager.psudoSplash = psudoSplash; } + public static IDownloadManagerEvents getDownloadEvents() { + return downloadEvents; + } + public static void setDownloadEvents(IDownloadManagerEvents de) { + if(downloadEvents!=null) + downloadEvents = de; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IDownloadManagerEvents.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IDownloadManagerEvents.java new file mode 100644 index 00000000..eef4d26c --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IDownloadManagerEvents.java @@ -0,0 +1,6 @@ +package com.neuronrobotics.bowlerstudio.scripting; + +public interface IDownloadManagerEvents { + public void startDownload(); + public void finishDownload(); +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 80eb589f..be97a29e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -571,7 +571,7 @@ public static void createSymlinkInDocuments(File appDataDir) throws IOException // Delete existing symlink if it exists if (Files.exists(symlinkPath)) { - Files.delete(symlinkPath); + return; } // Create the symlink From 4c590f951c45cf2aa3cdfaa96f1b8e1d617b912c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 20 Oct 2024 10:34:40 -0400 Subject: [PATCH 159/635] adding the url to the download print --- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index db9cafd2..f1752290 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -930,6 +930,7 @@ public void process(double percent) { if (approval.get(downloadName, downloadJsonURL)) { System.out.println("Start Downloading " + filename); + System.out.println("From "+downloadJsonURL); } else { pis.close(); From ff094e096714e351dbbebffd612e43a681caea29 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 20 Oct 2024 11:31:50 -0400 Subject: [PATCH 160/635] Make the downloader retry only 3 times and check for the installerd application in the provided system path first --- .../scripting/DownloadManager.java | 24 ++++++++++++------- .../bowlerstudio/scripting/FreecadLoader.java | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index f1752290..ebb3795d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -290,17 +290,21 @@ public static Map getEnvironment(String exeType) { } public static File getRunExecutable(String exeType, IExternalEditor editor) { - while(!getExecutable(exeType, editor, "executable").exists()) { - new RuntimeException("Download or extraction failed, retrying").printStackTrace(); - } - return getExecutable(exeType, editor, "executable"); + String executable = "executable"; + retryLoop(exeType, editor, executable); + return getExecutable(exeType, editor, executable); } public static File getConfigExecutable(String exeType, IExternalEditor editor) { - while(!getExecutable(exeType, editor, "configExecutable").exists()) { + String executable = "configExecutable"; + retryLoop(exeType, editor, executable); + return getExecutable(exeType, editor, executable); + } + private static void retryLoop(String exeType, IExternalEditor editor, String executable) { + + for(int i=0;i<3&&!getExecutable(exeType, editor, executable).exists();i++) { new RuntimeException("Download or extraction failed, retrying").printStackTrace(); } - return getExecutable(exeType, editor, "configExecutable"); } private static File getExecutable(String exeType, IExternalEditor editor, String executable) { @@ -323,6 +327,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String String baseURL = vm.get("url").toString(); String type = vm.get("type").toString(); String name = vm.get("name").toString(); + String ospath = vm.get("ospath").toString(); String exeInZip = vm.get(executable).toString(); String configexe = vm.get("configExecutable").toString(); String jvmURL = baseURL + name + "." + type; @@ -333,7 +338,10 @@ private static File getExecutable(String exeType, IExternalEditor editor, String } else environment = new HashMap<>(); File dest = new File(bindir + targetdir); - String cmd = bindir + targetdir + "/" + exeInZip; + String cmd = bindir + targetdir + delim() + exeInZip; + if(ospath!=null) { + cmd=ospath+delim()+exeInZip; + } if (!new File(cmd).exists()) { if(exeType.toLowerCase().contentEquals("freecad")) { FreecadLoader.update(vm); @@ -803,8 +811,8 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc }catch(Throwable ex) { downloadEvents.finishDownload(); ex.printStackTrace(); + new File(inputFile).delete(); throw ex; - //new File(inputFile).delete(); } downloadEvents.finishDownload(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index 02ccf8dd..1e38e47d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -263,7 +263,7 @@ private static String readAll(Reader rd) throws IOException { return sb.toString(); } public static void update(Map vm) throws MalformedURLException, IOException { - String url= "https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases/tags/weekly-builds"; + String url= "https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases/tags/1.0rc2"; InputStream is = new URL(url).openStream(); String type = vm.get("type").toString(); From aeb8a7ca53decdc8838e38327704ea248c23ee29 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 20 Oct 2024 11:36:25 -0400 Subject: [PATCH 161/635] adding op to approval classes --- .../bowlerstudio/scripting/IApprovalForDownload.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java index dac19f0a..ca048219 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java @@ -2,4 +2,5 @@ public interface IApprovalForDownload { boolean get(String name, String url); + void onInstallFail(String url); } From e741ffa826fbe757dfb267d7f293b566977e5582 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 20 Oct 2024 11:44:53 -0400 Subject: [PATCH 162/635] kick the download back to the user if the local install fails --- .../bowlerstudio/scripting/DownloadManager.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index ebb3795d..49651c8a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -108,8 +108,14 @@ public boolean get(String name, String url) { System.out.println("Command line mode, assuming yes to downloading \n" + name + " \nfrom \n" + url); return true; } + + @Override + public void onInstallFail(String url) { + System.out.println("Plugin needs to be installed from "+url); + } }; private static GitLogProgressMonitor psudoSplash; + private static String jvmURL; public static Thread run(IExternalEditor editor, File dir, PrintStream out, List finalCommand) { return run(new HashMap(), editor, dir, out, finalCommand); @@ -301,10 +307,13 @@ public static File getConfigExecutable(String exeType, IExternalEditor editor) { return getExecutable(exeType, editor, executable); } private static void retryLoop(String exeType, IExternalEditor editor, String executable) { - - for(int i=0;i<3&&!getExecutable(exeType, editor, executable).exists();i++) { + for(int i=0;i<3;i++) { + if(getExecutable(exeType, editor, executable).exists()) { + return; + } new RuntimeException("Download or extraction failed, retrying").printStackTrace(); } + approval.onInstallFail(jvmURL); } private static File getExecutable(String exeType, IExternalEditor editor, String executable) { @@ -330,7 +339,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String String ospath = vm.get("ospath").toString(); String exeInZip = vm.get(executable).toString(); String configexe = vm.get("configExecutable").toString(); - String jvmURL = baseURL + name + "." + type; + jvmURL = baseURL + name + "." + type; Map environment; Object o = vm.get("environment"); if (o != null) { From 4a429e691f17a9bb30d55c3e8a0b0332d4d2e28f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 20 Oct 2024 11:47:18 -0400 Subject: [PATCH 163/635] making sure the cmd is not changed in the case the installed system wide is not working --- .../bowlerstudio/scripting/DownloadManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 49651c8a..4a047406 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -349,7 +349,9 @@ private static File getExecutable(String exeType, IExternalEditor editor, String File dest = new File(bindir + targetdir); String cmd = bindir + targetdir + delim() + exeInZip; if(ospath!=null) { - cmd=ospath+delim()+exeInZip; + String string = ospath+delim()+exeInZip; + if(new File(string).exists()) + cmd=string; } if (!new File(cmd).exists()) { if(exeType.toLowerCase().contentEquals("freecad")) { From 7272b14c6f883a2cea0af94ab49babf3623106dc Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 20 Oct 2024 12:14:57 -0400 Subject: [PATCH 164/635] fail gracefully when the ospath is not defined --- .../bowlerstudio/scripting/DownloadManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 4a047406..d15ddd3c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -336,7 +336,10 @@ private static File getExecutable(String exeType, IExternalEditor editor, String String baseURL = vm.get("url").toString(); String type = vm.get("type").toString(); String name = vm.get("name").toString(); - String ospath = vm.get("ospath").toString(); + String ospath =null; + try { + ospath=vm.get("ospath").toString(); + }catch(Throwable t) {} String exeInZip = vm.get(executable).toString(); String configexe = vm.get("configExecutable").toString(); jvmURL = baseURL + name + "." + type; From dbcebb45fca2e4d204a7e2078dcea56f30364b62 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 23 Oct 2024 09:52:07 -0400 Subject: [PATCH 165/635] updating the JavaCad stack --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 1c49b973..4b0b1f93 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 1c49b97396d99dc7d8f968b71cb9aa49aceecf20 +Subproject commit 4b0b1f934999d8bff14c8382718fb66b73c620b6 diff --git a/build.gradle b/build.gradle index 3b4c7a91..0ad889e2 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.7.1' + api 'com.neuronrobotics:JavaCad:1.8.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ccd25ccb0e3e7e4a920020adfe60bfb1b8822836 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 23 Oct 2024 10:44:11 -0400 Subject: [PATCH 166/635] parametrics should only regenerate when the regen is not running --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1102adbb..acca3e0a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -146,7 +146,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { return null; if (isRegenerating() || isOperationRunning()) { System.out.println("Opperation is running, ignoring regen"); - return opperationRunner; + return null; } int endIndex = getCurrentIndex(); int size = opperations.size(); From be14a5a50e43cd7a9f29648868dda7f9cc5a3da4 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 24 Oct 2024 18:07:04 -0400 Subject: [PATCH 167/635] updating jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 4b0b1f93..730e0f58 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4b0b1f934999d8bff14c8382718fb66b73c620b6 +Subproject commit 730e0f58b21084f66f6052239df740a3b9b89619 From 95858d77e5ab7c29ba182931dfbfdb83c9bd4f94 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 26 Oct 2024 11:09:53 -0400 Subject: [PATCH 168/635] https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/5 --- .../scripting/cadoodle/AddFromFile.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index f585c622..22c5d7d6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -30,7 +30,8 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation private StringParameter parameter = null; public AddFromFile set(File source) { - getParameter().setStrValue(source.getAbsolutePath()); + String absolutePath = toLocal(source).getAbsolutePath(); + getParameter(absolutePath).setStrValue(absolutePath); return this; } @@ -52,10 +53,10 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); - System.out.println("Initial Loading " + getParameter().getStrValue()); + System.out.println("Initial Loading " + parameter.getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); - CSG processedCSG = processGiven(csg, i, getParameter(), getOrderedName()); + CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); collect.add(processedCSG); } @@ -95,10 +96,8 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); return targetFile; } - - public File getFile() { + private File toLocal(File file) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); - File file = new File(getParameter().getStrValue()); File parentFileIncoming = file.getParentFile(); File parentFile = new File(loc.getStrValue()).getParentFile(); String source = parentFile.getAbsolutePath(); @@ -117,9 +116,12 @@ public File getFile() { } } file = new File(source + DownloadManager.delim() + file.getName()); - getParameter().setStrValue(file.getAbsolutePath()); + getParameter(file.getAbsolutePath()).setStrValue(file.getAbsolutePath()); return file; } + public File getFile() { + return toLocal(new File(parameter.getStrValue())); + } private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { CSG processedCSG = csg @@ -165,9 +167,9 @@ public void setName(String name) { this.name = name; } - public StringParameter getParameter() { + public StringParameter getParameter(String defaultVal) { if (parameter == null) - setParameter(new StringParameter(getName() + "_CaDoodle_File", "UnKnown", options)); + setParameter(new StringParameter(getName() + "_CaDoodle_File", defaultVal, options)); return parameter; } From 164665229a803ce59a1b7d3e7e2d74f4c99ff83d Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 26 Oct 2024 12:17:30 -0400 Subject: [PATCH 169/635] Adding file working with the CSG database --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 22c5d7d6..df2222d9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -18,6 +18,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { @@ -32,6 +33,7 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation public AddFromFile set(File source) { String absolutePath = toLocal(source).getAbsolutePath(); getParameter(absolutePath).setStrValue(absolutePath); + CSGDatabase.saveDatabase(); return this; } @@ -53,7 +55,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); - System.out.println("Initial Loading " + parameter.getStrValue()); + System.out.println("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); @@ -120,7 +122,12 @@ private File toLocal(File file) { return file; } public File getFile() { - return toLocal(new File(parameter.getStrValue())); + return new File(getStrValue()); + } + + private String getStrValue() { + + return getParameter("UnKnown").getStrValue(); } private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { From 73234f3df3916cb2e3ce3c62d335003f65d6ed0c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 11:46:27 -0400 Subject: [PATCH 170/635] Adding a method to list all of the vitaamins --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index bc34e378..bce4a359 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -227,6 +227,11 @@ public static String getScriptGitURL(String type) { return script.get("scriptGit").toString(); } + public static void loadAllScriptFiles() { + for(String type:listVitaminTypes()) { + getScriptFile(type); + } + } public static File getScriptFile(String type) { Map script = getMeta(type); From b06b04e9e8d9db20bcc8d7716ae79d7bf411da7e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 11:54:38 -0400 Subject: [PATCH 171/635] use the percentage to render the regeneration percentage --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index acca3e0a..e69b77b3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -149,7 +149,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { return null; } int endIndex = getCurrentIndex(); - int size = opperations.size(); + double size = opperations.size(); if (endIndex != size) { // new Exception("Regenerationg from a position back in time " + endIndex + " but have " + size) // .printStackTrace(); @@ -170,6 +170,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { for (; getCurrentIndex() < size;) { setCurrentIndex(getCurrentIndex() + 1); + setPercentInitialized(((double)getCurrentIndex())/size); // System.out.println("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); From ea90df271de9d15de69356fd982fd1b995f97c33 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 16:33:28 -0400 Subject: [PATCH 172/635] making vitamins more thread safe and robust with synchronized data structures --- .../bowlerstudio/vitamins/Vitamins.java | 308 +++++++++--------- 1 file changed, 151 insertions(+), 157 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index bce4a359..196794bb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -2,11 +2,12 @@ import java.io.File; import java.io.IOException; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import com.neuronrobotics.sdk.common.Log; @@ -50,24 +51,25 @@ public class Vitamins { private static String jsonRootDir = "json/"; - private static final Map fileLastLoaded = new HashMap(); - private static final Map>> databaseSet = new HashMap>>(); + private static final Map fileLastLoaded = new ConcurrentHashMap(); + private static final Map>> databaseSet = new ConcurrentHashMap>>(); private static final String defaultgitRpoDatabase = "https://github.com/madhephaestus/Hardware-Dimensions.git"; private static String gitRpoDatabase = defaultgitRpoDatabase; // Create the type, this tells GSON what datatypes to instantiate when parsing // and saving the json - private static Type TT_mapStringString = new TypeToken>>() { + private static Type TT_mapStringString = new TypeToken>>() { }.getType(); // chreat the gson object, this is the parsing factory private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); private static boolean checked; - private static HashMap changeListeners = new HashMap(); + private static ConcurrentHashMap changeListeners = new ConcurrentHashMap(); + public static void clear() { System.out.println("Vitamins Database Cleraing, reloading files"); - for(String keys:databaseSet.keySet()) { - HashMap> data = databaseSet.get(keys); - for(String key2:data.keySet()) { - HashMap data2 = data.get(key2); + for (String keys : databaseSet.keySet()) { + ConcurrentHashMap> data = databaseSet.get(keys); + for (String key2 : data.keySet()) { + ConcurrentHashMap data2 = data.get(key2); data2.clear(); } data.clear(); @@ -75,12 +77,14 @@ public static void clear() { databaseSet.clear(); fileLastLoaded.clear(); } + public static CSG get(File resource) { - return get(resource,false); + return get(resource, false); } + public static CSG get(File resource, boolean forceRefresh) { - if (fileLastLoaded.get(resource.getAbsolutePath()) == null||forceRefresh) { + if (fileLastLoaded.get(resource.getAbsolutePath()) == null || forceRefresh) { // forces the first time the files is accessed by the application tou pull an // update try { @@ -151,21 +155,22 @@ public static boolean isGitURL(String text2) { } catch (Exception ex) { if (!text2.startsWith("git@")) { ex.printStackTrace(); - return false ; + return false; } } return true; } + public static void flatten(ArrayList flat, Object o) { ScriptingEngine.flatten(flat, o); } - + public static CSG get(String type, String id) throws Exception { - if(isGitURL(type)) { - Object o =ScriptingEngine.gitScriptRun(type, id); - ArrayList flat= new ArrayList(); - Vitamins.flatten(flat,o); - return CSG.unionAll( flat); + if (isGitURL(type)) { + Object o = ScriptingEngine.gitScriptRun(type, id); + ArrayList flat = new ArrayList(); + Vitamins.flatten(flat, o); + return CSG.unionAll(flat); } return get(type, id, 0); } @@ -189,20 +194,20 @@ private static CSG get(String type, String id, int depthGauge) throws Exception repostring.toString(), // file to load servoMeasurments); Map configuration = Vitamins.getConfiguration(type, id); - newVitamin.setName(type +"-"+ id); + newVitamin.setName(type + "-" + id); newVitamin.setManufacturing(incoming -> null); try { Transform com = new Transform() - .movex(Double.parseDouble(configuration.get("massCentroidX").toString())) - .movey(Double.parseDouble(configuration.get("massCentroidY").toString())) - .movez(Double.parseDouble(configuration.get("massCentroidZ").toString())); + .movex(Double.parseDouble(configuration.get("massCentroidX").toString())) + .movey(Double.parseDouble(configuration.get("massCentroidY").toString())) + .movez(Double.parseDouble(configuration.get("massCentroidZ").toString())); newVitamin.getStorage().set("massKg", configuration.get("massKg")); newVitamin.getStorage().set("massCentroid", com); - + return newVitamin; - }catch(Exception ex) { - //System.err.println(type +"-"+ id+" Failed"); - //ex.printStackTrace(); + } catch (Exception ex) { + // System.err.println(type +"-"+ id+" Failed"); + // ex.printStackTrace(); return newVitamin; } } else { @@ -220,21 +225,23 @@ private static CSG get(String type, String id, int depthGauge) throws Exception } } } + public static String getScriptGitURL(String type) { Map script = getMeta(type); - - + return script.get("scriptGit").toString(); } + public static void loadAllScriptFiles() { - for(String type:listVitaminTypes()) { + for (String type : listVitaminTypes()) { getScriptFile(type); } } + public static File getScriptFile(String type) { Map script = getMeta(type); - + try { return ScriptingEngine.fileFromGit(script.get("scriptGit").toString(), script.get("scriptFile").toString()); } catch (InvalidRemoteException e) { @@ -261,44 +268,33 @@ public static void setScript(String type, String git, String file) throws Except setParameter(type, "meta", "scriptGit", git); setParameter(type, "meta", "scriptFile", file); } - - public static Map getConfiguration(String type, String id){ - return Collections.unmodifiableMap(getConfigurationRW( type, id)); + + public static Map getConfiguration(String type, String id) { + return Collections.unmodifiableMap(getConfigurationRW(type, id)); } - public static void putMeasurment(String type, String size,String measurementName, Object measurmentValue) { - getConfigurationRW(type,size).put(measurementName, measurmentValue); + + public static void putMeasurment(String type, String size, String measurementName, Object measurmentValue) { + getConfigurationRW(type, size).put(measurementName, measurmentValue); } - public static Object getMeasurement(String type, String size,String measurementName) { - return getConfigurationRW(type,size).get(measurementName); + + public static Object getMeasurement(String type, String size, String measurementName) { + return getConfigurationRW(type, size).get(measurementName); } - public static HashMap getConfigurationRW(String type, String id) { - HashMap> database = getDatabase(type); + + public static ConcurrentHashMap getConfigurationRW(String type, String id) { + ConcurrentHashMap> database = getDatabase(type); if (database.get(id) == null) { - database.put(id, new HashMap()); + database.put(id, new ConcurrentHashMap()); } - for(int j=0;j<5;j++) { - try { - HashMap hashMap = database.get(id); - Object[] array = hashMap.keySet().toArray(); - for (int i=0;i ConcurrentHashMap = database.get(id); + Object[] array = ConcurrentHashMap.keySet().toArray(); + for (int i = 0; i < array.length; i++) { + String key = (String) array[i]; + sanatize(key, ConcurrentHashMap); } - return new HashMap(); + return ConcurrentHashMap; + } public static String makeJson(String type) { @@ -310,14 +306,16 @@ public static void saveDatabase(String type) throws Exception { // Save contents and publish them String jsonString = makeJson(type); try { - //new Exception().printStackTrace(); + // new Exception().printStackTrace(); ScriptingEngine.pushCodeToGit(getGitRepoDatabase(), // git repo, change this if you fork this demo ScriptingEngine.getFullBranch(getGitRepoDatabase()), // branch or tag getRootFolder() + type + ".json", // local path to the file in git jsonString, // content of the file - "Making changes to "+type+" by "+PasswordManager.getUsername()+"\n\nAuto-save inside com.neuronrobotics.bowlerstudio.vitamins.Vitamins inside bowler-scripting-kernel");// commit message - //System.err.println(jsonString); - System.out.println("Database saved "+getVitaminFile(type,null,false).getAbsolutePath()); + "Making changes to " + type + " by " + PasswordManager.getUsername() + + "\n\nAuto-save inside com.neuronrobotics.bowlerstudio.vitamins.Vitamins inside bowler-scripting-kernel");// commit + // message + // System.err.println(jsonString); + System.out.println("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); } catch (org.eclipse.jgit.api.errors.TransportException ex) { System.out.println("You need to fork " + defaultgitRpoDatabase + " to have permission to save"); System.out.println( @@ -326,6 +324,7 @@ public static void saveDatabase(String type) throws Exception { } } + public static void saveDatabaseForkIfMissing(String type) throws Exception { org.kohsuke.github.GitHub github = PasswordManager.getGithub(); @@ -334,73 +333,64 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { saveDatabase(type); } catch (org.eclipse.jgit.api.errors.TransportException ex) { System.err.println("Forked repo is missing!"); - + GHRepository newRepo = repo.fork(); Thread.sleep(6000); Vitamins.gitRpoDatabase = newRepo.getGitTransportUrl().replaceAll("git://", "https://"); saveDatabase(type); - + } - if(PasswordManager.getUsername().contentEquals("madhephaestus")) + if (PasswordManager.getUsername().contentEquals("madhephaestus")) return; try { - GHRepository myrepo = github.getRepository(PasswordManager.getUsername()+"/Hardware-Dimensions"); - List asList1 = myrepo.queryPullRequests().state(GHIssueState.OPEN).head("madhephaestus:master") - .list().asList(); + GHRepository myrepo = github.getRepository(PasswordManager.getUsername() + "/Hardware-Dimensions"); + List asList1 = myrepo.queryPullRequests().state(GHIssueState.OPEN) + .head("madhephaestus:master").list().asList(); Thread.sleep(200);// Some asynchronus delay here, not sure why... - if(asList1.size()==0) { + if (asList1.size() == 0) { try { - GHPullRequest request = myrepo.createPullRequest("Update from source", - "madhephaestus:master", - "master", - "## Upstream add vitamins", - false, false); - if(request!=null) { + GHPullRequest request = myrepo.createPullRequest("Update from source", "madhephaestus:master", + "master", "## Upstream add vitamins", false, false); + if (request != null) { processSelfPR(request); } - }catch(org.kohsuke.github.HttpException ex) { + } catch (org.kohsuke.github.HttpException ex) { // no commits have been made to master } - - }else { + + } else { processSelfPR(asList1.get(0)); } - String head = PasswordManager.getUsername()+":master"; - List asList = repo.queryPullRequests() - .state(GHIssueState.OPEN) - .head(head) - .list().asList(); - if(asList.size()==0) { - System.err.println("Creating PR for "+head); - GHPullRequest request = repo.createPullRequest("User Added vitamins to "+type, - head, - "master", - "## User added vitamins", - true, true); + String head = PasswordManager.getUsername() + ":master"; + List asList = repo.queryPullRequests().state(GHIssueState.OPEN).head(head).list().asList(); + if (asList.size() == 0) { + System.err.println("Creating PR for " + head); + GHPullRequest request = repo.createPullRequest("User Added vitamins to " + type, head, "master", + "## User added vitamins", true, true); try { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } - }else { - + } else { + } - }catch(Exception ex) { - new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(),ex); + } catch (Exception ex) { + new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); } - } private static void processSelfPR(GHPullRequest request) throws IOException { - if(request== null) + if (request == null) return; try { if (request.getMergeable()) { request.merge("Auto Merging Master"); reLoadDatabaseFromFiles(); - System.out.println("Merged Hardware-Dimensions madhephaestus:master into "+PasswordManager.getUsername()+":master"); + System.out.println("Merged Hardware-Dimensions madhephaestus:master into " + + PasswordManager.getUsername() + ":master"); } else { try { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); @@ -409,12 +399,13 @@ private static void processSelfPR(GHPullRequest request) throws IOException { e.printStackTrace(); } } - }catch(java.lang.NullPointerException ex) { + } catch (java.lang.NullPointerException ex) { ex.printStackTrace(); } } + public static void newVitamin(String type, String id) throws Exception { - HashMap> database = getDatabase(type); + ConcurrentHashMap> database = getDatabase(type); if (database.keySet().size() > 0) { String exampleKey = null; for (String key : database.keySet()) { @@ -439,15 +430,15 @@ public static void newVitamin(String type, String id) throws Exception { public static void setParameter(String type, String id, String parameterName, Object parameter) throws Exception { - HashMap config = getConfigurationRW(type, id); + ConcurrentHashMap config = getConfigurationRW(type, id); config.put(parameterName, parameter); - sanatize(parameterName, config); + sanatize(parameterName, config); // saveDatabase(type); } - private static void sanatize(String parameterName, HashMap config) { - Object parameter=config.get(parameterName); + private static void sanatize(String parameterName, ConcurrentHashMap config) { + Object parameter = config.get(parameterName); try { config.put(parameterName, Double.parseDouble(parameter.toString())); } catch (NumberFormatException ex) { @@ -455,7 +446,7 @@ private static void sanatize(String parameterName, HashMap conf } } - public static HashMap> getDatabase(String type) { + public static ConcurrentHashMap> getDatabase(String type) { if (databaseSet.get(type) == null) { // we are using the default vitamins configuration // https://github.com/madhephaestus/Hardware-Dimensions.git @@ -467,40 +458,39 @@ public static HashMap> getDatabase(String type) // attempt to load the JSON file from the GIt Repo and pars the JSON string File f; try { - - Runnable onChange=null; - if(changeListeners.get(type)==null) { - changeListeners.put(type,() -> { + + Runnable onChange = null; + if (changeListeners.get(type) == null) { + changeListeners.put(type, () -> { // If the file changes, clear the database and load the new data - System.out.println("Re-loading "+type); - databaseSet.put(type,null); + System.out.println("Re-loading " + type); + databaseSet.put(type, null); new RuntimeException().printStackTrace(); }); - onChange=changeListeners.get(type); + onChange = changeListeners.get(type); } - - - f = getVitaminFile(type,onChange,true); - HashMap> database; - if(f.exists()) { - + f = getVitaminFile(type, onChange, true); + + ConcurrentHashMap> database; + if (f.exists()) { + inPut = FileUtils.openInputStream(f); - + jsonString = IOUtils.toString(inPut); inPut.close(); - System.out.println("JSON loading Loading "+type+" "+jsonString.length()); + System.out.println("JSON loading Loading " + type + " " + jsonString.length()); // perfoem the GSON parse database = gson.fromJson(jsonString, TT_mapStringString); - if(database==null) + if (database == null) throw new RuntimeException("Database failed to read"); - }else { - database=new HashMap>(); + } else { + database = new ConcurrentHashMap>(); } databaseSet.put(type, database); for (String key : databaseSet.get(type).keySet()) { - HashMap conf = database.get(key); + ConcurrentHashMap conf = database.get(key); for (String confKey : conf.keySet()) { try { double num = Double.parseDouble(conf.get(confKey).toString()); @@ -515,7 +505,7 @@ public static HashMap> getDatabase(String type) } catch (Exception e) { e.printStackTrace(); - databaseSet.put(type, new HashMap>()); + databaseSet.put(type, new ConcurrentHashMap>()); } } return databaseSet.get(type); @@ -524,12 +514,11 @@ public static HashMap> getDatabase(String type) public static File getVitaminFile(String type, Runnable onChange, boolean oneShot) throws InvalidRemoteException, TransportException, GitAPIException, IOException { - - - File f= ScriptingEngine.fileFromGit(getGitRepoDatabase(), // git repo, change this if you fork this demo + + File f = ScriptingEngine.fileFromGit(getGitRepoDatabase(), // git repo, change this if you fork this demo getRootFolder() + type + ".json"// File from within the Git repo ); - if(onChange!=null) { + if (onChange != null) { // FileChangeWatcher watcher = FileChangeWatcher.watch(f); // watcher.addIFileChangeListener((fileThatChanged, event) -> { // onChange.run(); @@ -541,36 +530,40 @@ public static File getVitaminFile(String type, Runnable onChange, boolean oneSho private static String getRootFolder() { return getJsonRootDir(); } - public static ArrayList listVitaminActuators() { - ArrayList actuators = new ArrayList(); - + + public static CopyOnWriteArrayList listVitaminActuators() { + CopyOnWriteArrayList actuators = new CopyOnWriteArrayList(); + for (String vitaminsType : Vitamins.listVitaminTypes()) { - if (isActuator( vitaminsType)) + if (isActuator(vitaminsType)) actuators.add(vitaminsType); } return actuators; } - public static ArrayList listVitaminShafts() { - ArrayList actuators = new ArrayList(); + + public static CopyOnWriteArrayList listVitaminShafts() { + CopyOnWriteArrayList actuators = new CopyOnWriteArrayList(); for (String vitaminsType : Vitamins.listVitaminTypes()) { - if (isShaft( vitaminsType)) + if (isShaft(vitaminsType)) actuators.add(vitaminsType); } return actuators; } - + public static boolean isShaft(String vitaminsType) { Map meta = Vitamins.getMeta(vitaminsType); if (meta != null && meta.containsKey("shaft")) return true; return false; } + public static boolean isActuator(String vitaminsType) { Map meta = Vitamins.getMeta(vitaminsType); if (meta != null && meta.containsKey("actuator")) return true; return false; } + public static void setIsShaft(String type) { Vitamins.getMeta(type).remove("motor"); Vitamins.getMeta(type).put("shaft", "true"); @@ -580,12 +573,14 @@ public static void setIsActuator(String type) { Vitamins.getMeta(type).remove("shaft"); Vitamins.getMeta(type).put("actuator", "true"); } - public static ArrayList listVitaminTypes() { - ArrayList types = new ArrayList(); + public static CopyOnWriteArrayList listVitaminTypes() { + + CopyOnWriteArrayList types = new CopyOnWriteArrayList(); File folder; - try { - folder = new File(ScriptingEngine.getRepositoryCloneDirectory(getGitRepoDatabase()).getAbsoluteFile()+"/"+getRootFolder()); + try { + folder = new File(ScriptingEngine.getRepositoryCloneDirectory(getGitRepoDatabase()).getAbsoluteFile() + "/" + + getRootFolder()); File[] listOfFiles = folder.listFiles(); for (File f : listOfFiles) { @@ -605,7 +600,7 @@ public static ArrayList listVitaminTypes() { public static ArrayList listVitaminSizes(String type) { ArrayList types = new ArrayList(); - HashMap> database = getDatabase(type); + ConcurrentHashMap> database = getDatabase(type); Set keys = database.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext();) { String s = iterator.next(); @@ -619,23 +614,23 @@ public static ArrayList listVitaminSizes(String type) { return types; } - public static String getGitRepoDatabase() { + public static String getGitRepoDatabase() { if (!checked) { checked = true; try { if (PasswordManager.getUsername() != null) { - //ScriptingEngine.setAutoupdate(true); + // ScriptingEngine.setAutoupdate(true); org.kohsuke.github.GitHub github = PasswordManager.getGithub(); try { - GHRepository repo =github.getRepository(PasswordManager.getLoginID() + "/Hardware-Dimensions" ); - if(repo!=null) { + GHRepository repo = github.getRepository(PasswordManager.getLoginID() + "/Hardware-Dimensions"); + if (repo != null) { String myAssets = repo.getGitTransportUrl().replaceAll("git://", "https://"); // System.out.println("Using my version of Viamins: "+myAssets); setGitRepoDatabase(myAssets); - }else { + } else { throw new org.kohsuke.github.GHFileNotFoundException(); } - }catch(Exception ex) { + } catch (Exception ex) { setGitRepoDatabase(defaultgitRpoDatabase); } } @@ -655,11 +650,11 @@ public static String getGitRepoDatabase() { } public static void reLoadDatabaseFromFiles() { - + setGitRepoDatabase(getGitRepoDatabase()); try { ScriptingEngine.pull(getGitRepoDatabase()); - }catch (CheckoutConflictException|NoHeadException e) { + } catch (CheckoutConflictException | NoHeadException e) { ScriptingEngine.deleteRepo(getGitRepoDatabase()); try { ScriptingEngine.pull(getGitRepoDatabase()); @@ -667,12 +662,13 @@ public static void reLoadDatabaseFromFiles() { // TODO Auto-generated catch block e1.printStackTrace(); } - }catch (Exception e) { + } catch (Exception e) { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), e); } listVitaminTypes(); - + } + public static void setGitRepoDatabase(String gitRpoDatabase) { Vitamins.gitRpoDatabase = gitRpoDatabase; databaseSet.clear(); @@ -689,6 +685,4 @@ public static void setJsonRootDir(String jsonRootDir) throws IOException { setGitRepoDatabase(getGitRepoDatabase()); } - - } From bf932a121de462c9d5820d49def87b80c8cfbb12 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 16:41:55 -0400 Subject: [PATCH 173/635] delete the vitamins repo and try again --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 196794bb..fda432bb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -177,10 +177,10 @@ public static CSG get(String type, String id) throws Exception { private static CSG get(String type, String id, int depthGauge) throws Exception { String key = type + id; + Map script = getMeta(type); try { CSG newVitamin = null; - Map script = getMeta(type); StringParameter size = new StringParameter(type + " Default", id, Vitamins.listVitaminSizes(type)); size.setStrValue(id); Object file = script.get("scriptGit"); @@ -217,6 +217,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception } catch (Exception e) { e.printStackTrace(); gitRpoDatabase = defaultgitRpoDatabase; + ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); if (depthGauge < 2) { return get(type, id, depthGauge + 1); From 463f7615a521b903d25248030b7ea72b69be0daa Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 16:42:38 -0400 Subject: [PATCH 174/635] return an error cube instead of null --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index fda432bb..393a074a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -12,6 +12,7 @@ import com.neuronrobotics.sdk.common.Log; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Cube; import eu.mihosoft.vrl.v3d.STL; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; @@ -222,7 +223,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception if (depthGauge < 2) { return get(type, id, depthGauge + 1); } else { - return null; + return new Cube(20).toCSG(); } } } From d22d84e2b5306aa1270ea1a8244d2693228f237c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 16:43:02 -0400 Subject: [PATCH 175/635] make error cube red --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 393a074a..c5a60d8a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -17,6 +17,7 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; +import javafx.scene.paint.Color; import com.neuronrobotics.bowlerstudio.BowlerKernel; import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; @@ -223,7 +224,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception if (depthGauge < 2) { return get(type, id, depthGauge + 1); } else { - return new Cube(20).toCSG(); + return new Cube(20).toCSG().setColor(Color.RED); } } } From 49db6d22c4464fc103294fb4c63f7067928ee8c3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 17:11:36 -0400 Subject: [PATCH 176/635] updating the JCSG with fewer prints --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0ad889e2..a5d6a6f5 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.0' + api 'com.neuronrobotics:JavaCad:1.8.2' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From b8b5c532b5ab5f1e2080b73bef9ae0d361fda2bb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 17:58:58 -0400 Subject: [PATCH 177/635] removing prints for the log instead --- GithubPasswordManager | 2 +- java-bowler | 2 +- .../bowlerkernel/Bezier3d/BezierEditor.java | 4 +- .../bowlerkernel/Bezier3d/Manipulation.java | 10 +- .../bowlerkernel/BowlerKernelBuildInfo.java | 2 +- .../bowlerkernel/djl/UniquePersonFactory.java | 6 +- .../bowlerstudio/AudioPlayer.java | 4 +- .../bowlerstudio/BowlerKernel.java | 74 +++++------ .../bowlerstudio/CoquiDockerManager.java | 16 +-- .../IssueReportingExceptionHandler.java | 14 +-- .../bowlerstudio/TextToSpeech.java | 2 +- .../bowlerstudio/assets/AssetFactory.java | 10 +- .../assets/ConfigurationDatabase.java | 4 +- .../bowlerstudio/assets/StudioBuildInfo.java | 2 +- .../creature/CadFileExporter.java | 14 +-- .../creature/MobileBaseCadManager.java | 26 ++-- .../creature/MobileBaseLoader.java | 4 +- .../bowlerstudio/lipsync/RhubarbManager.java | 14 +-- .../bowlerstudio/lipsync/VoskLipSync.java | 14 +-- .../physics/CSGPhysicsManager.java | 2 +- .../physics/HingeCSGPhysicsManager.java | 4 +- .../physics/MobileBasePhysicsManager.java | 4 +- .../physics/MuJoCoPhysicsManager.java | 18 +-- .../bowlerstudio/physics/PhysicsCore.java | 4 +- .../printbed/PrintBedManager.java | 10 +- .../bowlerstudio/printbed/PrintBedObject.java | 2 +- .../bowlerstudio/scripting/ArduinoLoader.java | 4 +- .../bowlerstudio/scripting/BashLoader.java | 4 +- .../bowlerstudio/scripting/BlenderLoader.java | 4 +- .../bowlerstudio/scripting/ClojureHelper.java | 2 +- .../scripting/DownloadManager.java | 70 +++++------ .../bowlerstudio/scripting/FreecadLoader.java | 2 +- .../bowlerstudio/scripting/GroovyHelper.java | 4 +- .../bowlerstudio/scripting/JythonHelper.java | 2 +- .../bowlerstudio/scripting/RobotHelper.java | 2 +- .../scripting/ScriptingEngine.java | 118 +++++++++--------- .../bowlerstudio/scripting/SvgLoader.java | 2 +- .../scripting/cadoodle/AddFromFile.java | 4 +- .../scripting/cadoodle/CaDoodleFile.java | 22 ++-- .../ICaDoodleOperationAdapterFactory.java | 2 +- .../bowlerstudio/sequence/TimeSequence.java | 14 +-- .../bowlerstudio/util/FileChangeWatcher.java | 14 +-- .../bowlerstudio/vitamins/Purchasing.java | 4 +- .../vitamins/VitaminBomManager.java | 4 +- .../bowlerstudio/vitamins/Vitamins.java | 26 ++-- .../imageprovider/NativeResource.java | 20 +-- .../addons/gamepad/BowlerJInputDevice.java | 12 +- .../addons/gamepad/ControllerEnvironment.java | 2 +- .../sdk/addons/gamepad/JogTrainerWidget.java | 18 +-- .../sdk/dyio/sequencer/CoreScheduler.java | 30 ++--- .../sdk/dyio/sequencer/SequencerWAV.java | 8 +- .../sequencer/ServoOutputScheduleChannel.java | 22 ++-- .../src/junit/bowler/BlenderLoadingTest.java | 4 +- test/java/src/junit/bowler/GitHub.java | 36 +++--- test/java/src/junit/bowler/JettyTest.java | 6 +- test/java/src/junit/bowler/JsonTester.java | 8 +- .../src/junit/bowler/MobileBaseLoading.java | 8 +- .../bowler/MuJoCoBowlerIntegrationTest.java | 8 +- test/java/src/junit/bowler/MuJoCoTest.java | 6 +- .../src/junit/bowler/PyTorchResNetTest.java | 22 ++-- test/java/src/junit/bowler/TTSTest.java | 4 +- .../junit/bowler/TestCaDoodleWorkflow.java | 12 +- test/java/src/junit/bowler/TestCheckout.java | 2 +- 63 files changed, 400 insertions(+), 400 deletions(-) diff --git a/GithubPasswordManager b/GithubPasswordManager index cc34e23e..f38fc5f4 160000 --- a/GithubPasswordManager +++ b/GithubPasswordManager @@ -1 +1 @@ -Subproject commit cc34e23eebb200deaaf698a9eca0e3a2a0178669 +Subproject commit f38fc5f48b6f073c2f8c306a3128627558e0dd8c diff --git a/java-bowler b/java-bowler index b61304b7..af1c55a5 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit b61304b79dc69418852dfcc8cb5362be32202b67 +Subproject commit af1c55a5f241389f6e074ed763b2ede020a5efda diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java index acc48e76..f55349f9 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java @@ -232,7 +232,7 @@ private TransformNR updateLines(CartesianManipulator m, CartesianManipulator p, TransformNR az = new TransformNR(0, 0, 0, new RotationNR(0, -xyRot, 0)); TransformNR reorented = az.times(vect); - // System.out.println("CP1 "+reorented.getX()+" "+reorented.getY()+" + // com.neuronrobotics.sdk.common.Log.error("CP1 "+reorented.getX()+" "+reorented.getY()+" // "+reorented.getZ()); double xzRot = Math.toDegrees(Math.atan2(reorented.getZ(), reorented.getY())); @@ -325,7 +325,7 @@ public void save() { database.put("bezier", bezData); new Thread(() -> { - System.out.println("Saving to file " + cachejson.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Saving to file " + cachejson.getAbsolutePath()); String writeOut = gson.toJson(database, TT_mapStringString); if (url != null) { try { diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index faa8b987..18bdadc1 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -135,7 +135,7 @@ public void handle(MouseEvent event) { // m.getMesh().setMaterial(color); // break; default: - // System.out.println("UNKNOWN! Mouse event "+name); + // com.neuronrobotics.sdk.common.Log.error("UNKNOWN! Mouse event "+name); break; } @@ -175,12 +175,12 @@ private void dragged(MouseEvent event) { double delty = (starty - event.getScreenY()); double x = deltx/ getDepthNow() ; double y = delty/ getDepthNow() ; - //System.out.println("Moved "+x+" "+y); + //com.neuronrobotics.sdk.common.Log.error("Moved "+x+" "+y); if(Double.isFinite(y) && Double.isFinite(x)) { TransformNR trans = new TransformNR(x, y, 0, new RotationNR()); performMove(trans); }else { - System.out.println("ERROR?"); + com.neuronrobotics.sdk.common.Log.error("ERROR?"); } }); event.consume(); @@ -241,7 +241,7 @@ private void performMove(TransformNR trans) { global.setRotation(new RotationNR()); setGlobal(global); - //System.out.println(" drag "+global.getX()+" , "+global.getY()+" ,"+global.getZ()); + //com.neuronrobotics.sdk.common.Log.error(" drag "+global.getX()+" , "+global.getY()+" ,"+global.getZ()); }catch(Throwable t) { t.printStackTrace(); @@ -287,7 +287,7 @@ public void setInReferenceFrame(double newX, double newY, double newZ) { TransformNR wp = new TransformNR( getFrameOfReference() .getRotation()); inLocal=wp.times(inLocal); inLocal.setRotation(new RotationNR()); - //System.out.println("Setting in reference frame:"+inLocal.toSimpleString()); + //com.neuronrobotics.sdk.common.Log.error("Setting in reference frame:"+inLocal.toSimpleString()); setGlobal(inLocal); for (Runnable R : eventListeners) { R.run(); diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/BowlerKernelBuildInfo.java b/src/main/java/com/neuronrobotics/bowlerkernel/BowlerKernelBuildInfo.java index 24211628..9793cd39 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/BowlerKernelBuildInfo.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/BowlerKernelBuildInfo.java @@ -120,7 +120,7 @@ public static String getBuildDate() { } } catch (IOException e) { } - // System.out.println("Manifest:\n"+s); + // com.neuronrobotics.sdk.common.Log.error("Manifest:\n"+s); return ""; } diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java b/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java index 6cd4cdae..fbe711a8 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java @@ -262,7 +262,7 @@ private void processBlocking() { if (up.features.size() >= numberOfTrainingHashes) { if (!longTermMemory.contains(up)) { longTermMemory.add(up); - System.out.println("Saving new Face to database " + up.name); + com.neuronrobotics.sdk.common.Log.error("Saving new Face to database " + up.name); save(); } } @@ -280,7 +280,7 @@ private void processBlocking() { try { id = features.predict(cmp); } catch (Throwable ex) { - System.out.println("Image failed h=" + imgBuff.getHeight() + " w=" + imgBuff.getWidth()); + com.neuronrobotics.sdk.common.Log.error("Image failed h=" + imgBuff.getHeight() + " w=" + imgBuff.getWidth()); // ex.printStackTrace(); continue; } @@ -344,7 +344,7 @@ private void processBlocking() { private EventHandler setAction(UniquePerson p) { return event -> { String newName = getUI(p).name.getText(); - System.out.println("Renaming " + p.name + " to " + newName); + com.neuronrobotics.sdk.common.Log.error("Renaming " + p.name + " to " + newName); p.name = newName; new Thread(() -> save()).start(); }; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/AudioPlayer.java b/src/main/java/com/neuronrobotics/bowlerstudio/AudioPlayer.java index 72e5db80..f8f62641 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/AudioPlayer.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/AudioPlayer.java @@ -271,7 +271,7 @@ public float getGainValue() { public void setGain(float fGain) { // if (line != null) - // System.out.println(((FloatControl) + // com.neuronrobotics.sdk.common.Log.error(((FloatControl) // line.getControl(FloatControl.Type.MASTER_GAIN)).getValue()) // Set the value @@ -284,7 +284,7 @@ public void setGain(float fGain) { // OR (Math.log(fGain == 0.0 ? 0.0000 : fGain) / Math.log(10.0)) // if (line != null) - // System.out.println(((FloatControl) + // com.neuronrobotics.sdk.common.Log.error(((FloatControl) // line.getControl(FloatControl.Type.MASTER_GAIN)).getValue()) } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 0dd6abd8..7563a35c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -101,13 +101,13 @@ private static void loadHistoryLocal() { } private static void fail() { - System.err.println( + com.neuronrobotics.sdk.common.Log.error( "Usage: \r\njava -jar BowlerScriptKernel.jar -s .. # This will load one script after the next "); - System.err.println( + com.neuronrobotics.sdk.common.Log.error( "java -jar BowlerScriptKernel.jar -p .. # This will load one script then take the list of objects returned and pss them to the next script as its 'args' variable "); - System.err.println( + com.neuronrobotics.sdk.common.Log.error( "java -jar BowlerScriptKernel.jar -r (Optional)(-s or -p) .. # This will start a shell in the requested langauge and run the files provided. "); - System.err.println("java -jar BowlerScriptKernel.jar -g # this will run a file from git"); + com.neuronrobotics.sdk.common.Log.error("java -jar BowlerScriptKernel.jar -g # this will run a file from git"); System.exit(1); } @@ -161,7 +161,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } } if (!fileExists) { - System.err.println("\n\nERROR file does not exist: " + gitFile); + com.neuronrobotics.sdk.common.Log.error("\n\nERROR file does not exist: " + gitFile); gitFile = null; } if (gitFile != null) @@ -176,9 +176,9 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) fail(); } else { - System.out.println("Files in git:"); + com.neuronrobotics.sdk.common.Log.error("Files in git:"); for (String f : files) { - System.out.println("\t" + f); + com.neuronrobotics.sdk.common.Log.error("\t" + f); } } finish(startTime); @@ -187,7 +187,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) // "BowlerStudioVitamins/stl/servo/smallservo.stl"); // // ArrayList cad = (ArrayList )ScriptingEngine.inlineGistScriptRun("4814b39ee72e9f590757", "javaCad.groovy" , null); -// System.out.println(servo.exists()+" exists: "+servo); +// com.neuronrobotics.sdk.common.Log.error(servo.exists()+" exists: "+servo); boolean startLoadingScripts = false; for (String s : args) { @@ -208,9 +208,9 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } baseWorkspaceFile = new File(location); - System.out.println("Using working directory "+baseWorkspaceFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Using working directory "+baseWorkspaceFile.getAbsolutePath()); f=new File(baseWorkspaceFile.getAbsolutePath()+"/"+f.getName()); - System.out.println("File "+f.getName()); + com.neuronrobotics.sdk.common.Log.error("File "+f.getName()); ret = ScriptingEngine.inlineFileScriptRun(f, null); } catch (Throwable e) { e.printStackTrace(); @@ -268,12 +268,12 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) if (!runShell) { finish(startTime); } - System.out.println("Starting Bowler REPL in langauge: " + shellTypeStorage); + com.neuronrobotics.sdk.common.Log.error("Starting Bowler REPL in langauge: " + shellTypeStorage); // sample from // http://jline.sourceforge.net/testapidocs/src-html/jline/example/Example.html if (!Terminal.getTerminal().isSupported()) { - System.out.println("Terminal not supported " + Terminal.getTerminal()); + com.neuronrobotics.sdk.common.Log.error("Terminal not supported " + Terminal.getTerminal()); } // Terminal.getTerminal().initializeTerminal(); @@ -328,7 +328,7 @@ public void run() { if (line.equalsIgnoreCase("history") || line.equalsIgnoreCase("h")) { List h = reader.getHistory().getHistoryList(); for (String s : h) { - System.out.println(s); + com.neuronrobotics.sdk.common.Log.error(s); } continue; } @@ -343,7 +343,7 @@ public void run() { try { ret = ScriptingEngine.inlineScriptStringRun(line, null, shellTypeStorage); if (ret != null) { - System.out.println(ret); + com.neuronrobotics.sdk.common.Log.error(ret); } processReturnedObjectsStart(ret, null); } catch (Error e) { @@ -363,7 +363,7 @@ private static void startupProcedures(String[] args) JavaFXInitializer.go(); } catch (Throwable t) { t.printStackTrace(); - System.err.println("ERROR No UI engine availible"); + com.neuronrobotics.sdk.common.Log.error("ERROR No UI engine availible"); } ScriptingEngine.waitForLogin(); if (args.length == 0) { @@ -374,7 +374,7 @@ private static void startupProcedures(String[] args) } private static void finish(long startTime) { - System.out.println( + com.neuronrobotics.sdk.common.Log.error( "Process took " + (((double) (System.currentTimeMillis() - startTime))) / 60000.0 + " minutes"); System.exit(0); } @@ -382,7 +382,7 @@ private static void finish(long startTime) { public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { processUIOpening(ret); if(baseWorkspaceFile!=null) - System.out.println("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); CSG.setProgressMoniter(new ICSGProgress() { @Override public void progressUpdate(int currentIndex, int finalIndex, String type, @@ -432,12 +432,12 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, try { processReturnedObjects(ret, csgBits); String url = ScriptingEngine.locateGitUrl(baseWorkspaceFile); - System.out.println("Loading printbed URL "+url); + com.neuronrobotics.sdk.common.Log.error("Loading printbed URL "+url); PrintBedManager printBedManager = new PrintBedManager(baseWorkspaceFile, csgBits); if(printBedManager.hasPrintBed()) csgBits = printBedManager.makePrintBeds(); else { - System.out.println("Exporting files without print bed"); + com.neuronrobotics.sdk.common.Log.error("Exporting files without print bed"); } new CadFileExporter().generateManufacturingParts(csgBits, baseWorkspaceFile); } catch (Throwable t) { @@ -448,7 +448,7 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, private static void processUIOpening(Object ret) { if(Tab.class.isInstance(ret)) { - System.out.println("Launching User Defined UI"); + com.neuronrobotics.sdk.common.Log.error("Launching User Defined UI"); Tab t=(Tab)ret; CompletableFuture future = new CompletableFuture<>(); @@ -488,7 +488,7 @@ private static void processUIOpening(Object ret) { newStage.sizeToScene(); }); if(IStageReceiver.class.isInstance(ret)) { - System.out.println("UI is a IStageReceiver"); + com.neuronrobotics.sdk.common.Log.error("UI is a IStageReceiver"); IStageReceiver r=(IStageReceiver)ret; BowlerKernel.runLater(()->{ r.receiveStage(newStage, scene); @@ -588,7 +588,7 @@ public void addCSG(Collection toAdd, File source) { m._generateStls(ret2, dir, false); return; } - System.out.println("Found arrangeBed API in CAD engine"); + com.neuronrobotics.sdk.common.Log.error("Found arrangeBed API in CAD engine"); List totalAssembly = bed.arrangeBed(ret2); ret2.disconnect(); Thread.sleep(1000); @@ -599,19 +599,19 @@ public void addCSG(Collection toAdd, File source) { // Get maximum size of heap in bytes. The heap cannot grow beyond this size.// // Any attempt will result in an OutOfMemoryException. long heapMaxSize = Runtime.getRuntime().maxMemory(); - // System.out.println("Heap remaining + // com.neuronrobotics.sdk.common.Log.error("Heap remaining // "+(heapMaxSize-Runtime.getRuntime().totalMemory())); - // System.out.println("Of Heap "+(heapMaxSize)); + // com.neuronrobotics.sdk.common.Log.error("Of Heap "+(heapMaxSize)); for (int i = 0; i < totalAssembly.size(); i++) { List tmp = Arrays.asList(totalAssembly.get(i)); totalAssembly.set(i, null); - // System.out.println("Before Heap remaining + // com.neuronrobotics.sdk.common.Log.error("Before Heap remaining // "+(heapMaxSize-Runtime.getRuntime().totalMemory())); new CadFileExporter(m.getUi()).generateManufacturingParts(tmp, dir); tmp = null; System.gc(); - // System.out.println("After Heap remaining + // com.neuronrobotics.sdk.common.Log.error("After Heap remaining // "+(heapMaxSize-Runtime.getRuntime().totalMemory())); } @@ -637,7 +637,7 @@ public static ArrayList loadHistory() throws IOException { } public static void writeHistory(List history) { - System.out.println("Saving history"); + com.neuronrobotics.sdk.common.Log.error("Saving history"); FileOutputStream fos; try { fos = new FileOutputStream(historyFile); @@ -690,7 +690,7 @@ public static int speak(String msg, Number rate, Number pitch, Number voiceNumbe } TextToSpeech tts = new TextToSpeech(); // cd .. - tts.getAvailableVoices().stream().forEach(voice -> System.out.println("Voice: " + voice)); + tts.getAvailableVoices().stream().forEach(voice -> com.neuronrobotics.sdk.common.Log.error("Voice: " + voice)); // Setting the Current Voice // voice =(tts.getAvailableVoices().toArray()[0].toString()); String voice = "dfki-poppy-hsmm"; @@ -709,7 +709,7 @@ else if (voiceNumber.doubleValue() > 100) tts.setVoice(voice); - System.out.println("Using voice " + voice); + com.neuronrobotics.sdk.common.Log.error("Using voice " + voice); RobotiserEffect vocalTractLSE = new RobotiserEffect(); // russian drunk effect vocalTractLSE.setParams("amount:" + pitch.intValue()); @@ -717,12 +717,12 @@ else if (voiceNumber.doubleValue() > 100) // TTS say something that we actually are typing into the first variable // tts.getAudioEffects().stream().forEach(audioEffect -> { // if(audioEffect.getName().contains("Rate")) { -// System.out.println("-----Name-----"); -// System.out.println(audioEffect.getName()); -// System.out.println("-----Examples-----"); -// System.out.println(audioEffect.getExampleParameters()); -// System.out.println("-----Help Text------"); -// System.out.println(audioEffect.getHelpText() + "\n\n"); +// com.neuronrobotics.sdk.common.Log.error("-----Name-----"); +// com.neuronrobotics.sdk.common.Log.error(audioEffect.getName()); +// com.neuronrobotics.sdk.common.Log.error("-----Examples-----"); +// com.neuronrobotics.sdk.common.Log.error(audioEffect.getExampleParameters()); +// com.neuronrobotics.sdk.common.Log.error("-----Help Text------"); +// com.neuronrobotics.sdk.common.Log.error(audioEffect.getHelpText() + "\n\n"); // } // }); String effect = ""; @@ -754,7 +754,7 @@ else if (voiceNumber.doubleValue() > 100) effect += "+" + volumeEffect.getFullEffectAsString(); if (pitch.intValue() > 0) effect += "+" + vocalTractLSE.getFullEffectAsString(); - System.out.println(msg + "-->" + effect); + com.neuronrobotics.sdk.common.Log.error(msg + "-->" + effect); tts.getMarytts().setAudioEffects(effect); tts.speak(msg, 2.0f, false, true, progress); @@ -764,7 +764,7 @@ else if (voiceNumber.doubleValue() > 100) public static void upenURL(String string) { - System.err.println("Opening " + string); + com.neuronrobotics.sdk.common.Log.error("Opening " + string); try { upenURL(new URI(string)); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java index fb6d62c6..35d6760e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java @@ -81,7 +81,7 @@ private CoquiDockerManager(String voice) throws InterruptedException, InvalidRem } managers.clear(); managers.put(voice, this); - System.out.println("Coqui Voice " + voice); + com.neuronrobotics.sdk.common.Log.error("Coqui Voice " + voice); String[] parts = voice.split("/"); String voiceSlug = "-" + parts[parts.length - 1]; ScriptingEngine.cloneRepo("https://github.com/Halloween2020TheChild/CoquiDocker.git", null); @@ -107,13 +107,13 @@ private CoquiDockerManager(String voice) throws InterruptedException, InvalidRem for (Container c : allCOntainers) { if (forMe != null) continue; - System.out.println("Container: " + c); + com.neuronrobotics.sdk.common.Log.error("Container: " + c); String[] names = c.getNames(); for (String n : names) { String cs = "/" + imageName + voiceSlug; - System.out.println("Checking " + n + " to " + cs); + com.neuronrobotics.sdk.common.Log.error("Checking " + n + " to " + cs); boolean PortMatch=false; ContainerPort[] conPorts = c.getPorts(); for(ContainerPort cp:conPorts) { @@ -143,11 +143,11 @@ private CoquiDockerManager(String voice) throws InterruptedException, InvalidRem @Override public void onNext(BuildResponseItem item) { // Handle build output (optional) - System.out.println(item.getStream()); + com.neuronrobotics.sdk.common.Log.error(item.getStream()); super.onNext(item); } }).awaitImageId(); - System.out.println("Docker image built successfully."); + com.neuronrobotics.sdk.common.Log.error("Docker image built successfully."); try { ExposedPort port = ExposedPort.tcp(hostPort); Ports portBindings = new Ports(); @@ -161,7 +161,7 @@ public void onNext(BuildResponseItem item) { @Override public void onNext(WaitResponse item) { // Handle build output (optional) - System.out.println(item.toString()); + com.neuronrobotics.sdk.common.Log.error(item.toString()); super.onNext(item); } }).awaitCompletion(); @@ -170,7 +170,7 @@ public void onNext(WaitResponse item) { @Override public void onNext(Frame item) { String string = item.toString(); - System.out.println(string); + com.neuronrobotics.sdk.common.Log.error(string); if(string.contains("Press CTRL+C to quit")) { started=true; } @@ -187,7 +187,7 @@ public void onNext(Frame item) { } while(!started) { Thread.sleep(1000); - System.out.println("Waiting for server to start"); + com.neuronrobotics.sdk.common.Log.error("Waiting for server to start"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java b/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java index 645d1efb..9b972ae3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java @@ -69,7 +69,7 @@ public static void runLater(Runnable r, Throwable ex) { } public void except(Throwable e, String stacktraceFromCatch) { - System.out.println(stacktraceFromCatch); + com.neuronrobotics.sdk.common.Log.error(stacktraceFromCatch); new Thread(() -> { String stacktrace = org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e); StackTraceElement[] element = e.getStackTrace(); @@ -133,10 +133,10 @@ public void except(Throwable e, String stacktraceFromCatch) { + "```\n" + stacktrace + "\n```" + "\n\nCaught and reported at: \n" + "```\n" + stacktraceFromCatch + "\n```\n" + "\nIssueReportingExceptionHandler Created at:\n" + "\n```\n" + stacktraceFromHandlerInstantiation + "\n```\n"; - System.err.println(body); - System.err.println("\r\n\r\nBug Reported!\r\n\r\n"); - System.out.println(body); - System.out.println("\r\n\r\nBug Reported!\r\n\r\n"); + com.neuronrobotics.sdk.common.Log.error(body); + com.neuronrobotics.sdk.common.Log.error("\r\n\r\nBug Reported!\r\n\r\n"); + com.neuronrobotics.sdk.common.Log.error(body); + com.neuronrobotics.sdk.common.Log.error("\r\n\r\nBug Reported!\r\n\r\n"); GitHub github = PasswordManager.getGithub(); if (github == null || github.isAnonymous()) @@ -171,7 +171,7 @@ private void runReport(StackTraceElement[] element, String body, GitHub github) String source = getTitle(element); for (GHIssue i : issues) { - System.err.println("Issues are :" + i.getTitle()); + com.neuronrobotics.sdk.common.Log.error("Issues are :" + i.getTitle()); if (i.getTitle().contains(source)) { List comments = i.getComments(); // Check to see if i created this issue @@ -240,7 +240,7 @@ public void except(Throwable t) { return; } if (Platform.isFxApplicationThread()) { - System.err.println("Exception in Javafx thread! \n" + com.neuronrobotics.sdk.common.Log.error("Exception in Javafx thread! \n" + org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(t)); //throw new RuntimeException(t); return; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/TextToSpeech.java b/src/main/java/com/neuronrobotics/bowlerstudio/TextToSpeech.java index 4a80fd25..fa398fbd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/TextToSpeech.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/TextToSpeech.java @@ -81,7 +81,7 @@ public int speak(String text , float gainValue , boolean daemon , boolean join, Logger.getLogger(getClass().getName()).log(Level.WARNING, "IO Exception", ex); } catch (InterruptedException ex) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "Interrupted ", ex); - System.out.println("Speaking clean exit"); + com.neuronrobotics.sdk.common.Log.error("Speaking clean exit"); tts.cancel(); tts.interrupt(); return 1; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 6c360aad..7991aeb2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -34,7 +34,7 @@ public class AssetFactory { private AssetFactory() { } static { - System.out.println("AssetFactory loaded"); + com.neuronrobotics.sdk.common.Log.error("AssetFactory loaded"); //new RuntimeException().printStackTrace(); } @@ -105,7 +105,7 @@ public static Image loadAsset(String file) throws Exception { } cache.put(file, obj_img); - System.out.println("No image at " + file); + com.neuronrobotics.sdk.common.Log.error("No image at " + file); try { new RuntimeException().printStackTrace(); @@ -153,7 +153,7 @@ public static String getGitSource() throws Exception { } public static void setGitSource(String gitSource, String assetRepoBranch) throws Exception { - System.err.println("Assets from: " + gitSource + "#" + assetRepoBranch); + com.neuronrobotics.sdk.common.Log.error("Assets from: " + gitSource + "#" + assetRepoBranch); //new Exception().printStackTrace(); setAssetRepoBranch(assetRepoBranch); AssetFactory.gitSource = gitSource; @@ -162,7 +162,7 @@ public static void setGitSource(String gitSource, String assetRepoBranch) throws } public static void loadAllAssets() throws Exception { - System.err.println("Loading assets"); + com.neuronrobotics.sdk.common.Log.error("Loading assets"); List files; try { files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); @@ -170,7 +170,7 @@ public static void loadAllAssets() throws Exception { files = ScriptingEngine.filesInGit(gitSource); } for (String file : files) { - System.err.println("Loading asset file: "+file); + com.neuronrobotics.sdk.common.Log.error("Loading asset file: "+file); loadAsset(file); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index a61eace2..8bc1606e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -90,7 +90,7 @@ public static Object getObject(String paramsKey, String objectKey, Object defau getDatabase(); synchronized(database){ if (getParamMap(paramsKey).get(objectKey) == null) { - //System.err.println("Cant find: " + paramsKey + ":" + objectKey); + //com.neuronrobotics.sdk.common.Log.error("Cant find: " + paramsKey + ":" + objectKey); setObject(paramsKey, objectKey, defaultValue); } ret= getParamMap(paramsKey).get(objectKey); @@ -146,7 +146,7 @@ public static void save() { e.printStackTrace(); return; } - System.out.println("Saved "+f.getName()); + com.neuronrobotics.sdk.common.Log.error("Saved "+f.getName()); } @SuppressWarnings("unchecked") diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/StudioBuildInfo.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/StudioBuildInfo.java index b5c58f6f..6cba9805 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/StudioBuildInfo.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/StudioBuildInfo.java @@ -86,7 +86,7 @@ public static String getBuildDate() { } } catch (IOException ignored) { } - // System.out.println("Manifest:\n"+s); + // com.neuronrobotics.sdk.common.Log.error("Manifest:\n"+s); return ""; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 02bb5480..e79cd29a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -104,7 +104,7 @@ public ArrayList generateManufacturingParts(List totalAssembly , File try { allCadStl.add(makeStl(nameBase,manufactured));// default to stl }catch(Throwable t) { - System.err.println("Failed to generate "+part.getName()); + com.neuronrobotics.sdk.common.Log.error("Failed to generate "+part.getName()); t.printStackTrace(); } }else{ @@ -158,7 +158,7 @@ public ArrayList generateManufacturingParts(List totalAssembly , File } private File makeFreecad(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".FCStd"); - System.out.println("Writing "+blend.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) FreecadLoader.addCSGToFreeCAD( blend,tmp); return blend; @@ -168,20 +168,20 @@ private File makeStl(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".stl"); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); - System.out.println("Writing "+stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing "+stl.getAbsolutePath()); return stl; } private File makeObj(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".obj"); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toObjString()); - System.out.println("Writing "+stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing "+stl.getAbsolutePath()); return stl; } private File makeBlender(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".blend"); - System.out.println("Writing "+blend.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) BlenderLoader.toBlenderFile(tmp, blend); return blend; @@ -212,9 +212,9 @@ private File makeSvg(String nameBase, List currentCsg) throws IOException { } - System.out.println("Writing " + stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing " + stl.getAbsolutePath()); } catch (Throwable t) { - System.err.println("ERROR, NO pixelization engine availible for slicing"); + com.neuronrobotics.sdk.common.Log.error("ERROR, NO pixelization engine availible for slicing"); t.printStackTrace(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 3f906a5c..7cc3f237 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -635,7 +635,7 @@ public void run() { } } catch (Throwable t) { // rendering not availible - System.err.println("Exception for render engine " + base.getScriptingName()); + com.neuronrobotics.sdk.common.Log.error("Exception for render engine " + base.getScriptingName()); t.printStackTrace(); try { Thread.sleep(100); @@ -778,7 +778,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event) { if(cadGenerating) return; try { - System.err.println("Clearing the compiled CAD script for " + key); + com.neuronrobotics.sdk.common.Log.error("Clearing the compiled CAD script for " + key); cadScriptCache.remove(key); try { build(key, f); @@ -823,7 +823,7 @@ public void onConnect(BowlerAbstractDevice source) { } private void build(String key, File f) throws Throwable { try { - System.err.println( + com.neuronrobotics.sdk.common.Log.error( "Building the compiled CAD script for " + key + " " + base + " " + base.getScriptingName()); cadScriptCache.put(key, ScriptingEngine.inlineFileScriptRun(f, null)); } catch (Throwable e) { @@ -991,11 +991,11 @@ public ArrayList generateBody(MobileBase base, boolean clear) { } catch (Throwable e) { getUi().highlightException(getCadScriptFromMobileBase(device), e); } - System.out.println("Displaying Body"); + com.neuronrobotics.sdk.common.Log.error("Displaying Body"); setProgress(0.35); // clears old robot and places base getUi().setAllCSG(getBasetoCadMap().get(device), getCadScriptFromMobileBase(device)); - System.out.println("Rendering limbs"); + com.neuronrobotics.sdk.common.Log.error("Rendering limbs"); setProgress(0.4); ArrayList limbs = base.getAllDHChains(); double numLimbs = limbs.size(); @@ -1078,7 +1078,7 @@ private void set(MobileBase base, int limb, int link) { DHParameterKinematics dh = limbs.get(limb); double partsTotal = numLimbs * dh.getNumberOfLinks(); double progress = ((double) ((limb * dh.getNumberOfLinks()) + link)) / partsTotal; - // System.out.println("Cad progress " + progress + " limb " + limb + " link " + + // com.neuronrobotics.sdk.common.Log.error("Cad progress " + progress + " limb " + limb + " link " + // link + " total parts " + partsTotal); setProgress(0.333 + (2 * (progress / 3))); } @@ -1107,7 +1107,7 @@ public ArrayList generateStls(MobileBase base, File baseDirForFiles, boole return _generateStls(base, dir, kinematic); } - System.out.println("Found arrangeBed API in CAD engine"); + com.neuronrobotics.sdk.common.Log.error("Found arrangeBed API in CAD engine"); List totalAssembly = bed.arrangeBed(base); getUi().setAllCSG(totalAssembly, getCadScriptFromMobileBase(base)); @@ -1188,14 +1188,14 @@ public ArrayList _generateStls(MobileBase base, File baseDirForFiles, bool File stl = new File( dir.getAbsolutePath() + "/" + linkNum + name + "_limb_" + i + "_Part_" + j + ".stl"); - System.out.println("Writing STL for " + name+" to "+stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing STL for " + name+" to "+stl.getAbsolutePath()); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); allCadStl.add(stl); // totalAssembly.add(tmp); getUi().setAllCSG(totalAssembly, getCadScriptFromMobileBase(base)); set(base, i, j); }else { - System.err.println("ERROR "+parts.get(j).getName()+" has no link associated "); + com.neuronrobotics.sdk.common.Log.error("ERROR "+parts.get(j).getName()+" has no link associated "); } } } catch (Exception ex) { @@ -1395,7 +1395,7 @@ public void selectCsgByMobileBase(MobileBase base) { getUi().setSelectedCsg(csg); } catch (Exception ex) { // getUi().highlightException(null, ex); - System.err.println("Base not loaded yet"); + com.neuronrobotics.sdk.common.Log.error("Base not loaded yet"); } } @@ -1408,7 +1408,7 @@ public void selectCsgByLimb(MobileBase base, DHParameterKinematics limb) { getUi().setSelected((Affine) limb.getRootListener()); } catch (Exception ex) { // getUi().highlightException(null, ex); - System.err.println("Limb not loaded yet"); + com.neuronrobotics.sdk.common.Log.error("Limb not loaded yet"); } } @@ -1418,7 +1418,7 @@ public void selectCsgByLink(MobileBase base, LinkConfiguration limb) { ArrayList limCad = MobileBaseCadManager.get(base).getLinktoCadMap().get(limb); getUi().setSelectedCsg(limCad); } catch (Exception ex) { - System.err.println("Limb not loaded yet"); + com.neuronrobotics.sdk.common.Log.error("Limb not loaded yet"); } } public void generateCad() { @@ -1634,7 +1634,7 @@ public void setUi(IMobileBaseUI ui) { } public void setConfigurationViewerMode(boolean b) { - System.out.println("Setting config mode " + b); + com.neuronrobotics.sdk.common.Log.error("Setting config mode " + b); setConfigMode(b); for (MobileBaseCadManager m : slaves) { m.setConfigurationViewerMode(b); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java index 6caa9a63..5ac38d32 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java @@ -56,7 +56,7 @@ public void onFileDelete(File fileThatIsDeleted) { public void onFileChange(File fileThatChanged, WatchEvent event) { try { - System.out.println("D-H Solver changed, updating " + device.getScriptingName()); + com.neuronrobotics.sdk.common.Log.error("D-H Solver changed, updating " + device.getScriptingName()); DhInverseSolver d = (DhInverseSolver) ScriptingEngine.inlineFileScriptRun(c, null); device.setInverseSolver(d); } catch (Exception ex) { @@ -113,7 +113,7 @@ public void onFileDelete(File fileThatIsDeleted) { public void onFileChange(File fileThatChanged, WatchEvent event){ try { - System.out.println("Walking Gait Script changed, updating " + device.getScriptingName()); + com.neuronrobotics.sdk.common.Log.error("Walking Gait Script changed, updating " + device.getScriptingName()); defaultDriveEngine = (IDriveEngine) ScriptingEngine.inlineFileScriptRun(c, null); device.setWalkingDriveEngine(defaultDriveEngine); } catch (Exception ex) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java index 1cd1f243..ad485c4b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java @@ -41,7 +41,7 @@ public void processRaw(File f, String ttsLocation) throws Exception { + RhubarbVersion + "-" + os + "/rhubarb" + exeExtention); timeCodedVisemes = new ArrayList<>(); if (!exe.exists()) { - System.out.println("Downloading " + exe.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Downloading " + exe.getAbsolutePath()); String zipfileName = "Rhubarb-Lip-Sync-" + RhubarbVersion + "-" + os + ".zip"; String urlStr = "https://github.com/DanielSWolf/rhubarb-lip-sync/releases/download/v" + RhubarbVersion + "/" + zipfileName; @@ -73,7 +73,7 @@ public void processRaw(File f, String ttsLocation) throws Exception { Process process; String command = exe +" --dialogFile "+ttsLocation+" --machineReadable -f json " + f.getAbsolutePath(); - System.out.println(command); + com.neuronrobotics.sdk.common.Log.error(command); process = Runtime.getRuntime().exec(command); int exitCode = process.waitFor(); @@ -83,8 +83,8 @@ public void processRaw(File f, String ttsLocation) throws Exception { String utf8 = StandardCharsets.UTF_8.toString(); IOUtils.copy(is, writer, utf8); String result = writer.toString(); - // System.out.println(status); - // System.out.println(result); + // com.neuronrobotics.sdk.common.Log.error(status); + // com.neuronrobotics.sdk.common.Log.error(result); Type TT_mapStringString = new TypeToken>() { }.getType(); Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); @@ -99,7 +99,7 @@ public void processRaw(File f, String ttsLocation) throws Exception { // double percent = end / duration * 100.0; // AudioStatus val = AudioStatus.get(cue.get("value").toString().charAt(0)); -// System.out.println("End at " + percent + " " + val); +// com.neuronrobotics.sdk.common.Log.error("End at " + percent + " " + val); // HashMap map = new HashMap<>(); // map.put(val, percent); TimeCodedViseme map = new TimeCodedViseme(val, start, end, duration); @@ -112,7 +112,7 @@ public void processRaw(File f, String ttsLocation) throws Exception { public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) { File audio = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/tmp-tts.wav"); try { - System.out.println("Begin writing.."); + com.neuronrobotics.sdk.common.Log.error("Begin writing.."); AudioSystem.write(ais, AudioFileFormat.Type.WAVE, audio); ais = AudioSystem.getAudioInputStream(audio); File text = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/tmp-tts.txt"); @@ -127,7 +127,7 @@ public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) } // rhubarb! processRaw(audio, text.getAbsolutePath()); - System.out.println("Done writing!"); + com.neuronrobotics.sdk.common.Log.error("Done writing!"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java index 41638bf9..7034349b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java @@ -120,7 +120,7 @@ public static void setModelName(String modelName) { FileOutputStream fis = new FileOutputStream(zipfile); byte[] buffer = new byte[1024]; int count = 0; - System.out.println("Downloading Vosk Model " + getModelName()); + com.neuronrobotics.sdk.common.Log.error("Downloading Vosk Model " + getModelName()); while ((count = bis.read(buffer, 0, 1024)) != -1) { fis.write(buffer, 0, count); System.out.print("."); @@ -130,7 +130,7 @@ public static void setModelName(String modelName) { String source = zipfile.getAbsolutePath(); String destination = ScriptingEngine.getWorkspace().getAbsolutePath(); - System.out.println("Unzipping Vosk Model " + getModelName()); + com.neuronrobotics.sdk.common.Log.error("Unzipping Vosk Model " + getModelName()); ZipFile zipFile = new ZipFile(source); zipFile.extractAll(destination); } @@ -370,7 +370,7 @@ public void processRaw(File f, String ttsLocation) throws UnsupportedAudioFileEx BufferedWriter writer = new BufferedWriter(new FileWriter(json.getAbsolutePath())); writer.write(s); writer.close(); - System.out.println("Lip Sync data writen to " + json.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Lip Sync data writen to " + json.getAbsolutePath()); timeCodedVisemesCache.clear(); } catch (Throwable tr) { tr.printStackTrace(); @@ -398,7 +398,7 @@ public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) File audio = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/tmp-tts.wav"); try { long start = System.currentTimeMillis(); - System.out.println("Vosk Lip Sync Begin writing.."); + com.neuronrobotics.sdk.common.Log.error("Vosk Lip Sync Begin writing.."); AudioSystem.write(ais, AudioFileFormat.Type.WAVE, audio); ais = AudioSystem.getAudioInputStream(audio); File text = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/tmp-tts.txt"); @@ -413,7 +413,7 @@ public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) } // rhubarb! processRaw(audio, text.getAbsolutePath()); - System.out.println("Vosk Lip Sync Done writing! took " + (System.currentTimeMillis() - start)); + com.neuronrobotics.sdk.common.Log.error("Vosk Lip Sync Done writing! took " + (System.currentTimeMillis() - start)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -490,14 +490,14 @@ public static String promptFromMicrophone() throws IOException, LineUnavailableE // println "Listening..." } } else { - // System.out.println(recognizer.getPartialResult()); + // com.neuronrobotics.sdk.common.Log.error(recognizer.getPartialResult()); } } } catch (Throwable t) { t.printStackTrace(); } recognizer.close(); - // System.out.println(result); + // com.neuronrobotics.sdk.common.Log.error(result); microphone.close(); return result; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java index 8d40ecc3..00d9cf60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java @@ -106,7 +106,7 @@ public void setup(CollisionShape fallShape, Transform pose, double mass, Physics this.setCore(core); // setup the motion state for the ball - System.out.println("Starting Object at " + TransformFactory.bulletToNr(pose)); + com.neuronrobotics.sdk.common.Log.error("Starting Object at " + TransformFactory.bulletToNr(pose)); DefaultMotionState fallMotionState = new DefaultMotionState(pose); // This we're going to give mass so it responds to gravity Vector3f fallInertia = new Vector3f(0, 0, 0); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/HingeCSGPhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/HingeCSGPhysicsManager.java index 8bf7ab2a..1d0da038 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/HingeCSGPhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/HingeCSGPhysicsManager.java @@ -43,14 +43,14 @@ public void update(float timeStep) { getCore().remove(this); setConstraint(null); getCore().add(this); - System.out.println( + com.neuronrobotics.sdk.common.Log.error( "ERROR Link Broken, Strength: " + getMuscleStrength() + " applied impluse " + constraint .getAppliedImpulse()); } } else if (constraint != null && flagBroken) { constraint.enableAngularMotor(false, 0, 0); } - //System.out.println("Constraint = "+constraint+" controller= "+getController()+" broken= "+flagBroken); + //com.neuronrobotics.sdk.common.Log.error("Constraint = "+constraint+" controller= "+getController()+" broken= "+flagBroken); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MobileBasePhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MobileBasePhysicsManager.java index 3387b9e1..5d63506d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MobileBasePhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MobileBasePhysicsManager.java @@ -116,7 +116,7 @@ public MobileBasePhysicsManager(MobileBase base, ArrayList baseCad, Maxz = c.getMaxZ(); } } - // System.out.println("Minimum z = "+minz); + // com.neuronrobotics.sdk.common.Log.error("Minimum z = "+minz); Transform start = new Transform(); base.setFiducialToGlobalTransform(new TransformNR()); // TransformNR globe= base.getFiducialToGlobalTransform(); @@ -279,7 +279,7 @@ public void run() { ILinkListener ll = new ILinkListener() { @Override public void onLinkPositionUpdate(AbstractLink source, double engineeringUnitsValue) { - // System.out.println(" + // com.neuronrobotics.sdk.common.Log.error(" // value="+engineeringUnitsValue); hingePhysicsManager.setTarget(Math.toRadians(-engineeringUnitsValue)); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java index 9e24c8a9..9a5c885e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java @@ -147,7 +147,7 @@ public void controlStep(MuJoCoModelManager manager) { double target = Math.toRadians(link.getCurrentEngineeringUnits()) * gearRatios.get(link); // double error = target-positions.get(s); // double effort = error * kp; - // System.out.println("Actuator "+s+" position "+positions.get(s)+" effort + // com.neuronrobotics.sdk.common.Log.error("Actuator "+s+" position "+positions.get(s)+" effort // "+effort); setEfforts.put(s, target); } @@ -173,11 +173,11 @@ public void controlStep(MuJoCoModelManager manager) { rotxAcceleration, rotyAcceleration, rotzAcceleration, currentTimeMillis())); } catch (NullPointerException e) { // startup sync problems, ignore - System.out.println(e.getMessage()); + com.neuronrobotics.sdk.common.Log.error(e.getMessage()); } } - // System.out.println("Body "+s+" pose "+); + // com.neuronrobotics.sdk.common.Log.error("Body "+s+" pose "+); } } } @@ -316,7 +316,7 @@ public long stepAndWait() { if (Thread.interrupted()) throw new RuntimeException("Interrupted exception!"); } else { - // System.err.println("MuJoCo Real time broken, expected + // com.neuronrobotics.sdk.common.Log.error("MuJoCo Real time broken, expected // "+getTimestepMilliSeconds()+" took "+time); } if (Thread.interrupted()) @@ -364,7 +364,7 @@ public File getXMLFile() throws IOException, JAXBException { } else { tempFile = new File(workingDir.getAbsolutePath() + "/" + name + ".xml"); } - System.out.println("Writing " + tempFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Writing " + tempFile.getAbsolutePath()); Files.write(Paths.get(tempFile.getAbsolutePath()), xml.getBytes()); return tempFile; } @@ -546,7 +546,7 @@ public void loadBase(MobileBase cat, org.mujoco.xml.BodyarchType.Builder link double val = part.getMassKG(mass) * KgtoMujocoMass; geom.withMass(BigDecimal.valueOf(val)); } else { - System.out.println("\nUsing density for "+part.getName()); + com.neuronrobotics.sdk.common.Log.error("\nUsing density for "+part.getName()); } } @@ -614,7 +614,7 @@ public void loadBase(MobileBase cat, org.mujoco.xml.BodyarchType.Builder link double val = csg.getMassKG(linkMass/numPartsWithoutMassLink) * KgtoMujocoMass; geom.withMass(BigDecimal.valueOf(val)); } else { - System.out.println("\nUsing density for "+csg.getName()); + com.neuronrobotics.sdk.common.Log.error("\nUsing density for "+csg.getName()); } } } @@ -954,7 +954,7 @@ public void putCSGInAssets(String nameOfCSG, CSG hull, boolean isFree) throws IO Files.write(Paths.get(tempFile.getAbsolutePath()), obj.getBytes()); System.out.print(" " + (System.currentTimeMillis() - start+"\n")); } else { - System.out.println("Loading cache " + tempFile.getName()); + com.neuronrobotics.sdk.common.Log.error("Loading cache " + tempFile.getName()); } if (isFree) { asset.addTexture().withRgb1(toColorString(hull.getColor())).withRgb2(toColorString(hull.getColor())) @@ -998,7 +998,7 @@ public void waitForCad(MobileBaseCadManager cadMan, long start) { e.printStackTrace(); throw new RuntimeException(e); } - System.out.println("Waiting for cad to process " + percent); + com.neuronrobotics.sdk.common.Log.error("Waiting for cad to process " + percent); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsCore.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsCore.java index 0e18de32..2306cb47 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsCore.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsCore.java @@ -170,7 +170,7 @@ public void startPhysicsThread(int ms) { if (took < msTime) { ThreadUtil.wait((int) (msTime - took)); } else { - System.out.println("Real time physics broken: " + took); + com.neuronrobotics.sdk.common.Log.error("Real time physics broken: " + took); } } catch (Exception E) { E.printStackTrace(); @@ -201,7 +201,7 @@ public void step(float timeStep) { getDynamicsWorld().stepSimulation(timeStep, getSimulationSubSteps()); if ((((float) (System.currentTimeMillis() - startTime)) / 1000.0f) > timeStep) { - // System.out.println(" Compute took too long "+timeStep); + // com.neuronrobotics.sdk.common.Log.error(" Compute took too long "+timeStep); } for (IPhysicsManager o : getPhysicsObjects()) { o.update(timeStep); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java index 40ce000e..de551eb0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java @@ -65,9 +65,9 @@ public boolean init(File dir, ArrayList parts) { if (url == null) return false; File f = new File(dir.getAbsolutePath() + "/" + file); - System.out.println("Searching for printbed at "+f); + com.neuronrobotics.sdk.common.Log.error("Searching for printbed at "+f); if (f.exists()) { - System.out.println("Print Bed file found! "+f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Print Bed file found! "+f.getAbsolutePath()); String source; byte[] bytes; try { @@ -79,7 +79,7 @@ public boolean init(File dir, ArrayList parts) { } }else { - System.out.println("Print Bed NOT file found! "+f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Print Bed NOT file found! "+f.getAbsolutePath()); return false; } if (database == null) { @@ -104,7 +104,7 @@ public boolean init(File dir, ArrayList parts) { if(names.contains(name)) continue; names.add(name); - System.out.println(bit.getName() + " on " + index + " rot " + zrot + " y " + yval); + com.neuronrobotics.sdk.common.Log.error(bit.getName() + " on " + index + " rot " + zrot + " y " + yval); if (database.locations.get(name) == null) { database.locations.put(name, new TransformNR()); } @@ -169,7 +169,7 @@ public ArrayList makePrintBeds() { bed.addExportFormat(s); } if (bed != null) { - //System.out.println("Mesh fixing for "+name); + //com.neuronrobotics.sdk.common.Log.error("Mesh fixing for "+name); //bed=bed.union(bed); bed.setName(name); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java index 83cd2f47..d23b757f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java @@ -32,7 +32,7 @@ public PrintBedObject(String name, CSG part, double xMax, double xMin, double yM manip = new Manipulation(affine, new Vector3d(1, 1, 0), startPose); part.getStorage().set("manipulator",manip.map); part.setManipulator(affine); - manip.addSaveListener(() -> System.out.println("Saving PrintBedObject "+name)); + manip.addSaveListener(() -> com.neuronrobotics.sdk.common.Log.error("Saving PrintBedObject "+name)); checkBounds(); } public void addEventListener(Runnable r) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java index f9be1654..0de90769 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java @@ -38,14 +38,14 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } File ino = findIno(code); if (ino == null) { - //System.out.println("Error: no .ino file found!"); + //com.neuronrobotics.sdk.common.Log.error("Error: no .ino file found!"); return null; } commands.add("upload"); commands.add(ino.getAbsolutePath()); - //System.out.println("Arduino Load: \n"+execString); + //com.neuronrobotics.sdk.common.Log.error("Arduino Load: \n"+execString); Thread ret = DownloadManager.run(null, ino.getParentFile(), System.out, commands); ret.join(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java index bd22c24d..5845c65a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java @@ -39,10 +39,10 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio while ((s = stdInput.readLine()) != null || (e = errInput.readLine()) != null) { if (s != null) { back.add(s); - System.out.println(s); + com.neuronrobotics.sdk.common.Log.error(s); } if (e != null) - System.out.println(e); + com.neuronrobotics.sdk.common.Log.error(e); // } process.waitFor(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index a795cf72..7d30be73 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -52,7 +52,7 @@ public static void toBlenderFile(CSG stlIn,File blenderfile) throws IOException public static void toBlenderFile(File stl,File blenderfile) { - System.out.println("Converting to Blender file before loading"); + com.neuronrobotics.sdk.common.Log.error("Converting to Blender file before loading"); File stlIn; try { @@ -158,7 +158,7 @@ public void getDefaultContents(File source) { String absolutePath = source.getAbsolutePath(); File parent = new File(absolutePath).getParentFile(); if(source.exists()) { - System.out.println("Blender file exists, being overwritten to blank "+absolutePath); + com.neuronrobotics.sdk.common.Log.error("Blender file exists, being overwritten to blank "+absolutePath); source.delete(); } ArrayList args = new ArrayList<>(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java index 547aa085..772fac1b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java @@ -72,7 +72,7 @@ public Object inlineScriptRun(File code, ArrayList args) { // TODO Auto-generated catch block e1.printStackTrace(); } - // System.out.println("Clojure returned of type="+ret.getClass()+" value="+ret); + // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index d15ddd3c..89b3e1d9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -105,13 +105,13 @@ public static File getTmpSTL(CSG stlIn) throws IOException { @Override public boolean get(String name, String url) { - System.out.println("Command line mode, assuming yes to downloading \n" + name + " \nfrom \n" + url); + com.neuronrobotics.sdk.common.Log.error("Command line mode, assuming yes to downloading \n" + name + " \nfrom \n" + url); return true; } @Override public void onInstallFail(String url) { - System.out.println("Plugin needs to be installed from "+url); + com.neuronrobotics.sdk.common.Log.error("Plugin needs to be installed from "+url); } }; private static GitLogProgressMonitor psudoSplash; @@ -158,7 +158,7 @@ public static void legacySystemRun(Map envincoming, File dir, Pr if (envincoming != null) { envir.putAll(envincoming); for (String s : envincoming.keySet()) { - System.out.println("Environment var set: " + s + " to " + envir.get(s)); + com.neuronrobotics.sdk.common.Log.error("Environment var set: " + s + " to " + envir.get(s)); } } // setting the directory @@ -190,7 +190,7 @@ public static void legacySystemRun(Map envincoming, File dir, Pr int ev = process.exitValue(); // out.println("Running "+commands); if (ev != 0) { - System.out.println("ERROR PROCESS Process exited with " + ev); + com.neuronrobotics.sdk.common.Log.error("ERROR PROCESS Process exited with " + ev); } while (process.isAlive()) { Thread.sleep(100); @@ -281,7 +281,7 @@ public static Map getEnvironment(String exeType) { Map environment; Object o = vm.get("environment"); if (o != null) { - System.out.println("Environment found for " + exeType + " on " + key); + com.neuronrobotics.sdk.common.Log.error("Environment found for " + exeType + " on " + key); return (Map) o; } @@ -332,7 +332,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String Map vm = (Map) database.get(key); if (vm != null) { String targetdir = exeType; - System.out.println("Configuration found for " + exeType + " on " + key); + com.neuronrobotics.sdk.common.Log.error("Configuration found for " + exeType + " on " + key); String baseURL = vm.get("url").toString(); String type = vm.get("type").toString(); String name = vm.get("name").toString(); @@ -377,7 +377,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String File jvmArchive = download("", jvmURL, 800000000, bindir, name + "." + type, exeType); if (dest.exists()) { - System.out.println("Erasing stale dir " + dest.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Erasing stale dir " + dest.getAbsolutePath()); deleteDirectory(dest); } if (type.toLowerCase().contains("zip")) { @@ -415,7 +415,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String Object configurations = database.get("Meta-Configuration"); if (configurations != null) { List configs = (List) configurations; - System.out.println("Got Configurations " + configs.size()); + com.neuronrobotics.sdk.common.Log.error("Got Configurations " + configs.size()); ev = -1; IExternalEditor errorcheckerEditor = new IExternalEditor() { @@ -457,7 +457,7 @@ public Image getImage() { } }; for (int i = 0; i < configs.size(); i++) { - System.out.println("Running " + exeType + " Configuration " + (i + 1) + " of " + com.neuronrobotics.sdk.common.Log.error("Running " + exeType + " Configuration " + (i + 1) + " of " + configs.size()); ArrayList toRun = new ArrayList<>(); toRun.add(bindir + targetdir + "/" + configexe); @@ -467,7 +467,7 @@ public Image getImage() { } // = +" "+configs.get(i); - // System.out.println(toRun); + // com.neuronrobotics.sdk.common.Log.error(toRun); Thread thread = run(errorcheckerEditor, new File(bindir), System.out, toRun); thread.join(); @@ -480,7 +480,7 @@ public Image getImage() { } } else { - System.out.println("Not extraction, Application exists " + cmd); + com.neuronrobotics.sdk.common.Log.error("Not extraction, Application exists " + cmd); } return new File(cmd); @@ -576,7 +576,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { after.removeAll(before); Object[] array = after.toArray(); String newMount = (String) array[0]; - System.out.println("Extracted " + jvmArchive.getAbsolutePath() + " is mounted at " + newMount); + com.neuronrobotics.sdk.common.Log.error("Extracted " + jvmArchive.getAbsolutePath() + " is mounted at " + newMount); // asr restore --source "$MOUNT_POINT" --target "$DEST_PATH" --erase --noprompt if (!location.exists()) { location.mkdirs(); @@ -594,7 +594,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { return; } // wait for the mount to finish - System.out.println("Extracted " + jvmArchive.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Extracted " + jvmArchive.getAbsolutePath()); } @@ -609,7 +609,7 @@ public static boolean isExecutable(ZipArchiveEntry entry) { private static void extract7zSystemCall(String archivePath, String outputPath) { File outputDir = new File(outputPath); if (outputDir.exists()) { - System.err.println("Deleting partial extraction, using system 7z"); + com.neuronrobotics.sdk.common.Log.error("Deleting partial extraction, using system 7z"); deleteDirectory(outputDir); } outputDir.mkdirs(); @@ -637,8 +637,8 @@ public static void extract7zArchive(String archivePath, String outputPath) { try (RandomAccessFile randomAccessFile = new RandomAccessFile(archivePath, "r"); IInArchive inArchive = SevenZip.openInArchive(null, new RandomAccessFileInStream(randomAccessFile))) { - System.out.println("Archive size: " + randomAccessFile.length() + " bytes"); - System.out.println("Items in archive: " + inArchive.getNumberOfItems()); + com.neuronrobotics.sdk.common.Log.error("Archive size: " + randomAccessFile.length() + " bytes"); + com.neuronrobotics.sdk.common.Log.error("Items in archive: " + inArchive.getNumberOfItems()); for (int i = 0; i < inArchive.getNumberOfItems(); i++) { Boolean isFolder = (Boolean) inArchive.getProperty(i, PropID.IS_FOLDER); @@ -647,10 +647,10 @@ public static void extract7zArchive(String archivePath, String outputPath) { } } - System.out.println("Extraction completed successfully."); + com.neuronrobotics.sdk.common.Log.error("Extraction completed successfully."); } catch (Exception e) { - System.err.println("Error extracting archive: " + e.getMessage()); + com.neuronrobotics.sdk.common.Log.error("Error extracting archive: " + e.getMessage()); e.printStackTrace(); } } @@ -683,9 +683,9 @@ public int write(byte[] data) throws SevenZipException { } downloadEvents.finishDownload(); if (result == ExtractOperationResult.OK) { - System.out.println("Extracted: " + path); + com.neuronrobotics.sdk.common.Log.error("Extracted: " + path); } else { - System.err.println("Error extracting " + path + ": " + result); + com.neuronrobotics.sdk.common.Log.error("Error extracting " + path + ": " + result); } } @@ -704,17 +704,17 @@ public int write(byte[] data) throws SevenZipException { * (entry.isDirectory()) { continue; } File outputFile = new File(outputDir, * entry.getName()); File parent = outputFile.getParentFile(); if * (!parent.exists()) { parent.mkdirs(); } - * System.out.println("Inflating 7z "+outputFile.getAbsolutePath()); try + * com.neuronrobotics.sdk.common.Log.error("Inflating 7z "+outputFile.getAbsolutePath()); try * (FileOutputStream out = new FileOutputStream(outputFile)) { byte[] content = * new byte[(int) entry.getSize()]; sevenZFile.read(content, 0, content.length); * out.write(content); } } - * System.out.println("Extraction completed successfully."); } catch + * com.neuronrobotics.sdk.common.Log.error("Extraction completed successfully."); } catch * (IOException e) { e.printStackTrace(System.out); } } * * } */ public static void unzip(File path, String dir) throws Exception { - System.out.println("Unzipping " + path.getName() + " into " + dir); + com.neuronrobotics.sdk.common.Log.error("Unzipping " + path.getName() + " into " + dir); String fileBaseName = FilenameUtils.getBaseName(path.getName().toString()); Path destFolderPath = new File(dir).toPath(); @@ -735,7 +735,7 @@ public static void unzip(File path, String dir) throws Exception { String text = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)) .lines().collect(Collectors.joining("\n")); Path target = Paths.get(".", text); - System.out.println("Creating symlink " + entryPath + " with " + target); + com.neuronrobotics.sdk.common.Log.error("Creating symlink " + entryPath + " with " + target); Files.createSymbolicLink(entryPath, target); continue; @@ -745,7 +745,7 @@ public static void unzip(File path, String dir) throws Exception { } try (OutputStream out = new FileOutputStream(entryPath.toFile())) { IOUtils.copy(in, out); - System.out.println("Inflating " + entryPath); + com.neuronrobotics.sdk.common.Log.error("Inflating " + entryPath); } if (isExecutable(entry)) { @@ -792,13 +792,13 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc try { Files.createSymbolicLink(outPath, target); } catch (IOException | UnsupportedOperationException e) { - System.err.println("Failed to create symlink " + outPath + ". Copying target instead."); + com.neuronrobotics.sdk.common.Log.error("Failed to create symlink " + outPath + ". Copying target instead."); // Fallback: copy the target file instead Path resolvedTarget = outPath.getParent().resolve(target).normalize(); if (Files.exists(resolvedTarget)) { Files.copy(resolvedTarget, outPath); } else { - System.err.println("Symlink target does not exist: " + resolvedTarget); + com.neuronrobotics.sdk.common.Log.error("Symlink target does not exist: " + resolvedTarget); } } } else if (entry.isDirectory()) { @@ -832,7 +832,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc } public static void untar(File tarFile, String dir) throws Exception { - System.out.println("Untaring " + tarFile.getName() + " into " + dir); + com.neuronrobotics.sdk.common.Log.error("Untaring " + tarFile.getName() + " into " + dir); File dest = new File(dir); dest.mkdir(); @@ -848,7 +848,7 @@ public static void untar(File tarFile, String dir) throws Exception { // tarIn is a TarArchiveInputStream while (tarEntry != null) {// create a file with the same name as the tarEntry File destPath = new File(dest.toString() + System.getProperty("file.separator") + tarEntry.getName()); - System.out.println("Inflating: " + destPath.getCanonicalPath()); + com.neuronrobotics.sdk.common.Log.error("Inflating: " + destPath.getCanonicalPath()); if (tarEntry.isDirectory()) { destPath.mkdirs(); } else { @@ -951,8 +951,8 @@ public void process(double percent) { if (!folder.exists() || !exe.exists()) { if (approval.get(downloadName, downloadJsonURL)) { - System.out.println("Start Downloading " + filename); - System.out.println("From "+downloadJsonURL); + com.neuronrobotics.sdk.common.Log.error("Start Downloading " + filename); + com.neuronrobotics.sdk.common.Log.error("From "+downloadJsonURL); } else { pis.close(); @@ -972,11 +972,11 @@ public void process(double percent) { } fileOutputStream.close(); pis.close(); - System.out.println("Finished downloading " + filename); + com.neuronrobotics.sdk.common.Log.error("Finished downloading " + filename); psudoSplash.onUpdate((int) (1 * 100)+" % " +filename , null); downloadEvents.finishDownload(); } else { - System.out.println("Not downloading, it existst " + filename); + com.neuronrobotics.sdk.common.Log.error("Not downloading, it existst " + filename); } return exe; } @@ -1010,11 +1010,11 @@ public static String delim() { // File f = getRunExecutable("eclipse",null); // String ws = EclipseExternalEditor.getEclipseWorkspace(); // if(f.exists()) { -// System.out.println("Executable retrived:\n"+f.getAbsolutePath()); +// com.neuronrobotics.sdk.common.Log.error("Executable retrived:\n"+f.getAbsolutePath()); // run(getEnvironment("eclipse"),null,f.getParentFile(), System.err,Arrays.asList(f.getAbsolutePath(),"-data", ws)); // } // else -// System.out.println("Failed to load file!\n"+f.getAbsolutePath()); +// com.neuronrobotics.sdk.common.Log.error("Failed to load file!\n"+f.getAbsolutePath()); // } public static IApprovalForDownload getApproval() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index 1e38e47d..e4ea89c7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -305,7 +305,7 @@ public static void update(Map vm) throws MalformedURLException, continue; } String name = assetName.replace("."+type, ""); - System.out.println("Updating Freecad assets to "+name); + com.neuronrobotics.sdk.common.Log.error("Updating Freecad assets to "+name); vm.put("name",name); if(isMac()) continue; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 18fa67f6..4545d020 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -39,14 +39,14 @@ private Object inline(Object code, ArrayList args) throws Exception { // } catch (Throwable e) { // //throw e; // } -//// System.err.println("Device " + bad.getScriptingName() + " is " +//// com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " //// + bad); // } binding.setVariable("args", args); GroovyShell shell = new GroovyShell(GroovyHelper.class .getClassLoader(), binding, cc); - //System.out.println(code + "\n\nStart\n\n"); + //com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); Script script; if (String.class.isInstance(code)) { script = shell.parse((String) code); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java index 03d03a66..89a03af6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java @@ -45,7 +45,7 @@ public Object inlineScriptRun(String code, ArrayList args) { // // TODO Auto-generated catch block // e.printStackTrace(); // } -// System.err.println("Device " + bad.getScriptingName() + " is " +// com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " // + bad); // } interp.set("args", args); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java index a9442065..ad18cf2e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java @@ -39,7 +39,7 @@ public Object inlineScriptRun(File code, ArrayList args) { // TODO Auto-generated catch block e1.printStackTrace(); } - // System.out.println("Clojure returned of type="+ret.getClass()+" value="+ret); + // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index be97a29e..419c50d8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -201,7 +201,7 @@ public static List flaten(File f, Class type, ArrayList args) public static void setWorkspace(File file) { workspace = file; - System.err.println("Workspace: " + workspace.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Workspace: " + workspace.getAbsolutePath()); if (!workspace.exists()) { workspace.mkdir(); } @@ -319,10 +319,10 @@ public void update(int completed) { String str = format + "% " + stage + " " + reponame + " " + tasks + " of task " + type; if (timeofLastUpdate + 500 < System.currentTimeMillis()) { if (printProgress) - System.out.println(str); + com.neuronrobotics.sdk.common.Log.error(str); timeofLastUpdate = System.currentTimeMillis(); } - // System.err.println(str); + // com.neuronrobotics.sdk.common.Log.error(str); for (GitLogProgressMonitor l : logListeners) { l.onUpdate(str, e); @@ -343,7 +343,7 @@ public boolean isCancelled() { public void endTask() { String string = "100% " + stage + " " + reponame + " " + type; if (printProgress) - System.out.println(string); + com.neuronrobotics.sdk.common.Log.error(string); for (GitLogProgressMonitor l : logListeners) { l.onUpdate(string, e); } @@ -352,7 +352,7 @@ public void endTask() { @Override public void beginTask(String title, int totalWork) { stage = title; - // System.out.println("Setting totalWork to "+totalWork+" for stage "+stage); + // com.neuronrobotics.sdk.common.Log.error("Setting totalWork to "+totalWork+" for stage "+stage); total = totalWork; sum = 0; tasks += 1; @@ -420,12 +420,12 @@ public static Git openGit(Repository localRepo) { int i = 0; while (gitOpenTimeout.containsKey(g)) { - System.out.println("Git is locked by other process, blocking " + com.neuronrobotics.sdk.common.Log.error("Git is locked by other process, blocking " + localRepo.getDirectory().getAbsolutePath()); - System.out.println("Git locked " + t.ref); + com.neuronrobotics.sdk.common.Log.error("Git locked " + t.ref); if (i > 3) { t.getException().printStackTrace(System.out); - System.out.println("Blocking process: "); + com.neuronrobotics.sdk.common.Log.error("Blocking process: "); new Exception().printStackTrace(System.out); } @@ -514,7 +514,7 @@ public static void removeOnCommitEventListeners(String url, Runnable event) { public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception { if (filesRun.get(code.getName()) == null) { filesRun.put(code.getName(), code); - // System.out.println("Loading "+code.getAbsolutePath()); + // com.neuronrobotics.sdk.common.Log.error("Loading "+code.getAbsolutePath()); } if (langauges.get(shellTypeStorage) != null) { @@ -576,7 +576,7 @@ public static void createSymlinkInDocuments(File appDataDir) throws IOException // Create the symlink Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); - System.out.println("Symlink created: " + symlinkPath); + com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); } public static File getWorkingDirectory() { String relative = Paths.get(System.getProperty("user.home"), "Documents").toString(); @@ -677,11 +677,11 @@ private static List returnFirstGist(String html) { Elements links = doc.select("script"); for (int i = 0; i < links.size(); i++) { Element e = links.get(i); - /// System.out.println("Found gist embed: "+e); + /// com.neuronrobotics.sdk.common.Log.error("Found gist embed: "+e); Attributes n = e.attributes(); String jSSource = n.get("src"); if (jSSource.contains("https://gist.github.com/")) { - // System.out.println("Source = "+jSSource); + // com.neuronrobotics.sdk.common.Log.error("Source = "+jSSource); String slug = jSSource; String js = slug.split(".js")[0]; String[] id = js.split("/"); @@ -723,7 +723,7 @@ public static List getCurrentGist(String addr, Object engine) { */ public static void waitForLogin() throws IOException, InvalidRemoteException, TransportException, GitAPIException { if (!PasswordManager.hasNetwork()) { - System.err.println("No network, cant log in"); + com.neuronrobotics.sdk.common.Log.error("No network, cant log in"); return; } try { @@ -731,18 +731,18 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr if (PasswordManager.loggedIn()) return; if (PasswordManager.getLoginID() == null) { - System.err.println("No login ID found!"); + com.neuronrobotics.sdk.common.Log.error("No login ID found!"); return; } if (PasswordManager.getPassword() == null) { - System.err.println("No login api key found!"); + com.neuronrobotics.sdk.common.Log.error("No login api key found!"); return; } - System.err.println("Performing Login"); + com.neuronrobotics.sdk.common.Log.error("Performing Login"); PasswordManager.waitForLogin(); if (!PasswordManager.loggedIn()) { - System.err.println("\nERROR: Wrong Password!\n"); + com.neuronrobotics.sdk.common.Log.error("\nERROR: Wrong Password!\n"); login(); } @@ -760,11 +760,11 @@ public static void waitForRepo(String remoteURI, String reason) { GitTimeoutThread t = gitOpenTimeout.get(g); if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) { - System.err.println("\n\n\nPaused " + reason + " by another thread, waiting for repo " + remoteURI); + com.neuronrobotics.sdk.common.Log.error("\n\n\nPaused " + reason + " by another thread, waiting for repo " + remoteURI); new Exception().printStackTrace(System.err); - System.err.println("Paused by:"); + com.neuronrobotics.sdk.common.Log.error("Paused by:"); t.getException().printStackTrace(System.err); - System.err.println("\n\n\n"); + com.neuronrobotics.sdk.common.Log.error("\n\n\n"); } } @@ -800,25 +800,25 @@ private static void deleteFolder(File folder) { try { FileChangeWatcher.notifyOfDelete(f); FileChangeWatcher.close(f); - System.out.println("Deleting File " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Deleting File " + f.getAbsolutePath()); if (!f.delete()) { - System.err.println("File failed to delete! " + f); + com.neuronrobotics.sdk.common.Log.error("File failed to delete! " + f); } } catch (Throwable t) { t.printStackTrace(); } - // System.out.println("Deleting " + f.getAbsolutePath()); + // com.neuronrobotics.sdk.common.Log.error("Deleting " + f.getAbsolutePath()); } } } try { - System.out.println("Deleting Folder " + folder.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Deleting Folder " + folder.getAbsolutePath()); folder.delete(); } catch (Throwable t) { t.printStackTrace(); } if (folder.exists()) { - System.err.println("Folder failed to delete! " + folder); + com.neuronrobotics.sdk.common.Log.error("Folder failed to delete! " + folder); deleteFolder(folder); } @@ -913,10 +913,10 @@ private static boolean ensureExistance(File desired) throws IOException { File parent = desired.getParentFile(); if (!parent.exists()) { parent.mkdirs(); - System.err.println("Creating " + parent.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Creating " + parent.getAbsolutePath()); } if (!desired.exists() && parent.exists()) { - System.err.println("Creating " + desired.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Creating " + desired.getAbsolutePath()); desired.createNewFile(); createdFlag = true; } @@ -1067,7 +1067,7 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); closeGit(git); - System.out.println("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); + com.neuronrobotics.sdk.common.Log.error("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); } catch (Exception ex) { ex.printStackTrace(); closeGit(git); @@ -1083,7 +1083,7 @@ public static String[] codeFromGit(String id, String FileName) throws Exception File targetFile = fileFromGit(id, FileName); if (targetFile.exists()) { - // System.err.println("Loading file: + // com.neuronrobotics.sdk.common.Log.error("Loading file: // "+targetFile.getAbsoluteFile()); // Target file is ready to go String text = new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())), @@ -1099,7 +1099,7 @@ private static String[] codeFromGistID(String id, String FileName) throws Except File targetFile = fileFromGit(giturl, FileName); if (targetFile.exists()) { - System.err.println("Gist at GIT : " + giturl); + com.neuronrobotics.sdk.common.Log.error("Gist at GIT : " + giturl); // Target file is ready to go String text = new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())), StandardCharsets.UTF_8); @@ -1150,7 +1150,7 @@ public static File uriToFile(String remoteURI) { File gistDir = new File(getWorkspace().getAbsolutePath() + "/gitcache/" + gitSplit + "/.git"); return gistDir; } catch (ArrayIndexOutOfBoundsException ex) { - System.err.println("Failed to parse " + remoteURI); + com.neuronrobotics.sdk.common.Log.error("Failed to parse " + remoteURI); throw ex; } @@ -1302,9 +1302,9 @@ private static void newBranchLocal(String newBranch, String remoteURI, Git git, setName.setForce(true); } setName.call(); - System.out.println("Created new branch " + remoteURI + "\t\t" + newBranch); + com.neuronrobotics.sdk.common.Log.error("Created new branch " + remoteURI + "\t\t" + newBranch); } catch (org.eclipse.jgit.api.errors.RefNotFoundException ex) { - System.err.println("ERROR Creating " + newBranch + " in " + remoteURI); + com.neuronrobotics.sdk.common.Log.error("ERROR Creating " + newBranch + " in " + remoteURI); ex.printStackTrace(); } catch (org.eclipse.jgit.api.errors.RefAlreadyExistsException ex) { // just checkout the existing branch then @@ -1333,7 +1333,7 @@ private static boolean hasAtLeastOneReference(Git git) throws Exception { if (ref.getObjectId() != null) { List branchList = listBranches(remoteURI, git); if (branchList.size() > 0) { - // System.out.println("Found "+branchList.size()+" + // com.neuronrobotics.sdk.common.Log.error("Found "+branchList.size()+" // branches"); return true; } @@ -1364,10 +1364,10 @@ public static List listBranches(String remoteURI) throws Exception { public static List listBranches(String remoteURI, Git git) throws Exception { // https://gist.github.com/0e6454891a3b3f7c8f28.git - // System.out.println("Listing references from: "+remoteURI); - // System.out.println(" branch: "+getFullBranch(remoteURI)); + // com.neuronrobotics.sdk.common.Log.error("Listing references from: "+remoteURI); + // com.neuronrobotics.sdk.common.Log.error(" branch: "+getFullBranch(remoteURI)); List list = git.branchList().setListMode(ListMode.ALL).call(); - // System.out.println(" size : "+list.size()); + // com.neuronrobotics.sdk.common.Log.error(" size : "+list.size()); return list; } @@ -1397,7 +1397,7 @@ public static List listLocalBranchNames(String remoteURI) throws Excepti List list = listLocalBranches(remoteURI); for (Ref ref : list) { - // System.out.println("Branch: " + ref + " " + ref.getName() + " " + + // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + ref.getName() + " " + // ref.getObjectId().getName()); branchNames.add(ref.getName()); } @@ -1409,7 +1409,7 @@ public static List listBranchNames(String remoteURI) throws Exception { List list = listBranches(remoteURI); for (Ref ref : list) { - // System.out.println("Branch: " + ref + " " + ref.getName() + " " + + // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + ref.getName() + " " + // ref.getObjectId().getName()); branchNames.add(ref.getName()); } @@ -1566,7 +1566,7 @@ public static void checkoutCommit(String remoteURI, String branch, String commit waitForRepo(remoteURI, "checkoutCommit"); File gitRepoFile = ScriptingEngine.uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - System.err.println("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } Repository localRepo = new FileRepository(gitRepoFile); @@ -1605,7 +1605,7 @@ public static void checkout(String remoteURI, String branch) // cloneRepo(remoteURI, branch); File gitRepoFile = uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - System.err.println("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } @@ -1617,7 +1617,7 @@ public static void checkout(String remoteURI, String branch) branch = currentBranch; if (currentBranch.length() < branch.length() || !currentBranch.endsWith(branch)) { - System.err.println("Current branch is " + currentBranch + " need " + branch); + com.neuronrobotics.sdk.common.Log.error("Current branch is " + currentBranch + " need " + branch); Git git = null; try { @@ -1625,7 +1625,7 @@ public static void checkout(String remoteURI, String branch) git = openGit(localRepo); for (Ref R : branches) { if (R.getName().endsWith(branch)) { - System.err.println("\nFound upstream " + R.getName()); + com.neuronrobotics.sdk.common.Log.error("\nFound upstream " + R.getName()); shallowCheckout(remoteURI, branch, git); closeGit(git); } @@ -1701,9 +1701,9 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti Status stat = git.status().call(); Set changed = stat.getModified(); if (changed.size() > 0) { - System.out.println("Modified "); + com.neuronrobotics.sdk.common.Log.error("Modified "); for (String p : changed) { - System.out.println("Modified Conflict with: " + p); + com.neuronrobotics.sdk.common.Log.error("Modified Conflict with: " + p); byte[] bytes; String content = ""; try { @@ -1726,9 +1726,9 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti } Set untracked = stat.getUntracked(); if (untracked.size() > 0) { - System.out.println("Untracked "); + com.neuronrobotics.sdk.common.Log.error("Untracked "); for (String p : untracked) { - System.out.println("Untracked Conflict with: " + p); + com.neuronrobotics.sdk.common.Log.error("Untracked Conflict with: " + p); File f = fileFromGit(remoteURI, p); f.delete(); } @@ -1758,10 +1758,10 @@ public static File cloneRepo(String remoteURI, String branch) { if (!hasNetwork()) return null;// No login info means there is no way to publish waitForRepo(remoteURI, "cloneRepo"); - System.out.println("Cloning files from: " + remoteURI); + com.neuronrobotics.sdk.common.Log.error("Cloning files from: " + remoteURI); if (branch != null) - System.out.println(" branch: " + branch); - System.out.println(" to: " + localPath); + com.neuronrobotics.sdk.common.Log.error(" branch: " + branch); + com.neuronrobotics.sdk.common.Log.error(" to: " + localPath); Throwable ex = null; // Clone the repo Git git = null; @@ -1816,7 +1816,7 @@ public static String locateGitUrl(File f, Git ref) throws IOException { File gitRepoFile = new File(f.getAbsolutePath()); while (gitRepoFile != null) { if (new File(gitRepoFile.getAbsolutePath() + "/.git/config").exists()) { - // System.err.println("Fount git repo for file: "+gitRepoFile); + // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: "+gitRepoFile); Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile() + "/.git"); Git git = ref; if (git == null) @@ -1840,7 +1840,7 @@ public static Git locateGit(File f) throws IOException { gitRepoFile = gitRepoFile.getParentFile(); if (gitRepoFile != null) if (new File(gitRepoFile.getAbsolutePath() + "/.git/config").exists()) { - // System.err.println("Fount git repo for file: "+gitRepoFile); + // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: "+gitRepoFile); Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile() + "/.git"); return openGit(localRepo); @@ -2045,7 +2045,7 @@ public static String fork(String sourceURL, String newRepoName, String newRepoDe } catch (org.kohsuke.github.HttpException ex) { if (ex.getMessage().contains("name already exists on this account")) { repository = github.getRepository(PasswordManager.getLoginID() + "/" + newRepoName); - System.out.println("Repo exists!"); + com.neuronrobotics.sdk.common.Log.error("Repo exists!"); return repository.getHttpTransportUrl(); } throw ex; @@ -2158,7 +2158,7 @@ public static String urlToString(URL htmlUrl) { public static String urlToGist(URL htmlUrl) { String externalForm = urlToString(htmlUrl); - System.out.println(externalForm); + com.neuronrobotics.sdk.common.Log.error(externalForm); return ScriptingEngine.urlToGist(externalForm); } @@ -2238,7 +2238,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi if (newFileCode == null) newFileCode = new String[] { "" }; if (newFileCode[0].length() < 10) { - System.out.println("Copy Content to " + targetGit + "/" + targetFilename); + com.neuronrobotics.sdk.common.Log.error("Copy Content to " + targetGit + "/" + targetFilename); ScriptingEngine.pushCodeToGit(targetGit, ScriptingEngine.getFullBranch(targetGit), targetFilename, WalkingEngine[0], "copy file content"); } @@ -2423,7 +2423,7 @@ public int compare(String object1, String object2) { public static boolean tagExists(String remoteURI, String newTag) { List tags = getAllTags(remoteURI); for (String s : tags) { - System.out.println("Checking " + newTag + " against " + s); + com.neuronrobotics.sdk.common.Log.error("Checking " + newTag + " against " + s); if (s.contentEquals(newTag)) { return true; } @@ -2432,9 +2432,9 @@ public static boolean tagExists(String remoteURI, String newTag) { } public static void tagRepo(String remoteURI, String newTag) { - System.out.println("Tagging " + remoteURI + " at " + newTag); + com.neuronrobotics.sdk.common.Log.error("Tagging " + remoteURI + " at " + newTag); if (tagExists(remoteURI, newTag)) { - System.out.println("ERROR! Tag exists " + remoteURI + "@" + newTag); + com.neuronrobotics.sdk.common.Log.error("ERROR! Tag exists " + remoteURI + "@" + newTag); return; } Git git = openGit(remoteURI); @@ -2476,7 +2476,7 @@ public static void ignore(String url, String filepattern) throws Exception { String line = reader.readLine(); while (line != null) { if (line.contains(filepattern)) { - System.out.println("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); reader.close(); return; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index 376982dd..1e52f2c8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -22,7 +22,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio SVGLoad s = new SVGLoad(code.toURI()); return run(s); }catch(Exception e) { - System.err.println("SVG had error, attempting to fix "+code.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("SVG had error, attempting to fix "+code.getAbsolutePath()); File tmp=GeometrySimplification.simplifySVG(code); SVGLoad s = new SVGLoad(tmp.toURI()); return run(s); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index df2222d9..c6a93ee3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -55,7 +55,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); - System.out.println("Initial Loading " + getStrValue()); + com.neuronrobotics.sdk.common.Log.error("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); @@ -140,7 +140,7 @@ private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) try { File file = getFile(); String fileLocation = file.getAbsolutePath(); - System.out.println("Regenerating " + fileLocation); + com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); return processGiven(csg1, i, parameter, name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e69b77b3..78fe9690 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -145,7 +145,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) return null; if (isRegenerating() || isOperationRunning()) { - System.out.println("Opperation is running, ignoring regen"); + com.neuronrobotics.sdk.common.Log.error("Opperation is running, ignoring regen"); return null; } int endIndex = getCurrentIndex(); @@ -157,7 +157,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { opperationRunner = new Thread(() -> { opperationRunner.setName("Regeneration Thread"); setRegenerating(true); - // System.out.println("Regenerating Object from "+source.getType()); + // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from "+source.getType()); int opIndex = 0; for (int i = 0; i < size; i++) { ICaDoodleOpperation op = opperations.get(i); @@ -171,7 +171,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { for (; getCurrentIndex() < size;) { setCurrentIndex(getCurrentIndex() + 1); setPercentInitialized(((double)getCurrentIndex())/size); - // System.out.println("Regenerating "+currentIndex); + // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); storeResultInCache(op, process); @@ -260,7 +260,7 @@ private void pruneForward() { ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); - System.err.println("Pruning forward here!"); + com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); } private void storeResultInCache(ICaDoodleOpperation op, List process) { @@ -290,7 +290,7 @@ private void updateCurrentFromCache() { ICaDoodleOpperation key = getCurrentOpperation(); if (key == null) return; - System.out.println("Current opperation results: " + key.getType()); + com.neuronrobotics.sdk.common.Log.error("Current opperation results: " + key.getType()); setCurrentState(key, getCurrentState()); } @@ -403,10 +403,10 @@ public File save() throws IOException { BufferedImage bufferedImage = SwingFXUtils.fromFXImage(getImage(), null); try { ImageIO.write(bufferedImage, "png", image); - // System.out.println("Thumbnail saved successfully to " + + // com.neuronrobotics.sdk.common.Log.error("Thumbnail saved successfully to " + // image.getAbsolutePath()); } catch (IOException e) { - // System.err.println("Error saving image: " + e.getMessage()); + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + e.getMessage()); e.printStackTrace(); } } @@ -427,7 +427,7 @@ public WritableImage loadImageFromFile() { loadingImageFromUIThread(); } } catch (IOException e) { - System.err.println("Error loading image: " + e.getMessage()); + com.neuronrobotics.sdk.common.Log.error("Error loading image: " + e.getMessage()); e.printStackTrace(); } return img; @@ -438,7 +438,7 @@ private void loadingImageFromUIThread() { while (getImage() == null) try { Thread.sleep(16); - // System.out.println("Waiting for image to write"); + // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -475,14 +475,14 @@ public static CaDoodleFile fromFile(File f) throws Exception { } public static String getProjectName(File f) throws Exception { - System.out.println("CaDoodle file reading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("CaDoodle file reading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, null, f, false); return file.getProjectName(); } public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boolean initialize) throws Exception { - System.out.println("CaDoodle file loading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("CaDoodle file loading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, listener, f, initialize); return file; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 8ddcad04..33ef1732 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -73,7 +73,7 @@ public T read(JsonReader in) throws IOException { throw new JsonParseException("Unknown type: " + typeName); } TypeAdapter delegateAdapter = gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get(clazz)); - System.out.println("JSON Parsing "+typeName); + com.neuronrobotics.sdk.common.Log.error("JSON Parsing "+typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } }.nullSafe(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java index 125339cc..9b591be8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java @@ -90,7 +90,7 @@ public void execute(String content) throws Exception { } public void runSequence() throws Exception { - System.out.println("Initialize Sequence"); + com.neuronrobotics.sdk.common.Log.error("Initialize Sequence"); ScriptingEngine.gitScriptRun(getUrl(), getFile()); HashMap devices = getDevices(); @@ -103,13 +103,13 @@ public void runSequence() throws Exception { for (String mine : devices.keySet()) { for (String key : getDevicesInSequence()) if (mine.contentEquals(key)) { - System.out.println("Found Device " + key); + com.neuronrobotics.sdk.common.Log.error("Found Device " + key); HashMap devSeq = getSequence(key); Thread t = new Thread(() -> { for (int i = 0; i < finalDur && !Thread.interrupted(); i++) { SequenceEvent event = devSeq.get("" + i); if (event != null) { - System.out.println(key + " Execute @ " + i); + com.neuronrobotics.sdk.common.Log.error(key + " Execute @ " + i); event.execute((DHParameterKinematics) devices.get(key)); } try { @@ -122,7 +122,7 @@ public void runSequence() throws Exception { threads.add(t); } } - System.out.println("Running sequence"); + com.neuronrobotics.sdk.common.Log.error("Running sequence"); for (Thread t : threads) { t.start(); } @@ -135,7 +135,7 @@ public void runSequence() throws Exception { t.interrupt(); } } - System.out.println( + com.neuronrobotics.sdk.common.Log.error( "Running complete, took " + (System.currentTimeMillis() - start) + " expcted " + getDuration()); } @@ -163,7 +163,7 @@ private void addWavFileRun(ArrayList threads) throws InvalidRemoteExcept while (audioClip.isRunning() && !Thread.interrupted()) { double pos = (double) audioClip.getMicrosecondPosition() / 1000.0; double percent = pos / len * 100.0; - // System.out.println("Current " + pos + " Percent = " + percent); + // com.neuronrobotics.sdk.common.Log.error("Current " + pos + " Percent = " + percent); ThreadUtil.wait(10); } } catch (Throwable t) { @@ -172,7 +172,7 @@ private void addWavFileRun(ArrayList threads) throws InvalidRemoteExcept audioClip.stop(); audioClip.close(); ((AudioInputStream) audioStream).close(); - System.out.println("Audio clip exited "+getWavurl()+" : "+getWavfile()); + com.neuronrobotics.sdk.common.Log.error("Audio clip exited "+getWavurl()+" : "+getWavfile()); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java index 04581edf..6da2aecc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java @@ -114,7 +114,7 @@ public static FileChangeWatcher watch(File fileToWatch) throws IOException { String path = fileToWatch.getAbsolutePath(); if (activeListener.get(path) == null) { activeListener.put(path, new FileChangeWatcher(fileToWatch)); - System.err.println("Adding file to listening " + fileToWatch.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Adding file to listening " + fileToWatch.getAbsolutePath()); } return activeListener.get(path); } @@ -130,14 +130,14 @@ public static FileChangeWatcher watch(File fileToWatch) throws IOException { private FileChangeWatcher(File fileToWatch) throws IOException { this.setFileToWatch(fileToWatch); - //System.err.println("\n\n\n\tWatching "+fileToWatch.getAbsolutePath()+"\n\n\n"); + //com.neuronrobotics.sdk.common.Log.error("\n\n\n\tWatching "+fileToWatch.getAbsolutePath()+"\n\n\n"); this.watcher = FileSystems.getDefault().newWatchService(); this.keys = new HashMap(); Path dir = Paths.get(fileToWatch.getParent()); if (recursive) { System.out.format("Scanning %s ...\n", dir); registerAll(dir); - System.out.println("Done."); + com.neuronrobotics.sdk.common.Log.error("Done."); } else { register(dir); } @@ -149,7 +149,7 @@ public void run() { while (run) { try { - //System.err.println("Checking File: " + getFileToWatch().getAbsolutePath()); + //com.neuronrobotics.sdk.common.Log.error("Checking File: " + getFileToWatch().getAbsolutePath()); watch(); } catch (Exception ex) { ex.printStackTrace(); @@ -270,7 +270,7 @@ public void watch() { Path dir = keys.get(key); if (dir == null) { - System.err.println("WatchKey not recognized!!"); + com.neuronrobotics.sdk.common.Log.error("WatchKey not recognized!!"); return; } @@ -292,7 +292,7 @@ public void watch() { } // print out event // System.out.format("%s: %s\n", event.kind().name(), child); - System.err.println("File Changed: " + getFileToWatch().getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("File Changed: " + getFileToWatch().getAbsolutePath()); for (int i = 0; i < listeners.size(); i++) { listeners.get(i).onFileChange(child.toFile(), event); @@ -354,7 +354,7 @@ public void close() { //new Exception("File watcher closed " + fileToWatch.getAbsolutePath()).printStackTrace(); this.run = false; try { - System.err.println("Closing watcher for "+fileToWatch.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.error("Closing watcher for "+fileToWatch.getAbsolutePath()); watcher.close(); } catch (IOException e) { // TODO Auto-generated catch block diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java index 021b93e6..cb58417a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java @@ -81,8 +81,8 @@ public static void saveDatabase(String type) throws Exception { "Pushing changed Database");//commit message } catch (org.eclipse.jgit.api.errors.TransportException ex) { - System.out.println("You need to fork " + getGitRpoDatabase() + " to have permission to save"); - System.out.println( + com.neuronrobotics.sdk.common.Log.error("You need to fork " + getGitRpoDatabase() + " to have permission to save"); + com.neuronrobotics.sdk.common.Log.error( "You do not have permission to push to this repo, change the GIT repo to your fork with setGitRpoDatabase(String gitRpoDatabase) "); throw ex; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 5fbb3412..2cf88ac0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -209,7 +209,7 @@ private void saveLocal() { csv += key + "," + size + "," + URL +","+object+ "\n"; } else { - System.out.println("Failure on " + key); + com.neuronrobotics.sdk.common.Log.error("Failure on " + key); } } @@ -217,7 +217,7 @@ private void saveLocal() { String current = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_CSV)[0]; String currentJ = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_JSON)[0]; if (current.contentEquals(csv) && currentJ.contentEquals(content)) { - //System.out.println("No update, BoM current"); + //com.neuronrobotics.sdk.common.Log.error("No update, BoM current"); saving = false; return; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index c5a60d8a..aa7a89a4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -67,7 +67,7 @@ public class Vitamins { private static ConcurrentHashMap changeListeners = new ConcurrentHashMap(); public static void clear() { - System.out.println("Vitamins Database Cleraing, reloading files"); + com.neuronrobotics.sdk.common.Log.error("Vitamins Database Cleraing, reloading files"); for (String keys : databaseSet.keySet()) { ConcurrentHashMap> data = databaseSet.get(keys); for (String key2 : data.keySet()) { @@ -143,7 +143,7 @@ public static CSG get(String type, String id, String purchasingVariant) throws E } CSG vitToGet = fileLastLoaded.get(type + id); - // System.err.println("Loading "+vitToGet); + // com.neuronrobotics.sdk.common.Log.error("Loading "+vitToGet); return vitToGet; } @@ -208,7 +208,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception return newVitamin; } catch (Exception ex) { - // System.err.println(type +"-"+ id+" Failed"); + // com.neuronrobotics.sdk.common.Log.error(type +"-"+ id+" Failed"); // ex.printStackTrace(); return newVitamin; } @@ -317,11 +317,11 @@ public static void saveDatabase(String type) throws Exception { "Making changes to " + type + " by " + PasswordManager.getUsername() + "\n\nAuto-save inside com.neuronrobotics.bowlerstudio.vitamins.Vitamins inside bowler-scripting-kernel");// commit // message - // System.err.println(jsonString); - System.out.println("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); + // com.neuronrobotics.sdk.common.Log.error(jsonString); + com.neuronrobotics.sdk.common.Log.error("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); } catch (org.eclipse.jgit.api.errors.TransportException ex) { - System.out.println("You need to fork " + defaultgitRpoDatabase + " to have permission to save"); - System.out.println( + com.neuronrobotics.sdk.common.Log.error("You need to fork " + defaultgitRpoDatabase + " to have permission to save"); + com.neuronrobotics.sdk.common.Log.error( "You do not have permission to push to this repo, change the GIT repo to your fork with setGitRpoDatabase(String gitRpoDatabase) "); throw ex; } @@ -335,7 +335,7 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { try { saveDatabase(type); } catch (org.eclipse.jgit.api.errors.TransportException ex) { - System.err.println("Forked repo is missing!"); + com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); GHRepository newRepo = repo.fork(); Thread.sleep(6000); @@ -367,7 +367,7 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { String head = PasswordManager.getUsername() + ":master"; List asList = repo.queryPullRequests().state(GHIssueState.OPEN).head(head).list().asList(); if (asList.size() == 0) { - System.err.println("Creating PR for " + head); + com.neuronrobotics.sdk.common.Log.error("Creating PR for " + head); GHPullRequest request = repo.createPullRequest("User Added vitamins to " + type, head, "master", "## User added vitamins", true, true); try { @@ -392,7 +392,7 @@ private static void processSelfPR(GHPullRequest request) throws IOException { if (request.getMergeable()) { request.merge("Auto Merging Master"); reLoadDatabaseFromFiles(); - System.out.println("Merged Hardware-Dimensions madhephaestus:master into " + com.neuronrobotics.sdk.common.Log.error("Merged Hardware-Dimensions madhephaestus:master into " + PasswordManager.getUsername() + ":master"); } else { try { @@ -466,7 +466,7 @@ public static ConcurrentHashMap> getDa if (changeListeners.get(type) == null) { changeListeners.put(type, () -> { // If the file changes, clear the database and load the new data - System.out.println("Re-loading " + type); + com.neuronrobotics.sdk.common.Log.error("Re-loading " + type); databaseSet.put(type, null); new RuntimeException().printStackTrace(); }); @@ -482,7 +482,7 @@ public static ConcurrentHashMap> getDa jsonString = IOUtils.toString(inPut); inPut.close(); - System.out.println("JSON loading Loading " + type + " " + jsonString.length()); + com.neuronrobotics.sdk.common.Log.error("JSON loading Loading " + type + " " + jsonString.length()); // perfoem the GSON parse database = gson.fromJson(jsonString, TT_mapStringString); if (database == null) @@ -628,7 +628,7 @@ public static String getGitRepoDatabase() { GHRepository repo = github.getRepository(PasswordManager.getLoginID() + "/Hardware-Dimensions"); if (repo != null) { String myAssets = repo.getGitTransportUrl().replaceAll("git://", "https://"); - // System.out.println("Using my version of Viamins: "+myAssets); + // com.neuronrobotics.sdk.common.Log.error("Using my version of Viamins: "+myAssets); setGitRepoDatabase(myAssets); } else { throw new org.kohsuke.github.GHFileNotFoundException(); diff --git a/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java b/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java index 386e6151..285f18ae 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java +++ b/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java @@ -49,8 +49,8 @@ private void inJarLoad(String name)throws UnsatisfiedLinkError, NativeResourceEx public static File inJarLoad(Class inputClass, String name) throws IOException{ InputStream resourceSource = inputClass.getResourceAsStream(name); File resourceLocation = prepResourceLocation(name); - //System.out.println("Resource selected "+resourceSource); - //System.out.println("Resource target "+resourceLocation); + //com.neuronrobotics.sdk.common.Log.error("Resource selected "+resourceSource); + //com.neuronrobotics.sdk.common.Log.error("Resource target "+resourceLocation); copyResource(resourceSource, resourceLocation); return resourceLocation; @@ -58,8 +58,8 @@ public static File inJarLoad(Class inputClass, String name) throws IOException{ public static File inJarLoad(InputStream inputStream, String name) throws IOException{ InputStream resourceSource = inputStream; File resourceLocation = prepResourceLocation(name); - //System.out.println("Resource selected "+resourceSource); - //System.out.println("Resource target "+resourceLocation); + //com.neuronrobotics.sdk.common.Log.error("Resource selected "+resourceSource); + //com.neuronrobotics.sdk.common.Log.error("Resource target "+resourceLocation); copyResource(resourceSource, resourceLocation); return resourceLocation; @@ -99,17 +99,17 @@ private InputStream locateResource(String name) { } } }else{ - System.err.println("Can't load native file: "+name+" for os arch: "+ getOsArch()); + com.neuronrobotics.sdk.common.Log.error("Can't load native file: "+name+" for os arch: "+ getOsArch()); return null; } - //System.out.println("Loading "+file); + //com.neuronrobotics.sdk.common.Log.error("Loading "+file); return getClass().getResourceAsStream(file); } private void loadResource(File resource) { if(!resource.canRead()) throw new RuntimeException("Cant open JNI file: "+resource.getAbsolutePath()); - //System.out.println("Loading: "+resource.getAbsolutePath()); + //com.neuronrobotics.sdk.common.Log.error("Loading: "+resource.getAbsolutePath()); System.load(resource.getAbsolutePath()); } @@ -190,13 +190,13 @@ public static File prepResourceLocation(String fileName) throws NativeResourceEx if(fd == null || !fd.canRead()) { throw new NativeResourceException("Unable to deploy native resource"); } - //System.out.println("Local file: "+fd.getAbsolutePath()); + //com.neuronrobotics.sdk.common.Log.error("Local file: "+fd.getAbsolutePath()); return fd; } public static boolean is64Bit() { - ////System.out.println("Arch: "+getOsArch()); + ////com.neuronrobotics.sdk.common.Log.error("Arch: "+getOsArch()); return getOsArch().startsWith("x86_64") || getOsArch().startsWith("amd64"); } public static boolean isARM() { @@ -210,7 +210,7 @@ public static boolean isCortexA8(){ return false; } public static boolean isWindows() { - ////System.out.println("OS name: "+getOsName()); + ////com.neuronrobotics.sdk.common.Log.error("OS name: "+getOsName()); return getOsName().toLowerCase().startsWith("windows") ||getOsName().toLowerCase().startsWith("microsoft") || getOsName().toLowerCase().startsWith("ms"); } diff --git a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java index a22dab88..9045c4cc 100644 --- a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java +++ b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java @@ -96,7 +96,7 @@ private void setControllerByName(List names) { controller = c; break; } else - System.out.println("Non match: " + c.getName() + " " + n); + com.neuronrobotics.sdk.common.Log.error("Non match: " + c.getName() + " " + n); } } } @@ -149,7 +149,7 @@ public void run() { setControllerByName(searches); break; } catch (Throwable t) { - System.out.println("BowlerJInputDevice Waiting for device to be availible"); + com.neuronrobotics.sdk.common.Log.error("BowlerJInputDevice Waiting for device to be availible"); t.printStackTrace(); try { Thread.sleep(1000); @@ -227,7 +227,7 @@ public String getControllerName() { * @param controller the new controller */ public void setController(Controller controller) { - System.out.println("Found! " + controller.getName()); + com.neuronrobotics.sdk.common.Log.error("Found! " + controller.getName()); this.name = controller.getName(); controller.poll(); EventQueue queue = controller.getEventQueue(); @@ -322,13 +322,13 @@ public static void main(String[] args) throws InterruptedException { BowlerJInputDevice g = new BowlerJInputDevice("X-Box","Gamesir","Dragon"); // g.connect(); // Connect to it. g.addListeners((name, value) -> { - System.out.println(g); + com.neuronrobotics.sdk.common.Log.error(g); }); while (g.isAvailable()) Thread.sleep(100); - System.out.println("Controller clean exit"); + com.neuronrobotics.sdk.common.Log.error("Controller clean exit"); } catch (Throwable t) { - System.out.println("Waiting for device to be availible"); + com.neuronrobotics.sdk.common.Log.error("Waiting for device to be availible"); t.printStackTrace(); Thread.sleep(1000); } diff --git a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/ControllerEnvironment.java b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/ControllerEnvironment.java index 97ecc7cb..58fd4717 100644 --- a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/ControllerEnvironment.java +++ b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/ControllerEnvironment.java @@ -96,7 +96,7 @@ protected static void libfix() { File test = new File(absolutePathToDirectory); if (!test.isDirectory()) absolutePathToDirectory = test.getParentFile().getAbsolutePath(); - // System.out.println("Setting net.java.games.input.librarypath : + // com.neuronrobotics.sdk.common.Log.error("Setting net.java.games.input.librarypath : // "+absolutePathToDirectory); System.setProperty("net.java.games.input.librarypath", absolutePathToDirectory); } diff --git a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/JogTrainerWidget.java b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/JogTrainerWidget.java index 4063b50d..4d0c861a 100644 --- a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/JogTrainerWidget.java +++ b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/JogTrainerWidget.java @@ -98,7 +98,7 @@ public void handle(ActionEvent event) { List maps = PersistantControllerMap.getDefaultMaps(); int i = 0; - System.out.println("There are "+maps.size()+" rows"); + com.neuronrobotics.sdk.common.Log.error("There are "+maps.size()+" rows"); for (i = 0; i < maps.size(); i++) { String map = maps.get(i); @@ -194,10 +194,10 @@ public void onEvent(String name, float value) { values.put(name,value); timeOfLastAxisSet.put(name, System.currentTimeMillis()); if(abs>0.2) - System.out.println("value for "+name+" seems noisy "+value+" most recent was "+values.get(name)); + com.neuronrobotics.sdk.common.Log.error("value for "+name+" seems noisy "+value+" most recent was "+values.get(name)); return; }else { - System.out.println("Value changed! "+name+" "+float1+" to "+value); + com.neuronrobotics.sdk.common.Log.error("Value changed! "+name+" "+float1+" to "+value); values.put(name, value); timeOfLastAxisSet.put(name, System.currentTimeMillis()); } @@ -205,8 +205,8 @@ public void onEvent(String name, float value) { for(String s:listOfMappedAxis) { if(s.contentEquals(name)) { - System.out.println("mapping skipped for "+name); - System.out.println(gameController); + com.neuronrobotics.sdk.common.Log.error("mapping skipped for "+name); + com.neuronrobotics.sdk.common.Log.error(gameController); return;// This axis name is already mapped and will not be mapped again } } @@ -216,7 +216,7 @@ public void onEvent(String name, float value) { } axisWaiting=name; - System.out.println("Adding Axis "+name); + com.neuronrobotics.sdk.common.Log.error("Adding Axis "+name); listOfMappedAxis.add(name); timeOfLastAxisSet.put(name,System.currentTimeMillis()); @@ -236,17 +236,17 @@ public void onEvent(String name, float value) { } public static void run(BowlerJInputDevice c) { - //System.out.println("Launching Controller mapping"); + //com.neuronrobotics.sdk.common.Log.error("Launching Controller mapping"); BowlerKernel.runLater(new Runnable() { @Override public void run() { - //System.out.println("Creating stage"); + //com.neuronrobotics.sdk.common.Log.error("Creating stage"); Stage s = new Stage(); new Thread() { public void run() { JogTrainerWidget controller = new JogTrainerWidget(c); try { - //System.out.println("Loading FXML"); + //com.neuronrobotics.sdk.common.Log.error("Loading FXML"); controller.start(s); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java index 060cf9b9..a2fb4fc4 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java @@ -117,10 +117,10 @@ public void loadFromFile(File f){ } catch (IOException e) { throw new RuntimeException(e); } - //System.out.println("Parsing File..."); + //com.neuronrobotics.sdk.common.Log.error("Parsing File..."); NodeList nList = doc.getElementsByTagName("ServoOutputSequenceGroup"); for (int temp = 0; temp < nList.getLength(); temp++) { - //System.out.println("Leg # "+temp); + //com.neuronrobotics.sdk.common.Log.error("Leg # "+temp); Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; @@ -134,7 +134,7 @@ public void loadFromFile(File f){ setLoopTime(Integer.parseInt(getTagValue("loopTime",eElement))); NodeList links = eElement.getElementsByTagName("ServoOutputSequence"); for (int i = 0; i < links.getLength(); i++) { - //System.out.println("\tLink # "+i); + //com.neuronrobotics.sdk.common.Log.error("\tLink # "+i); Node lNode = links.item(i); if (lNode.getNodeType() == Node.ELEMENT_NODE) { Element lElement = (Element) lNode; @@ -158,7 +158,7 @@ public void loadFromFile(File f){ int current = data[j]; int after = data[j+1]; if(current == 0 &&before!=0 && after!=0){ - System.out.println("Smoothing xml"); + com.neuronrobotics.sdk.common.Log.error("Smoothing xml"); data[j]=(before+after)/2; } } @@ -177,10 +177,10 @@ public void loadFromFile(File f){ } }else{ - //System.out.println("Not Element Node"); + //com.neuronrobotics.sdk.common.Log.error("Not Element Node"); } } - System.out.println("Populated Scheduler"); + com.neuronrobotics.sdk.common.Log.error("Populated Scheduler"); } /** @@ -193,7 +193,7 @@ public void loadFromFile(File f){ private static String getTagValue(String sTag, Element eElement){ NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes(); Node nValue = (Node) nlList.item(0); - //System.out.println("\t\t"+sTag+" = "+nValue.getNodeValue()); + //com.neuronrobotics.sdk.common.Log.error("\t\t"+sTag+" = "+nValue.getNodeValue()); return nValue.getNodeValue(); } @@ -209,7 +209,7 @@ public void setAudioFile(File f) { filename=f.getAbsolutePath(); mp3 = new SequencerWAV(f.getAbsolutePath()); msDuration = mp3.getTrackLength(); - System.out.println("Setting track length: "+msDuration); + com.neuronrobotics.sdk.common.Log.error("Setting track length: "+msDuration); setSequenceParams( msDuration, 0); } @@ -259,7 +259,7 @@ public boolean isPlaying() { * @return the servo output schedule channel */ public ServoOutputScheduleChannel addServoChannel(int dyIOChannel){ - System.out.println("Adding DyIO channel: "+dyIOChannel); + com.neuronrobotics.sdk.common.Log.error("Adding DyIO channel: "+dyIOChannel); ServoChannel srv = new ServoChannel(getDyIO().getChannel(dyIOChannel)); srv.SetPosition(srv.getValue()); srv.flush(); @@ -290,7 +290,7 @@ public void removeServoOutputScheduleChannel(ServoOutputScheduleChannel s){ public void setSequenceParams(int setpoint,long StartOffset){ msDuration=setpoint; this.StartOffset=StartOffset; - //System.out.println("Starting scheduler setpoint="+setpoint+" offset="+StartOffset); + //com.neuronrobotics.sdk.common.Log.error("Starting scheduler setpoint="+setpoint+" offset="+StartOffset); if(getSt()==null) setSt(new SchedulerThread(msDuration,StartOffset)); if(mp3!=null) @@ -475,7 +475,7 @@ public void run(){ } flushTime = System.currentTimeMillis()-start; if(flushTime>getLoopTime()){ - System.err.println("Flush took:"+flushTime+ " and loop time="+getLoopTime()); + com.neuronrobotics.sdk.common.Log.error("Flush took:"+flushTime+ " and loop time="+getLoopTime()); flushTime=getLoopTime(); } }else{ @@ -543,7 +543,7 @@ private class SchedulerThread extends Thread{ public SchedulerThread(double ms,final long so){ time = ms; StartOffset=so; - //System.out.println("Slider value of init="+StartOffset); + //com.neuronrobotics.sdk.common.Log.error("Slider value of init="+StartOffset); if(mp3!=null) { mp3.setCurrentTime((int) (StartOffset)); } @@ -556,7 +556,7 @@ public SchedulerThread(double ms,final long so){ * Play step. */ public void playStep(){ - //System.out.println("Stepping scheduler"); + //com.neuronrobotics.sdk.common.Log.error("Stepping scheduler"); boolean playing; long current; if(mp3==null){ @@ -580,7 +580,7 @@ public void playStep(){ * @see java.lang.Thread#run() */ public void run(){ - //System.out.println("Starting timer"); + //com.neuronrobotics.sdk.common.Log.error("Starting timer"); do{ do{ while(pause){ @@ -590,7 +590,7 @@ public void run(){ long start = System.currentTimeMillis(); playStep(); ThreadUtil.wait(getLoopTime()); - //System.out.println("Flush took "+(System.currentTimeMillis()-start)); + //com.neuronrobotics.sdk.common.Log.error("Flush took "+(System.currentTimeMillis()-start)); }while(isRun()); setCurrentTime(0); setPause(true); diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/SequencerWAV.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/SequencerWAV.java index c0be2082..7aa80586 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/SequencerWAV.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/SequencerWAV.java @@ -30,7 +30,7 @@ public SequencerWAV(String filename) { } catch (Exception e) { - System.out.println("Problem playing file " + filename+"\r\n"); + com.neuronrobotics.sdk.common.Log.error("Problem playing file " + filename+"\r\n"); //e.printStackTrace(); throw new RuntimeException(e); } @@ -139,12 +139,12 @@ public static void main(String[] args) { SequencerWAV mp3 = new SequencerWAV("track.mp3"); mp3.play(); - System.out.println("Track length= "+mp3.getTrackLength()); + com.neuronrobotics.sdk.common.Log.error("Track length= "+mp3.getTrackLength()); while(mp3.isPlaying() ){ - System.out.println("Current "+mp3.getCurrentTime() +" Percent = "+mp3.getPercent()); + com.neuronrobotics.sdk.common.Log.error("Current "+mp3.getCurrentTime() +" Percent = "+mp3.getPercent()); ThreadUtil.wait(100); } - System.out.println("Finished "+mp3.getCurrentTime()+" of "+mp3.getTrackLength()); + com.neuronrobotics.sdk.common.Log.error("Finished "+mp3.getCurrentTime()+" of "+mp3.getTrackLength()); System.exit(0); //mediaPlayer. diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java index e652b09b..d6179bd3 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java @@ -79,7 +79,7 @@ public int getChannelNumber(){ * Pause recording. */ public void pauseRecording(){ - System.out.println("pausing recording"); + com.neuronrobotics.sdk.common.Log.error("pausing recording"); if(input != null) input.removeAnalogInputListener(this); setRecording(false); @@ -91,7 +91,7 @@ public void pauseRecording(){ public void resumeRecording(){ if(input==null) initInput(); - System.out.println("resuming recording"); + com.neuronrobotics.sdk.common.Log.error("resuming recording"); setRecording(true); } @@ -117,7 +117,7 @@ private void initInput() { } if(input.getChannel().getChannelNumber() != analogInputChannelNumber) { - System.out.println("Re-Setting analog input channel: "+analogInputChannelNumber); + com.neuronrobotics.sdk.common.Log.error("Re-Setting analog input channel: "+analogInputChannelNumber); input.removeAllAnalogInputListeners(); input=new AnalogInputChannel(output.getChannel().getDevice().getChannel(analogInputChannelNumber),true); } @@ -149,7 +149,7 @@ public void onTimeUpdate(double ms) { //output.SetPosition(data.get(index).input); - //System.out.println("Setting servo "+getChannelNumber()+" value="+getCurrentValue()); + //com.neuronrobotics.sdk.common.Log.error("Setting servo "+getChannelNumber()+" value="+getCurrentValue()); } @@ -161,7 +161,7 @@ public void setIntervalTime(int msInterval, int totalTime) { setInterval(msInterval); int slices = totalTime/msInterval; if(data.size()==0){ - System.out.println("Setting up sample data: "+msInterval+"ms for: "+totalTime); + com.neuronrobotics.sdk.common.Log.error("Setting up sample data: "+msInterval+"ms for: "+totalTime); data = new ArrayList(); setCurrentTargetValue(getCurrentValue()); if(getCurrentTargetValue()>getOutputMax()){ @@ -186,14 +186,14 @@ public void setIntervalTime(int msInterval, int totalTime) { public void onAnalogValueChange(AnalogInputChannel chan, double value) { double centerOffset =getInputCenter()-(512*getInputScale()); - //System.out.println("Center Offset="+centerOffset); + //com.neuronrobotics.sdk.common.Log.error("Center Offset="+centerOffset); double scaled = (value*getInputScale()); double recentered = (scaled+centerOffset); setCurrentTargetValue((int) recentered ); - //System.out.println("Analog value="+(int)value+" scaled="+(int)scaled +" recentered="+(int)recentered); + //com.neuronrobotics.sdk.common.Log.error("Analog value="+(int)value+" scaled="+(int)scaled +" recentered="+(int)recentered); if(getCurrentTargetValue()>getOutputMax()){ setCurrentTargetValue(getOutputMax()); } @@ -383,7 +383,7 @@ public void setData(int[] data2) { * Start test. */ public void startTest() { - System.out.println("Starting test for output: "+getChannelNumber()); + com.neuronrobotics.sdk.common.Log.error("Starting test for output: "+getChannelNumber()); initInput(); directTester = new Tester(); directTester.start(); @@ -463,7 +463,7 @@ public void flush(){ * @param analogInputChannelNumber the new analog input channel number */ public void setAnalogInputChannelNumber(int analogInputChannelNumber) { - //System.out.println("Setting analog input number: "+analogInputChannelNumber); + //com.neuronrobotics.sdk.common.Log.error("Setting analog input number: "+analogInputChannelNumber); this.analogInputChannelNumber = analogInputChannelNumber; } @@ -499,12 +499,12 @@ private class Tester extends Thread { * @see java.lang.Thread#run() */ public void run() { - //System.out.println("Starting Test"); + //com.neuronrobotics.sdk.common.Log.error("Starting Test"); while(running) { flush(); try {Thread.sleep((long) getInterval());} catch (InterruptedException e) {} } - //System.out.println("Test Done"); + //com.neuronrobotics.sdk.common.Log.error("Test Done"); } /** diff --git a/test/java/src/junit/bowler/BlenderLoadingTest.java b/test/java/src/junit/bowler/BlenderLoadingTest.java index 26468d9d..2212461c 100644 --- a/test/java/src/junit/bowler/BlenderLoadingTest.java +++ b/test/java/src/junit/bowler/BlenderLoadingTest.java @@ -19,12 +19,12 @@ public void test() throws Exception { "TestRepo4.blend"); if(loaded.getPolygons().size()!=12) fail("Failed to load polygon!"); - System.out.println("Blender file loaded num polys: "+loaded.getPolygons().size()); + com.neuronrobotics.sdk.common.Log.error("Blender file loaded num polys: "+loaded.getPolygons().size()); CSG cube = new Cube(100).toCSG(); CSG remeshed = GeometrySimplification.remesh(cube, 10.0); if(remeshed.getPolygons().size()!=1452) fail("Blender failed to remesh"); - System.out.println("Remeshing produced: "+remeshed.getPolygons().size()); + com.neuronrobotics.sdk.common.Log.error("Remeshing produced: "+remeshed.getPolygons().size()); } } diff --git a/test/java/src/junit/bowler/GitHub.java b/test/java/src/junit/bowler/GitHub.java index 6c428877..8f79f00b 100644 --- a/test/java/src/junit/bowler/GitHub.java +++ b/test/java/src/junit/bowler/GitHub.java @@ -25,7 +25,7 @@ public class GitHub { public void test() throws Exception { //ScriptingEngine.login(); // String remoteURI = "https://github.com/madhephaestusdemo/WalkTest_madhephaestusdemo.git"; -// System.out.println(ScriptingEngine.getRepositoryCloneDirectory(remoteURI)); +// com.neuronrobotics.sdk.common.Log.error(ScriptingEngine.getRepositoryCloneDirectory(remoteURI)); // ScriptingEngine.pull(remoteURI); //ScriptingEngine.fork("https://github.com/madhephaestus/6dofServoArm.git", "forktest6dof", "testing yo!"); @@ -37,46 +37,46 @@ public void test() throws Exception { } ScriptingEngine.setAutoupdate(true); } catch (Exception ex) { - System.out.println("User not logged in, test can not run"); + com.neuronrobotics.sdk.common.Log.error("User not logged in, test can not run"); } org.kohsuke.github.GitHub github = ScriptingEngine.getGithub(); while (github == null) { github = ScriptingEngine.getGithub(); ThreadUtil.wait(2000); - System.out.println("Waiting for github"); + com.neuronrobotics.sdk.common.Log.error("Waiting for github"); } Map orgs = github.getMyOrganizations(); for (String org : orgs.keySet()) { - System.out.println("Org: " + org); + com.neuronrobotics.sdk.common.Log.error("Org: " + org); GHOrganization ghorg = orgs.get(org); Map repos = ghorg.getRepositories(); for (String orgRepo : repos.keySet()) { - System.out.println("\tRepo " + org + " " + orgRepo); + com.neuronrobotics.sdk.common.Log.error("\tRepo " + org + " " + orgRepo); } } Map> teams = github.getMyTeams(); for (String team : teams.keySet()) { - System.out.println("Team " + team); + com.neuronrobotics.sdk.common.Log.error("Team " + team); Set ghteam = teams.get(team); for (GHTeam ghT : ghteam) { - System.out.println("\tGHTeam " + ghT.getName()); + com.neuronrobotics.sdk.common.Log.error("\tGHTeam " + ghT.getName()); Map repos = ghT.getRepositories(); for (String repoName : repos.keySet()) { - System.out.println("\t\tGHTeam " + ghT.getName() + " repo " + repoName); + com.neuronrobotics.sdk.common.Log.error("\t\tGHTeam " + ghT.getName() + " repo " + repoName); } } } GHMyself self = github.getMyself(); Map myPublic = self.getAllRepositories(); for (String myRepo : myPublic.keySet()) { - System.out.println("Repo " + myRepo); + com.neuronrobotics.sdk.common.Log.error("Repo " + myRepo); GHRepository ghrepo = myPublic.get(myRepo); // if(ghrepo.getOwnerName().contains("demo")) - System.out.println("\tOwner: " + ghrepo.getOwnerName() + " " + myRepo); + com.neuronrobotics.sdk.common.Log.error("\tOwner: " + ghrepo.getOwnerName() + " " + myRepo); } PagedIterable watching = self.listSubscriptions(); for (GHRepository g : watching) { - System.out.println("Watching " + g.getOwnerName() + " " + g.getFullName()); + com.neuronrobotics.sdk.common.Log.error("Watching " + g.getOwnerName() + " " + g.getFullName()); } String gitURL ="https://github.com/madhephaestus/clojure-utils.git"; ArrayList listofFiles = ScriptingEngine.filesInGit(gitURL, @@ -84,39 +84,39 @@ public void test() throws Exception { if (listofFiles.size() == 0) fail(); for (String s : listofFiles) { - System.out.println("Files " + s); + com.neuronrobotics.sdk.common.Log.error("Files " + s); } String asstsRepo="https://github.com/madhephaestus/BowlerStudioImageAssets.git"; // https://github.com/madhephaestus/BowlerStudioImageAssets.git ScriptingEngine.deleteRepo(asstsRepo); List call = ScriptingEngine.listBranches(asstsRepo); - System.out.println("Branches # " + call.size()); + com.neuronrobotics.sdk.common.Log.error("Branches # " + call.size()); if (call.size() > 0) { for (Ref ref : call) { - System.out.println("Branch: Ref= " + ref + " name= " + ref.getName() + " ID = " + ref.getObjectId().getName()); } + com.neuronrobotics.sdk.common.Log.error("Branch: Ref= " + ref + " name= " + ref.getName() + " ID = " + ref.getObjectId().getName()); } } else { fail(); } ScriptingEngine.checkout(asstsRepo, call.get(0).getName()); call = ScriptingEngine.listLocalBranches(asstsRepo); - System.out.println("Local Branches # " + call.size()); + com.neuronrobotics.sdk.common.Log.error("Local Branches # " + call.size()); if (call.size() > 0) { for (Ref ref : call) { - System.out.println("Branch: Ref= " + ref + " name= " + ref.getName() + " ID = " + ref.getObjectId().getName()); + com.neuronrobotics.sdk.common.Log.error("Branch: Ref= " + ref + " name= " + ref.getName() + " ID = " + ref.getObjectId().getName()); } } else { fail(); } - //System.out.println("Creating branch # " ); + //com.neuronrobotics.sdk.common.Log.error("Creating branch # " ); // ScriptingEngine.newBranch(asstsRepo, "0.20.0"); // try{ // ScriptingEngine.deleteBranch(asstsRepo, "0.20.0"); // }catch(Exception e){ // e.printStackTrace(); // } - System.out.println("Current Branch # " + ScriptingEngine.getFullBranch(asstsRepo)); + com.neuronrobotics.sdk.common.Log.error("Current Branch # " + ScriptingEngine.getFullBranch(asstsRepo)); */ } diff --git a/test/java/src/junit/bowler/JettyTest.java b/test/java/src/junit/bowler/JettyTest.java index cc9c6243..09b6af59 100644 --- a/test/java/src/junit/bowler/JettyTest.java +++ b/test/java/src/junit/bowler/JettyTest.java @@ -38,7 +38,7 @@ public void startJetty() throws Exception { ScriptingEngine.setupAnyonmous(); // ScriptingEngine.setAutoupdate(true); } catch (Exception ex) { - System.out.println("User not logged in, test can not run"); + com.neuronrobotics.sdk.common.Log.error("User not logged in, test can not run"); } File indexOfTutorial = ScriptingEngine .fileFromGit("https://github.com/CommonWealthRobotics/CommonWealthRobotics.github.io.git", @@ -55,7 +55,7 @@ public void startJetty() throws Exception { ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setDirectoriesListed(true); resource_handler.setWelcomeFiles(new String[]{"index.html"}); - System.out.println("Serving " + indexOfTutorial.getParent()); + com.neuronrobotics.sdk.common.Log.error("Serving " + indexOfTutorial.getParent()); resource_handler.setResourceBase(indexOfTutorial.getParent()); HandlerList handlers = new HandlerList(); @@ -75,7 +75,7 @@ public void test() throws InvalidRemoteException, TransportException, GitAPIExce try { java.io.InputStream url = new URL(HOME_Local_URL).openStream(); try { - System.out.println(org.apache.commons.io.IOUtils.toString(url)); + com.neuronrobotics.sdk.common.Log.error(org.apache.commons.io.IOUtils.toString(url)); } finally { org.apache.commons.io.IOUtils.closeQuietly(url); } diff --git a/test/java/src/junit/bowler/JsonTester.java b/test/java/src/junit/bowler/JsonTester.java index 9bce704a..a37cf9c4 100644 --- a/test/java/src/junit/bowler/JsonTester.java +++ b/test/java/src/junit/bowler/JsonTester.java @@ -25,20 +25,20 @@ public void test() throws Exception { ScriptingEngine.setupAnyonmous(); //ScriptingEngine.setAutoupdate(true); }catch (Exception ex){ - System.out.println("User not logged in, test can not run"); + com.neuronrobotics.sdk.common.Log.error("User not logged in, test can not run"); } File f = ScriptingEngine .fileFromGit( "https://github.com/madhephaestus/BowlerStudioExampleRobots.git",// git repo, change this if you fork this demo "exampleRobots.json"// File from within the Git repo ); - System.out.println("File: "+f); + com.neuronrobotics.sdk.common.Log.error("File: "+f); HashMap> map = (HashMap>) ScriptingEngine .inlineFileScriptRun(f, null); for(String menuTitle:map.keySet()){ HashMap script = map.get(menuTitle); - System.out.println((String)script.get("scriptGit")); - System.out.println((String)script.get("scriptFile")); ; + com.neuronrobotics.sdk.common.Log.error((String)script.get("scriptGit")); + com.neuronrobotics.sdk.common.Log.error((String)script.get("scriptFile")); ; } */ diff --git a/test/java/src/junit/bowler/MobileBaseLoading.java b/test/java/src/junit/bowler/MobileBaseLoading.java index 4c024e94..5f671dbe 100644 --- a/test/java/src/junit/bowler/MobileBaseLoading.java +++ b/test/java/src/junit/bowler/MobileBaseLoading.java @@ -25,13 +25,13 @@ public void test() throws Exception { IMobileBaseUI mobileBaseUI = new IMobileBaseUI() { @Override public void setAllCSG(Collection collection, File file) { - System.out.println("Setting CSG's # " +collection.size()); + com.neuronrobotics.sdk.common.Log.error("Setting CSG's # " +collection.size()); numCSG=collection.size(); } @Override public void addCSG(Collection collection, File file) { - System.out.println("Adding CSG's # " +collection.size()); + com.neuronrobotics.sdk.common.Log.error("Adding CSG's # " +collection.size()); } @@ -68,10 +68,10 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, CSG in // MobileBaseCadManager.get(mobileBase).getUi(). DeviceManager.addConnection(mobileBase, mobileBase.getScriptingName()); mobileBaseCadManager.generateCad(); - System.out.println("Waiting for cad to generate"); + com.neuronrobotics.sdk.common.Log.error("Waiting for cad to generate"); ThreadUtil.wait(1000); while (MobileBaseCadManager.get(mobileBase).getProcesIndictor().get() < 1 ) { - //System.out.println("Waiting: " + MobileBaseCadManager.get(mobileBase).getProcesIndictor().get()); + //com.neuronrobotics.sdk.common.Log.error("Waiting: " + MobileBaseCadManager.get(mobileBase).getProcesIndictor().get()); ThreadUtil.wait(1000); } if(numCSG==0) diff --git a/test/java/src/junit/bowler/MuJoCoBowlerIntegrationTest.java b/test/java/src/junit/bowler/MuJoCoBowlerIntegrationTest.java index 4929bc94..6e8a13fd 100644 --- a/test/java/src/junit/bowler/MuJoCoBowlerIntegrationTest.java +++ b/test/java/src/junit/bowler/MuJoCoBowlerIntegrationTest.java @@ -26,7 +26,7 @@ public void test() throws Exception { // JavaFXInitializer.go(); // } catch (Throwable t) { // t.printStackTrace(); -// System.err.println("ERROR No UI engine availible"); +// com.neuronrobotics.sdk.common.Log.error("ERROR No UI engine availible"); // } // ArrayList bases = new ArrayList<>(); // ArrayList free =new ArrayList<>(); @@ -39,7 +39,7 @@ public void test() throws Exception { // terrain= (ArrayList) ScriptingEngine.gitScriptRun( // "https://github.com/madhephaestus/VexHighStakes2024.git", // "field.groovy"); -// System.out.println("Parts size = "+parts.size()); +// com.neuronrobotics.sdk.common.Log.error("Parts size = "+parts.size()); // //terrain.add(new Cube(10000,10000,100).toCSG().toZMax()); // free.addAll(parts); // MuJoCoPhysicsManager manager = new MuJoCoPhysicsManager("javaCadTest", bases, free, terrain, new File("./physicsTest")); @@ -58,7 +58,7 @@ public void test() throws Exception { // } // fail("Real time broken! "+took+" instead of expected "+manager.getCurrentSimulationTimeSeconds()); // }else { -// System.out.println("Time "+now); +// com.neuronrobotics.sdk.common.Log.error("Time "+now); // } // long timeSinceStart = System.currentTimeMillis()-start; // double sec = ((double)timeSinceStart)/1000.0; @@ -67,7 +67,7 @@ public void test() throws Exception { // } // } // manager.close(); -// System.out.println("Success!"); +// com.neuronrobotics.sdk.common.Log.error("Success!"); } diff --git a/test/java/src/junit/bowler/MuJoCoTest.java b/test/java/src/junit/bowler/MuJoCoTest.java index d50485a3..d52631c0 100644 --- a/test/java/src/junit/bowler/MuJoCoTest.java +++ b/test/java/src/junit/bowler/MuJoCoTest.java @@ -9,12 +9,12 @@ public class MuJoCoTest { @Test public void test() { - System.out.println("mujocoJNILoadTest"); - System.out.println(System.getProperty("org.bytedeco.javacpp.logger.debug")); + com.neuronrobotics.sdk.common.Log.error("mujocoJNILoadTest"); + com.neuronrobotics.sdk.common.Log.error(System.getProperty("org.bytedeco.javacpp.logger.debug")); System.setProperty("org.bytedeco.javacpp.logger.debug", "true"); MuJoCoLib lib = new MuJoCoLib(); - System.out.println("Starting " + MuJoCoLib.mj_versionString().getString()); + com.neuronrobotics.sdk.common.Log.error("Starting " + MuJoCoLib.mj_versionString().getString()); } } diff --git a/test/java/src/junit/bowler/PyTorchResNetTest.java b/test/java/src/junit/bowler/PyTorchResNetTest.java index 8bf336a0..013fb4de 100644 --- a/test/java/src/junit/bowler/PyTorchResNetTest.java +++ b/test/java/src/junit/bowler/PyTorchResNetTest.java @@ -20,13 +20,13 @@ public class PyTorchResNetTest { // @Test // public void testResNet() throws Exception { -// System.err.println(Thread.currentThread().getStackTrace()[1].getMethodName()); +// com.neuronrobotics.sdk.common.Log.error(Thread.currentThread().getStackTrace()[1].getMethodName()); // // } // // @Test // public void testretinaface() throws Exception { -// System.err.println(Thread.currentThread().getStackTrace()[1].getMethodName()); +// com.neuronrobotics.sdk.common.Log.error(Thread.currentThread().getStackTrace()[1].getMethodName()); // // BufferedImage bimg = ImageIO.read(new URL(imageUrl)); // @@ -43,7 +43,7 @@ public class PyTorchResNetTest { // // @Test // public void testUltraNet() throws Exception { -// System.err.println(Thread.currentThread().getStackTrace()[1].getMethodName()); +// com.neuronrobotics.sdk.common.Log.error(Thread.currentThread().getStackTrace()[1].getMethodName()); // // BufferedImage bimg = ImageIO.read(new URL(imageUrl)); // @@ -82,12 +82,12 @@ private static void saveBoundingBoxImage(Image img, DetectedObjects detection, S Path imagePath = outputDir.resolve(type + ".png").toAbsolutePath(); img.save(Files.newOutputStream(imagePath), "png"); - System.out.println("Face detection result image has been saved in: {} " + imagePath); + com.neuronrobotics.sdk.common.Log.error("Face detection result image has been saved in: {} " + imagePath); } // @Test public void testYolo() throws Exception { - System.err.println(Thread.currentThread().getStackTrace()[1].getMethodName()); + com.neuronrobotics.sdk.common.Log.error(Thread.currentThread().getStackTrace()[1].getMethodName()); Predictor predictor = PredictorFactory.imageContentsFactory(ImagePredictorType.yolov5); for (int i = 0; i < 3; i++) { @@ -101,7 +101,7 @@ public void testYolo() throws Exception { // // @Test // public void testFeatures() throws Exception { -// System.err.println(Thread.currentThread().getStackTrace()[1].getMethodName()); +// com.neuronrobotics.sdk.common.Log.error(Thread.currentThread().getStackTrace()[1].getMethodName()); // BufferedImage img = ImageIO.read(new URL(imageUrl)); // BufferedImage img2 = ImageIO.read(new URL(image2URL)); // BufferedImage img3 = ImageIO.read(new URL(image3URL)); @@ -112,12 +112,12 @@ public void testYolo() throws Exception { // float[] back3 = predictor.predict(ImageFactory.getInstance().fromImage(img3)); // float[] back4 = predictor.predict(ImageFactory.getInstance().fromImage(ImageIO.read(new URL(notme)))); // -// System.out.println(" Comprair 1 to 2 " + PredictorFactory.calculSimilarFaceFeature(back, back2)); -// System.out.println(" Comprair 1 to 3 " + PredictorFactory.calculSimilarFaceFeature(back, back3)); -// System.out.println(" Comprair 2 to 3 " + PredictorFactory.calculSimilarFaceFeature(back2, back3)); -// System.out.println(" Comprair 1 to 4 " + PredictorFactory.calculSimilarFaceFeature(back, back4)); +// com.neuronrobotics.sdk.common.Log.error(" Comprair 1 to 2 " + PredictorFactory.calculSimilarFaceFeature(back, back2)); +// com.neuronrobotics.sdk.common.Log.error(" Comprair 1 to 3 " + PredictorFactory.calculSimilarFaceFeature(back, back3)); +// com.neuronrobotics.sdk.common.Log.error(" Comprair 2 to 3 " + PredictorFactory.calculSimilarFaceFeature(back2, back3)); +// com.neuronrobotics.sdk.common.Log.error(" Comprair 1 to 4 " + PredictorFactory.calculSimilarFaceFeature(back, back4)); // -// System.out.println(Arrays.toString(back)); +// com.neuronrobotics.sdk.common.Log.error(Arrays.toString(back)); // // } diff --git a/test/java/src/junit/bowler/TTSTest.java b/test/java/src/junit/bowler/TTSTest.java index 7ad42e4b..3cae596e 100644 --- a/test/java/src/junit/bowler/TTSTest.java +++ b/test/java/src/junit/bowler/TTSTest.java @@ -21,7 +21,7 @@ public void TTSText() { @Override public void update(double percentage, AudioStatus status) { // TODO Auto-generated method stub - System.out.println(percentage+" "+status.toString()); + com.neuronrobotics.sdk.common.Log.error(percentage+" "+status.toString()); } }; //BowlerKernel.speak("Coqui one text to speech", 200, 0, 800, 1.0, 1.0,sp); @@ -34,7 +34,7 @@ public void update(double percentage, AudioStatus status) { // for(int i=800;i<(800+CoquiDockerManager.getNummberOfOptions());i++) { // BowlerKernel.speak("Coqui " + i + " text to speech", 200, 0, i, 1.0, 1.0,null); -// System.out.println("\n\nVoice finished"); +// com.neuronrobotics.sdk.common.Log.error("\n\nVoice finished"); // } } diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 6ec946f1..6a672e77 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -41,7 +41,7 @@ public void test() throws Exception { .setProjectName("A Test Project"); String jsonContent = cf.toJson(); - System.out.println(jsonContent); + com.neuronrobotics.sdk.common.Log.error(jsonContent); AddFromScript cube1 = new AddFromScript() .set("https://github.com/madhephaestus/CaDoodle-Example-Objects.git", @@ -61,8 +61,8 @@ public void test() throws Exception { String nameTwo = back.get(1).getName(); if(nameOne.contentEquals(nameTwo)) fail("Names must be unique!"); - System.out.println("Name one : "+nameOne ); - System.out.println("Name two : "+nameTwo ); + com.neuronrobotics.sdk.common.Log.error("Name one : "+nameOne ); + com.neuronrobotics.sdk.common.Log.error("Name two : "+nameTwo ); double distaance =10; MoveCenter move = new MoveCenter() .setLocation(new TransformNR(distaance,0,0)) @@ -77,7 +77,7 @@ public void test() throws Exception { if(back.get(0).getCenterX()!=0) fail("Move misapplied "); jsonContent = cf.toJson(); - //System.out.println(jsonContent); + //com.neuronrobotics.sdk.common.Log.error(jsonContent); cf.save(); CaDoodleFile loaded = CaDoodleFile.fromFile(cf.getSelf()); if(!MoveCenter.class.isInstance(loaded.getOpperations().get(2))) { @@ -127,7 +127,7 @@ public void test() throws Exception { fail("THis should be aa group result"); } String groupName = back.get(2).getName(); - System.out.println("Group Name : "+groupName); + com.neuronrobotics.sdk.common.Log.error("Group Name : "+groupName); TransformNR height = new TransformNR(0,0,40); TransformNR leftFront = new TransformNR(40,80,0); TransformNR rightRear = new TransformNR(-10,10,0); @@ -220,7 +220,7 @@ public void test() throws Exception { fail("Load and export mismatch"); loaded.setSelf(cf.getSelf()); - System.out.println(after); + com.neuronrobotics.sdk.common.Log.error(after); diff --git a/test/java/src/junit/bowler/TestCheckout.java b/test/java/src/junit/bowler/TestCheckout.java index f37599d5..b84b4032 100644 --- a/test/java/src/junit/bowler/TestCheckout.java +++ b/test/java/src/junit/bowler/TestCheckout.java @@ -25,7 +25,7 @@ public void test() throws IOException, GitAPIException { try { String []name = select.getName().split("/"); String myName = name[name.length-1]; - System.out.println("Selecting Branch\r\n"+url+" \t\t"+myName); + com.neuronrobotics.sdk.common.Log.error("Selecting Branch\r\n"+url+" \t\t"+myName); String was = ScriptingEngine.getBranch(url); ScriptingEngine.checkout(url, myName); String s = ScriptingEngine.getBranch(url); From 4c9c2ee33636a5172e4148bcab9f8991f1fc3e3a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 18:00:43 -0400 Subject: [PATCH 178/635] update jcsd --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 730e0f58..3a4ed889 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 730e0f58b21084f66f6052239df740a3b9b89619 +Subproject commit 3a4ed889648d840bd649b40ea7266439d76b6edb From d901fe4040e4738c454ebaca0314a6e002f86840 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 18:02:02 -0400 Subject: [PATCH 179/635] update JCSG --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a5d6a6f5..e9103e28 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.2' + api 'com.neuronrobotics:JavaCad:1.8.4' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 92cc5c015f3f3bcdb76f15c3ec1c86b3554a87bb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 19:20:20 -0400 Subject: [PATCH 180/635] upadting the cad kernel to be more robust to partially broken polygons --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 3a4ed889..91b00e46 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 3a4ed889648d840bd649b40ea7266439d76b6edb +Subproject commit 91b00e46a0fe493610de71c4b11581e0c9cc32b8 diff --git a/build.gradle b/build.gradle index e9103e28..6e6ddc69 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.4' + api 'com.neuronrobotics:JavaCad:1.8.5' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 5cc3f158ca89f4d023bfd7c857fa84f5974b9a88 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 19:23:32 -0400 Subject: [PATCH 181/635] cad --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 91b00e46..8ada7800 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 91b00e46a0fe493610de71c4b11581e0c9cc32b8 +Subproject commit 8ada78001fc87df99dcaf52821264dbc6d8f378e From 0cbd774fc78c81d9b85ce3320100f39caf1441e0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 27 Oct 2024 20:19:23 -0400 Subject: [PATCH 182/635] Updating the jcsg to disallow setting of a CSG name to null --- JCSG | 2 +- build.gradle | 2 +- .../neuronrobotics/bowlerstudio/scripting/SvgLoader.java | 3 +++ .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 9 ++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/JCSG b/JCSG index 8ada7800..021a9571 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 8ada78001fc87df99dcaf52821264dbc6d8f378e +Subproject commit 021a95710b9d266d8f05f704a6bf07d5ff3f100a diff --git a/build.gradle b/build.gradle index 6e6ddc69..1d424b77 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.5' + api 'com.neuronrobotics:JavaCad:1.8.7' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index 1e52f2c8..0be6cc60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -22,6 +22,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio SVGLoad s = new SVGLoad(code.toURI()); return run(s); }catch(Exception e) { + e.printStackTrace(); com.neuronrobotics.sdk.common.Log.error("SVG had error, attempting to fix "+code.getAbsolutePath()); File tmp=GeometrySimplification.simplifySVG(code); SVGLoad s = new SVGLoad(tmp.toURI()); @@ -49,6 +50,8 @@ private Object run(SVGLoad s) { double depth =5+(layers.size()*5); for(int i=0;i process(List incoming) { com.neuronrobotics.sdk.common.Log.error("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); - CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); - - collect.add(processedCSG); + try { + CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); + collect.add(processedCSG); + }catch(Exception ex) { + ex.printStackTrace(); + } } back.addAll(collect); } catch (Exception e) { From 25402af38a024c583f734c11362832e40db78fd3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 28 Oct 2024 07:20:29 -0400 Subject: [PATCH 183/635] jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1d424b77..7016b673 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.7' + api 'com.neuronrobotics:JavaCad:1.8.8' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 99da876bb13ba3be23152921843eead8a09fca39 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 28 Oct 2024 10:47:13 -0400 Subject: [PATCH 184/635] make the progress log work in headless mode --- .../bowlerstudio/scripting/DownloadManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index d15ddd3c..321d1b3c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -114,7 +114,15 @@ public void onInstallFail(String url) { System.out.println("Plugin needs to be installed from "+url); } }; - private static GitLogProgressMonitor psudoSplash; + private static GitLogProgressMonitor psudoSplash = new GitLogProgressMonitor() { + + @Override + public void onUpdate(String update, Exception e) { + // TODO Auto-generated method stub + + } + + }; private static String jvmURL; public static Thread run(IExternalEditor editor, File dir, PrintStream out, List finalCommand) { From 18ce56882bd1d8e6382d4b912582e7eb04176081 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 28 Oct 2024 11:43:33 -0400 Subject: [PATCH 185/635] update jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 021a9571..e18f463c 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 021a95710b9d266d8f05f704a6bf07d5ff3f100a +Subproject commit e18f463c2025b2fcc830ff5f0f97a4090da7e39a From 8de825c92dd1c1a2ac0898cc61ab677706c9c3d4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 28 Oct 2024 13:14:40 -0400 Subject: [PATCH 186/635] Always use the parent file location to load the file from the database --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 8569646c..b9d557ac 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -125,7 +125,10 @@ private File toLocal(File file) { return file; } public File getFile() { - return new File(getStrValue()); + StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); + File parentFile = new File(loc.getStrValue()).getParentFile(); + File file = new File(getStrValue()); + return new File(parentFile.getAbsolutePath()+DownloadManager.delim()+file.getName()); } private String getStrValue() { From 776ad69b53aea7f74eb4c6bc24ea2864cc0e616f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 2 Nov 2024 11:48:07 -0400 Subject: [PATCH 187/635] Fix the setting of the parameter when the file is loaded --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index b9d557ac..40340454 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -54,7 +54,10 @@ public List process(List incoming) { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); - List flattenedCSGs = ScriptingEngine.flaten(getFile(), CSG.class, null); + File file = getFile(); + String pathname = file.getAbsolutePath(); + getParameter(pathname).setStrValue(pathname); + List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); com.neuronrobotics.sdk.common.Log.error("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); @@ -128,7 +131,8 @@ public File getFile() { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFile = new File(loc.getStrValue()).getParentFile(); File file = new File(getStrValue()); - return new File(parentFile.getAbsolutePath()+DownloadManager.delim()+file.getName()); + String pathname = parentFile.getAbsolutePath()+DownloadManager.delim()+file.getName(); + return new File(pathname); } private String getStrValue() { From 034d5a317eb239fe57e819f85abb8fccd597fe94 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 2 Nov 2024 16:38:46 -0400 Subject: [PATCH 188/635] add paraameters to the openscad --- .../scripting/OpenSCADLoader.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java index dfc9c55c..90469837 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.HashMap; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.InvalidRemoteException; @@ -23,7 +24,15 @@ public class OpenSCADLoader implements IScriptingLanguage { public Object inlineScriptRun(File code, ArrayList args) throws Exception { File stl = File.createTempFile(sanitizeString(code.getName()), ".stl"); stl.deleteOnExit(); - toSTLFile(code,stl); + HashMap params=new HashMap(); + if(args!=null) { + Object o = args.get(0); + if(HashMap.class.isInstance(o)) { + params=(HashMap)o; + } + } + + toSTLFile(code,stl,params); CSG back = Vitamins.get(stl,true); back.setColor(Color.YELLOW); return back; @@ -51,14 +60,19 @@ public ArrayList getFileExtenetion() { - public static void toSTLFile(File openscadfile,File stlout) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + public static void toSTLFile(File openscadfile,File stlout, HashMap params) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { File exe = getConfigExecutable("openscad", null); - + if(params==null) + params=new HashMap(); ArrayList args = new ArrayList<>(); if(stlout.exists()) stlout.delete(); args.add(exe.getAbsolutePath()); + for(String key:params.keySet()) { + args.add("-D"); + args.add(key+"="+params.get(key)); + } args.add("-o"); args.add(stlout.getAbsolutePath()); args.add(openscadfile.getAbsolutePath()); @@ -66,7 +80,7 @@ public static void toSTLFile(File openscadfile,File stlout) throws InvalidRemote } @Override public String getDefaultContents() { - return "cube([3, 2, 1]);"; + return "cube([30, 20, 10]);"; } @Override @@ -81,7 +95,8 @@ public static void main(String[] args) throws InvalidRemoteException, TransportE File testblend = new File("test.scad"); if(!testblend.exists()) loader.getDefaultContents(testblend); - toSTLFile(testblend, new File("testscad.stl")); + HashMap params = new HashMap(); + toSTLFile(testblend, new File("testscad.stl"),params); } } From bf15e4c2fb41344a59d52e3ff8cb490fec61b63d Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 10 Nov 2024 09:05:07 -0500 Subject: [PATCH 189/635] Adding prints for export and push --- .../bowlerstudio/creature/CadFileExporter.java | 11 ++++++----- .../bowlerstudio/scripting/ScriptingEngine.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index e79cd29a..26977dc1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -154,11 +154,12 @@ public ArrayList generateManufacturingParts(List totalAssembly , File if(freecadParts.size()>0){ allCadStl.add(makeFreecad(nameBase,freecadParts));// default to stl } + System.out.println("Finished Export!"); return allCadStl; } private File makeFreecad(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".FCStd"); - com.neuronrobotics.sdk.common.Log.error("Writing "+blend.getAbsolutePath()); + System.out.println("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) FreecadLoader.addCSGToFreeCAD( blend,tmp); return blend; @@ -168,20 +169,20 @@ private File makeStl(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".stl"); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); - com.neuronrobotics.sdk.common.Log.error("Writing "+stl.getAbsolutePath()); + System.out.println("Writing "+stl.getAbsolutePath()); return stl; } private File makeObj(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".obj"); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toObjString()); - com.neuronrobotics.sdk.common.Log.error("Writing "+stl.getAbsolutePath()); + System.out.println("Writing "+stl.getAbsolutePath()); return stl; } private File makeBlender(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".blend"); - com.neuronrobotics.sdk.common.Log.error("Writing "+blend.getAbsolutePath()); + System.out.println("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) BlenderLoader.toBlenderFile(tmp, blend); return blend; @@ -212,7 +213,7 @@ private File makeSvg(String nameBase, List currentCsg) throws IOException { } - com.neuronrobotics.sdk.common.Log.error("Writing " + stl.getAbsolutePath()); + System.out.println("Writing " + stl.getAbsolutePath()); } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error("ERROR, NO pixelization engine availible for slicing"); t.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 419c50d8..a6722c97 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -1067,7 +1067,7 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); closeGit(git); - com.neuronrobotics.sdk.common.Log.error("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); + System.out.println("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); } catch (Exception ex) { ex.printStackTrace(); closeGit(git); From 1cb522e6ab71822cc92723373d713c28c3e39d08 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 10 Nov 2024 10:00:59 -0500 Subject: [PATCH 190/635] updating the jcsg kernel --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7016b673..490e81d5 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.8.8' + api 'com.neuronrobotics:JavaCad:1.9.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ee3dc82921d4c0276afee5f745643373386c52a5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 10 Nov 2024 17:33:26 -0500 Subject: [PATCH 191/635] Remove the centering on the objject loaders, this should be done on each model loader not indiscrimantly --- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 92cb89e3..6c93d783 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -60,9 +60,9 @@ public List process(List incoming) { .stream() .map(csg->{ return csg - .moveToCenterX() - .moveToCenterY() - .toZMin() +// .moveToCenterX() +// .moveToCenterY() +// .toZMin() .transformed(TransformFactory.nrToCSG( getLocation() )) .syncProperties(csg) .setName(getOrderedName()); From 6f1fc69b9e2fd0a9343b20bf5031bacaaf217da3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 11 Nov 2024 15:02:14 -0500 Subject: [PATCH 192/635] Adding the dependant library --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 490e81d5..8096be3b 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.9.0' + api 'com.neuronrobotics:JavaCad:1.10.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From b6c94dda63163fafe588ad39d1f16a79bb20b659 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Nov 2024 12:30:09 -0500 Subject: [PATCH 193/635] Fixing the launching of the docker --- .../com/neuronrobotics/bowlerstudio/CoquiDockerManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java index 35d6760e..784d5ca1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java @@ -143,7 +143,7 @@ private CoquiDockerManager(String voice) throws InterruptedException, InvalidRem @Override public void onNext(BuildResponseItem item) { // Handle build output (optional) - com.neuronrobotics.sdk.common.Log.error(item.getStream()); + System.out.println(item.getStream()); super.onNext(item); } }).awaitImageId(); From 7759b506f1278875cbb84eb0efdb8ec97d7c7333 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 16 Nov 2024 07:21:40 -0500 Subject: [PATCH 194/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index e18f463c..b0de6e17 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e18f463c2025b2fcc830ff5f0f97a4090da7e39a +Subproject commit b0de6e17ff9e43f8f80e25874a92278dd94a109d From fe48c31276d778e9fae984a974fed27b70ec7d31 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 16 Nov 2024 08:55:09 -0500 Subject: [PATCH 195/635] Adding a workplane change wvent to the cadoodle file changes --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 11 +++++++++++ .../scripting/cadoodle/ICaDoodleStateUpdate.java | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 78fe9690..7edc62be 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -377,6 +377,16 @@ private void fireSaveSuggestion() { } } } + private void fireWorkplaneChange() { + + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onWorkplaneChange(workplane); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } public String getProjectName() { return projectName; @@ -504,6 +514,7 @@ public TransformNR getWorkplane() { public void setWorkplane(TransformNR workplane) { this.workplane = workplane; + fireWorkplaneChange(); fireSaveSuggestion(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index bde72a1a..403a6d55 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -2,10 +2,13 @@ import java.util.List; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + import eu.mihosoft.vrl.v3d.CSG; public interface ICaDoodleStateUpdate { public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); public void onSaveSuggestion(); public void onInitializationDone(); + public void onWorkplaneChange(TransformNR newWP); } From abfedcd7478725a29f60ae9812d2a3f7f193091a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 16 Nov 2024 16:54:09 -0500 Subject: [PATCH 196/635] updateing the JCSG --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8096be3b..c4818fe9 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.10.0' + api 'com.neuronrobotics:JavaCad:1.10.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From af719d41c9db1be8402acbe764f00800d693cb3a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 18 Nov 2024 07:04:09 -0500 Subject: [PATCH 197/635] adding the new advanced mesh export --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c4818fe9..0f079250 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:1.10.1' + api 'com.neuronrobotics:JavaCad:2.0.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From e4d746eb22ca31a01643f8f104476e47003192b5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 18 Nov 2024 08:05:56 -0500 Subject: [PATCH 198/635] latest jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index b0de6e17..b44276a9 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit b0de6e17ff9e43f8f80e25874a92278dd94a109d +Subproject commit b44276a9157f6d9ca4daf737d188413fe47b5e50 From e4cf84569df9444feda5dcb6af54a57545530bed Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 18 Nov 2024 08:13:39 -0500 Subject: [PATCH 199/635] making the defaults for JCSG what they were --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0f079250..2f78550d 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.0' + api 'com.neuronrobotics:JavaCad:2.0.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 0ccf7f8a5e7e0394f21e94ae17bc24ea46560c42 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 18 Nov 2024 10:26:11 -0500 Subject: [PATCH 200/635] fix new bug in jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2f78550d..2105261a 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.1' + api 'com.neuronrobotics:JavaCad:2.0.2' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 8ac4060cdcb51849c99e07441c79866984773005 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 18 Nov 2024 12:29:35 -0500 Subject: [PATCH 201/635] Re-enabling advanced STL for kernel --- src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 7563a35c..f0202c77 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -371,6 +371,7 @@ private static void startupProcedures(String[] args) } ScriptingEngine.gitScriptRun("https://github.com/CommonWealthRobotics/DeviceProviders.git", "loadAll.groovy", null); + CSG.setPreventNonManifoldTriangles(true); } private static void finish(long startTime) { From cbf5c969d343a5831c283075f5c29abcf371471b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 18 Nov 2024 14:00:40 -0500 Subject: [PATCH 202/635] Moving the csg upddate script to the startup --- .../neuronrobotics/bowlerstudio/BowlerKernel.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index f0202c77..6ea9c8fe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -372,6 +372,14 @@ private static void startupProcedures(String[] args) ScriptingEngine.gitScriptRun("https://github.com/CommonWealthRobotics/DeviceProviders.git", "loadAll.groovy", null); CSG.setPreventNonManifoldTriangles(true); + CSG.setProgressMoniter(new ICSGProgress() { + @Override + public void progressUpdate(int currentIndex, int finalIndex, String type, + eu.mihosoft.vrl.v3d.CSG intermediateShape) { + + } + + }); } private static void finish(long startTime) { @@ -384,14 +392,7 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil processUIOpening(ret); if(baseWorkspaceFile!=null) com.neuronrobotics.sdk.common.Log.error("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); - CSG.setProgressMoniter(new ICSGProgress() { - @Override - public void progressUpdate(int currentIndex, int finalIndex, String type, - eu.mihosoft.vrl.v3d.CSG intermediateShape) { - } - - }); if (baseWorkspaceFile != null) { From 444b0950546ad58bf32fe2edd13c37004f1865a7 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 18 Nov 2024 15:59:18 -0500 Subject: [PATCH 203/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index b44276a9..31f1c5e7 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit b44276a9157f6d9ca4daf737d188413fe47b5e50 +Subproject commit 31f1c5e714f297f644e887cc18401d227d17de50 From db5181cc687811dc069ab8739c4d1a9cf2aee6c6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 21 Nov 2024 11:23:02 -0500 Subject: [PATCH 204/635] updating the JCSG core --- JCSG | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index 31f1c5e7..40cd5759 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 31f1c5e714f297f644e887cc18401d227d17de50 +Subproject commit 40cd57591d2f468b4a95bef1f690cd9bc020ad40 diff --git a/build.gradle b/build.gradle index 2105261a..ec0d0763 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.2' + api 'com.neuronrobotics:JavaCad:2.0.3' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 0cf55666b4f2fae31e010f14c6789501e0d3069f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 21 Nov 2024 18:25:06 -0500 Subject: [PATCH 205/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 40cd5759..31f1c5e7 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 40cd57591d2f468b4a95bef1f690cd9bc020ad40 +Subproject commit 31f1c5e714f297f644e887cc18401d227d17de50 From 615e40d2eef8166c5cdcda677d4a602bbc456585 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 23 Nov 2024 09:11:58 -0500 Subject: [PATCH 206/635] OBJ loading --- .../bowlerstudio/scripting/ObjLoader.java | 47 +++++++++++++++++++ .../scripting/ScriptingEngine.java | 1 + .../bowlerstudio/vitamins/Vitamins.java | 7 ++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java new file mode 100644 index 00000000..4079ab46 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java @@ -0,0 +1,47 @@ +package com.neuronrobotics.bowlerstudio.scripting; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; + +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; + +import eu.mihosoft.vrl.v3d.CSG; + +public class ObjLoader implements IScriptingLanguage { + + @Override + public Object inlineScriptRun(File code, ArrayList args) throws Exception { + CSG sllLoaded = Vitamins.get(code); + return sllLoaded; + } + + @Override + public Object inlineScriptRun(String code, ArrayList args) throws Exception { + throw new RuntimeException("This engine only supports files"); + } + + @Override + public String getShellType() { + return "obj"; + } + @Override + public boolean getIsTextFile() { + // TODO Auto-generated method stub + return false; + } + /** + * Get the contents of an empty file + * + * @return + */ + public String getDefaultContents() { + return null; + } + @Override + public ArrayList getFileExtenetion() { + // TODO Auto-generated method stub + return new ArrayList<>(Arrays.asList("obj","OBJ","Obj")); + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index a6722c97..d3d5f35f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -197,6 +197,7 @@ public static List flaten(File f, Class type, ArrayList args) addScriptingLanguage(new FXMLBowlerLoader()); addScriptingLanguage(new OpenSCADLoader()); addScriptingLanguage(new CaDoodleLoader()); + addScriptingLanguage(new ObjLoader()); } public static void setWorkspace(File file) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index aa7a89a4..fdb201f8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.vitamins; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -15,6 +16,7 @@ import eu.mihosoft.vrl.v3d.Cube; import eu.mihosoft.vrl.v3d.STL; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.ObjImporter; import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import javafx.scene.paint.Color; @@ -90,7 +92,10 @@ public static CSG get(File resource, boolean forceRefresh) { // forces the first time the files is accessed by the application tou pull an // update try { - fileLastLoaded.put(resource.getAbsolutePath(), STL.file(resource.toPath())); + if(resource.getName().toLowerCase().endsWith(".stl")) + fileLastLoaded.put(resource.getAbsolutePath(), STL.file(resource.toPath())); + if(resource.getName().toLowerCase().endsWith(".obj")) + fileLastLoaded.put(resource.getAbsolutePath(), new ObjImporter(new FileInputStream(resource)).); // try { // FileChangeWatcher f = FileChangeWatcher.watch(resource); // f.addIFileChangeListener(new IFileChangeListener() { From e1bb58b2f5dc9a42c40a7ecc7dc1ebf498453b02 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 23 Nov 2024 09:16:30 -0500 Subject: [PATCH 207/635] remove junk code --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index fdb201f8..ab1db3e4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -94,8 +94,8 @@ public static CSG get(File resource, boolean forceRefresh) { try { if(resource.getName().toLowerCase().endsWith(".stl")) fileLastLoaded.put(resource.getAbsolutePath(), STL.file(resource.toPath())); - if(resource.getName().toLowerCase().endsWith(".obj")) - fileLastLoaded.put(resource.getAbsolutePath(), new ObjImporter(new FileInputStream(resource)).); +// if(resource.getName().toLowerCase().endsWith(".obj")) +// fileLastLoaded.put(resource.getAbsolutePath(), new ObjImporter(new FileInputStream(resource)).); // try { // FileChangeWatcher f = FileChangeWatcher.watch(resource); // f.addIFileChangeListener(new IFileChangeListener() { From 854c389a3adea78ac549a25fd96455c4a8e1f23f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 23 Nov 2024 10:07:33 -0500 Subject: [PATCH 208/635] pass the mouse event up the stack on the manipulators for detecting shift button presses --- .../bowlerkernel/Bezier3d/BezierEditor.java | 8 ++--- .../Bezier3d/CartesianManipulator.java | 4 ++- .../bowlerkernel/Bezier3d/Manipulation.java | 30 +++++++++---------- .../bowlerstudio/printbed/PrintBedObject.java | 4 ++- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java index f55349f9..b8fbb295 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java @@ -133,21 +133,21 @@ public BezierEditor(File data, int numPoints) { endManip.addSaveListener(() -> { save(); }); - endManip.addEventListener(() -> { + endManip.addEventListener(e -> { update(); }); cp1Manip.addSaveListener(() -> { save(); }); - cp1Manip.addEventListener(() -> { + cp1Manip.addEventListener(e -> { update(); }); cp2Manip.addSaveListener(() -> { save(); }); - cp2Manip.addEventListener(() -> { + cp2Manip.addEventListener(e -> { update(); }); ArrayList parts = new ArrayList<>(); @@ -381,7 +381,7 @@ public void setStartManip(CartesianManipulator start) { start.addSaveListener(() -> { save(); }); - start.addEventListener(() -> { + start.addEventListener(e -> { update(); }); start.addDependant(cp1Manip); diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java index 42786f6d..a43694c4 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java @@ -9,6 +9,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Cylinder; import eu.mihosoft.vrl.v3d.Vector3d; +import javafx.event.EventHandler; +import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.transform.Affine; @@ -35,7 +37,7 @@ public CartesianManipulator(TransformNR globalPose) { } } - public void addEventListener(Runnable r) { + public void addEventListener(EventHandler r) { for (int i = 0; i < 3; i++) manipulationList[i].addEventListener(r); } diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 18bdadc1..f0d3f94b 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -29,7 +29,7 @@ public class Manipulation { private static IInteractiveUIElementProvider ui = new IInteractiveUIElementProvider() { }; - private ArrayList eventListeners = new ArrayList<>(); + private ArrayList> eventListeners = new ArrayList<>(); private ArrayList saveListeners = new ArrayList<>(); private ArrayList dependants = new ArrayList<>(); private Affine manipulationMatrix; @@ -46,7 +46,7 @@ private enum DragState { private DragState state = DragState.IDLE; - public void addEventListener(Runnable r) { + public void addEventListener(EventHandler r) { if (eventListeners.contains(r)) return; eventListeners.add(r); @@ -71,12 +71,12 @@ public void clearListeners() { eventListeners.clear(); } - private void fireMove(TransformNR trans) { + private void fireMove(TransformNR trans, MouseEvent event2) { for (Manipulation R : dependants) { - R.performMove(trans); + R.performMove(trans,event2); } - for (Runnable R : eventListeners) { - R.run(); + for (EventHandler R : eventListeners) { + R.handle(event2); } } @@ -119,7 +119,7 @@ public void handle(MouseEvent event) { pressed(event); break; case "MOUSE_DRAGGED": - dragged(event); + dragged(event,event); break; case "MOUSE_RELEASED": release(event); @@ -167,7 +167,7 @@ private void release(MouseEvent event) { //manip.getMesh().setMaterial(color); } - private void dragged(MouseEvent event) { + private void dragged(MouseEvent event, MouseEvent event2) { if(state==DragState.Dragging) { getUi().runLater(() -> { setDragging(event); @@ -178,7 +178,7 @@ private void dragged(MouseEvent event) { //com.neuronrobotics.sdk.common.Log.error("Moved "+x+" "+y); if(Double.isFinite(y) && Double.isFinite(x)) { TransformNR trans = new TransformNR(x, y, 0, new RotationNR()); - performMove(trans); + performMove(trans,event2); }else { com.neuronrobotics.sdk.common.Log.error("ERROR?"); } @@ -214,7 +214,7 @@ private void setDragging(MouseEvent event) { } } - private void performMove(TransformNR trans) { + private void performMove(TransformNR trans, MouseEvent event2) { TransformNR camerFrame = getUi().getCamerFrame(); TransformNR globalTMP = new TransformNR(camerFrame.getRotation()); try { @@ -246,7 +246,7 @@ private void performMove(TransformNR trans) { }catch(Throwable t) { t.printStackTrace(); } - fireMove(trans); + fireMove(trans,event2); } private double round(double in) { return Math.round(in / increment) * increment; @@ -277,8 +277,8 @@ public void set(double newX, double newY, double newZ) { getGlobalPose().setY(newY); getGlobalPose().setZ(newZ); setGlobal(new TransformNR(newX, newY, newZ, new RotationNR())); - for (Runnable R : eventListeners) { - R.run(); + for (EventHandler R : eventListeners) { + R.handle(null); } } @@ -289,8 +289,8 @@ public void setInReferenceFrame(double newX, double newY, double newZ) { inLocal.setRotation(new RotationNR()); //com.neuronrobotics.sdk.common.Log.error("Setting in reference frame:"+inLocal.toSimpleString()); setGlobal(inLocal); - for (Runnable R : eventListeners) { - R.run(); + for (EventHandler R : eventListeners) { + R.handle(null); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java index d23b757f..939cec0d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedObject.java @@ -8,6 +8,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Vector3d; +import javafx.event.EventHandler; +import javafx.scene.input.MouseEvent; import javafx.scene.transform.Affine; public class PrintBedObject { @@ -35,7 +37,7 @@ public PrintBedObject(String name, CSG part, double xMax, double xMin, double yM manip.addSaveListener(() -> com.neuronrobotics.sdk.common.Log.error("Saving PrintBedObject "+name)); checkBounds(); } - public void addEventListener(Runnable r) { + public void addEventListener(EventHandler r) { manip.addEventListener(r); } From 87b53684500f60f0099fccbc49e26fa693b50d02 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 23 Nov 2024 11:27:59 -0500 Subject: [PATCH 209/635] removing junk test code --- .../com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index f0d3f94b..ba13223a 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -253,6 +253,9 @@ private double round(double in) { } private void setGlobal(TransformNR global) { +// newx = global.getX(); +// newy = global.getY(); +// newz = global.getZ(); getCurrentPose().setX(newx); getCurrentPose().setY(newy); getCurrentPose().setZ(newz); From 08ff9dc175092acd2b4ad67233b6bcbb327ffcd0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 23 Nov 2024 14:43:18 -0500 Subject: [PATCH 210/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 31f1c5e7..64e5cd00 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 31f1c5e714f297f644e887cc18401d227d17de50 +Subproject commit 64e5cd00ba9094f738ae17c41c64f308f1d78236 From e46e526908f6bea7d6b5113f219c97a009d525f1 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 24 Nov 2024 14:05:28 -0500 Subject: [PATCH 211/635] Make sure the cadoodle file is synchronized on itself during saving --- .../scripting/cadoodle/CaDoodleFile.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7edc62be..04513a82 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -157,7 +157,8 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { opperationRunner = new Thread(() -> { opperationRunner.setName("Regeneration Thread"); setRegenerating(true); - // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from "+source.getType()); + // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from + // "+source.getType()); int opIndex = 0; for (int i = 0; i < size; i++) { ICaDoodleOpperation op = opperations.get(i); @@ -170,7 +171,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { for (; getCurrentIndex() < size;) { setCurrentIndex(getCurrentIndex() + 1); - setPercentInitialized(((double)getCurrentIndex())/size); + setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); List process = op.process(getPreviouState()); @@ -377,6 +378,7 @@ private void fireSaveSuggestion() { } } } + private void fireWorkplaneChange() { for (ICaDoodleStateUpdate l : listeners) { @@ -398,7 +400,11 @@ public CaDoodleFile setProjectName(String projectName) { } public String toJson() { - return gson.toJson(this); + String ret = null; + synchronized (this) { + ret = gson.toJson(this); + } + return ret; } public File save() throws IOException { @@ -416,7 +422,8 @@ public File save() throws IOException { // com.neuronrobotics.sdk.common.Log.error("Thumbnail saved successfully to " + // image.getAbsolutePath()); } catch (IOException e) { - // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + e.getMessage()); + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + + // e.getMessage()); e.printStackTrace(); } } From 2892b2a1a8c96ae30dd0c8c02e2dab9902178f02 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 24 Nov 2024 15:19:18 -0500 Subject: [PATCH 212/635] Refuse to perform opperations on locked CSG's --- .../bowlerstudio/scripting/cadoodle/Allign.java | 2 ++ .../bowlerstudio/scripting/cadoodle/Delete.java | 2 ++ .../bowlerstudio/scripting/cadoodle/Group.java | 2 ++ .../bowlerstudio/scripting/cadoodle/Mirror.java | 3 +++ .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 2 ++ .../bowlerstudio/scripting/cadoodle/Resize.java | 5 ++++- .../bowlerstudio/scripting/cadoodle/ToHole.java | 2 ++ .../bowlerstudio/scripting/cadoodle/ToSolid.java | 2 ++ 8 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 210d402e..e0e649b3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -46,6 +46,8 @@ public List process(List incoming) { CSG reference=null; CSG refProps =null; for(CSG c: incoming) { + if(c.isLock()) + continue; String name = names.get(0); if(name.contentEquals(c.getName())) { back.remove(c); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index dd3a0422..4400be52 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -26,6 +26,8 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c:incoming) { + if(c.isLock()) + continue; for(String s:names) { if(s.contentEquals(c.getName())) { back.remove(c); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 0ebbea85..eb0a8d64 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -30,6 +30,8 @@ public List process(List incoming) { ArrayList replace = new ArrayList(); back.addAll(incoming); for(CSG csg: incoming) { + if(csg.isLock()) + continue; for(String name:names) { if(name.contentEquals(csg.getName())) { replace.add(csg); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index c3b72604..deb15b04 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -27,7 +27,10 @@ public List process(List incoming) { back.addAll(incoming .stream() .map(csg->{ + for(String name:names) { + if(csg.isLock()) + continue; if(csg.getName().contentEquals(name)) return mirror(csg, name) ; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 2ad259a4..dd3df809 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -37,6 +37,8 @@ private void moveByName(String name, ArrayList back, HashSet groups for (int i = 0; i < back.size(); i++) { CSG csg = back.get(i); + if(csg.isLock()) + continue; if ( csg.getName().contentEquals(name) || (csg.isInGroup() && csg.checkGroupMembership(name))){ groupsProcessed.add(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index ff0295b1..98cdab29 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -77,12 +77,15 @@ public List process(List incoming) { back.addAll(incoming); HashMap groupsProcessed = new HashMap<>(); ArrayList selected = new ArrayList(); - for(CSG c:incoming) + for(CSG c:incoming) { + if(c.isLock()) + continue; for (String name : names) { if(c.getName().contentEquals(name)) { selected.add(c); } } + } Bounds b = getSellectedBounds(selected); for (String name : names) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index c4f642d5..1f21c248 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -21,6 +21,8 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c: incoming) { + if(c.isLock()) + continue; for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index af25bb5a..d9bc9ac7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -33,6 +33,8 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c: incoming) { + if(c.isLock()) + continue; for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); From 826610f6de77d0982c1d9777df97f8fad34b9255 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 25 Nov 2024 12:04:58 -0500 Subject: [PATCH 213/635] regeneration events --- .../scripting/cadoodle/CaDoodleFile.java | 38 +++++++++++++++++++ .../cadoodle/ICaDoodleStateUpdate.java | 3 ++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 04513a82..13453aa2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -103,6 +103,7 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { public void initialize() { if (initializing) throw new RuntimeException("Can not initialize while initializing."); + fireInitializationStart(); initializing = true; if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); @@ -148,6 +149,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { com.neuronrobotics.sdk.common.Log.error("Opperation is running, ignoring regen"); return null; } + fireRegenerateStart(); int endIndex = getCurrentIndex(); double size = opperations.size(); if (endIndex != size) { @@ -185,6 +187,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setRegenerating(false); fireSaveSuggestion(); opperationRunner = null; + fireRegenerateDone(); }); opperationRunner.start(); return opperationRunner; @@ -194,6 +197,7 @@ public Thread regenerateCurrent() { if (isOperationRunning()) { return opperationRunner; } + fireRegenerateStart(); opperationRunner = new Thread(() -> { opperationRunner.setName("regenerateCurrent Thread"); @@ -203,6 +207,7 @@ public Thread regenerateCurrent() { setCurrentState(op, process); fireSaveSuggestion(); opperationRunner = null; + fireRegenerateDone(); }); opperationRunner.start(); return opperationRunner; @@ -379,6 +384,39 @@ private void fireSaveSuggestion() { } } + private void fireInitializationStart() { + + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onInitializationStart(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + private void fireRegenerateDone() { + + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onRegenerateDone(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + private void fireRegenerateStart() { + + for (ICaDoodleStateUpdate l : listeners) { + try { + l.onSaveSuggestion(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + private void fireWorkplaneChange() { for (ICaDoodleStateUpdate l : listeners) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index 403a6d55..f2d888c1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -10,5 +10,8 @@ public interface ICaDoodleStateUpdate { public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); public void onSaveSuggestion(); public void onInitializationDone(); + public void onInitializationStart(); + public void onRegenerateDone(); + public void onRegenerateStart(); public void onWorkplaneChange(TransformNR newWP); } From 4d5a16c5eba9ff9e77f54ff45e9f61b63a73d6c6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 25 Nov 2024 12:19:13 -0500 Subject: [PATCH 214/635] typo --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 13453aa2..5357291a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -410,7 +410,7 @@ private void fireRegenerateStart() { for (ICaDoodleStateUpdate l : listeners) { try { - l.onSaveSuggestion(); + l.onRegenerateStart(); } catch (Throwable e) { e.printStackTrace(); } From cfd4bbfa7a1a40da2efeabbfaa9e931237996cb8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 26 Nov 2024 10:32:29 -0500 Subject: [PATCH 215/635] add a toString that includes the name and type --- .../bowlerstudio/scripting/cadoodle/AbstractAddFrom.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 8464f1ee..eae14606 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -5,7 +5,7 @@ import com.google.gson.annotations.Expose; -public abstract class AbstractAddFrom { +public abstract class AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = false, deserialize = false) protected HashSet namesAdded = new HashSet<>(); @Expose (serialize = false, deserialize = false) @@ -31,4 +31,8 @@ public String getOrderedName() { return result; } public abstract File getFile(); + @Override + public String toString() { + return getType()+" with name "+getName(); + } } From c110cdd5931c8cfa38dc3edb9fedb2db5e7e1ece Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 29 Nov 2024 11:05:00 -0500 Subject: [PATCH 216/635] adding verbose to the attach --- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 4ea18af0..04334186 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -574,7 +574,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { Set before = Stream.of(listFiles).filter(file -> file.isDirectory()).map(File::getName) .collect(Collectors.toSet()); Thread t = run(null, new File("."), System.out, - Arrays.asList("hdiutil", "attach", jvmArchive.getAbsolutePath())); + Arrays.asList("hdiutil", "attach","-verbose", jvmArchive.getAbsolutePath())); try { t.join(); Thread.sleep(2000);// wait for mount to settle From f85c0668d0632f71cda4b99230a55643dc27b7c9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 1 Dec 2024 18:16:37 -0500 Subject: [PATCH 217/635] updated the BoM manager to use a specified directory instead of a URL --- .../bowlerstudio/BowlerKernel.java | 12 +- .../scripting/cadoodle/CaDoodleFile.java | 23 +++- .../bowlerstudio/vitamins/IVitamin.java | 8 -- .../bowlerstudio/vitamins/MicroServo.java | 37 ------ .../vitamins/VitaminBomManager.java | 118 ++++++++---------- 5 files changed, 75 insertions(+), 123 deletions(-) delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/vitamins/IVitamin.java delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/vitamins/MicroServo.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 6ea9c8fe..44bb645b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -403,9 +403,9 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.MANUFACTURING_BOM_CSV); if (bomCSV.exists()) { - File file = new File(baseDirForFiles.getAbsolutePath() + "/bom.csv"); - if (file.exists()) - file.delete(); + File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.MANUFACTURING_BOM_CSV); +// if (file.exists()) +// file.delete(); try { Files.copy(bomCSV.toPath(), file.toPath()); } catch (IOException e) { @@ -416,9 +416,9 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil File bom = new File( baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.MANUFACTURING_BOM_JSON); if (bom.exists()) { - File file = new File(baseDirForFiles.getAbsolutePath() + "/bom.json"); - if (file.exists()) - file.delete(); + File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.MANUFACTURING_BOM_JSON); +// if (file.exists()) +// file.delete(); try { Files.copy(bom.toPath(), file.toPath()); } catch (IOException e) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 5357291a..087f6f1e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -25,6 +25,7 @@ import com.neuronrobotics.bowlerstudio.creature.ThumbnailImage; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -66,6 +67,7 @@ public class CaDoodleFile { private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; + private VitaminBomManager bom; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -108,11 +110,18 @@ public void initialize() { if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); - if (selfInternal != null) { - StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), - new ArrayList()); - loc.setStrValue(selfInternal.getAbsolutePath()); - } + + StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), + new ArrayList()); + loc.setStrValue(selfInternal.getAbsolutePath()); + + File bomF = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "BillOfMaterials.json"); + StringParameter bomLocation = new StringParameter("CaDoodle_BoM_Location", bomF.getAbsolutePath(), + new ArrayList()); + bomLocation.setStrValue(bomF.getAbsolutePath()); + + bom = new VitaminBomManager(selfInternal.getAbsoluteFile().getParentFile()); + bom.save(); } int indexStarting = getCurrentIndex(); setCurrentIndex(0); @@ -604,4 +613,8 @@ private void setRegenerating(boolean regenerating) { this.regenerating = regenerating; } + public VitaminBomManager getBillOfMaterials() { + return bom; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/IVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/IVitamin.java deleted file mode 100644 index 3587c27f..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/IVitamin.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.neuronrobotics.bowlerstudio.vitamins; - -import eu.mihosoft.vrl.v3d.CSG; - -public interface IVitamin { - - public CSG toCSG(); -} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/MicroServo.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/MicroServo.java deleted file mode 100644 index 01adb41c..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/MicroServo.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.neuronrobotics.bowlerstudio.vitamins; - -import java.io.File; -import java.io.IOException; - -import com.neuronrobotics.imageprovider.NativeResource; - -import eu.mihosoft.vrl.v3d.CSG; -import eu.mihosoft.vrl.v3d.STL; -import eu.mihosoft.vrl.v3d.Transform; - -public class MicroServo implements IVitamin { - - private static CSG servoModel; - - static { - - try { - File stl = NativeResource.inJarLoad(IVitamin.class, "hxt900-servo.stl"); - servoModel = STL.file(stl.toPath()); - servoModel = servoModel.transformed(new Transform().translateZ(-19.3)); - servoModel = servoModel.transformed(new Transform().translateX(5.4)); - -// stl = NativeResource.inJarLoad(IVitamin.class ,"arm.stl"); -// servoModel=servoModel.union(STL.file(stl.toPath())); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public CSG toCSG() { - return servoModel.clone(); - } - -} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 2cf88ac0..6ac69ae1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -29,28 +29,27 @@ import javafx.scene.paint.Color; public class VitaminBomManager { - public static final String MANUFACTURING_BOM_BASE = "manufacturing/bom"; + public static final String MANUFACTURING_BOM_BASE = "manufacturing/BillOfMaterials"; public static final String MANUFACTURING_BOM_JSON = MANUFACTURING_BOM_BASE + ".json"; public static final String MANUFACTURING_BOM_CSV = MANUFACTURING_BOM_BASE + ".csv"; private static boolean saving = false; -// private class VitaminLocation { -// String name; -// String type; -// String size; -// TransformNR pose; -// } - Type type = new TypeToken>>() { }.getType(); - Gson gson = new GsonBuilder().disableHtmlEscaping() - .excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create(); + Gson gson = new GsonBuilder().disableHtmlEscaping().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting() + .create(); private HashMap> database = null;// - private String baseURL; + private String baseURL = null; + private File baseWorkspaceFile; public VitaminBomManager(String url) throws IOException { + this(ScriptingEngine.getRepositoryCloneDirectory(url)); baseURL = url; - File baseWorkspaceFile = ScriptingEngine.getRepositoryCloneDirectory(baseURL); + + } + + public VitaminBomManager(File parentFile) { + baseWorkspaceFile = parentFile; File bom = new File(baseWorkspaceFile.getAbsolutePath() + "/" + MANUFACTURING_BOM_JSON); if (!bom.exists()) { if (!bom.getParentFile().exists()) { @@ -68,37 +67,25 @@ public VitaminBomManager(String url) throws IOException { try { bytes = Files.readAllBytes(bom.toPath()); source = new String(bytes, "UTF-8"); - if(source.length()>0) + if (source.length() > 0) database = gson.fromJson(source, type); } catch (Exception ex) { ex.printStackTrace(); } } - if(database==null) { - database=new HashMap>(); + if (database == null) { + database = new HashMap>(); save(); } } -// public void set(String name, String type, String size, TransformNR location) { -// VitaminLocation newElement = getElement(name); -// if (newElement == null) { -// newElement = new VitaminLocation(name,type,size,location); -// } -// newElement.setLocation(location); -// newElement.setSize(size); -// newElement.setType(type); -// addVitamin(newElement); -// // newElement.url=(String) getConfiguration(name).get("source"); -// } - public void addVitamin(VitaminLocation newElement) { String key = newElement.getType() + ":" + newElement.getSize(); // synchronized (database) { if (database.get(key) == null) { database.put(key, new ArrayList()); } - boolean toAdd=!database.get(key).contains(newElement); + boolean toAdd = !database.get(key).contains(newElement); if (toAdd) database.get(key).add(newElement); // } @@ -111,7 +98,8 @@ public CSG get(String name) { throw new RuntimeException("Vitamin must be defined before it is used: " + name); try { - CSG transformed = MobileBaseCadManager.vitaminMakeCSG(e).transformed(TransformFactory.nrToCSG(e.getLocation())); + CSG transformed = MobileBaseCadManager.vitaminMakeCSG(e) + .transformed(TransformFactory.nrToCSG(e.getLocation())); transformed.setManufacturing(incominng -> { return null; }); @@ -130,11 +118,11 @@ public TransformNR getCoMLocation(String name) { try { double x = (double) getConfiguration(name).get("massCentroidX"); double y = (double) getConfiguration(name).get("massCentroidY"); - + double z = (double) getConfiguration(name).get("massCentroidZ"); return e.getLocation().copy().translateX(x).translateY(y).translateZ(z); - }catch(Exception ex) { + } catch (Exception ex) { return e.getLocation().copy(); } } @@ -142,17 +130,17 @@ public TransformNR getCoMLocation(String name) { public double getMassKg(String name) { try { return (double) getConfiguration(name).get("massKg"); - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); return 0.001; } } - public Map getConfiguration(String name) throws Exception{ + public Map getConfiguration(String name) throws Exception { VitaminLocation e = getElement(name); if (e == null) throw new RuntimeException("Vitamin must be defined before it is used: " + name); - if(e.isScript()) + if (e.isScript()) throw new RuntimeException("Script Vitamins do not have configurations"); return Vitamins.getConfiguration(e.getType(), e.getSize()); @@ -190,47 +178,43 @@ private void saveLocal() { if (list.size() > 0) { VitaminLocation e = list.get(0); String size = database.get(key).size() + ""; - String URL =null; - Object object =null; - if(!e.isScript()) + String URL = null; + Object object = null; + if (!e.isScript()) try { Map configuration = getConfiguration(e.getName()); - URL=(String) configuration.get("source"); - object= configuration.get("price"); - }catch(Exception ex) { + URL = (String) configuration.get("source"); + object = configuration.get("price"); + } catch (Exception ex) { ex.printStackTrace(); } - if(URL==null) { - URL="http://commonwealthrobotics.com"; + if (URL == null) { + URL = "http://commonwealthrobotics.com"; } - if(object==null) - object="0.01"; - - csv += key + "," + size + "," + URL +","+object+ "\n"; + if (object == null) + object = "0.01"; + + csv += key + "," + size + "," + URL + "," + object + "\n"; } else { com.neuronrobotics.sdk.common.Log.error("Failure on " + key); } } - - try { - String current = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_CSV)[0]; - String currentJ = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_JSON)[0]; - if (current.contentEquals(csv) && currentJ.contentEquals(content)) { - //com.neuronrobotics.sdk.common.Log.error("No update, BoM current"); - saving = false; - return; + if (baseURL != null) + try { + String current = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_CSV)[0]; + String currentJ = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_JSON)[0]; + if (current.contentEquals(csv) && currentJ.contentEquals(content)) { + // com.neuronrobotics.sdk.common.Log.error("No update, BoM current"); + saving = false; + return; + } + } catch (Exception e1) { + // file doesnt exist } - } catch (Exception e1) { - // file doesnt exist - } try { write(MANUFACTURING_BOM_JSON, content); write(MANUFACTURING_BOM_CSV, csv); -// ScriptingEngine.commit(baseURL, ScriptingEngine.getBranch(baseURL), MANUFACTURING_BOM_JSON, content, -// "Save Bill Of Material", true); -// ScriptingEngine.commit(baseURL, ScriptingEngine.getBranch(baseURL), MANUFACTURING_BOM_CSV, csv, -// "Save Bill Of Material", true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -241,7 +225,7 @@ private void saveLocal() { private void write(String file, String content) throws InvalidRemoteException, TransportException, GitAPIException, IOException { - File f = ScriptingEngine.fileFromGit(baseURL, file); + File f = new File(baseWorkspaceFile.getAbsolutePath() + "/" + file); if (!f.getParentFile().exists()) f.getParentFile().mkdir(); if (!f.exists()) { @@ -257,16 +241,16 @@ public void save() { } public void loadBaseVitamins(MobileBase base) { - for(VitaminLocation v:base.getVitamins()) { + for (VitaminLocation v : base.getVitamins()) { addVitamin(v); } - for(DHParameterKinematics k:base.getAllDHChains()) { - for(int i=0;i Date: Sun, 1 Dec 2024 18:51:55 -0500 Subject: [PATCH 218/635] Setting up the vitamin BoM to use a working directory --- .../bowlerstudio/BowlerKernel.java | 8 +-- .../creature/MobileBaseCadManager.java | 4 +- .../scripting/cadoodle/CaDoodleFile.java | 19 +++---- .../vitamins/VitaminBomManager.java | 53 ++++++++++++++----- 4 files changed, 52 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 44bb645b..ef45ec3e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -400,10 +400,10 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil if (baseDirForFiles.exists()) { // baseDirForFiles.mkdir(); File bomCSV = new File( - baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.MANUFACTURING_BOM_CSV); + baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomCsv()); if (bomCSV.exists()) { - File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.MANUFACTURING_BOM_CSV); + File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.getManufacturingBomCsv()); // if (file.exists()) // file.delete(); try { @@ -414,9 +414,9 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil } } File bom = new File( - baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.MANUFACTURING_BOM_JSON); + baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomJson()); if (bom.exists()) { - File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.MANUFACTURING_BOM_JSON); + File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.getManufacturingBomJson()); // if (file.exists()) // file.delete(); try { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 7cc3f237..6c4246fc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -1115,7 +1115,7 @@ public ArrayList generateStls(MobileBase base, File baseDirForFiles, boole return new CadFileExporter(getUi()).generateManufacturingParts(totalAssembly, dir); } public IgenerateBed getPrintBed(File baseDirForFiles, IgenerateBed bed, File baseWorkspaceFile) throws IOException { - File bomCSV = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.MANUFACTURING_BOM_CSV); + File bomCSV = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.getManufacturingBomCsv()); if(bomCSV.exists()) { File file = new File(baseDirForFiles.getAbsolutePath()+"/bom.csv"); @@ -1123,7 +1123,7 @@ public IgenerateBed getPrintBed(File baseDirForFiles, IgenerateBed bed, File bas file.delete(); Files.copy(bomCSV.toPath(),file.toPath()); } - File bom = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.MANUFACTURING_BOM_JSON); + File bom = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.getManufacturingBomJson()); if(bom.exists()) { File file = new File(baseDirForFiles.getAbsolutePath()+"/bom.json"); if(file.exists()) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 087f6f1e..87b1f88c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -67,7 +67,6 @@ public class CaDoodleFile { private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; - private VitaminBomManager bom; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -110,18 +109,11 @@ public void initialize() { if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setDbFile(db); - StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); loc.setStrValue(selfInternal.getAbsolutePath()); + CaDoodleFile.getBoM().save(); - File bomF = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "BillOfMaterials.json"); - StringParameter bomLocation = new StringParameter("CaDoodle_BoM_Location", bomF.getAbsolutePath(), - new ArrayList()); - bomLocation.setStrValue(bomF.getAbsolutePath()); - - bom = new VitaminBomManager(selfInternal.getAbsoluteFile().getParentFile()); - bom.save(); } int indexStarting = getCurrentIndex(); setCurrentIndex(0); @@ -150,6 +142,12 @@ public void initialize() { } initializing = false; } + public static VitaminBomManager getBoM() { + StringParameter loc = new StringParameter("CaDoodle_File_Location", "", + new ArrayList()); + String strValue = loc.getStrValue(); + return new VitaminBomManager(new File(strValue).getParentFile()); + } public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) @@ -613,8 +611,5 @@ private void setRegenerating(boolean regenerating) { this.regenerating = regenerating; } - public VitaminBomManager getBillOfMaterials() { - return bom; - } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 6ac69ae1..c0551ea5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -29,9 +29,9 @@ import javafx.scene.paint.Color; public class VitaminBomManager { - public static final String MANUFACTURING_BOM_BASE = "manufacturing/BillOfMaterials"; - public static final String MANUFACTURING_BOM_JSON = MANUFACTURING_BOM_BASE + ".json"; - public static final String MANUFACTURING_BOM_CSV = MANUFACTURING_BOM_BASE + ".csv"; + private static final String MANUFACTURING_BOM_BASE = "manufacturing/BillOfMaterials"; + private static final String MANUFACTURING_BOM_JSON = getManufacturingBomBase() + ".json"; + private static final String MANUFACTURING_BOM_CSV = getManufacturingBomBase() + ".csv"; private static boolean saving = false; Type type = new TypeToken>>() { @@ -50,7 +50,7 @@ public VitaminBomManager(String url) throws IOException { public VitaminBomManager(File parentFile) { baseWorkspaceFile = parentFile; - File bom = new File(baseWorkspaceFile.getAbsolutePath() + "/" + MANUFACTURING_BOM_JSON); + File bom = new File(baseWorkspaceFile.getAbsolutePath() + "/" + getManufacturingBomJson()); if (!bom.exists()) { if (!bom.getParentFile().exists()) { bom.getParentFile().mkdir(); @@ -79,17 +79,27 @@ public VitaminBomManager(File parentFile) { } } - public void addVitamin(VitaminLocation newElement) { + public VitaminBomManager addVitamin(VitaminLocation newElement) { String key = newElement.getType() + ":" + newElement.getSize(); // synchronized (database) { if (database.get(key) == null) { database.put(key, new ArrayList()); } - boolean toAdd = !database.get(key).contains(newElement); + ArrayList arrayList = database.get(key); + + boolean toAdd = !arrayList.contains(newElement); + for (int i = 0; i < arrayList.size(); i++) { + VitaminLocation loc = arrayList.get(i); + if(loc.getName().contentEquals(newElement.getName())) { + arrayList.set(i,newElement); + return this; + } + } if (toAdd) - database.get(key).add(newElement); + arrayList.add(newElement); // } save(); + return this; } public CSG get(String name) { @@ -159,10 +169,11 @@ private VitaminLocation getElement(String name) { return null; } - public void clear() { + public VitaminBomManager clear() { // synchronized (database) { database.clear(); // } + return this; } private void saveLocal() { @@ -202,8 +213,8 @@ private void saveLocal() { } if (baseURL != null) try { - String current = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_CSV)[0]; - String currentJ = ScriptingEngine.codeFromGit(baseURL, MANUFACTURING_BOM_JSON)[0]; + String current = ScriptingEngine.codeFromGit(baseURL, getManufacturingBomCsv())[0]; + String currentJ = ScriptingEngine.codeFromGit(baseURL, getManufacturingBomJson())[0]; if (current.contentEquals(csv) && currentJ.contentEquals(content)) { // com.neuronrobotics.sdk.common.Log.error("No update, BoM current"); saving = false; @@ -213,8 +224,8 @@ private void saveLocal() { // file doesnt exist } try { - write(MANUFACTURING_BOM_JSON, content); - write(MANUFACTURING_BOM_CSV, csv); + write(getManufacturingBomJson(), content); + write(getManufacturingBomCsv(), csv); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -236,11 +247,12 @@ private void write(String file, String content) writer.close(); } - public void save() { + public VitaminBomManager save() { saveLocal(); + return this; } - public void loadBaseVitamins(MobileBase base) { + public VitaminBomManager loadBaseVitamins(MobileBase base) { for (VitaminLocation v : base.getVitamins()) { addVitamin(v); } @@ -255,6 +267,19 @@ public void loadBaseVitamins(MobileBase base) { } } } + return this; + } + + public static String getManufacturingBomJson() { + return MANUFACTURING_BOM_JSON; + } + + public static String getManufacturingBomCsv() { + return MANUFACTURING_BOM_CSV; + } + + public static String getManufacturingBomBase() { + return MANUFACTURING_BOM_BASE; } } From 5dc023bef71359ab6266da8645a13330b713c55c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 1 Dec 2024 20:44:51 -0500 Subject: [PATCH 219/635] Make sure the vitamins manager is loading the file and is ensuring there is just one of each name --- java-bowler | 2 +- .../scripting/cadoodle/AddFromScript.java | 35 +++++++++++++++---- .../vitamins/VitaminBomManager.java | 35 ++++++++++++++++--- 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/java-bowler b/java-bowler index af1c55a5..1e178525 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit af1c55a5f241389f6e074ed763b2ede020a5efda +Subproject commit 1e178525a0c87c912e2936d9108a4b894cd6d9f3 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 6c93d783..176b5e60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Random; @@ -15,6 +16,8 @@ import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -28,7 +31,8 @@ public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperatio private String name=null; @Expose(serialize = true, deserialize = true) private TransformNR location =null; - + @Expose(serialize = true, deserialize = true) + private Boolean preventBoM =false; @@ -46,6 +50,7 @@ public String getType() { @Override public List process(List incoming) { + nameIndex=0; ArrayList back = new ArrayList(); back.addAll(incoming); @@ -55,20 +60,27 @@ public List process(List incoming) { try { ArrayListargs = new ArrayList<>(); args.addAll(Arrays.asList(name )); - back.addAll(ScriptingEngine + HashMap configs =new HashMap(); + configs.put("name", name); + configs.put("PreventBomAdd", preventBoM); + args.add(configs); + ArrayList collect = ScriptingEngine .flaten(gitULR, fileRel, CSG.class,args) .stream() .map(csg->{ return csg -// .moveToCenterX() -// .moveToCenterY() -// .toZMin() .transformed(TransformFactory.nrToCSG( getLocation() )) .syncProperties(csg) .setName(getOrderedName()); }) - .collect(Collectors.toCollection(ArrayList::new)) - ); + .collect(Collectors.toCollection(ArrayList::new)); + back.addAll(collect); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(name); + if(loc!=null) { + loc.setLocation(location); + boM.save(); + } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -108,4 +120,13 @@ public File getFile() { } } + public Boolean getPreventBoM() { + return preventBoM; + } + + public AddFromScript setPreventBoM(Boolean preventBoM) { + this.preventBoM = preventBoM; + return this; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index c0551ea5..5af9204f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -78,8 +78,32 @@ public VitaminBomManager(File parentFile) { save(); } } - + public VitaminLocation getByName(String name) { + for(String keys:database.keySet()) { + ArrayList arrayList = database.get(keys); + for (int i = 0; i < arrayList.size(); i++) { + VitaminLocation vl = arrayList.get(i); + if(vl.getName().contentEquals(name)) { + return vl; + } + } + } + return null; + } public VitaminBomManager addVitamin(VitaminLocation newElement) { + return addVitamin(newElement,true); + } + public VitaminBomManager addVitamin(VitaminLocation newElement, boolean save) { + for(String keys:database.keySet()) { + ArrayList arrayList = database.get(keys); + for (int i = 0; i < arrayList.size(); i++) { + VitaminLocation vl = arrayList.get(i); + if(vl.getName().contentEquals(newElement.getName())) { + arrayList.remove(vl); + break; + } + } + } String key = newElement.getType() + ":" + newElement.getSize(); // synchronized (database) { if (database.get(key) == null) { @@ -98,7 +122,7 @@ public VitaminBomManager addVitamin(VitaminLocation newElement) { if (toAdd) arrayList.add(newElement); // } - save(); + if(save)save(); return this; } @@ -156,12 +180,13 @@ public Map getConfiguration(String name) throws Exception { return Vitamins.getConfiguration(e.getType(), e.getSize()); } - private VitaminLocation getElement(String name) { + public VitaminLocation getElement(String name) { // synchronized (database) { for (String testName : database.keySet()) { ArrayList list = database.get(testName); for (VitaminLocation el : list) { - if (el.getName().contentEquals(name)) + String name2 = el.getName(); + if (name2.contentEquals(name)) return el; } } @@ -176,7 +201,7 @@ public VitaminBomManager clear() { return this; } - private void saveLocal() { + private synchronized void saveLocal() { saving = true; String csv = "name,qty,source,unit price (USD)\n"; String content = null; From 5e86b898c9bcddd6813ef30a1f99658f0cbcde65 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 2 Dec 2024 21:30:44 -0500 Subject: [PATCH 220/635] Adding Bom to all cadoodle opperations that woudl interact with the Bom --- .../scripting/cadoodle/AddFromFile.java | 27 +++++++++++++++++-- .../scripting/cadoodle/CaDoodleFile.java | 11 ++++++-- .../scripting/cadoodle/Delete.java | 8 ++++++ .../scripting/cadoodle/MoveCenter.java | 8 ++++++ .../scripting/cadoodle/Paste.java | 11 ++++++++ .../vitamins/VitaminBomManager.java | 13 +++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 40340454..3c22831c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -7,6 +7,7 @@ import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.stream.Collectors; @@ -15,6 +16,8 @@ import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -29,7 +32,8 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation private TransformNR location = null; private ArrayList options = new ArrayList(); private StringParameter parameter = null; - + @Expose(serialize = true, deserialize = true) + private Boolean preventBoM =false; public AddFromFile set(File source) { String absolutePath = toLocal(source).getAbsolutePath(); getParameter(absolutePath).setStrValue(absolutePath); @@ -57,7 +61,13 @@ public List process(List incoming) { File file = getFile(); String pathname = file.getAbsolutePath(); getParameter(pathname).setStrValue(pathname); - List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); + ArrayListargs = new ArrayList<>(); + args.addAll(Arrays.asList(name )); + HashMap configs =new HashMap(); + configs.put("name", name); + configs.put("PreventBomAdd", preventBoM); + args.add(configs); + List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); com.neuronrobotics.sdk.common.Log.error("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); @@ -69,6 +79,12 @@ public List process(List incoming) { } } back.addAll(collect); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(name); + if(loc!=null) { + loc.setLocation(location); + boM.save(); + } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -193,5 +209,12 @@ public StringParameter getParameter(String defaultVal) { public void setParameter(StringParameter parameter) { this.parameter = parameter; } + public Boolean getPreventBoM() { + return preventBoM; + } + public AddFromFile setPreventBoM(Boolean preventBoM) { + this.preventBoM = preventBoM; + return this; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 87b1f88c..d08cc0ff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -67,6 +67,8 @@ public class CaDoodleFile { private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; + private static HashMap bomManagers = new HashMap<>(); + private VitaminBomManager boM; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -112,7 +114,8 @@ public void initialize() { StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); loc.setStrValue(selfInternal.getAbsolutePath()); - CaDoodleFile.getBoM().save(); + boM = CaDoodleFile.getBoM(); + boM.save(); } int indexStarting = getCurrentIndex(); @@ -143,10 +146,13 @@ public void initialize() { initializing = false; } public static VitaminBomManager getBoM() { + StringParameter loc = new StringParameter("CaDoodle_File_Location", "", new ArrayList()); String strValue = loc.getStrValue(); - return new VitaminBomManager(new File(strValue).getParentFile()); + if(bomManagers.get(strValue)==null) + bomManagers.put(strValue, new VitaminBomManager(new File(strValue).getParentFile())); + return bomManagers.get(strValue); } public Thread regenerateFrom(ICaDoodleOpperation source) { @@ -471,6 +477,7 @@ public File save() throws IOException { // e.getMessage()); e.printStackTrace(); } + boM.save(); } return getSelf(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 4400be52..25b18ac2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -6,6 +6,8 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -31,6 +33,12 @@ public List process(List incoming) { for(String s:names) { if(s.contentEquals(c.getName())) { back.remove(c); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(s); + if(loc!=null) { + boM.remove(loc); + boM.save(); + } } } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index dd3df809..7acce4be 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -7,6 +7,8 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -52,6 +54,12 @@ private void moveByName(String name, ArrayList back, HashSet groups .transformed(TransformFactory.nrToCSG(location)) .syncProperties(csg) .setName(csg.getName()); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(name); + if(loc!=null) { + loc.setLocation(loc.getLocation().times(location)); + boM.save(); + } back.set(i, tmpToAdd); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 8ca07a68..d0771d74 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -7,6 +7,8 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -63,8 +65,17 @@ public List process(List incoming) { } private int copyPasteMoved(ArrayList back, int index, CSG c) { + CSG newOne = c.clone().movex(offset); String name = getPaserID()+(index==0?"":"_"+index); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(c.getName()); + if(loc!=null) { + VitaminLocation newElement = new VitaminLocation(loc, name); + newElement.setLocation(newElement.getLocation().times(new TransformNR(offset,0,0))); + boM.addVitamin(newElement); + boM.save(); + } index++; newOne.syncProperties(c).setName(name); back.add(newOne); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 5af9204f..113069fb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -307,4 +307,17 @@ public static String getManufacturingBomBase() { return MANUFACTURING_BOM_BASE; } + public void remove(VitaminLocation loc) { + for(String keys:database.keySet()) { + ArrayList arrayList = database.get(keys); + for (int i = 0; i < arrayList.size(); i++) { + VitaminLocation vl = arrayList.get(i); + if(vl.getName().contentEquals(loc.getName())) { + arrayList.remove(vl); + return; + } + } + } + } + } From 4d7788d3e2965407c78a0270604872798d197c2a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 3 Dec 2024 10:43:18 -0500 Subject: [PATCH 221/635] java --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 1e178525..cf9ccba1 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 1e178525a0c87c912e2936d9108a4b894cd6d9f3 +Subproject commit cf9ccba176094f6a58a1d5a80b34b923d7afe6b2 From dcdb98c90494eb3a0b0ea690170add43c5a55079 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 4 Dec 2024 12:40:06 -0500 Subject: [PATCH 222/635] add a recoursice opperator to the cadoodle file class to apply an opperation to all elements recoursivly --- .../scripting/cadoodle/CaDoodleFile.java | 24 +++++- .../scripting/cadoodle/Delete.java | 23 ++++-- .../cadoodle/ICadoodleRecursiveEvent.java | 7 ++ .../scripting/cadoodle/MoveCenter.java | 73 +++++++++++-------- 4 files changed, 88 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index d08cc0ff..81e68955 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -7,6 +7,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -23,9 +24,11 @@ import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.BowlerKernel; import com.neuronrobotics.bowlerstudio.creature.ThumbnailImage; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -226,7 +229,26 @@ public Thread regenerateCurrent() { return opperationRunner; } - + public static void getAllConstituantElements(String name, ArrayList back, HashSet groupsProcessed ,ICadoodleRecursiveEvent p) { + for (int i = 0; i < back.size(); i++) { + CSG csg = back.get(i); + if(csg.isLock()) + continue; + if ( csg.getName().contentEquals(name) || + (csg.isInGroup() && csg.checkGroupMembership(name))){ + groupsProcessed.add(name); + if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { + // composite group + getAllConstituantElements(csg.getName(), back,groupsProcessed,p); + + } + // move it + CSG tmpToAdd = p.process(csg); + back.set(i, tmpToAdd); + } + } + back.removeAll(Collections.singleton(null)); + } private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 25b18ac2..cc2d272a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -27,19 +28,25 @@ public String getType() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); + HashSet groupsProcessed = new HashSet(); + for(CSG c:incoming) { if(c.isLock()) continue; for(String s:names) { - if(s.contentEquals(c.getName())) { - back.remove(c); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(s); - if(loc!=null) { - boM.remove(loc); - boM.save(); + CaDoodleFile.getAllConstituantElements(s, back, groupsProcessed, new ICadoodleRecursiveEvent() { + @Override + public CSG process(CSG incoming) { + //back.remove(c); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(s); + if(loc!=null) { + boM.remove(loc); + boM.save(); + } + return null; } - } + }); } } return back; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java new file mode 100644 index 00000000..3f75eaa5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import eu.mihosoft.vrl.v3d.CSG; + +public interface ICadoodleRecursiveEvent { + public CSG process(CSG incoming); +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 7acce4be..d1aa2255 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -30,40 +30,53 @@ public List process(List incoming) { HashSet groupsProcessed = new HashSet(); back.addAll(incoming); for (String name : names) { - moveByName(name,back,groupsProcessed); + CaDoodleFile.getAllConstituantElements(name, back, groupsProcessed, new ICadoodleRecursiveEvent() { + @Override + public CSG process(CSG incoming) { + CSG tmpToAdd = incoming.transformed(TransformFactory.nrToCSG(location)).syncProperties(incoming) + .setName(incoming.getName()); + VitaminBomManager boM = CaDoodleFile.getBoM(); + VitaminLocation loc = boM.getByName(name); + if (loc != null) { + loc.setLocation(loc.getLocation().times(location)); + boM.save(); + } + return tmpToAdd; + } + }); } return back; } - private void moveByName(String name, ArrayList back, HashSet groupsProcessed) { - - for (int i = 0; i < back.size(); i++) { - CSG csg = back.get(i); - if(csg.isLock()) - continue; - if ( csg.getName().contentEquals(name) || - (csg.isInGroup() && csg.checkGroupMembership(name))){ - groupsProcessed.add(name); - if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { - // composite group - moveByName(csg.getName(), back,groupsProcessed); - - } - // move it - CSG tmpToAdd = csg - .transformed(TransformFactory.nrToCSG(location)) - .syncProperties(csg) - .setName(csg.getName()); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(name); - if(loc!=null) { - loc.setLocation(loc.getLocation().times(location)); - boM.save(); - } - back.set(i, tmpToAdd); - } - } - } +// private void moveByName(String name, ArrayList back, HashSet groupsProcessed) { +// +// for (int i = 0; i < back.size(); i++) { +// CSG csg = back.get(i); +// if(csg.isLock()) +// continue; +// if ( csg.getName().contentEquals(name) || +// (csg.isInGroup() && csg.checkGroupMembership(name))){ +// groupsProcessed.add(name); +// if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { +// // composite group +// moveByName(csg.getName(), back,groupsProcessed); +// +// } +// // move it +// CSG tmpToAdd = csg +// .transformed(TransformFactory.nrToCSG(location)) +// .syncProperties(csg) +// .setName(csg.getName()); +// VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminLocation loc = boM.getByName(name); +// if(loc!=null) { +// loc.setLocation(loc.getLocation().times(location)); +// boM.save(); +// } +// back.set(i, tmpToAdd); +// } +// } +// } public TransformNR getLocation() { return location; From e1533044ca345c8507ec945469df9b8559931e31 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 7 Dec 2024 11:13:33 -0500 Subject: [PATCH 223/635] Adding a cadoodle vitamins manager --- .../scripting/cadoodle/CaDoodleVitamin.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java new file mode 100644 index 00000000..ead27ecb --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -0,0 +1,51 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.util.ArrayList; +import java.util.HashMap; + +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.IRegenerate; +import eu.mihosoft.vrl.v3d.parametrics.StringParameter; + +public class CaDoodleVitamin { + public static CSG get(String type, ArrayList args) { + ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); + String name = args.get(0).toString(); + StringParameter size = new StringParameter(type + " Default", listVitaminSizes.get(0), listVitaminSizes); + if (size.getStrValue().length() == 0) + size.setStrValue(listVitaminSizes.get(0)); + StringParameter word = new StringParameter(name + "_CaDoodle_Vitamin_Size", size.getStrValue(), + listVitaminSizes); + size.setStrValue(word.getStrValue()); + if (args.size() > 1) { + HashMap object = (HashMap) args.get(1); + if (!(Boolean) object.get("PreventBomAdd")) { + VitaminLocation vl = new VitaminLocation(false, name, type, word.getStrValue(), new TransformNR()); + CaDoodleFile.getBoM().addVitamin(vl, true); + } + } + CSG part; + try { + part = Vitamins.get(type, word.getStrValue()).setIsHole(true); + CSGDatabase.saveDatabase(); + return part.setParameter(word).setRegenerate(new IRegenerate() { + @Override + public CSG regenerate(CSG previous) { + ArrayList ar = new ArrayList<>(); + ar.addAll(args); + ar.set(0, previous.getName()); + return CaDoodleVitamin.get(type, ar); + } + }); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + throw new RuntimeException("Failed to load vitamin of type " + type); + } +} From 75e3928e32517dd467e8d434d3ab791abdf16494 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 12:59:57 -0500 Subject: [PATCH 224/635] ensuring the regeneration is preserved through the stack --- build.gradle | 2 +- .../scripting/cadoodle/AddFromScript.java | 32 +++++++---- .../scripting/cadoodle/CaDoodleFile.java | 2 +- .../scripting/cadoodle/CaDoodleVitamin.java | 14 ++++- .../scripting/cadoodle/Group.java | 2 +- .../bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../bowlerstudio/scripting/cadoodle/Lock.java | 2 +- .../scripting/cadoodle/Paste.java | 56 ++++++++++--------- .../bowlerstudio/scripting/cadoodle/Show.java | 2 +- .../scripting/cadoodle/ToHole.java | 2 +- .../scripting/cadoodle/ToSolid.java | 2 +- .../scripting/cadoodle/UnGroup.java | 2 +- .../scripting/cadoodle/UnLock.java | 2 +- .../bowlerstudio/vitamins/Vitamins.java | 3 +- 14 files changed, 73 insertions(+), 52 deletions(-) diff --git a/build.gradle b/build.gradle index ec0d0763..5dec3dee 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.3' + api 'com.neuronrobotics:JavaCad:2.0.5' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 176b5e60..d312a2dd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -64,16 +64,19 @@ public List process(List incoming) { configs.put("name", name); configs.put("PreventBomAdd", preventBoM); args.add(configs); - ArrayList collect = ScriptingEngine - .flaten(gitULR, fileRel, CSG.class,args) - .stream() - .map(csg->{ - return csg - .transformed(TransformFactory.nrToCSG( getLocation() )) - .syncProperties(csg) - .setName(getOrderedName()); - }) - .collect(Collectors.toCollection(ArrayList::new)); + List flaten = ScriptingEngine + .flaten(gitULR, fileRel, CSG.class,args); + ArrayList collect = new ArrayList<>(); + collect.addAll(flaten); + for(int i=0;i process(List incoming) { boM.save(); } } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if(!fileRel.contains("generated")) + try { + fileRel="generated/"+fileRel; + return process(incoming); + }catch(Exception e2) { + e2.printStackTrace(); + } } return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 81e68955..8ffc0785 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -311,7 +311,7 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { if (names.contains(c.getName())) throw new RuntimeException("There can not be 2 objects with the same name after an opperation!"); names.add(c.getName()); - cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName())); + cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()).setRegenerate(c.getRegenerate())); } cache.put(op, cachedCopy); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index ead27ecb..3df757fd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Set; import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; @@ -19,7 +20,8 @@ public static CSG get(String type, ArrayList args) { StringParameter size = new StringParameter(type + " Default", listVitaminSizes.get(0), listVitaminSizes); if (size.getStrValue().length() == 0) size.setStrValue(listVitaminSizes.get(0)); - StringParameter word = new StringParameter(name + "_CaDoodle_Vitamin_Size", size.getStrValue(), + String string = "_CaDoodle_Vitamin_Size"; + StringParameter word = new StringParameter(name + string, size.getStrValue(), listVitaminSizes); size.setStrValue(word.getStrValue()); if (args.size() > 1) { @@ -33,12 +35,20 @@ public static CSG get(String type, ArrayList args) { try { part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); + Set params = part.getParameters(); + for(String s:params) { + if(s.contains(string)) { + part.getMapOfparametrics().remove(s); + } + } return part.setParameter(word).setRegenerate(new IRegenerate() { @Override public CSG regenerate(CSG previous) { + String name2 = previous.getName(); + System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); - ar.set(0, previous.getName()); + ar.set(0, name2); return CaDoodleVitamin.get(type, ar); } }); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index eb0a8d64..b7dca826 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -35,7 +35,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(csg.getName())) { replace.add(csg); - CSG c=csg.clone().syncProperties(csg).setName(name); + CSG c=csg.clone().syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); if(csg.isHole()) { holes.add(c); }else diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 362b12c7..38389fb4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsHide(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index b09f5f35..ff2e3e41 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsLock(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index d0771d74..4357aaf2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -14,17 +14,17 @@ import eu.mihosoft.vrl.v3d.CSG; public class Paste implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private TransformNR location=new TransformNR(); - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) + private TransformNR location = new TransformNR(); + @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); - @Expose (serialize = true, deserialize = true) - public String paste=null; - @Expose (serialize = true, deserialize = true) - public double offset=10; - @Expose (serialize = false, deserialize = false) + @Expose(serialize = true, deserialize = true) + public String paste = null; + @Expose(serialize = true, deserialize = true) + public double offset = 10; + @Expose(serialize = false, deserialize = false) public HashSet newNames = new HashSet(); - + @Override public String getType() { return "Paste"; @@ -34,24 +34,24 @@ public String getType() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - int index=0; + int index = 1; for (int i = 0; i < incoming.size(); i++) { CSG c = incoming.get(i); - for(String s:names) { - if(s.contentEquals(c.getName())) { + for (String s : names) { + if (s.contentEquals(c.getName())) { index = copyPasteMoved(back, index, c); - if(c.isGroupResult()) { + if (c.isGroupResult()) { String groupName = c.getName(); - CSG newGroupResult= back.get(back.size()-1); + CSG newGroupResult = back.get(back.size() - 1); newGroupResult.removeIsGroupResult(groupName); newGroupResult.addIsGroupResult(newGroupResult.getName()); - for(int j=0;j process(List incoming) { } private int copyPasteMoved(ArrayList back, int index, CSG c) { - - CSG newOne = c.clone().movex(offset); - String name = getPaserID()+(index==0?"":"_"+index); + String name = getPaserID() + (index == 0 ? "" : "_" + index); + CSG clone = c.clone(); + clone.setRegenerate(c.getRegenerate()).setName(name); + CSG newOne = clone.regenerate().movex(offset); VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(c.getName()); - if(loc!=null) { + VitaminLocation loc = boM.getByName(name); + if (loc != null) { VitaminLocation newElement = new VitaminLocation(loc, name); - newElement.setLocation(newElement.getLocation().times(new TransformNR(offset,0,0))); + newElement.setLocation(newElement.getLocation().times(new TransformNR(offset, 0, 0))); boM.addVitamin(newElement); boM.save(); } @@ -100,9 +101,10 @@ public Paste setNames(List names) { this.names = names; return this; } + public String getPaserID() { - if(paste==null) - paste=RandomStringFactory.generateRandomString(); + if (paste == null) + paste = RandomStringFactory.generateRandomString(); return paste; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 1b02bcd2..8471fc03 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsHide(false); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index 1f21c248..323f37ed 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -26,7 +26,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsHole(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index d9bc9ac7..7900166b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -38,7 +38,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG t=c.clone().syncProperties(c); + CSG t=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); t.setIsHole(false); if(useColor) { t.setColor(getColor()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index a181128b..cb6a6cd4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -30,7 +30,7 @@ public List process(List incoming) { if (csg.isInGroup()) { if (csg.checkGroupMembership(name)) { // release this object from the group - CSG readd= csg.clone().syncProperties(csg).setName(csg.getName()); + CSG readd= csg.clone().setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); readd.removeGroupMembership(name); back.remove(csg); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index 0082961a..8f12e0bb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsLock(false); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index ab1db3e4..a31708c8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -120,8 +120,9 @@ public static CSG get(File resource, boolean forceRefresh) { e.printStackTrace(); } } + CSG csg = fileLastLoaded.get(resource.getAbsolutePath()); - return fileLastLoaded.get(resource.getAbsolutePath()).clone(); + return csg.clone().setRegenerate(csg.getRegenerate()).syncProperties(csg); } public static CSG get(String type, String id, String purchasingVariant) throws Exception { From 08ed28844a700f946c337791b4a7c1663ebd6d17 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 13:48:07 -0500 Subject: [PATCH 225/635] make the doodle file opperations update the names added and be part of the addFrom classes --- java-bowler | 2 +- .../scripting/cadoodle/AbstractAddFrom.java | 18 +++++++++++++---- .../scripting/cadoodle/AddFromFile.java | 12 ----------- .../scripting/cadoodle/AddFromScript.java | 20 +++++-------------- .../scripting/cadoodle/CaDoodleVitamin.java | 17 +++++++++++++++- .../scripting/cadoodle/Group.java | 10 ++++++++-- .../scripting/cadoodle/Paste.java | 15 ++++++++------ .../scripting/cadoodle/UnGroup.java | 10 ++++++++-- 8 files changed, 61 insertions(+), 43 deletions(-) diff --git a/java-bowler b/java-bowler index cf9ccba1..a359eb82 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit cf9ccba176094f6a58a1d5a80b34b923d7afe6b2 +Subproject commit a359eb822352ab2697f152ec513a93f461e35fca diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index eae14606..e2462731 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.HashSet; import com.google.gson.annotations.Expose; @@ -10,13 +11,21 @@ public abstract class AbstractAddFrom implements ICaDoodleOpperation { protected HashSet namesAdded = new HashSet<>(); @Expose (serialize = false, deserialize = false) protected int nameIndex = 0; - + @Expose(serialize = true, deserialize = true) + protected String name = null; public HashSet getNamesAdded() { return namesAdded; } - public abstract String getName(); + public String getName() { + if (name == null) { + setName(RandomStringFactory.generateRandomString()); + } + return name; + } - public abstract void setName(String name); + public void setName(String name) { + this.name = name; + } public String getOrderedName() { if(getName()==null) { @@ -30,7 +39,8 @@ public String getOrderedName() { namesAdded.add(result); return result; } - public abstract File getFile(); + + public abstract File getFile()throws NoSuchFileException; @Override public String toString() { return getType()+" with name "+getName(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 3c22831c..ec5f9ac4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -25,9 +25,6 @@ import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { - - @Expose(serialize = true, deserialize = true) - private String name = null; @Expose(serialize = true, deserialize = true) private TransformNR location = null; private ArrayList options = new ArrayList(); @@ -189,16 +186,7 @@ public AddFromFile setLocation(TransformNR location) { return this; } - public String getName() { - if (name == null) { - setName(RandomStringFactory.generateRandomString()); - } - return name; - } - public void setName(String name) { - this.name = name; - } public StringParameter getParameter(String defaultVal) { if (parameter == null) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index d312a2dd..ecb96770 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -27,8 +27,7 @@ public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperatio private String gitULR = ""; @Expose (serialize = true, deserialize = true) private String fileRel = ""; - @Expose (serialize = true, deserialize = true) - private String name=null; + @Expose(serialize = true, deserialize = true) private TransformNR location =null; @Expose(serialize = true, deserialize = true) @@ -54,14 +53,12 @@ public List process(List incoming) { nameIndex=0; ArrayList back = new ArrayList(); back.addAll(incoming); - if(name==null) { - name=RandomStringFactory.generateRandomString(); - } + try { ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(name )); + args.addAll(Arrays.asList(getName() )); HashMap configs =new HashMap(); - configs.put("name", name); + configs.put("name", getName()); configs.put("PreventBomAdd", preventBoM); args.add(configs); List flaten = ScriptingEngine @@ -79,7 +76,7 @@ public List process(List incoming) { } back.addAll(collect); VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(name); + VitaminLocation loc = boM.getByName(getName()); if(loc!=null) { loc.setLocation(location); boM.save(); @@ -108,13 +105,6 @@ public AddFromScript setLocation(TransformNR location) { this.location = location; return this; } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } @Override public File getFile() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 3df757fd..dc8312d6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -17,6 +17,7 @@ public class CaDoodleVitamin { public static CSG get(String type, ArrayList args) { ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); String name = args.get(0).toString(); + StringParameter size = new StringParameter(type + " Default", listVitaminSizes.get(0), listVitaminSizes); if (size.getStrValue().length() == 0) size.setStrValue(listVitaminSizes.get(0)); @@ -27,21 +28,33 @@ public static CSG get(String type, ArrayList args) { if (args.size() > 1) { HashMap object = (HashMap) args.get(1); if (!(Boolean) object.get("PreventBomAdd")) { + VitaminLocation vl = new VitaminLocation(false, name, type, word.getStrValue(), new TransformNR()); + System.out.println("BoM update "+vl); CaDoodleFile.getBoM().addVitamin(vl, true); } } CSG part; try { + System.out.println("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); Set params = part.getParameters(); for(String s:params) { if(s.contains(string)) { + System.out.println("Removing stale parameter "+s); part.getMapOfparametrics().remove(s); + CSGDatabase.delete(s); } } - return part.setParameter(word).setRegenerate(new IRegenerate() { + part.setParameter(word); + params = part.getParameters(); + + System.out.println("Parameters on Vitamin: "+name); + for(String s:params) { + System.out.println("\t"+s); + } + CSG back = part.setRegenerate(new IRegenerate() { @Override public CSG regenerate(CSG previous) { String name2 = previous.getName(); @@ -52,6 +65,8 @@ public CSG regenerate(CSG previous) { return CaDoodleVitamin.get(type, ar); } }); + + return back; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index b7dca826..5c139816 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -1,5 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -10,7 +12,7 @@ import eu.mihosoft.vrl.v3d.parametrics.IParametric; import javafx.scene.paint.Color; -public class Group implements ICaDoodleOpperation { +public class Group extends AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) @@ -77,6 +79,7 @@ public List process(List incoming) { mapOfparametrics.clear(); result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); + namesAdded.add(result.getName()); back.add(result); return back; } @@ -100,5 +103,8 @@ public Group setHull(boolean hull) { this.hull = hull; return this; } - + @Override + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(null); + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 4357aaf2..e735ca94 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -1,5 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -13,7 +15,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Paste implements ICaDoodleOpperation { +public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) @@ -22,8 +24,6 @@ public class Paste implements ICaDoodleOpperation { public String paste = null; @Expose(serialize = true, deserialize = true) public double offset = 10; - @Expose(serialize = false, deserialize = false) - public HashSet newNames = new HashSet(); @Override public String getType() { @@ -80,7 +80,7 @@ private int copyPasteMoved(ArrayList back, int index, CSG c) { index++; newOne.syncProperties(c).setName(name); back.add(newOne); - getNewNames().add(name); + getNamesAdded().add(name); return index; } @@ -113,7 +113,10 @@ public Paste setOffset(double offset) { return this; } - public HashSet getNewNames() { - return newNames; + + + @Override + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(null); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index cb6a6cd4..166831fe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -1,5 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.List; @@ -7,7 +9,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class UnGroup implements ICaDoodleOpperation { +public class UnGroup extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @@ -15,7 +17,10 @@ public class UnGroup implements ICaDoodleOpperation { public String getType() { return "Un-Group"; } - + @Override + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(null); + } @Override public List process(List incoming) { ArrayList back = new ArrayList(); @@ -35,6 +40,7 @@ public List process(List incoming) { readd.removeGroupMembership(name); back.remove(csg); back.add(readd); + namesAdded.add(readd.getName()); } } From e8aa3ea46341dc393e078a79fb380404498adf7a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 15:16:14 -0500 Subject: [PATCH 226/635] update the Bom on prune forward --- .../scripting/cadoodle/CaDoodleFile.java | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8ffc0785..aaa2cd1e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -34,6 +34,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.IParametric; +import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import javafx.embed.swing.SwingFXUtils; @@ -118,6 +120,7 @@ public void initialize() { new ArrayList()); loc.setStrValue(selfInternal.getAbsolutePath()); boM = CaDoodleFile.getBoM(); + boM.clear(); boM.save(); } @@ -150,12 +153,19 @@ public void initialize() { } public static VitaminBomManager getBoM() { + String strValue = getCadoodleFileLocation(); + File file = new File(strValue).getParentFile(); + if(bomManagers.get(strValue)==null) { + bomManagers.put(strValue, new VitaminBomManager(file)); + } + return bomManagers.get(strValue); + } + + private static String getCadoodleFileLocation() { StringParameter loc = new StringParameter("CaDoodle_File_Location", "", new ArrayList()); String strValue = loc.getStrValue(); - if(bomManagers.get(strValue)==null) - bomManagers.put(strValue, new VitaminBomManager(new File(strValue).getParentFile())); - return bomManagers.get(strValue); + return strValue; } public Thread regenerateFrom(ICaDoodleOpperation source) { @@ -293,7 +303,43 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { - List back = cache.remove(getOpperations().get(i)); + ICaDoodleOpperation key = getOpperations().get(i); + List back = cache.remove(key); + VitaminBomManager boM = CaDoodleFile.getBoM(); + if(AbstractAddFrom.class.isInstance(key)) { + AbstractAddFrom aaf=(AbstractAddFrom)key; + for(String name:aaf.getNamesAdded()) { + VitaminLocation loc = boM.getByName(name); + if(loc!=null) { + boM.remove(loc); + boM.save(); + } + } + } + if(Delete.class.isInstance(key)) { + Delete d =(Delete)key; + for(String s:d.getNames()) { + for(CSG c:back) { + String type =null; + String size=null; + if(c.getName().contentEquals(s)) { + for(String param:c.getParameters()) { + if(param.contains("_CaDoodle_Vitamin_Type")) { + Parameter p = CSGDatabase.get(param); + type=p.getStrValue(); + } + if(param.contains("_CaDoodle_Vitamin_Size")) { + Parameter p = CSGDatabase.get(param); + size=p.getStrValue(); + } + } + if(type!=null&&size!=null) { + boM.addVitamin(new VitaminLocation(false,c.getName(), type, size, new TransformNR())); + } + } + } + } + } if (back != null) back.clear(); } From 7b33da4f75612c29794c06345dd1cbae6ccfa854 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 15:16:34 -0500 Subject: [PATCH 227/635] Add the vitamin type to the parameters --- .../scripting/cadoodle/CaDoodleVitamin.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index dc8312d6..40fe54b3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -14,16 +14,36 @@ import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class CaDoodleVitamin { - public static CSG get(String type, ArrayList args) { - ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); + public static CSG get(String typencoming, ArrayList args) { String name = args.get(0).toString(); + + ArrayListtypes=new ArrayList<>(); + types.addAll(Vitamins.listVitaminTypes()); + StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming, + types); + String type=typeParam.getStrValue(); + ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); StringParameter size = new StringParameter(type + " Default", listVitaminSizes.get(0), listVitaminSizes); - if (size.getStrValue().length() == 0) + + String strValue = size.getStrValue(); + if(strValue.length() == 0) { size.setStrValue(listVitaminSizes.get(0)); + } String string = "_CaDoodle_Vitamin_Size"; - StringParameter word = new StringParameter(name + string, size.getStrValue(), + StringParameter word = new StringParameter(name + string, strValue, listVitaminSizes); + boolean sizeExists=false; + for(String s:Vitamins.listVitaminSizes(type)) { + if(s.contentEquals(word.getStrValue())) { + sizeExists=true; + break; + } + } + if(!sizeExists) { + + word.setStrValue(strValue); + } size.setStrValue(word.getStrValue()); if (args.size() > 1) { HashMap object = (HashMap) args.get(1); @@ -40,14 +60,9 @@ public static CSG get(String type, ArrayList args) { part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); Set params = part.getParameters(); - for(String s:params) { - if(s.contains(string)) { - System.out.println("Removing stale parameter "+s); - part.getMapOfparametrics().remove(s); - CSGDatabase.delete(s); - } - } + part.setParameter(word); + part.setParameter(typeParam); params = part.getParameters(); System.out.println("Parameters on Vitamin: "+name); From 6158105ade08f1ef054a7387a22acbe1fd095dd8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 15:16:50 -0500 Subject: [PATCH 228/635] remove junk print --- .../bowlerstudio/vitamins/VitaminBomManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 113069fb..2d686b48 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -232,9 +232,7 @@ private synchronized void saveLocal() { object = "0.01"; csv += key + "," + size + "," + URL + "," + object + "\n"; - } else { - com.neuronrobotics.sdk.common.Log.error("Failure on " + key); - } + } } if (baseURL != null) try { From 0f458ef0e6d4655246cd5fa46d14f82526ebaef2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 8 Dec 2024 15:29:56 -0500 Subject: [PATCH 229/635] Add getters for the files --- .../bowlerstudio/vitamins/VitaminBomManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 2d686b48..2c88ba76 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -50,7 +50,7 @@ public VitaminBomManager(String url) throws IOException { public VitaminBomManager(File parentFile) { baseWorkspaceFile = parentFile; - File bom = new File(baseWorkspaceFile.getAbsolutePath() + "/" + getManufacturingBomJson()); + File bom = getBomFile(); if (!bom.exists()) { if (!bom.getParentFile().exists()) { bom.getParentFile().mkdir(); @@ -78,6 +78,12 @@ public VitaminBomManager(File parentFile) { save(); } } + public File getBomCsv() { + return new File(baseWorkspaceFile.getAbsolutePath() + "/" + getManufacturingBomCsv()); + } + public File getBomFile() { + return new File(baseWorkspaceFile.getAbsolutePath() + "/" + getManufacturingBomJson()); + } public VitaminLocation getByName(String name) { for(String keys:database.keySet()) { ArrayList arrayList = database.get(keys); From 81a48df394632bf5e0f89ced1c5f05e607d69c5e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 8 Dec 2024 23:02:33 -0500 Subject: [PATCH 230/635] copy paste still not working correctly --- .../scripting/cadoodle/CaDoodleFile.java | 101 +++++++++++------- .../scripting/cadoodle/CaDoodleVitamin.java | 2 + .../scripting/cadoodle/Delete.java | 16 +-- .../cadoodle/ICadoodleRecursiveEvent.java | 4 +- .../scripting/cadoodle/MoveCenter.java | 8 +- .../scripting/cadoodle/Paste.java | 57 +++++----- 6 files changed, 106 insertions(+), 82 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index aaa2cd1e..b1ae2123 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -72,7 +72,7 @@ public class CaDoodleFile { private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; - private static HashMap bomManagers = new HashMap<>(); + private static HashMap bomManagers = new HashMap<>(); private VitaminBomManager boM; public void close() { @@ -151,19 +151,19 @@ public void initialize() { } initializing = false; } + public static VitaminBomManager getBoM() { - + String strValue = getCadoodleFileLocation(); File file = new File(strValue).getParentFile(); - if(bomManagers.get(strValue)==null) { + if (bomManagers.get(strValue) == null) { bomManagers.put(strValue, new VitaminBomManager(file)); } return bomManagers.get(strValue); } private static String getCadoodleFileLocation() { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "", - new ArrayList()); + StringParameter loc = new StringParameter("CaDoodle_File_Location", "", new ArrayList()); String strValue = loc.getStrValue(); return strValue; } @@ -239,26 +239,49 @@ public Thread regenerateCurrent() { return opperationRunner; } - public static void getAllConstituantElements(String name, ArrayList back, HashSet groupsProcessed ,ICadoodleRecursiveEvent p) { - for (int i = 0; i < back.size(); i++) { - CSG csg = back.get(i); - if(csg.isLock()) + + public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, + HashSet groupsProcessed, ICadoodleRecursiveEvent p) { + ArrayList immutable = new ArrayList<>(); + immutable.addAll(back); + for (int i = 0; i < immutable.size(); i++) { + CSG csg = immutable.get(i); + if (csg.isLock()) continue; - if ( csg.getName().contentEquals(name) || - (csg.isInGroup() && csg.checkGroupMembership(name))){ - groupsProcessed.add(name); - if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { - // composite group - getAllConstituantElements(csg.getName(), back,groupsProcessed,p); - - } + boolean inGroup = csg.isInGroup(); + boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); + String thisCSGName = csg.getName(); + boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); + boolean groupResult = csg.isGroupResult(); + + if (thisCSGIsTheTarget ) { + groupsProcessed.add(targetName); // move it - CSG tmpToAdd = p.process(csg); - back.set(i, tmpToAdd); + ArrayList tmpToAdd = p.process(csg); + if (addRet) { + back.addAll(tmpToAdd); + } else { + for (int j = 0; j < back.size(); j++) { + if (back.get(j).getName().contentEquals(csg.getName())) { + back.remove(j); + break; + } + } + back.addAll(tmpToAdd); + } + continue; + } + boolean contains = groupsProcessed.contains(thisCSGName); + boolean isContinue = (groupResult && thisCSGIsInGroupNamedAfterTarget) ; + if (isContinue) { + // composite group + applyToAllConstituantElements(addRet, thisCSGName, back, groupsProcessed, p); } } back.removeAll(Collections.singleton(null)); + return back.size(); } + private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); @@ -306,35 +329,35 @@ private void pruneForward() { ICaDoodleOpperation key = getOpperations().get(i); List back = cache.remove(key); VitaminBomManager boM = CaDoodleFile.getBoM(); - if(AbstractAddFrom.class.isInstance(key)) { - AbstractAddFrom aaf=(AbstractAddFrom)key; - for(String name:aaf.getNamesAdded()) { + if (AbstractAddFrom.class.isInstance(key)) { + AbstractAddFrom aaf = (AbstractAddFrom) key; + for (String name : aaf.getNamesAdded()) { VitaminLocation loc = boM.getByName(name); - if(loc!=null) { + if (loc != null) { boM.remove(loc); boM.save(); } } } - if(Delete.class.isInstance(key)) { - Delete d =(Delete)key; - for(String s:d.getNames()) { - for(CSG c:back) { - String type =null; - String size=null; - if(c.getName().contentEquals(s)) { - for(String param:c.getParameters()) { - if(param.contains("_CaDoodle_Vitamin_Type")) { + if (Delete.class.isInstance(key)) { + Delete d = (Delete) key; + for (String s : d.getNames()) { + for (CSG c : back) { + String type = null; + String size = null; + if (c.getName().contentEquals(s)) { + for (String param : c.getParameters()) { + if (param.contains("_CaDoodle_Vitamin_Type")) { Parameter p = CSGDatabase.get(param); - type=p.getStrValue(); + type = p.getStrValue(); } - if(param.contains("_CaDoodle_Vitamin_Size")) { + if (param.contains("_CaDoodle_Vitamin_Size")) { Parameter p = CSGDatabase.get(param); - size=p.getStrValue(); + size = p.getStrValue(); } } - if(type!=null&&size!=null) { - boM.addVitamin(new VitaminLocation(false,c.getName(), type, size, new TransformNR())); + if (type != null && size != null) { + boM.addVitamin(new VitaminLocation(false, c.getName(), type, size, new TransformNR())); } } } @@ -357,7 +380,8 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { if (names.contains(c.getName())) throw new RuntimeException("There can not be 2 objects with the same name after an opperation!"); names.add(c.getName()); - cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()).setRegenerate(c.getRegenerate())); + cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) + .setRegenerate(c.getRegenerate())); } cache.put(op, cachedCopy); } @@ -686,5 +710,4 @@ private void setRegenerating(boolean regenerating) { this.regenerating = regenerating; } - } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 40fe54b3..33dcb49f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -73,10 +73,12 @@ public static CSG get(String typencoming, ArrayList args) { @Override public CSG regenerate(CSG previous) { String name2 = previous.getName(); + System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); ar.set(0, name2); + return CaDoodleVitamin.get(type, ar); } }); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index cc2d272a..ba396ff7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -30,13 +30,13 @@ public List process(List incoming) { back.addAll(incoming); HashSet groupsProcessed = new HashSet(); - for(CSG c:incoming) { - if(c.isLock()) - continue; + //for(CSG c:incoming) { +// if(c.isLock()) +// continue; for(String s:names) { - CaDoodleFile.getAllConstituantElements(s, back, groupsProcessed, new ICadoodleRecursiveEvent() { + CaDoodleFile.applyToAllConstituantElements(false,s, back, groupsProcessed, new ICadoodleRecursiveEvent() { @Override - public CSG process(CSG incoming) { + public ArrayList process(CSG incoming) { //back.remove(c); VitaminBomManager boM = CaDoodleFile.getBoM(); VitaminLocation loc = boM.getByName(s); @@ -44,10 +44,12 @@ public CSG process(CSG incoming) { boM.remove(loc); boM.save(); } - return null; + ArrayList b = new ArrayList<>(); + b.add(null); + return b; } }); - } + //} } return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java index 3f75eaa5..178d2319 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java @@ -1,7 +1,9 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.util.ArrayList; + import eu.mihosoft.vrl.v3d.CSG; public interface ICadoodleRecursiveEvent { - public CSG process(CSG incoming); + public ArrayList process(CSG incoming); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index d1aa2255..81d6732f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -30,9 +30,9 @@ public List process(List incoming) { HashSet groupsProcessed = new HashSet(); back.addAll(incoming); for (String name : names) { - CaDoodleFile.getAllConstituantElements(name, back, groupsProcessed, new ICadoodleRecursiveEvent() { + CaDoodleFile.applyToAllConstituantElements(false,name, back, groupsProcessed, new ICadoodleRecursiveEvent() { @Override - public CSG process(CSG incoming) { + public ArrayList process(CSG incoming) { CSG tmpToAdd = incoming.transformed(TransformFactory.nrToCSG(location)).syncProperties(incoming) .setName(incoming.getName()); VitaminBomManager boM = CaDoodleFile.getBoM(); @@ -41,7 +41,9 @@ public CSG process(CSG incoming) { loc.setLocation(loc.getLocation().times(location)); boM.save(); } - return tmpToAdd; + ArrayList b = new ArrayList<>(); + b.add(tmpToAdd); + return b; } }); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index e735ca94..8d7aab12 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -24,6 +24,7 @@ public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { public String paste = null; @Expose(serialize = true, deserialize = true) public double offset = 10; + private int index; @Override public String getType() { @@ -34,43 +35,35 @@ public String getType() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - int index = 1; - for (int i = 0; i < incoming.size(); i++) { - CSG c = incoming.get(i); - for (String s : names) { - if (s.contentEquals(c.getName())) { - index = copyPasteMoved(back, index, c); - if (c.isGroupResult()) { - String groupName = c.getName(); - CSG newGroupResult = back.get(back.size() - 1); - newGroupResult.removeIsGroupResult(groupName); - newGroupResult.addIsGroupResult(newGroupResult.getName()); - for (int j = 0; j < incoming.size(); j++) { - CSG jc = incoming.get(j); - if (jc.isInGroup()) { - if (jc.checkGroupMembership(groupName)) { - // this pasted gropups member found - index = copyPasteMoved(back, index, jc); - CSG newCopyInGroup = back.get(back.size() - 1); - newCopyInGroup.removeGroupMembership(groupName); - newCopyInGroup.addGroupMembership(newGroupResult.getName()); - } - } - } - } + index = 1; + HashSet groupsProcessed = new HashSet(); + + for (int j = 0; j < names.size(); j++) { + String s = names.get(j); + CaDoodleFile.applyToAllConstituantElements(false, s, back, groupsProcessed, new ICadoodleRecursiveEvent() { + @Override + public ArrayList process(CSG ic) { + ArrayList copyPasteMoved = copyPasteMoved(back, ic); + return copyPasteMoved; } - } + }); } + return back; } - private int copyPasteMoved(ArrayList back, int index, CSG c) { + private ArrayList copyPasteMoved(ArrayList back, CSG c) { String name = getPaserID() + (index == 0 ? "" : "_" + index); CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); - CSG newOne = clone.regenerate().movex(offset); + + CSG newOne = clone.regenerate().moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) + .movex(offset); + newOne.setRegenerate(c.getRegenerate()).setName(name); VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(name); + String name2 = c.getName(); + VitaminLocation loc = boM.getByName(name2); + VitaminLocation locNew = boM.getByName(name); if (loc != null) { VitaminLocation newElement = new VitaminLocation(loc, name); newElement.setLocation(newElement.getLocation().times(new TransformNR(offset, 0, 0))); @@ -79,9 +72,11 @@ private int copyPasteMoved(ArrayList back, int index, CSG c) { } index++; newOne.syncProperties(c).setName(name); - back.add(newOne); getNamesAdded().add(name); - return index; + ArrayList b = new ArrayList<>(); + b.add(c); + b.add(newOne); + return b; } public TransformNR getLocation() { @@ -113,8 +108,6 @@ public Paste setOffset(double offset) { return this; } - - @Override public File getFile() throws NoSuchFileException { throw new NoSuchFileException(null); From 88dafafdd2dcddb6cc7bc230256ca84ecac5c6fa Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 9 Dec 2024 16:16:25 -0500 Subject: [PATCH 231/635] add what object was caulsing the problem to the exception --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b1ae2123..830ce44e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -378,7 +378,7 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { HashSet names = new HashSet<>(); for (CSG c : process) { if (names.contains(c.getName())) - throw new RuntimeException("There can not be 2 objects with the same name after an opperation!"); + throw new RuntimeException("There can not be 2 objects with the same name after an opperation! "+c.getName()); names.add(c.getName()); cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) .setRegenerate(c.getRegenerate())); From f14ebbde2b1c4db06293d850565f936175c554c2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Dec 2024 10:38:57 -0500 Subject: [PATCH 232/635] moving the parameters to the regeneration --- .../scripting/cadoodle/CaDoodleVitamin.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 33dcb49f..d0cbabb9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -11,11 +11,22 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.IRegenerate; +import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class CaDoodleVitamin { public static CSG get(String typencoming, ArrayList args) { String name = args.get(0).toString(); + ArrayListtypes=new ArrayList<>(); + types.addAll(Vitamins.listVitaminTypes()); + StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming, + types); + String type=typeParam.getStrValue(); + ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); + return get( type, listVitaminSizes.get(0), args); + } + public static CSG get(String typencoming,String defaultValue, ArrayList args) { + String name = args.get(0).toString(); ArrayListtypes=new ArrayList<>(); types.addAll(Vitamins.listVitaminTypes()); @@ -24,7 +35,7 @@ public static CSG get(String typencoming, ArrayList args) { String type=typeParam.getStrValue(); ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); - StringParameter size = new StringParameter(type + " Default", listVitaminSizes.get(0), listVitaminSizes); + StringParameter size = new StringParameter(type + " Default", defaultValue, listVitaminSizes); String strValue = size.getStrValue(); if(strValue.length() == 0) { @@ -78,8 +89,12 @@ public CSG regenerate(CSG previous) { ArrayList ar = new ArrayList<>(); ar.addAll(args); ar.set(0, name2); - - return CaDoodleVitamin.get(type, ar); + Parameter s = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Size"); + Parameter t = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Type"); + if(t==null) { + System.out.println("Error, type is null, previous "+name2+" has no parameters somehow??"); + } + return CaDoodleVitamin.get(t.getStrValue(),s.getStrValue(), ar); } }); From e3ebaad260a13e44c85cd9664a59e1b095763cc6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Dec 2024 10:49:06 -0500 Subject: [PATCH 233/635] Adding a path to pass the previous value through the CSG data --- .../scripting/cadoodle/CaDoodleVitamin.java | 13 +++++++++---- .../bowlerstudio/scripting/cadoodle/Paste.java | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index d0cbabb9..025e38b5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Optional; import java.util.Set; import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; @@ -83,8 +84,12 @@ public static CSG get(String typencoming,String defaultValue, ArrayList CSG back = part.setRegenerate(new IRegenerate() { @Override public CSG regenerate(CSG previous) { - String name2 = previous.getName(); - + Optional pv = previous.getStorage().getValue("PreviousName"); + String name2 = null; + if(pv.isPresent()) + name2=pv.get().toString(); + else + name2=name; System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); @@ -92,12 +97,12 @@ public CSG regenerate(CSG previous) { Parameter s = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Size"); Parameter t = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Type"); if(t==null) { - System.out.println("Error, type is null, previous "+name2+" has no parameters somehow??"); + System.out.println(" Error, type is null, previous "+name2+" has no parameters somehow??"); } return CaDoodleVitamin.get(t.getStrValue(),s.getStrValue(), ar); } }); - + //back.getStorage().set("PreviousName", name); return back; } catch (Exception e) { // TODO Auto-generated catch block diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 8d7aab12..a8e6f81b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -53,10 +53,11 @@ public ArrayList process(CSG ic) { } private ArrayList copyPasteMoved(ArrayList back, CSG c) { + String prevName = c.getName(); String name = getPaserID() + (index == 0 ? "" : "_" + index); CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); - + clone.getStorage().set("PreviousName", prevName); CSG newOne = clone.regenerate().moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) .movex(offset); newOne.setRegenerate(c.getRegenerate()).setName(name); From cafb037e35682c073f8c24dae007f244456f2a42 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Dec 2024 13:19:09 -0500 Subject: [PATCH 234/635] fix the copy/paste bug for vitamins --- .../bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 025e38b5..c937ed69 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -93,7 +93,7 @@ public CSG regenerate(CSG previous) { System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); - ar.set(0, name2); + ar.set(0, previous.getName()); Parameter s = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Size"); Parameter t = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Type"); if(t==null) { From 7f7df4b1f83c5fa096ad3c769e73bf792872c638 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Dec 2024 14:08:44 -0500 Subject: [PATCH 235/635] adjusting the recoursive application of operations to groups --- .../scripting/cadoodle/CaDoodleFile.java | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 830ce44e..12c7f392 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -239,49 +239,6 @@ public Thread regenerateCurrent() { return opperationRunner; } - - public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - HashSet groupsProcessed, ICadoodleRecursiveEvent p) { - ArrayList immutable = new ArrayList<>(); - immutable.addAll(back); - for (int i = 0; i < immutable.size(); i++) { - CSG csg = immutable.get(i); - if (csg.isLock()) - continue; - boolean inGroup = csg.isInGroup(); - boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); - String thisCSGName = csg.getName(); - boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); - boolean groupResult = csg.isGroupResult(); - - if (thisCSGIsTheTarget ) { - groupsProcessed.add(targetName); - // move it - ArrayList tmpToAdd = p.process(csg); - if (addRet) { - back.addAll(tmpToAdd); - } else { - for (int j = 0; j < back.size(); j++) { - if (back.get(j).getName().contentEquals(csg.getName())) { - back.remove(j); - break; - } - } - back.addAll(tmpToAdd); - } - continue; - } - boolean contains = groupsProcessed.contains(thisCSGName); - boolean isContinue = (groupResult && thisCSGIsInGroupNamedAfterTarget) ; - if (isContinue) { - // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, groupsProcessed, p); - } - } - back.removeAll(Collections.singleton(null)); - return back.size(); - } - private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); @@ -323,6 +280,49 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.start(); return opperationRunner; } + public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, + HashSet groupsProcessed, ICadoodleRecursiveEvent p) { + ArrayList immutable = new ArrayList<>(); + immutable.addAll(back); + for (int i = 0; i < immutable.size(); i++) { + CSG csg = immutable.get(i); + if (csg.isLock()) + continue; + boolean inGroup = csg.isInGroup(); + boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); + String thisCSGName = csg.getName(); + boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); + boolean groupResult = csg.isGroupResult(); + + if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget ) { + groupsProcessed.add(targetName); + // move it + ArrayList tmpToAdd = p.process(csg); + if (addRet) { + back.addAll(tmpToAdd); + } else { + for (int j = 0; j < back.size(); j++) { + if (back.get(j).getName().contentEquals(csg.getName())) { + back.remove(j); + break; + } + } + back.addAll(tmpToAdd); + } + continue; + } + boolean contains = groupsProcessed.contains(thisCSGName); + boolean isContinue = (groupResult) ; + if (isContinue && thisCSGIsInGroupNamedAfterTarget) { + // composite group + applyToAllConstituantElements(addRet, thisCSGName, back, groupsProcessed, p); + } + } + back.removeAll(Collections.singleton(null)); + return back.size(); + } + + private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { From c8cd1164ad0f8d6df8a92680d42e169e4d83bd54 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 10 Dec 2024 14:08:44 -0500 Subject: [PATCH 236/635] remove the unused groups processed data structure --- .../scripting/cadoodle/CaDoodleFile.java | 84 +++++++++---------- .../scripting/cadoodle/Delete.java | 3 +- .../scripting/cadoodle/MoveCenter.java | 3 +- .../scripting/cadoodle/Paste.java | 7 +- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 830ce44e..1d07d5c7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -239,49 +239,6 @@ public Thread regenerateCurrent() { return opperationRunner; } - - public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - HashSet groupsProcessed, ICadoodleRecursiveEvent p) { - ArrayList immutable = new ArrayList<>(); - immutable.addAll(back); - for (int i = 0; i < immutable.size(); i++) { - CSG csg = immutable.get(i); - if (csg.isLock()) - continue; - boolean inGroup = csg.isInGroup(); - boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); - String thisCSGName = csg.getName(); - boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); - boolean groupResult = csg.isGroupResult(); - - if (thisCSGIsTheTarget ) { - groupsProcessed.add(targetName); - // move it - ArrayList tmpToAdd = p.process(csg); - if (addRet) { - back.addAll(tmpToAdd); - } else { - for (int j = 0; j < back.size(); j++) { - if (back.get(j).getName().contentEquals(csg.getName())) { - back.remove(j); - break; - } - } - back.addAll(tmpToAdd); - } - continue; - } - boolean contains = groupsProcessed.contains(thisCSGName); - boolean isContinue = (groupResult && thisCSGIsInGroupNamedAfterTarget) ; - if (isContinue) { - // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, groupsProcessed, p); - } - } - back.removeAll(Collections.singleton(null)); - return back.size(); - } - private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); @@ -323,6 +280,47 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.start(); return opperationRunner; } + public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, + ICadoodleRecursiveEvent p) { + ArrayList immutable = new ArrayList<>(); + immutable.addAll(back); + for (int i = 0; i < immutable.size(); i++) { + CSG csg = immutable.get(i); + if (csg.isLock()) + continue; + boolean inGroup = csg.isInGroup(); + boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); + String thisCSGName = csg.getName(); + boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); + boolean groupResult = csg.isGroupResult(); + + if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget ) { + // move it + ArrayList tmpToAdd = p.process(csg); + if (addRet) { + back.addAll(tmpToAdd); + } else { + for (int j = 0; j < back.size(); j++) { + if (back.get(j).getName().contentEquals(csg.getName())) { + back.remove(j); + break; + } + } + back.addAll(tmpToAdd); + } + continue; + } + boolean isContinue = (groupResult) ; + if (isContinue && thisCSGIsInGroupNamedAfterTarget) { + // composite group + applyToAllConstituantElements(addRet, thisCSGName, back, p); + } + } + back.removeAll(Collections.singleton(null)); + return back.size(); + } + + private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index ba396ff7..bd3bbde8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -28,13 +28,12 @@ public String getType() { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - HashSet groupsProcessed = new HashSet(); //for(CSG c:incoming) { // if(c.isLock()) // continue; for(String s:names) { - CaDoodleFile.applyToAllConstituantElements(false,s, back, groupsProcessed, new ICadoodleRecursiveEvent() { + CaDoodleFile.applyToAllConstituantElements(false,s, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG incoming) { //back.remove(c); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 81d6732f..65f19de1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -27,10 +27,9 @@ public String getType() { @Override public List process(List incoming) { ArrayList back = new ArrayList(); - HashSet groupsProcessed = new HashSet(); back.addAll(incoming); for (String name : names) { - CaDoodleFile.applyToAllConstituantElements(false,name, back, groupsProcessed, new ICadoodleRecursiveEvent() { + CaDoodleFile.applyToAllConstituantElements(false,name, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG incoming) { CSG tmpToAdd = incoming.transformed(TransformFactory.nrToCSG(location)).syncProperties(incoming) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index a8e6f81b..570d0c8d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -3,6 +3,7 @@ import java.io.File; import java.nio.file.NoSuchFileException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -25,6 +26,7 @@ public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) public double offset = 10; private int index; + private HashMap cpMap = new HashMap(); @Override public String getType() { @@ -36,11 +38,9 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); index = 1; - HashSet groupsProcessed = new HashSet(); - for (int j = 0; j < names.size(); j++) { String s = names.get(j); - CaDoodleFile.applyToAllConstituantElements(false, s, back, groupsProcessed, new ICadoodleRecursiveEvent() { + CaDoodleFile.applyToAllConstituantElements(false, s, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG ic) { ArrayList copyPasteMoved = copyPasteMoved(back, ic); @@ -77,6 +77,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { ArrayList b = new ArrayList<>(); b.add(c); b.add(newOne); + cpMap.put(c.getName(), newOne.getName()); return b; } From 48f934af3269ae3976a2ffc2fb4bd2f58f2ba122 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 11 Dec 2024 10:26:34 -0500 Subject: [PATCH 237/635] Adding code to the paste opperation to reset the groups of the pasted parts --- .../scripting/cadoodle/Paste.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 570d0c8d..b5248137 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -22,7 +22,7 @@ public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @Expose(serialize = true, deserialize = true) - public String paste = null; + public String myName = null; @Expose(serialize = true, deserialize = true) public double offset = 10; private int index; @@ -38,6 +38,7 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); index = 1; + cpMap.clear(); for (int j = 0; j < names.size(); j++) { String s = names.get(j); CaDoodleFile.applyToAllConstituantElements(false, s, back, new ICadoodleRecursiveEvent() { @@ -48,9 +49,36 @@ public ArrayList process(CSG ic) { } }); } - + for(String from:cpMap.keySet()) { + CSG source = getByName(back, from); + if(source.isGroupResult()) { + ArrayList c =constituants(back,from); + String newGroupName = getByName(back,cpMap.get(from)).getName(); + for(String s:c) { + CSG dest = getByName(back,cpMap.get(s)); + //dest.removeGroupMembership(from); + //dest.addGroupMembership(newGroupName); + } + } + } return back; } + private ArrayList constituants(ArrayList back,String name){ + ArrayList c = new ArrayList(); + for(CSG csg:back) { + if(csg.checkGroupMembership(name)) + c.add(csg.getName()); + } + return c; + } + private CSG getByName(ArrayList back, String name) { + for(CSG c:back) { + if (c.getName().contentEquals(name)) + return c; + } + throw new RuntimeException("Fail! there was no object named "+name); + } + private ArrayList copyPasteMoved(ArrayList back, CSG c) { String prevName = c.getName(); @@ -100,9 +128,9 @@ public Paste setNames(List names) { } public String getPaserID() { - if (paste == null) - paste = RandomStringFactory.generateRandomString(); - return paste; + if (myName == null) + myName = RandomStringFactory.generateRandomString(); + return myName; } public Paste setOffset(double offset) { From 0d1f0870a4ed23954acfe0e994c21c7ccb8818ce Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 11 Dec 2024 10:43:18 -0500 Subject: [PATCH 238/635] pasting the renamed group worked, other issues persist --- .../scripting/cadoodle/Paste.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index b5248137..489b8779 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -22,8 +22,6 @@ public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @Expose(serialize = true, deserialize = true) - public String myName = null; - @Expose(serialize = true, deserialize = true) public double offset = 10; private int index; private HashMap cpMap = new HashMap(); @@ -55,9 +53,9 @@ public ArrayList process(CSG ic) { ArrayList c =constituants(back,from); String newGroupName = getByName(back,cpMap.get(from)).getName(); for(String s:c) { - CSG dest = getByName(back,cpMap.get(s)); - //dest.removeGroupMembership(from); - //dest.addGroupMembership(newGroupName); + CSG dest = getByName(back,s); + dest.removeGroupMembership(from); + dest.addGroupMembership(newGroupName); } } } @@ -66,8 +64,10 @@ public ArrayList process(CSG ic) { private ArrayList constituants(ArrayList back,String name){ ArrayList c = new ArrayList(); for(CSG csg:back) { - if(csg.checkGroupMembership(name)) - c.add(csg.getName()); + if(csg.checkGroupMembership(name)) { + if(csg.getName().contains(getName())) + c.add(csg.getName()); + } } return c; } @@ -82,7 +82,7 @@ private CSG getByName(ArrayList back, String name) { private ArrayList copyPasteMoved(ArrayList back, CSG c) { String prevName = c.getName(); - String name = getPaserID() + (index == 0 ? "" : "_" + index); + String name = getName() + (index == 0 ? "" : "_" + index); CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); @@ -127,11 +127,6 @@ public Paste setNames(List names) { return this; } - public String getPaserID() { - if (myName == null) - myName = RandomStringFactory.generateRandomString(); - return myName; - } public Paste setOffset(double offset) { this.offset = offset; From c99e83253721580c1e408db139d537ec5b510daa Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 11 Dec 2024 13:44:17 -0500 Subject: [PATCH 239/635] Adding the offset transform to the properties of the CSG --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 5 ++++- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 5 ++++- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 6 ++---- .../bowlerstudio/scripting/cadoodle/Paste.java | 9 ++++++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index ec5f9ac4..c67edae1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -21,6 +21,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; @@ -154,11 +155,12 @@ private String getStrValue() { } private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { + Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() // .toZMin() - .transformed(TransformFactory.nrToCSG(getLocation())).syncProperties(csg).setParameter(parameter) + .transformed(nrToCSG).syncProperties(csg).setParameter(parameter) .setRegenerate(previous -> { try { File file = getFile(); @@ -172,6 +174,7 @@ private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) } return previous; }).setName(name); + processedCSG.getStorage().set("StartingTransform", nrToCSG); return processedCSG; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index ecb96770..7b28327f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -21,6 +21,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) @@ -67,12 +68,14 @@ public List process(List incoming) { collect.addAll(flaten); for(int i=0;i { - while (toProcess.size() > 0) { opperationRunner.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); @@ -288,7 +287,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam CSG csg = immutable.get(i); if (csg.isLock()) continue; - boolean inGroup = csg.isInGroup(); + //boolean inGroup = csg.isInGroup(); boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); String thisCSGName = csg.getName(); boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); @@ -310,8 +309,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } continue; } - boolean isContinue = (groupResult) ; - if (isContinue && thisCSGIsInGroupNamedAfterTarget) { + if (groupResult && thisCSGIsInGroupNamedAfterTarget) { // composite group applyToAllConstituantElements(addRet, thisCSGName, back, p); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 489b8779..e2e11cf9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import com.google.gson.annotations.Expose; @@ -15,6 +16,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -65,6 +67,7 @@ private ArrayList constituants(ArrayList back,String name){ ArrayList c = new ArrayList(); for(CSG csg:back) { if(csg.checkGroupMembership(name)) { + // only add objects that were created by this operation if(csg.getName().contains(getName())) c.add(csg.getName()); } @@ -86,7 +89,11 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); - CSG newOne = clone.regenerate().moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) + Transform nrToCSG = new Transform(); + Optional o=c.getStorage().getValue("StartingTransform"); + if(o.isPresent()) + nrToCSG=(Transform) o.get(); + CSG newOne = clone.regenerate().transformed(nrToCSG).moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) .movex(offset); newOne.setRegenerate(c.getRegenerate()).setName(name); VitaminBomManager boM = CaDoodleFile.getBoM(); From 3ff6adde552dfd74bcc6665c41c4e904e9e81057 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 11 Dec 2024 18:24:19 -0500 Subject: [PATCH 240/635] Fix the problem where loading a bad vitamin zise causes the vitamin loading to throw an exception. Instead it should just load the first default size --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index a31708c8..ac3e5ce9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -225,7 +225,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception } catch (Exception e) { e.printStackTrace(); gitRpoDatabase = defaultgitRpoDatabase; - ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); + //ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); if (depthGauge < 2) { return get(type, id, depthGauge + 1); @@ -293,7 +293,7 @@ public static Object getMeasurement(String type, String size, String measurement public static ConcurrentHashMap getConfigurationRW(String type, String id) { ConcurrentHashMap> database = getDatabase(type); if (database.get(id) == null) { - database.put(id, new ConcurrentHashMap()); + id=Vitamins.listVitaminSizes(type).get(0); } ConcurrentHashMap ConcurrentHashMap = database.get(id); From 435dd298b2f53912fc7dfaea42911786fd40a3d6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 12 Dec 2024 13:16:58 -0500 Subject: [PATCH 241/635] Add a regeneration step to the ungoup operation --- .../bowlerstudio/scripting/cadoodle/UnGroup.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 166831fe..5a0da655 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -4,10 +4,12 @@ import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import com.google.gson.annotations.Expose; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class UnGroup extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -35,7 +37,11 @@ public List process(List incoming) { if (csg.isInGroup()) { if (csg.checkGroupMembership(name)) { // release this object from the group - CSG readd= csg.clone().setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); + Transform nrToCSG = new Transform(); + Optional o=csg.getStorage().getValue("StartingTransform"); + if(o.isPresent()) + nrToCSG=(Transform) o.get(); + CSG readd= csg.regenerate().transformed(nrToCSG).setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); readd.removeGroupMembership(name); back.remove(csg); From 47b476626d8d1ff251097831b4aa887cc66760b6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 13 Dec 2024 10:30:57 -0500 Subject: [PATCH 242/635] update the Bom Managment so that the Bom is updated based on the current state of vitamins in the CSG's of the current state. --- .../scripting/cadoodle/AddFromFile.java | 12 +- .../scripting/cadoodle/AddFromScript.java | 12 +- .../scripting/cadoodle/CaDoodleFile.java | 126 +++++++++++------- .../scripting/cadoodle/CaDoodleVitamin.java | 6 +- .../scripting/cadoodle/Delete.java | 12 +- .../scripting/cadoodle/MoveCenter.java | 12 +- .../scripting/cadoodle/Paste.java | 18 +-- 7 files changed, 114 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index c67edae1..478a433f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -77,12 +77,12 @@ public List process(List incoming) { } } back.addAll(collect); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(name); - if(loc!=null) { - loc.setLocation(location); - boM.save(); - } +// VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminLocation loc = boM.getByName(name); +// if(loc!=null) { +// loc.setLocation(location); +// boM.save(); +// } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 7b28327f..b3906f7c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -78,12 +78,12 @@ public List process(List incoming) { tmp.getStorage().set("StartingTransform", nrToCSG); } back.addAll(collect); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(getName()); - if(loc!=null) { - loc.setLocation(location); - boM.save(); - } +// VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminLocation loc = boM.getByName(getName()); +// if(loc!=null) { +// loc.setLocation(location); +// boM.save(); +// } } catch (Exception e) { if(!fileRel.contains("generated")) try { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index ad2ea02a..4208bf1a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -73,7 +73,7 @@ public class CaDoodleFile { private javafx.scene.image.WritableImage img; private boolean initializing; private static HashMap bomManagers = new HashMap<>(); - private VitaminBomManager boM; + private VitaminBomManager bom; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -119,9 +119,9 @@ public void initialize() { StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); loc.setStrValue(selfInternal.getAbsolutePath()); - boM = CaDoodleFile.getBoM(); - boM.clear(); - boM.save(); + bom = CaDoodleFile.getBillOfMaterials(); + bom.clear(); + bom.save(); } int indexStarting = getCurrentIndex(); @@ -149,10 +149,37 @@ public void initialize() { e.printStackTrace(); } } + updateBoM(); initializing = false; } - public static VitaminBomManager getBoM() { + private void updateBoM() { + bom.clear(); + bom.save(); + for (CSG c : getCurrentState()) { + String type = null; + String size = null; + for (String param : c.getParameters()) { + if(!param.contains(c.getName())) + continue; + if (param.contains("_CaDoodle_Vitamin_Type")) { + Parameter p = CSGDatabase.get(param); + type = p.getStrValue(); + } + if (param.contains("_CaDoodle_Vitamin_Size")) { + Parameter p = CSGDatabase.get(param); + size = p.getStrValue(); + } + if (type != null && size != null) { + bom.addVitamin(new VitaminLocation(false, c.getName(), type, size, new TransformNR())); + break; + } + } + } + bom.save(); + } + + public static VitaminBomManager getBillOfMaterials() { String strValue = getCadoodleFileLocation(); File file = new File(strValue).getParentFile(); @@ -210,6 +237,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setCurrentIndex(endIndex); updateCurrentFromCache(); } + updateBoM(); setRegenerating(false); fireSaveSuggestion(); opperationRunner = null; @@ -239,6 +267,7 @@ public Thread regenerateCurrent() { return opperationRunner; } + private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); storeResultInCache(op, process); @@ -273,27 +302,29 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc ex.printStackTrace(); } } + updateBoM(); fireSaveSuggestion(); opperationRunner = null; }); opperationRunner.start(); return opperationRunner; } + public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - ICadoodleRecursiveEvent p) { + ICadoodleRecursiveEvent p) { ArrayList immutable = new ArrayList<>(); immutable.addAll(back); for (int i = 0; i < immutable.size(); i++) { CSG csg = immutable.get(i); if (csg.isLock()) continue; - //boolean inGroup = csg.isInGroup(); + // boolean inGroup = csg.isInGroup(); boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); String thisCSGName = csg.getName(); boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); boolean groupResult = csg.isGroupResult(); - - if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget ) { + + if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget) { // move it ArrayList tmpToAdd = p.process(csg); if (addRet) { @@ -318,47 +349,45 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam return back.size(); } - - private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); List back = cache.remove(key); - VitaminBomManager boM = CaDoodleFile.getBoM(); - if (AbstractAddFrom.class.isInstance(key)) { - AbstractAddFrom aaf = (AbstractAddFrom) key; - for (String name : aaf.getNamesAdded()) { - VitaminLocation loc = boM.getByName(name); - if (loc != null) { - boM.remove(loc); - boM.save(); - } - } - } - if (Delete.class.isInstance(key)) { - Delete d = (Delete) key; - for (String s : d.getNames()) { - for (CSG c : back) { - String type = null; - String size = null; - if (c.getName().contentEquals(s)) { - for (String param : c.getParameters()) { - if (param.contains("_CaDoodle_Vitamin_Type")) { - Parameter p = CSGDatabase.get(param); - type = p.getStrValue(); - } - if (param.contains("_CaDoodle_Vitamin_Size")) { - Parameter p = CSGDatabase.get(param); - size = p.getStrValue(); - } - } - if (type != null && size != null) { - boM.addVitamin(new VitaminLocation(false, c.getName(), type, size, new TransformNR())); - } - } - } - } - } + VitaminBomManager boM = CaDoodleFile.getBillOfMaterials(); +// if (AbstractAddFrom.class.isInstance(key)) { +// AbstractAddFrom aaf = (AbstractAddFrom) key; +// for (String name : aaf.getNamesAdded()) { +// VitaminLocation loc = boM.getByName(name); +// if (loc != null) { +// boM.remove(loc); +// boM.save(); +// } +// } +// } +// if (Delete.class.isInstance(key)) { +// Delete d = (Delete) key; +// for (String s : d.getNames()) { +// for (CSG c : back) { +// String type = null; +// String size = null; +// if (c.getName().contentEquals(s)) { +// for (String param : c.getParameters()) { +// if (param.contains("_CaDoodle_Vitamin_Type")) { +// Parameter p = CSGDatabase.get(param); +// type = p.getStrValue(); +// } +// if (param.contains("_CaDoodle_Vitamin_Size")) { +// Parameter p = CSGDatabase.get(param); +// size = p.getStrValue(); +// } +// } +// if (type != null && size != null) { +// boM.addVitamin(new VitaminLocation(false, c.getName(), type, size, new TransformNR())); +// } +// } +// } +// } +// } if (back != null) back.clear(); } @@ -374,7 +403,8 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { HashSet names = new HashSet<>(); for (CSG c : process) { if (names.contains(c.getName())) - throw new RuntimeException("There can not be 2 objects with the same name after an opperation! "+c.getName()); + throw new RuntimeException( + "There can not be 2 objects with the same name after an opperation! " + c.getName()); names.add(c.getName()); cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) .setRegenerate(c.getRegenerate())); @@ -565,7 +595,7 @@ public File save() throws IOException { // e.getMessage()); e.printStackTrace(); } - boM.save(); + bom.save(); } return getSelf(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index c937ed69..ea1d7311 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -61,9 +61,9 @@ public static CSG get(String typencoming,String defaultValue, ArrayList HashMap object = (HashMap) args.get(1); if (!(Boolean) object.get("PreventBomAdd")) { - VitaminLocation vl = new VitaminLocation(false, name, type, word.getStrValue(), new TransformNR()); - System.out.println("BoM update "+vl); - CaDoodleFile.getBoM().addVitamin(vl, true); +// VitaminLocation vl = new VitaminLocation(false, name, type, word.getStrValue(), new TransformNR()); +// //System.out.println("BoM update "+vl); +// CaDoodleFile.getBoM().addVitamin(vl, true); } } CSG part; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index bd3bbde8..18b01781 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -37,12 +37,12 @@ public List process(List incoming) { @Override public ArrayList process(CSG incoming) { //back.remove(c); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(s); - if(loc!=null) { - boM.remove(loc); - boM.save(); - } +// VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminLocation loc = boM.getByName(s); +// if(loc!=null) { +// boM.remove(loc); +// boM.save(); +// } ArrayList b = new ArrayList<>(); b.add(null); return b; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 65f19de1..3dfde659 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -34,12 +34,12 @@ public List process(List incoming) { public ArrayList process(CSG incoming) { CSG tmpToAdd = incoming.transformed(TransformFactory.nrToCSG(location)).syncProperties(incoming) .setName(incoming.getName()); - VitaminBomManager boM = CaDoodleFile.getBoM(); - VitaminLocation loc = boM.getByName(name); - if (loc != null) { - loc.setLocation(loc.getLocation().times(location)); - boM.save(); - } +// VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminLocation loc = boM.getByName(name); +// if (loc != null) { +// loc.setLocation(loc.getLocation().times(location)); +// boM.save(); +// } ArrayList b = new ArrayList<>(); b.add(tmpToAdd); return b; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index e2e11cf9..ed4af0f8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -96,16 +96,16 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { CSG newOne = clone.regenerate().transformed(nrToCSG).moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) .movex(offset); newOne.setRegenerate(c.getRegenerate()).setName(name); - VitaminBomManager boM = CaDoodleFile.getBoM(); +// VitaminBomManager boM = CaDoodleFile.getBoM(); String name2 = c.getName(); - VitaminLocation loc = boM.getByName(name2); - VitaminLocation locNew = boM.getByName(name); - if (loc != null) { - VitaminLocation newElement = new VitaminLocation(loc, name); - newElement.setLocation(newElement.getLocation().times(new TransformNR(offset, 0, 0))); - boM.addVitamin(newElement); - boM.save(); - } +// VitaminLocation loc = boM.getByName(name2); +// VitaminLocation locNew = boM.getByName(name); +// if (loc != null) { +// VitaminLocation newElement = new VitaminLocation(loc, name); +// newElement.setLocation(newElement.getLocation().times(new TransformNR(offset, 0, 0))); +// boM.addVitamin(newElement); +// boM.save(); +// } index++; newOne.syncProperties(c).setName(name); getNamesAdded().add(name); From f48c8e9d306c1d467a08f6bae831d01c056be366 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 13 Dec 2024 10:44:23 -0500 Subject: [PATCH 243/635] Side channel the moves so that a regeneration can produce accurate ungroups --- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 11 ++++++++++- .../bowlerstudio/scripting/cadoodle/Paste.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 3dfde659..cf9ccdd5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import com.google.gson.annotations.Expose; @@ -12,6 +13,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class MoveCenter implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -32,7 +34,14 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false,name, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG incoming) { - CSG tmpToAdd = incoming.transformed(TransformFactory.nrToCSG(location)).syncProperties(incoming) + Transform nrToCSG2 = TransformFactory.nrToCSG(location); + Optional o=incoming.getStorage().getValue("StartingTransform"); + if(o.isPresent()) { + TransformNR nrToCSG=TransformFactory.csgToNR((Transform) o.get()); + nrToCSG=location.times(nrToCSG); + incoming.getStorage().set("StartingTransform", TransformFactory.nrToCSG(nrToCSG)); + } + CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming) .setName(incoming.getName()); // VitaminBomManager boM = CaDoodleFile.getBoM(); // VitaminLocation loc = boM.getByName(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index ed4af0f8..3b0f6d94 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -93,7 +93,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { Optional o=c.getStorage().getValue("StartingTransform"); if(o.isPresent()) nrToCSG=(Transform) o.get(); - CSG newOne = clone.regenerate().transformed(nrToCSG).moveToCenter().movex(c.getCenterX()).movey(c.getCenterY()).movez(c.getCenterZ()) + CSG newOne = clone.regenerate().transformed(nrToCSG) .movex(offset); newOne.setRegenerate(c.getRegenerate()).setName(name); // VitaminBomManager boM = CaDoodleFile.getBoM(); From 01a4e4c1383610923bc0eaf5a61f04400a01ccf7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 13 Dec 2024 13:40:09 -0500 Subject: [PATCH 244/635] Add the motion from the paste to the starting transform --- .../bowlerstudio/scripting/cadoodle/Paste.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 3b0f6d94..50837750 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -93,8 +93,9 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { Optional o=c.getStorage().getValue("StartingTransform"); if(o.isPresent()) nrToCSG=(Transform) o.get(); - CSG newOne = clone.regenerate().transformed(nrToCSG) - .movex(offset); + nrToCSG=nrToCSG.movex(offset); + c.getStorage().set("StartingTransform", nrToCSG); + CSG newOne = clone.regenerate().transformed(nrToCSG); newOne.setRegenerate(c.getRegenerate()).setName(name); // VitaminBomManager boM = CaDoodleFile.getBoM(); String name2 = c.getName(); From ba4725cf31a89f18f35559a1b3e865b40def3b27 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 13 Dec 2024 13:42:27 -0500 Subject: [PATCH 245/635] null checking the min and max --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 98cdab29..f583b74e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -68,7 +68,8 @@ public Bounds getSellectedBounds(List incoming) { if (max.z < max2.z) max.z = max2.z; } - + if(min==null||max==null) + throw new RuntimeException("Min and max can not be null"); return new Bounds(min, max); } @Override From 6082c352ed9dae687b6aa1e4d6d3d8cd555d5641 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 14 Dec 2024 11:19:40 -0500 Subject: [PATCH 246/635] Removing the offset from paste, move that to a seperate MoveCenter opperation in the UI --- .../bowlerstudio/scripting/cadoodle/Paste.java | 16 ++++++++-------- .../bowlerstudio/scripting/cadoodle/Resize.java | 5 ++++- .../bowlerstudio/scripting/cadoodle/UnGroup.java | 12 ++++++------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 50837750..00701438 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -23,8 +23,8 @@ public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); - @Expose(serialize = true, deserialize = true) - public double offset = 10; +// @Expose(serialize = true, deserialize = true) +// public double offset = 10; private int index; private HashMap cpMap = new HashMap(); @@ -93,8 +93,8 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { Optional o=c.getStorage().getValue("StartingTransform"); if(o.isPresent()) nrToCSG=(Transform) o.get(); - nrToCSG=nrToCSG.movex(offset); - c.getStorage().set("StartingTransform", nrToCSG); + //nrToCSG=nrToCSG.movex(offset); + //c.getStorage().set("StartingTransform", nrToCSG); CSG newOne = clone.regenerate().transformed(nrToCSG); newOne.setRegenerate(c.getRegenerate()).setName(name); // VitaminBomManager boM = CaDoodleFile.getBoM(); @@ -136,10 +136,10 @@ public Paste setNames(List names) { } - public Paste setOffset(double offset) { - this.offset = offset; - return this; - } +// public Paste setOffset(double offset) { +// this.offset = offset; +// return this; +// } @Override public File getFile() throws NoSuchFileException { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index f583b74e..00b27704 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -68,8 +68,11 @@ public Bounds getSellectedBounds(List incoming) { if (max.z < max2.z) max.z = max2.z; } - if(min==null||max==null) + if(min==null||max==null) { + System.out.println("Found bounds to be null "); + throw new RuntimeException("Min and max can not be null"); + } return new Bounds(min, max); } @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 5a0da655..321a34f8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -11,7 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class UnGroup extends AbstractAddFrom implements ICaDoodleOpperation { +public class UnGroup implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @@ -19,10 +19,10 @@ public class UnGroup extends AbstractAddFrom implements ICaDoodleOpperation { public String getType() { return "Un-Group"; } - @Override - public File getFile() throws NoSuchFileException { - throw new NoSuchFileException(null); - } +// @Override +// public File getFile() throws NoSuchFileException { +// throw new NoSuchFileException(null); +// } @Override public List process(List incoming) { ArrayList back = new ArrayList(); @@ -46,7 +46,7 @@ public List process(List incoming) { readd.removeGroupMembership(name); back.remove(csg); back.add(readd); - namesAdded.add(readd.getName()); + //namesAdded.add(readd.getName()); } } From 54b602165ab087e7d540354bc7d75ea5cbf4b759 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 14 Dec 2024 12:45:13 -0500 Subject: [PATCH 247/635] Moving all of thee motion opperations into MoveCenter and using the CSG storage map to store the transform order --- build.gradle | 2 +- .../scripting/cadoodle/AddFromFile.java | 27 +++-- .../scripting/cadoodle/AddFromScript.java | 25 ++--- .../scripting/cadoodle/MoveCenter.java | 105 +++++++++++------- .../scripting/cadoodle/Paste.java | 17 +-- .../scripting/cadoodle/UnGroup.java | 10 +- 6 files changed, 90 insertions(+), 96 deletions(-) diff --git a/build.gradle b/build.gradle index 5dec3dee..81bfe97d 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.5' + api 'com.neuronrobotics:JavaCad:2.0.6' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 478a433f..c05eadf2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -26,8 +26,8 @@ import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { - @Expose(serialize = true, deserialize = true) - private TransformNR location = null; +// @Expose(serialize = true, deserialize = true) +// private TransformNR location = null; private ArrayList options = new ArrayList(); private StringParameter parameter = null; @Expose(serialize = true, deserialize = true) @@ -155,7 +155,7 @@ private String getStrValue() { } private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { - Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); + Transform nrToCSG = new Transform();//TransformFactory.nrToCSG(getLocation()); CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() @@ -174,20 +174,19 @@ private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) } return previous; }).setName(name); - processedCSG.getStorage().set("StartingTransform", nrToCSG); return processedCSG; } - public TransformNR getLocation() { - if (location == null) - location = new TransformNR(); - return location; - } - - public AddFromFile setLocation(TransformNR location) { - this.location = location; - return this; - } +// public TransformNR getLocation() { +// if (location == null) +// location = new TransformNR(); +// return location; +// } +// +// public AddFromFile setLocation(TransformNR location) { +// this.location = location; +// return this; +// } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index b3906f7c..22ae1126 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -29,8 +29,8 @@ public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperatio @Expose (serialize = true, deserialize = true) private String fileRel = ""; - @Expose(serialize = true, deserialize = true) - private TransformNR location =null; +// @Expose(serialize = true, deserialize = true) +// private TransformNR location =null; @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; @@ -68,14 +68,13 @@ public List process(List incoming) { collect.addAll(flaten); for(int i=0;i process(List incoming) { - public TransformNR getLocation() { - if(location==null) - location=new TransformNR(); - return location; - } +// public TransformNR getLocation() { +// if(location==null) +// location=new TransformNR(); +// return location; +// } - public AddFromScript setLocation(TransformNR location) { - this.location = location; - return this; - } +// public AddFromScript setLocation(TransformNR location) { +// this.location = location; +// return this; +// } @Override public File getFile() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index cf9ccdd5..16f4829b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -13,6 +13,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; public class MoveCenter implements ICaDoodleOpperation { @@ -20,12 +21,71 @@ public class MoveCenter implements ICaDoodleOpperation { private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); + @Expose(serialize = true, deserialize = true) + protected String name = null; + + public String getName() { + if (name == null) { + setName(RandomStringFactory.generateRandomString()); + } + return name; + } + public void setName(String name) { + this.name = name; + } + @Override public String getType() { return "Move Center"; } - + public static void set(String name,CSG c, TransformNR tf) { + if(tf==null) + throw new NullPointerException(); + if(name==null) + throw new NullPointerException(); + if(c==null) + throw new NullPointerException(); + PropertyStorage storage = c.getStorage(); + Optional o= storage.getValue("TFSet"); + ArrayList tfs = null; + if(!o.isPresent()) { + tfs=new ArrayList(); + storage.set("TFSet", tfs); + }else { + tfs=(ArrayList) o.get(); + } + boolean contains = false; + for(String s:tfs) { + if(s.contentEquals(name)) { + contains=true; + break; + } + } + storage.set(name, tf); + if(!contains) + tfs.add(name); + } + public static Transform getTotalOffset(CSG c) { + Transform nrToCSG = new Transform(); + PropertyStorage storage = c.getStorage(); + Optional o= storage.getValue("TFSet"); + if(o.isPresent()) { + TransformNR start = new TransformNR(); + ArrayList tfs=(ArrayList) o.get(); + for(String s:tfs) { + try { + TransformNR transTmp = (TransformNR) storage.getValue(s).get(); + start=start.times(transTmp); + }catch(Exception ex) { + ex.printStackTrace(); + } + } + nrToCSG=TransformFactory.nrToCSG(start); + } + return nrToCSG; + } + @Override public List process(List incoming) { ArrayList back = new ArrayList(); @@ -35,22 +95,11 @@ public List process(List incoming) { @Override public ArrayList process(CSG incoming) { Transform nrToCSG2 = TransformFactory.nrToCSG(location); - Optional o=incoming.getStorage().getValue("StartingTransform"); - if(o.isPresent()) { - TransformNR nrToCSG=TransformFactory.csgToNR((Transform) o.get()); - nrToCSG=location.times(nrToCSG); - incoming.getStorage().set("StartingTransform", TransformFactory.nrToCSG(nrToCSG)); - } CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming) .setName(incoming.getName()); -// VitaminBomManager boM = CaDoodleFile.getBoM(); -// VitaminLocation loc = boM.getByName(name); -// if (loc != null) { -// loc.setLocation(loc.getLocation().times(location)); -// boM.save(); -// } ArrayList b = new ArrayList<>(); b.add(tmpToAdd); + set(getName(),tmpToAdd,location); return b; } }); @@ -58,36 +107,6 @@ public ArrayList process(CSG incoming) { return back; } -// private void moveByName(String name, ArrayList back, HashSet groupsProcessed) { -// -// for (int i = 0; i < back.size(); i++) { -// CSG csg = back.get(i); -// if(csg.isLock()) -// continue; -// if ( csg.getName().contentEquals(name) || -// (csg.isInGroup() && csg.checkGroupMembership(name))){ -// groupsProcessed.add(name); -// if(csg.isInGroup() && csg.isGroupResult() && !groupsProcessed.contains(csg.getName())) { -// // composite group -// moveByName(csg.getName(), back,groupsProcessed); -// -// } -// // move it -// CSG tmpToAdd = csg -// .transformed(TransformFactory.nrToCSG(location)) -// .syncProperties(csg) -// .setName(csg.getName()); -// VitaminBomManager boM = CaDoodleFile.getBoM(); -// VitaminLocation loc = boM.getByName(name); -// if(loc!=null) { -// loc.setLocation(loc.getLocation().times(location)); -// boM.save(); -// } -// back.set(i, tmpToAdd); -// } -// } -// } - public TransformNR getLocation() { return location; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 00701438..71c2fb97 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -89,24 +89,9 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); - Transform nrToCSG = new Transform(); - Optional o=c.getStorage().getValue("StartingTransform"); - if(o.isPresent()) - nrToCSG=(Transform) o.get(); - //nrToCSG=nrToCSG.movex(offset); - //c.getStorage().set("StartingTransform", nrToCSG); + Transform nrToCSG = MoveCenter.getTotalOffset(c); CSG newOne = clone.regenerate().transformed(nrToCSG); newOne.setRegenerate(c.getRegenerate()).setName(name); -// VitaminBomManager boM = CaDoodleFile.getBoM(); - String name2 = c.getName(); -// VitaminLocation loc = boM.getByName(name2); -// VitaminLocation locNew = boM.getByName(name); -// if (loc != null) { -// VitaminLocation newElement = new VitaminLocation(loc, name); -// newElement.setLocation(newElement.getLocation().times(new TransformNR(offset, 0, 0))); -// boM.addVitamin(newElement); -// boM.save(); -// } index++; newOne.syncProperties(c).setName(name); getNamesAdded().add(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 321a34f8..b74c1496 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -19,10 +19,6 @@ public class UnGroup implements ICaDoodleOpperation { public String getType() { return "Un-Group"; } -// @Override -// public File getFile() throws NoSuchFileException { -// throw new NoSuchFileException(null); -// } @Override public List process(List incoming) { ArrayList back = new ArrayList(); @@ -37,16 +33,12 @@ public List process(List incoming) { if (csg.isInGroup()) { if (csg.checkGroupMembership(name)) { // release this object from the group - Transform nrToCSG = new Transform(); - Optional o=csg.getStorage().getValue("StartingTransform"); - if(o.isPresent()) - nrToCSG=(Transform) o.get(); + Transform nrToCSG = MoveCenter.getTotalOffset(csg); CSG readd= csg.regenerate().transformed(nrToCSG).setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); readd.removeGroupMembership(name); back.remove(csg); back.add(readd); - //namesAdded.add(readd.getName()); } } From f72e3095a5b7911278fac193a8d6ec17553146ef Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 14 Dec 2024 13:54:26 -0500 Subject: [PATCH 248/635] MoveCenter now keeps track of the center of each object as a series of transform steps stored in the --- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 81bfe97d..15cdff5b 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.6' + api 'com.neuronrobotics:JavaCad:2.0.7' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 16f4829b..7c7ec32e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -76,7 +76,7 @@ public static Transform getTotalOffset(CSG c) { for(String s:tfs) { try { TransformNR transTmp = (TransformNR) storage.getValue(s).get(); - start=start.times(transTmp); + start=transTmp.times(start); }catch(Exception ex) { ex.printStackTrace(); } From 266b46e82c256690e887ccc851581ad7d4ae956f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 15 Dec 2024 17:08:59 -0500 Subject: [PATCH 249/635] only regenerate the vitamins, clone the other shapes --- .../bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java | 8 ++++++++ .../bowlerstudio/scripting/cadoodle/Paste.java | 7 ++++++- .../bowlerstudio/scripting/cadoodle/UnGroup.java | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index ea1d7311..fa278f5f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -26,6 +26,14 @@ public static CSG get(String typencoming, ArrayList args) { ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); return get( type, listVitaminSizes.get(0), args); } + public static boolean isVitamin(CSG c) { + for(String s:c.getParameters()) { + if(s.contains("_CaDoodle_Vitamin_") && s.contains(c.getName())) { + return true; + } + } + return false; + } public static CSG get(String typencoming,String defaultValue, ArrayList args) { String name = args.get(0).toString(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 71c2fb97..e2fad554 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -83,6 +83,7 @@ private CSG getByName(ArrayList back, String name) { } + private ArrayList copyPasteMoved(ArrayList back, CSG c) { String prevName = c.getName(); String name = getName() + (index == 0 ? "" : "_" + index); @@ -90,7 +91,11 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); Transform nrToCSG = MoveCenter.getTotalOffset(c); - CSG newOne = clone.regenerate().transformed(nrToCSG); + CSG newOne =null; + if(CaDoodleVitamin.isVitamin(c)) + newOne=clone.regenerate().transformed(nrToCSG); + else + newOne=clone; newOne.setRegenerate(c.getRegenerate()).setName(name); index++; newOne.syncProperties(c).setName(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index b74c1496..d208940e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -34,7 +34,12 @@ public List process(List incoming) { if (csg.checkGroupMembership(name)) { // release this object from the group Transform nrToCSG = MoveCenter.getTotalOffset(csg); - CSG readd= csg.regenerate().transformed(nrToCSG).setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); + CSG transformed=null; + if(CaDoodleVitamin.isVitamin(csg)) + transformed= csg.regenerate().transformed(nrToCSG); + else + transformed=csg; + CSG readd= transformed.setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); readd.removeGroupMembership(name); back.remove(csg); From 56c2de1cbb601d318bb1d9e2057a87a149a3c318 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sun, 15 Dec 2024 17:45:43 -0500 Subject: [PATCH 250/635] cleanup --- .../scripting/cadoodle/Delete.java | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 18b01781..8a2c804b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -14,9 +14,9 @@ import eu.mihosoft.vrl.v3d.CSG; public class Delete implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private TransformNR location=new TransformNR(); - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) + private TransformNR location = new TransformNR(); + @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @Override @@ -29,26 +29,16 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - //for(CSG c:incoming) { -// if(c.isLock()) -// continue; - for(String s:names) { - CaDoodleFile.applyToAllConstituantElements(false,s, back, new ICadoodleRecursiveEvent() { - @Override - public ArrayList process(CSG incoming) { - //back.remove(c); -// VitaminBomManager boM = CaDoodleFile.getBoM(); -// VitaminLocation loc = boM.getByName(s); -// if(loc!=null) { -// boM.remove(loc); -// boM.save(); -// } - ArrayList b = new ArrayList<>(); - b.add(null); - return b; - } - }); - //} + for (String s : names) { + CaDoodleFile.applyToAllConstituantElements(false, s, back, new ICadoodleRecursiveEvent() { + @Override + public ArrayList process(CSG incoming) { + + ArrayList b = new ArrayList<>(); + b.add(null); + return b; + } + }); } return back; } From 19f61155d49032dc536077fba4df9bde6c4974a3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 21 Dec 2024 14:30:40 -0500 Subject: [PATCH 251/635] move the name set looping internal --- .../scripting/cadoodle/CaDoodleFile.java | 9 ++- .../scripting/cadoodle/Delete.java | 21 +++-- .../scripting/cadoodle/MoveCenter.java | 77 ++++++++++--------- .../scripting/cadoodle/Paste.java | 58 +++++++------- 4 files changed, 85 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4208bf1a..031a4e1e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -309,7 +309,14 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.start(); return opperationRunner; } - + public static int applyToAllConstituantElements(boolean addRet, List targetNames, ArrayList back, + ICadoodleRecursiveEvent p) { + for (int i = 0; i < targetNames.size(); i++) { + String s = targetNames.get(i); + applyToAllConstituantElements(addRet, s, back, p); + } + return back.size(); + } public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, ICadoodleRecursiveEvent p) { ArrayList immutable = new ArrayList<>(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 8a2c804b..1b657e9f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -29,17 +29,16 @@ public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - for (String s : names) { - CaDoodleFile.applyToAllConstituantElements(false, s, back, new ICadoodleRecursiveEvent() { - @Override - public ArrayList process(CSG incoming) { - - ArrayList b = new ArrayList<>(); - b.add(null); - return b; - } - }); - } + CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { + @Override + public ArrayList process(CSG incoming) { + + ArrayList b = new ArrayList<>(); + b.add(null); + return b; + } + }); + return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 7c7ec32e..04f6a6c8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -23,7 +23,7 @@ public class MoveCenter implements ICaDoodleOpperation { private List names = new ArrayList(); @Expose(serialize = true, deserialize = true) protected String name = null; - + public String getName() { if (name == null) { setName(RandomStringFactory.generateRandomString()); @@ -34,76 +34,77 @@ public String getName() { public void setName(String name) { this.name = name; } - + @Override public String getType() { return "Move Center"; } - public static void set(String name,CSG c, TransformNR tf) { - if(tf==null) + + public static void set(String name, CSG c, TransformNR tf) { + if (tf == null) throw new NullPointerException(); - if(name==null) + if (name == null) throw new NullPointerException(); - if(c==null) + if (c == null) throw new NullPointerException(); PropertyStorage storage = c.getStorage(); - Optional o= storage.getValue("TFSet"); + Optional o = storage.getValue("TFSet"); ArrayList tfs = null; - if(!o.isPresent()) { - tfs=new ArrayList(); + if (!o.isPresent()) { + tfs = new ArrayList(); storage.set("TFSet", tfs); - }else { - tfs=(ArrayList) o.get(); + } else { + tfs = (ArrayList) o.get(); } boolean contains = false; - for(String s:tfs) { - if(s.contentEquals(name)) { - contains=true; + for (String s : tfs) { + if (s.contentEquals(name)) { + contains = true; break; } } storage.set(name, tf); - if(!contains) + if (!contains) tfs.add(name); } + public static Transform getTotalOffset(CSG c) { Transform nrToCSG = new Transform(); PropertyStorage storage = c.getStorage(); - Optional o= storage.getValue("TFSet"); - if(o.isPresent()) { + Optional o = storage.getValue("TFSet"); + if (o.isPresent()) { TransformNR start = new TransformNR(); - ArrayList tfs=(ArrayList) o.get(); - for(String s:tfs) { + ArrayList tfs = (ArrayList) o.get(); + for (String s : tfs) { try { TransformNR transTmp = (TransformNR) storage.getValue(s).get(); - start=transTmp.times(start); - }catch(Exception ex) { + start = transTmp.times(start); + } catch (Exception ex) { ex.printStackTrace(); } } - nrToCSG=TransformFactory.nrToCSG(start); - } + nrToCSG = TransformFactory.nrToCSG(start); + } return nrToCSG; } - + @Override public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - for (String name : names) { - CaDoodleFile.applyToAllConstituantElements(false,name, back, new ICadoodleRecursiveEvent() { - @Override - public ArrayList process(CSG incoming) { - Transform nrToCSG2 = TransformFactory.nrToCSG(location); - CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming) - .setName(incoming.getName()); - ArrayList b = new ArrayList<>(); - b.add(tmpToAdd); - set(getName(),tmpToAdd,location); - return b; - } - }); - } + + CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { + @Override + public ArrayList process(CSG incoming) { + Transform nrToCSG2 = TransformFactory.nrToCSG(location); + CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); + ArrayList b = new ArrayList<>(); + b.add(tmpToAdd); + set(getName(), tmpToAdd, location); + return b; + } + }); + return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index e2fad554..361def5e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -39,23 +39,22 @@ public List process(List incoming) { back.addAll(incoming); index = 1; cpMap.clear(); - for (int j = 0; j < names.size(); j++) { - String s = names.get(j); - CaDoodleFile.applyToAllConstituantElements(false, s, back, new ICadoodleRecursiveEvent() { - @Override - public ArrayList process(CSG ic) { - ArrayList copyPasteMoved = copyPasteMoved(back, ic); - return copyPasteMoved; - } - }); - } - for(String from:cpMap.keySet()) { + + CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { + @Override + public ArrayList process(CSG ic) { + ArrayList copyPasteMoved = copyPasteMoved(back, ic); + return copyPasteMoved; + } + }); + + for (String from : cpMap.keySet()) { CSG source = getByName(back, from); - if(source.isGroupResult()) { - ArrayList c =constituants(back,from); - String newGroupName = getByName(back,cpMap.get(from)).getName(); - for(String s:c) { - CSG dest = getByName(back,s); + if (source.isGroupResult()) { + ArrayList c = constituants(back, from); + String newGroupName = getByName(back, cpMap.get(from)).getName(); + for (String s : c) { + CSG dest = getByName(back, s); dest.removeGroupMembership(from); dest.addGroupMembership(newGroupName); } @@ -63,26 +62,26 @@ public ArrayList process(CSG ic) { } return back; } - private ArrayList constituants(ArrayList back,String name){ + + private ArrayList constituants(ArrayList back, String name) { ArrayList c = new ArrayList(); - for(CSG csg:back) { - if(csg.checkGroupMembership(name)) { + for (CSG csg : back) { + if (csg.checkGroupMembership(name)) { // only add objects that were created by this operation - if(csg.getName().contains(getName())) + if (csg.getName().contains(getName())) c.add(csg.getName()); } } return c; } + private CSG getByName(ArrayList back, String name) { - for(CSG c:back) { + for (CSG c : back) { if (c.getName().contentEquals(name)) - return c; + return c; } - throw new RuntimeException("Fail! there was no object named "+name); + throw new RuntimeException("Fail! there was no object named " + name); } - - private ArrayList copyPasteMoved(ArrayList back, CSG c) { String prevName = c.getName(); @@ -91,11 +90,11 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); Transform nrToCSG = MoveCenter.getTotalOffset(c); - CSG newOne =null; - if(CaDoodleVitamin.isVitamin(c)) - newOne=clone.regenerate().transformed(nrToCSG); + CSG newOne = null; + if (CaDoodleVitamin.isVitamin(c)) + newOne = clone.regenerate().transformed(nrToCSG); else - newOne=clone; + newOne = clone; newOne.setRegenerate(c.getRegenerate()).setName(name); index++; newOne.syncProperties(c).setName(name); @@ -125,7 +124,6 @@ public Paste setNames(List names) { return this; } - // public Paste setOffset(double offset) { // this.offset = offset; // return this; From 14ed72caf2d021fc4626038c6887a2ddfc09210a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 21 Dec 2024 14:31:39 -0500 Subject: [PATCH 252/635] removing dead code --- .../scripting/cadoodle/CaDoodleFile.java | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 031a4e1e..6be89848 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -361,40 +361,6 @@ private void pruneForward() { ICaDoodleOpperation key = getOpperations().get(i); List back = cache.remove(key); VitaminBomManager boM = CaDoodleFile.getBillOfMaterials(); -// if (AbstractAddFrom.class.isInstance(key)) { -// AbstractAddFrom aaf = (AbstractAddFrom) key; -// for (String name : aaf.getNamesAdded()) { -// VitaminLocation loc = boM.getByName(name); -// if (loc != null) { -// boM.remove(loc); -// boM.save(); -// } -// } -// } -// if (Delete.class.isInstance(key)) { -// Delete d = (Delete) key; -// for (String s : d.getNames()) { -// for (CSG c : back) { -// String type = null; -// String size = null; -// if (c.getName().contentEquals(s)) { -// for (String param : c.getParameters()) { -// if (param.contains("_CaDoodle_Vitamin_Type")) { -// Parameter p = CSGDatabase.get(param); -// type = p.getStrValue(); -// } -// if (param.contains("_CaDoodle_Vitamin_Size")) { -// Parameter p = CSGDatabase.get(param); -// size = p.getStrValue(); -// } -// } -// if (type != null && size != null) { -// boM.addVitamin(new VitaminLocation(false, c.getName(), type, size, new TransformNR())); -// } -// } -// } -// } -// } if (back != null) back.clear(); } From fa880e931357e5db25bfef6198eb744e27e0fd91 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 23 Dec 2024 10:18:40 -0500 Subject: [PATCH 253/635] adding depth gauge to the recoursion --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 +++++----- .../bowlerstudio/scripting/cadoodle/Delete.java | 4 ++-- .../scripting/cadoodle/ICadoodleRecursiveEvent.java | 2 +- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 4 ++-- .../bowlerstudio/scripting/cadoodle/Paste.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6be89848..4e64b001 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -310,15 +310,15 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner; } public static int applyToAllConstituantElements(boolean addRet, List targetNames, ArrayList back, - ICadoodleRecursiveEvent p) { + ICadoodleRecursiveEvent p, int depth) { for (int i = 0; i < targetNames.size(); i++) { String s = targetNames.get(i); - applyToAllConstituantElements(addRet, s, back, p); + applyToAllConstituantElements(addRet, s, back, p,depth); } return back.size(); } public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - ICadoodleRecursiveEvent p) { + ICadoodleRecursiveEvent p, int depth) { ArrayList immutable = new ArrayList<>(); immutable.addAll(back); for (int i = 0; i < immutable.size(); i++) { @@ -333,7 +333,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget) { // move it - ArrayList tmpToAdd = p.process(csg); + ArrayList tmpToAdd = p.process(csg,depth); if (addRet) { back.addAll(tmpToAdd); } else { @@ -349,7 +349,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } if (groupResult && thisCSGIsInGroupNamedAfterTarget) { // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, p); + applyToAllConstituantElements(addRet, thisCSGName, back, p,depth+1); } } back.removeAll(Collections.singleton(null)); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 1b657e9f..4d4afb8f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -31,13 +31,13 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { @Override - public ArrayList process(CSG incoming) { + public ArrayList process(CSG incoming, int depth) { ArrayList b = new ArrayList<>(); b.add(null); return b; } - }); + },1); return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java index 178d2319..5511804e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleRecursiveEvent.java @@ -5,5 +5,5 @@ import eu.mihosoft.vrl.v3d.CSG; public interface ICadoodleRecursiveEvent { - public ArrayList process(CSG incoming); + public ArrayList process(CSG incoming,int depth); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 04f6a6c8..47011d3d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -95,7 +95,7 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { @Override - public ArrayList process(CSG incoming) { + public ArrayList process(CSG incoming, int depth) { Transform nrToCSG2 = TransformFactory.nrToCSG(location); CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); ArrayList b = new ArrayList<>(); @@ -103,7 +103,7 @@ public ArrayList process(CSG incoming) { set(getName(), tmpToAdd, location); return b; } - }); + },1); return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 361def5e..6d4467c2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -42,11 +42,11 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { @Override - public ArrayList process(CSG ic) { + public ArrayList process(CSG ic, int depth) { ArrayList copyPasteMoved = copyPasteMoved(back, ic); return copyPasteMoved; } - }); + },1); for (String from : cpMap.keySet()) { CSG source = getByName(back, from); From f43285bda7cae50ab785d73d9d2fcc5458e0b97c Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 23 Dec 2024 12:41:51 -0500 Subject: [PATCH 254/635] repairing the copy paste by fixing the recoursive apply algorithm --- .../scripting/cadoodle/CaDoodleFile.java | 13 +++++++------ .../scripting/cadoodle/Paste.java | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4e64b001..8c882978 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -109,8 +109,8 @@ public CaDoodleFile addListener(ICaDoodleStateUpdate l) { } public void initialize() { - if (initializing) - throw new RuntimeException("Can not initialize while initializing."); +// if (initializing) +// throw new RuntimeException("Can not initialize while initializing."); fireInitializationStart(); initializing = true; if (selfInternal != null) { @@ -134,8 +134,9 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - pruneForward(); - return; + //pruneForward(); + indexStarting = i; + break; } } setCurrentIndex(indexStarting); @@ -331,7 +332,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); boolean groupResult = csg.isGroupResult(); - if (thisCSGIsTheTarget || thisCSGIsInGroupNamedAfterTarget) { + if (thisCSGIsTheTarget ) { // move it ArrayList tmpToAdd = p.process(csg,depth); if (addRet) { @@ -347,7 +348,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } continue; } - if (groupResult && thisCSGIsInGroupNamedAfterTarget) { + if (thisCSGIsInGroupNamedAfterTarget) { // composite group applyToAllConstituantElements(addRet, thisCSGName, back, p,depth+1); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 6d4467c2..dc0bba53 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -3,6 +3,7 @@ import java.io.File; import java.nio.file.NoSuchFileException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -43,7 +44,7 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG ic, int depth) { - ArrayList copyPasteMoved = copyPasteMoved(back, ic); + ArrayList copyPasteMoved = copyPasteMoved(back, ic,depth); return copyPasteMoved; } },1); @@ -52,6 +53,8 @@ public ArrayList process(CSG ic, int depth) { CSG source = getByName(back, from); if (source.isGroupResult()) { ArrayList c = constituants(back, from); + if(c.size()<2) + throw new RuntimeException("A group result must have at least 2 constituants!"); String newGroupName = getByName(back, cpMap.get(from)).getName(); for (String s : c) { CSG dest = getByName(back, s); @@ -63,14 +66,19 @@ public ArrayList process(CSG ic, int depth) { return back; } - private ArrayList constituants(ArrayList back, String name) { + private ArrayList constituants(ArrayList b, String name) { ArrayList c = new ArrayList(); - for (CSG csg : back) { + for (String ky:cpMap.keySet()) { + CSG byName = getByName(b,ky); + String name2 = cpMap.get(ky); + CSG byName2 = getByName(b,name2); + for(CSG csg:Arrays.asList(byName,byName2)){ if (csg.checkGroupMembership(name)) { // only add objects that were created by this operation if (csg.getName().contains(getName())) c.add(csg.getName()); } + } } return c; } @@ -83,9 +91,9 @@ private CSG getByName(ArrayList back, String name) { throw new RuntimeException("Fail! there was no object named " + name); } - private ArrayList copyPasteMoved(ArrayList back, CSG c) { + private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { String prevName = c.getName(); - String name = getName() + (index == 0 ? "" : "_" + index); + String name = getName() +(index == 0 ? "" : "_" + index); CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); @@ -102,6 +110,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c) { ArrayList b = new ArrayList<>(); b.add(c); b.add(newOne); + System.out.println("Copy "+c.getName()+" to "+newOne.getName()); cpMap.put(c.getName(), newOne.getName()); return b; } From 817c286ece5a4639a6da4b095c43f453285ae894 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 23 Dec 2024 13:04:02 -0500 Subject: [PATCH 255/635] freecad is 1.0.0 now, no longer autoupdate --- .../neuronrobotics/bowlerstudio/BowlerKernel.java | 13 +++++++++++-- .../bowlerstudio/scripting/DownloadManager.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index ef45ec3e..a0cb9d28 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -72,6 +72,7 @@ public class BowlerKernel { // private static final String CSG = null; private static File historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history"); + private static boolean kernelMode=true; private static void loadHistoryLocal() { historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history"); @@ -108,8 +109,8 @@ private static void fail() { com.neuronrobotics.sdk.common.Log.error( "java -jar BowlerScriptKernel.jar -r (Optional)(-s or -p) .. # This will start a shell in the requested langauge and run the files provided. "); com.neuronrobotics.sdk.common.Log.error("java -jar BowlerScriptKernel.jar -g # this will run a file from git"); - - System.exit(1); + if(isKernelMode()) + System.exit(1); } /** @@ -821,5 +822,13 @@ public static void runLater(Runnable r, Throwable ex) { }); } + public static boolean isKernelMode() { + return kernelMode; + } + + public static void setKernelMode(boolean kernelMode) { + BowlerKernel.kernelMode = kernelMode; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 04334186..94233c5c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -366,7 +366,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String } if (!new File(cmd).exists()) { if(exeType.toLowerCase().contentEquals("freecad")) { - FreecadLoader.update(vm); + //FreecadLoader.update(vm); baseURL = vm.get("url").toString(); name = vm.get("name").toString(); exeInZip = vm.get(executable).toString(); From f9a7073827c523a50687931473b32844c49e29a5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 23 Dec 2024 14:56:03 -0500 Subject: [PATCH 256/635] recoursivly apply the allign move but only calculate the move by the visable objectes --- .../scripting/CaDoodleLoader.java | 5 +- .../scripting/cadoodle/Allign.java | 115 ++++++++---------- .../scripting/cadoodle/CaDoodleFile.java | 11 ++ .../scripting/cadoodle/Paste.java | 21 ++-- 4 files changed, 68 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index f2ddfc35..ef220884 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -36,10 +36,7 @@ public static Object process(CaDoodleFile loaded) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c: incoming) { - if(c.isInGroup()) { - back.remove(c); - } - if(c.isHide()) { + if(c.isInGroup() || c.isHide()) { back.remove(c); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index e0e649b3..947a228f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import com.google.gson.annotations.Expose; @@ -9,6 +10,7 @@ import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class Allign implements ICaDoodleOpperation { @Expose (serialize = true, deserialize = true) @@ -40,77 +42,62 @@ public String toString(){ @Override public List process(List incoming) { - ArrayList toMove = new ArrayList(); ArrayList back = new ArrayList(); back.addAll(incoming); - CSG reference=null; - CSG refProps =null; - for(CSG c: incoming) { - if(c.isLock()) - continue; - String name = names.get(0); - if(name.contentEquals(c.getName())) { - back.remove(c); - refProps=c; - reference=c.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); - } - } - for(String name:names) - collectToMove(toMove, back, name); + Bounds bounds2 ;// if(bounds!=null) { bounds2=bounds.getBounds(); - toMove.add(refProps); }else { - CSG transformed = reference.transformed(TransformFactory.nrToCSG(getWorkplane())); - back.add(sync(refProps,transformed)); - bounds2 = reference.getBounds(); + throw new RuntimeException("Allign can not be initialized without bounds!"); } - for(CSG tmp:toMove) { - CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); - c = performTransform(bounds2, c); - back.add(sync(tmp,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); + HashMap moves= new HashMap<>(); + for(String name :names) { + for(CSG tmp:back) { + if(!tmp.getName().contentEquals(name)) + continue; + CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + TransformNR tf = performTransform(bounds2, c); + moves.put(c.getName(),tf); + } + } + for(String name:moves.keySet()) { + Transform tf = TransformFactory.nrToCSG(moves.get(name)); + CaDoodleFile.applyToAllConstituantElements(false, name, back, (incoming1, depth) ->{ + ArrayList b = new ArrayList<>(); + CSG c = incoming1.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + c=c.transformed(tf); + b.add(sync(incoming1,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); + return b; + }, 1); } return back; } - private void collectToMove(ArrayList toMove, ArrayList back, String name) { - ArrayList toSearch = new ArrayList(); - toSearch.addAll(back); - for (int i = 0; i < toSearch.size(); i++) { - CSG c = toSearch.get(i); - if(name.contentEquals(c.getName())) { - back.remove(c); - toMove.add(c); - if(c.isGroupResult()) { - for(int j=0;j toMove, ArrayList back, String name) { +// ArrayList toSearch = new ArrayList(); +// toSearch.addAll(back); +// for (int i = 0; i < toSearch.size(); i++) { +// CSG c = toSearch.get(i); +// if(name.contentEquals(c.getName())) { +// toMove.add(c); +// } +// } +// } - private CSG performTransform(Bounds reference, CSG incoming) { - CSG c = incoming; + private TransformNR performTransform(Bounds reference, CSG incoming) { + //CSG c = incoming; + double tx=0,ty=0,tz=0; if(z!=null) { switch(z) { case negative: - c=( c.toZMin() - .movez(reference.getMinZ()) - ); + tz=-incoming.getMinZ()+reference.getMinZ(); break; case middle: - c=( c.moveToCenterZ() - .movez(reference.getCenterZ())); + tz=-incoming.getCenterZ()+reference.getCenterZ(); break; case positive: - c=( c.toZMax() - .movez(reference.getMaxZ())); + tz=-incoming.getMaxZ()+reference.getMaxZ(); break; default: break; @@ -119,16 +106,13 @@ private CSG performTransform(Bounds reference, CSG incoming) { if(x!=null) { switch(x) { case negative: - c=( c.toXMin() - .movex(reference.getMinX())); + tx=-incoming.getMinX()+reference.getMinX(); break; case middle: - c=( c.moveToCenterX() - .movex(reference.getCenterX())); + tx=-incoming.getCenterX()+reference.getCenterX(); break; case positive: - c=( c.toXMax() - .movex(reference.getMaxX())); + tx=-incoming.getMaxX()+reference.getMaxX(); break; default: break; @@ -137,24 +121,21 @@ private CSG performTransform(Bounds reference, CSG incoming) { } if(y!=null) { switch(y) { + case negative: + ty=-incoming.getMinY()+reference.getMinY(); + break; case middle: - c=( c.moveToCenterY() - .movey(reference.getCenterY())); + ty=-incoming.getCenterY()+reference.getCenterY(); break; case positive: - c=( c.toYMax() - .movey(reference.getMaxY())); - break; - case negative: - c= c.toYMin() - .movey(reference.getMinY()); + ty=-incoming.getMaxY()+reference.getMaxY(); break; default: break; } } - return sync(incoming, c); + return new TransformNR(tx,ty,tz); } private CSG sync(CSG incoming, CSG c) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8c882978..992be77f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -310,10 +310,21 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.start(); return opperationRunner; } + public static CSG getByName(ArrayList back, String name) { + for (CSG c : back) { + if (c.getName().contentEquals(name)) + return c; + } + throw new RuntimeException("Fail! there was no object named " + name); + } + public static int applyToAllConstituantElements(boolean addRet, List targetNames, ArrayList back, ICadoodleRecursiveEvent p, int depth) { for (int i = 0; i < targetNames.size(); i++) { String s = targetNames.get(i); + CSG c=getByName(back, s); + if(c.isInGroup()) + continue; applyToAllConstituantElements(addRet, s, back, p,depth); } return back.size(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index dc0bba53..3a2e58ec 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -50,14 +50,14 @@ public ArrayList process(CSG ic, int depth) { },1); for (String from : cpMap.keySet()) { - CSG source = getByName(back, from); + CSG source = CaDoodleFile.getByName(back, from); if (source.isGroupResult()) { ArrayList c = constituants(back, from); if(c.size()<2) throw new RuntimeException("A group result must have at least 2 constituants!"); - String newGroupName = getByName(back, cpMap.get(from)).getName(); + String newGroupName = CaDoodleFile.getByName(back, cpMap.get(from)).getName(); for (String s : c) { - CSG dest = getByName(back, s); + CSG dest = CaDoodleFile.getByName(back, s); dest.removeGroupMembership(from); dest.addGroupMembership(newGroupName); } @@ -69,9 +69,9 @@ public ArrayList process(CSG ic, int depth) { private ArrayList constituants(ArrayList b, String name) { ArrayList c = new ArrayList(); for (String ky:cpMap.keySet()) { - CSG byName = getByName(b,ky); + CSG byName = CaDoodleFile.getByName(b,ky); String name2 = cpMap.get(ky); - CSG byName2 = getByName(b,name2); + CSG byName2 = CaDoodleFile.getByName(b,name2); for(CSG csg:Arrays.asList(byName,byName2)){ if (csg.checkGroupMembership(name)) { // only add objects that were created by this operation @@ -83,13 +83,7 @@ private ArrayList constituants(ArrayList b, String name) { return c; } - private CSG getByName(ArrayList back, String name) { - for (CSG c : back) { - if (c.getName().contentEquals(name)) - return c; - } - throw new RuntimeException("Fail! there was no object named " + name); - } + private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { String prevName = c.getName(); @@ -106,7 +100,8 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { newOne.setRegenerate(c.getRegenerate()).setName(name); index++; newOne.syncProperties(c).setName(name); - getNamesAdded().add(name); + if(!c.isInGroup()) + getNamesAdded().add(name); ArrayList b = new ArrayList<>(); b.add(c); b.add(newOne); From e1486525b6fd98a4b6b3da80f5d00b411ce7d42a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 23 Dec 2024 20:20:02 -0500 Subject: [PATCH 257/635] Fixing the regeneration problem with pasted items Boils down to making sure that all added objects are added to the creaated names, but then are filtered out in the recoursive apply just like the locked items. THis allows the parameterics to be added to the new items, but also prevents then additional items from being selected in the selection box. --- .../scripting/cadoodle/Allign.java | 28 +++++++++++++++---- .../scripting/cadoodle/CaDoodleVitamin.java | 14 +++++----- .../scripting/cadoodle/Paste.java | 23 +++++++++------ .../scripting/cadoodle/UnGroup.java | 10 +++---- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 947a228f..dc54b32d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import com.google.gson.annotations.Expose; @@ -25,7 +26,18 @@ public class Allign implements ICaDoodleOpperation { private TransformNR workplane=null; @Expose (serialize = true, deserialize = true) public StoragbeBounds bounds=null; - + @Expose(serialize = true, deserialize = true) + protected String name = null; + public String getName() { + if (name == null) { + setName(RandomStringFactory.generateRandomString()); + } + return name; + } + + public void setName(String name) { + this.name = name; + } @Override public String getType() { return "Allign"; @@ -62,12 +74,18 @@ public List process(List incoming) { } } for(String name:moves.keySet()) { - Transform tf = TransformFactory.nrToCSG(moves.get(name)); + TransformNR wpinv = getWorkplane().inverse(); + TransformNR nr = moves.get(name); + TransformNR wp = getWorkplane(); + + TransformNR times = wp.times(nr.times(wpinv)); + Transform tf = TransformFactory.nrToCSG(times); CaDoodleFile.applyToAllConstituantElements(false, name, back, (incoming1, depth) ->{ ArrayList b = new ArrayList<>(); - CSG c = incoming1.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); - c=c.transformed(tf); - b.add(sync(incoming1,c.transformed(TransformFactory.nrToCSG(getWorkplane())))); + CSG c=incoming1.transformed(tf); + sync(incoming1,c); + MoveCenter.set(getName() , c, times); + b.add(c); return b; }, 1); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index fa278f5f..ddaaf33d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -76,7 +76,7 @@ public static CSG get(String typencoming,String defaultValue, ArrayList } CSG part; try { - System.out.println("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); +// System.out.println("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); Set params = part.getParameters(); @@ -84,11 +84,11 @@ public static CSG get(String typencoming,String defaultValue, ArrayList part.setParameter(word); part.setParameter(typeParam); params = part.getParameters(); - - System.out.println("Parameters on Vitamin: "+name); - for(String s:params) { - System.out.println("\t"+s); - } + part.setName(name); +// System.out.println("Parameters on Vitamin: "+name); +// for(String s:params) { +// System.out.println("\t"+s); +// } CSG back = part.setRegenerate(new IRegenerate() { @Override public CSG regenerate(CSG previous) { @@ -98,7 +98,7 @@ public CSG regenerate(CSG previous) { name2=pv.get().toString(); else name2=name; - System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); + //System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); ar.set(0, previous.getName()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 3a2e58ec..6e9cdf35 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import com.google.gson.annotations.Expose; @@ -18,6 +19,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.Parameter; public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -87,25 +90,27 @@ private ArrayList constituants(ArrayList b, String name) { private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { String prevName = c.getName(); - String name = getName() +(index == 0 ? "" : "_" + index); + String name = getName() +( index == 0 ? "" : "_" + index); CSG clone = c.clone(); clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); Transform nrToCSG = MoveCenter.getTotalOffset(c); CSG newOne = null; - if (CaDoodleVitamin.isVitamin(c)) - newOne = clone.regenerate().transformed(nrToCSG); - else + if (CaDoodleVitamin.isVitamin(c)) { + CSG regenerate = clone.getRegenerate().regenerate(clone); + newOne = regenerate.transformed(nrToCSG); + newOne.setRegenerate(regenerate.getRegenerate()); + }else { newOne = clone; - newOne.setRegenerate(c.getRegenerate()).setName(name); - index++; + newOne.setRegenerate(c.getRegenerate()); + } newOne.syncProperties(c).setName(name); - if(!c.isInGroup()) - getNamesAdded().add(name); + index++; + getNamesAdded().add(name); ArrayList b = new ArrayList<>(); b.add(c); b.add(newOne); - System.out.println("Copy "+c.getName()+" to "+newOne.getName()); + //System.out.println("Copy "+c.getName()+" to "+newOne.getName()); cpMap.put(c.getName(), newOne.getName()); return b; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index d208940e..92774521 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -34,11 +34,11 @@ public List process(List incoming) { if (csg.checkGroupMembership(name)) { // release this object from the group Transform nrToCSG = MoveCenter.getTotalOffset(csg); - CSG transformed=null; - if(CaDoodleVitamin.isVitamin(csg)) - transformed= csg.regenerate().transformed(nrToCSG); - else - transformed=csg; + CSG transformed=csg; + if(CaDoodleVitamin.isVitamin(csg)) { + CSG regenerate = csg.getRegenerate().regenerate(csg); + transformed = regenerate.transformed(nrToCSG); + } CSG readd= transformed.setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); readd.removeGroupMembership(name); From d7afb39b35e604e8a3d489ded3dc2b042fd3d7ac Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 24 Dec 2024 11:10:25 -0500 Subject: [PATCH 258/635] remove unneeded transform in the add script --- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 22ae1126..f61e445a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -68,9 +68,7 @@ public List process(List incoming) { collect.addAll(flaten); for(int i=0;i Date: Tue, 24 Dec 2024 11:10:59 -0500 Subject: [PATCH 259/635] formatting --- .../scripting/cadoodle/CaDoodleFile.java | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 992be77f..22b21c09 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -134,7 +134,7 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - //pruneForward(); + // pruneForward(); indexStarting = i; break; } @@ -161,7 +161,7 @@ private void updateBoM() { String type = null; String size = null; for (String param : c.getParameters()) { - if(!param.contains(c.getName())) + if (!param.contains(c.getName())) continue; if (param.contains("_CaDoodle_Vitamin_Type")) { Parameter p = CSGDatabase.get(param); @@ -224,20 +224,24 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } } setCurrentIndex(opIndex); - - for (; getCurrentIndex() < size;) { - setCurrentIndex(getCurrentIndex() + 1); - setPercentInitialized(((double) getCurrentIndex()) / size); - // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); - ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); - List process = op.process(getPreviouState()); - storeResultInCache(op, process); - setCurrentState(op, process); - } - if (getCurrentIndex() != endIndex) { - setCurrentIndex(endIndex); - updateCurrentFromCache(); + try { + for (; getCurrentIndex() < size;) { + setCurrentIndex(getCurrentIndex() + 1); + setPercentInitialized(((double) getCurrentIndex()) / size); + // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); + ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); + List process = op.process(getPreviouState()); + storeResultInCache(op, process); + setCurrentState(op, process); + } + if (getCurrentIndex() != endIndex) { + setCurrentIndex(endIndex); + updateCurrentFromCache(); + } + } catch (Exception ex) { + ex.printStackTrace(); } + setPercentInitialized(1); updateBoM(); setRegenerating(false); fireSaveSuggestion(); @@ -310,6 +314,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.start(); return opperationRunner; } + public static CSG getByName(ArrayList back, String name) { for (CSG c : back) { if (c.getName().contentEquals(name)) @@ -322,13 +327,14 @@ public static int applyToAllConstituantElements(boolean addRet, List tar ICadoodleRecursiveEvent p, int depth) { for (int i = 0; i < targetNames.size(); i++) { String s = targetNames.get(i); - CSG c=getByName(back, s); - if(c.isInGroup()) + CSG c = getByName(back, s); + if (c.isInGroup()) continue; - applyToAllConstituantElements(addRet, s, back, p,depth); + applyToAllConstituantElements(addRet, s, back, p, depth); } return back.size(); } + public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, ICadoodleRecursiveEvent p, int depth) { ArrayList immutable = new ArrayList<>(); @@ -343,9 +349,9 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam boolean thisCSGIsTheTarget = thisCSGName.contentEquals(targetName); boolean groupResult = csg.isGroupResult(); - if (thisCSGIsTheTarget ) { + if (thisCSGIsTheTarget) { // move it - ArrayList tmpToAdd = p.process(csg,depth); + ArrayList tmpToAdd = p.process(csg, depth); if (addRet) { back.addAll(tmpToAdd); } else { @@ -361,7 +367,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } if (thisCSGIsInGroupNamedAfterTarget) { // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, p,depth+1); + applyToAllConstituantElements(addRet, thisCSGName, back, p, depth + 1); } } back.removeAll(Collections.singleton(null)); From d4851fda7cd1c890df5e3ddc0e1b41fb79c71d84 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 24 Dec 2024 11:10:59 -0500 Subject: [PATCH 260/635] formatting From 3c6e6574452916f4ab060832e768b37a54bbd645 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 24 Dec 2024 11:33:01 -0500 Subject: [PATCH 261/635] java-bowler --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index a359eb82..90f84a6c 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit a359eb822352ab2697f152ec513a93f461e35fca +Subproject commit 90f84a6c23e99eeb112e216c6d167ce92f6b06d9 From 7f7f797e1a0333df9ef3f333ff4f2b6a99808315 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 24 Dec 2024 12:28:02 -0500 Subject: [PATCH 262/635] Correcting a loading bug in the addFromScript that caused erronious file locations to be set and saved --- .../scripting/cadoodle/AddFromScript.java | 62 +++++++++++-------- .../scripting/cadoodle/CaDoodleFile.java | 7 ++- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index f61e445a..1c24edf6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -24,18 +24,16 @@ import eu.mihosoft.vrl.v3d.Transform; public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) private String gitULR = ""; - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) private String fileRel = ""; // @Expose(serialize = true, deserialize = true) // private TransformNR location =null; @Expose(serialize = true, deserialize = true) - private Boolean preventBoM =false; - + private Boolean preventBoM = false; - public AddFromScript set(String git, String f) { gitULR = git; fileRel = f; @@ -46,32 +44,42 @@ public AddFromScript set(String git, String f) { public String getType() { return "Add Object"; } - @Override public List process(List incoming) { + return process(incoming, fileRel); + } + + public List process(List incoming, String fileName) { - nameIndex=0; + nameIndex = 0; ArrayList back = new ArrayList(); back.addAll(incoming); try { - ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(getName() )); - HashMap configs =new HashMap(); + ArrayList args = new ArrayList<>(); + args.addAll(Arrays.asList(getName())); + HashMap configs = new HashMap(); configs.put("name", getName()); configs.put("PreventBomAdd", preventBoM); args.add(configs); - List flaten = ScriptingEngine - .flaten(gitULR, fileRel, CSG.class,args); + List flaten = ScriptingEngine.flaten(gitULR, fileName, CSG.class, args); ArrayList collect = new ArrayList<>(); collect.addAll(flaten); - for(int i=0;i0?("_"+i):"")); +// collect.set(i, tmp); +// namesAdded.add(tmp.getName()); +// System.out.println("AddFromScript: "+fileRel+" "+tmp.getName()); +// new RuntimeException().printStackTrace(); +// } + for (int i = 0; i < collect.size(); i++) { + CSG csg = collect.get(i); + CSG tmp = csg.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(getOrderedName()); collect.set(i, tmp); } back.addAll(collect); @@ -82,19 +90,21 @@ public List process(List incoming) { // boM.save(); // } } catch (Exception e) { - if(!fileRel.contains("generated")) - try { - fileRel="generated/"+fileRel; - return process(incoming); - }catch(Exception e2) { - e2.printStackTrace(); + e.printStackTrace(); + if (!fileName.contains("generated")) { + try { + return process(incoming, "generated/" + fileRel); + } catch (Exception e2) { + e2.printStackTrace(); + } } } + + if (back.size() == 0) + throw new RuntimeException("AddFromScript must return at least one CSG! " + getName()); return back; } - - // public TransformNR getLocation() { // if(location==null) // location=new TransformNR(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 22b21c09..f8d37868 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -253,9 +253,14 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } public Thread regenerateCurrent() { - if (isOperationRunning()) { + if (isOperationRunning() ) { return opperationRunner; } + if(initializing) { + Thread t = new Thread(); + t.start(); + return t; + } fireRegenerateStart(); opperationRunner = new Thread(() -> { opperationRunner.setName("regenerateCurrent Thread"); From 986173729314e1550353a1a020b3a74592a371d0 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 26 Dec 2024 14:04:00 -0500 Subject: [PATCH 263/635] updated the mirror algorithm to apply to elements recoursivly --- .../scripting/cadoodle/Mirror.java | 115 +++++++++++++----- .../scripting/cadoodle/MirrorOrentation.java | 5 + 2 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MirrorOrentation.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index deb15b04..3655a6c1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -9,61 +9,101 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; public class Mirror implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) - private TransformNR location=new TransformNR(); - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) + private MirrorOrentation location; + @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); - + @Expose(serialize = true, deserialize = true) + private TransformNR workplane = null; + @Override public String getType() { return "Move Center"; } + private CSG sync(CSG incoming, CSG c) { + return c.syncProperties(incoming).setName(incoming.getName()).setColor(incoming.getColor()); + } + @Override public List process(List incoming) { ArrayList back = new ArrayList(); - back.addAll(incoming - .stream() - .map(csg->{ - - for(String name:names) { - if(csg.isLock()) - continue; - if(csg.getName().contentEquals(name)) - return mirror(csg, name) - ; + back.addAll(incoming); + for (String name : names) { + for (CSG csg : incoming) { + if(!csg.getName().contentEquals(name)) + continue; + CSG base = csg.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + Transform mirroringCenter = new Transform().movex(base.getCenterX()).movey(base.getCenterY()) + .movez(base.getCenterZ()); + CaDoodleFile.applyToAllConstituantElements(false, name, back, (incoming1, depth) -> { + ArrayList b = new ArrayList<>(); + CSG t = incoming1.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + CSG centered = t.transformed(mirroringCenter.inverse()); + if (location == MirrorOrentation.x) { + centered = centered.mirrorx(); + } + if (location == MirrorOrentation.y) { + centered = centered.mirrory(); } - return csg; - }) - .collect(Collectors.toCollection(ArrayList::new)) - ); + if (location == MirrorOrentation.z) { + centered = centered.mirrorz(); + } + centered = centered.transformed(mirroringCenter); + centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane())); + CSG tf = centered.setName(name).syncProperties(incoming1); + sync(incoming1, tf); + b.add(tf); + return b; + }, 1); + } + } return back; +// back.addAll(incoming +// .stream() +// .map(csg->{ +// +// for(String name:names) { +// if(csg.isLock()) +// continue; +// if(csg.getName().contentEquals(name)) +// return mirror(csg, name) +// ; +// } +// return csg; +// }) +// .collect(Collectors.toCollection(ArrayList::new)) +// ); +// return back; } private CSG mirror(CSG csg, String name) { - CSG centered=csg.moveToCenter(); - if(location.getX()>0) { - centered=centered.mirrorx(); + CSG t = csg.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + Transform mirroringCenter = new Transform().movex(t.getCenterX()).movex(t.getCenterY()).movez(t.getCenterZ()); + + CSG centered = t.transformed(mirroringCenter.inverse()); + if (location == MirrorOrentation.x) { + centered = centered.mirrorx(); } - if(location.getY()>0) { - centered=centered.mirrory(); + if (location == MirrorOrentation.y) { + centered = centered.mirrory(); } - if(location.getZ()>0) { - centered=centered.mirrorz(); - } - return centered - .move(csg.getCenter()) - .setName(name) - .syncProperties(csg); + if (location == MirrorOrentation.z) { + centered = centered.mirrorz(); + } + centered = centered.transformed(mirroringCenter); + centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane())); + return centered.setName(name).syncProperties(csg); } - public TransformNR getLocation() { + public MirrorOrentation getLocation() { return location; } - public Mirror setLocation(TransformNR location) { + public Mirror setLocation(MirrorOrentation location) { this.location = location; return this; } @@ -77,4 +117,15 @@ public Mirror setNames(List names) { return this; } + public TransformNR getWorkplane() { + if (workplane == null) + workplane = new TransformNR(); + return workplane; + } + + public Mirror setWorkplane(TransformNR workplane) { + this.workplane = workplane; + return this; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MirrorOrentation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MirrorOrentation.java new file mode 100644 index 00000000..ee3456c5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MirrorOrentation.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public enum MirrorOrentation { + x,y,z; +} From 41a315ef4f3d24ca6d46d8c013e722deecfa0202 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 26 Dec 2024 16:15:11 -0500 Subject: [PATCH 264/635] Store the transforms as CSG transforms to allow for the mirror tf's to be stored --- .../scripting/cadoodle/Mirror.java | 46 ++++++++++++++----- .../scripting/cadoodle/MoveCenter.java | 12 +++-- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 3655a6c1..832ffb7d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -18,7 +18,19 @@ public class Mirror implements ICaDoodleOpperation { private List names = new ArrayList(); @Expose(serialize = true, deserialize = true) private TransformNR workplane = null; + @Expose(serialize = true, deserialize = true) + protected String name = null; + private int index; + public String getName() { + if (name == null) { + setName(RandomStringFactory.generateRandomString()); + } + return name; + } + public void setName(String name) { + this.name = name; + } @Override public String getType() { return "Move Center"; @@ -32,6 +44,7 @@ private CSG sync(CSG incoming, CSG c) { public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); + index = 0; for (String name : names) { for (CSG csg : incoming) { if(!csg.getName().contentEquals(name)) @@ -39,23 +52,34 @@ public List process(List incoming) { CSG base = csg.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); Transform mirroringCenter = new Transform().movex(base.getCenterX()).movey(base.getCenterY()) .movez(base.getCenterZ()); + Transform sc = new Transform(); + if (location == MirrorOrentation.x) { + sc=new Transform().scaleX(-1); + } + if (location == MirrorOrentation.y) { + sc=new Transform().scaleY(-1); + } + if (location == MirrorOrentation.z) { + sc=new Transform().scaleZ(-1); + } + Transform scale=sc; + CaDoodleFile.applyToAllConstituantElements(false, name, back, (incoming1, depth) -> { ArrayList b = new ArrayList<>(); - CSG t = incoming1.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + Transform inverse = TransformFactory.nrToCSG(getWorkplane()).inverse(); + CSG t = incoming1.transformed(inverse); CSG centered = t.transformed(mirroringCenter.inverse()); - if (location == MirrorOrentation.x) { - centered = centered.mirrorx(); - } - if (location == MirrorOrentation.y) { - centered = centered.mirrory(); - } - if (location == MirrorOrentation.z) { - centered = centered.mirrorz(); - } + centered = centered.transformed(scale); centered = centered.transformed(mirroringCenter); - centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane())); + Transform wp = TransformFactory.nrToCSG(getWorkplane()); + centered = centered.transformed(wp); CSG tf = centered.setName(name).syncProperties(incoming1); sync(incoming1, tf); + MoveCenter.set(getName()+(index++) , tf, inverse); + MoveCenter.set(getName()+(index++) , tf, mirroringCenter.inverse()); + MoveCenter.set(getName()+(index++) , tf, scale); + MoveCenter.set(getName()+(index++) , tf, mirroringCenter); + MoveCenter.set(getName()+(index++) , tf, wp); b.add(tf); return b; }, 1); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 47011d3d..0cf6df40 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -39,8 +39,10 @@ public void setName(String name) { public String getType() { return "Move Center"; } - public static void set(String name, CSG c, TransformNR tf) { + set(name,c,TransformFactory.nrToCSG(tf)); + } + public static void set(String name, CSG c, Transform tf) { if (tf == null) throw new NullPointerException(); if (name == null) @@ -73,17 +75,17 @@ public static Transform getTotalOffset(CSG c) { PropertyStorage storage = c.getStorage(); Optional o = storage.getValue("TFSet"); if (o.isPresent()) { - TransformNR start = new TransformNR(); + Transform start = new Transform(); ArrayList tfs = (ArrayList) o.get(); for (String s : tfs) { try { - TransformNR transTmp = (TransformNR) storage.getValue(s).get(); - start = transTmp.times(start); + Transform transTmp = new Transform().apply((Transform) storage.getValue(s).get()); + start = transTmp.apply(start); } catch (Exception ex) { ex.printStackTrace(); } } - nrToCSG = TransformFactory.nrToCSG(start); + nrToCSG = start; } return nrToCSG; } From 76cfb6d9bbe2a59f7706602f1de49538f02c87ae Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 10:49:15 -0500 Subject: [PATCH 265/635] make sure the bom exists before saving it --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f8d37868..2f599244 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -591,7 +591,8 @@ public File save() throws IOException { // e.getMessage()); e.printStackTrace(); } - bom.save(); + if(bom!=null) + bom.save(); } return getSelf(); From 28cb40348e8d208a728599e3d5d472cb46e55dee Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 11:25:10 -0500 Subject: [PATCH 266/635] remove generated TODO's --- GithubPasswordManager | 2 +- JCSG | 2 +- java-bowler | 2 +- .../bowlerkernel/Bezier3d/BezierEditor.java | 6 +-- .../Bezier3d/CartesianManipulator.java | 2 +- .../bowlerkernel/Bezier3d/Manipulation.java | 4 +- .../bowlerkernel/djl/UniquePersonFactory.java | 14 ++--- .../bowlerstudio/BowlerKernel.java | 28 +++++----- .../bowlerstudio/CoquiDockerManager.java | 2 +- .../IssueReportingExceptionHandler.java | 6 +-- .../assets/ConfigurationDatabase.java | 6 +-- .../creature/CadFileExporter.java | 12 ++--- .../creature/MobileBaseCadManager.java | 54 +++++++++---------- .../creature/MobileBaseLoader.java | 4 +- .../bowlerstudio/lipsync/RhubarbManager.java | 2 +- .../bowlerstudio/lipsync/VoskLipSync.java | 2 +- .../bowlerstudio/opencv/OpenCVManager.java | 2 +- .../physics/MuJoCoPhysicsManager.java | 6 +-- .../bowlerstudio/physics/PhysicsEngine.java | 2 +- .../physics/TransformFactory.java | 2 +- .../printbed/PrintBedManager.java | 4 +- .../bowlerstudio/scripting/ArduinoLoader.java | 4 +- .../bowlerstudio/scripting/BashLoader.java | 2 +- .../bowlerstudio/scripting/BlenderLoader.java | 12 ++--- .../bowlerstudio/scripting/ClojureHelper.java | 6 +-- .../scripting/DownloadManager.java | 36 ++++++------- .../scripting/FXMLBowlerLoader.java | 6 +-- .../bowlerstudio/scripting/GroovyHelper.java | 8 +-- .../scripting/IScriptingLanguage.java | 4 +- .../bowlerstudio/scripting/JsonRunner.java | 2 +- .../bowlerstudio/scripting/JythonHelper.java | 8 +-- .../bowlerstudio/scripting/ObjLoader.java | 4 +- .../bowlerstudio/scripting/RobotHelper.java | 10 ++-- .../scripting/ScriptingEngine.java | 20 +++---- .../scripting/SequenceRunner.java | 2 +- .../bowlerstudio/scripting/StlLoader.java | 6 +-- .../scripting/cadoodle/AddFromFile.java | 4 +- .../scripting/cadoodle/AddFromScript.java | 4 +- .../scripting/cadoodle/CaDoodleFile.java | 4 +- .../scripting/cadoodle/CaDoodleVitamin.java | 2 +- .../bowlerstudio/sequence/SequenceEvent.java | 2 +- .../bowlerstudio/util/FileChangeWatcher.java | 8 +-- .../util/FileWatchDeviceWrapper.java | 6 +-- .../util/GeometrySimplification.java | 2 +- .../util/IFileChangeListener.java | 2 +- .../bowlerstudio/vitamins/Purchasing.java | 2 +- .../vitamins/VitaminBomManager.java | 6 +-- .../bowlerstudio/vitamins/Vitamins.java | 20 +++---- .../imageprovider/AbstractImageProvider.java | 2 +- .../imageprovider/NativeResource.java | 2 +- .../imageprovider/StaticFileProvider.java | 6 +-- .../imageprovider/URLImageProvider.java | 6 +-- .../imageprovider/VirtualCameraFactory.java | 4 +- .../addons/gamepad/BowlerJInputDevice.java | 6 +-- .../sdk/dyio/sequencer/CoreScheduler.java | 4 +- .../dyio/sequencer/ISchedulerListener.java | 2 +- .../sequencer/ServoOutputScheduleChannel.java | 8 +-- .../src/junit/bowler/MobileBaseLoading.java | 2 +- test/java/src/junit/bowler/TTSTest.java | 2 +- test/java/src/junit/bowler/TestCheckout.java | 2 +- test/java/src/junit/bowler/WekaTester.java | 2 +- 61 files changed, 202 insertions(+), 202 deletions(-) diff --git a/GithubPasswordManager b/GithubPasswordManager index f38fc5f4..9da2226c 160000 --- a/GithubPasswordManager +++ b/GithubPasswordManager @@ -1 +1 @@ -Subproject commit f38fc5f48b6f073c2f8c306a3128627558e0dd8c +Subproject commit 9da2226c2553c0ede08a62bcf18c69e43175c2a6 diff --git a/JCSG b/JCSG index 64e5cd00..552527ae 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 64e5cd00ba9094f738ae17c41c64f308f1d78236 +Subproject commit 552527ae7998f0e167db69b28e814ee9734e8a11 diff --git a/java-bowler b/java-bowler index 90f84a6c..c25c1fe1 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 90f84a6c23e99eeb112e216c6d167ce92f6b06d9 +Subproject commit c25c1fe14d0f7a6a64ad138bca6c15d82af685d1 diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java index b8fbb295..60c53ce8 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java @@ -332,7 +332,7 @@ public void save() { ScriptingEngine.pushCodeToGit(url, ScriptingEngine.getFullBranch(url), gitfile, writeOut, "Saving Bezier"); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } else { @@ -340,7 +340,7 @@ public void save() { try { cachejson.createNewFile(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } OutputStream out = null; @@ -351,7 +351,7 @@ public void save() { // completes // normally } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } finally { IOUtils.closeQuietly(out); diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java index a43694c4..c2764ae3 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/CartesianManipulator.java @@ -75,7 +75,7 @@ public boolean isMoving() { } public void clearListeners() { - // TODO Auto-generated method stub + // Auto-generated method stub for (int i = 0; i < 3; i++) manipulationList[i].clearListeners(); } diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index ba13223a..95aae5a8 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -66,7 +66,7 @@ public void addSaveListener(Runnable r) { } public void clearListeners() { - // TODO Auto-generated method stub + // Auto-generated method stub saveListeners.clear(); eventListeners.clear(); } @@ -298,7 +298,7 @@ public void setInReferenceFrame(double newX, double newY, double newZ) { } public void reset() { - // TODO Auto-generated method stub + // Auto-generated method stub } diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java b/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java index fbe711a8..eb28eb82 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/djl/UniquePersonFactory.java @@ -105,13 +105,13 @@ private UniquePersonFactory(File database) { try { features = PredictorFactory.faceFeatureFactory(); } catch (ModelNotFoundException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (MalformedModelException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } factory = ImageFactory.getInstance(); @@ -144,7 +144,7 @@ public String save() { try { Files.write(path, strToBytes); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } if (workingMemory != null) @@ -415,7 +415,7 @@ private boolean processMemory(HashMap tmpPe @Override public ArrayList getNamespacesImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @@ -480,7 +480,7 @@ public void setDatabase(File database) { database.createNewFile(); save(); } catch (IOException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } else { @@ -490,7 +490,7 @@ public void setDatabase(File database) { longTermMemory = gson.fromJson(jsonString, TT_mapStringString); resetHash(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index a0cb9d28..aad3662a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -81,7 +81,7 @@ private static void loadHistoryLocal() { try { historyFile.createNewFile(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } history.add("println SDKBuildInfo.getVersion()"); @@ -410,7 +410,7 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil try { Files.copy(bomCSV.toPath(), file.toPath()); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -423,7 +423,7 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil try { Files.copy(bom.toPath(), file.toPath()); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -534,19 +534,19 @@ private static void processReturnedObjects(Object ret, ArrayList csgBits) { @Override public void setSelectedCsg(Collection selectedCsg) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void setSelected(Affine rootListener) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void setAllCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -558,13 +558,13 @@ public void highlightException(File fileEngineRunByName, Throwable ex) { @Override public Set getVisibleCSGs() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @Override public void addCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); @@ -619,7 +619,7 @@ public void addCSG(Collection toAdd, File source) { } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); fail(); } @@ -652,10 +652,10 @@ public static void writeHistory(List history) { bw.close(); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -772,10 +772,10 @@ public static void upenURL(String string) { upenURL(new URI(string)); } catch (URISyntaxException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (Throwable e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -785,7 +785,7 @@ public static void upenURL(URI htmlUrl) { try { Desktop.getDesktop().browse(htmlUrl); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java index 784d5ca1..2f6f1d3e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java @@ -194,7 +194,7 @@ public void onNext(Frame item) { } public void disconnect() { - // TODO Auto-generated method stub + // Auto-generated method stub dockerClient.killContainerCmd(id).exec(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java b/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java index 9b972ae3..c7fa0e69 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/IssueReportingExceptionHandler.java @@ -96,7 +96,7 @@ public void except(Throwable e, String stacktraceFromCatch) { try { Thread.sleep(5000); } catch (InterruptedException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } // wait for the Issue to be reported System.exit(-5); @@ -107,7 +107,7 @@ public void except(Throwable e, String stacktraceFromCatch) { try { Thread.sleep(5000); } catch (InterruptedException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } // wait for the Issue to be reported System.exit(-5); @@ -217,7 +217,7 @@ private void runReport(StackTraceElement[] element, String body, GitHub github) BowlerKernel.upenURL(i.getHtmlUrl().toURI()); } catch (Throwable e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } processing = false; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 8bc1606e..be9e13ea 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -142,7 +142,7 @@ public static void save() { try (PrintWriter out = new PrintWriter(f.getAbsolutePath())) { out.println(writeOut); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return; } @@ -189,12 +189,12 @@ public static File loadFile() { try (PrintWriter out = new PrintWriter(f.getAbsolutePath())) { out.println(contents); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 26977dc1..9c4c7a9f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -30,37 +30,37 @@ public CadFileExporter(){ @Override public void setSelectedCsg(Collection selectedCsg) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void setAllCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void highlightException(File fileEngineRunByName, Throwable ex) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public Set getVisibleCSGs() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @Override public void addCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void setSelected(Affine rootListener) { - // TODO Auto-generated method stub + // Auto-generated method stub } }; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 6c4246fc..dc4be7d3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -127,7 +127,7 @@ private ArrayList toVitaminCad(ArrayList vitamins,Affine m vitamin = getVitamin(vi,manipulator,offset); parts.add(vitamin); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -160,7 +160,7 @@ public CSG getVitamin(VitaminLocation vitamin,Affine manipulator,TransformNR off starting.setIsWireFrame(true); starting.syncProperties(origin); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return null; } @@ -191,7 +191,7 @@ public CSG getVitaminDisplay(VitaminLocation vitamin,Affine manipulator, Transfo }); } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return null; } @@ -256,7 +256,7 @@ public ArrayList vitaminsToDisplay(ArrayList l,Affine mani vitamin = getVitaminDisplay(vi,manipulator, offset); parts.add(vitamin); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -462,34 +462,34 @@ public void highlightException(File fileEngineRunByName, Throwable ex) { @Override public void setAllCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub list.clear(); list.addAll(toAdd); } @Override public void addCSG(Collection toAdd, File source) { - // TODO Auto-generated method stub + // Auto-generated method stub list.addAll(toAdd); } @Override public Set getVisibleCSGs() { - // TODO Auto-generated method stub + // Auto-generated method stub return new HashSet(list); } @Override public void setSelectedCsg(Collection selectedCsg) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void setSelected(Affine rootListener) { - // TODO Auto-generated method stub + // Auto-generated method stub } }; @@ -783,7 +783,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event) { try { build(key, f); } catch (Throwable e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } //ex.printStackTrace(); @@ -808,14 +808,14 @@ public void onDisconnect(BowlerAbstractDevice source) { @Override public void onConnect(BowlerAbstractDevice source) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); } return cadScriptCache.get(key); } catch (GitAPIException | IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } throw new RuntimeException("File Missing!"); @@ -840,16 +840,16 @@ private void closeScriptFromFileInfo(String[] args) { FileChangeWatcher.close(f); } catch (InvalidRemoteException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (TransportException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (GitAPIException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -900,7 +900,7 @@ private ICadGenerator getConfigurationDisplay()throws Throwable { try { getConfigurationDisplay(); } catch (Throwable e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } MobileBaseCadManager mobileBaseCadManager = null; @@ -1053,7 +1053,7 @@ public File getCadScriptFromLimnb(DHParameterKinematics l) { try { return ScriptingEngine.fileFromGit(l.getGitCadEngine()[0], l.getGitCadEngine()[1]); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return null; @@ -1063,7 +1063,7 @@ public File getCadScriptFromMobileBase(MobileBase device) { try { return ScriptingEngine.fileFromGit(device.getGitCadEngine()[0], device.getGitCadEngine()[1]); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return null; @@ -1299,7 +1299,7 @@ public void onDisconnect(BowlerAbstractDevice arg0) { @Override public void onConnect(BowlerAbstractDevice arg0) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); @@ -1361,7 +1361,7 @@ public ArrayList generateCad(DHParameterKinematics dh) { @Override public void onLinkPositionUpdate(AbstractLink arg0, double arg1) { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -1464,7 +1464,7 @@ public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } setProgress(1); @@ -1552,14 +1552,14 @@ public static MobileBaseCadManager get(MobileBase device) { @Override public void onDisconnect(BowlerAbstractDevice source) { - // TODO Auto-generated method stub + // Auto-generated method stub ui2.list.clear(); } @Override public void onConnect(BowlerAbstractDevice source) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); @@ -1641,7 +1641,7 @@ public void setConfigurationViewerMode(boolean b) { } } public void invalidateModelCache() { - // TODO Auto-generated method stub + // Auto-generated method stub } /** @@ -1657,7 +1657,7 @@ public void setConfigMode(boolean configMode) { this.configMode = configMode; } public boolean isCADstarted() { - // TODO Auto-generated method stub + // Auto-generated method stub return cadGenerating; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java index 5ac38d32..ac604351 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java @@ -48,7 +48,7 @@ public File setDefaultDhParameterKinematics(DHParameterKinematics device) { @Override public void onFileDelete(File fileThatIsDeleted) { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -105,7 +105,7 @@ public void setGitWalkingEngine(String git, String file, MobileBase device) { @Override public void onFileDelete(File fileThatIsDeleted) { - // TODO Auto-generated method stub + // Auto-generated method stub } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java index ad485c4b..8f6d5db7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/RhubarbManager.java @@ -129,7 +129,7 @@ public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) processRaw(audio, text.getAbsolutePath()); com.neuronrobotics.sdk.common.Log.error("Done writing!"); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java index 7034349b..b8aa7df5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/lipsync/VoskLipSync.java @@ -415,7 +415,7 @@ public AudioInputStream startProcessing(AudioInputStream ais, String TTSString) processRaw(audio, text.getAbsolutePath()); com.neuronrobotics.sdk.common.Log.error("Vosk Lip Sync Done writing! took " + (System.currentTimeMillis() - start)); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/opencv/OpenCVManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/opencv/OpenCVManager.java index 61f04cff..bca3f042 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/opencv/OpenCVManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/opencv/OpenCVManager.java @@ -52,7 +52,7 @@ public boolean connectDeviceImp() { @Override public ArrayList getNamespacesImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java index 9a5c885e..5e711c81 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/MuJoCoPhysicsManager.java @@ -309,7 +309,7 @@ public long stepAndWait() { try { Thread.sleep(diff); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block throw new RuntimeException(e); } } else if (diff == 0) { @@ -778,7 +778,7 @@ public org.mujoco.xml.BodyarchType.Builder loadLink(MobileBase cat, DHParamet } } } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } else { @@ -994,7 +994,7 @@ public void waitForCad(MobileBaseCadManager cadMan, long start) { try { Thread.sleep(1000); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); throw new RuntimeException(e); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsEngine.java index d2730271..ff1f40e8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/PhysicsEngine.java @@ -73,7 +73,7 @@ public static PhysicsCore get() { try { mainEngine = new PhysicsCore(); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java index b406ad53..caa193cb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java @@ -11,7 +11,7 @@ import javafx.application.Platform; import javafx.scene.transform.Affine; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * A factory for creating Transform objects. diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java index de551eb0..1d470deb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/printbed/PrintBedManager.java @@ -55,7 +55,7 @@ public PrintBedManager(File dir, ArrayList parts) { try { this.url=ScriptingEngine.locateGitUrl(dir); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } setHasPrintBed(init(dir, parts)); @@ -201,7 +201,7 @@ private synchronized void saveLocal() { // ScriptingEngine.commit(url, ScriptingEngine.getBranch(url), file, content, "Save Print Bed Locations", // true); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java index 0de90769..6f6307dd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java @@ -83,7 +83,7 @@ private File findIno(File start) { @Override public Object inlineScriptRun(String code, ArrayList args) throws Exception { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @@ -164,7 +164,7 @@ public static String getARDUINOExec() { @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList( ".ino",".c", ".h", ".cpp", ".hpp")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java index 5845c65a..b648b7d4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java @@ -82,7 +82,7 @@ public String getDefaultContents() { @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index 7d30be73..cef1de27 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -58,7 +58,7 @@ public static void toBlenderFile(File stl,File blenderfile) { try { stlIn = File.createTempFile(stl.getName(), ".stl"); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return; } @@ -85,7 +85,7 @@ public static void toBlenderFile(File stl,File blenderfile) { t.join(); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return; } @@ -95,7 +95,7 @@ public static void scaleStl(File incoming, File outgoing, double scale) { try { FileUtil.write(Paths.get(outgoing.getAbsolutePath()), back.toStlString()); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -173,10 +173,10 @@ public void getDefaultContents(File source) { try { DownloadManager.legacySystemRun(null, parent, System.out, args); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -184,7 +184,7 @@ public void getDefaultContents(File source) { @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return false; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java index 772fac1b..db314245 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java @@ -69,7 +69,7 @@ public Object inlineScriptRun(File code, ArrayList args) { String s = new String(bytes, "UTF-8"); return inlineScriptRun(s, args); } catch (IOException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); @@ -89,7 +89,7 @@ public String getShellType() { @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } @@ -104,7 +104,7 @@ public String getDefaultContents() { @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("clj", "cljs", "cljc")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 94233c5c..6cc310e0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -77,13 +77,13 @@ public class DownloadManager { @Override public void startDownload() { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void finishDownload() { - // TODO Auto-generated method stub + // Auto-generated method stub } }; @@ -118,7 +118,7 @@ public void onInstallFail(String url) { @Override public void onUpdate(String update, Exception e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -430,37 +430,37 @@ private static File getExecutable(String exeType, IExternalEditor editor, String @Override public void onProcessExit(int e) { ev = e; - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public String nameOfEditor() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @Override public void launch(File file, Button advanced) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public Class getSupportedLangauge() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @Override public URL getInstallURL() throws MalformedURLException { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } @Override public Image getImage() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } }; @@ -496,7 +496,7 @@ public Image getImage() { } } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -507,7 +507,7 @@ private static void saveFile(File file, String json) { try { FileUtils.writeStringToFile(file, json, Charset.forName("UTF-8")); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -526,7 +526,7 @@ private static void runInstaller(List installerList) { try { tcopy.join(); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } }else { @@ -534,7 +534,7 @@ private static void runInstaller(List installerList) { try { tcopy.join(); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -559,7 +559,7 @@ private static void standaloneEXE(String type, String name, String targetdir, St try { Files.move(Paths.get(bindir + name + "." + type), Paths.get(cmd), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } new File(cmd).setExecutable(true); @@ -597,7 +597,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { Arrays.asList("hdiutil", "detach", "/Volumes/" + newMount)); tdetach.join(); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return; } // wait for the mount to finish @@ -633,10 +633,10 @@ private static void extract7zSystemCall(String archivePath, String outputPath) { try { legacySystemRun(null, outputDir, System.out, args); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -1012,7 +1012,7 @@ public static String delim() { // try { // PasswordManager.login(); // } catch (IOException e) { -// // TODO Auto-generated catch block +// // Auto-generated catch block // e.printStackTrace(); // } // File f = getRunExecutable("eclipse",null); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java index d82b5d74..c802f1d7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java @@ -24,12 +24,12 @@ public Object inlineScriptRun(String code, ArrayList args) throws Except @Override public String getShellType() { - // TODO Auto-generated method stub + // Auto-generated method stub return "fxml"; } @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } /** @@ -42,7 +42,7 @@ public String getDefaultContents() { } @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("fxml","FXML","FxML")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 4545d020..c5e13ed6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -87,24 +87,24 @@ public Object inlineScriptRun(String code, ArrayList args) throws Except @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList( "groovy","java")); } @Override public IDebugScriptRunner compileDebug(File f) { - // TODO Auto-generated method stub + // Auto-generated method stub return new IDebugScriptRunner() { @Override public String[] step() { - // TODO Auto-generated method stub + // Auto-generated method stub return new String[]{"fileame.groovy", "345"}; } }; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java index 7a2797ac..a6101ef2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java @@ -104,7 +104,7 @@ default void getDefaultContents(File source) { * @return */ default String getDefaultContents() { - // TODO Auto-generated method stub + // Auto-generated method stub throw new RuntimeException("This shell " + getShellType() + " has binary files "); } @@ -118,7 +118,7 @@ default void getDefaultContents(String gitURL, String fileSlug) { try { getDefaultContents(ScriptingEngine.fileFromGit(gitURL, fileSlug)); } catch (GitAPIException | IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java index 7bccb957..0c2f2997 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java @@ -61,7 +61,7 @@ public String getDefaultContents() { @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("json")); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java index 89a03af6..ec46ca87 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java @@ -42,7 +42,7 @@ public Object inlineScriptRun(String code, ArrayList args) { // Class.forName(bad.getClass().getName()) // .cast(bad)); // } catch (ClassNotFoundException e) { -// // TODO Auto-generated catch block +// // Auto-generated catch block // e.printStackTrace(); // } // com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " @@ -82,7 +82,7 @@ public Object inlineScriptRun(File code, ArrayList args) { String s = new String(bytes, "UTF-8"); return inlineScriptRun(s, args); } catch (IOException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } return null; @@ -103,13 +103,13 @@ public String getDefaultContents() { } @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("py", "jy")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java index 4079ab46..3bab3dc5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java @@ -27,7 +27,7 @@ public String getShellType() { } @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return false; } /** @@ -40,7 +40,7 @@ public String getDefaultContents() { } @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("obj","OBJ","Obj")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java index ad18cf2e..2b38c878 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java @@ -31,12 +31,12 @@ public Object inlineScriptRun(File code, ArrayList args) { mb.setGitSelfSource(ScriptingEngine.findGitTagFromFile(code)); return MobileBaseLoader.get(mb).getBase(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return null; } } catch (IOException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); @@ -50,7 +50,7 @@ public Object inlineScriptRun(String code, ArrayList args) { try { mb = new MobileBase(IOUtils.toInputStream(code, "UTF-8")); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return null; } @@ -65,7 +65,7 @@ public String getShellType() { @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return true; } @@ -134,7 +134,7 @@ public void getDefaultContents(String gitURL, String slug) { @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("xml")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index d3d5f35f..86e82244 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -374,7 +374,7 @@ public static Git openGit(String url) { localRepo = getRepository(url); return openGit(localRepo); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } throw new RuntimeException("IOException making repo"); @@ -593,7 +593,7 @@ public static File getWorkingDirectory() { try { createSymlinkInDocuments(appDataDir); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -1714,11 +1714,11 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti commit(remoteURI, getBranch(remoteURI), p, content, "auto-save in ScriptingEngine.resolveConflict", false, git); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } catch (IOException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } @@ -1736,7 +1736,7 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti return resolveConflict(remoteURI, con, git); } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return true; @@ -2100,7 +2100,7 @@ public static GHRepository makeNewRepoNoFailOver(String newName, String descript try { Thread.sleep(1000); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -2125,7 +2125,7 @@ public static GHRepository makeNewRepo(String newName, String description) throw commit(url, "main", "firstCommit"); newBranch(url, "main"); } catch (IOException | GitAPIException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } catch (org.kohsuke.github.HttpException ex) { @@ -2147,7 +2147,7 @@ public static String locateGitUrlString(File f) { return string; } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return null; @@ -2408,7 +2408,7 @@ public static List getAllTags(String gitRepo) { tags.add(string); } } catch (Throwable e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -2453,7 +2453,7 @@ public static void tagRepo(String remoteURI, String newTag) { git.push().setPushTags().setCredentialsProvider(PasswordManager.getCredentialProvider()) .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); } catch (GitAPIException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } closeGit(git); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java index 3254ebb7..32d33319 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java @@ -55,7 +55,7 @@ public String getDefaultContents() { @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("sequence")); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java index 84fc5bf0..1b6c704b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java @@ -23,12 +23,12 @@ public Object inlineScriptRun(String code, ArrayList args) throws Except @Override public String getShellType() { - // TODO Auto-generated method stub + // Auto-generated method stub return "Stl"; } @Override public boolean getIsTextFile() { - // TODO Auto-generated method stub + // Auto-generated method stub return false; } /** @@ -41,7 +41,7 @@ public String getDefaultContents() { } @Override public ArrayList getFileExtenetion() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList<>(Arrays.asList("stl","STL","Stl")); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index c05eadf2..88d0baff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -84,7 +84,7 @@ public List process(List incoming) { // boM.save(); // } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return back; @@ -132,7 +132,7 @@ private File toLocal(File file) { copied = copyFileToNewDirectory(file, parentFile, getName()); file = copied; } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 1c24edf6..a701e86b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -118,11 +118,11 @@ public List process(List incoming, String fileName) { @Override public File getFile() { - // TODO Auto-generated method stub + // Auto-generated method stub try { return ScriptingEngine.fileFromGit(gitULR, fileRel); } catch (GitAPIException | IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 2f599244..e6a63ec3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -449,7 +449,7 @@ public File getSelf() { try { selfInternal = File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -624,7 +624,7 @@ private void loadingImageFromUIThread() { Thread.sleep(16); // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); break; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index ddaaf33d..6fca1af8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -113,7 +113,7 @@ public CSG regenerate(CSG previous) { //back.getStorage().set("PreviousName", name); return back; } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } throw new RuntimeException("Failed to load vitamin of type " + type); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/SequenceEvent.java b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/SequenceEvent.java index 656d87d9..1af6e3ce 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/SequenceEvent.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/SequenceEvent.java @@ -77,7 +77,7 @@ public void setMsDuration(int msDuration) { @Override public void done(InterpolationMoveState state) { - // TODO Auto-generated method stub + // Auto-generated method stub } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java index 6da2aecc..7d9325e3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java @@ -41,7 +41,7 @@ import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The Class FileChangeWatcher. */ @@ -158,7 +158,7 @@ public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -300,7 +300,7 @@ public void watch() { // overwrites } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -357,7 +357,7 @@ public void close() { com.neuronrobotics.sdk.common.Log.error("Closing watcher for "+fileToWatch.getAbsolutePath()); watcher.close(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } activeListener.remove(fileToWatch.getAbsolutePath()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileWatchDeviceWrapper.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileWatchDeviceWrapper.java index e08bcf15..24f7019f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileWatchDeviceWrapper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileWatchDeviceWrapper.java @@ -16,19 +16,19 @@ public static FileChangeWatcher watch(BowlerAbstractDevice device, File code,IFi @Override public void onDisconnect(BowlerAbstractDevice arg0) { - // TODO Auto-generated method stub + // Auto-generated method stub watcher.removeIFileChangeListener(cadWatcher); } @Override public void onConnect(BowlerAbstractDevice arg0) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); return watcher; } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block //BowlerStudioController.highlightException(code, e); } return null; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java index 79a97c87..a2f155d6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -69,7 +69,7 @@ public static File simplifySVG(File incoming, double threshhold) { legacySystemRun(null, inkscape.getAbsoluteFile().getParentFile(), System.out, args); return svg; } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return incoming; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/IFileChangeListener.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/IFileChangeListener.java index 38fcf66e..d4a066c2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/IFileChangeListener.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/IFileChangeListener.java @@ -3,7 +3,7 @@ import java.io.File; import java.nio.file.WatchEvent; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The listener interface for receiving IFileChange events. * The class that is interested in processing a IFileChange diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java index cb58417a..addaf30f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java @@ -184,7 +184,7 @@ public static ArrayList listVitaminTypes() { } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return types; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 2c88ba76..f18dd7d4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -58,7 +58,7 @@ public VitaminBomManager(File parentFile) { try { bom.createNewFile(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } else { @@ -147,7 +147,7 @@ public CSG get(String name) { return transformed; } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } return null; @@ -256,7 +256,7 @@ private synchronized void saveLocal() { write(getManufacturingBomJson(), content); write(getManufacturingBomCsv(), csv); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } saving = false; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index ac3e5ce9..80f869fa 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -112,11 +112,11 @@ public static CSG get(File resource, boolean forceRefresh) { // } // }); // } catch (IOException e) { -// // TODO Auto-generated catch block +// // Auto-generated catch block // e.printStackTrace(); // } } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -254,16 +254,16 @@ public static File getScriptFile(String type) { try { return ScriptingEngine.fileFromGit(script.get("scriptGit").toString(), script.get("scriptFile").toString()); } catch (InvalidRemoteException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (TransportException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (GitAPIException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return null; @@ -379,7 +379,7 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { try { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); } catch (URISyntaxException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } else { @@ -404,7 +404,7 @@ private static void processSelfPR(GHPullRequest request) throws IOException { try { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); } catch (URISyntaxException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -599,7 +599,7 @@ public static CopyOnWriteArrayList listVitaminTypes() { } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } Collections.sort(types); @@ -668,7 +668,7 @@ public static void reLoadDatabaseFromFiles() { try { ScriptingEngine.pull(getGitRepoDatabase()); } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } } catch (Exception e) { diff --git a/src/main/java/com/neuronrobotics/imageprovider/AbstractImageProvider.java b/src/main/java/com/neuronrobotics/imageprovider/AbstractImageProvider.java index 0f3eb2a3..d31e4ae0 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/AbstractImageProvider.java +++ b/src/main/java/com/neuronrobotics/imageprovider/AbstractImageProvider.java @@ -41,7 +41,7 @@ public abstract class AbstractImageProvider extends NonBowlerDevice { @Override public void onAsyncResponse(BowlerDatagram data) { - // TODO Auto-generated method stub + // Auto-generated method stub } diff --git a/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java b/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java index 285f18ae..df8f74a9 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java +++ b/src/main/java/com/neuronrobotics/imageprovider/NativeResource.java @@ -40,7 +40,7 @@ private void inJarLoad(String name)throws UnsatisfiedLinkError, NativeResourceEx loadResource(resourceLocation); testNativeCode(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } diff --git a/src/main/java/com/neuronrobotics/imageprovider/StaticFileProvider.java b/src/main/java/com/neuronrobotics/imageprovider/StaticFileProvider.java index 9a59e90e..8de2ffc3 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/StaticFileProvider.java +++ b/src/main/java/com/neuronrobotics/imageprovider/StaticFileProvider.java @@ -27,19 +27,19 @@ protected boolean captureNewImage(BufferedImage imageData) { @Override public void disconnectDeviceImp() { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public boolean connectDeviceImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return false; } @Override public ArrayList getNamespacesImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } diff --git a/src/main/java/com/neuronrobotics/imageprovider/URLImageProvider.java b/src/main/java/com/neuronrobotics/imageprovider/URLImageProvider.java index c58ab148..b1c835c5 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/URLImageProvider.java +++ b/src/main/java/com/neuronrobotics/imageprovider/URLImageProvider.java @@ -29,19 +29,19 @@ protected boolean captureNewImage(BufferedImage imageData) { @Override public void disconnectDeviceImp() { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public boolean connectDeviceImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return false; } @Override public ArrayList getNamespacesImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return null; } diff --git a/src/main/java/com/neuronrobotics/imageprovider/VirtualCameraFactory.java b/src/main/java/com/neuronrobotics/imageprovider/VirtualCameraFactory.java index df52cef3..fda1614d 100644 --- a/src/main/java/com/neuronrobotics/imageprovider/VirtualCameraFactory.java +++ b/src/main/java/com/neuronrobotics/imageprovider/VirtualCameraFactory.java @@ -8,11 +8,11 @@ public class VirtualCameraFactory { @Override public AbstractImageProvider getVirtualCamera() { - // TODO Auto-generated method stub + // Auto-generated method stub try { return new URLImageProvider(new URL("http://commonwealthrobotics.com/img/AndrewHarrington/2014-09-15-86.jpg")); } catch (MalformedURLException e) { - // TODO Auto-generated catch block + // Auto-generated catch block throw new RuntimeException(e); } } diff --git a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java index 9045c4cc..3b0c5872 100644 --- a/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java +++ b/src/main/java/com/neuronrobotics/sdk/addons/gamepad/BowlerJInputDevice.java @@ -17,7 +17,7 @@ import eu.mihosoft.vrl.v3d.JavaFXInitializer; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The Class BowlerJInputDevice. */ @@ -154,7 +154,7 @@ public void run() { try { Thread.sleep(1000); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -277,7 +277,7 @@ public void addListeners(IGameControlEvent l) { */ @Override public ArrayList getNamespacesImp() { - // TODO Auto-generated method stub + // Auto-generated method stub return new ArrayList(); } diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java index a2fb4fc4..452fa9ff 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/CoreScheduler.java @@ -19,7 +19,7 @@ import com.neuronrobotics.sdk.dyio.DyIO; import com.neuronrobotics.sdk.dyio.peripherals.ServoChannel; import com.neuronrobotics.sdk.util.ThreadUtil; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The Class CoreScheduler. @@ -482,7 +482,7 @@ public void run(){ try { Thread.sleep(10); } catch (InterruptedException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ISchedulerListener.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ISchedulerListener.java index 2e0bf7a5..ad8d642e 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ISchedulerListener.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ISchedulerListener.java @@ -1,6 +1,6 @@ package com.neuronrobotics.sdk.dyio.sequencer; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The listener interface for receiving IScheduler events. * The class that is interested in processing a IScheduler diff --git a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java index d6179bd3..6e3cd30d 100644 --- a/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java +++ b/src/main/java/com/neuronrobotics/sdk/dyio/sequencer/ServoOutputScheduleChannel.java @@ -7,7 +7,7 @@ import com.neuronrobotics.sdk.dyio.peripherals.IServoPositionUpdateListener; import com.neuronrobotics.sdk.dyio.peripherals.ServoChannel; -// TODO: Auto-generated Javadoc +// Auto-generated Javadoc /** * The Class ServoOutputScheduleChannel. */ @@ -520,7 +520,7 @@ public void kill() { */ @Override public void onReset() { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -529,7 +529,7 @@ public void onReset() { */ @Override public void onPlay() { - // TODO Auto-generated method stub + // Auto-generated method stub } @@ -538,7 +538,7 @@ public void onPlay() { */ @Override public void onPause() { - // TODO Auto-generated method stub + // Auto-generated method stub } diff --git a/test/java/src/junit/bowler/MobileBaseLoading.java b/test/java/src/junit/bowler/MobileBaseLoading.java index 5f671dbe..da933afd 100644 --- a/test/java/src/junit/bowler/MobileBaseLoading.java +++ b/test/java/src/junit/bowler/MobileBaseLoading.java @@ -55,7 +55,7 @@ public void setSelectedCsg(Collection collection) { @Override public void progressUpdate(int currentIndex, int finalIndex, String type, CSG intermediateShape) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); diff --git a/test/java/src/junit/bowler/TTSTest.java b/test/java/src/junit/bowler/TTSTest.java index 3cae596e..0dcfd42b 100644 --- a/test/java/src/junit/bowler/TTSTest.java +++ b/test/java/src/junit/bowler/TTSTest.java @@ -20,7 +20,7 @@ public void TTSText() { @Override public void update(double percentage, AudioStatus status) { - // TODO Auto-generated method stub + // Auto-generated method stub com.neuronrobotics.sdk.common.Log.error(percentage+" "+status.toString()); } }; diff --git a/test/java/src/junit/bowler/TestCheckout.java b/test/java/src/junit/bowler/TestCheckout.java index b84b4032..5279fb1d 100644 --- a/test/java/src/junit/bowler/TestCheckout.java +++ b/test/java/src/junit/bowler/TestCheckout.java @@ -32,7 +32,7 @@ public void test() throws IOException, GitAPIException { assertTrue("Changing from "+was+" to "+myName+" got "+s,myName.contains(s)); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); fail(); } diff --git a/test/java/src/junit/bowler/WekaTester.java b/test/java/src/junit/bowler/WekaTester.java index 8a8e1d38..86b42f7c 100644 --- a/test/java/src/junit/bowler/WekaTester.java +++ b/test/java/src/junit/bowler/WekaTester.java @@ -8,7 +8,7 @@ public class WekaTester { @Test public void test() { - //TODO + } } From e5bf24add83b69b78d430b415c83de5bf63ed3d6 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 11:40:04 -0500 Subject: [PATCH 267/635] prevent the database files from accumulation unneeded data --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e6a63ec3..6e8e8524 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -115,6 +115,7 @@ public void initialize() { initializing = true; if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); + CSGDatabase.clear(); CSGDatabase.setDbFile(db); StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); From 6ebd21b19393ef9c2b50c71332131c057ae97d29 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 12:07:14 -0500 Subject: [PATCH 268/635] Pruning the random name factory --- .../bowlerstudio/scripting/ScriptingEngine.java | 2 +- .../scripting/cadoodle/RandomStringFactory.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 86e82244..1904b2db 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -1092,7 +1092,7 @@ public static String[] codeFromGit(String id, String FileName) throws Exception return new String[] { text, FileName, targetFile.getAbsolutePath() }; } - return null; + throw new RuntimeException("File missing! "+targetFile.getAbsolutePath()); } private static String[] codeFromGistID(String id, String FileName) throws Exception { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java index bae1e6da..5c3d03e0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/RandomStringFactory.java @@ -22,34 +22,34 @@ public class RandomStringFactory { "Snappy", "Peppy", "Effulgent", "Radiant", "Luminous", "Beaming", "Glowing", "Incandescent", "Resplendent", "Lustrous", "Glistening", "Scintillating", "Efflorescent", "Blooming", "Flourishing", - "Thriving", "Burgeoning", "Prolific", "Fecund", "Teeming", + "Thriving", "Burgeoning", "Prolific", "Teeming", "Abundant", "Plentiful", "Bountiful", "Copious", "Profuse", "Exuberant", "Luxuriant", "Lush", "Verdant", "Fertile", "Productive", "Fruitful", "Generative", "Creative", "Imaginative", "Inventive", "Ingenious", "Clever", "Brilliant", "Dazzling", "Bright", "Luminous", "Radiant", "Gleaming", "Glittering", "Sparkling", "Twinkling", "Shimmering", "Glowing", "Beaming", - "Effulgent", "Refulgent", "Resplendent", "Splendid", "Magnificent", + "Effulgent", "Resplendent", "Splendid", "Magnificent", "Majestic", "Grand", "Glorious", "Superb", "Marvelous", "Wonderful", "Fantastic", "Fabulous", "Astounding", "Amazing" }; public static String[] creaturesMachines = { "Dragon", "Robot", "Unicorn", "Cyborg", "Griffin", - "Automaton", "Phoenix", "Mech", "Kraken", "Droid", + "Automaton", "Phoenix", "Mech", "Kraken", "Chimera", "Golem", "Pegasus", "Android", "Hydra", "Centaur", "Drone", "Sphinx", "Exosuit", "Minotaur", "Cyclops", "Hologram", "Werewolf", "Nanobot", "Gorgon", "Replicant", "Banshee", "Hovercraft", "Basilisk", "Jetpack", - "Gargoyle", "Teleporter", "Manticore", "Forcefield", + "Gargoyle", "Teleporter", "Forcefield", "Submarine", "Cerberus", "Hoverboard", "Siren", "Skycycle", "Yeti", "Hoverbike", "Sasquatch", "Hyperloop", "Thunderbird", "Gyrocopter", "Leviathan", "Airship", "Behemoth", "Starship", "Colossus", "Monowheel", "Titan", "Rocketship", "Gremlin", "Hovercar", "Imp", "Zeppelin", "Ogre", "Monorail", - "Troll", "Bathyscaphe", "Gnome", "Segway", "Leprechaun", + "Troll", "Gnome", "Leprechaun", "Hyperpod", "Fairy", "Gyrocar", "Elf", "Ornithopter", - "Wraith", "Hoversuit", "Specter", "Levitator", "Phantom", + "Hoversuit", "Specter", "Levitator", "Phantom", "Telekinetic", "Goblin", "Gravicycle", "Dwarf", "Jetbike", "Hobgoblin", "Ekranoplan", "Aerotrain", "Sprite", "Maglev", "Aerosled", From 3b6cd4e9364e198de4e70aee72a20089c7be80cd Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 16:15:46 -0500 Subject: [PATCH 269/635] Use SVG loader to load all elements instead of flattening the layer into one CSG --- .../com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index 0be6cc60..86c836b0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -52,9 +52,9 @@ private Object run(SVGLoad s) { String layerName=layers.get(i); if(layerName==null) layerName="TopLayer"; - CSG extrudeLayerToCSG = s.extrudeLayerToCSG(depth,layerName); + ArrayList extrudeLayerToCSG = s.extrudeLayer(depth,layerName); //extrudeLayerToCSG.setColor(Color.web(SVGExporter.colorNames.get(i))); - polys.add(extrudeLayerToCSG); + polys.addAll(extrudeLayerToCSG); depth-=5; } From eacbe79e8702d3f3f1ae4db418fa5648d157888f Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 16:17:12 -0500 Subject: [PATCH 270/635] Add the transform on add back to apply it to all elements of an SVG when loaded. This works even when the number of items returned from an SVG load change --- .../scripting/cadoodle/AddFromFile.java | 27 +++++----- .../scripting/cadoodle/AddFromScript.java | 52 ++++++++----------- 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 88d0baff..711d5469 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -26,8 +26,8 @@ import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { -// @Expose(serialize = true, deserialize = true) -// private TransformNR location = null; + @Expose(serialize = true, deserialize = true) + private TransformNR location = null; private ArrayList options = new ArrayList(); private StringParameter parameter = null; @Expose(serialize = true, deserialize = true) @@ -155,7 +155,7 @@ private String getStrValue() { } private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { - Transform nrToCSG = new Transform();//TransformFactory.nrToCSG(getLocation()); + Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() @@ -174,19 +174,20 @@ private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) } return previous; }).setName(name); + MoveCenter.set(getName(), processedCSG, nrToCSG); return processedCSG; } -// public TransformNR getLocation() { -// if (location == null) -// location = new TransformNR(); -// return location; -// } -// -// public AddFromFile setLocation(TransformNR location) { -// this.location = location; -// return this; -// } + public TransformNR getLocation() { + if (location == null) + location = new TransformNR(); + return location; + } + + public AddFromFile setLocation(TransformNR location) { + this.location = location; + return this; + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index a701e86b..9242e2f9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -29,8 +29,8 @@ public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperatio @Expose(serialize = true, deserialize = true) private String fileRel = ""; -// @Expose(serialize = true, deserialize = true) -// private TransformNR location =null; + @Expose(serialize = true, deserialize = true) + private TransformNR location =null; @Expose(serialize = true, deserialize = true) private Boolean preventBoM = false; @@ -66,29 +66,18 @@ public List process(List incoming, String fileName) { List flaten = ScriptingEngine.flaten(gitULR, fileName, CSG.class, args); ArrayList collect = new ArrayList<>(); collect.addAll(flaten); -// for(int i=0;i0?("_"+i):"")); -// collect.set(i, tmp); -// namesAdded.add(tmp.getName()); -// System.out.println("AddFromScript: "+fileRel+" "+tmp.getName()); -// new RuntimeException().printStackTrace(); -// } - for (int i = 0; i < collect.size(); i++) { - CSG csg = collect.get(i); - CSG tmp = csg.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(getOrderedName()); + for(int i=0;i process(List incoming, String fileName) { e2.printStackTrace(); } } + throw new RuntimeException(e); } if (back.size() == 0) @@ -105,16 +95,16 @@ public List process(List incoming, String fileName) { return back; } -// public TransformNR getLocation() { -// if(location==null) -// location=new TransformNR(); -// return location; -// } + public TransformNR getLocation() { + if(location==null) + location=new TransformNR(); + return location; + } -// public AddFromScript setLocation(TransformNR location) { -// this.location = location; -// return this; -// } + public AddFromScript setLocation(TransformNR location) { + this.location = location; + return this; + } @Override public File getFile() { From 1435665b2ec8ce34e8085acf0a39ea88b2ebe331 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 16:49:46 -0500 Subject: [PATCH 271/635] updating the SVG loading to add hole information --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 15cdff5b..b9a1b03e 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.0.7' + api 'com.neuronrobotics:JavaCad:2.1.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ea8ff17233ebce27b5caca0479ebfef2a6c2d86a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Fri, 27 Dec 2024 18:09:18 -0500 Subject: [PATCH 272/635] add the parameters to each object of a file load --- .../scripting/cadoodle/AddFromFile.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 711d5469..eb3165d9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -29,12 +29,11 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation @Expose(serialize = true, deserialize = true) private TransformNR location = null; private ArrayList options = new ArrayList(); - private StringParameter parameter = null; @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; public AddFromFile set(File source) { String absolutePath = toLocal(source).getAbsolutePath(); - getParameter(absolutePath).setStrValue(absolutePath); + getFileParameter().setStrValue(absolutePath); CSGDatabase.saveDatabase(); return this; } @@ -57,8 +56,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); - String pathname = file.getAbsolutePath(); - getParameter(pathname).setStrValue(pathname); + ArrayListargs = new ArrayList<>(); args.addAll(Arrays.asList(name )); HashMap configs =new HashMap(); @@ -66,11 +64,10 @@ public List process(List incoming) { configs.put("PreventBomAdd", preventBoM); args.add(configs); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); - com.neuronrobotics.sdk.common.Log.error("Initial Loading " + getStrValue()); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); try { - CSG processedCSG = processGiven(csg, i,parameter, getOrderedName()); + CSG processedCSG = processGiven(csg, i, getOrderedName()); collect.add(processedCSG); }catch(Exception ex) { ex.printStackTrace(); @@ -138,24 +135,32 @@ private File toLocal(File file) { } } file = new File(source + DownloadManager.delim() + file.getName()); - getParameter(file.getAbsolutePath()).setStrValue(file.getAbsolutePath()); return file; } public File getFile() { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFile = new File(loc.getStrValue()).getParentFile(); - File file = new File(getStrValue()); + StringParameter stringParameter = getFileParameter(); + File file = new File(stringParameter.getStrValue()); String pathname = parentFile.getAbsolutePath()+DownloadManager.delim()+file.getName(); return new File(pathname); } - - private String getStrValue() { - - return getParameter("UnKnown").getStrValue(); +// +// private String getStrValue() { +// +// return getParameter("UnKnown").getStrValue(); +// } + + private StringParameter getFileParameter() { + return new StringParameter(getName() + "_CaDoodle_File", "NotSet", options); } - private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) { + private CSG processGiven(CSG csg, int i, String name) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); + String pathname = getFile().getAbsolutePath(); + + StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); + parameter.setStrValue(pathname); CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() @@ -168,7 +173,7 @@ private CSG processGiven(CSG csg, int i, StringParameter parameter, String name) com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); - return processGiven(csg1, i, parameter, name); + return processGiven(csg1, i, name); } catch (Exception e) { e.printStackTrace(); } @@ -191,15 +196,6 @@ public AddFromFile setLocation(TransformNR location) { - public StringParameter getParameter(String defaultVal) { - if (parameter == null) - setParameter(new StringParameter(getName() + "_CaDoodle_File", defaultVal, options)); - return parameter; - } - - public void setParameter(StringParameter parameter) { - this.parameter = parameter; - } public Boolean getPreventBoM() { return preventBoM; } From 95a21ea72ea5b994f064573fb8f5e6f318b2383a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 28 Dec 2024 10:31:34 -0500 Subject: [PATCH 273/635] Add anotation --- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 6cc310e0..59970827 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -265,7 +265,7 @@ private static void startOutputReader(final InputStream is, final String type, P } }).start(); } - + @SuppressWarnings("unchecked") public static Map getEnvironment(String exeType) { String key = discoverKey(); From 964adb540a06400a44f765e68aca6f8e4ee6bb10 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 28 Dec 2024 15:54:32 -0500 Subject: [PATCH 274/635] stable hole colors --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b9a1b03e..8fa14070 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.1.0' + api 'com.neuronrobotics:JavaCad:2.1.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From cf00047fc787658174564d016666351e31f78ddb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 31 Dec 2024 11:51:36 -0500 Subject: [PATCH 275/635] https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/36 --- .../com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 95aae5a8..9d43c081 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -116,7 +116,8 @@ public void handle(MouseEvent event) { String name = event.getEventType().getName(); switch (name) { case "MOUSE_PRESSED": - pressed(event); + if(event.isPrimaryButtonDown()) + pressed(event); break; case "MOUSE_DRAGGED": dragged(event,event); From 75ca91e3c63a1c030c5ed69306b1f1b762cd3ecb Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Tue, 31 Dec 2024 17:01:12 -0500 Subject: [PATCH 276/635] get rid of the redundant parametric --- .../scripting/cadoodle/AddFromFile.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index eb3165d9..024542a2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -32,9 +32,7 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; public AddFromFile set(File source) { - String absolutePath = toLocal(source).getAbsolutePath(); - getFileParameter().setStrValue(absolutePath); - CSGDatabase.saveDatabase(); + toLocal(source); return this; } @@ -56,6 +54,9 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); + if(!file.exists()) { + throw new RuntimeException("Failed to find file"); + } ArrayListargs = new ArrayList<>(); args.addAll(Arrays.asList(name )); @@ -140,10 +141,13 @@ private File toLocal(File file) { public File getFile() { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFile = new File(loc.getStrValue()).getParentFile(); - StringParameter stringParameter = getFileParameter(); - File file = new File(stringParameter.getStrValue()); - String pathname = parentFile.getAbsolutePath()+DownloadManager.delim()+file.getName(); - return new File(pathname); + for(String f:parentFile.list()) { + if(f.contains(name)) { + String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; + return new File(pathname); + } + } + throw new RuntimeException("File not found! "+name); } // // private String getStrValue() { @@ -151,10 +155,6 @@ public File getFile() { // return getParameter("UnKnown").getStrValue(); // } - private StringParameter getFileParameter() { - return new StringParameter(getName() + "_CaDoodle_File", "NotSet", options); - } - private CSG processGiven(CSG csg, int i, String name) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); String pathname = getFile().getAbsolutePath(); From 4dd3ca220ddbe665ff805f3043a1d177de8448c9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 6 Jan 2025 10:39:49 -0500 Subject: [PATCH 277/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 552527ae..21878fc4 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 552527ae7998f0e167db69b28e814ee9734e8a11 +Subproject commit 21878fc49db49bd58474a3062a9d372d1f835c3b From bd4f81660209c197d06569ae7241d395632d583c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 7 Jan 2025 13:49:07 -0500 Subject: [PATCH 278/635] DO not copy the objects --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6e8e8524..be105450 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -403,8 +403,9 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { throw new RuntimeException( "There can not be 2 objects with the same name after an opperation! " + c.getName()); names.add(c.getName()); - cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) - .setRegenerate(c.getRegenerate())); +// cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) +// .setRegenerate(c.getRegenerate())); + cachedCopy.add(c); } cache.put(op, cachedCopy); } From b92e54396330383a23bb717fa4c46fad2ef3f4e0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 14:00:42 -0500 Subject: [PATCH 279/635] Forcing the Git objects to be life-cycled by the ScriptingEngine --- .../bowlerstudio/scripting/IGitAccessor.java | 7 + .../scripting/ScriptingEngine.java | 684 +++++++++--------- 2 files changed, 329 insertions(+), 362 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/IGitAccessor.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IGitAccessor.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IGitAccessor.java new file mode 100644 index 00000000..12af69b5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IGitAccessor.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting; + +import org.eclipse.jgit.api.Git; + +public interface IGitAccessor { + public void run(Git git) throws Exception; +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 1904b2db..505e9328 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -177,7 +177,7 @@ public static List flaten(File f, Class type, ArrayList args) private static String delim; - private static String appName="BowlerLauncher"; + private static String appName = "BowlerLauncher"; static { PasswordManager.hasNetwork(); @@ -238,7 +238,7 @@ public static void clearLogListener() { logListeners.clear(); } - private static Git cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean useSSH) + private static void cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean useSSH, IGitAccessor accessor) throws InvalidRemoteException, TransportException, GitAPIException { CloneCommand setURI = Git.cloneRepository().setURI(remoteURI); @@ -253,11 +253,17 @@ private static Git cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean Git git = setURI.call(); gitOpenTimeout.put(git, makeTimeoutThread(git)); - return git; + try { + accessor.run(git); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + gitclose(git); } /** - * CLoe git and start a timeout timer + * Clone git and start a timeout timer * * @param remoteURI * @param branch @@ -267,21 +273,22 @@ private static Git cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean * @throws TransportException * @throws GitAPIException */ - private static Git cloneRepoLocal(String remoteURI, File dir) + private static void cloneRepoLocal(String remoteURI, File dir, IGitAccessor accessor) throws InvalidRemoteException, TransportException, GitAPIException { boolean startsWith = remoteURI.startsWith("git@"); - try { - return cloneRepoLocalSelectAuth(remoteURI, dir, startsWith); + cloneRepoLocalSelectAuth(remoteURI, dir, startsWith, accessor); } catch (org.eclipse.jgit.api.errors.JGitInternalException ex) { if (ex.getMessage().contains("already exists and is not an empty directory")) { deleteRepo(remoteURI); - return cloneRepoLocal(remoteURI, dir); + cloneRepoLocal(remoteURI, dir, accessor); + return; } throw ex; } catch (org.eclipse.jgit.api.errors.TransportException ex) { if (ex.getMessage().contains("Auth fail") && !startsWith) { - return cloneRepoLocalSelectAuth(remoteURI, dir, true); + cloneRepoLocalSelectAuth(remoteURI, dir, true, accessor); + return; } throw ex; } @@ -353,7 +360,8 @@ public void endTask() { @Override public void beginTask(String title, int totalWork) { stage = title; - // com.neuronrobotics.sdk.common.Log.error("Setting totalWork to "+totalWork+" for stage "+stage); + // com.neuronrobotics.sdk.common.Log.error("Setting totalWork to "+totalWork+" + // for stage "+stage); total = totalWork; sum = 0; tasks += 1; @@ -368,11 +376,11 @@ public void beginTask(String title, int totalWork) { * @param url * @return */ - public static Git openGit(String url) { + public static void openGit(String url, IGitAccessor accessor) { Repository localRepo; try { localRepo = getRepository(url); - return openGit(localRepo); + openGit(localRepo, accessor); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -405,7 +413,8 @@ public static boolean isUrlAlreadyOpen(String URL) { * @return */ - public static Git openGit(Repository localRepo) { + public static void openGit(Repository localRepo, IGitAccessor accessor) { + Git git = null; try { Object[] keySet; @@ -437,14 +446,24 @@ public static Git openGit(Repository localRepo) { } } - Git git = new Git(localRepo); + git = new Git(localRepo); gitOpenTimeout.put(git, makeTimeoutThread(git)); - return git; + if (accessor != null) { + try { + accessor.run(git); + } catch (Throwable t) { + new IssueReportingExceptionHandler().except(t); + throw new RuntimeException(t); + } + } + gitclose(git); } catch (Throwable t) { new IssueReportingExceptionHandler().except(t); + if (git != null) { + gitclose(git); + } throw new RuntimeException(t); - } } @@ -453,7 +472,7 @@ public static Git openGit(Repository localRepo) { * * @param git */ - public static void closeGit(Git git) { + private static void gitclose(Git git) { if (git == null) return; if (gitOpenTimeout.containsKey(git)) { @@ -559,38 +578,40 @@ public static void removeIGithubLoginListener(IGithubLoginListener l) { public static File getWorkspace() { if (workspace == null) { File relative = getWorkingDirectory(); - File file = new File(relative.getAbsolutePath() + delim+ "bowler-workspace"+delim); + File file = new File(relative.getAbsolutePath() + delim + "bowler-workspace" + delim); file.mkdirs(); setWorkspace(file); } return workspace; } - public static void createSymlinkInDocuments(File appDataDir) throws IOException { - String userHome = System.getProperty("user.home"); - Path documentsDir = Paths.get(userHome, "Documents"); - Path symlinkPath = documentsDir.resolve(appDataDir.getName()); - - // Delete existing symlink if it exists - if (Files.exists(symlinkPath)) { - return; - } - - // Create the symlink - Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); - com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); - } + + public static void createSymlinkInDocuments(File appDataDir) throws IOException { + String userHome = System.getProperty("user.home"); + Path documentsDir = Paths.get(userHome, "Documents"); + Path symlinkPath = documentsDir.resolve(appDataDir.getName()); + + // Delete existing symlink if it exists + if (Files.exists(symlinkPath)) { + return; + } + + // Create the symlink + Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); + com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); + } + public static File getWorkingDirectory() { String relative = Paths.get(System.getProperty("user.home"), "Documents").toString(); - if(OSUtil.isOSX()) { + if (OSUtil.isOSX()) { File appDataDir = new File(System.getProperty("user.home") + "/Library/Application Support/" + appName); - - if (!appDataDir.exists()) { - if (!appDataDir.mkdirs()) { - throw new RuntimeException("Failed to create app data directory"); - } - } - relative=appDataDir.getAbsolutePath(); - try { + + if (!appDataDir.exists()) { + if (!appDataDir.mkdirs()) { + throw new RuntimeException("Failed to create app data directory"); + } + } + relative = appDataDir.getAbsolutePath(); + try { createSymlinkInDocuments(appDataDir); } catch (IOException e) { // Auto-generated catch block @@ -600,12 +621,12 @@ public static File getWorkingDirectory() { delim = "/"; if (OSUtil.isLinux()) if (!relative.endsWith("Documents")) { - relative = relative+ delim+ "Documents"; + relative = relative + delim + "Documents"; } if (OSUtil.isWindows()) { - delim="\\"; + delim = "\\"; if (!relative.endsWith("Documents")) { - relative = relative +delim+ "Documents"; + relative = relative + delim + "Documents"; } } File file = new File(relative + delim); @@ -761,7 +782,8 @@ public static void waitForRepo(String remoteURI, String reason) { GitTimeoutThread t = gitOpenTimeout.get(g); if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) { - com.neuronrobotics.sdk.common.Log.error("\n\n\nPaused " + reason + " by another thread, waiting for repo " + remoteURI); + com.neuronrobotics.sdk.common.Log + .error("\n\n\nPaused " + reason + " by another thread, waiting for repo " + remoteURI); new Exception().printStackTrace(System.err); com.neuronrobotics.sdk.common.Log.error("Paused by:"); t.getException().printStackTrace(System.err); @@ -926,11 +948,13 @@ private static boolean ensureExistance(File desired) throws IOException { public static void commit(String id, String branch, String FileName, String content, String commitMessage, boolean flagNewFile) throws Exception { - commit(id, branch, FileName, content, commitMessage, flagNewFile, null); + openGit(id, git -> { + commit(id, branch, FileName, content, commitMessage, flagNewFile, git); + }); } @SuppressWarnings("deprecation") - public static void commit(String id, String branch, String FileName, String content, String commitMessage, + private static void commit(String id, String branch, String FileName, String content, String commitMessage, boolean flagNewFile, Git gitRef) throws Exception { if (content != null) if ("Binary File".contentEquals(content)) { @@ -951,13 +975,11 @@ public static void commit(String id, String branch, String FileName, String cont Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile()); Git git = gitRef; if (git == null) - git = openGit(localRepo); + throw new RuntimeException("Fail! Git must exist before commiting"); try { // latest version if (flagNewFile) { git.add().addFilepattern(FileName).call(); } - if (gitRef == null) - closeGit(git); if (content != null) { OutputStream out = null; try { @@ -973,13 +995,8 @@ public static void commit(String id, String branch, String FileName, String cont commit(id, branch, commitMessage, gitRef); } catch (Exception ex) { - if (gitRef == null) - closeGit(git); - throw ex; } - if (gitRef == null) - closeGit(git); try { if (!desired.getName().contentEquals("csgDatabase.json")) { String[] gitID = ScriptingEngine.findGitTagFromFile(desired, gitRef); @@ -994,7 +1011,7 @@ public static void commit(String id, String branch, String FileName, String cont CSGDatabase.saveDatabase(); @SuppressWarnings("resource") String c = new Scanner(dbFile).useDelimiter("\\Z").next(); - ScriptingEngine.commit(remoteURI, branch, s, c, "saving CSG database", false, gitRef); + commit(remoteURI, branch, s, c, "saving CSG database", false, gitRef); } } } @@ -1038,40 +1055,40 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam File gitRepoFile = new File(localPath + "/.git"); Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile()); - Git git = null; + // Git git = null; try { try { pull(remoteURI, branch); } catch (java.lang.RuntimeException exp) { } - git = openGit(localRepo); - // latest version - if (flagNewFile) { - git.add().addFilepattern(FileName).call(); - } - if (content != null) { - OutputStream out = null; - try { - out = FileUtils.openOutputStream(desired, false); - IOUtils.write(content, out); - out.close(); // don't swallow close Exception if copy - // completes - // normally - } finally { - IOUtils.closeQuietly(out); + String c = content; + openGit(localRepo, git -> { + // latest version + if (flagNewFile) { + git.add().addFilepattern(FileName).call(); } - } - if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) - git.push().setTransportConfigCallback(transportConfigCallback) - .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); - else - git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) - .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); - closeGit(git); + if (c != null) { + OutputStream out = null; + try { + out = FileUtils.openOutputStream(desired, false); + IOUtils.write(c, out, Charset.defaultCharset()); + out.close(); // don't swallow close Exception if copy + // completes + // normally + } finally { + IOUtils.closeQuietly(out); + } + } + if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) + git.push().setTransportConfigCallback(transportConfigCallback) + .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); + else + git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) + .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); + }); System.out.println("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); } catch (Exception ex) { ex.printStackTrace(); - closeGit(git); String[] gitID = ScriptingEngine.findGitTagFromFile(desired); String id = gitID[0]; @@ -1092,7 +1109,7 @@ public static String[] codeFromGit(String id, String FileName) throws Exception return new String[] { text, FileName, targetFile.getAbsolutePath() }; } - throw new RuntimeException("File missing! "+targetFile.getAbsolutePath()); + throw new RuntimeException("File missing! " + targetFile.getAbsolutePath()); } private static String[] codeFromGistID(String id, String FileName) throws Exception { @@ -1213,31 +1230,31 @@ public static void deleteBranch(String remoteURI, String toDelete) throws Except // CheckoutCommand checkout; // String source = getFullBranch(remoteURI); - Git git; + openGit(localRepo, git -> { + String d = toDelete; + if (!toDelete.contains("heads")) { + d = "heads/" + d; + } + if (!toDelete.contains("refs")) { + d = "refs/" + d; + } + Exception ex = null; + try { + // delete branch 'branchToDelete' locally + git.branchDelete().setBranchNames(d).call(); - git = openGit(localRepo); - if (!toDelete.contains("heads")) { - toDelete = "heads/" + toDelete; - } - if (!toDelete.contains("refs")) { - toDelete = "refs/" + toDelete; - } - Exception ex = null; - try { - // delete branch 'branchToDelete' locally - git.branchDelete().setBranchNames(toDelete).call(); + // delete branch 'branchToDelete' on remote 'origin' + RefSpec refSpec = new RefSpec().setSource(null).setDestination(d); + git.push().setRefSpecs(refSpec).setRemote("origin") + .setCredentialsProvider(PasswordManager.getCredentialProvider()) + .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); + } catch (Exception e) { + ex = e; + } + if (ex != null) + throw ex; + }); - // delete branch 'branchToDelete' on remote 'origin' - RefSpec refSpec = new RefSpec().setSource(null).setDestination(toDelete); - git.push().setRefSpecs(refSpec).setRemote("origin") - .setCredentialsProvider(PasswordManager.getCredentialProvider()) - .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); - } catch (Exception e) { - ex = e; - } - closeGit(git); - if (ex != null) - throw ex; } public static String newBranch(String remoteURI, String newBranch) @@ -1253,41 +1270,32 @@ public static void newBranch(String remoteURI, String newBranch, RevCommit sourc waitForRepo(remoteURI, "newBranch"); Repository localRepo = getRepository(remoteURI); - Git git = null; try { for (String s : listBranchNames(remoteURI)) { if (s.contains(newBranch)) { // throw new RuntimeException(newBranch + " can not be created because " + s + " // is too similar"); - - git = openGit(localRepo); - shallowCheckout(remoteURI, newBranch, git); - closeGit(git); + openGit(localRepo, git -> { + shallowCheckout(remoteURI, newBranch, git); + }); return; } } } catch (Exception e) { e.printStackTrace(); - closeGit(git); } - git = openGit(localRepo); - try { + openGit(localRepo, git -> { try { - if (source == null) - source = git.log().setMaxCount(1).call().iterator().next(); - newBranchLocal(newBranch, remoteURI, git, source); + RevCommit s = source; + if (s == null) + s = git.log().setMaxCount(1).call().iterator().next(); + newBranchLocal(newBranch, remoteURI, git, s); } catch (NoHeadException ex) { newBranchLocal(newBranch, remoteURI, git, null); } - } catch (Throwable ex) { - closeGit(git); - throw ex; - } - - closeGit(git); - + }); } private static void newBranchLocal(String newBranch, String remoteURI, Git git, RevCommit source) @@ -1355,18 +1363,21 @@ public static List listBranches(String remoteURI) throws Exception { Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile()); // https://gist.github.com/0e6454891a3b3f7c8f28.git - List Ret; - Git git = openGit(localRepo); - Ret = listBranches(remoteURI, git); - closeGit(git); - return Ret; + ArrayList back = new ArrayList(); + openGit(localRepo, git -> { + List Ret = listBranches(remoteURI, git); + back.addAll(Ret); + }); + return back; } public static List listBranches(String remoteURI, Git git) throws Exception { // https://gist.github.com/0e6454891a3b3f7c8f28.git - // com.neuronrobotics.sdk.common.Log.error("Listing references from: "+remoteURI); - // com.neuronrobotics.sdk.common.Log.error(" branch: "+getFullBranch(remoteURI)); + // com.neuronrobotics.sdk.common.Log.error("Listing references from: + // "+remoteURI); + // com.neuronrobotics.sdk.common.Log.error(" branch: + // "+getFullBranch(remoteURI)); List list = git.branchList().setListMode(ListMode.ALL).call(); // com.neuronrobotics.sdk.common.Log.error(" size : "+list.size()); return list; @@ -1381,16 +1392,12 @@ public static List listLocalBranches(String remoteURI) throws IOException { Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile()); // https://gist.github.com/0e6454891a3b3f7c8f28.git - Git git = openGit(localRepo); - try { + ArrayList back = new ArrayList(); + openGit(localRepo, git -> { List list = git.branchList().call(); - closeGit(git); - return list; - } catch (Exception ex) { - - } - closeGit(git); - return new ArrayList<>(); + back.addAll(list); + }); + return back; } public static List listLocalBranchNames(String remoteURI) throws Exception { @@ -1398,7 +1405,8 @@ public static List listLocalBranchNames(String remoteURI) throws Excepti List list = listLocalBranches(remoteURI); for (Ref ref : list) { - // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + ref.getName() + " " + + // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + + // ref.getName() + " " + // ref.getObjectId().getName()); branchNames.add(ref.getName()); } @@ -1410,7 +1418,8 @@ public static List listBranchNames(String remoteURI) throws Exception { List list = listBranches(remoteURI); for (Ref ref : list) { - // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + ref.getName() + " " + + // com.neuronrobotics.sdk.common.Log.error("Branch: " + ref + " " + + // ref.getName() + " " + // ref.getObjectId().getName()); branchNames.add(ref.getName()); } @@ -1430,8 +1439,7 @@ public static void pull(String remoteURI, String branch) throws IOException, Che } Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile()); - Git git = openGit(localRepo); - try { + openGit(localRepo, git -> { String ref = git.getRepository().getConfig().getString("remote", "origin", "url"); try { @@ -1453,64 +1461,57 @@ public static void pull(String remoteURI, String branch) throws IOException, Che throw ex; } - closeGit(git); - // new Exception(ref).printStackTrace(); } catch (CheckoutConflictException ex) { -// closeGit(git); -// resolveConflict(remoteURI, ex, git); -// pull(remoteURI, branch); - closeGit(git); + PasswordManager.checkInternet(); throw ex; } catch (WrongRepositoryStateException e) { e.printStackTrace(); - closeGit(git); + PasswordManager.checkInternet(); // deleteRepo(remoteURI); throw e; } catch (InvalidConfigurationException e) { PasswordManager.checkInternet(); - closeGit(git); + throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } catch (DetachedHeadException e) { PasswordManager.checkInternet(); - closeGit(git); + throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } catch (InvalidRemoteException e) { PasswordManager.checkInternet(); - closeGit(git); + throw new InvalidRemoteException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } catch (CanceledException e) { PasswordManager.checkInternet(); - closeGit(git); + throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } catch (RefNotFoundException e) { PasswordManager.checkInternet(); - closeGit(git); + throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } catch (RefNotAdvertisedException e) { PasswordManager.checkInternet(); - closeGit(git); + try { if (branch != null) newBranch(remoteURI, branch); else { - git = openGit(remoteURI); - RevCommit source = git.log().setMaxCount(1).call().iterator().next(); + openGit(remoteURI, g -> { + RevCommit source = g.log().setMaxCount(1).call().iterator().next(); - newBranchLocal("main", remoteURI, git, source); - closeGit(git); + newBranchLocal("main", remoteURI, g, source); + }); } } catch (Exception ex) { - closeGit(git); ex.printStackTrace(); throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + ex.getMessage()); } } catch (NoHeadException e) { PasswordManager.checkInternet(); - closeGit(git); throw e; // try { // closeGit(git); @@ -1528,30 +1529,20 @@ public static void pull(String remoteURI, String branch) throws IOException, Che try { git.pull().setTransportConfigCallback(transportConfigCallback) .setProgressMonitor(getProgressMoniter("Pull ", remoteURI)).call(); - closeGit(git); } catch (Exception ex) { - closeGit(git); throw new RuntimeException( "remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } } else { - closeGit(git); throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } } catch (GitAPIException e) { e.printStackTrace(); PasswordManager.checkInternet(); - closeGit(git); throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } - } catch (InvalidRemoteException e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new InvalidRemoteException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); - } catch (Throwable t) { - closeGit(git); - } + }); } @@ -1571,17 +1562,10 @@ public static void checkoutCommit(String remoteURI, String branch, String commit throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } Repository localRepo = new FileRepository(gitRepoFile); - Git git = openGit(localRepo); - try { + openGit(localRepo, git -> { git.checkout().setName(commitHash).call(); git.checkout().setCreateBranch(true).setName(branch).setStartPoint(commitHash).call(); - - } catch (Exception ex) { - ex.printStackTrace(); - } - - closeGit(git); - + }); } public static void checkout(String remoteURI, RevCommit commit) @@ -1620,56 +1604,48 @@ public static void checkout(String remoteURI, String branch) if (currentBranch.length() < branch.length() || !currentBranch.endsWith(branch)) { com.neuronrobotics.sdk.common.Log.error("Current branch is " + currentBranch + " need " + branch); - Git git = null; try { Collection branches = getAllBranches(remoteURI); - git = openGit(localRepo); - for (Ref R : branches) { - if (R.getName().endsWith(branch)) { - com.neuronrobotics.sdk.common.Log.error("\nFound upstream " + R.getName()); - shallowCheckout(remoteURI, branch, git); - closeGit(git); + String br = branch; + openGit(localRepo, git -> { + for (Ref R : branches) { + if (R.getName().endsWith(br)) { + com.neuronrobotics.sdk.common.Log.error("\nFound upstream " + R.getName()); + shallowCheckout(remoteURI, br, git); + } } - } - // The ref does not exist upstream, create - try { - PasswordManager.checkInternet(); - closeGit(git); - newBranch(remoteURI, branch); - } catch (org.eclipse.jgit.api.errors.TransportException ex) { - // Not logged in yet, just return - PasswordManager.checkInternet(); - closeGit(git); - return; - } catch (RefAlreadyExistsException e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new RuntimeException(e); - } catch (RefNotFoundException e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new RuntimeException(e); - } catch (InvalidRefNameException e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new RuntimeException(e); - } catch (CheckoutConflictException e) { - resolveConflict(remoteURI, e, git); - } catch (GitAPIException e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new RuntimeException(e); - } catch (Exception e) { - PasswordManager.checkInternet(); - closeGit(git); - throw new RuntimeException(e); - } + // The ref does not exist upstream, create + try { + PasswordManager.checkInternet(); + newBranch(remoteURI, br); + } catch (org.eclipse.jgit.api.errors.TransportException ex) { + // Not logged in yet, just return + PasswordManager.checkInternet(); + return; + } catch (RefAlreadyExistsException e) { + PasswordManager.checkInternet(); + throw new RuntimeException(e); + } catch (RefNotFoundException e) { + PasswordManager.checkInternet(); + throw new RuntimeException(e); + } catch (InvalidRefNameException e) { + PasswordManager.checkInternet(); + throw new RuntimeException(e); + } catch (CheckoutConflictException e) { + resolveConflict(remoteURI, e, git); + } catch (GitAPIException e) { + PasswordManager.checkInternet(); + throw new RuntimeException(e); + } catch (Exception e) { + PasswordManager.checkInternet(); + throw new RuntimeException(e); + } + }); + } catch (Exception ex) { PasswordManager.checkInternet(); - closeGit(git); throw new RuntimeException(ex); } - closeGit(git); } } @@ -1765,30 +1741,21 @@ public static File cloneRepo(String remoteURI, String branch) { com.neuronrobotics.sdk.common.Log.error(" to: " + localPath); Throwable ex = null; // Clone the repo - Git git = null; try { if (branch == null) { - git = cloneRepoLocal(remoteURI, dir); - hasAtLeastOneReference(git); - closeGit(git); + cloneRepoLocal(remoteURI, dir, git -> { + hasAtLeastOneReference(git); + }); branch = getFullBranch(remoteURI); } else { - git = cloneRepoLocal(remoteURI, dir); - hasAtLeastOneReference(git); - closeGit(git); + cloneRepoLocal(remoteURI, dir, git -> { + hasAtLeastOneReference(git); + }); checkout(remoteURI, branch); } - - } catch (org.eclipse.jgit.api.errors.JGitInternalException exe) { - closeGit(git); - // deleteRepo(remoteURI); - throw exe; - } catch (Throwable e) { - e.printStackTrace(); - closeGit(git); - PasswordManager.checkInternet(); - throw new RuntimeException(e); + } catch (Throwable t) { + t.printStackTrace(); } } @@ -1817,16 +1784,22 @@ public static String locateGitUrl(File f, Git ref) throws IOException { File gitRepoFile = new File(f.getAbsolutePath()); while (gitRepoFile != null) { if (new File(gitRepoFile.getAbsolutePath() + "/.git/config").exists()) { - // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: "+gitRepoFile); + // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: + // "+gitRepoFile); Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile() + "/.git"); - Git git = ref; - if (git == null) - git = openGit(localRepo); - String url = git.getRepository().getConfig().getString("remote", "origin", "url"); + // Git git = ref; + if (ref == null) { + ArrayList s = new ArrayList(); + File fi = gitRepoFile; + openGit(localRepo, git -> { + s.add(locateGitUrl(fi, git)); + }); + return s.get(0); + } + String url = ref.getRepository().getConfig().getString("remote", "origin", "url"); if (!url.endsWith(".git")) url += ".git"; - if (ref == null) - closeGit(git); + localRepo.close(); return url; } gitRepoFile = gitRepoFile.getParentFile(); @@ -1835,16 +1808,17 @@ public static String locateGitUrl(File f, Git ref) throws IOException { return null; } - public static Git locateGit(File f) throws IOException { + public static void locateGit(File f, IGitAccessor access) throws IOException { File gitRepoFile = f; while (gitRepoFile != null) { gitRepoFile = gitRepoFile.getParentFile(); if (gitRepoFile != null) if (new File(gitRepoFile.getAbsolutePath() + "/.git/config").exists()) { - // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: "+gitRepoFile); + // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: + // "+gitRepoFile); Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile() + "/.git"); - return openGit(localRepo); - + openGit(localRepo, access); + return; } } @@ -1922,15 +1896,13 @@ public static String findLocalPath(File currentFile, Git git) { @SuppressWarnings("unused") public static String findLocalPath(File currentFile) { - Git git = null; try { - git = locateGit(currentFile); - String ret = findLocalPath(currentFile, git); - closeGit(git); - return ret; + ArrayList s = new ArrayList(); + locateGit(currentFile, git -> { + s.add(findLocalPath(currentFile, git)); + }); + return s.get(0); } catch (IOException e) { - if (git != null) - closeGit(git); throw new RuntimeException(e); } @@ -1942,50 +1914,39 @@ public static String[] findGitTagFromFile(File currentFile) throws IOException { public static String[] findGitTagFromFile(File currentFile, Git ref) throws IOException { String string = locateGitUrl(currentFile, ref); - Git git = ref; - if (git == null) - git = locateGit(currentFile); - try { - String[] strings = new String[] { string, findLocalPath(currentFile, git) }; - if (ref == null) - closeGit(git); - return strings; - } catch (Throwable t) { - t.printStackTrace(); - if (ref == null) - closeGit(git); - throw t; + String[] strings = new String[2]; + if (ref == null) + locateGit(currentFile, git -> { + String[] str = findGitTagFromFile(currentFile, git); + strings[0] = str[0]; + strings[1] = str[1]; + }); + else { + strings[0] = string; + strings[1] = findLocalPath(currentFile, ref); } + return strings; + } public static boolean checkOwner(String url) { - Git git = null; - try { - git = openGit(getRepository(url)); - } catch (IOException e1) { - closeGit(git); - throw new RuntimeException(e1); - } - boolean owned = checkOwner(git); - closeGit(git); - return owned; + ArrayList owners = new ArrayList(); + openGit(url,git->{ + owners.add(checkOwner(git)); + }); + return owners.get(0); } public static boolean checkOwner(File currentFile) { - Git git; + ArrayList owners = new ArrayList(); try { - git = locateGit(currentFile); + locateGit(currentFile,git->{ + owners.add(checkOwner(git)); + }); } catch (Throwable e1) { return false; } - boolean owned; - try { - owned = checkOwner(git); - } catch (Throwable t) { - owned = false; - } - closeGit(git); - return owned; + return owners.get(0); } private static boolean checkOwner(Git git) { @@ -2054,33 +2015,35 @@ public static String fork(String sourceURL, String newRepoName, String newRepoDe String gitRepo = repository.getHttpTransportUrl(); ArrayList files = filesInGit(sourceURL); - Git git = locateGit(fileFromGit(sourceURL, files.get(0))); - Repository sourceRepoObject = git.getRepository(); - try { - sourceRepoObject.getConfig().setString("remote", "origin", "url", gitRepo); - if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) - git.push().setTransportConfigCallback(transportConfigCallback) - .setProgressMonitor(getProgressMoniter("Pushing ", gitRepo)).call(); - else - git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) - .setProgressMonitor(getProgressMoniter("Pushing ", gitRepo)).call(); - closeGit(git); - - filesInGit(gitRepo); - - return gitRepo; - } catch (org.kohsuke.github.HttpException ex) { - closeGit(git); - if (ex.getMessage().contains("name already exists on this account")) { - return PasswordManager.getGithub().getRepository(PasswordManager.getLoginID() + "/" + newRepoName) - .getHttpTransportUrl(); + ArrayList back = new ArrayList(); + locateGit(fileFromGit(sourceURL, files.get(0)),git->{ + Repository sourceRepoObject = git.getRepository(); + try { + sourceRepoObject.getConfig().setString("remote", "origin", "url", gitRepo); + if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) + git.push().setTransportConfigCallback(transportConfigCallback) + .setProgressMonitor(getProgressMoniter("Pushing ", gitRepo)).call(); + else + git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) + .setProgressMonitor(getProgressMoniter("Pushing ", gitRepo)).call(); + + filesInGit(gitRepo); + + back.add(gitRepo); + } catch (org.kohsuke.github.HttpException ex) { + if (ex.getMessage().contains("name already exists on this account")) { + back.add( + PasswordManager.getGithub().getRepository(PasswordManager.getLoginID() + "/" + newRepoName) + .getHttpTransportUrl()); + } + ex.printStackTrace(); + } catch (Throwable ex) { + ex.printStackTrace(); } - ex.printStackTrace(); - } catch (Throwable ex) { - ex.printStackTrace(); - } - closeGit(git); - throw new RuntimeException("Repo could not be forked and does not exist"); + if(back.size()==0) + throw new RuntimeException("Repo could not be forked and does not exist"); + }); + return back.get(0); } public static GHRepository makeNewRepoNoFailOver(String newName, String description) @@ -2140,12 +2103,13 @@ public static GHRepository makeNewRepo(String newName, String description) throw public static String locateGitUrlString(File f) { try { - Git locateGit = ScriptingEngine.locateGit(f); - Repository repository = locateGit.getRepository(); - String string = repository.getConfig().getString("remote", "origin", "url"); - ScriptingEngine.closeGit(locateGit); - return string; - + ArrayList back = new ArrayList(); + locateGit(f,locateGit->{ + Repository repository = locateGit.getRepository(); + String string = repository.getConfig().getString("remote", "origin", "url"); + back.add(string); + }); + return back.get(0); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -2267,9 +2231,11 @@ public static Ref getBranch(String remoteURI, String branch) throws IOException, public static Collection getAllBranches(String remoteURI) throws IOException, GitAPIException { cloneRepo(remoteURI, null); - Git git = openGit(getRepository(remoteURI)); - String ref = git.getRepository().getConfig().getString("remote", "origin", "url"); - closeGit(git); + ArrayList refs=new ArrayList(); + openGit(getRepository(remoteURI),git->{ + refs.add(git.getRepository().getConfig().getString("remote", "origin", "url")); + }); + String ref = refs.get(0); System.out.print("Getting branches " + ref + " "); if (ref != null && ref.startsWith("git@")) { @@ -2331,11 +2297,15 @@ private static void commit(String url, String branch, String message) private static void commit(String url, String branch, String message, Git passedRef) throws IOException, GitAPIException, NoHeadException, NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException { - Git git = passedRef; - if (git == null) - git = openGit(getRepository(url)); + + if (passedRef == null) { + openGit(getRepository(url),git->{ + commit(url, branch, message, git); + }); + return; + } try { - git.commit().setAll(true).setMessage(message).call(); + passedRef.commit().setAll(true).setMessage(message).call(); ArrayList arrayList = onCommitEventListeners.get(url); if (arrayList != null) { for (int i = 0; i < arrayList.size(); i++) { @@ -2348,12 +2318,8 @@ private static void commit(String url, String branch, String message, Git passed } } } catch (Throwable t) { - if (passedRef == null) - closeGit(git); throw t; } - if (passedRef == null) - closeGit(git); } public static File getAppData() { @@ -2399,25 +2365,24 @@ public static int versionCompare(String v1, String v2) { public static List getAllTags(String gitRepo) { ArrayList tags = new ArrayList<>(); - Git jGit = openGit(gitRepo); - List call; - try { - call = jGit.tagList().call(); - for (Ref ref : call) { - String string = ref.getName().split("/")[2]; - tags.add(string); - } - } catch (Throwable e) { - // Auto-generated catch block - e.printStackTrace(); - - } - Collections.sort(tags, new Comparator() { - public int compare(String object1, String object2) { - return versionCompare(object1, object2); + openGit(gitRepo,jGit->{ + List call; + try { + call = jGit.tagList().call(); + for (Ref ref : call) { + String string = ref.getName().split("/")[2]; + tags.add(string); + } + } catch (Throwable e) { + // Auto-generated catch block + e.printStackTrace(); } + Collections.sort(tags, new Comparator() { + public int compare(String object1, String object2) { + return versionCompare(object1, object2); + } + }); }); - closeGit(jGit); return tags; } @@ -2438,9 +2403,7 @@ public static void tagRepo(String remoteURI, String newTag) { com.neuronrobotics.sdk.common.Log.error("ERROR! Tag exists " + remoteURI + "@" + newTag); return; } - Git git = openGit(remoteURI); - // Creating tag - try { + openGit(remoteURI,git->{ try { git.tag().setName(newTag).setForceUpdate(true).call(); } catch (Throwable t) { @@ -2452,11 +2415,7 @@ public static void tagRepo(String remoteURI, String newTag) { else git.push().setPushTags().setCredentialsProvider(PasswordManager.getCredentialProvider()) .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); - } catch (GitAPIException e) { - // Auto-generated catch block - e.printStackTrace(); - } - closeGit(git); + }); } public static boolean isPrintProgress() { @@ -2477,7 +2436,8 @@ public static void ignore(String url, String filepattern) throws Exception { String line = reader.readLine(); while (line != null) { if (line.contains(filepattern)) { - com.neuronrobotics.sdk.common.Log.error("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log + .error("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); reader.close(); return; } From 63f220c6f965419d9149b925686067783d08ee91 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 14:17:39 -0500 Subject: [PATCH 280/635] making the open return on no exception --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 505e9328..3703af42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -381,6 +381,7 @@ public static void openGit(String url, IGitAccessor accessor) { try { localRepo = getRepository(url); openGit(localRepo, accessor); + return; } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); From 267bf38f01927587ca532a66f803eb6eead10b1a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 14:44:07 -0500 Subject: [PATCH 281/635] Ensure the timeout thread is fully exited before moving on --- .../bowlerstudio/scripting/GitTimeoutThread.java | 11 +++++++++-- .../bowlerstudio/scripting/ScriptingEngine.java | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java index 17d41fb1..a93a474b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java @@ -9,6 +9,7 @@ public class GitTimeoutThread extends Thread { String ref; private RuntimeException ex; long startTime=0; + boolean run = true; public GitTimeoutThread(Git g) { git=g; ref = git.getRepository().getConfig().getString("remote", "origin", "url"); @@ -19,10 +20,13 @@ public GitTimeoutThread(Git g) { public void run() { resetTimer(); try { - while((startTime+(1000*120))>System.currentTimeMillis()) - Thread.sleep(1000); + while((startTime+(1000*120))>System.currentTimeMillis() && run) + Thread.sleep(100); git.close(); ScriptingEngine.gitOpenTimeout.remove(git); + if(!run) + return; + ex.printStackTrace(); new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), getException()); } catch (InterruptedException e) { // exited clean @@ -37,4 +41,7 @@ public RuntimeException getException() { private void setException(RuntimeException ex) { this.ex = ex; } + public void close() { + run=false; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 3703af42..ce69a063 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -477,9 +477,15 @@ private static void gitclose(Git git) { if (git == null) return; if (gitOpenTimeout.containsKey(git)) { - Thread thread = gitOpenTimeout.remove(git); + GitTimeoutThread thread = gitOpenTimeout.remove(git); if (thread != null) { - thread.interrupt(); + thread.close(); + try { + thread.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } else { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), new RuntimeException("Closing a git object that was not opened with a timeout!")); From 97660bc3281028f48c09281200542f123e213f00 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Thu, 9 Jan 2025 16:41:09 -0500 Subject: [PATCH 282/635] Removing the timeout thread system to replace it with the access checkout --- .../scripting/GitTimeoutThread.java | 47 ------ .../scripting/ScriptingEngine.java | 135 +++++------------- 2 files changed, 34 insertions(+), 148 deletions(-) delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java deleted file mode 100644 index a93a474b..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitTimeoutThread.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.neuronrobotics.bowlerstudio.scripting; - -import org.eclipse.jgit.api.Git; - -import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; - -public class GitTimeoutThread extends Thread { - Git git; - String ref; - private RuntimeException ex; - long startTime=0; - boolean run = true; - public GitTimeoutThread(Git g) { - git=g; - ref = git.getRepository().getConfig().getString("remote", "origin", "url"); - setException(new RuntimeException( - "Git opened here, timeout on close!!\nWhen Done with the git object, Call:\n ScriptingEngine.closeGit(git);\n" - + ref + "\n")); - } - public void run() { - resetTimer(); - try { - while((startTime+(1000*120))>System.currentTimeMillis() && run) - Thread.sleep(100); - git.close(); - ScriptingEngine.gitOpenTimeout.remove(git); - if(!run) - return; - ex.printStackTrace(); - new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), getException()); - } catch (InterruptedException e) { - // exited clean - } - } - public void resetTimer() { - startTime=System.currentTimeMillis(); - } - public RuntimeException getException() { - return ex; - } - private void setException(RuntimeException ex) { - this.ex = ex; - } - public void close() { - run=false; - } -} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index ce69a063..099637e5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -173,8 +173,9 @@ public static List flaten(File f, Class type, ArrayList args) private static HashMap> onCommitEventListeners = new HashMap<>(); // static IssueReportingExceptionHandler exp = new // IssueReportingExceptionHandler(); - static HashMap gitOpenTimeout = new HashMap<>(); - + //static HashMap gitOpenTimeout = new HashMap<>(); + static HashMap open = new HashMap(); + private static String delim; private static String appName = "BowlerLauncher"; @@ -252,7 +253,7 @@ private static void cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean } Git git = setURI.call(); - gitOpenTimeout.put(git, makeTimeoutThread(git)); + open.put(dir.getAbsolutePath(), git); try { accessor.run(git); } catch (Exception e) { @@ -307,14 +308,14 @@ private static ProgressMonitor getProgressMoniter(String type, String remoteURI) @Override public void update(int completed) { - for (Iterator iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) { - Git g = iterator.next(); - GitTimeoutThread t = gitOpenTimeout.get(g); - if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) { - t.resetTimer(); - break; - } - } +// for (Iterator iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) { +// Git g = iterator.next(); +// GitTimeoutThread t = gitOpenTimeout.get(g); +// if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) { +// t.resetTimer(); +// break; +// } +// } sum += completed; DecimalFormat df = new DecimalFormat("###.#"); @@ -389,23 +390,19 @@ public static void openGit(String url, IGitAccessor accessor) { throw new RuntimeException("IOException making repo"); } - public static boolean isUrlAlreadyOpen(String URL) { - if (URL == null) - return false; - Object[] keySet; - synchronized (gitOpenTimeout) { - keySet = gitOpenTimeout.keySet().toArray(); - } - for (int i = 0; i < keySet.length; i++) { - Git g = (Git) keySet[i]; - GitTimeoutThread t = gitOpenTimeout.get(g); - if (t.ref.toLowerCase().contentEquals(URL.toLowerCase())) { - // t.getException().printStackTrace(System.err); - return true; - } - } - return false; - } +// public static boolean isUrlAlreadyOpen(String URL) { +// if (URL == null) +// return false; +// Set keySet = open.keySet(); +// +// for (String s:keySet) { +// if (s.toLowerCase().contentEquals(URL.toLowerCase())) { +// // t.getException().printStackTrace(System.err); +// return true; +// } +// } +// return false; +// } /** * Open a git object and start a timeout timer for closing it @@ -417,45 +414,20 @@ public static boolean isUrlAlreadyOpen(String URL) { public static void openGit(Repository localRepo, IGitAccessor accessor) { Git git = null; try { - - Object[] keySet; - synchronized (gitOpenTimeout) { - keySet = gitOpenTimeout.keySet().toArray(); - } - for (int j = 0; j < keySet.length; j++) { - Object gO = keySet[j]; - Git g = (Git) gO; + for (String s:open.keySet()) { + Git g= open.get(s); if (g.getRepository().getDirectory().getAbsolutePath() .contentEquals(localRepo.getDirectory().getAbsolutePath())) { - GitTimeoutThread t = gitOpenTimeout.get(g); - int i = 0; - while (gitOpenTimeout.containsKey(g)) { - - com.neuronrobotics.sdk.common.Log.error("Git is locked by other process, blocking " - + localRepo.getDirectory().getAbsolutePath()); - com.neuronrobotics.sdk.common.Log.error("Git locked " + t.ref); - if (i > 3) { - t.getException().printStackTrace(System.out); - com.neuronrobotics.sdk.common.Log.error("Blocking process: "); - - new Exception().printStackTrace(System.out); - } - i++; - ThreadUtil.wait(1000); - } - break; + throw new RuntimeException("Fail! This Git is already open! "+localRepo.getDirectory().getAbsolutePath()); } } - git = new Git(localRepo); - - gitOpenTimeout.put(git, makeTimeoutThread(git)); + open.put(localRepo.getDirectory().getAbsolutePath(), git); if (accessor != null) { try { accessor.run(git); } catch (Throwable t) { new IssueReportingExceptionHandler().except(t); - throw new RuntimeException(t); } } gitclose(git); @@ -476,37 +448,11 @@ public static void openGit(Repository localRepo, IGitAccessor accessor) { private static void gitclose(Git git) { if (git == null) return; - if (gitOpenTimeout.containsKey(git)) { - GitTimeoutThread thread = gitOpenTimeout.remove(git); - if (thread != null) { - thread.close(); - try { - thread.join(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else { - new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), - new RuntimeException("Closing a git object that was not opened with a timeout!")); - } - } + open.remove(git.getRepository().getDirectory().getAbsolutePath()); git.getRepository().close(); git.close(); } - /** - * Make a timeout thread for printing an exception whenever a git object is - * opened and not closed within 5 seconds - * - * @return - */ - private static GitTimeoutThread makeTimeoutThread(Git git) { - - GitTimeoutThread thread = new GitTimeoutThread(git); - thread.start(); - return thread; - } public static void addOnCommitEventListeners(String url, Runnable event) { synchronized (onCommitEventListeners) { @@ -782,23 +728,10 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr } public static void waitForRepo(String remoteURI, String reason) { - while (ScriptingEngine.isUrlAlreadyOpen(remoteURI)) { - ThreadUtil.wait(500); - for (Iterator iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) { - Git g = iterator.next(); - GitTimeoutThread t = gitOpenTimeout.get(g); - if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) { - - com.neuronrobotics.sdk.common.Log - .error("\n\n\nPaused " + reason + " by another thread, waiting for repo " + remoteURI); - new Exception().printStackTrace(System.err); - com.neuronrobotics.sdk.common.Log.error("Paused by:"); - t.getException().printStackTrace(System.err); - com.neuronrobotics.sdk.common.Log.error("\n\n\n"); - - } - } - } +// while (ScriptingEngine.isUrlAlreadyOpen(remoteURI)) { +// ThreadUtil.wait(500); +// System.err.println("Waiting..."); +// } } public static void deleteRepo(String remoteURI) { From 51293cd06a33f6b174f1b28f87ea58b7a6b63bd0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 20:07:40 -0500 Subject: [PATCH 283/635] Wait for there to be only one --- .../scripting/ScriptingEngine.java | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 099637e5..9e3dbc52 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -173,9 +173,9 @@ public static List flaten(File f, Class type, ArrayList args) private static HashMap> onCommitEventListeners = new HashMap<>(); // static IssueReportingExceptionHandler exp = new // IssueReportingExceptionHandler(); - //static HashMap gitOpenTimeout = new HashMap<>(); - static HashMap open = new HashMap(); - + // static HashMap gitOpenTimeout = new HashMap<>(); + static HashMap open = new HashMap(); + private static String delim; private static String appName = "BowlerLauncher"; @@ -390,19 +390,19 @@ public static void openGit(String url, IGitAccessor accessor) { throw new RuntimeException("IOException making repo"); } -// public static boolean isUrlAlreadyOpen(String URL) { -// if (URL == null) -// return false; -// Set keySet = open.keySet(); -// -// for (String s:keySet) { -// if (s.toLowerCase().contentEquals(URL.toLowerCase())) { -// // t.getException().printStackTrace(System.err); -// return true; -// } -// } -// return false; -// } + public static boolean isUrlAlreadyOpen(File URL) { + if (URL == null) + return false; + Set keySet = open.keySet(); + + for (String s : keySet) { + if (s.toLowerCase().contentEquals(URL.getAbsolutePath())) { + // t.getException().printStackTrace(System.err); + return true; + } + } + return false; + } /** * Open a git object and start a timeout timer for closing it @@ -414,11 +414,15 @@ public static void openGit(String url, IGitAccessor accessor) { public static void openGit(Repository localRepo, IGitAccessor accessor) { Git git = null; try { - for (String s:open.keySet()) { - Git g= open.get(s); - if (g.getRepository().getDirectory().getAbsolutePath() + for (String s : open.keySet()) { + Git g = open.get(s); + + while (g.getRepository().getDirectory().getAbsolutePath() .contentEquals(localRepo.getDirectory().getAbsolutePath())) { - throw new RuntimeException("Fail! This Git is already open! "+localRepo.getDirectory().getAbsolutePath()); + Thread.sleep(500); + g = open.get(s); + if(g==null) + break; } } git = new Git(localRepo); @@ -453,7 +457,6 @@ private static void gitclose(Git git) { git.close(); } - public static void addOnCommitEventListeners(String url, Runnable event) { synchronized (onCommitEventListeners) { if (!onCommitEventListeners.containsKey(url)) { @@ -728,10 +731,17 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr } public static void waitForRepo(String remoteURI, String reason) { -// while (ScriptingEngine.isUrlAlreadyOpen(remoteURI)) { -// ThreadUtil.wait(500); -// System.err.println("Waiting..."); -// } + try { + File f = getRepository(remoteURI).getDirectory(); + while (ScriptingEngine.isUrlAlreadyOpen(f)) { + ThreadUtil.wait(500); + System.err.println("Waiting..."); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } public static void deleteRepo(String remoteURI) { @@ -1871,7 +1881,7 @@ public static String[] findGitTagFromFile(File currentFile, Git ref) throws IOEx public static boolean checkOwner(String url) { ArrayList owners = new ArrayList(); - openGit(url,git->{ + openGit(url, git -> { owners.add(checkOwner(git)); }); return owners.get(0); @@ -1880,7 +1890,7 @@ public static boolean checkOwner(String url) { public static boolean checkOwner(File currentFile) { ArrayList owners = new ArrayList(); try { - locateGit(currentFile,git->{ + locateGit(currentFile, git -> { owners.add(checkOwner(git)); }); } catch (Throwable e1) { @@ -1956,7 +1966,7 @@ public static String fork(String sourceURL, String newRepoName, String newRepoDe ArrayList files = filesInGit(sourceURL); ArrayList back = new ArrayList(); - locateGit(fileFromGit(sourceURL, files.get(0)),git->{ + locateGit(fileFromGit(sourceURL, files.get(0)), git -> { Repository sourceRepoObject = git.getRepository(); try { sourceRepoObject.getConfig().setString("remote", "origin", "url", gitRepo); @@ -1972,15 +1982,14 @@ public static String fork(String sourceURL, String newRepoName, String newRepoDe back.add(gitRepo); } catch (org.kohsuke.github.HttpException ex) { if (ex.getMessage().contains("name already exists on this account")) { - back.add( - PasswordManager.getGithub().getRepository(PasswordManager.getLoginID() + "/" + newRepoName) + back.add(PasswordManager.getGithub().getRepository(PasswordManager.getLoginID() + "/" + newRepoName) .getHttpTransportUrl()); } ex.printStackTrace(); } catch (Throwable ex) { ex.printStackTrace(); } - if(back.size()==0) + if (back.size() == 0) throw new RuntimeException("Repo could not be forked and does not exist"); }); return back.get(0); @@ -2044,7 +2053,7 @@ public static String locateGitUrlString(File f) { try { ArrayList back = new ArrayList(); - locateGit(f,locateGit->{ + locateGit(f, locateGit -> { Repository repository = locateGit.getRepository(); String string = repository.getConfig().getString("remote", "origin", "url"); back.add(string); @@ -2171,8 +2180,8 @@ public static Ref getBranch(String remoteURI, String branch) throws IOException, public static Collection getAllBranches(String remoteURI) throws IOException, GitAPIException { cloneRepo(remoteURI, null); - ArrayList refs=new ArrayList(); - openGit(getRepository(remoteURI),git->{ + ArrayList refs = new ArrayList(); + openGit(getRepository(remoteURI), git -> { refs.add(git.getRepository().getConfig().getString("remote", "origin", "url")); }); String ref = refs.get(0); @@ -2239,7 +2248,7 @@ private static void commit(String url, String branch, String message, Git passed ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException { if (passedRef == null) { - openGit(getRepository(url),git->{ + openGit(getRepository(url), git -> { commit(url, branch, message, git); }); return; @@ -2305,7 +2314,7 @@ public static int versionCompare(String v1, String v2) { public static List getAllTags(String gitRepo) { ArrayList tags = new ArrayList<>(); - openGit(gitRepo,jGit->{ + openGit(gitRepo, jGit -> { List call; try { call = jGit.tagList().call(); @@ -2343,7 +2352,7 @@ public static void tagRepo(String remoteURI, String newTag) { com.neuronrobotics.sdk.common.Log.error("ERROR! Tag exists " + remoteURI + "@" + newTag); return; } - openGit(remoteURI,git->{ + openGit(remoteURI, git -> { try { git.tag().setName(newTag).setForceUpdate(true).call(); } catch (Throwable t) { From 949002abd8903296ab441311498022a6bc747c3f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 20:08:54 -0500 Subject: [PATCH 284/635] scritpting engine update --- .../bowlerstudio/scripting/ScriptingEngine.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 9e3dbc52..e74cdedf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -414,19 +414,21 @@ public static boolean isUrlAlreadyOpen(File URL) { public static void openGit(Repository localRepo, IGitAccessor accessor) { Git git = null; try { + String absolutePath = localRepo.getDirectory().getAbsolutePath(); for (String s : open.keySet()) { Git g = open.get(s); while (g.getRepository().getDirectory().getAbsolutePath() - .contentEquals(localRepo.getDirectory().getAbsolutePath())) { + .contentEquals(absolutePath)) { Thread.sleep(500); + System.out.println("Waiting for git to close "+absolutePath); g = open.get(s); if(g==null) break; } } git = new Git(localRepo); - open.put(localRepo.getDirectory().getAbsolutePath(), git); + open.put(absolutePath, git); if (accessor != null) { try { accessor.run(git); From 38bdcea25ac32fa3d475d4e5d7a9a2498532dce2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 20:16:07 -0500 Subject: [PATCH 285/635] FIxed the recoursion to just use the open git lol --- .../scripting/ScriptingEngine.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index e74cdedf..de959fb3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -413,22 +413,23 @@ public static boolean isUrlAlreadyOpen(File URL) { public static void openGit(Repository localRepo, IGitAccessor accessor) { Git git = null; + boolean alreadyOpen= false; try { String absolutePath = localRepo.getDirectory().getAbsolutePath(); for (String s : open.keySet()) { Git g = open.get(s); - - while (g.getRepository().getDirectory().getAbsolutePath() + if(g!=null) + if (g.getRepository().getDirectory().getAbsolutePath() .contentEquals(absolutePath)) { - Thread.sleep(500); - System.out.println("Waiting for git to close "+absolutePath); - g = open.get(s); - if(g==null) - break; + git=g; + alreadyOpen=true; + break; } } - git = new Git(localRepo); - open.put(absolutePath, git); + if(!alreadyOpen) { + git = new Git(localRepo); + open.put(absolutePath, git); + } if (accessor != null) { try { accessor.run(git); @@ -436,7 +437,8 @@ public static void openGit(Repository localRepo, IGitAccessor accessor) { new IssueReportingExceptionHandler().except(t); } } - gitclose(git); + if(!alreadyOpen) + gitclose(git); } catch (Throwable t) { new IssueReportingExceptionHandler().except(t); if (git != null) { From 6aef77ef4f645d00aaa921cb2660f985746d9f78 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 9 Jan 2025 20:19:49 -0500 Subject: [PATCH 286/635] fix the scripting engine recourcsive close --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index de959fb3..948a310d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -457,7 +457,7 @@ private static void gitclose(Git git) { if (git == null) return; open.remove(git.getRepository().getDirectory().getAbsolutePath()); - git.getRepository().close(); + //git.getRepository().close(); git.close(); } From 2c2e79b0c5b5b69cac6d54cd9ac323e4fdf2cd63 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 10:23:19 -0500 Subject: [PATCH 287/635] https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/40 Adding a sweep operation to the cadoodle file processor --- .../scripting/cadoodle/AddFromFile.java | 6 +- .../scripting/cadoodle/Sweep.java | 146 ++++++++++++++++++ 2 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 024542a2..a69aba5b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -32,7 +32,7 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; public AddFromFile set(File source) { - toLocal(source); + toLocal(source,getName()); return this; } @@ -116,7 +116,7 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); return targetFile; } - private File toLocal(File file) { + public static File toLocal(File file, String name) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFileIncoming = file.getParentFile(); File parentFile = new File(loc.getStrValue()).getParentFile(); @@ -127,7 +127,7 @@ private File toLocal(File file) { if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase()) && file.exists()) { File copied; try { - copied = copyFileToNewDirectory(file, parentFile, getName()); + copied = copyFileToNewDirectory(file, parentFile, name); file = copied; } catch (IOException e) { // Auto-generated catch block diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java new file mode 100644 index 00000000..29db211a --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -0,0 +1,146 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.parametrics.StringParameter; + +public class Sweep extends AbstractAddFrom{ + @Expose(serialize = true, deserialize = true) + private TransformNR location = null; + private ArrayList options = new ArrayList(); + @Expose(serialize = true, deserialize = true) + private Boolean preventBoM =false; + + public Sweep set(File source) throws Exception { + if(!source.getName().toLowerCase().endsWith(".svg")) + throw new Exception("Sweep can only take files with the .svg extention"); + AddFromFile.toLocal(source,getName()); + return this; + } + @Override + public String getType() { + // TODO Auto-generated method stub + return "Sweep"; + } + + @Override + public List process(List incoming) { + nameIndex = 0; + ArrayList back = new ArrayList(); + back.addAll(incoming); + if (getName() == null) { + + } + try { +// ArrayListargs = new ArrayList<>(); +// args.addAll(Arrays.asList(getName() )); + ArrayList collect = new ArrayList<>(); + File file = getFile(); + if(!file.exists()) { + throw new RuntimeException("Failed to find file"); + } + + ArrayListargs = new ArrayList<>(); + args.addAll(Arrays.asList(name )); + HashMap configs =new HashMap(); + configs.put("name", name); + configs.put("PreventBomAdd", preventBoM); + args.add(configs); + List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + for (int i = 0; i < flattenedCSGs.size(); i++) { + CSG csg = flattenedCSGs.get(i); + try { + CSG processedCSG = processGiven(csg, i, getOrderedName()); + collect.add(processedCSG); + }catch(Exception ex) { + ex.printStackTrace(); + } + } + back.addAll(collect); + } catch (Exception e) { + e.printStackTrace(); + } + return back; + } + + + + public File getFile() { + StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); + File parentFile = new File(loc.getStrValue()).getParentFile(); + for(String f:parentFile.list()) { + if(f.contains(name)) { + String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; + return new File(pathname); + } + } + throw new RuntimeException("File not found! "+name); + } + + + private CSG processGiven(CSG csg, int i, String name) { + Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); + String pathname = getFile().getAbsolutePath(); + + StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); + parameter.setStrValue(pathname); + CSG processedCSG = csg + .transformed(nrToCSG).syncProperties(csg).setParameter(parameter) + .setRegenerate(previous -> { + try { + File file = getFile(); + String fileLocation = file.getAbsolutePath(); + com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); + List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); + CSG csg1 = flattenedCSGs.get(i); + return processGiven(csg1, i, name); + } catch (Exception e) { + e.printStackTrace(); + } + return previous; + }).setName(name); + MoveCenter.set(getName(), processedCSG, nrToCSG); + return processedCSG; + } + + public TransformNR getLocation() { + if (location == null) + location = new TransformNR(); + return location; + } + + public Sweep setLocation(TransformNR location) { + this.location = location; + return this; + } + + + + public Boolean getPreventBoM() { + return preventBoM; + } + + public Sweep setPreventBoM(Boolean preventBoM) { + this.preventBoM = preventBoM; + return this; + } + + +} From 7cb770184340bec1e34f97a4b471390c9fe2441b Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 13:32:54 -0500 Subject: [PATCH 288/635] Adding a Sweep Command! --- .../scripting/cadoodle/AddFromFile.java | 11 +- .../ICaDoodleOperationAdapterFactory.java | 1 + .../scripting/cadoodle/Sweep.java | 176 +++++++++++++++--- 3 files changed, 162 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index a69aba5b..805997f0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.ArrayList; @@ -138,7 +139,8 @@ public static File toLocal(File file, String name) { file = new File(source + DownloadManager.delim() + file.getName()); return file; } - public File getFile() { + + public static File getFile(String name) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFile = new File(loc.getStrValue()).getParentFile(); for(String f:parentFile.list()) { @@ -157,7 +159,7 @@ public File getFile() { private CSG processGiven(CSG csg, int i, String name) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); - String pathname = getFile().getAbsolutePath(); + String pathname = getFile(name).getAbsolutePath(); StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); parameter.setStrValue(pathname); @@ -204,4 +206,9 @@ public AddFromFile setPreventBoM(Boolean preventBoM) { this.preventBoM = preventBoM; return this; } + + @Override + public File getFile() throws NoSuchFileException { + return AddFromFile.getFile(name); + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java index 33ef1732..6ffa0087 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java @@ -30,6 +30,7 @@ public ICaDoodleOperationAdapterFactory() { registerType("ToSolid", ToSolid.class); registerType("UnGroup", UnGroup.class); registerType("UnLock", UnLock.class); + registerType("Sweep", Sweep.class); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 29db211a..4b436977 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -17,14 +17,23 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Extrude; +import eu.mihosoft.vrl.v3d.Plane; +import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.Vector3d; +import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil; +import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; +import eu.mihosoft.vrl.v3d.svg.SVGLoad; public class Sweep extends AbstractAddFrom{ @Expose(serialize = true, deserialize = true) private TransformNR location = null; - private ArrayList options = new ArrayList(); + private static ArrayList options = new ArrayList(); + private static ArrayList nopt=new ArrayList(); @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; @@ -39,6 +48,83 @@ public String getType() { // TODO Auto-generated method stub return "Sweep"; } + + public static CSG sweep(Polygon p, Transform increment, Transform offset, int steps) { + Polygon offsetP =p.transformed(offset); + List newPolygons = new ArrayList<>(); + newPolygons.addAll(PolygonUtil.concaveToConvex(offsetP)); + Transform running = new Transform(); + Polygon prev=offsetP; + for(int i=0;i parts = monotoneExtrude(prev,step); + prev=step; + newPolygons.addAll(parts); + } + Polygon polygon2 = offsetP.transformed(running); + List topPolygons = PolygonUtil.concaveToConvex(polygon2.flipped()); + newPolygons.addAll(topPolygons); + + return CSG.fromPolygons(newPolygons); + } + + public static CSG sweep(Polygon p, double angle, double z, double radius, int steps) { + return sweep(p,new Transform().rotX(angle).movex(z),new Transform().movey(radius),steps); + } + public static CSG sweep(Polygon p, String name, Bounds b) { + + int steps=(int)new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM(); + double angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM()/steps; + double z=new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt).getMM(); + double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); + if(angle<0) + angle=-angle; + Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY()); + Transform increment = new Transform().rotY(-angle).movey(z); + Transform radiusT = new Transform().movex(radius); + Polygon transformedP = p.transformed(centerandAllignedPolygon); + return sweep(transformedP,increment,radiusT,steps).rotx(-90).setName(name); + } + public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) { + List newPolygons = new ArrayList<>(); +// CSG extrude; + //polygon1=polygon1.flipped(); + //newPolygons.addAll(PolygonUtil.concaveToConvex(polygon1.flipped())); + //Polygon polygon2 = polygon1.translated(dir); + + int numvertices = polygon1.vertices.size(); + //com.neuronrobotics.sdk.common.Log.error("Building Polygon "+polygon1.getPoints().size()); + for (int i = 0; i < numvertices; i++) { + + int nexti = (i + 1) % numvertices; + + Vector3d bottomV1 = polygon1.vertices.get(i).pos; + Vector3d topV1 = polygon2.vertices.get(i).pos; + Vector3d bottomV2 = polygon1.vertices.get(nexti).pos; + Vector3d topV2 = polygon2.vertices.get(nexti).pos; + double distance = bottomV1.minus(bottomV2).magnitude(); + if(Math.abs(distance) pPoints = Arrays.asList(bottomV2, topV2, topV1, bottomV1); + try { + newPolygons.add(Polygon.fromPoints(pPoints, polygon1.getStorage())); + }catch(Exception ex) { + //com.neuronrobotics.sdk.common.Log.error("Polygon has problems: "); + ex.printStackTrace(); + } + } + +// polygon2 = polygon2.flipped(); +// List topPolygons = PolygonUtil.concaveToConvex(polygon2.flipped()); +// +// newPolygons.addAll(topPolygons); +// extrude = CSG.fromPolygons(newPolygons); + + return newPolygons; + } @Override public List process(List incoming) { @@ -63,16 +149,22 @@ public List process(List incoming) { configs.put("name", name); configs.put("PreventBomAdd", preventBoM); args.add(configs); - List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); - for (int i = 0; i < flattenedCSGs.size(); i++) { - CSG csg = flattenedCSGs.get(i); - try { - CSG processedCSG = processGiven(csg, i, getOrderedName()); + //List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + SVGLoad s = new SVGLoad(file.toURI()); + HashMap> polygons = s.toPolygons(); + Object[] array = polygons.keySet().toArray(); + int j =0; + Bounds b=getBounds(polygons); + for (int i = 0; i < array.length; i++) { + String key = (String)array[i]; + for(Polygon P:polygons.get(key)) { + + String orderedName = getOrderedName(); + CSG processedCSG = processGiven(P,b,j++, orderedName); collect.add(processedCSG); - }catch(Exception ex) { - ex.printStackTrace(); } } + back.addAll(collect); } catch (Exception e) { e.printStackTrace(); @@ -80,37 +172,73 @@ public List process(List incoming) { return back; } + public Bounds getBounds(HashMap> polygons) { + Vector3d min = null; + Vector3d max = null; + // TickToc.tic("getSellectedBounds "+incoming.size()); + for(String s:polygons.keySet()) + for (Polygon csg : polygons.get(s)) { - - public File getFile() { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); - File parentFile = new File(loc.getStrValue()).getParentFile(); - for(String f:parentFile.list()) { - if(f.contains(name)) { - String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; - return new File(pathname); - } + Bounds b = csg.getBounds(); + Vector3d min2 = b.getMin().clone(); + Vector3d max2 = b.getMax().clone(); + if (min == null) + min = min2; + if (max == null) + max = max2; + if (min2.x < min.x) + min.x = min2.x; + if (min2.y < min.y) + min.y = min2.y; + if (min2.z < min.z) + min.z = min2.z; + if (max.x < max2.x) + max.x = max2.x; + if (max.y < max2.y) + max.y = max2.y; + if (max.z < max2.z) + max.z = max2.z; + // TickToc.tic("Bounds for "+c.getName()); } - throw new RuntimeException("File not found! "+name); + + return new Bounds(min, max); + } + + @Override + public File getFile() throws NoSuchFileException { + return AddFromFile.getFile(name); } - private CSG processGiven(CSG csg, int i, String name) { + private CSG processGiven( Polygon p, Bounds b, int j, String name) { + CSG csg = sweep(p,name,b); Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); - String pathname = getFile().getAbsolutePath(); + String pathname; + try { + pathname = getFile().getAbsolutePath(); + } catch (NoSuchFileException e) { + throw new RuntimeException(e); + } StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); + LengthParameter steps=new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt); + LengthParameter angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt); + LengthParameter z=new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt); + LengthParameter radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt); parameter.setStrValue(pathname); CSG processedCSG = csg - .transformed(nrToCSG).syncProperties(csg).setParameter(parameter) + .transformed(nrToCSG).syncProperties(csg) + .setParameter(parameter) + .setParameter(steps) + .setParameter(angle) + .setParameter(z) + .setParameter(radius) .setRegenerate(previous -> { try { File file = getFile(); String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); - List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); - CSG csg1 = flattenedCSGs.get(i); - return processGiven(csg1, i, name); + return processGiven(p,b, j, name); } catch (Exception e) { e.printStackTrace(); } From 5cf631a183e794deb9dd9d74c401d4c54ce17a9a Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 14:15:47 -0500 Subject: [PATCH 289/635] Set the color of the extrusions based on the SVG color for the polygon --- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/Sweep.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8fa14070..0802beec 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.1.1' + api 'com.neuronrobotics:JavaCad:2.2.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 4b436977..e3597627 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -28,6 +28,7 @@ import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import eu.mihosoft.vrl.v3d.svg.SVGLoad; +import javafx.scene.paint.Color; public class Sweep extends AbstractAddFrom{ @Expose(serialize = true, deserialize = true) @@ -211,7 +212,12 @@ public File getFile() throws NoSuchFileException { private CSG processGiven( Polygon p, Bounds b, int j, String name) { + Color c=p.getColor(); + if(c==null) + c=Color.ROSYBROWN; + boolean hole = p.isHole(); CSG csg = sweep(p,name,b); + Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); String pathname; try { @@ -233,6 +239,8 @@ private CSG processGiven( Polygon p, Bounds b, int j, String name) { .setParameter(angle) .setParameter(z) .setParameter(radius) + .setColor(c) + .setIsHole(hole) .setRegenerate(previous -> { try { File file = getFile(); From f6e3ee100606ae954d9a06d5ac4782d3cc88e3ee Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 14:29:26 -0500 Subject: [PATCH 290/635] Use the number of steps to make the z value be explicate and absolute --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index e3597627..8feeb0e6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -77,7 +77,10 @@ public static CSG sweep(Polygon p, String name, Bounds b) { int steps=(int)new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM(); double angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM()/steps; - double z=new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt).getMM(); + double d = new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt).getMM()-b.getTotalY(); + if(d<0) + d=0; + double z=d/steps; double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); if(angle<0) angle=-angle; From 946ae93a277eae07e54f2ba92c54f5059ba9792e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 14:31:55 -0500 Subject: [PATCH 291/635] when the z is bounded, set it to the default cvalue --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 8feeb0e6..e18fe2ad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -77,9 +77,12 @@ public static CSG sweep(Polygon p, String name, Bounds b) { int steps=(int)new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM(); double angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM()/steps; - double d = new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt).getMM()-b.getTotalY(); - if(d<0) + LengthParameter zp = new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt); + double d = zp.getMM()-b.getTotalY(); + if(d<0) { d=0; + zp.setMM(b.getTotalY()); + } double z=d/steps; double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); if(angle<0) From 0f76f9d58951ef268a920b7b7a9255b15abc3690 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 14:46:50 -0500 Subject: [PATCH 292/635] changing it back to increment --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index e18fe2ad..28ca0920 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -77,13 +77,13 @@ public static CSG sweep(Polygon p, String name, Bounds b) { int steps=(int)new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM(); double angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM()/steps; - LengthParameter zp = new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt); - double d = zp.getMM()-b.getTotalY(); - if(d<0) { - d=0; - zp.setMM(b.getTotalY()); - } - double z=d/steps; + LengthParameter zp = new LengthParameter(name + "_CaDoodle_Z-per", 0.0, nopt); +// double d = zp.getMM()-b.getTotalY(); +// if(d<0) { +// d=0; +// zp.setMM(b.getTotalY()); +// } + double z=zp.getMM(); double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); if(angle<0) angle=-angle; @@ -235,7 +235,7 @@ private CSG processGiven( Polygon p, Bounds b, int j, String name) { StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); LengthParameter steps=new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt); LengthParameter angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt); - LengthParameter z=new LengthParameter(name + "_CaDoodle_Z", 0.0, nopt); + LengthParameter z=new LengthParameter(name + "_CaDoodle_Z-per", 0.0, nopt); LengthParameter radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt); parameter.setStrValue(pathname); CSG processedCSG = csg From f8ec4a7b96d6f7f67638ef98bacbdd643b3adc05 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 15:20:49 -0500 Subject: [PATCH 293/635] steps per rotation --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 28ca0920..2e3acd58 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -74,16 +74,17 @@ public static CSG sweep(Polygon p, double angle, double z, double radius, int st return sweep(p,new Transform().rotX(angle).movex(z),new Transform().movey(radius),steps); } public static CSG sweep(Polygon p, String name, Bounds b) { - - int steps=(int)new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM(); - double angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM()/steps; + double sweepTot = new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM(); + double d = sweepTot/360; + int steps=(int)(new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM()*d); + double angle=sweepTot/steps; LengthParameter zp = new LengthParameter(name + "_CaDoodle_Z-per", 0.0, nopt); // double d = zp.getMM()-b.getTotalY(); // if(d<0) { // d=0; // zp.setMM(b.getTotalY()); // } - double z=zp.getMM(); + double z=zp.getMM()*d/steps; double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); if(angle<0) angle=-angle; From 3ba4f280fe78a21808880981233df0769801e1e5 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 11 Jan 2025 15:44:23 -0500 Subject: [PATCH 294/635] set the name of the addFromFile stack --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 805997f0..9a2ae3da 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -157,11 +157,11 @@ public static File getFile(String name) { // return getParameter("UnKnown").getStrValue(); // } - private CSG processGiven(CSG csg, int i, String name) { + private CSG processGiven(CSG csg, int i, String n) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); - String pathname = getFile(name).getAbsolutePath(); + String pathname = getFile(this.name).getAbsolutePath(); - StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); + StringParameter parameter=new StringParameter(n + "_CaDoodle_File", pathname, options); parameter.setStrValue(pathname); CSG processedCSG = csg // .moveToCenterX() @@ -175,12 +175,12 @@ private CSG processGiven(CSG csg, int i, String name) { com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); - return processGiven(csg1, i, name); + return processGiven(csg1, i, n); } catch (Exception e) { e.printStackTrace(); } return previous; - }).setName(name); + }).setName(n); MoveCenter.set(getName(), processedCSG, nrToCSG); return processedCSG; } From 72cdc21dd9e7012a1c2e35eec0e9b02998dd1f44 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 13 Jan 2025 21:25:46 -0500 Subject: [PATCH 295/635] clear dataabases only for this file --- .../scripting/cadoodle/CaDoodleFile.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index be105450..1fe928ad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -115,7 +115,17 @@ public void initialize() { initializing = true; if (selfInternal != null) { File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); - CSGDatabase.clear(); + try { + // set a temp file for the database to clear + // this ensures that parameters are not cleared from another project :/ + File createTempFile = File.createTempFile(projectName, ".json"); + CSGDatabase.setDbFile(createTempFile); + CSGDatabase.clear(); + createTempFile.delete(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } CSGDatabase.setDbFile(db); StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); @@ -700,6 +710,8 @@ public int getCurrentIndex() { public void setCurrentIndex(int currentIndex) { // new Exception("Current Index set to " + currentIndex).printStackTrace(); + if((currentIndex-1)>=opperations.size()) + throw new RuntimeException("Fail! Can not set an index greater than the availible operations"); this.currentIndex = currentIndex; } From feac33014356739970b72043c2d5a2b1a7c184d9 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Mon, 13 Jan 2025 22:14:34 -0500 Subject: [PATCH 296/635] change sweep to use triangles instead of rectangles --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 2e3acd58..88954b25 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -116,9 +116,9 @@ public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) //com.neuronrobotics.sdk.common.Log.error("Skipping invalid polygon "+i+" to "+nexti); continue; } - List pPoints = Arrays.asList(bottomV2, topV2, topV1, bottomV1); try { - newPolygons.add(Polygon.fromPoints(pPoints, polygon1.getStorage())); + newPolygons.add(Polygon.fromPoints(Arrays.asList(bottomV2, topV2, topV1), polygon1.getStorage())); + newPolygons.add(Polygon.fromPoints(Arrays.asList(bottomV2, topV1, bottomV1), polygon1.getStorage())); }catch(Exception ex) { //com.neuronrobotics.sdk.common.Log.error("Polygon has problems: "); ex.printStackTrace(); From bf073181aeccd24412e1668b190a2b81d563e4e8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 15 Jan 2025 14:29:59 -0500 Subject: [PATCH 297/635] Adjusting the parameters for the sweep --- .../scripting/cadoodle/AddFromFile.java | 7 +++ .../scripting/cadoodle/Sweep.java | 50 +++++++++++++++---- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 9a2ae3da..6e65b442 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -121,6 +121,13 @@ public static File toLocal(File file, String name) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFileIncoming = file.getParentFile(); File parentFile = new File(loc.getStrValue()).getParentFile(); +// if(parentFile==null) +// try { +// parentFile=File.createTempFile(name, name).getParentFile(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } String source = parentFile.getAbsolutePath(); if (parentFileIncoming != null) { String parentIncoming = parentFileIncoming.getAbsolutePath(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 88954b25..e65f5957 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -25,7 +25,9 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.Vector3d; import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; +import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import eu.mihosoft.vrl.v3d.svg.SVGLoad; import javafx.scene.paint.Color; @@ -38,6 +40,12 @@ public class Sweep extends AbstractAddFrom{ @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; + private LengthParameter z=null; + private LengthParameter rad=null; + private LengthParameter step=null; + private LengthParameter angle=null; + + public Sweep set(File source) throws Exception { if(!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); @@ -73,19 +81,19 @@ public static CSG sweep(Polygon p, Transform increment, Transform offset, int st public static CSG sweep(Polygon p, double angle, double z, double radius, int steps) { return sweep(p,new Transform().rotX(angle).movex(z),new Transform().movey(radius),steps); } - public static CSG sweep(Polygon p, String name, Bounds b) { - double sweepTot = new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt).getMM(); + public CSG sweep(Polygon p, String name, Bounds b) { + double sweepTot = angle(name).getMM(); double d = sweepTot/360; - int steps=(int)(new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt).getMM()*d); + int steps=(int)(steps(name).getMM()*d); double angle=sweepTot/steps; - LengthParameter zp = new LengthParameter(name + "_CaDoodle_Z-per", 0.0, nopt); + Parameter zp = zoffset(name); // double d = zp.getMM()-b.getTotalY(); // if(d<0) { // d=0; // zp.setMM(b.getTotalY()); // } double z=zp.getMM()*d/steps; - double radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt).getMM(); + double radius=radius(name).getMM(); if(angle<0) angle=-angle; Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY()); @@ -94,6 +102,30 @@ public static CSG sweep(Polygon p, String name, Bounds b) { Polygon transformedP = p.transformed(centerandAllignedPolygon); return sweep(transformedP,increment,radiusT,steps).rotx(-90).setName(name); } + private LengthParameter radius(String name) { + String key = name + "_CaDoodle_Rad"; + if(rad==null) + rad= new LengthParameter(key, 10.0, nopt); + return rad; + } + private LengthParameter zoffset(String name) { + String key = name + "_CaDoodle_Z-per"; + if(z==null) + z= new LengthParameter(key, 0.0, nopt); + return z; + } + private LengthParameter steps(String name) { + String key = name + "_CaDoodle_Step"; + if(step==null) + step= new LengthParameter(key, 30.0, nopt); + return step; + } + private LengthParameter angle(String name) { + String key = name + "_CaDoodle_Angle"; + if(angle==null) + angle= new LengthParameter(key, 360.0, nopt); + return angle; + } public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) { List newPolygons = new ArrayList<>(); // CSG extrude; @@ -234,10 +266,10 @@ private CSG processGiven( Polygon p, Bounds b, int j, String name) { } StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); - LengthParameter steps=new LengthParameter(name + "_CaDoodle_Step", 30.0, nopt); - LengthParameter angle=new LengthParameter(name + "_CaDoodle_Angle", 360.0, nopt); - LengthParameter z=new LengthParameter(name + "_CaDoodle_Z-per", 0.0, nopt); - LengthParameter radius=new LengthParameter(name + "_CaDoodle_Rad", 10.0, nopt); + Parameter steps=steps(name); + Parameter angle=angle(name); + Parameter z=zoffset(name); + Parameter radius=radius(name); parameter.setStrValue(pathname); CSG processedCSG = csg .transformed(nrToCSG).syncProperties(csg) From c65cf4ad97f4506a171070374223fd6aa382859c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 15 Jan 2025 16:40:09 -0500 Subject: [PATCH 298/635] Making sure teh files exist in sweep --- .../scripting/cadoodle/AddFromFile.java | 6 +- .../scripting/cadoodle/Sweep.java | 225 +++++++++--------- 2 files changed, 119 insertions(+), 112 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 6e65b442..c1bc0916 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -132,7 +132,11 @@ public static File toLocal(File file, String name) { if (parentFileIncoming != null) { String parentIncoming = parentFileIncoming.getAbsolutePath(); - if (!parentIncoming.toLowerCase().contentEquals(source.toLowerCase()) && file.exists()) { + String lowerCase = parentIncoming.toLowerCase(); + String lowerCase2 = source.toLowerCase(); + boolean b = !lowerCase.contentEquals(lowerCase2); + boolean exists = file.exists(); + if (b && exists) { File copied; try { copied = copyFileToNewDirectory(file, parentFile, name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index e65f5957..9c607ffe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -32,109 +32,122 @@ import eu.mihosoft.vrl.v3d.svg.SVGLoad; import javafx.scene.paint.Color; -public class Sweep extends AbstractAddFrom{ +public class Sweep extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private TransformNR location = null; private static ArrayList options = new ArrayList(); - private static ArrayList nopt=new ArrayList(); + private static ArrayList nopt = new ArrayList(); @Expose(serialize = true, deserialize = true) - private Boolean preventBoM =false; - - private LengthParameter z=null; - private LengthParameter rad=null; - private LengthParameter step=null; - private LengthParameter angle=null; - - + private Boolean preventBoM = false; + + private LengthParameter z = null; + private LengthParameter rad = null; + private LengthParameter step = null; + private LengthParameter angle = null; + public Sweep set(File source) throws Exception { - if(!source.getName().toLowerCase().endsWith(".svg")) + if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); - AddFromFile.toLocal(source,getName()); + System.out.println("Saving Local Copy of "+source.getAbsolutePath()); + AddFromFile.toLocal(source, getName()); + try { + getFile(); + } catch (Exception ex) { + ex.printStackTrace(); + } return this; } + @Override public String getType() { // TODO Auto-generated method stub return "Sweep"; } - + public static CSG sweep(Polygon p, Transform increment, Transform offset, int steps) { - Polygon offsetP =p.transformed(offset); + Polygon offsetP = p.transformed(offset); List newPolygons = new ArrayList<>(); newPolygons.addAll(PolygonUtil.concaveToConvex(offsetP)); Transform running = new Transform(); - Polygon prev=offsetP; - for(int i=0;i parts = monotoneExtrude(prev,step); - prev=step; + List parts = monotoneExtrude(prev, step); + prev = step; newPolygons.addAll(parts); } Polygon polygon2 = offsetP.transformed(running); List topPolygons = PolygonUtil.concaveToConvex(polygon2.flipped()); newPolygons.addAll(topPolygons); - + return CSG.fromPolygons(newPolygons); } - + public static CSG sweep(Polygon p, double angle, double z, double radius, int steps) { - return sweep(p,new Transform().rotX(angle).movex(z),new Transform().movey(radius),steps); + return sweep(p, new Transform().rotX(angle).movex(z), new Transform().movey(radius), steps); } + public CSG sweep(Polygon p, String name, Bounds b) { double sweepTot = angle(name).getMM(); - double d = sweepTot/360; - int steps=(int)(steps(name).getMM()*d); - double angle=sweepTot/steps; + double d = sweepTot / 360; + int steps = (int) (steps(name).getMM() * d); + double angle = sweepTot / steps; Parameter zp = zoffset(name); // double d = zp.getMM()-b.getTotalY(); // if(d<0) { // d=0; // zp.setMM(b.getTotalY()); // } - double z=zp.getMM()*d/steps; - double radius=radius(name).getMM(); - if(angle<0) - angle=-angle; + double z = zp.getMM() * d / steps; + double radius = radius(name).getMM(); + if (angle < 0) + angle = -angle; Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY()); Transform increment = new Transform().rotY(-angle).movey(z); Transform radiusT = new Transform().movex(radius); Polygon transformedP = p.transformed(centerandAllignedPolygon); - return sweep(transformedP,increment,radiusT,steps).rotx(-90).setName(name); + return sweep(transformedP, increment, radiusT, steps).rotx(-90).setName(name); } + private LengthParameter radius(String name) { String key = name + "_CaDoodle_Rad"; - if(rad==null) - rad= new LengthParameter(key, 10.0, nopt); - return rad; + if (rad == null) + rad = new LengthParameter(key, 10.0, nopt); + return rad; } + private LengthParameter zoffset(String name) { String key = name + "_CaDoodle_Z-per"; - if(z==null) - z= new LengthParameter(key, 0.0, nopt); - return z; + if (z == null) + z = new LengthParameter(key, 0.0, nopt); + return z; } + private LengthParameter steps(String name) { String key = name + "_CaDoodle_Step"; - if(step==null) - step= new LengthParameter(key, 30.0, nopt); - return step; + if (step == null) + step = new LengthParameter(key, 30.0, nopt); + return step; } + private LengthParameter angle(String name) { String key = name + "_CaDoodle_Angle"; - if(angle==null) - angle= new LengthParameter(key, 360.0, nopt); - return angle; + if (angle == null) + angle = new LengthParameter(key, 360.0, nopt); + return angle; } + public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) { List newPolygons = new ArrayList<>(); // CSG extrude; - //polygon1=polygon1.flipped(); - //newPolygons.addAll(PolygonUtil.concaveToConvex(polygon1.flipped())); - //Polygon polygon2 = polygon1.translated(dir); + // polygon1=polygon1.flipped(); + // newPolygons.addAll(PolygonUtil.concaveToConvex(polygon1.flipped())); + // Polygon polygon2 = polygon1.translated(dir); int numvertices = polygon1.vertices.size(); - //com.neuronrobotics.sdk.common.Log.error("Building Polygon "+polygon1.getPoints().size()); + // com.neuronrobotics.sdk.common.Log.error("Building Polygon + // "+polygon1.getPoints().size()); for (int i = 0; i < numvertices; i++) { int nexti = (i + 1) % numvertices; @@ -144,15 +157,16 @@ public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) Vector3d bottomV2 = polygon1.vertices.get(nexti).pos; Vector3d topV2 = polygon2.vertices.get(nexti).pos; double distance = bottomV1.minus(bottomV2).magnitude(); - if(Math.abs(distance) process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); - if(!file.exists()) { + if (!file.exists()) { throw new RuntimeException("Failed to find file"); } - - ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(name )); - HashMap configs =new HashMap(); + + ArrayList args = new ArrayList<>(); + args.addAll(Arrays.asList(name)); + HashMap configs = new HashMap(); configs.put("name", name); configs.put("PreventBomAdd", preventBoM); args.add(configs); - //List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + // List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); SVGLoad s = new SVGLoad(file.toURI()); HashMap> polygons = s.toPolygons(); Object[] array = polygons.keySet().toArray(); - int j =0; - Bounds b=getBounds(polygons); + int j = 0; + Bounds b = getBounds(polygons); for (int i = 0; i < array.length; i++) { - String key = (String)array[i]; - for(Polygon P:polygons.get(key)) { - + String key = (String) array[i]; + for (Polygon P : polygons.get(key)) { + String orderedName = getOrderedName(); - CSG processedCSG = processGiven(P,b,j++, orderedName); + CSG processedCSG = processGiven(P, b, j++, orderedName); collect.add(processedCSG); } } - + back.addAll(collect); } catch (Exception e) { e.printStackTrace(); @@ -216,30 +230,30 @@ public Bounds getBounds(HashMap> polygons) { Vector3d min = null; Vector3d max = null; // TickToc.tic("getSellectedBounds "+incoming.size()); - for(String s:polygons.keySet()) - for (Polygon csg : polygons.get(s)) { - - Bounds b = csg.getBounds(); - Vector3d min2 = b.getMin().clone(); - Vector3d max2 = b.getMax().clone(); - if (min == null) - min = min2; - if (max == null) - max = max2; - if (min2.x < min.x) - min.x = min2.x; - if (min2.y < min.y) - min.y = min2.y; - if (min2.z < min.z) - min.z = min2.z; - if (max.x < max2.x) - max.x = max2.x; - if (max.y < max2.y) - max.y = max2.y; - if (max.z < max2.z) - max.z = max2.z; - // TickToc.tic("Bounds for "+c.getName()); - } + for (String s : polygons.keySet()) + for (Polygon csg : polygons.get(s)) { + + Bounds b = csg.getBounds(); + Vector3d min2 = b.getMin().clone(); + Vector3d max2 = b.getMax().clone(); + if (min == null) + min = min2; + if (max == null) + max = max2; + if (min2.x < min.x) + min.x = min2.x; + if (min2.y < min.y) + min.y = min2.y; + if (min2.z < min.z) + min.z = min2.z; + if (max.x < max2.x) + max.x = max2.x; + if (max.y < max2.y) + max.y = max2.y; + if (max.z < max2.z) + max.z = max2.z; + // TickToc.tic("Bounds for "+c.getName()); + } return new Bounds(min, max); } @@ -249,14 +263,13 @@ public File getFile() throws NoSuchFileException { return AddFromFile.getFile(name); } - - private CSG processGiven( Polygon p, Bounds b, int j, String name) { - Color c=p.getColor(); - if(c==null) - c=Color.ROSYBROWN; + private CSG processGiven(Polygon p, Bounds b, int j, String name) { + Color c = p.getColor(); + if (c == null) + c = Color.ROSYBROWN; boolean hole = p.isHole(); - CSG csg = sweep(p,name,b); - + CSG csg = sweep(p, name, b); + Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); String pathname; try { @@ -265,27 +278,20 @@ private CSG processGiven( Polygon p, Bounds b, int j, String name) { throw new RuntimeException(e); } - StringParameter parameter=new StringParameter(name + "_CaDoodle_File", pathname, options); - Parameter steps=steps(name); - Parameter angle=angle(name); - Parameter z=zoffset(name); - Parameter radius=radius(name); + StringParameter parameter = new StringParameter(name + "_CaDoodle_File", pathname, options); + Parameter steps = steps(name); + Parameter angle = angle(name); + Parameter z = zoffset(name); + Parameter radius = radius(name); parameter.setStrValue(pathname); - CSG processedCSG = csg - .transformed(nrToCSG).syncProperties(csg) - .setParameter(parameter) - .setParameter(steps) - .setParameter(angle) - .setParameter(z) - .setParameter(radius) - .setColor(c) - .setIsHole(hole) + CSG processedCSG = csg.transformed(nrToCSG).syncProperties(csg).setParameter(parameter).setParameter(steps) + .setParameter(angle).setParameter(z).setParameter(radius).setColor(c).setIsHole(hole) .setRegenerate(previous -> { try { File file = getFile(); String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); - return processGiven(p,b, j, name); + return processGiven(p, b, j, name); } catch (Exception e) { e.printStackTrace(); } @@ -306,8 +312,6 @@ public Sweep setLocation(TransformNR location) { return this; } - - public Boolean getPreventBoM() { return preventBoM; } @@ -317,5 +321,4 @@ public Sweep setPreventBoM(Boolean preventBoM) { return this; } - } From 40227ef8e60a3bc738d444dfc490f36a8219318b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 16 Jan 2025 11:40:31 -0500 Subject: [PATCH 299/635] Adding bounds to the sweep parameters. --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 9c607ffe..1db25ff4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -114,6 +114,8 @@ private LengthParameter radius(String name) { String key = name + "_CaDoodle_Rad"; if (rad == null) rad = new LengthParameter(key, 10.0, nopt); + if(rad.getMM()<0) + rad.setMM(0); return rad; } @@ -128,6 +130,8 @@ private LengthParameter steps(String name) { String key = name + "_CaDoodle_Step"; if (step == null) step = new LengthParameter(key, 30.0, nopt); + if(step.getMM()<3) + step.setMM(3); return step; } @@ -135,6 +139,8 @@ private LengthParameter angle(String name) { String key = name + "_CaDoodle_Angle"; if (angle == null) angle = new LengthParameter(key, 360.0, nopt); + if (angle.getMM()<0.001) + angle.setMM(0.001); return angle; } From 457a41fdf970d38bf17be297dc9454c297b1078f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 16 Jan 2025 12:32:40 -0500 Subject: [PATCH 300/635] Moving the sweep code into the Extrude class in JavaCAD --- build.gradle | 2 +- .../scripting/cadoodle/Sweep.java | 71 +------------------ 2 files changed, 2 insertions(+), 71 deletions(-) diff --git a/build.gradle b/build.gradle index 0802beec..856c7d35 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.2.0' + api 'com.neuronrobotics:JavaCad:2.3.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 1db25ff4..4dd898a6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -64,41 +64,12 @@ public String getType() { return "Sweep"; } - public static CSG sweep(Polygon p, Transform increment, Transform offset, int steps) { - Polygon offsetP = p.transformed(offset); - List newPolygons = new ArrayList<>(); - newPolygons.addAll(PolygonUtil.concaveToConvex(offsetP)); - Transform running = new Transform(); - Polygon prev = offsetP; - for (int i = 0; i < steps; i++) { - running.apply(increment); - Polygon step = offsetP.transformed(running); - List parts = monotoneExtrude(prev, step); - prev = step; - newPolygons.addAll(parts); - } - Polygon polygon2 = offsetP.transformed(running); - List topPolygons = PolygonUtil.concaveToConvex(polygon2.flipped()); - newPolygons.addAll(topPolygons); - - return CSG.fromPolygons(newPolygons); - } - - public static CSG sweep(Polygon p, double angle, double z, double radius, int steps) { - return sweep(p, new Transform().rotX(angle).movex(z), new Transform().movey(radius), steps); - } - public CSG sweep(Polygon p, String name, Bounds b) { double sweepTot = angle(name).getMM(); double d = sweepTot / 360; int steps = (int) (steps(name).getMM() * d); double angle = sweepTot / steps; Parameter zp = zoffset(name); -// double d = zp.getMM()-b.getTotalY(); -// if(d<0) { -// d=0; -// zp.setMM(b.getTotalY()); -// } double z = zp.getMM() * d / steps; double radius = radius(name).getMM(); if (angle < 0) @@ -107,7 +78,7 @@ public CSG sweep(Polygon p, String name, Bounds b) { Transform increment = new Transform().rotY(-angle).movey(z); Transform radiusT = new Transform().movex(radius); Polygon transformedP = p.transformed(centerandAllignedPolygon); - return sweep(transformedP, increment, radiusT, steps).rotx(-90).setName(name); + return Extrude.sweep(transformedP, increment, radiusT, steps).rotx(-90).setName(name); } private LengthParameter radius(String name) { @@ -144,47 +115,7 @@ private LengthParameter angle(String name) { return angle; } - public static List monotoneExtrude(Polygon polygon2, Polygon polygon1) { - List newPolygons = new ArrayList<>(); -// CSG extrude; - // polygon1=polygon1.flipped(); - // newPolygons.addAll(PolygonUtil.concaveToConvex(polygon1.flipped())); - // Polygon polygon2 = polygon1.translated(dir); - - int numvertices = polygon1.vertices.size(); - // com.neuronrobotics.sdk.common.Log.error("Building Polygon - // "+polygon1.getPoints().size()); - for (int i = 0; i < numvertices; i++) { - int nexti = (i + 1) % numvertices; - - Vector3d bottomV1 = polygon1.vertices.get(i).pos; - Vector3d topV1 = polygon2.vertices.get(i).pos; - Vector3d bottomV2 = polygon1.vertices.get(nexti).pos; - Vector3d topV2 = polygon2.vertices.get(nexti).pos; - double distance = bottomV1.minus(bottomV2).magnitude(); - if (Math.abs(distance) < Plane.getEPSILON()) { - // com.neuronrobotics.sdk.common.Log.error("Skipping invalid polygon "+i+" to - // "+nexti); - continue; - } - try { - newPolygons.add(Polygon.fromPoints(Arrays.asList(bottomV2, topV2, topV1), polygon1.getStorage())); - newPolygons.add(Polygon.fromPoints(Arrays.asList(bottomV2, topV1, bottomV1), polygon1.getStorage())); - } catch (Exception ex) { - // com.neuronrobotics.sdk.common.Log.error("Polygon has problems: "); - ex.printStackTrace(); - } - } - -// polygon2 = polygon2.flipped(); -// List topPolygons = PolygonUtil.concaveToConvex(polygon2.flipped()); -// -// newPolygons.addAll(topPolygons); -// extrude = CSG.fromPolygons(newPolygons); - - return newPolygons; - } @Override public List process(List incoming) { From 4202a2b69e42fbb954422a25013fb1b8c75642b5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 16 Jan 2025 12:54:53 -0500 Subject: [PATCH 301/635] removing bugged out javacad --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 856c7d35..6aa78891 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.3.0' + api 'com.neuronrobotics:JavaCad:2.3.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 08c0ca24f2298d0a1e2a9bd8b660870ea84dc000 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 17 Jan 2025 08:54:46 -0500 Subject: [PATCH 302/635] Remove the fall-back onto Git based configuratins --- .../assets/ConfigurationDatabase.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index be9e13ea..f450fe7f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -179,25 +179,6 @@ public static File loadFile() { } catch (IOException e) { throw new RuntimeException(e.getMessage()); } - if(!PasswordManager.isAnonMode()) { - String username = PasswordManager.getLoginID(); - if(username!=null) - try { - File file =ScriptingEngine.fileFromGit("https://github.com/"+username+"/BowlerStudioConfiguration.git", "database.json"); - if(file.exists()) { - String contents= FileUtils.readFileToString(file, StandardCharsets.UTF_8); - try (PrintWriter out = new PrintWriter(f.getAbsolutePath())) { - out.println(contents); - } catch (FileNotFoundException e) { - // Auto-generated catch block - e.printStackTrace(); - } - } - } catch (Exception e) { - // Auto-generated catch block - e.printStackTrace(); - } - } } return f; } From 4e1a26dd744f24d263f2786405ae15399b1aa752 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 12 Feb 2025 09:16:30 -0500 Subject: [PATCH 303/635] Make sure tmp STLs are created fast --- .../creature/CadFileExporter.java | 4 +- .../creature/MobileBaseCadManager.java | 490 ++++++++++-------- .../bowlerstudio/scripting/BlenderLoader.java | 4 + .../scripting/DownloadManager.java | 3 + 4 files changed, 270 insertions(+), 231 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 9c4c7a9f..bfca4e98 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -167,8 +167,10 @@ private File makeFreecad(String nameBase,List current ) throws IOException private File makeStl(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".stl"); - + boolean manifold=CSG.isPreventNonManifoldTriangles(); + CSG.setPreventNonManifoldTriangles(false); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); + CSG.setPreventNonManifoldTriangles(manifold); System.out.println("Writing "+stl.getAbsolutePath()); return stl; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index dc4be7d3..30a25db5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -75,10 +75,9 @@ public class MobileBaseCadManager implements Runnable { private HashMap> DHtoCadMap = new HashMap<>(); private HashMap> LinktoCadMap = new HashMap<>(); private HashMap> BasetoCadMap = new HashMap<>(); - private HashMap vitaminCad=new HashMap<>(); - private HashMap vitaminDisplay=new HashMap<>(); - private HashMap vitaminLocation=new HashMap<>(); - + private HashMap vitaminCad = new HashMap<>(); + private HashMap vitaminDisplay = new HashMap<>(); + private HashMap vitaminLocation = new HashMap<>(); private boolean cadGenerating = false; private boolean showingStl = false; @@ -95,36 +94,39 @@ public class MobileBaseCadManager implements Runnable { private Thread renderWrangler = null; private HashMap cadScriptCache = new HashMap<>(); private static ArrayList toRun = new ArrayList(); - private ArrayList rendersync=new ArrayList<>(); + private ArrayList rendersync = new ArrayList<>(); private boolean forceChage = true; + public CSG getVitamin(VitaminLocation vitamin) throws Exception { - return getVitamin(vitamin,new Affine(),null); + return getVitamin(vitamin, new Affine(), null); } - public ArrayList getVitamins(IVitaminHolder link,Affine manipulator) { + public ArrayList getVitamins(IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getVitamins(); - return toVitaminCad(vitamins,manipulator,null); + return toVitaminCad(vitamins, manipulator, null); } - public ArrayList getOriginVitamins(IVitaminHolder link,Affine manipulator,TransformNR offset){ + + public ArrayList getOriginVitamins(IVitaminHolder link, Affine manipulator, TransformNR offset) { ArrayList vitamins = link.getOriginVitamins(); - return toVitaminCad(vitamins,manipulator,offset); + return toVitaminCad(vitamins, manipulator, offset); } - public ArrayList getDefaultVitamins(IVitaminHolder link,Affine manipulator){ + + public ArrayList getDefaultVitamins(IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getDefaultVitamins(); - return toVitaminCad(vitamins,manipulator,null); + return toVitaminCad(vitamins, manipulator, null); } - public ArrayList getPreviousLinkVitamins(IVitaminHolder link,Affine manipulator){ + + public ArrayList getPreviousLinkVitamins(IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getPreviousLinkVitamins(); - return toVitaminCad(vitamins,manipulator,null); + return toVitaminCad(vitamins, manipulator, null); } - - private ArrayList toVitaminCad(ArrayList vitamins,Affine manipulator, TransformNR offset) { + private ArrayList toVitaminCad(ArrayList vitamins, Affine manipulator, TransformNR offset) { ArrayList parts = new ArrayList(); - for(VitaminLocation vi:vitamins) { + for (VitaminLocation vi : vitamins) { CSG vitamin; try { - vitamin = getVitamin(vi,manipulator,offset); + vitamin = getVitamin(vi, manipulator, offset); parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block @@ -133,30 +135,30 @@ private ArrayList toVitaminCad(ArrayList vitamins,Affine m } return parts; } - - + public ArrayList getVitamins(AbstractLink link) { LinkConfiguration conf = link.getLinkConfiguration(); return getVitamins(conf, (Affine) link.getGlobalPositionListener()); } - - public ArrayList getVitamins(AbstractLink link,Affine manipulator) { + public ArrayList getVitamins(AbstractLink link, Affine manipulator) { LinkConfiguration conf = link.getLinkConfiguration(); return getVitamins(conf, manipulator); } + public ArrayList getVitamins(MobileBase base) { Affine rootListener = (Affine) base.getRootListener(); return getVitamins(base, rootListener); } - public CSG getVitamin(VitaminLocation vitamin,Affine manipulator,TransformNR offset) { - if(!vitaminCad.containsKey(vitamin)) { + + public CSG getVitamin(VitaminLocation vitamin, Affine manipulator, TransformNR offset) { + if (!vitaminCad.containsKey(vitamin)) { CSG starting; try { CSG origin = vitaminMakeCSG(vitamin); - starting=origin.transformed(TransformFactory.nrToCSG(vitamin.getLocation())); - if(offset!=null) - starting=starting.transformed(TransformFactory.nrToCSG(offset)); + starting = origin.transformed(TransformFactory.nrToCSG(vitamin.getLocation())); + if (offset != null) + starting = starting.transformed(TransformFactory.nrToCSG(offset)); starting.setIsWireFrame(true); starting.syncProperties(origin); } catch (Exception e) { @@ -171,23 +173,24 @@ public CSG getVitamin(VitaminLocation vitamin,Affine manipulator,TransformNR off } public static CSG vitaminMakeCSG(VitaminLocation vitamin) throws Exception { - if(vitamin.isScript()) { - Object o =ScriptingEngine.gitScriptRun(vitamin.getType(), vitamin.getSize()); - ArrayList flat= new ArrayList(); - Vitamins.flatten(flat,o); - return CSG.unionAll( flat); - }else + if (vitamin.isScript()) { + Object o = ScriptingEngine.gitScriptRun(vitamin.getType(), vitamin.getSize()); + ArrayList flat = new ArrayList(); + Vitamins.flatten(flat, o); + return CSG.unionAll(flat); + } else return Vitamins.get(vitamin.getType(), vitamin.getSize()); } - public CSG getVitaminDisplay(VitaminLocation vitamin,Affine manipulator, TransformNR offset){ - if(!vitaminDisplay.containsKey(vitamin)) { + + public CSG getVitaminDisplay(VitaminLocation vitamin, Affine manipulator, TransformNR offset) { + if (!vitaminDisplay.containsKey(vitamin)) { CSG starting; Affine offsetDisplay = new Affine(); try { starting = vitaminMakeCSG(vitamin); - if(offset!=null){ - BowlerKernel.runLater(()->{ - TransformFactory.nrToAffine(offset,offsetDisplay); + if (offset != null) { + BowlerKernel.runLater(() -> { + TransformFactory.nrToAffine(offset, offsetDisplay); }); } } catch (Exception e) { @@ -196,11 +199,11 @@ public CSG getVitaminDisplay(VitaminLocation vitamin,Affine manipulator, Transfo return null; } starting.setManipulator(manipulator); - Affine frameOffset=new Affine(); - Affine cameraFrame=new Affine(); + Affine frameOffset = new Affine(); + Affine cameraFrame = new Affine(); setFrames(vitamin, frameOffset, cameraFrame); vitaminLocation.put(vitamin, cameraFrame); - vitamin.addChangeListener(()->{ + vitamin.addChangeListener(() -> { setFrames(vitamin, frameOffset, cameraFrame); }); @@ -211,6 +214,7 @@ public CSG getVitaminDisplay(VitaminLocation vitamin,Affine manipulator, Transfo } return vitaminDisplay.get(vitamin); } + private void setFrames(VitaminLocation vitamin, Affine frameOffset, Affine cameraFrame) { BowlerKernel.runLater(() -> { TransformNR translationComponent = vitamin.getLocation().copy().setRotation(new RotationNR()); @@ -222,38 +226,41 @@ private void setFrames(VitaminLocation vitamin, Affine frameOffset, Affine camer public Affine getVitaminAffine(VitaminLocation vitamin) { Affine a = vitaminLocation.get(vitamin); - if(a!=null) + if (a != null) return a; - throw new RuntimeException("Affine not present! "+vitamin.getName()); + throw new RuntimeException("Affine not present! " + vitamin.getName()); } - - public ArrayList getOriginVitaminsDisplay(IVitaminHolder link,Affine manipulator,TransformNR offset){ + + public ArrayList getOriginVitaminsDisplay(IVitaminHolder link, Affine manipulator, TransformNR offset) { ArrayList vitamins = link.getOriginVitamins(); - return vitaminsToDisplay(vitamins,manipulator,offset); + return vitaminsToDisplay(vitamins, manipulator, offset); } - public ArrayList getDefaultVitaminsDisplay(IVitaminHolder link,Affine manipulator){ + + public ArrayList getDefaultVitaminsDisplay(IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getDefaultVitamins(); - return vitaminsToDisplay(vitamins,manipulator); + return vitaminsToDisplay(vitamins, manipulator); } - public ArrayList getPreviousLinkVitaminsDisplay(IVitaminHolder link,Affine manipulator){ + + public ArrayList getPreviousLinkVitaminsDisplay(IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getPreviousLinkVitamins(); - return vitaminsToDisplay(vitamins,manipulator); + return vitaminsToDisplay(vitamins, manipulator); } - - public ArrayList getVitaminsDisplay(IVitaminHolder link,Affine manipulator) { - - return vitaminsToDisplay(link.getVitamins(),manipulator); + + public ArrayList getVitaminsDisplay(IVitaminHolder link, Affine manipulator) { + + return vitaminsToDisplay(link.getVitamins(), manipulator); } - - public ArrayList vitaminsToDisplay(ArrayList l,Affine manipulator){ - return vitaminsToDisplay(l,manipulator,null); + + public ArrayList vitaminsToDisplay(ArrayList l, Affine manipulator) { + return vitaminsToDisplay(l, manipulator, null); } - public ArrayList vitaminsToDisplay(ArrayList l,Affine manipulator, TransformNR offset){ + + public ArrayList vitaminsToDisplay(ArrayList l, Affine manipulator, TransformNR offset) { ArrayList parts = new ArrayList(); - for(VitaminLocation vi:l) { + for (VitaminLocation vi : l) { CSG vitamin; try { - vitamin = getVitaminDisplay(vi,manipulator, offset); + vitamin = getVitaminDisplay(vi, manipulator, offset); parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block @@ -262,161 +269,168 @@ public ArrayList vitaminsToDisplay(ArrayList l,Affine mani } return parts; } - + public ArrayList getVitaminsDisplay(AbstractLink link) { LinkConfiguration conf = link.getLinkConfiguration(); return getVitaminsDisplay(conf, (Affine) link.getGlobalPositionListener()); } - public ArrayList getVitaminsDisplay(AbstractLink link,Affine manipulator) { + + public ArrayList getVitaminsDisplay(AbstractLink link, Affine manipulator) { LinkConfiguration conf = link.getLinkConfiguration(); return getVitaminsDisplay(conf, manipulator); } - public ArrayList getVitaminsDisplay(MobileBase base) { Affine rootListener = (Affine) base.getRootListener(); return getVitaminsDisplay(base, rootListener); } - + public void render() { run(); - forceChage=true; - while(forceChage) + forceChage = true; + while (forceChage) ThreadUtil.wait(1); } + public void addIRenderSynchronizationEvent(IRenderSynchronizationEvent ev) { - if(rendersync.contains(ev)) + if (rendersync.contains(ev)) return; rendersync.add(ev); } + public void removeIRenderSynchronizationEvent(IRenderSynchronizationEvent ev) { - if(rendersync.contains(ev)) + if (rendersync.contains(ev)) rendersync.remove(ev); } - + private void fireIRenderSynchronizationEvent() { - for(int i=0;ihighest.x) - highest.x=high.x; - if(high.y>highest.y) - highest.y=high.y; - if(high.z>highest.z) - highest.z=high.z; + + if (highest == null) + highest = high; + if (high.x > highest.x) + highest.x = high.x; + if (high.y > highest.y) + highest.y = high.y; + if (high.z > highest.z) + highest.z = high.z; } - for(DHParameterKinematics k:cat.getAllDHChains()) { - for(int i=0;ihighest.x) - highest.x=high.x; - if(high.y>highest.y) - highest.y=high.y; - if(high.z>highest.z) - highest.z=high.z; + + if (highest == null) + highest = high; + if (high.x > highest.x) + highest.x = high.x; + if (high.y > highest.y) + highest.y = high.y; + if (high.z > highest.z) + highest.z = high.z; } } } return highest; } + public Vector3d computeLowestPoint() { render(); - MobileBase cat=base; + MobileBase cat = base; MobileBaseCadManager cadMan = MobileBaseCadManager.get(cat); - Vector3d lowest =null; - Affine l =(Affine) cat.getRootListener(); + Vector3d lowest = null; + Affine l = (Affine) cat.getRootListener(); TransformNR tmp = TransformFactory.affineToNr(l); Transform baseloc = TransformFactory.nrToCSG(tmp); - for(CSG c:cadMan.getBasetoCadMap().get(cat)) { + for (CSG c : cadMan.getBasetoCadMap().get(cat)) { CSG moved = c.transformed(baseloc); double z = moved.getMinZ(); - double y= moved.getMinY(); - double x=moved.getMinX(); + double y = moved.getMinY(); + double x = moved.getMinX(); Vector3d low = new Vector3d(x, y, z); - - if(lowest==null) - lowest=low; - if(low.xnew Affine[size]); - TransformNR[] vals = tmp.values().stream().toArray(size->new TransformNR[size]); + Affine[] iterator = tmp.keySet().stream().toArray(size -> new Affine[size]); + TransformNR[] vals = tmp.values().stream().toArray(size -> new TransformNR[size]); tmp.clear(); if (iterator.length > 0) { BowlerKernel.runLater(() -> { @@ -635,7 +650,8 @@ public void run() { } } catch (Throwable t) { // rendering not availible - com.neuronrobotics.sdk.common.Log.error("Exception for render engine " + base.getScriptingName()); + com.neuronrobotics.sdk.common.Log + .error("Exception for render engine " + base.getScriptingName()); t.printStackTrace(); try { Thread.sleep(100); @@ -643,17 +659,18 @@ public void run() { break; } } - + } renderWrangler = null; } + private void addConfL(MobileBase base, ILinkConfigurationChangeListener confL2) { - if(base==null) + if (base == null) return; - for(DHParameterKinematics k:base.getAllDHChains()) { - for(int i=0;i map2, HashMap jointPoses) { - TransformNR back =updateBase(b, baseLoc, map2); + TransformNR back = updateBase(b, baseLoc, map2); for (DHParameterKinematics k : b.getAllDHChains()) { updateLimb(k, back, map2, jointPoses); } @@ -691,7 +708,7 @@ private void updateMobileBase(MobileBase b, TransformNR baseLoc, HashMap map2, HashMap jointPoses) { - //updateBase(k, baseLoc, map2); + // updateBase(k, baseLoc, map2); TransformNR previous = k.getFiducialToGlobalTransform(); k.setGlobalToFiducialTransform(baseLoc, false); ArrayList ll = k.getChain().getChain(jointPoses.get(k)); @@ -719,8 +736,8 @@ private void updateLimb(DHParameterKinematics k, TransformNR baseLoc, HashMap { + Object cadForBodyEngine = scriptFromFileInfo(b.getScriptingName(), b.getGitCadEngine(), () -> { run(); generateCad(); }); @@ -868,10 +885,10 @@ private IgenerateBody getIgenerateBody(MobileBase b) throws Throwable{ return null; } - private IgenerateCad getIgenerateCad(DHParameterKinematics dh) throws Throwable{ + private IgenerateCad getIgenerateCad(DHParameterKinematics dh) throws Throwable { if (isConfigMode()) return getConfigurationDisplay(); - Object cadForBodyEngine = scriptFromFileInfo(dh.getScriptingName(),dh.getGitCadEngine(), () -> { + Object cadForBodyEngine = scriptFromFileInfo(dh.getScriptingName(), dh.getGitCadEngine(), () -> { run(); generateCad(); }); @@ -881,8 +898,8 @@ private IgenerateCad getIgenerateCad(DHParameterKinematics dh) throws Throwable{ return null; } - public IgenerateBed getIgenerateBed() throws Throwable{ - Object cadForBodyEngine = scriptFromFileInfo(base.getScriptingName(),base.getGitCadEngine(), () -> { + public IgenerateBed getIgenerateBed() throws Throwable { + Object cadForBodyEngine = scriptFromFileInfo(base.getScriptingName(), base.getGitCadEngine(), () -> { run(); }); if (IgenerateBed.class.isInstance(cadForBodyEngine)) { @@ -891,10 +908,10 @@ public IgenerateBed getIgenerateBed() throws Throwable{ return null; } - private ICadGenerator getConfigurationDisplay()throws Throwable { + private ICadGenerator getConfigurationDisplay() throws Throwable { if (cadEngineConfiguration == null) { - String[] args = new String[] { - "https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy" }; + String[] args = new String[] { "https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", + "dhcad.groovy" }; Object cadForBodyEngine = scriptFromFileInfo("ConfigDisplay", args, () -> { cadEngineConfiguration = null; try { @@ -936,7 +953,7 @@ public ArrayList generateBody(MobileBase base, boolean clear) { getAllCad().clear(); setAllCad(new ArrayList<>()); } - //System.gc(); + // System.gc(); MobileBase device = base; if (getBasetoCadMap().get(device) == null) { getBasetoCadMap().put(device, new ArrayList()); @@ -976,7 +993,7 @@ public ArrayList generateBody(MobileBase base, boolean clear) { ArrayList arrayList = getBasetoCadMap().get(device); if (clear) { arrayList.clear(); - //System.gc(); + // System.gc(); } for (CSG c : getAllCad()) { arrayList.add(c); @@ -1017,7 +1034,7 @@ public ArrayList generateBody(MobileBase base, boolean clear) { } else { if (clear) { arrayList.clear(); - //System.gc(); + // System.gc(); } ArrayList linksCad = generateCad(l); @@ -1039,7 +1056,7 @@ public ArrayList generateBody(MobileBase base, boolean clear) { getAllCad().addAll(m.generateBody(m.base, false)); } showingStl = false; - //setProgress(1); + // setProgress(1); // PhysicsEngine.clear(); // MobileBasePhysicsManager m = new MobileBasePhysicsManager(base, // baseCad, getSimplecad()); @@ -1078,7 +1095,8 @@ private void set(MobileBase base, int limb, int link) { DHParameterKinematics dh = limbs.get(limb); double partsTotal = numLimbs * dh.getNumberOfLinks(); double progress = ((double) ((limb * dh.getNumberOfLinks()) + link)) / partsTotal; - // com.neuronrobotics.sdk.common.Log.error("Cad progress " + progress + " limb " + limb + " link " + + // com.neuronrobotics.sdk.common.Log.error("Cad progress " + progress + " limb " + // + limb + " link " + // link + " total parts " + partsTotal); setProgress(0.333 + (2 * (progress / 3))); } @@ -1099,46 +1117,46 @@ public ArrayList generateStls(MobileBase base, File baseDirForFiles, boole File dir = new File(baseDirForFiles.getAbsolutePath() + "/" + base.getScriptingName()); if (!dir.exists()) dir.mkdirs(); - IgenerateBed bed=null; + IgenerateBed bed = null; String baseURL = base.getGitSelfSource()[0]; File baseWorkspaceFile = ScriptingEngine.getRepositoryCloneDirectory(baseURL); bed = getPrintBed(dir, bed, baseWorkspaceFile); if (bed == null || kinematic) { return _generateStls(base, dir, kinematic); } - + com.neuronrobotics.sdk.common.Log.error("Found arrangeBed API in CAD engine"); List totalAssembly = bed.arrangeBed(base); getUi().setAllCSG(totalAssembly, getCadScriptFromMobileBase(base)); - return new CadFileExporter(getUi()).generateManufacturingParts(totalAssembly, dir); } + public IgenerateBed getPrintBed(File baseDirForFiles, IgenerateBed bed, File baseWorkspaceFile) throws IOException { - File bomCSV = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.getManufacturingBomCsv()); - if(bomCSV.exists()) { - - File file = new File(baseDirForFiles.getAbsolutePath()+"/bom.csv"); - if(file.exists()) + File bomCSV = new File(baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomCsv()); + if (bomCSV.exists()) { + + File file = new File(baseDirForFiles.getAbsolutePath() + "/bom.csv"); + if (file.exists()) file.delete(); - Files.copy(bomCSV.toPath(),file.toPath()); + Files.copy(bomCSV.toPath(), file.toPath()); } - File bom = new File(baseWorkspaceFile.getAbsolutePath()+"/"+VitaminBomManager.getManufacturingBomJson()); - if(bom.exists()) { - File file = new File(baseDirForFiles.getAbsolutePath()+"/bom.json"); - if(file.exists()) + File bom = new File(baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomJson()); + if (bom.exists()) { + File file = new File(baseDirForFiles.getAbsolutePath() + "/bom.json"); + if (file.exists()) file.delete(); - Files.copy(bom.toPath(),file.toPath()); + Files.copy(bom.toPath(), file.toPath()); } - try{ - bed= getIgenerateBed(); - }catch(Throwable T) { + try { + bed = getIgenerateBed(); + } catch (Throwable T) { throw new RuntimeException(T.getMessage()); } - if(bed == null) { - File printArrangment = new File(baseWorkspaceFile.getAbsolutePath()+"/"+PrintBedManager.file); - if(printArrangment.exists()) { - bed = new UserManagedPrintBed(printArrangment,this); + if (bed == null) { + File printArrangment = new File(baseWorkspaceFile.getAbsolutePath() + "/" + PrintBedManager.file); + if (printArrangment.exists()) { + bed = new UserManagedPrintBed(printArrangment, this); } } return bed; @@ -1178,24 +1196,30 @@ public ArrayList _generateStls(MobileBase base, File baseDirForFiles, bool else totalAssembly.add(tmp); LinkConfiguration conf = getLinkConfiguration(parts.get(j)); - if(conf!=null) { + if (conf != null) { String linkNum = conf.getLinkIndex() + "_Link_"; - + File dir = new File(baseDirForFiles.getAbsolutePath() + "/" + base.getScriptingName() + "/" + l.getScriptingName()); if (!dir.exists()) dir.mkdirs(); - - File stl = new File( - dir.getAbsolutePath() + "/" + linkNum + name + "_limb_" + i + "_Part_" + j + ".stl"); - com.neuronrobotics.sdk.common.Log.error("Writing STL for " + name+" to "+stl.getAbsolutePath()); + + File stl = new File(dir.getAbsolutePath() + "/" + linkNum + name + "_limb_" + i + "_Part_" + + j + ".stl"); + com.neuronrobotics.sdk.common.Log + .error("Writing STL for " + name + " to " + stl.getAbsolutePath()); + boolean manifold = CSG.isPreventNonManifoldTriangles(); + //CSG.setPreventNonManifoldTriangles(false); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); + + CSG.setPreventNonManifoldTriangles(manifold); allCadStl.add(stl); // totalAssembly.add(tmp); getUi().setAllCSG(totalAssembly, getCadScriptFromMobileBase(base)); set(base, i, j); - }else { - com.neuronrobotics.sdk.common.Log.error("ERROR "+parts.get(j).getName()+" has no link associated "); + } else { + com.neuronrobotics.sdk.common.Log + .error("ERROR " + parts.get(j).getName() + " has no link associated "); } } } catch (Exception ex) { @@ -1270,7 +1294,7 @@ public void setMobileBase(MobileBase b) { for (DHParameterKinematics k : base.getAllDHChains()) { k.setRenderWrangler(this); } - base.setConfigurationUpdate(()->{ + base.setConfigurationUpdate(() -> { generateCad(); }); run(); @@ -1421,9 +1445,11 @@ public void selectCsgByLink(MobileBase base, LinkConfiguration limb) { com.neuronrobotics.sdk.common.Log.error("Limb not loaded yet"); } } + public void generateCad() { - generateCadWithEnd((Runnable)null); + generateCadWithEnd((Runnable) null); } + public void generateCadWithEnd(Runnable done) { if (cadGenerating || !getAutoRegen()) return; @@ -1449,7 +1475,7 @@ public void run() { try { setAllCad(generateBody(device, true)); } catch (Exception e) { - + getUi().highlightException(getCadScriptFromMobileBase(device), e); } @@ -1468,10 +1494,10 @@ public void run() { e.printStackTrace(); } setProgress(1); - if(done!=null) { + if (done != null) { try { done.run(); - }catch(Throwable t) { + } catch (Throwable t) { t.printStackTrace(); } } @@ -1479,12 +1505,14 @@ public void run() { } }.start(); } + private void setProgress(double val) { - if(cadGenerating==false) { - val=1; + if (cadGenerating == false) { + val = 1; } getProcesIndictor().set(val); } + public void onTabClosing() { } @@ -1533,8 +1561,6 @@ public static MobileBaseCadManager get(MobileBase device, IMobileBaseUI ui) { return mobileBaseCadManager; } - - public static MobileBaseCadManager get(MobileBase device) { if (cadmap.get(device) == null) { for (MobileBase mb : cadmap.keySet()) { @@ -1640,22 +1666,26 @@ public void setConfigurationViewerMode(boolean b) { m.setConfigurationViewerMode(b); } } + public void invalidateModelCache() { // Auto-generated method stub - + } + /** * @return the configMode */ public boolean isConfigMode() { return configMode; } + /** * @param configMode the configMode to set */ public void setConfigMode(boolean configMode) { this.configMode = configMode; } + public boolean isCADstarted() { // Auto-generated method stub return cadGenerating; @@ -1663,32 +1693,32 @@ public boolean isCADstarted() { public static MobileBaseCadManager get(IVitaminHolder holder) { Set keySet = cadmap.keySet(); - for(MobileBase b:keySet) { - MobileBaseCadManager m =checkforBase(holder, b); - if (m!=null) + for (MobileBase b : keySet) { + MobileBaseCadManager m = checkforBase(holder, b); + if (m != null) return m; } return null; } + private static MobileBaseCadManager checkforBase(IVitaminHolder holder, MobileBase b) { - if(b==holder) + if (b == holder) return get(b); - for(DHParameterKinematics k:b.getAllDHChains()) { - for(int i=0;i Date: Wed, 12 Feb 2025 10:33:03 -0500 Subject: [PATCH 304/635] Update the jcsg --- build.gradle | 2 +- .../neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6aa78891..c2ea1ab3 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.3.1' + api 'com.neuronrobotics:JavaCad:2.4.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java index 00d9cf60..ec3de2d0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/CSGPhysicsManager.java @@ -83,7 +83,7 @@ protected CSG loadCSGToPoints(CSG baseCSG, boolean adjustCenter, Transform pose, //if(polygons.size()>1000) // polygons = getBoundingBox(finalCSG).getPolygons(); for (Polygon p : polygons) { - for (Vertex v : p.vertices) { + for (Vertex v : p.getVertices()) { arg0.add(new Vector3f((float) v.getX(), (float) v.getY(), (float) v.getZ())); } } From c072290b71c475b6c032275cbc4bed59280d9fd0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 12 Feb 2025 11:38:04 -0500 Subject: [PATCH 305/635] Make sure the file extention of the file matches a supported file format --- .../bowlerstudio/scripting/ScriptingEngine.java | 11 ++++++++++- .../scripting/cadoodle/AddFromFile.java | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 948a310d..0ce6063d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -2087,7 +2087,16 @@ public static List getAllLangauges() { } return langs; } - + public static List getAllExtentions() { + ArrayList langs = new ArrayList<>(); + for (String L : getLangaugesMap().keySet()) { + IScriptingLanguage lang = getLangaugesMap().get(L); + for(String s:lang.getFileExtenetion()) { + langs.add(s); + } + } + return langs; + } public static HashMap getLangaugesMap() { return langauges; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index c1bc0916..9251ea90 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -33,8 +33,13 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation @Expose(serialize = true, deserialize = true) private Boolean preventBoM =false; public AddFromFile set(File source) { - toLocal(source,getName()); - return this; + for(String s:ScriptingEngine.getAllExtentions()) { + if(source.getName().toLowerCase().endsWith(s.toLowerCase())) { + toLocal(source,getName()); + return this; + } + } + throw new RuntimeException("File Extention not supported: "+source.getName()); } @Override @@ -156,8 +161,12 @@ public static File getFile(String name) { File parentFile = new File(loc.getStrValue()).getParentFile(); for(String f:parentFile.list()) { if(f.contains(name)) { - String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; - return new File(pathname); + for(String s:ScriptingEngine.getAllExtentions()) { + if(f.toLowerCase().endsWith(s.toLowerCase())) { + String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; + return new File(pathname); + } + } } } throw new RuntimeException("File not found! "+name); From 2af732e62234b92598931f207615c1a1bfc41a6a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 13:44:38 -0500 Subject: [PATCH 306/635] getter for vitamins dataabase --- .../bowlerstudio/vitamins/Vitamins.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 80f869fa..7fe470c5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -141,7 +141,7 @@ public static CSG get(String type, String id, String purchasingVariant) throws E } catch (Exception e) { e.printStackTrace(); - gitRpoDatabase = defaultgitRpoDatabase; + setGitRepoDatabase(defaultgitRpoDatabase); clear(); return get(type, id); } @@ -224,7 +224,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception } } catch (Exception e) { e.printStackTrace(); - gitRpoDatabase = defaultgitRpoDatabase; + setGitRepoDatabase(defaultgitRpoDatabase); //ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); if (depthGauge < 2) { @@ -345,7 +345,7 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { GHRepository newRepo = repo.fork(); Thread.sleep(6000); - Vitamins.gitRpoDatabase = newRepo.getGitTransportUrl().replaceAll("git://", "https://"); + Vitamins.setGitRepoDatabase(newRepo.getGitTransportUrl().replaceAll("git://", "https://")); saveDatabase(type); } @@ -646,16 +646,16 @@ public static String getGitRepoDatabase() { } catch (Exception ex) { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); } - ScriptingEngine.cloneRepo(gitRpoDatabase, "master"); + ScriptingEngine.cloneRepo(getGitRpoDatabase(), "master"); try { - ScriptingEngine.pull(gitRpoDatabase); + ScriptingEngine.pull(getGitRpoDatabase()); } catch (IOException | GitAPIException e) { - ScriptingEngine.deleteRepo(gitRpoDatabase); - ScriptingEngine.cloneRepo(gitRpoDatabase, "master"); + ScriptingEngine.deleteRepo(getGitRpoDatabase()); + ScriptingEngine.cloneRepo(getGitRpoDatabase(), "master"); } } - return gitRpoDatabase; + return getGitRpoDatabase(); } public static void reLoadDatabaseFromFiles() { @@ -679,7 +679,7 @@ public static void reLoadDatabaseFromFiles() { } public static void setGitRepoDatabase(String gitRpoDatabase) { - Vitamins.gitRpoDatabase = gitRpoDatabase; + Vitamins.gitRpoDatabase=gitRpoDatabase; databaseSet.clear(); fileLastLoaded.clear(); @@ -694,4 +694,9 @@ public static void setJsonRootDir(String jsonRootDir) throws IOException { setGitRepoDatabase(getGitRepoDatabase()); } + public static String getGitRpoDatabase() { + return gitRpoDatabase; + } + + } From f0d212da3e95c752f54ce7d6a275972e1aaae93d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 15:18:52 -0500 Subject: [PATCH 307/635] Adding getters for the sourece urls' --- .../bowlerstudio/assets/AssetFactory.java | 2 +- .../bowlerstudio/vitamins/Vitamins.java | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 7991aeb2..0b227df2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -167,7 +167,7 @@ public static void loadAllAssets() throws Exception { try { files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); }catch(Exception ex) { - files = ScriptingEngine.filesInGit(gitSource); + files = ScriptingEngine.filesInGit(getGitSource()); } for (String file : files) { com.neuronrobotics.sdk.common.Log.error("Loading asset file: "+file); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 7fe470c5..78bafb2c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -646,16 +646,16 @@ public static String getGitRepoDatabase() { } catch (Exception ex) { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); } - ScriptingEngine.cloneRepo(getGitRpoDatabase(), "master"); + ScriptingEngine.cloneRepo(getGitRepoDatabase(), "master"); try { - ScriptingEngine.pull(getGitRpoDatabase()); + ScriptingEngine.pull(getGitRepoDatabase()); } catch (IOException | GitAPIException e) { - ScriptingEngine.deleteRepo(getGitRpoDatabase()); - ScriptingEngine.cloneRepo(getGitRpoDatabase(), "master"); + ScriptingEngine.deleteRepo(getGitRepoDatabase()); + ScriptingEngine.cloneRepo(getGitRepoDatabase(), "master"); } } - return getGitRpoDatabase(); + return getGitRepoDatabase(); } public static void reLoadDatabaseFromFiles() { @@ -694,9 +694,4 @@ public static void setJsonRootDir(String jsonRootDir) throws IOException { setGitRepoDatabase(getGitRepoDatabase()); } - public static String getGitRpoDatabase() { - return gitRpoDatabase; - } - - } From 382964baa817f85525c543e379dc9597458a26a3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 15:24:34 -0500 Subject: [PATCH 308/635] remove the recoursinve loop --- .../neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 78bafb2c..fd0ddc65 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -646,16 +646,16 @@ public static String getGitRepoDatabase() { } catch (Exception ex) { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); } - ScriptingEngine.cloneRepo(getGitRepoDatabase(), "master"); + ScriptingEngine.cloneRepo(gitRpoDatabase, "master"); try { - ScriptingEngine.pull(getGitRepoDatabase()); + ScriptingEngine.pull(gitRpoDatabase); } catch (IOException | GitAPIException e) { - ScriptingEngine.deleteRepo(getGitRepoDatabase()); - ScriptingEngine.cloneRepo(getGitRepoDatabase(), "master"); + ScriptingEngine.deleteRepo(gitRpoDatabase); + ScriptingEngine.cloneRepo(gitRpoDatabase, "master"); } } - return getGitRepoDatabase(); + return gitRpoDatabase; } public static void reLoadDatabaseFromFiles() { From 9b7fcbdbe5934033f9878fac935a6a97337255c8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 15:48:49 -0500 Subject: [PATCH 309/635] close #445 --- .../neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index fd0ddc65..2c0871c3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -310,7 +310,7 @@ public static String makeJson(String type) { return gson.toJson(getDatabase(type), TT_mapStringString); } - public static void saveDatabase(String type) throws Exception { + public static boolean saveDatabase(String type) throws Exception { // Save contents and publish them String jsonString = makeJson(type); @@ -325,13 +325,13 @@ public static void saveDatabase(String type) throws Exception { // message // com.neuronrobotics.sdk.common.Log.error(jsonString); com.neuronrobotics.sdk.common.Log.error("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); - } catch (org.eclipse.jgit.api.errors.TransportException ex) { + } catch (Exception ex) { com.neuronrobotics.sdk.common.Log.error("You need to fork " + defaultgitRpoDatabase + " to have permission to save"); com.neuronrobotics.sdk.common.Log.error( "You do not have permission to push to this repo, change the GIT repo to your fork with setGitRpoDatabase(String gitRpoDatabase) "); throw ex; } - + return true; } public static void saveDatabaseForkIfMissing(String type) throws Exception { @@ -340,7 +340,7 @@ public static void saveDatabaseForkIfMissing(String type) throws Exception { GHRepository repo = github.getRepository("madhephaestus/Hardware-Dimensions"); try { saveDatabase(type); - } catch (org.eclipse.jgit.api.errors.TransportException ex) { + } catch (Exception ex) { com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); GHRepository newRepo = repo.fork(); From 62ed8eac1029ebdcb2facf0dc7a78bb53b0a14ea Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 16:35:33 -0500 Subject: [PATCH 310/635] remove issue reporting https://github.com/CommonWealthRobotics/BowlerStudio/issues/445 --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 0ce6063d..dd2677d3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -440,7 +440,7 @@ public static void openGit(Repository localRepo, IGitAccessor accessor) { if(!alreadyOpen) gitclose(git); } catch (Throwable t) { - new IssueReportingExceptionHandler().except(t); + //new IssueReportingExceptionHandler().except(t); if (git != null) { gitclose(git); } From b36a2f4b9cc815ce8920f3fbc4819daf2f591c71 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 15 Feb 2025 16:45:44 -0500 Subject: [PATCH 311/635] https://github.com/CommonWealthRobotics/BowlerStudio/issues/445 --- .../bowlerstudio/scripting/ScriptingEngine.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index dd2677d3..2fd05733 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -434,16 +434,18 @@ public static void openGit(Repository localRepo, IGitAccessor accessor) { try { accessor.run(git); } catch (Throwable t) { - new IssueReportingExceptionHandler().except(t); + //new IssueReportingExceptionHandler().except(t); + throw new RuntimeException(t); } } if(!alreadyOpen) gitclose(git); } catch (Throwable t) { //new IssueReportingExceptionHandler().except(t); - if (git != null) { - gitclose(git); - } + if(!alreadyOpen) + if (git != null) { + gitclose(git); + } throw new RuntimeException(t); } } From 8533601ff035b3a8c111d5bb31da70f9e4ae3699 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 20 Feb 2025 16:08:23 -0500 Subject: [PATCH 312/635] remove incorrect manafod forcing --- .../bowlerstudio/creature/CadFileExporter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index bfca4e98..9bcd296f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -167,10 +167,10 @@ private File makeFreecad(String nameBase,List current ) throws IOException private File makeStl(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".stl"); - boolean manifold=CSG.isPreventNonManifoldTriangles(); - CSG.setPreventNonManifoldTriangles(false); +// boolean manifold=CSG.isPreventNonManifoldTriangles(); +// CSG.setPreventNonManifoldTriangles(false); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); - CSG.setPreventNonManifoldTriangles(manifold); + //CSG.setPreventNonManifoldTriangles(manifold); System.out.println("Writing "+stl.getAbsolutePath()); return stl; } From 54539bfeee04142dbfe79dbe480f1cbc4eaf216d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 23 Feb 2025 10:20:03 -0500 Subject: [PATCH 313/635] update the jcsg to remove excessive prints --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c2ea1ab3..72e19455 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.4.0' + api 'com.neuronrobotics:JavaCad:2.4.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From b7508ca6e2aea91b683fbcc445dfd5c2e591f2ee Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 24 Feb 2025 09:22:36 -0500 Subject: [PATCH 314/635] change the filename geter --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1fe928ad..977a96ae 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -145,7 +145,7 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - // pruneForward(); + pruneForward(); indexStarting = i; break; } @@ -567,7 +567,7 @@ private void fireWorkplaneChange() { } } - public String getProjectName() { + public String getMyProjectName() { return projectName; } @@ -674,7 +674,7 @@ public static String getProjectName(File f) throws Exception { com.neuronrobotics.sdk.common.Log.error("CaDoodle file reading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, null, f, false); - return file.getProjectName(); + return file.getMyProjectName(); } public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boolean initialize) throws Exception { From 5442872043e644c67fb22823fe1bf8511ad256d2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 27 Feb 2025 13:33:15 -0500 Subject: [PATCH 315/635] make variables viable to debugger --- .../bowlerstudio/assets/ConfigurationDatabase.java | 3 ++- .../bowlerstudio/scripting/ScriptingEngine.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index f450fe7f..444d86bd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -157,7 +157,8 @@ public static void getDatabase() { File loadFile = loadFile(); if(loadFile.exists()) try { - database = Collections.synchronizedMap((HashMap>) ScriptingEngine.inlineFileScriptRun(loadFile, null)); + Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(loadFile, null); + database = Collections.synchronizedMap((HashMap>) inlineFileScriptRun); } catch (Exception e) { // databse is empty diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 2fd05733..8663c5b0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -499,8 +499,9 @@ public static Object inlineScriptRun(File code, ArrayList args, String s // com.neuronrobotics.sdk.common.Log.error("Loading "+code.getAbsolutePath()); } - if (langauges.get(shellTypeStorage) != null) { - return langauges.get(shellTypeStorage).inlineScriptRun(code, args); + IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); + if (iScriptingLanguage != null) { + return iScriptingLanguage.inlineScriptRun(code, args); } return null; } From 31541fbd4d5c8167009a70de3996fe6e0da02db6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 2 Mar 2025 16:51:28 -0500 Subject: [PATCH 316/635] updating JCSG --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 72e19455..f81b313e 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.4.1' + api 'com.neuronrobotics:JavaCad:2.5.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From a37aae616f9ce16864cbfeb5389ee29af1a6694f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 17 Mar 2025 14:35:37 -0400 Subject: [PATCH 317/635] add arm support for mujoco --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f81b313e..cda60576 100755 --- a/build.gradle +++ b/build.gradle @@ -287,7 +287,7 @@ dependencies { //MuJoCo implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.7' - implementation group: 'com.neuronrobotics', name: 'mujoco-java', version:'3.1.3-pre.11' + implementation group: 'com.neuronrobotics', name: 'mujoco-java', version:'3.1.3-pre.16' // https://mvnrepository.com/artifact/org.robokind/org.robokind.api.speech implementation group: 'org.robokind', name: 'org.robokind.api.speech', version: '0.9.5' From 0c8ea6239887e92a3323354f775ac47cae3e8890 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 17 Mar 2025 14:58:52 -0400 Subject: [PATCH 318/635] Make sure the copy takes place when file is missing --- .../bowlerstudio/scripting/ScriptingEngine.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 8663c5b0..b994c777 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -2164,6 +2164,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi } String[] newFileCode; try { + System.out.println("Opening "+targetFilename+" from "+targetGit); newFileCode = ScriptingEngine.codeFromGit(targetGit, targetFilename); if (newFileCode == null) newFileCode = new String[] { "" }; @@ -2173,7 +2174,8 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi WalkingEngine[0], "copy file content"); } } catch (Exception e) { - throw new RuntimeException(e); + ScriptingEngine.pushCodeToGit(targetGit, ScriptingEngine.getFullBranch(targetGit), targetFilename, + WalkingEngine[0], "copy file content"); } } catch (Exception e1) { throw new RuntimeException(e1); From 6d45fc20c2829da367936906d9245aaf035da9cc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 11:36:47 -0400 Subject: [PATCH 319/635] Repairing the Vitamins add feature --- .../bowlerstudio/vitamins/Vitamins.java | 141 +++++++++++------- 1 file changed, 84 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 2c0871c3..3f5fa806 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -57,8 +57,9 @@ public class Vitamins { private static String jsonRootDir = "json/"; private static final Map fileLastLoaded = new ConcurrentHashMap(); private static final Map>> databaseSet = new ConcurrentHashMap>>(); - private static final String defaultgitRpoDatabase = "https://github.com/madhephaestus/Hardware-Dimensions.git"; - private static String gitRpoDatabase = defaultgitRpoDatabase; + private static final String sourceRepo = "CommonWealthRobotics/Hardware-Dimensions"; + private static final String defaultGit = "https://github.com/" + getSourcerepo() + ".git"; + private static String gitRpoDatabase = defaultGit; // Create the type, this tells GSON what datatypes to instantiate when parsing // and saving the json private static Type TT_mapStringString = new TypeToken>>() { @@ -141,7 +142,7 @@ public static CSG get(String type, String id, String purchasingVariant) throws E } catch (Exception e) { e.printStackTrace(); - setGitRepoDatabase(defaultgitRpoDatabase); + setGitRepoDatabase(gitRpoDatabase); clear(); return get(type, id); } @@ -224,7 +225,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception } } catch (Exception e) { e.printStackTrace(); - setGitRepoDatabase(defaultgitRpoDatabase); + setGitRepoDatabase(gitRpoDatabase); //ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); if (depthGauge < 2) { @@ -270,7 +271,7 @@ public static File getScriptFile(String type) { } public static Map getMeta(String type) { - return getConfigurationRW(type, "meta"); + return getConfiguration(type, "meta"); } public static void setScript(String type, String git, String file) throws Exception { @@ -279,11 +280,23 @@ public static void setScript(String type, String git, String file) throws Except } public static Map getConfiguration(String type, String id) { - return Collections.unmodifiableMap(getConfigurationRW(type, id)); + ConcurrentHashMap> database = getDatabase(type); + if (id== null) { + id=Vitamins.listVitaminSizes(type).get(0); + } + + ConcurrentHashMap ConcurrentHashMap = database.get(id); + Object[] array = ConcurrentHashMap.keySet().toArray(); + for (int i = 0; i < array.length; i++) { + String key = (String) array[i]; + sanatize(key, ConcurrentHashMap); + } + return Collections.unmodifiableMap(ConcurrentHashMap); } public static void putMeasurment(String type, String size, String measurementName, Object measurmentValue) { - getConfigurationRW(type, size).put(measurementName, measurmentValue); + ConcurrentHashMap configurationRW = getConfigurationRW(type, size); + configurationRW.put(measurementName, measurmentValue); } public static Object getMeasurement(String type, String size, String measurementName) { @@ -292,11 +305,16 @@ public static Object getMeasurement(String type, String size, String measurement public static ConcurrentHashMap getConfigurationRW(String type, String id) { ConcurrentHashMap> database = getDatabase(type); - if (database.get(id) == null) { + if (id == null) { id=Vitamins.listVitaminSizes(type).get(0); } ConcurrentHashMap ConcurrentHashMap = database.get(id); + if(ConcurrentHashMap == null) { + ConcurrentHashMap=new ConcurrentHashMap (); + + database.put(id, ConcurrentHashMap); + } Object[] array = ConcurrentHashMap.keySet().toArray(); for (int i = 0; i < array.length; i++) { String key = (String) array[i]; @@ -316,8 +334,9 @@ public static boolean saveDatabase(String type) throws Exception { String jsonString = makeJson(type); try { // new Exception().printStackTrace(); - ScriptingEngine.pushCodeToGit(getGitRepoDatabase(), // git repo, change this if you fork this demo - ScriptingEngine.getFullBranch(getGitRepoDatabase()), // branch or tag + String gitRepoDatabase = getGitRepoDatabase(); + ScriptingEngine.pushCodeToGit(gitRepoDatabase, // git repo, change this if you fork this demo + null, // branch or tag getRootFolder() + type + ".json", // local path to the file in git jsonString, // content of the file "Making changes to " + type + " by " + PasswordManager.getUsername() @@ -326,68 +345,72 @@ public static boolean saveDatabase(String type) throws Exception { // com.neuronrobotics.sdk.common.Log.error(jsonString); com.neuronrobotics.sdk.common.Log.error("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error("You need to fork " + defaultgitRpoDatabase + " to have permission to save"); - com.neuronrobotics.sdk.common.Log.error( - "You do not have permission to push to this repo, change the GIT repo to your fork with setGitRpoDatabase(String gitRpoDatabase) "); + if(ex.getMessage().contains("Cannot commit on a repo with state: MERGING")) { + ScriptingEngine.deleteRepo(getGitRepoDatabase()); + saveDatabase(type); + return true; + } + ex.printStackTrace(); throw ex; } return true; } - public static void saveDatabaseForkIfMissing(String type) throws Exception { + public static void saveDatabaseForkIfMissing(String type,String username) throws Exception { org.kohsuke.github.GitHub github = PasswordManager.getGithub(); - GHRepository repo = github.getRepository("madhephaestus/Hardware-Dimensions"); + GHRepository repo = github.getRepository(getSourcerepo()); + GHRepository newRepo; try { - saveDatabase(type); + newRepo=github.getRepository(username+"/Hardware-Dimensions"); + String newURL = newRepo.getGitTransportUrl().replaceAll("git://", "https://"); + ScriptingEngine.pull(newURL); + ArrayList files = ScriptingEngine.filesInGit(newURL); + if(type!=null) + saveDatabase(type); } catch (Exception ex) { + ex.printStackTrace(); com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); - GHRepository newRepo = repo.fork(); - Thread.sleep(6000); - Vitamins.setGitRepoDatabase(newRepo.getGitTransportUrl().replaceAll("git://", "https://")); - saveDatabase(type); - - } - if (PasswordManager.getUsername().contentEquals("madhephaestus")) - return; - try { - GHRepository myrepo = github.getRepository(PasswordManager.getUsername() + "/Hardware-Dimensions"); - List asList1 = myrepo.queryPullRequests().state(GHIssueState.OPEN) - .head("madhephaestus:master").list().asList(); - Thread.sleep(200);// Some asynchronus delay here, not sure why... - if (asList1.size() == 0) { + newRepo = github.getRepository(getSourcerepo()).fork(); + while(true) { try { - GHPullRequest request = myrepo.createPullRequest("Update from source", "madhephaestus:master", - "master", "## Upstream add vitamins", false, false); - if (request != null) { - processSelfPR(request); - } - } catch (org.kohsuke.github.HttpException ex) { - // no commits have been made to master + Thread.sleep(6000); + String newURL = newRepo.getGitTransportUrl().replaceAll("git://", "https://"); + Vitamins.setGitRepoDatabase(newURL); + break; + }catch(Exception exc) { + System.err.println("Waiting for repo to finish forking"); + exc.printStackTrace(); } - - } else { - processSelfPR(asList1.get(0)); } - String head = PasswordManager.getUsername() + ":master"; - List asList = repo.queryPullRequests().state(GHIssueState.OPEN).head(head).list().asList(); - if (asList.size() == 0) { - com.neuronrobotics.sdk.common.Log.error("Creating PR for " + head); - GHPullRequest request = repo.createPullRequest("User Added vitamins to " + type, head, "master", - "## User added vitamins", true, true); - try { - BowlerKernel.upenURL(request.getHtmlUrl().toURI()); - } catch (URISyntaxException e) { - // Auto-generated catch block - e.printStackTrace(); - } - } else { + saveDatabase(type); - } - } catch (Exception ex) { - new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); } + +// try { +// GHRepository myrepo = github.getRepository(username+ "/Hardware-Dimensions"); +// List asList1 = myrepo.queryPullRequests().state(GHIssueState.OPEN) +// .head("madhephaestus:master").list().asList(); +// Thread.sleep(200);// Some asynchronus delay here, not sure why... +// if (asList1.size() == 0) { +// try { +// GHPullRequest request = myrepo.createPullRequest("Update from source", "madhephaestus:master", +// "master", "## Upstream add vitamins", false, false); +// if (request != null) { +// processSelfPR(request); +// } +// } catch (org.kohsuke.github.HttpException ex) { +// // no commits have been made to master +// } +// +// } else { +// processSelfPR(asList1.get(0)); +// } +// +// } catch (Exception ex) { +// new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); +// } } @@ -640,7 +663,7 @@ public static String getGitRepoDatabase() { throw new org.kohsuke.github.GHFileNotFoundException(); } } catch (Exception ex) { - setGitRepoDatabase(defaultgitRpoDatabase); + setGitRepoDatabase(defaultGit); } } } catch (Exception ex) { @@ -694,4 +717,8 @@ public static void setJsonRootDir(String jsonRootDir) throws IOException { setGitRepoDatabase(getGitRepoDatabase()); } + public static String getSourcerepo() { + return sourceRepo; + } + } From 8147bbb46db6a3194d5b3247d1f5648654726818 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 11:42:19 -0400 Subject: [PATCH 320/635] sanatize measurements as they are set --- .../java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 3f5fa806..3d76161b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -297,6 +297,7 @@ public static Map getConfiguration(String type, String id) { public static void putMeasurment(String type, String size, String measurementName, Object measurmentValue) { ConcurrentHashMap configurationRW = getConfigurationRW(type, size); configurationRW.put(measurementName, measurmentValue); + sanatize(measurementName, configurationRW); } public static Object getMeasurement(String type, String size, String measurementName) { From 417bdb7db71757243a2fad7e0cbf34308a47df32 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:00:22 -0400 Subject: [PATCH 321/635] Repairing the cadoodle file unit tests and the mujoco test --- .../scripting/cadoodle/CaDoodleFile.java | 64 +++++++++++++------ test/java/src/junit/bowler/MuJoCoTest.java | 1 - .../junit/bowler/TestCaDoodleWorkflow.java | 8 ++- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 977a96ae..0617fc52 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -32,6 +32,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.IParametric; @@ -166,6 +167,8 @@ public void initialize() { } private void updateBoM() { + if (bom == null) + return; bom.clear(); bom.save(); for (CSG c : getCurrentState()) { @@ -264,10 +267,10 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } public Thread regenerateCurrent() { - if (isOperationRunning() ) { + if (isOperationRunning()) { return opperationRunner; } - if(initializing) { + if (initializing) { Thread t = new Thread(); t.start(); return t; @@ -413,13 +416,27 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { throw new RuntimeException( "There can not be 2 objects with the same name after an opperation! " + c.getName()); names.add(c.getName()); -// cachedCopy.add(c.clone().setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) -// .setRegenerate(c.getRegenerate())); - cachedCopy.add(c); + cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) + .setRegenerate(c.getRegenerate())); + //cachedCopy.add(c); } cache.put(op, cachedCopy); } - + private CSG cloneCSG(CSG in) { + CSG csg = new CSG(); + ArrayList collect = new ArrayList(); + for (Polygon p : in.getPolygons()) { + if (p == null) + continue; + try { + collect.add(p); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + csg.setPolygons(collect); + return csg; + } public void back() { if (isBackAvailible()) setCurrentIndex(getCurrentIndex() - 1); @@ -593,17 +610,21 @@ public File save() throws IOException { File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); setImage(null); loadingImageFromUIThread(); - BufferedImage bufferedImage = SwingFXUtils.fromFXImage(getImage(), null); - try { - ImageIO.write(bufferedImage, "png", image); - // com.neuronrobotics.sdk.common.Log.error("Thumbnail saved successfully to " + - // image.getAbsolutePath()); - } catch (IOException e) { - // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + - // e.getMessage()); - e.printStackTrace(); + + WritableImage image2 = getImage(); + if (image2 != null) { + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); + try { + ImageIO.write(bufferedImage, "png", image); + // com.neuronrobotics.sdk.common.Log.error("Thumbnail saved successfully to " + + // image.getAbsolutePath()); + } catch (IOException e) { + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + + // e.getMessage()); + e.printStackTrace(); + } } - if(bom!=null) + if (bom != null) bom.save(); } @@ -622,7 +643,7 @@ public WritableImage loadImageFromFile() { } else { loadingImageFromUIThread(); } - } catch (IOException e) { + } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error loading image: " + e.getMessage()); e.printStackTrace(); } @@ -630,7 +651,12 @@ public WritableImage loadImageFromFile() { } private void loadingImageFromUIThread() { - BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); + try { + BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); + } catch (Throwable ex) { + ex.printStackTrace(); + return; + } while (getImage() == null) try { Thread.sleep(16); @@ -710,7 +736,7 @@ public int getCurrentIndex() { public void setCurrentIndex(int currentIndex) { // new Exception("Current Index set to " + currentIndex).printStackTrace(); - if((currentIndex-1)>=opperations.size()) + if ((currentIndex - 1) >= opperations.size()) throw new RuntimeException("Fail! Can not set an index greater than the availible operations"); this.currentIndex = currentIndex; } diff --git a/test/java/src/junit/bowler/MuJoCoTest.java b/test/java/src/junit/bowler/MuJoCoTest.java index d52631c0..f24d1a8c 100644 --- a/test/java/src/junit/bowler/MuJoCoTest.java +++ b/test/java/src/junit/bowler/MuJoCoTest.java @@ -10,7 +10,6 @@ public class MuJoCoTest { @Test public void test() { com.neuronrobotics.sdk.common.Log.error("mujocoJNILoadTest"); - com.neuronrobotics.sdk.common.Log.error(System.getProperty("org.bytedeco.javacpp.logger.debug")); System.setProperty("org.bytedeco.javacpp.logger.debug", "true"); MuJoCoLib lib = new MuJoCoLib(); diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java index 6a672e77..780a0ebd 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/TestCaDoodleWorkflow.java @@ -72,7 +72,8 @@ public void test() throws Exception { back=cf.getCurrentState(); if(back.size()!=2) fail("Same number of objects after"); - if(back.get(1).getCenterX()!=distaance) + double centerX = back.get(1).getCenterX(); + if(centerX!=distaance) fail("Move failed "); if(back.get(0).getCenterX()!=0) fail("Move misapplied "); @@ -102,9 +103,10 @@ public void test() throws Exception { back=loaded.getCurrentState(); loaded.addOpperation(move2).join();; back=loaded.getCurrentState(); - if(back.get(0).getCenterX()!=distaance) + double centerX2 = back.get(1).getCenterX(); + if(centerX2!=distaance) fail("Move failed "); - if(back.get(0).getCenterY()!=distaance) + if(back.get(1).getCenterY()!=distaance) fail("Move failed "); ToHole hole= new ToHole().setNames(Arrays.asList(nameOne)); loaded.addOpperation(hole).join();; From 11c1781071e121cacacd267167b0703b78c20d8c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:16:05 -0400 Subject: [PATCH 322/635] adding deps for the gpu to run --- .github/workflows/verify.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 989e74ff..3e20efe2 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -15,6 +15,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Install updated FreeType + run: | + sudo apt-get update + sudo apt-get install libfreetype6 + freetype-config --version # For debugging, check version - name: Checkout repository and submodules uses: actions/checkout@v2 with: From 4eab7158fccf7b13613e5dc4a27ea37bcefa27e4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:17:11 -0400 Subject: [PATCH 323/635] use sw rendering --- .github/workflows/verify.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 3e20efe2..173e5b7c 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -64,17 +64,17 @@ jobs: run: cat /home/runner/work/bowler-script-kernel/bowler-script-kernel/build/reports/tests/test/index.html - name: Test Bezier - run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.verbose=true -Dprism.forceGPU=true -jar build/libs/bowler-kernel.jar -g https://gist.github.com/4aeeaa49bd3a807eed8f8ff3dea84c48.git BezierEditorDemo.groovy + run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.order=sw -Dprism.verbose=true -jar build/libs/bowler-kernel.jar -g https://gist.github.com/4aeeaa49bd3a807eed8f8ff3dea84c48.git BezierEditorDemo.groovy - name: start xvfb run: Xvfb :0 & - name: Test Local - run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.verbose=true -Dprism.forceGPU=true -jar build/libs/bowler-kernel.jar -f kernel-return-test.groovy + run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.order=sw -Dprism.verbose=true -jar build/libs/bowler-kernel.jar -f kernel-return-test.groovy - name: Clean Cad run: rm -rf $HOME/bowler-workspace/gitcache/github.com/Hephaestus-Arm/HephaestusArm2 - name: build Cad - run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.verbose=true -Dprism.forceGPU=true -jar build/libs/bowler-kernel.jar -g https://github.com/Hephaestus-Arm/HephaestusArm2.git hephaestus.xml + run: xvfb-run -s '-screen 0 1024x768x24' java -Dprism.order=sw -Dprism.verbose=true -jar build/libs/bowler-kernel.jar -g https://github.com/Hephaestus-Arm/HephaestusArm2.git hephaestus.xml From b7c0b2b95d07d1e0fbf6e7d562b094f1fb711926 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:19:48 -0400 Subject: [PATCH 324/635] Update verify.yml --- .github/workflows/verify.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 173e5b7c..372e1db7 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -16,10 +16,7 @@ jobs: steps: - name: Install updated FreeType - run: | - sudo apt-get update - sudo apt-get install libfreetype6 - freetype-config --version # For debugging, check version + run: sudo apt-get update;sudo apt-get install libfreetype6;freetype-config --version # For debugging, check version - name: Checkout repository and submodules uses: actions/checkout@v2 with: From 1e3c9af603acf2426cd05e0fcd19da83b82b6c1f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:24:34 -0400 Subject: [PATCH 325/635] fix workflow --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 372e1db7..83ec2621 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Install updated FreeType - run: sudo apt-get update;sudo apt-get install libfreetype6;freetype-config --version # For debugging, check version + run: sudo apt-get update;sudo apt-get install libfreetype6 - name: Checkout repository and submodules uses: actions/checkout@v2 with: From 6a5b2f61f601186f3a1fb75e282c3bb3b0dbc98b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:32:16 -0400 Subject: [PATCH 326/635] run on older image --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 83ec2621..5c3655ea 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Install updated FreeType From 4979fd756642a4c0ed679b50f9ad81858ec136c1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:35:28 -0400 Subject: [PATCH 327/635] update jvm --- .github/workflows/verify.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5c3655ea..16af6782 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Install updated FreeType @@ -39,7 +39,7 @@ jobs: export DISPLAY=:0 - name: Pull a JavaFX JDK - run: wget http://static.azul.com/zulu/bin/zulu8.33.0.1-ca-fx-jdk8.0.192-linux_x64.tar.gz + run: wget http://static.azul.com/zulu/bin/zulu8.78.0.19-ca-fx-jdk8.0.412-linux_x64.tar.gz - name: After JDK download, list directory contnts run: pwd; ls -la @@ -48,7 +48,7 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - jdkFile: ./zulu8.33.0.1-ca-fx-jdk8.0.192-linux_x64.tar.gz + jdkFile: ./zulu8.78.0.19-ca-fx-jdk8.0.412-linux_x64.tar.gz - name: Build with Gradle From 37956f807de36f2ad32f334863dac01097fc4e8b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 13:52:47 -0400 Subject: [PATCH 328/635] make sure the cad parts list can not be made null --- .../bowlerstudio/creature/MobileBaseCadManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 30a25db5..807f0ad2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -991,6 +991,11 @@ public ArrayList generateBody(MobileBase base, boolean clear) { } else getUi().highlightException(null, new Exception()); ArrayList arrayList = getBasetoCadMap().get(device); + if (arrayList== null) { + arrayList=new ArrayList(); + getBasetoCadMap().put(device, arrayList); + } + if (clear) { arrayList.clear(); // System.gc(); From 7a64bf0e70df397f533d781e158f2b48e2585706 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 18 Mar 2025 16:51:27 -0400 Subject: [PATCH 329/635] Adding depenancies for Java 17 --- build.gradle | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cda60576..b43161c6 100755 --- a/build.gradle +++ b/build.gradle @@ -287,7 +287,19 @@ dependencies { //MuJoCo implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.7' - implementation group: 'com.neuronrobotics', name: 'mujoco-java', version:'3.1.3-pre.16' + implementation group: 'com.neuronrobotics', name: 'mujoco-java', version:'3.1.3-pre.17' + //Java17 update + // JAXB API + implementation 'javax.xml.bind:jaxb-api:2.3.1' + + // JAXB Implementation + implementation 'com.sun.xml.bind:jaxb-impl:2.3.1' + + // JAXB Core + implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1' + + // Java Activation needed by JAXB + implementation 'javax.activation:javax.activation-api:1.2.0' // https://mvnrepository.com/artifact/org.robokind/org.robokind.api.speech implementation group: 'org.robokind', name: 'org.robokind.api.speech', version: '0.9.5' From 0ed5152d89e3433a8bf0487359dc39b42a881cde Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 19 Mar 2025 12:38:04 -0400 Subject: [PATCH 330/635] make the download directories paraametric wherever they are used --- .../bowlerstudio/scripting/DownloadManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 5eb07e75..9814cf8d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -69,8 +69,9 @@ import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream; public class DownloadManager { + private static String STUDIO_INSTALL = "BowlerStudioInstall"; private static String editorsURL = "https://github.com/CommonWealthRobotics/ExternalEditorsBowlerStudio.git"; - private static String bindir = System.getProperty("user.home") + delim()+"bin"+delim()+"BowlerStudioInstall"+delim(); + private static String bindir = System.getProperty("user.home") + delim()+"bin"+delim()+getSTUDIO_INSTALL()+delim(); private static int ev = 0; private static String cmd = ""; private static IDownloadManagerEvents downloadEvents = new IDownloadManagerEvents() { @@ -1045,5 +1046,11 @@ public static void setDownloadEvents(IDownloadManagerEvents de) { if(downloadEvents!=null) downloadEvents = de; } + public static String getSTUDIO_INSTALL() { + return STUDIO_INSTALL; + } + public static void setSTUDIO_INSTALL(String sTUDIO_INSTALL) { + STUDIO_INSTALL = sTUDIO_INSTALL; + } } From 49a54d859a24ed6ae761b7e6e36fc5f84a863c6e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 19 Mar 2025 14:09:40 -0400 Subject: [PATCH 331/635] restoring the parameters to the clone --- .../scripting/cadoodle/CaDoodleFile.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 0617fc52..ef4f1fee 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import javax.imageio.ImageIO; @@ -422,10 +423,11 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { } cache.put(op, cachedCopy); } - private CSG cloneCSG(CSG in) { + private CSG cloneCSG(CSG dyingCSG) { CSG csg = new CSG(); + ArrayList collect = new ArrayList(); - for (Polygon p : in.getPolygons()) { + for (Polygon p : dyingCSG.getPolygons()) { if (p == null) continue; try { @@ -435,6 +437,22 @@ private CSG cloneCSG(CSG in) { } } csg.setPolygons(collect); + Set params = dyingCSG.getParameters(); + for (String param : params) { + boolean existing = false; + for (String s : csg.getParameters()) { + if (s.contentEquals(param)) + existing = true; + } + if (!existing) { + Parameter vals = CSGDatabase.get(param); + if (vals != null) + csg.setParameter(vals, dyingCSG.getMapOfparametrics().get(param)); + } + } + if (csg.getName().length() == 0) + csg.setName(dyingCSG.getName()); + csg.setColor(dyingCSG.getColor()); return csg; } public void back() { From b1c14da3f365686272f084f1464322e07b9fcd5e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 29 Mar 2025 10:49:39 -0400 Subject: [PATCH 332/635] Adding intersection to the group opperation as an option --- .../scripting/cadoodle/Group.java | 85 ++++++++++++------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 5c139816..bf3fd083 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -13,12 +13,15 @@ import javafx.scene.paint.Color; public class Group extends AbstractAddFrom implements ICaDoodleOpperation { - @Expose (serialize = true, deserialize = true) + @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); - @Expose (serialize = true, deserialize = true) - public String groupID=null; - @Expose (serialize = true, deserialize = true) - public boolean hull=false; + @Expose(serialize = true, deserialize = true) + public String groupID = null; + @Expose(serialize = true, deserialize = true) + public boolean hull = false; + @Expose(serialize = true, deserialize = true) + public boolean intersect = false; + @Override public String getType() { return "Group"; @@ -31,51 +34,57 @@ public List process(List incoming) { ArrayList back = new ArrayList(); ArrayList replace = new ArrayList(); back.addAll(incoming); - for(CSG csg: incoming) { - if(csg.isLock()) + for (CSG csg : incoming) { + if (csg.isLock()) continue; - for(String name:names) { - if(name.contentEquals(csg.getName())) { + for (String name : names) { + if (name.contentEquals(csg.getName())) { replace.add(csg); - CSG c=csg.clone().syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); - if(csg.isHole()) { + CSG c = csg.clone().syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + if (csg.isHole()) { holes.add(c); - }else + } else solids.add(c); c.addGroupMembership(getGroupID()); back.add(c); } } } - for(CSG c:replace) { + for (CSG c : replace) { back.remove(c); } - CSG result =null; - if(holes.size()>0&&solids.size()==0) { + CSG result = null; + if (holes.size() > 0 && solids.size() == 0) { result = CSG.unionAll(holes); - if(hull) - result=result.hull(); + if (hull) + result = result.hull(); result.setIsHole(true); - }else { - CSG holecutter =null; - if(holes.size()>0) { - holecutter=CSG.unionAll(holes); - if(hull) - holecutter=holecutter.hull(); + } else { + CSG holecutter = null; + if (holes.size() > 0) { + if (intersect) + holecutter = intersect(holes); + else + holecutter = CSG.unionAll(holes); + if (hull) + holecutter = holecutter.hull(); } - result = CSG.unionAll(solids); + if (intersect) + result = intersect(solids); + else + result = CSG.unionAll(solids); Color c = result.getColor(); - if(hull) { - result=result.hull(); + if (hull) { + result = result.hull(); } - if(holecutter!=null) - result=result.difference(holecutter); + if (holecutter != null) + result = result.difference(holecutter); result.setIsHole(false); result.setColor(c); } HashMap mapOfparametrics = result.getMapOfparametrics(); - if(mapOfparametrics!=null) + if (mapOfparametrics != null) mapOfparametrics.clear(); result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); @@ -84,6 +93,14 @@ public List process(List incoming) { return back; } + private CSG intersect(ArrayList solids) { + CSG first = solids.get(0); + for(int i=1;i getNames() { return names; } @@ -94,15 +111,21 @@ public Group setNames(List names) { } public String getGroupID() { - if(groupID==null) - groupID=RandomStringFactory.generateRandomString(); + if (groupID == null) + groupID = RandomStringFactory.generateRandomString(); return groupID; } + public Group setIntersect(boolean intersect) { + this.intersect = intersect; + return this; + } + public Group setHull(boolean hull) { this.hull = hull; return this; } + @Override public File getFile() throws NoSuchFileException { throw new NoSuchFileException(null); From 847773bfb6d81ad4b88a536703a7948dddc7eb7d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 29 Mar 2025 15:17:37 -0400 Subject: [PATCH 333/635] Adding comments --- .../scripting/DownloadManager.java | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 9814cf8d..017e9092 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -933,15 +933,28 @@ public static String discoverKey() { } return key; } - - public static File download(String version, String downloadJsonURL, long sizeOfJson, String bindir, String filename, + /** + * + * @param version A string indicating version, this will be the folder name + * @param URL The direct URL of the download + * @param sizeOfFile The number of bytes in the file + * @param directoryInWhichFileIsStored The root directory into which this will all be downloaded + * @param filename The resulting filename + * @param downloadName User level name for asking about the download + * @return + * @throws MalformedURLException + * @throws IOException + * @throws FileNotFoundException + * @throws InterruptedException + */ + public static File download(String version, String URL, long sizeOfFile, String directoryInWhichFileIsStored, String filename, String downloadName) throws MalformedURLException, IOException, FileNotFoundException, InterruptedException { - URL url = new URL(downloadJsonURL); + URL url = new URL(URL); URLConnection connection = url.openConnection(); InputStream is = connection.getInputStream(); - ProcessInputStream pis = new ProcessInputStream(is, (int) sizeOfJson); + ProcessInputStream pis = new ProcessInputStream(is, (int) sizeOfFile); pis.addListener(new Listener() { long timeSinceePrint = System.currentTimeMillis(); @@ -962,28 +975,16 @@ public void process(double percent) { if (!folder.exists() || !exe.exists()) { - if (approval.get(downloadName, downloadJsonURL)) { + if (approval.get(downloadName, URL)) { com.neuronrobotics.sdk.common.Log.error("Start Downloading " + filename); - com.neuronrobotics.sdk.common.Log.error("From "+downloadJsonURL); + com.neuronrobotics.sdk.common.Log.error("From "+URL); } else { pis.close(); throw new RuntimeException("No Application insalled"); } downloadEvents.startDownload(); - folder.mkdirs(); - exe.createNewFile(); - byte dataBuffer[] = new byte[1024*1000]; - int bytesRead; - FileOutputStream fileOutputStream = new FileOutputStream(exe.getAbsoluteFile()); - int chunks =0; - while ((bytesRead = pis.read(dataBuffer, 0, dataBuffer.length)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - //psudoSplash.onUpdate((int) (chunks++)+" Kb " +filename , null); - - } - fileOutputStream.close(); - pis.close(); + rawFileDownload(pis, folder, exe); com.neuronrobotics.sdk.common.Log.error("Finished downloading " + filename); psudoSplash.onUpdate((int) (1 * 100)+" % " +filename , null); downloadEvents.finishDownload(); @@ -992,6 +993,22 @@ public void process(double percent) { } return exe; } + private static void rawFileDownload(ProcessInputStream pis, File folder, File exe) + throws IOException, FileNotFoundException { + folder.mkdirs(); + exe.createNewFile(); + byte dataBuffer[] = new byte[1024*1000]; + int bytesRead; + FileOutputStream fileOutputStream = new FileOutputStream(exe.getAbsoluteFile()); + int chunks =0; + while ((bytesRead = pis.read(dataBuffer, 0, dataBuffer.length)) != -1) { + fileOutputStream.write(dataBuffer, 0, bytesRead); + //psudoSplash.onUpdate((int) (chunks++)+" Kb " +filename , null); + + } + fileOutputStream.close(); + pis.close(); + } /** * @return the editorsURL From 843405cf22c36452c130d1b1c9f85509e3bb0a28 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 29 Mar 2025 16:13:24 -0400 Subject: [PATCH 334/635] Make the get by name API more generaic --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index ef4f1fee..9df14faf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -335,7 +335,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner; } - public static CSG getByName(ArrayList back, String name) { + public static CSG getByName(List back, String name) { for (CSG c : back) { if (c.getName().contentEquals(name)) return c; From e28c9a0e29506a1f2576acfb990d8581036fbd78 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 2 Apr 2025 15:33:32 -0400 Subject: [PATCH 335/635] https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/44 Nerfing the 7z system exe due to download loop issue, will test and fix the root cause when this is validated. --- .../bowlerstudio/scripting/DownloadManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 017e9092..18703e60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -414,9 +414,9 @@ private static File getExecutable(String exeType, IExternalEditor editor, String } // extract7zArchive if (type.toLowerCase().contains("7z")) { - if (isWin() && !exeType.contentEquals("sevenzip")) { - extract7zSystemCall(jvmArchive.getAbsolutePath(), bindir + targetdir); - } else +// if (isWin() && !exeType.contentEquals("sevenzip")) { +// extract7zSystemCall(jvmArchive.getAbsolutePath(), bindir + targetdir); +// } else extract7zArchive(jvmArchive.getAbsolutePath(), bindir + targetdir); } Object installer = vm.get("installer"); From d224592f47d2022422f78735ade924e33e4c651e Mon Sep 17 00:00:00 2001 From: Kevin Bad Name Date: Thu, 3 Apr 2025 10:42:04 -0700 Subject: [PATCH 336/635] restore the 7z download --- .../bowlerstudio/scripting/DownloadManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 18703e60..017e9092 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -414,9 +414,9 @@ private static File getExecutable(String exeType, IExternalEditor editor, String } // extract7zArchive if (type.toLowerCase().contains("7z")) { -// if (isWin() && !exeType.contentEquals("sevenzip")) { -// extract7zSystemCall(jvmArchive.getAbsolutePath(), bindir + targetdir); -// } else + if (isWin() && !exeType.contentEquals("sevenzip")) { + extract7zSystemCall(jvmArchive.getAbsolutePath(), bindir + targetdir); + } else extract7zArchive(jvmArchive.getAbsolutePath(), bindir + targetdir); } Object installer = vm.get("installer"); From 316293f63a98583907e761ed8db2a07385aa1972 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 3 Apr 2025 11:22:37 -0400 Subject: [PATCH 337/635] Download to a temp file before copy over https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/44 --- .../scripting/DownloadManager.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 017e9092..3c78fa2d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -993,21 +993,26 @@ public void process(double percent) { } return exe; } - private static void rawFileDownload(ProcessInputStream pis, File folder, File exe) + private static void rawFileDownload(ProcessInputStream pis, File folder, File output) throws IOException, FileNotFoundException { folder.mkdirs(); - exe.createNewFile(); - byte dataBuffer[] = new byte[1024*1000]; + output.createNewFile(); + byte dataBuffer[] = new byte[1024 * 1000]; int bytesRead; - FileOutputStream fileOutputStream = new FileOutputStream(exe.getAbsoluteFile()); - int chunks =0; - while ((bytesRead = pis.read(dataBuffer, 0, dataBuffer.length)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - //psudoSplash.onUpdate((int) (chunks++)+" Kb " +filename , null); + File exe = File.createTempFile("tmp", output.getName()); + try { + FileOutputStream fileOutputStream = new FileOutputStream(exe.getAbsoluteFile()); + while ((bytesRead = pis.read(dataBuffer, 0, dataBuffer.length)) != -1) { + fileOutputStream.write(dataBuffer, 0, bytesRead); + } + fileOutputStream.close(); + pis.close(); + Files.copy(exe.toPath(), new FileOutputStream(output.getAbsoluteFile())); + } catch (Exception ex) { + ex.printStackTrace(); } - fileOutputStream.close(); - pis.close(); + exe.delete(); } /** From 714ffb0e87f4326a9ce7e40c83884883655eacbe Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 3 Apr 2025 11:37:43 -0400 Subject: [PATCH 338/635] cleaning up the download --- .../bowlerstudio/scripting/DownloadManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 3c78fa2d..372ff411 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -1008,9 +1008,13 @@ private static void rawFileDownload(ProcessInputStream pis, File folder, File ou } fileOutputStream.close(); pis.close(); - Files.copy(exe.toPath(), new FileOutputStream(output.getAbsoluteFile())); + FileOutputStream out = new FileOutputStream(output.getAbsoluteFile()); + Files.copy(exe.toPath(), out); + out.flush(); + out.close(); } catch (Exception ex) { ex.printStackTrace(); + output.delete(); } exe.delete(); } From 9938edd7b1647b0040a1f611c9dc12baf4d7baf0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 4 Apr 2025 11:33:37 -0400 Subject: [PATCH 339/635] only run failure option once https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/44 --- .../scripting/DownloadManager.java | 19 +++++++++++++++++-- .../scripting/IApprovalForDownload.java | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 372ff411..7b15ecbf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -35,8 +35,10 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -55,16 +57,21 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.BowlerKernel; +import com.neuronrobotics.bowlerstudio.assets.FontSizeManager; import com.neuronrobotics.video.OSUtil; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; +import javafx.scene.Node; +import javafx.scene.control.Alert; //import javafx.scene.control.Alert; import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; //import javafx.scene.control.ButtonType; //import javafx.scene.control.Alert.AlertType; import javafx.scene.image.Image; - +import javafx.stage.Stage; import net.sf.sevenzipjbinding.*; import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream; @@ -74,6 +81,7 @@ public class DownloadManager { private static String bindir = System.getProperty("user.home") + delim()+"bin"+delim()+getSTUDIO_INSTALL()+delim(); private static int ev = 0; private static String cmd = ""; + private static HashSet failedURLs = new HashSet(); private static IDownloadManagerEvents downloadEvents = new IDownloadManagerEvents() { @Override @@ -117,6 +125,9 @@ public boolean get(String name, String url) { public void onInstallFail(String url) { com.neuronrobotics.sdk.common.Log.error("Plugin needs to be installed from "+url); } + public void notifyOfFailure(String name) { + com.neuronrobotics.sdk.common.Log.error("Plugin failed "+name); + } }; private static GitLogProgressMonitor psudoSplash = new GitLogProgressMonitor() { @@ -325,7 +336,11 @@ private static void retryLoop(String exeType, IExternalEditor editor, String exe } new RuntimeException("Download or extraction failed, retrying").printStackTrace(); } - approval.onInstallFail(jvmURL); + if(!failedURLs.contains(jvmURL)) { + failedURLs.add(jvmURL); + approval.notifyOfFailure(exeType); + approval.onInstallFail(jvmURL); + } } private static File getExecutable(String exeType, IExternalEditor editor, String executable) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java index ca048219..9a9bd120 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IApprovalForDownload.java @@ -3,4 +3,5 @@ public interface IApprovalForDownload { boolean get(String name, String url); void onInstallFail(String url); + void notifyOfFailure(String name); } From b155db9baf4e16a3c08443734e665f781ab05a49 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 5 Apr 2025 11:33:20 -0400 Subject: [PATCH 340/635] Adding timeline images --- .../scripting/cadoodle/CaDoodleFile.java | 75 +++++++++++++------ 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9df14faf..0d70eeb2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -18,6 +18,7 @@ import javax.imageio.ImageIO; import javafx.scene.image.WritableImage; import org.apache.commons.io.FileUtils; +import org.python.google.common.io.Files; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -116,6 +117,10 @@ public void initialize() { fireInitializationStart(); initializing = true; if (selfInternal != null) { + File parent = selfInternal.getAbsoluteFile().getParentFile(); + File imageCacheDir = new File(parent.getAbsolutePath() + delim() +"timeline"); + if(!imageCacheDir.exists()) + imageCacheDir.mkdir(); File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); try { // set a temp file for the database to clear @@ -295,8 +300,15 @@ public Thread regenerateCurrent() { private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); + int currentIndex2 = getCurrentIndex(); + try { + setTimelineImage(process, currentIndex2); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } storeResultInCache(op, process); - setCurrentIndex(getCurrentIndex() + 1); + setCurrentIndex(currentIndex2 + 1); setCurrentState(op, process); } @@ -623,25 +635,10 @@ public File save() throws IOException { synchronized (selfInternal) { String contents = toJson(); + List currentState = getCurrentState(); + int currentIndex2 = getCurrentIndex(); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); - File parent = selfInternal.getAbsoluteFile().getParentFile(); - File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); - setImage(null); - loadingImageFromUIThread(); - - WritableImage image2 = getImage(); - if (image2 != null) { - BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); - try { - ImageIO.write(bufferedImage, "png", image); - // com.neuronrobotics.sdk.common.Log.error("Thumbnail saved successfully to " + - // image.getAbsolutePath()); - } catch (IOException e) { - // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + - // e.getMessage()); - e.printStackTrace(); - } - } + setTimelineImage(currentState, currentIndex2); if (bom != null) bom.save(); } @@ -649,6 +646,32 @@ public File save() throws IOException { return getSelf(); } + private void setTimelineImage(List currentState, int currentIndex2) throws IOException { + File parent = selfInternal.getAbsoluteFile().getParentFile(); + File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); + File imageCache = new File(parent.getAbsolutePath() + delim() +"timeline"+ delim() + currentIndex2+".png"); + if(imageCache.exists()) + return; + WritableImage image2 = loadingImageFromUIThread( currentState); + if (image2 != null) { + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); + try { + ImageIO.write(bufferedImage, "png", imageCache); + System.err.println("Thumbnail saved successfully to " + + imageCache.getAbsolutePath()); + } catch (IOException e) { + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + + // e.getMessage()); + e.printStackTrace(); + } + + if(currentIndex2 == currentIndex) { + Files.copy(imageCache,image ); + } + + } + } + public WritableImage loadImageFromFile() { try { File parent = selfInternal.getAbsoluteFile().getParentFile(); @@ -659,7 +682,7 @@ public WritableImage loadImageFromFile() { img = SwingFXUtils.toFXImage(bufferedImage, null); } } else { - loadingImageFromUIThread(); + loadingImageFromUIThread( getCurrentState()); } } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error loading image: " + e.getMessage()); @@ -668,14 +691,17 @@ public WritableImage loadImageFromFile() { return img; } - private void loadingImageFromUIThread() { + private javafx.scene.image.WritableImage loadingImageFromUIThread(List currentState ) { + ArrayList holder = new ArrayList(); try { - BowlerKernel.runLater(() -> setImage(ThumbnailImage.get(getCurrentState()))); + BowlerKernel.runLater(() -> { + holder.add(ThumbnailImage.get(currentState)); + }); } catch (Throwable ex) { ex.printStackTrace(); - return; + return null; } - while (getImage() == null) + while (holder.size()==0) try { Thread.sleep(16); // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); @@ -684,6 +710,7 @@ private void loadingImageFromUIThread() { e.printStackTrace(); break; } + return holder.get(0); } public static CaDoodleFile fromJsonString(String content) throws Exception { From d8fa9e27411d228b90e9c90edb9c7b80fd59d7b6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 5 Apr 2025 12:05:22 -0400 Subject: [PATCH 341/635] update the timeline immages based on the current state --- .../scripting/cadoodle/CaDoodleFile.java | 73 ++++++++++++++----- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 0d70eeb2..e9e6cbbb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -118,8 +118,8 @@ public void initialize() { initializing = true; if (selfInternal != null) { File parent = selfInternal.getAbsoluteFile().getParentFile(); - File imageCacheDir = new File(parent.getAbsolutePath() + delim() +"timeline"); - if(!imageCacheDir.exists()) + File imageCacheDir = new File(parent.getAbsolutePath() + delim() + "timeline"); + if (!imageCacheDir.exists()) imageCacheDir.mkdir(); File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); try { @@ -130,7 +130,7 @@ public void initialize() { CSGDatabase.clear(); createTempFile.delete(); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } CSGDatabase.setDbFile(db); @@ -249,8 +249,16 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { setCurrentIndex(getCurrentIndex() + 1); setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); - ICaDoodleOpperation op = opperations.get(getCurrentIndex() - 1); + int currentIndex2 = getCurrentIndex() - 1; + ICaDoodleOpperation op = opperations.get(currentIndex2); List process = op.process(getPreviouState()); + getTimelineImageFile(currentIndex2).delete(); + try { + setTimelineImage(process, currentIndex2); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } storeResultInCache(op, process); setCurrentState(op, process); } @@ -287,6 +295,14 @@ public Thread regenerateCurrent() { ICaDoodleOpperation op = getCurrentOpperation(); List process = op.process(getPreviouState()); + int currentIndex2 = getCurrentIndex(); + getTimelineImageFile(currentIndex2).delete(); + try { + setTimelineImage(process, currentIndex2); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } storeResultInCache(op, process); setCurrentState(op, process); fireSaveSuggestion(); @@ -304,7 +320,7 @@ private void process(ICaDoodleOpperation op) { try { setTimelineImage(process, currentIndex2); } catch (IOException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } storeResultInCache(op, process); @@ -406,13 +422,32 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam return back.size(); } + public File getTimelineImageFile(ICaDoodleOpperation test) { + for (int i = 0; i < getOpperations().size(); i++) { + ICaDoodleOpperation key = getOpperations().get(i); + if (key == test) { + File file = getTimelineImageFile(i); + return file; + } + } + throw new RuntimeException("File not found!"); + } + + public File getTimelineImageFile(int i) { + File parent = selfInternal.getAbsoluteFile().getParentFile(); + File file = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + (i + 1) + ".png"); + return file; + } + private void pruneForward() { for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); List back = cache.remove(key); - VitaminBomManager boM = CaDoodleFile.getBillOfMaterials(); if (back != null) back.clear(); + File imageCache = getTimelineImageFile(i); + //System.err.println("Deleting " + imageCache.getAbsolutePath()); + imageCache.delete(); } List subList = (List) getOpperations().subList(0, getCurrentIndex()); ArrayList newList = new ArrayList(); @@ -431,10 +466,11 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { names.add(c.getName()); cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) .setRegenerate(c.getRegenerate())); - //cachedCopy.add(c); + // cachedCopy.add(c); } cache.put(op, cachedCopy); } + private CSG cloneCSG(CSG dyingCSG) { CSG csg = new CSG(); @@ -467,6 +503,7 @@ private CSG cloneCSG(CSG dyingCSG) { csg.setColor(dyingCSG.getColor()); return csg; } + public void back() { if (isBackAvailible()) setCurrentIndex(getCurrentIndex() - 1); @@ -648,27 +685,27 @@ public File save() throws IOException { private void setTimelineImage(List currentState, int currentIndex2) throws IOException { File parent = selfInternal.getAbsoluteFile().getParentFile(); + File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); - File imageCache = new File(parent.getAbsolutePath() + delim() +"timeline"+ delim() + currentIndex2+".png"); - if(imageCache.exists()) + + if (imageCache.exists()) return; - WritableImage image2 = loadingImageFromUIThread( currentState); + WritableImage image2 = loadingImageFromUIThread(currentState); if (image2 != null) { BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); try { ImageIO.write(bufferedImage, "png", imageCache); - System.err.println("Thumbnail saved successfully to " + - imageCache.getAbsolutePath()); + System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } catch (IOException e) { // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + // e.getMessage()); e.printStackTrace(); } - if(currentIndex2 == currentIndex) { - Files.copy(imageCache,image ); + if (currentIndex2 == currentIndex) { + Files.copy(imageCache, image); } - + } } @@ -682,7 +719,7 @@ public WritableImage loadImageFromFile() { img = SwingFXUtils.toFXImage(bufferedImage, null); } } else { - loadingImageFromUIThread( getCurrentState()); + loadingImageFromUIThread(getCurrentState()); } } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error loading image: " + e.getMessage()); @@ -691,7 +728,7 @@ public WritableImage loadImageFromFile() { return img; } - private javafx.scene.image.WritableImage loadingImageFromUIThread(List currentState ) { + private javafx.scene.image.WritableImage loadingImageFromUIThread(List currentState) { ArrayList holder = new ArrayList(); try { BowlerKernel.runLater(() -> { @@ -701,7 +738,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr ex.printStackTrace(); return null; } - while (holder.size()==0) + while (holder.size() == 0) try { Thread.sleep(16); // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); From 9b913328b4a9a111238bb346ffad357816fc22c9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 5 Apr 2025 12:40:14 -0400 Subject: [PATCH 342/635] make sure the unit test loading is working --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e9e6cbbb..eda62be3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -684,6 +684,8 @@ public File save() throws IOException { } private void setTimelineImage(List currentState, int currentIndex2) throws IOException { + if(selfInternal==null) + return; File parent = selfInternal.getAbsoluteFile().getParentFile(); File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); From ff2b77f7fa278fc0508ef66b48c249a2ce14295c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 9 Apr 2025 16:42:31 -0400 Subject: [PATCH 343/635] new files should not generate a blank image --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index eda62be3..f8948933 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -686,6 +686,8 @@ public File save() throws IOException { private void setTimelineImage(List currentState, int currentIndex2) throws IOException { if(selfInternal==null) return; + if(currentIndex2==0) + return; File parent = selfInternal.getAbsoluteFile().getParentFile(); File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); From 9e866a306270e36ec0a976e3d9d10910a15bfde7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 11 Apr 2025 10:57:19 -0400 Subject: [PATCH 344/635] add a ruler location to the cadoodle file --- .../scripting/cadoodle/CaDoodleFile.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index eda62be3..9167995e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -55,6 +55,8 @@ public class CaDoodleFile { @Expose(serialize = true, deserialize = true) private String projectName = NO_NAME; @Expose(serialize = true, deserialize = true) + private TransformNR rulerLocation = new TransformNR(); + @Expose(serialize = true, deserialize = true) private TransformNR workplane = new TransformNR(); @Expose(serialize = false, deserialize = false) private File selfInternal; @@ -857,4 +859,14 @@ private void setRegenerating(boolean regenerating) { this.regenerating = regenerating; } + public TransformNR getRulerLocation() { + return rulerLocation; + } + + public void setRulerLocation(TransformNR rulerLocation) { + this.rulerLocation = rulerLocation; + fireWorkplaneChange(); + fireSaveSuggestion(); + } + } From 20a654976d52209df6eb5f51688d1f1dbc5c8e0f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 11 Apr 2025 11:13:57 -0400 Subject: [PATCH 345/635] ensure the ruler is pure translation --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9167995e..c5b1edf6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -31,6 +31,7 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; +import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -864,6 +865,7 @@ public TransformNR getRulerLocation() { } public void setRulerLocation(TransformNR rulerLocation) { + rulerLocation.setRotation(new RotationNR()); this.rulerLocation = rulerLocation; fireWorkplaneChange(); fireSaveSuggestion(); From 81ec68de96050aa55121421af0330072363d9f7e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 12 Apr 2025 19:43:02 -0400 Subject: [PATCH 346/635] initialize the base builder with the giturl --- .../bowlerstudio/creature/DHLimbBuilder.java | 5 +++++ .../bowlerstudio/creature/MobileBaseBuilder.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/DHLimbBuilder.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/DHLimbBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/DHLimbBuilder.java new file mode 100644 index 00000000..ea53bfab --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/DHLimbBuilder.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.creature; + +public class DHLimbBuilder { + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java new file mode 100644 index 00000000..816f8ad3 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -0,0 +1,13 @@ +package com.neuronrobotics.bowlerstudio.creature; + +public class MobileBaseBuilder { + + private String gitURL; + private String name; + + public MobileBaseBuilder(String gitURL, String name) { + this.gitURL = gitURL; + this.name = name; + + } +} From 3bdfad05b6492079da6dc3f2fb0363768d77fb77 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 12 Apr 2025 21:20:36 -0400 Subject: [PATCH 347/635] Adding builder and unit test --- .../creature/MobileBaseBuilder.java | 23 ++++++++++++++++ .../junit/bowler/MobileBaseBuilderTest.java | 26 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/java/src/junit/bowler/MobileBaseBuilderTest.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 816f8ad3..83023318 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -1,13 +1,36 @@ package com.neuronrobotics.bowlerstudio.creature; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; + public class MobileBaseBuilder { private String gitURL; private String name; + private String xmlName =null; public MobileBaseBuilder(String gitURL, String name) { this.gitURL = gitURL; this.name = name; } + + public MobileBase build() throws Exception { + MobileBase base = new MobileBase(); + base.setScriptingName(name); + String filename = name+".xml"; + if(xmlName!=null) { + filename=xmlName; + } + base.setGitSelfSource(new String[] {gitURL,filename}); + + + ScriptingEngine.pushCodeToGit(gitURL, null, filename, base.getXml(), "Builder Write XML ", true); + return base; + } + + public MobileBaseBuilder setXmlName(String xmlName) { + this.xmlName = xmlName; + return this; + } } diff --git a/test/java/src/junit/bowler/MobileBaseBuilderTest.java b/test/java/src/junit/bowler/MobileBaseBuilderTest.java new file mode 100644 index 00000000..7525c440 --- /dev/null +++ b/test/java/src/junit/bowler/MobileBaseBuilderTest.java @@ -0,0 +1,26 @@ +package junit.bowler; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; +import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; + +public class MobileBaseBuilderTest { + + @Test + public void test() throws Exception { + ScriptingEngine.login(); + MobileBaseBuilder builder = new MobileBaseBuilder( + "https://github.com/madhephaestus/TestRepo.git", "BuiltRobot") + .setXmlName("RobRobotExample.xml"); + + MobileBase base = builder.build(); + + + } + +} From aa1592d4f6aa83d716cdafac4408c579541c4c4a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 12 Apr 2025 22:31:10 -0400 Subject: [PATCH 348/635] update the maven location --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b43161c6..351d01c7 100755 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,7 @@ String getOsArch() { repositories { mavenCentral() maven { - url 'https://commonwealthrobotics.com/jcenter-mirror/' + url 'https://commonwealthrobotics.com/maven/' allowInsecureProtocol = true } maven { url 'https://repo.maven.apache.org/maven2/' } From b18bde714c79e028a3dea2e2d8d806bcafcde4ec Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 13 Apr 2025 17:24:20 -0400 Subject: [PATCH 349/635] Adding an interface to intercept the prun forward --- .../scripting/cadoodle/CaDoodleFile.java | 32 +++++++++++++++++-- .../cadoodle/IAcceptPruneForward.java | 5 +++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 41710687..da803e42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -80,6 +80,7 @@ public class CaDoodleFile { private boolean initializing; private static HashMap bomManagers = new HashMap<>(); private VitaminBomManager bom; + private IAcceptPruneForward accept=null; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -155,7 +156,13 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - pruneForward(); + try { + pruneForward(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + break; + } indexStarting = i; break; } @@ -349,7 +356,13 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc opperationRunner.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); if (getCurrentIndex() != getOpperations().size()) { - pruneForward(); + try { + pruneForward(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + break; + } } try { getOpperations().add(op); @@ -442,7 +455,12 @@ public File getTimelineImageFile(int i) { return file; } - private void pruneForward() { + private void pruneForward() throws Exception { + if(getAccept()!=null) { + if(!getAccept().accept()) { + throw new Exception("Do not accept the prune"); + } + } for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); List back = cache.remove(key); @@ -873,4 +891,12 @@ public void setRulerLocation(TransformNR rulerLocation) { fireSaveSuggestion(); } + public IAcceptPruneForward getAccept() { + return accept; + } + + public void setAccept(IAcceptPruneForward accept) { + this.accept = accept; + } + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java new file mode 100644 index 00000000..d3c1a798 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public interface IAcceptPruneForward { + public boolean accept(); +} From a0677353f0d7cab73e20f112b8b737b7a2b0189f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 14 Apr 2025 13:39:49 -0400 Subject: [PATCH 350/635] no prune on startup --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index da803e42..09009fb5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -156,13 +156,6 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - try { - pruneForward(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - break; - } indexStarting = i; break; } @@ -483,7 +476,7 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { for (CSG c : process) { if (names.contains(c.getName())) throw new RuntimeException( - "There can not be 2 objects with the same name after an opperation! " + c.getName()); + "There can not be 2 objects with the same name after an "+op.getType()+" opperation! " + c.getName()); names.add(c.getName()); cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) .setRegenerate(c.getRegenerate())); From d2d3f0a264da2a9f5893dfee1ebe7319c7c31eee Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 15 Apr 2025 08:56:28 -0400 Subject: [PATCH 351/635] Add setters for the default values --- .../scripting/cadoodle/Sweep.java | 54 +++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 4dd898a6..4dcd44cc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -44,6 +44,11 @@ public class Sweep extends AbstractAddFrom { private LengthParameter rad = null; private LengthParameter step = null; private LengthParameter angle = null; + + private double defz = 0; + private double defrad= 10; + private double defstep=30; + private double defangle=360; public Sweep set(File source) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) @@ -60,7 +65,6 @@ public Sweep set(File source) throws Exception { @Override public String getType() { - // TODO Auto-generated method stub return "Sweep"; } @@ -81,35 +85,35 @@ public CSG sweep(Polygon p, String name, Bounds b) { return Extrude.sweep(transformedP, increment, radiusT, steps).rotx(-90).setName(name); } - private LengthParameter radius(String name) { + public LengthParameter radius(String name) { String key = name + "_CaDoodle_Rad"; if (rad == null) - rad = new LengthParameter(key, 10.0, nopt); + rad = new LengthParameter(key, getDefrad(), nopt); if(rad.getMM()<0) rad.setMM(0); return rad; } - private LengthParameter zoffset(String name) { + public LengthParameter zoffset(String name) { String key = name + "_CaDoodle_Z-per"; if (z == null) - z = new LengthParameter(key, 0.0, nopt); + z = new LengthParameter(key, getDefz(), nopt); return z; } - private LengthParameter steps(String name) { + public LengthParameter steps(String name) { String key = name + "_CaDoodle_Step"; if (step == null) - step = new LengthParameter(key, 30.0, nopt); + step = new LengthParameter(key, getDefstep(), nopt); if(step.getMM()<3) step.setMM(3); return step; } - private LengthParameter angle(String name) { + public LengthParameter angle(String name) { String key = name + "_CaDoodle_Angle"; if (angle == null) - angle = new LengthParameter(key, 360.0, nopt); + angle = new LengthParameter(key, getDefangle(), nopt); if (angle.getMM()<0.001) angle.setMM(0.001); return angle; @@ -258,4 +262,36 @@ public Sweep setPreventBoM(Boolean preventBoM) { return this; } + public double getDefz() { + return defz; + } + + public void setDefz(double defz) { + this.defz = defz; + } + + public double getDefrad() { + return defrad; + } + + public void setDefrad(double defrad) { + this.defrad = defrad; + } + + public double getDefstep() { + return defstep; + } + + public void setDefstep(double defstep) { + this.defstep = defstep; + } + + public double getDefangle() { + return defangle; + } + + public void setDefangle(double defangle) { + this.defangle = defangle; + } + } From dfbb13261ca2f44e8b07eb162bba761034bdff83 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 19 Apr 2025 11:58:53 -0400 Subject: [PATCH 352/635] remove todo --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 09009fb5..485a4a47 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -352,7 +352,6 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc try { pruneForward(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); break; } From 1fd52a4c82e1d91dbc00223e5d64f5ce3bbe3163 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 19 Apr 2025 14:27:26 -0400 Subject: [PATCH 353/635] vitamins --- .../bowlerstudio/vitamins/Vitamins.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 3d76161b..7d4baebc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -286,12 +286,17 @@ public static Map getConfiguration(String type, String id) { } ConcurrentHashMap ConcurrentHashMap = database.get(id); - Object[] array = ConcurrentHashMap.keySet().toArray(); - for (int i = 0; i < array.length; i++) { - String key = (String) array[i]; - sanatize(key, ConcurrentHashMap); + try { + Object[] array = ConcurrentHashMap.keySet().toArray(); + for (int i = 0; i < array.length; i++) { + String key = (String) array[i]; + sanatize(key, ConcurrentHashMap); + } + return Collections.unmodifiableMap(ConcurrentHashMap); + }catch(Exception ex) { + ex.printStackTrace(); } - return Collections.unmodifiableMap(ConcurrentHashMap); + return new ConcurrentHashMap(); } public static void putMeasurment(String type, String size, String measurementName, Object measurmentValue) { From bdd417fc414c27b3e1398db15a00b559a431ee3b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 19 Apr 2025 16:23:34 -0400 Subject: [PATCH 354/635] Adding a check to see if a plugin is already downloaded --- .../scripting/DownloadManager.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 7b15ecbf..33aeb967 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -317,21 +317,23 @@ public static Map getEnvironment(String exeType) { } return new HashMap<>(); } - public static File getRunExecutable(String exeType, IExternalEditor editor) { + return getRunExecutable(exeType,editor,false); + } + public static File getRunExecutable(String exeType, IExternalEditor editor,boolean justChecking) { String executable = "executable"; - retryLoop(exeType, editor, executable); - return getExecutable(exeType, editor, executable); + retryLoop(exeType, editor, executable,justChecking); + return getExecutable(exeType, editor, executable,justChecking); } public static File getConfigExecutable(String exeType, IExternalEditor editor) { String executable = "configExecutable"; - retryLoop(exeType, editor, executable); - return getExecutable(exeType, editor, executable); + retryLoop(exeType, editor, executable,false); + return getExecutable(exeType, editor, executable,false); } - private static void retryLoop(String exeType, IExternalEditor editor, String executable) { + private static void retryLoop(String exeType, IExternalEditor editor, String executable,boolean justChecking) { for(int i=0;i<3;i++) { - if(getExecutable(exeType, editor, executable).exists()) { + if(getExecutable(exeType, editor, executable,justChecking).exists()) { return; } new RuntimeException("Download or extraction failed, retrying").printStackTrace(); @@ -343,7 +345,7 @@ private static void retryLoop(String exeType, IExternalEditor editor, String exe } } - private static File getExecutable(String exeType, IExternalEditor editor, String executable) { + private static File getExecutable(String exeType, IExternalEditor editor, String executable,boolean justChecking) { String key = discoverKey(); try { @@ -383,7 +385,7 @@ private static File getExecutable(String exeType, IExternalEditor editor, String if(new File(string).exists()) cmd=string; } - if (!new File(cmd).exists()) { + if (!new File(cmd).exists() && !justChecking) { if(exeType.toLowerCase().contentEquals("freecad")) { //FreecadLoader.update(vm); baseURL = vm.get("url").toString(); @@ -1093,5 +1095,9 @@ public static String getSTUDIO_INSTALL() { public static void setSTUDIO_INSTALL(String sTUDIO_INSTALL) { STUDIO_INSTALL = sTUDIO_INSTALL; } + public static boolean isDownloadedAlready(String string) { + File f= DownloadManager.getRunExecutable(string, null,true); + return f.exists(); + } } From 613106b39df782ccc7bb6b30a5eadb5dc2af5013 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 11:14:20 -0400 Subject: [PATCH 355/635] preserve the sweep defaults for re-loading accuracy --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 4dcd44cc..0c81e4f4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -44,10 +44,13 @@ public class Sweep extends AbstractAddFrom { private LengthParameter rad = null; private LengthParameter step = null; private LengthParameter angle = null; - + @Expose(serialize = true, deserialize = true) private double defz = 0; + @Expose(serialize = true, deserialize = true) private double defrad= 10; + @Expose(serialize = true, deserialize = true) private double defstep=30; + @Expose(serialize = true, deserialize = true) private double defangle=360; public Sweep set(File source) throws Exception { From 7e5d6bf0d833565956f37d5c52f036dc3b7fcf15 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 12:12:35 -0400 Subject: [PATCH 356/635] Make the setting of a specific timeline spot easy --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 485a4a47..b8d1c45e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -523,6 +523,16 @@ public void back() { updateCurrentFromCache(); fireSaveSuggestion(); } + + public void moveToOpIndex(int newIndex) { + if(newIndex> getOpperations().size()) + return; + if(newIndex<1) + return; + setCurrentIndex(newIndex+1); + updateCurrentFromCache(); + fireSaveSuggestion(); + } public boolean isBackAvailible() { return getCurrentIndex() > 1; From 7fe6d2283e3d45d9af962f4c666c7c175c7d97c2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 13:24:47 -0400 Subject: [PATCH 357/635] Add a listening event to the cadoodle file events --- .../scripting/cadoodle/CaDoodleFile.java | 22 +++++++++++++++++-- .../cadoodle/ICaDoodleStateUpdate.java | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b8d1c45e..42f29a49 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -329,6 +329,7 @@ private void process(ICaDoodleOpperation op) { storeResultInCache(op, process); setCurrentIndex(currentIndex2 + 1); setCurrentState(op, process); + } public boolean isOperationRunning() { @@ -522,6 +523,7 @@ public void back() { setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); fireSaveSuggestion(); + fireTimelineUpdate(); } public void moveToOpIndex(int newIndex) { @@ -532,6 +534,7 @@ public void moveToOpIndex(int newIndex) { setCurrentIndex(newIndex+1); updateCurrentFromCache(); fireSaveSuggestion(); + fireTimelineUpdate(); } public boolean isBackAvailible() { @@ -557,6 +560,7 @@ public void forward() { setCurrentIndex(getCurrentIndex() + 1); updateCurrentFromCache(); fireSaveSuggestion(); + fireTimelineUpdate(); } public boolean isForwardAvailible() { @@ -722,17 +726,31 @@ private void setTimelineImage(List currentState, int currentIndex2) throws BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); try { ImageIO.write(bufferedImage, "png", imageCache); - System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } catch (IOException e) { // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + // e.getMessage()); e.printStackTrace(); } - + do { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return; + } + }while(!imageCache.exists()); if (currentIndex2 == currentIndex) { Files.copy(imageCache, image); } + System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); + } + fireTimelineUpdate(); + } + private void fireTimelineUpdate() { + for(ICaDoodleStateUpdate s:listeners) { + s.onTimelineUpdate(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index f2d888c1..d2e47e77 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -14,4 +14,5 @@ public interface ICaDoodleStateUpdate { public void onRegenerateDone(); public void onRegenerateStart(); public void onWorkplaneChange(TransformNR newWP); + public void onTimelineUpdate(); } From 0e5ac9974f2888f74d245dd538bbb006a9e67684 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 15:02:46 -0400 Subject: [PATCH 358/635] Adjust how the timeline is updated https://github.com/CommonWealthRobotics/CaDoodle-Application/issues/48 --- .../scripting/cadoodle/CaDoodleFile.java | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 42f29a49..59ed4424 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -257,7 +257,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { List process = op.process(getPreviouState()); getTimelineImageFile(currentIndex2).delete(); try { - setTimelineImage(process, currentIndex2); + setTimelineImage(process, op); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -301,7 +301,7 @@ public Thread regenerateCurrent() { int currentIndex2 = getCurrentIndex(); getTimelineImageFile(currentIndex2).delete(); try { - setTimelineImage(process, currentIndex2); + setTimelineImage(process, op); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -320,16 +320,15 @@ public Thread regenerateCurrent() { private void process(ICaDoodleOpperation op) { List process = op.process(getCurrentState()); int currentIndex2 = getCurrentIndex(); + storeResultInCache(op, process); + setCurrentIndex(currentIndex2 + 1); + setCurrentState(op, process); try { - setTimelineImage(process, currentIndex2); + setTimelineImage(process, op); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); } - storeResultInCache(op, process); - setCurrentIndex(currentIndex2 + 1); - setCurrentState(op, process); - } public boolean isOperationRunning() { @@ -346,11 +345,14 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner; } opperationRunner = new Thread(() -> { + boolean prune=false; while (toProcess.size() > 0) { opperationRunner.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); if (getCurrentIndex() != getOpperations().size()) { try { + prune=true; + fireRegenerateStart(); pruneForward(); } catch (Exception e) { e.printStackTrace(); @@ -366,6 +368,8 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc } updateBoM(); fireSaveSuggestion(); + if(prune) + fireRegenerateDone(); opperationRunner = null; }); opperationRunner.start(); @@ -454,11 +458,13 @@ private void pruneForward() throws Exception { throw new Exception("Do not accept the prune"); } } - for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { + for (int i = getCurrentIndex()-1; i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); - List back = cache.remove(key); - if (back != null) - back.clear(); + if(i>=getCurrentIndex()) { + List back = cache.remove(key); + if (back != null) + back.clear(); + } File imageCache = getTimelineImageFile(i); //System.err.println("Deleting " + imageCache.getAbsolutePath()); imageCache.delete(); @@ -468,6 +474,8 @@ private void pruneForward() throws Exception { newList.addAll(subList); setOpperations(newList); com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); + fireTimelineUpdate(); + } private void storeResultInCache(ICaDoodleOpperation op, List process) { @@ -529,7 +537,7 @@ public void back() { public void moveToOpIndex(int newIndex) { if(newIndex> getOpperations().size()) return; - if(newIndex<1) + if(newIndex<0) return; setCurrentIndex(newIndex+1); updateCurrentFromCache(); @@ -702,7 +710,7 @@ public File save() throws IOException { List currentState = getCurrentState(); int currentIndex2 = getCurrentIndex(); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); - setTimelineImage(currentState, currentIndex2); + setTimelineImage(currentState, getCurrentOpperation()); if (bom != null) bom.save(); } @@ -710,11 +718,15 @@ public File save() throws IOException { return getSelf(); } - private void setTimelineImage(List currentState, int currentIndex2) throws IOException { + private void setTimelineImage(List currentState, ICaDoodleOpperation op) throws IOException { if(selfInternal==null) return; - if(currentIndex2==0) - return; + int currentIndex2=0; + for(int i=0;i currentState, int currentIndex2) throws try { Thread.sleep(100); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); return; } @@ -843,6 +854,7 @@ public ArrayList getOpperations() { public void setOpperations(ArrayList opperations) { this.opperations = opperations; + currentIndex=opperations.size(); } public TransformNR getWorkplane() { From fa315769166a06af3c4d96c797e2adafc0e88c0a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 17:06:54 -0400 Subject: [PATCH 359/635] only try to download when not just checking --- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 33aeb967..753a0177 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -332,6 +332,8 @@ public static File getConfigExecutable(String exeType, IExternalEditor editor) { return getExecutable(exeType, editor, executable,false); } private static void retryLoop(String exeType, IExternalEditor editor, String executable,boolean justChecking) { + if(justChecking) + return; for(int i=0;i<3;i++) { if(getExecutable(exeType, editor, executable,justChecking).exists()) { return; From 20e788a63a5ce77ddacf95902c4fd01d2c55b2cc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 18:24:31 -0400 Subject: [PATCH 360/635] Change the opperation options to include insertion --- .../scripting/cadoodle/CaDoodleFile.java | 61 +++++++++++++------ .../cadoodle/IAcceptPruneForward.java | 2 +- .../scripting/cadoodle/OperationResult.java | 5 ++ 3 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 59ed4424..13929c48 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -223,7 +223,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) return null; if (isRegenerating() || isOperationRunning()) { - com.neuronrobotics.sdk.common.Log.error("Opperation is running, ignoring regen"); + System.err.println("Opperation is running, ignoring regen"); return null; } fireRegenerateStart(); @@ -255,7 +255,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { int currentIndex2 = getCurrentIndex() - 1; ICaDoodleOpperation op = opperations.get(currentIndex2); List process = op.process(getPreviouState()); - getTimelineImageFile(currentIndex2).delete(); + getTimelineImageFile(op).delete(); try { setTimelineImage(process, op); } catch (IOException e) { @@ -335,7 +335,12 @@ public boolean isOperationRunning() { if (opperationRunner != null) if (!opperationRunner.isAlive()) opperationRunner = null; - return opperationRunner != null; + if(opperationRunner != null) { + if(Thread.currentThread().getId() == opperationRunner.getId()) + return false; + return true; + }else + return false; } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { @@ -349,21 +354,35 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc while (toProcess.size() > 0) { opperationRunner.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); + OperationResult res=OperationResult.APPEND; if (getCurrentIndex() != getOpperations().size()) { try { prune=true; fireRegenerateStart(); - pruneForward(); + res=pruneForward(op); } catch (Exception e) { e.printStackTrace(); break; } } - try { - getOpperations().add(op); - process(op); - } catch (Exception ex) { - ex.printStackTrace(); + if(res==OperationResult.APPEND || res==OperationResult.PRUNE) { + try { + getOpperations().add(op); + process(op); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if(res==OperationResult.INSERT) { + getOpperations().add(getCurrentIndex(),op); + setCurrentIndex(getCurrentIndex()+1); + try { + regenerateFrom(op).join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + updateCurrentFromCache(); } } updateBoM(); @@ -452,10 +471,12 @@ public File getTimelineImageFile(int i) { return file; } - private void pruneForward() throws Exception { + private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { + OperationResult res=OperationResult.INSERT; if(getAccept()!=null) { - if(!getAccept().accept()) { - throw new Exception("Do not accept the prune"); + res = getAccept().accept(); + if(res==OperationResult.ABORT) { + return res; } } for (int i = getCurrentIndex()-1; i < getOpperations().size(); i++) { @@ -469,13 +490,15 @@ private void pruneForward() throws Exception { //System.err.println("Deleting " + imageCache.getAbsolutePath()); imageCache.delete(); } - List subList = (List) getOpperations().subList(0, getCurrentIndex()); - ArrayList newList = new ArrayList(); - newList.addAll(subList); - setOpperations(newList); - com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); - fireTimelineUpdate(); - + if(res==OperationResult.PRUNE) { + List subList = (List) getOpperations().subList(0, getCurrentIndex()); + ArrayList newList = new ArrayList(); + newList.addAll(subList); + setOpperations(newList); + com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); + fireTimelineUpdate(); + } + return res; } private void storeResultInCache(ICaDoodleOpperation op, List process) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java index d3c1a798..9aa4b32d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/IAcceptPruneForward.java @@ -1,5 +1,5 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; public interface IAcceptPruneForward { - public boolean accept(); + public OperationResult accept(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java new file mode 100644 index 00000000..23a60392 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public enum OperationResult { + PRUNE,INSERT,ABORT,APPEND; +} From b729240032ed4bc50a6a8196b8f3572fb815f7fa Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 21:58:00 -0400 Subject: [PATCH 361/635] Add a delete interface to the doodle file --- .../scripting/cadoodle/CaDoodleFile.java | 111 ++++++++++++------ 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 13929c48..5bd06ddf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -80,7 +80,7 @@ public class CaDoodleFile { private boolean initializing; private static HashMap bomManagers = new HashMap<>(); private VitaminBomManager bom; - private IAcceptPruneForward accept=null; + private IAcceptPruneForward accept = null; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -134,7 +134,7 @@ public void initialize() { CSGDatabase.clear(); createTempFile.delete(); } catch (IOException e) { - // Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } CSGDatabase.setDbFile(db); @@ -259,7 +259,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { try { setTimelineImage(process, op); } catch (IOException e) { - // Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } storeResultInCache(op, process); @@ -303,7 +303,7 @@ public Thread regenerateCurrent() { try { setTimelineImage(process, op); } catch (IOException e) { - // Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } storeResultInCache(op, process); @@ -326,7 +326,7 @@ private void process(ICaDoodleOpperation op) { try { setTimelineImage(process, op); } catch (IOException e) { - // Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } @@ -335,11 +335,11 @@ public boolean isOperationRunning() { if (opperationRunner != null) if (!opperationRunner.isAlive()) opperationRunner = null; - if(opperationRunner != null) { - if(Thread.currentThread().getId() == opperationRunner.getId()) + if (opperationRunner != null) { + if (Thread.currentThread().getId() == opperationRunner.getId()) return false; return true; - }else + } else return false; } @@ -350,22 +350,22 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner; } opperationRunner = new Thread(() -> { - boolean prune=false; + boolean prune = false; while (toProcess.size() > 0) { opperationRunner.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); - OperationResult res=OperationResult.APPEND; + OperationResult res = OperationResult.APPEND; if (getCurrentIndex() != getOpperations().size()) { try { - prune=true; + prune = true; fireRegenerateStart(); - res=pruneForward(op); + res = pruneForward(op); } catch (Exception e) { e.printStackTrace(); break; } } - if(res==OperationResult.APPEND || res==OperationResult.PRUNE) { + if (res == OperationResult.APPEND || res == OperationResult.PRUNE) { try { getOpperations().add(op); process(op); @@ -373,9 +373,9 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc ex.printStackTrace(); } } - if(res==OperationResult.INSERT) { - getOpperations().add(getCurrentIndex(),op); - setCurrentIndex(getCurrentIndex()+1); + if (res == OperationResult.INSERT) { + getOpperations().add(getCurrentIndex(), op); + setCurrentIndex(getCurrentIndex() + 1); try { regenerateFrom(op).join(); } catch (InterruptedException e) { @@ -387,7 +387,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc } updateBoM(); fireSaveSuggestion(); - if(prune) + if (prune) fireRegenerateDone(); opperationRunner = null; }); @@ -395,6 +395,38 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner; } + public Thread deleteOperation(ICaDoodleOpperation op) { + if (isOperationRunning()) { + return opperationRunner; + } + opperationRunner = new Thread(() -> { + opperationRunner.setName("addOpperation Thread " + toProcess.size()); + int index=0; + for(int i=0;i back, String name) { for (CSG c : back) { if (c.getName().contentEquals(name)) @@ -472,26 +504,27 @@ public File getTimelineImageFile(int i) { } private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { - OperationResult res=OperationResult.INSERT; - if(getAccept()!=null) { + OperationResult res = OperationResult.INSERT; + if (getAccept() != null) { res = getAccept().accept(); - if(res==OperationResult.ABORT) { + if (res == OperationResult.ABORT) { return res; } } - for (int i = getCurrentIndex()-1; i < getOpperations().size(); i++) { + for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); - if(i>=getCurrentIndex()) { + if (i >= getCurrentIndex()) { List back = cache.remove(key); if (back != null) back.clear(); } File imageCache = getTimelineImageFile(i); - //System.err.println("Deleting " + imageCache.getAbsolutePath()); + // System.err.println("Deleting " + imageCache.getAbsolutePath()); imageCache.delete(); } - if(res==OperationResult.PRUNE) { - List subList = (List) getOpperations().subList(0, getCurrentIndex()); + if (res == OperationResult.PRUNE) { + List subList = (List) getOpperations().subList(0, + getCurrentIndex()); ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); @@ -506,8 +539,8 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { HashSet names = new HashSet<>(); for (CSG c : process) { if (names.contains(c.getName())) - throw new RuntimeException( - "There can not be 2 objects with the same name after an "+op.getType()+" opperation! " + c.getName()); + throw new RuntimeException("There can not be 2 objects with the same name after an " + op.getType() + + " opperation! " + c.getName()); names.add(c.getName()); cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) .setRegenerate(c.getRegenerate())); @@ -556,13 +589,13 @@ public void back() { fireSaveSuggestion(); fireTimelineUpdate(); } - + public void moveToOpIndex(int newIndex) { - if(newIndex> getOpperations().size()) + if (newIndex > getOpperations().size()) return; - if(newIndex<0) + if (newIndex < 0) return; - setCurrentIndex(newIndex+1); + setCurrentIndex(newIndex + 1); updateCurrentFromCache(); fireSaveSuggestion(); fireTimelineUpdate(); @@ -742,12 +775,12 @@ public File save() throws IOException { } private void setTimelineImage(List currentState, ICaDoodleOpperation op) throws IOException { - if(selfInternal==null) + if (selfInternal == null) return; - int currentIndex2=0; - for(int i=0;i currentState, ICaDoodleOpperation op) th e.printStackTrace(); return; } - }while(!imageCache.exists()); + } while (!imageCache.exists()); if (currentIndex2 == currentIndex) { Files.copy(imageCache, image); } @@ -783,7 +816,7 @@ private void setTimelineImage(List currentState, ICaDoodleOpperation op) th } private void fireTimelineUpdate() { - for(ICaDoodleStateUpdate s:listeners) { + for (ICaDoodleStateUpdate s : listeners) { s.onTimelineUpdate(); } } @@ -877,7 +910,7 @@ public ArrayList getOpperations() { public void setOpperations(ArrayList opperations) { this.opperations = opperations; - currentIndex=opperations.size(); + currentIndex = opperations.size(); } public TransformNR getWorkplane() { From d7aa99ea118006ac66e1b212bef9b57ba873e40a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 22:09:52 -0400 Subject: [PATCH 362/635] more stable loading after a delete --- .../scripting/cadoodle/CaDoodleFile.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 5bd06ddf..cfdb21ed 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -156,8 +156,7 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - indexStarting = i; - break; + opperations.remove(op); } } setCurrentIndex(indexStarting); @@ -254,16 +253,20 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; ICaDoodleOpperation op = opperations.get(currentIndex2); - List process = op.process(getPreviouState()); getTimelineImageFile(op).delete(); try { - setTimelineImage(process, op); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); + List process = op.process(getPreviouState()); + try { + setTimelineImage(process, op); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } + storeResultInCache(op, process); + setCurrentState(op, process); + } catch (Throwable tr) { + tr.printStackTrace(); } - storeResultInCache(op, process); - setCurrentState(op, process); } if (getCurrentIndex() != endIndex) { setCurrentIndex(endIndex); @@ -401,16 +404,16 @@ public Thread deleteOperation(ICaDoodleOpperation op) { } opperationRunner = new Thread(() -> { opperationRunner.setName("addOpperation Thread " + toProcess.size()); - int index=0; - for(int i=0;i Date: Mon, 21 Apr 2025 22:27:37 -0400 Subject: [PATCH 363/635] fixed broken new file startup --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index cfdb21ed..97e7e1c2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -769,7 +769,8 @@ public File save() throws IOException { List currentState = getCurrentState(); int currentIndex2 = getCurrentIndex(); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); - setTimelineImage(currentState, getCurrentOpperation()); + if(currentIndex2>0) + setTimelineImage(currentState, getCurrentOpperation()); if (bom != null) bom.save(); } From a1c04a7c3b0f23ab7e26eb350db43271187cf081 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 22:37:12 -0400 Subject: [PATCH 364/635] make sure it checks for the latest version for copy the thumbnail correctly --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 97e7e1c2..7b1f6a4d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -811,7 +811,7 @@ private void setTimelineImage(List currentState, ICaDoodleOpperation op) th return; } } while (!imageCache.exists()); - if (currentIndex2 == currentIndex) { + if (getOpperations().get(getOpperations().size()-1)==op) { Files.copy(imageCache, image); } System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); From 35f01bfa33504a040f31fa2bdb35078974deb49b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 22:56:57 -0400 Subject: [PATCH 365/635] change timeline events to ensure the timeline is populated correctly on load --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7b1f6a4d..876a0f61 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -417,13 +417,13 @@ public Thread deleteOperation(ICaDoodleOpperation op) { try { regenerateFrom(newTar).join(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } updateCurrentFromCache(); updateBoM(); fireSaveSuggestion(); + fireTimelineUpdate(); opperationRunner = null; }); opperationRunner.start(); @@ -774,7 +774,7 @@ public File save() throws IOException { if (bom != null) bom.save(); } - + fireTimelineUpdate(); return getSelf(); } @@ -805,7 +805,7 @@ private void setTimelineImage(List currentState, ICaDoodleOpperation op) th } do { try { - Thread.sleep(100); + Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); return; @@ -816,7 +816,7 @@ private void setTimelineImage(List currentState, ICaDoodleOpperation op) th } System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } - fireTimelineUpdate(); + //fireTimelineUpdate(); } private void fireTimelineUpdate() { From 5ca389d2aaffb291f27bc04476ef5318a98cf496 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Apr 2025 23:13:01 -0400 Subject: [PATCH 366/635] make sure the breaking changes do not continue --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 4 +++- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 876a0f61..1699d011 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -156,7 +156,9 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - opperations.remove(op); + indexStarting = i+1; + break; + //opperations.remove(op); } } setCurrentIndex(indexStarting); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index bf3fd083..b3104d58 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -66,14 +66,14 @@ public List process(List incoming) { if (intersect) holecutter = intersect(holes); else - holecutter = CSG.unionAll(holes); + holecutter = holes.size()==1?holes.get(0):CSG.unionAll(holes); if (hull) holecutter = holecutter.hull(); } if (intersect) result = intersect(solids); else - result = CSG.unionAll(solids); + result =solids.size()==1?solids.get(0): CSG.unionAll(solids); Color c = result.getColor(); if (hull) { result = result.hull(); From 4558bc8105d72228b34df58849e5b13f3d6f04c2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 25 Apr 2025 10:43:29 -0400 Subject: [PATCH 367/635] Adding the git location as the location to place themanufacturing file instead of the directory the target file is locatted in . --- .../bowlerstudio/BowlerKernel.java | 13 ++--- .../scripting/ScriptingEngine.java | 47 ++++++++++--------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index aad3662a..6b0e672d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -196,11 +196,12 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) try { File f = new File(s); - File parentFile = f.getParentFile(); - if(parentFile==null) { - parentFile=new File("."); + String location; + try { + location =ScriptingEngine.locateGitTopLevelDirectory(f).getAbsolutePath(); + }catch(Exception ex) { + location= new File(".").getAbsolutePath(); } - String location =parentFile.getAbsolutePath(); if(location.endsWith(".")) { location=location.substring(0,location.length()-1); } @@ -209,8 +210,8 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } baseWorkspaceFile = new File(location); - com.neuronrobotics.sdk.common.Log.error("Using working directory "+baseWorkspaceFile.getAbsolutePath()); - f=new File(baseWorkspaceFile.getAbsolutePath()+"/"+f.getName()); + System.out.println("Using working directory "+baseWorkspaceFile.getAbsolutePath()); + f=new File(baseWorkspaceFile.getAbsolutePath()+"/"+s); com.neuronrobotics.sdk.common.Log.error("File "+f.getName()); ret = ScriptingEngine.inlineFileScriptRun(f, null); } catch (Throwable e) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index b994c777..a16411a5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -413,20 +413,19 @@ public static boolean isUrlAlreadyOpen(File URL) { public static void openGit(Repository localRepo, IGitAccessor accessor) { Git git = null; - boolean alreadyOpen= false; + boolean alreadyOpen = false; try { String absolutePath = localRepo.getDirectory().getAbsolutePath(); for (String s : open.keySet()) { Git g = open.get(s); - if(g!=null) - if (g.getRepository().getDirectory().getAbsolutePath() - .contentEquals(absolutePath)) { - git=g; - alreadyOpen=true; - break; - } + if (g != null) + if (g.getRepository().getDirectory().getAbsolutePath().contentEquals(absolutePath)) { + git = g; + alreadyOpen = true; + break; + } } - if(!alreadyOpen) { + if (!alreadyOpen) { git = new Git(localRepo); open.put(absolutePath, git); } @@ -434,15 +433,15 @@ public static void openGit(Repository localRepo, IGitAccessor accessor) { try { accessor.run(git); } catch (Throwable t) { - //new IssueReportingExceptionHandler().except(t); + // new IssueReportingExceptionHandler().except(t); throw new RuntimeException(t); } } - if(!alreadyOpen) + if (!alreadyOpen) gitclose(git); } catch (Throwable t) { - //new IssueReportingExceptionHandler().except(t); - if(!alreadyOpen) + // new IssueReportingExceptionHandler().except(t); + if (!alreadyOpen) if (git != null) { gitclose(git); } @@ -459,7 +458,7 @@ private static void gitclose(Git git) { if (git == null) return; open.remove(git.getRepository().getDirectory().getAbsolutePath()); - //git.getRepository().close(); + // git.getRepository().close(); git.close(); } @@ -1765,23 +1764,23 @@ public static String locateGitUrl(File f, Git ref) throws IOException { return null; } - public static void locateGit(File f, IGitAccessor access) throws IOException { + public static File locateGitTopLevelDirectory(File f) throws IOException { File gitRepoFile = f; while (gitRepoFile != null) { gitRepoFile = gitRepoFile.getParentFile(); if (gitRepoFile != null) if (new File(gitRepoFile.getAbsolutePath() + "/.git/config").exists()) { - // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file: - // "+gitRepoFile); - Repository localRepo = new FileRepository(gitRepoFile.getAbsoluteFile() + "/.git"); - openGit(localRepo, access); - return; + return gitRepoFile; } } - throw new RuntimeException("File " + f + " is not in a git repository"); } + public static void locateGit(File f, IGitAccessor access) throws IOException { + Repository localRepo = new FileRepository(locateGitTopLevelDirectory(f).getAbsoluteFile() + "/.git"); + openGit(localRepo, access); + } + public static String getText(URL website) throws Exception { URLConnection connection = website.openConnection(); @@ -2090,16 +2089,18 @@ public static List getAllLangauges() { } return langs; } + public static List getAllExtentions() { ArrayList langs = new ArrayList<>(); for (String L : getLangaugesMap().keySet()) { IScriptingLanguage lang = getLangaugesMap().get(L); - for(String s:lang.getFileExtenetion()) { + for (String s : lang.getFileExtenetion()) { langs.add(s); } } return langs; } + public static HashMap getLangaugesMap() { return langauges; } @@ -2164,7 +2165,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi } String[] newFileCode; try { - System.out.println("Opening "+targetFilename+" from "+targetGit); + System.out.println("Opening " + targetFilename + " from " + targetGit); newFileCode = ScriptingEngine.codeFromGit(targetGit, targetFilename); if (newFileCode == null) newFileCode = new String[] { "" }; From 6a0b0dfd21846a9806b6d0906e9b4c9f1453766e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 25 Apr 2025 14:31:14 -0400 Subject: [PATCH 368/635] make arrow key more reactive --- .../scripting/cadoodle/CaDoodleFile.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1699d011..8ef65d58 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -328,12 +328,14 @@ private void process(ICaDoodleOpperation op) { storeResultInCache(op, process); setCurrentIndex(currentIndex2 + 1); setCurrentState(op, process); - try { - setTimelineImage(process, op); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); - } + new Thread(()->{ + try { + setTimelineImage(process, op); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } + }).start(); } public boolean isOperationRunning() { From 8797025c5021ce81bb65ac3851e3b6b7c1949d07 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 25 Apr 2025 19:29:29 -0400 Subject: [PATCH 369/635] Update the threading to keep the regeneration threads organized --- java-bowler | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 233 +++++++++--------- 2 files changed, 121 insertions(+), 114 deletions(-) diff --git a/java-bowler b/java-bowler index c25c1fe1..e09f747a 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit c25c1fe14d0f7a6a64ad138bca6c15d82af685d1 +Subproject commit e09f747a9f805bdb9ba2e355a7cda5fb2ac5bc76 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8ef65d58..8b5818e0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -33,6 +33,7 @@ import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import com.neuronrobotics.sdk.common.TickToc; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Polygon; @@ -73,7 +74,7 @@ public class CaDoodleFile { .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) .create(); private ArrayList listeners = new ArrayList(); - private Thread opperationRunner = null; + private final ArrayList opperationRunner = new ArrayList(); private boolean regenerating; private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; @@ -93,9 +94,8 @@ public void close() { toProcess.clear(); toProcess = null; img = null; - if (opperationRunner != null) - opperationRunner.interrupt(); - opperationRunner = null; + for (Thread t : opperationRunner) + t.interrupt(); } public CaDoodleFile clearListeners() { @@ -156,9 +156,9 @@ public void initialize() { process(op); } catch (Throwable t) { t.printStackTrace(); - indexStarting = i+1; + indexStarting = i + 1; break; - //opperations.remove(op); + // opperations.remove(op); } } setCurrentIndex(indexStarting); @@ -234,63 +234,60 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { // new Exception("Regenerationg from a position back in time " + endIndex + " but have " + size) // .printStackTrace(); } - opperationRunner = new Thread(() -> { - opperationRunner.setName("Regeneration Thread"); - setRegenerating(true); - // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from - // "+source.getType()); - int opIndex = 0; - for (int i = 0; i < size; i++) { - ICaDoodleOpperation op = opperations.get(i); - if (source == op) { - opIndex = i; - break; + Thread t = null; + t = new Thread() { + public void run() { + + setRegenerating(true); + // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from + // "+source.getType()); + int opIndex = 0; + for (int i = 0; i < size; i++) { + ICaDoodleOpperation op = opperations.get(i); + if (source == op) { + opIndex = i; + break; + } } - } - setCurrentIndex(opIndex); - try { - for (; getCurrentIndex() < size;) { - setCurrentIndex(getCurrentIndex() + 1); - setPercentInitialized(((double) getCurrentIndex()) / size); - // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); - int currentIndex2 = getCurrentIndex() - 1; - ICaDoodleOpperation op = opperations.get(currentIndex2); - getTimelineImageFile(op).delete(); - try { - List process = op.process(getPreviouState()); + setCurrentIndex(opIndex); + try { + for (; getCurrentIndex() < size;) { + setCurrentIndex(getCurrentIndex() + 1); + setPercentInitialized(((double) getCurrentIndex()) / size); + // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); + int currentIndex2 = getCurrentIndex() - 1; + ICaDoodleOpperation op = opperations.get(currentIndex2); + getTimelineImageFile(op).delete(); try { - setTimelineImage(process, op); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); + List process = op.process(getPreviouState()); + storeResultInCache(op, process); + setCurrentState(op, process); + } catch (Throwable tr) { + tr.printStackTrace(); } - storeResultInCache(op, process); - setCurrentState(op, process); - } catch (Throwable tr) { - tr.printStackTrace(); } + if (getCurrentIndex() != endIndex) { + setCurrentIndex(endIndex); + updateCurrentFromCache(); + } + } catch (Exception ex) { + ex.printStackTrace(); } - if (getCurrentIndex() != endIndex) { - setCurrentIndex(endIndex); - updateCurrentFromCache(); - } - } catch (Exception ex) { - ex.printStackTrace(); + setPercentInitialized(1); + updateBoM(); + setRegenerating(false); + fireSaveSuggestion(); + fireRegenerateDone(); + opperationRunner.remove(this); } - setPercentInitialized(1); - updateBoM(); - setRegenerating(false); - fireSaveSuggestion(); - opperationRunner = null; - fireRegenerateDone(); - }); - opperationRunner.start(); - return opperationRunner; + }; + opperationRunner.add(t); + return t; } public Thread regenerateCurrent() { if (isOperationRunning()) { - return opperationRunner; + return opperationRunner.get(0); } if (initializing) { Thread t = new Thread(); @@ -298,27 +295,33 @@ public Thread regenerateCurrent() { return t; } fireRegenerateStart(); - opperationRunner = new Thread(() -> { - opperationRunner.setName("regenerateCurrent Thread"); + Thread t = null; + t = new Thread() { + public void run() { + // TickToc.setEnabled(true); + + this.setName("regenerateCurrent Thread"); ICaDoodleOpperation op = getCurrentOpperation(); + TickToc.tic("Start regenerate"); List process = op.process(getPreviouState()); + TickToc.tic("Finish regenerate"); int currentIndex2 = getCurrentIndex(); getTimelineImageFile(currentIndex2).delete(); - try { - setTimelineImage(process, op); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); - } + TickToc.tic("Get timeline file"); storeResultInCache(op, process); + TickToc.tic("Stored results in cache"); setCurrentState(op, process); + TickToc.tic("set current state"); fireSaveSuggestion(); - opperationRunner = null; + TickToc.tic("Fired save suggestion"); fireRegenerateDone(); - }); - opperationRunner.start(); - return opperationRunner; + TickToc.tic("Fired regeneration Done"); + opperationRunner.remove(this); + }}; + opperationRunner.add(t); + t.start(); + return t; } @@ -328,38 +331,31 @@ private void process(ICaDoodleOpperation op) { storeResultInCache(op, process); setCurrentIndex(currentIndex2 + 1); setCurrentState(op, process); - new Thread(()->{ - try { - setTimelineImage(process, op); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); - } - }).start(); + } public boolean isOperationRunning() { - if (opperationRunner != null) - if (!opperationRunner.isAlive()) - opperationRunner = null; - if (opperationRunner != null) { - if (Thread.currentThread().getId() == opperationRunner.getId()) - return false; - return true; - } else - return false; + for (Thread t : opperationRunner) + if (t != null) { + if (Thread.currentThread().getId() == t.getId()) + return false; + return true; + } + return false; } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { toProcess.add(o); if (isOperationRunning()) { - return opperationRunner; + return opperationRunner.get(0); } - opperationRunner = new Thread(() -> { + Thread t = null; + t =new Thread() { + public void run() { boolean prune = false; while (toProcess.size() > 0) { - opperationRunner.setName("addOpperation Thread " + toProcess.size()); + this.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); OperationResult res = OperationResult.APPEND; if (getCurrentIndex() != getOpperations().size()) { @@ -396,18 +392,21 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc fireSaveSuggestion(); if (prune) fireRegenerateDone(); - opperationRunner = null; - }); - opperationRunner.start(); - return opperationRunner; + opperationRunner.remove(this); + }}; + opperationRunner.add(t); + t.start(); + return t; } public Thread deleteOperation(ICaDoodleOpperation op) { if (isOperationRunning()) { - return opperationRunner; + return opperationRunner.get(0); } - opperationRunner = new Thread(() -> { - opperationRunner.setName("addOpperation Thread " + toProcess.size()); + Thread t = null; + t = new Thread() { + public void run() { + this.setName("addOpperation Thread " + toProcess.size()); int index = 0; for (int i = 0; i < getOpperations().size(); i++) if (getOpperations().get(i) == op) @@ -427,11 +426,11 @@ public Thread deleteOperation(ICaDoodleOpperation op) { updateBoM(); fireSaveSuggestion(); - fireTimelineUpdate(); - opperationRunner = null; - }); - opperationRunner.start(); - return opperationRunner; + opperationRunner.remove(this); + }}; + opperationRunner.add(t); + t.start(); + return t; } public static CSG getByName(List back, String name) { @@ -536,7 +535,7 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { newList.addAll(subList); setOpperations(newList); com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); - fireTimelineUpdate(); + fireSaveSuggestion(); } return res; } @@ -594,7 +593,6 @@ public void back() { setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); fireSaveSuggestion(); - fireTimelineUpdate(); } public void moveToOpIndex(int newIndex) { @@ -605,7 +603,6 @@ public void moveToOpIndex(int newIndex) { setCurrentIndex(newIndex + 1); updateCurrentFromCache(); fireSaveSuggestion(); - fireTimelineUpdate(); } public boolean isBackAvailible() { @@ -631,7 +628,6 @@ public void forward() { setCurrentIndex(getCurrentIndex() + 1); updateCurrentFromCache(); fireSaveSuggestion(); - fireTimelineUpdate(); } public boolean isForwardAvailible() { @@ -720,6 +716,7 @@ private void fireRegenerateDone() { for (ICaDoodleStateUpdate l : listeners) { try { + TickToc.tic("Fire " + l.getClass()); l.onRegenerateDone(); } catch (Throwable e) { e.printStackTrace(); @@ -768,21 +765,32 @@ public String toJson() { public File save() throws IOException { - synchronized (selfInternal) { - String contents = toJson(); - List currentState = getCurrentState(); - int currentIndex2 = getCurrentIndex(); - FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); - if(currentIndex2>0) - setTimelineImage(currentState, getCurrentOpperation()); - if (bom != null) - bom.save(); + // synchronized (selfInternal) { + String contents = toJson(); + List currentState = getCurrentState(); + int currentIndex2 = getCurrentIndex(); + FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); + // } + for (int i = 0; i < opperations.size(); i++) { + File f = getTimelineImageFile(i); + ICaDoodleOpperation op = opperations.get(i); + List process = cache.get(op); + if (!f.exists()) + try { + setSaveImage(process, op); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } } + if (bom != null) + bom.save(); fireTimelineUpdate(); + // System.gc(); return getSelf(); } - private void setTimelineImage(List currentState, ICaDoodleOpperation op) throws IOException { + private void setSaveImage(List currentState, ICaDoodleOpperation op) throws IOException { if (selfInternal == null) return; int currentIndex2 = 0; @@ -815,12 +823,11 @@ private void setTimelineImage(List currentState, ICaDoodleOpperation op) th return; } } while (!imageCache.exists()); - if (getOpperations().get(getOpperations().size()-1)==op) { + if (getOpperations().get(getOpperations().size() - 1) == op) { Files.copy(imageCache, image); } System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } - //fireTimelineUpdate(); } private void fireTimelineUpdate() { From 635a682124b7709c4ad0a0297fbfa928269cfdca Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Apr 2025 08:05:48 -0400 Subject: [PATCH 370/635] Record the time since the last change to the state for use in the save thread --- .../scripting/cadoodle/CaDoodleFile.java | 172 ++++++++++-------- 1 file changed, 92 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 8b5818e0..1e9445a8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -82,6 +82,7 @@ public class CaDoodleFile { private static HashMap bomManagers = new HashMap<>(); private VitaminBomManager bom; private IAcceptPruneForward accept = null; + private long timeOfLastUpdate = 0; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -237,7 +238,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { Thread t = null; t = new Thread() { public void run() { - + timeOfLastUpdate = System.currentTimeMillis(); setRegenerating(true); // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from // "+source.getType()); @@ -298,27 +299,30 @@ public Thread regenerateCurrent() { Thread t = null; t = new Thread() { public void run() { - // TickToc.setEnabled(true); - - this.setName("regenerateCurrent Thread"); - - ICaDoodleOpperation op = getCurrentOpperation(); - TickToc.tic("Start regenerate"); - List process = op.process(getPreviouState()); - TickToc.tic("Finish regenerate"); - int currentIndex2 = getCurrentIndex(); - getTimelineImageFile(currentIndex2).delete(); - TickToc.tic("Get timeline file"); - storeResultInCache(op, process); - TickToc.tic("Stored results in cache"); - setCurrentState(op, process); - TickToc.tic("set current state"); - fireSaveSuggestion(); - TickToc.tic("Fired save suggestion"); - fireRegenerateDone(); - TickToc.tic("Fired regeneration Done"); - opperationRunner.remove(this); - }}; + timeOfLastUpdate = System.currentTimeMillis(); + + // TickToc.setEnabled(true); + + this.setName("regenerateCurrent Thread"); + + ICaDoodleOpperation op = getCurrentOpperation(); + TickToc.tic("Start regenerate"); + List process = op.process(getPreviouState()); + TickToc.tic("Finish regenerate"); + int currentIndex2 = getCurrentIndex(); + getTimelineImageFile(currentIndex2).delete(); + TickToc.tic("Get timeline file"); + storeResultInCache(op, process); + TickToc.tic("Stored results in cache"); + setCurrentState(op, process); + TickToc.tic("set current state"); + fireSaveSuggestion(); + TickToc.tic("Fired save suggestion"); + fireRegenerateDone(); + TickToc.tic("Fired regeneration Done"); + opperationRunner.remove(this); + } + }; opperationRunner.add(t); t.start(); return t; @@ -351,49 +355,51 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc return opperationRunner.get(0); } Thread t = null; - t =new Thread() { + t = new Thread() { public void run() { - boolean prune = false; - while (toProcess.size() > 0) { - this.setName("addOpperation Thread " + toProcess.size()); - ICaDoodleOpperation op = toProcess.remove(0); - OperationResult res = OperationResult.APPEND; - if (getCurrentIndex() != getOpperations().size()) { - try { - prune = true; - fireRegenerateStart(); - res = pruneForward(op); - } catch (Exception e) { - e.printStackTrace(); - break; + timeOfLastUpdate=System.currentTimeMillis(); + boolean prune = false; + while (toProcess.size() > 0) { + this.setName("addOpperation Thread " + toProcess.size()); + ICaDoodleOpperation op = toProcess.remove(0); + OperationResult res = OperationResult.APPEND; + if (getCurrentIndex() != getOpperations().size()) { + try { + prune = true; + fireRegenerateStart(); + res = pruneForward(op); + } catch (Exception e) { + e.printStackTrace(); + break; + } } - } - if (res == OperationResult.APPEND || res == OperationResult.PRUNE) { - try { - getOpperations().add(op); - process(op); - } catch (Exception ex) { - ex.printStackTrace(); + if (res == OperationResult.APPEND || res == OperationResult.PRUNE) { + try { + getOpperations().add(op); + process(op); + } catch (Exception ex) { + ex.printStackTrace(); + } } - } - if (res == OperationResult.INSERT) { - getOpperations().add(getCurrentIndex(), op); - setCurrentIndex(getCurrentIndex() + 1); - try { - regenerateFrom(op).join(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (res == OperationResult.INSERT) { + getOpperations().add(getCurrentIndex(), op); + setCurrentIndex(getCurrentIndex() + 1); + try { + regenerateFrom(op).join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + updateCurrentFromCache(); } - updateCurrentFromCache(); } + updateBoM(); + fireSaveSuggestion(); + if (prune) + fireRegenerateDone(); + opperationRunner.remove(this); } - updateBoM(); - fireSaveSuggestion(); - if (prune) - fireRegenerateDone(); - opperationRunner.remove(this); - }}; + }; opperationRunner.add(t); t.start(); return t; @@ -406,28 +412,31 @@ public Thread deleteOperation(ICaDoodleOpperation op) { Thread t = null; t = new Thread() { public void run() { - this.setName("addOpperation Thread " + toProcess.size()); - int index = 0; - for (int i = 0; i < getOpperations().size(); i++) - if (getOpperations().get(i) == op) - index = i; - getOpperations().remove(op); - if (index == getOpperations().size()) - index -= 1; - if (index < 1) - index = 1; - ICaDoodleOpperation newTar = getOpperations().get(index - 1); - try { - regenerateFrom(newTar).join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - updateCurrentFromCache(); + timeOfLastUpdate=System.currentTimeMillis(); + this.setName("addOpperation Thread " + toProcess.size()); + int index = 0; + for (int i = 0; i < getOpperations().size(); i++) + if (getOpperations().get(i) == op) + index = i; + getOpperations().remove(op); + if (index == getOpperations().size()) + index -= 1; + if (index < 1) + index = 1; + ICaDoodleOpperation newTar = getOpperations().get(index - 1); + try { + regenerateFrom(newTar).join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + setCurrentIndex(getCurrentIndex() - 1); + updateCurrentFromCache(); - updateBoM(); - fireSaveSuggestion(); - opperationRunner.remove(this); - }}; + updateBoM(); + fireSaveSuggestion(); + opperationRunner.remove(this); + } + }; opperationRunner.add(t); t.start(); return t; @@ -1002,4 +1011,7 @@ public void setAccept(IAcceptPruneForward accept) { this.accept = accept; } + public long timeSinceLastUpdate() { + return System.currentTimeMillis()-timeOfLastUpdate; + } } From 4c4208bb44971fd52a6b9f252abe2ee73a6c0852 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Apr 2025 09:10:52 -0400 Subject: [PATCH 371/635] ensure the thread runners die properly --- .../scripting/cadoodle/CaDoodleFile.java | 98 +++++++++++-------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1e9445a8..6bceb064 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -225,7 +225,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) return null; if (isRegenerating() || isOperationRunning()) { - System.err.println("Opperation is running, ignoring regen"); + new Exception("Operation Running, bailing").printStackTrace(); return null; } fireRegenerateStart(); @@ -238,47 +238,52 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { Thread t = null; t = new Thread() { public void run() { - timeOfLastUpdate = System.currentTimeMillis(); - setRegenerating(true); - // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from - // "+source.getType()); - int opIndex = 0; - for (int i = 0; i < size; i++) { - ICaDoodleOpperation op = opperations.get(i); - if (source == op) { - opIndex = i; - break; - } - } - setCurrentIndex(opIndex); + this.setName("Regeneration Threads"); try { - for (; getCurrentIndex() < size;) { - setCurrentIndex(getCurrentIndex() + 1); - setPercentInitialized(((double) getCurrentIndex()) / size); - // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); - int currentIndex2 = getCurrentIndex() - 1; - ICaDoodleOpperation op = opperations.get(currentIndex2); - getTimelineImageFile(op).delete(); - try { - List process = op.process(getPreviouState()); - storeResultInCache(op, process); - setCurrentState(op, process); - } catch (Throwable tr) { - tr.printStackTrace(); + timeOfLastUpdate = System.currentTimeMillis(); + setRegenerating(true); + // com.neuronrobotics.sdk.common.Log.error("Regenerating Object from + // "+source.getType()); + int opIndex = 0; + for (int i = 0; i < size; i++) { + ICaDoodleOpperation op = opperations.get(i); + if (source == op) { + opIndex = i; + break; } } - if (getCurrentIndex() != endIndex) { - setCurrentIndex(endIndex); - updateCurrentFromCache(); + setCurrentIndex(opIndex); + try { + for (; getCurrentIndex() < size;) { + setCurrentIndex(getCurrentIndex() + 1); + setPercentInitialized(((double) getCurrentIndex()) / size); + // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); + int currentIndex2 = getCurrentIndex() - 1; + ICaDoodleOpperation op = opperations.get(currentIndex2); + getTimelineImageFile(op).delete(); + try { + List process = op.process(getPreviouState()); + storeResultInCache(op, process); + setCurrentState(op, process); + } catch (Throwable tr) { + tr.printStackTrace(); + } + } + if (getCurrentIndex() != endIndex) { + setCurrentIndex(endIndex); + updateCurrentFromCache(); + } + } catch (Exception ex) { + ex.printStackTrace(); } - } catch (Exception ex) { - ex.printStackTrace(); + setPercentInitialized(1); + updateBoM(); + setRegenerating(false); + fireSaveSuggestion(); + fireRegenerateDone(); + } catch (Throwable th) { + th.printStackTrace(); } - setPercentInitialized(1); - updateBoM(); - setRegenerating(false); - fireSaveSuggestion(); - fireRegenerateDone(); opperationRunner.remove(this); } }; @@ -288,6 +293,8 @@ public void run() { public Thread regenerateCurrent() { if (isOperationRunning()) { + new Exception("Operation Running, bailing").printStackTrace(); + return opperationRunner.get(0); } if (initializing) { @@ -339,25 +346,33 @@ private void process(ICaDoodleOpperation op) { } public boolean isOperationRunning() { - for (Thread t : opperationRunner) + for (int i = 0; i < opperationRunner.size(); i++) { + Thread t = opperationRunner.get(i); if (t != null) { + if(!t.isAlive()) { + opperationRunner.remove(t); + new Exception("Thread failed to remove itself "+t.getName()).printStackTrace(); + continue; + } if (Thread.currentThread().getId() == t.getId()) return false; return true; } + } return false; } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { toProcess.add(o); if (isOperationRunning()) { + new Exception("Operation Running, bailing").printStackTrace(); return opperationRunner.get(0); } Thread t = null; t = new Thread() { public void run() { - timeOfLastUpdate=System.currentTimeMillis(); + timeOfLastUpdate = System.currentTimeMillis(); boolean prune = false; while (toProcess.size() > 0) { this.setName("addOpperation Thread " + toProcess.size()); @@ -407,12 +422,13 @@ public void run() { public Thread deleteOperation(ICaDoodleOpperation op) { if (isOperationRunning()) { + new Exception("Operation Running, bailing").printStackTrace(); return opperationRunner.get(0); } Thread t = null; t = new Thread() { public void run() { - timeOfLastUpdate=System.currentTimeMillis(); + timeOfLastUpdate = System.currentTimeMillis(); this.setName("addOpperation Thread " + toProcess.size()); int index = 0; for (int i = 0; i < getOpperations().size(); i++) @@ -1012,6 +1028,6 @@ public void setAccept(IAcceptPruneForward accept) { } public long timeSinceLastUpdate() { - return System.currentTimeMillis()-timeOfLastUpdate; + return System.currentTimeMillis() - timeOfLastUpdate; } } From 92af527fb629cfa1131735fe6fe696cb370ea462 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Apr 2025 10:20:53 -0400 Subject: [PATCH 372/635] ensure teh regeneration thread starts make sure all fo the operatiosn go through the getter ensure all operations added are cached --- .../scripting/cadoodle/CaDoodleFile.java | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6bceb064..c619571f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -150,9 +150,9 @@ public void initialize() { int indexStarting = getCurrentIndex(); setCurrentIndex(0); setPercentInitialized(0); - for (int i = 0; i < opperations.size(); i++) { - ICaDoodleOpperation op = opperations.get(i); - setPercentInitialized(((double) i) / (double) opperations.size()); + for (int i = 0; i < getOpperations().size(); i++) { + ICaDoodleOpperation op = getOpperations().get(i); + setPercentInitialized(((double) i) / (double) getOpperations().size()); try { process(op); } catch (Throwable t) { @@ -230,7 +230,7 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { } fireRegenerateStart(); int endIndex = getCurrentIndex(); - double size = opperations.size(); + double size = getOpperations().size(); if (endIndex != size) { // new Exception("Regenerationg from a position back in time " + endIndex + " but have " + size) // .printStackTrace(); @@ -246,7 +246,7 @@ public void run() { // "+source.getType()); int opIndex = 0; for (int i = 0; i < size; i++) { - ICaDoodleOpperation op = opperations.get(i); + ICaDoodleOpperation op = getOpperations().get(i); if (source == op) { opIndex = i; break; @@ -259,7 +259,7 @@ public void run() { setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; - ICaDoodleOpperation op = opperations.get(currentIndex2); + ICaDoodleOpperation op = getOpperations().get(currentIndex2); getTimelineImageFile(op).delete(); try { List process = op.process(getPreviouState()); @@ -288,6 +288,7 @@ public void run() { } }; opperationRunner.add(t); + t.start(); return t; } @@ -349,9 +350,10 @@ public boolean isOperationRunning() { for (int i = 0; i < opperationRunner.size(); i++) { Thread t = opperationRunner.get(i); if (t != null) { - if(!t.isAlive()) { + if (!t.isAlive()) { opperationRunner.remove(t); - new Exception("Thread failed to remove itself "+t.getName()).printStackTrace(); + // new Exception("Thread failed to remove itself + // "+t.getName()).printStackTrace(); continue; } if (Thread.currentThread().getId() == t.getId()) @@ -366,7 +368,6 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc toProcess.add(o); if (isOperationRunning()) { new Exception("Operation Running, bailing").printStackTrace(); - return opperationRunner.get(0); } Thread t = null; @@ -398,11 +399,10 @@ public void run() { } if (res == OperationResult.INSERT) { getOpperations().add(getCurrentIndex(), op); - setCurrentIndex(getCurrentIndex() + 1); + process(op); try { regenerateFrom(op).join(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } updateCurrentFromCache(); @@ -440,14 +440,13 @@ public void run() { if (index < 1) index = 1; ICaDoodleOpperation newTar = getOpperations().get(index - 1); + setCurrentIndex(index - 1); try { regenerateFrom(newTar).join(); } catch (InterruptedException e) { e.printStackTrace(); } - setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); - updateBoM(); fireSaveSuggestion(); opperationRunner.remove(this); @@ -702,7 +701,9 @@ public List getSelect(List selectedSnapshot) { public List getPreviouState() { if (getCurrentIndex() < 2) return new ArrayList(); - return cache.get(getOpperations().get(getCurrentIndex() - 2)); + ICaDoodleOpperation key = getOpperations().get(getCurrentIndex() - 2); + + return cache.get(key); } private void setCurrentState(ICaDoodleOpperation op, List currentState) { @@ -830,28 +831,32 @@ private void setSaveImage(List currentState, ICaDoodleOpperation op) throws if (imageCache.exists()) return; - WritableImage image2 = loadingImageFromUIThread(currentState); - if (image2 != null) { - BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); - try { - ImageIO.write(bufferedImage, "png", imageCache); - } catch (IOException e) { - // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + - // e.getMessage()); - e.printStackTrace(); - } - do { + try { + WritableImage image2 = loadingImageFromUIThread(currentState); + if (image2 != null) { + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image2, null); try { - Thread.sleep(10); - } catch (InterruptedException e) { + ImageIO.write(bufferedImage, "png", imageCache); + } catch (IOException e) { + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + + // e.getMessage()); e.printStackTrace(); - return; } - } while (!imageCache.exists()); - if (getOpperations().get(getOpperations().size() - 1) == op) { - Files.copy(imageCache, image); + do { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } + } while (!imageCache.exists()); + if (getOpperations().get(getOpperations().size() - 1) == op) { + Files.copy(imageCache, image); + } + System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } - System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); + } catch (Throwable t) { + t.printStackTrace(); } } @@ -881,6 +886,8 @@ public WritableImage loadImageFromFile() { } private javafx.scene.image.WritableImage loadingImageFromUIThread(List currentState) { + if (currentState == null) + throw new RuntimeException("Can not be null"); ArrayList holder = new ArrayList(); try { BowlerKernel.runLater(() -> { @@ -971,7 +978,7 @@ public int getCurrentIndex() { public void setCurrentIndex(int currentIndex) { // new Exception("Current Index set to " + currentIndex).printStackTrace(); - if ((currentIndex - 1) >= opperations.size()) + if ((currentIndex - 1) >= getOpperations().size()) throw new RuntimeException("Fail! Can not set an index greater than the availible operations"); this.currentIndex = currentIndex; } From 9c6a36185fc4bb139b061d54ca031cf0c29ec854 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Apr 2025 10:24:53 -0400 Subject: [PATCH 373/635] send the number of images updated in timeline --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 +++++--- .../scripting/cadoodle/ICaDoodleStateUpdate.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index c619571f..90c9530e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -797,12 +797,14 @@ public File save() throws IOException { int currentIndex2 = getCurrentIndex(); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); // } + int num=0; for (int i = 0; i < opperations.size(); i++) { File f = getTimelineImageFile(i); ICaDoodleOpperation op = opperations.get(i); List process = cache.get(op); if (!f.exists()) try { + num++; setSaveImage(process, op); } catch (IOException e) { // Auto-generated catch block @@ -811,7 +813,7 @@ public File save() throws IOException { } if (bom != null) bom.save(); - fireTimelineUpdate(); + fireTimelineUpdate(num); // System.gc(); return getSelf(); } @@ -860,9 +862,9 @@ private void setSaveImage(List currentState, ICaDoodleOpperation op) throws } } - private void fireTimelineUpdate() { + private void fireTimelineUpdate(int number) { for (ICaDoodleStateUpdate s : listeners) { - s.onTimelineUpdate(); + s.onTimelineUpdate(number); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index d2e47e77..d4706c09 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -14,5 +14,5 @@ public interface ICaDoodleStateUpdate { public void onRegenerateDone(); public void onRegenerateStart(); public void onWorkplaneChange(TransformNR newWP); - public void onTimelineUpdate(); + public void onTimelineUpdate(int numberOfNew); } From a57f2ba328670213247c42ce332010f744f16647 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Apr 2025 15:46:12 -0400 Subject: [PATCH 374/635] dix the index walking of the delete operation --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 90c9530e..51d1c351 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -440,7 +440,7 @@ public void run() { if (index < 1) index = 1; ICaDoodleOpperation newTar = getOpperations().get(index - 1); - setCurrentIndex(index - 1); + setCurrentIndex(index ); try { regenerateFrom(newTar).join(); } catch (InterruptedException e) { From 6308afb14b9ef72796544dc7bf96823d00c1a99a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 14:55:43 -0400 Subject: [PATCH 375/635] Making thee location part of the paste operation based on how the move center usis the thransforms --- .../bowlerstudio/scripting/cadoodle/Paste.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 6e9cdf35..efa7ed8c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -95,16 +95,19 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { clone.setRegenerate(c.getRegenerate()).setName(name); clone.getStorage().set("PreviousName", prevName); Transform nrToCSG = MoveCenter.getTotalOffset(c); + + Transform nrToCSG2 = TransformFactory.nrToCSG(location); CSG newOne = null; if (CaDoodleVitamin.isVitamin(c)) { CSG regenerate = clone.getRegenerate().regenerate(clone); - newOne = regenerate.transformed(nrToCSG); + newOne = regenerate.transformed(nrToCSG).transformed(nrToCSG2); newOne.setRegenerate(regenerate.getRegenerate()); }else { - newOne = clone; + newOne = clone.transformed(nrToCSG2); newOne.setRegenerate(c.getRegenerate()); } newOne.syncProperties(c).setName(name); + MoveCenter.set(name, newOne, location); index++; getNamesAdded().add(name); ArrayList b = new ArrayList<>(); From 5df3a5f59217217a53684b5ee9696ff23f1d673c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 15:41:14 -0400 Subject: [PATCH 376/635] Add a getter for the objects at a given staate --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 51d1c351..07690ea1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -676,9 +676,12 @@ public CaDoodleFile setSelf(File self) { } public List getCurrentState() { + return getStateAtOperation(getCurrentOpperation()); + } + public List getStateAtOperation(ICaDoodleOpperation op) { if (getCurrentIndex() == 0) return new ArrayList(); - List list = cache.get(getCurrentOpperation()); + List list = cache.get(op); if (list == null) list = new ArrayList(); return list; From bfd32e572331a8aa03364552c01de9078d5c4e0f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 16:44:29 -0400 Subject: [PATCH 377/635] paste needs to accomidate hull operations, which are groups that have jsut one input --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index efa7ed8c..f2c314be 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -56,8 +56,8 @@ public ArrayList process(CSG ic, int depth) { CSG source = CaDoodleFile.getByName(back, from); if (source.isGroupResult()) { ArrayList c = constituants(back, from); - if(c.size()<2) - throw new RuntimeException("A group result must have at least 2 constituants!"); + if(c.size()<1) + throw new RuntimeException("A group result must have at least 1 constituants!"); String newGroupName = CaDoodleFile.getByName(back, cpMap.get(from)).getName(); for (String s : c) { CSG dest = CaDoodleFile.getByName(back, s); From ef74adbb547c686819a67f777dd324fb77c91bad Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 16:58:18 -0400 Subject: [PATCH 378/635] on abort the model should re-show the current state. --- .../scripting/cadoodle/CaDoodleFile.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 07690ea1..5fe57196 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -83,6 +83,7 @@ public class CaDoodleFile { private VitaminBomManager bom; private IAcceptPruneForward accept = null; private long timeOfLastUpdate = 0; + private OperationResult result = OperationResult.APPEND; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { @@ -373,23 +374,24 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc Thread t = null; t = new Thread() { public void run() { + timeOfLastUpdate = System.currentTimeMillis(); boolean prune = false; while (toProcess.size() > 0) { + result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); - OperationResult res = OperationResult.APPEND; if (getCurrentIndex() != getOpperations().size()) { try { prune = true; fireRegenerateStart(); - res = pruneForward(op); + setResult(pruneForward(op)); } catch (Exception e) { e.printStackTrace(); break; } } - if (res == OperationResult.APPEND || res == OperationResult.PRUNE) { + if (getResult() == OperationResult.APPEND || getResult() == OperationResult.PRUNE) { try { getOpperations().add(op); process(op); @@ -397,7 +399,7 @@ public void run() { ex.printStackTrace(); } } - if (res == OperationResult.INSERT) { + if (getResult() == OperationResult.INSERT) { getOpperations().add(getCurrentIndex(), op); process(op); try { @@ -407,6 +409,9 @@ public void run() { } updateCurrentFromCache(); } + if(getResult()==OperationResult.ABORT) { + setCurrentState(getCurrentOpperation(), getCurrentState()); + } } updateBoM(); fireSaveSuggestion(); @@ -1042,4 +1047,12 @@ public void setAccept(IAcceptPruneForward accept) { public long timeSinceLastUpdate() { return System.currentTimeMillis() - timeOfLastUpdate; } + + public OperationResult getResult() { + return result; + } + + public void setResult(OperationResult result) { + this.result = result; + } } From e81f6762c43c9e04b81fbd146d16ca83350e8e3b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 22:07:28 -0400 Subject: [PATCH 379/635] always fire teh regeneration done when adding anything --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 5fe57196..7aa35ca9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -415,8 +415,7 @@ public void run() { } updateBoM(); fireSaveSuggestion(); - if (prune) - fireRegenerateDone(); + fireRegenerateDone(); opperationRunner.remove(this); } }; From 04be30ecce08f43edb525922a5d403375c99f737 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Apr 2025 22:38:33 -0400 Subject: [PATCH 380/635] Make sure the delete step selects the correct next operation --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7aa35ca9..e1a36196 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -439,8 +439,8 @@ public void run() { if (getOpperations().get(i) == op) index = i; getOpperations().remove(op); - if (index == getOpperations().size()) - index -= 1; +// if (index == getOpperations().size()) +// index -= 1; if (index < 1) index = 1; ICaDoodleOpperation newTar = getOpperations().get(index - 1); @@ -545,6 +545,7 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { return res; } } + if( getCurrentIndex() >0) for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { ICaDoodleOpperation key = getOpperations().get(i); if (i >= getCurrentIndex()) { From 5c6c773da6e7aa04e774ddcfdfd5745f22111130 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 29 Apr 2025 10:33:08 -0400 Subject: [PATCH 381/635] Add a status update for displaying time consuming operation status' Allow the cadoodle file to display the status of which time consuming status it is working on and what the overall percentage is. --- .../scripting/cadoodle/CaDoodleFile.java | 28 +++++++++++++++++-- .../cadoodle/ICadoodleSaveStatusUpdate.java | 5 ++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleSaveStatusUpdate.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e1a36196..ba776497 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -84,7 +84,13 @@ public class CaDoodleFile { private IAcceptPruneForward accept = null; private long timeOfLastUpdate = 0; private OperationResult result = OperationResult.APPEND; - + private ICadoodleSaveStatusUpdate defaultSaver=new ICadoodleSaveStatusUpdate() { + @Override + public void renderSplashFrame(int percent, String message) { + System.out.println(percent+"% "+message); + } + }; + private ICadoodleSaveStatusUpdate saveUpdate =null; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); @@ -256,11 +262,13 @@ public void run() { setCurrentIndex(opIndex); try { for (; getCurrentIndex() < size;) { + int percent =(int)( ((double )getCurrentIndex())/((double)getOpperations().size())*100.0); setCurrentIndex(getCurrentIndex() + 1); setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; ICaDoodleOpperation op = getOpperations().get(currentIndex2); + getSaveUpdate().renderSplashFrame(percent, "Regenerating "+op.getType()+" "+currentIndex2); getTimelineImageFile(op).delete(); try { List process = op.process(getPreviouState()); @@ -803,17 +811,22 @@ public File save() throws IOException { String contents = toJson(); List currentState = getCurrentState(); int currentIndex2 = getCurrentIndex(); + getSaveUpdate().renderSplashFrame(1, "Save Doodle to "+selfInternal.getName()); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); // } int num=0; for (int i = 0; i < opperations.size(); i++) { File f = getTimelineImageFile(i); ICaDoodleOpperation op = opperations.get(i); + int percent =(int)( ((double )i)/((double)opperations.size())*100.0); List process = cache.get(op); if (!f.exists()) try { num++; + getSaveUpdate().renderSplashFrame(percent, "Save Timeline Image "+i+".png"); + setSaveImage(process, op); + } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -821,6 +834,7 @@ public File save() throws IOException { } if (bom != null) bom.save(); + getSaveUpdate().renderSplashFrame(100, "Doofle save Done "); fireTimelineUpdate(num); // System.gc(); return getSelf(); @@ -863,7 +877,7 @@ private void setSaveImage(List currentState, ICaDoodleOpperation op) throws if (getOpperations().get(getOpperations().size() - 1) == op) { Files.copy(imageCache, image); } - System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); + //System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } } catch (Throwable t) { t.printStackTrace(); @@ -1055,4 +1069,14 @@ public OperationResult getResult() { public void setResult(OperationResult result) { this.result = result; } + + public ICadoodleSaveStatusUpdate getSaveUpdate() { + if(saveUpdate==null) + return defaultSaver; + return saveUpdate; + } + + public void setSaveUpdate(ICadoodleSaveStatusUpdate saveUpdate) { + this.saveUpdate = saveUpdate; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleSaveStatusUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleSaveStatusUpdate.java new file mode 100644 index 00000000..539d5b07 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleSaveStatusUpdate.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public interface ICadoodleSaveStatusUpdate { + public void renderSplashFrame(int percent, String message); +} From 0419f5fe0a7a6f5ebf2fe8e53f2a69ff6964a7a4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 29 Apr 2025 18:56:33 -0400 Subject: [PATCH 382/635] fix the issue where group of a hole with an object it doesnt touch caused an error --- .../bowlerstudio/scripting/cadoodle/Group.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index b3104d58..63323e82 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -78,8 +78,13 @@ public List process(List incoming) { if (hull) { result = result.hull(); } - if (holecutter != null) - result = result.difference(holecutter); + if (holecutter != null) { + if(result.getBounds().isBoundsTouching(holecutter.getBounds())) { + result = result.difference(holecutter); + }else + result=result.clone(); + } + result.setIsHole(false); result.setColor(c); } From fbab0ca42982649a76ed747242b28b1061c32afc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 29 Apr 2025 18:56:33 -0400 Subject: [PATCH 383/635] fix the issue where group of a hole with an object it doesnt touch caused an error --- .../bowlerstudio/scripting/cadoodle/Group.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index b3104d58..f135eb7f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -73,13 +73,17 @@ public List process(List incoming) { if (intersect) result = intersect(solids); else - result =solids.size()==1?solids.get(0): CSG.unionAll(solids); + result =solids.size()==1?solids.get(0).clone(): CSG.unionAll(solids); Color c = result.getColor(); if (hull) { result = result.hull(); } - if (holecutter != null) - result = result.difference(holecutter); + if (holecutter != null) { + if(result.getBounds().isBoundsTouching(holecutter.getBounds())) { + result = result.difference(holecutter); + } + } + result.setIsHole(false); result.setColor(c); } From c6f8dc7e7bbfaa73354b0b7698a66df4e1a600a4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 2 May 2025 13:33:16 -0400 Subject: [PATCH 384/635] add prints --- src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 6b0e672d..5c43cfbf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -393,7 +393,7 @@ private static void finish(long startTime) { public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { processUIOpening(ret); if(baseWorkspaceFile!=null) - com.neuronrobotics.sdk.common.Log.error("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); + System.out.println("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); if (baseWorkspaceFile != null) { From 0a0e45a7c507e6251404021422ae9fe341d4bbd3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 4 May 2025 10:35:25 -0400 Subject: [PATCH 385/635] have each operation be able to return what objects it is operation on --- .../bowlerstudio/scripting/cadoodle/AbstractAddFrom.java | 8 ++++++++ .../scripting/cadoodle/ICaDoodleOpperation.java | 1 + 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index e2462731..3a0788a3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -2,7 +2,9 @@ import java.io.File; import java.nio.file.NoSuchFileException; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import com.google.gson.annotations.Expose; @@ -16,6 +18,12 @@ public abstract class AbstractAddFrom implements ICaDoodleOpperation { public HashSet getNamesAdded() { return namesAdded; } + public List getNames(){ + ArrayList names= new ArrayList(); + names.addAll(getNamesAdded()); + return names; + } + public String getName() { if (name == null) { setName(RandomStringFactory.generateRandomString()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java index 74d1afe7..64863488 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java @@ -8,4 +8,5 @@ public interface ICaDoodleOpperation { public String getType(); public List process(List incoming); + public List getNames(); } From 1a0d1ec835a74f5deaeeb77d2ca04d0d90cc565f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 4 May 2025 10:54:18 -0400 Subject: [PATCH 386/635] Mae sure all of the objects the op is applied to and the results are returned in the getNames method --- .../bowlerstudio/scripting/cadoodle/Group.java | 7 +++++-- .../bowlerstudio/scripting/cadoodle/Paste.java | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index f135eb7f..21a43356 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -104,9 +104,12 @@ private CSG intersect(ArrayList solids) { } return first; } - + @Override public List getNames() { - return names; + ArrayList n= new ArrayList(); + n.addAll(getNamesAdded()); + n.addAll(names); + return n; } public Group setNames(List names) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index f2c314be..10ff19fa 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -128,7 +128,10 @@ public Paste setLocation(TransformNR location) { } public List getNames() { - return names; + ArrayList n= new ArrayList(); + n.addAll(getNamesAdded()); + n.addAll(names); + return n; } public Paste setNames(List names) { From 9bbc608ef61b590af3c750e1e7b0d97b660f4fe7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 7 May 2025 09:13:45 -0400 Subject: [PATCH 387/635] close https://github.com/CommonWealthRobotics/BowlerStudio/issues/452 --- .../neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 7d4baebc..7ba7d473 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -37,6 +37,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.eclipse.jgit.api.errors.CheckoutConflictException; @@ -270,7 +272,7 @@ public static File getScriptFile(String type) { return null; } - public static Map getMeta(String type) { + public static ConcurrentHashMap getMeta(String type) { return getConfiguration(type, "meta"); } @@ -279,7 +281,7 @@ public static void setScript(String type, String git, String file) throws Except setParameter(type, "meta", "scriptFile", file); } - public static Map getConfiguration(String type, String id) { + public static ConcurrentHashMap getConfiguration(String type, String id) { ConcurrentHashMap> database = getDatabase(type); if (id== null) { id=Vitamins.listVitaminSizes(type).get(0); @@ -292,7 +294,7 @@ public static Map getConfiguration(String type, String id) { String key = (String) array[i]; sanatize(key, ConcurrentHashMap); } - return Collections.unmodifiableMap(ConcurrentHashMap); + return ConcurrentHashMap; }catch(Exception ex) { ex.printStackTrace(); } From 6f4cafebae14706307263022d480ec49626c2fe2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 7 May 2025 11:22:29 -0400 Subject: [PATCH 388/635] make sure failing task does not blow up the build --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index ba776497..7a0ae7eb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -481,9 +481,13 @@ public static int applyToAllConstituantElements(boolean addRet, List tar ICadoodleRecursiveEvent p, int depth) { for (int i = 0; i < targetNames.size(); i++) { String s = targetNames.get(i); - CSG c = getByName(back, s); - if (c.isInGroup()) - continue; + try { + CSG c = getByName(back, s); + if (c.isInGroup()) + continue; + }catch(Exception ex) { + ex.printStackTrace(); + } applyToAllConstituantElements(addRet, s, back, p, depth); } return back.size(); From e5d74c7c3b007f3ec441916e96fdb92f639ab7cb Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 9 May 2025 14:33:21 -0400 Subject: [PATCH 389/635] Adding memory check --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7a0ae7eb..ef5c7368 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -594,6 +594,11 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { // cachedCopy.add(c); } cache.put(op, cachedCopy); + Runtime runtime = Runtime.getRuntime(); + long totalMemory = runtime.totalMemory(); // Current heap size + long freeMemory = runtime.freeMemory(); // Free memory in the heap + long maxMemory = runtime.maxMemory(); // Maximum heap size + long usedMemory = totalMemory - freeMemory; } private CSG cloneCSG(CSG dyingCSG) { From aef0d399ea3f526c9601cc762a4566b545043e83 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 13 May 2025 13:58:23 -0400 Subject: [PATCH 390/635] Add a thumbnail update and a print for mem usage --- .../bowlerstudio/creature/ThumbnailImage.java | 18 +++++++++------ .../scripting/cadoodle/CaDoodleFile.java | 22 ++++++++++++++----- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 2dc8acdc..d11e167d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -84,16 +84,20 @@ public static WritableImage get(List c) { continue; if(csg.isInGroup()) continue; - MeshView meshView = csg.movez(-zCenter).getMesh(); - if (csg.isHole()) { + try { + MeshView meshView = csg.movez(-zCenter).getMesh(); PhongMaterial material = new PhongMaterial(); - material.setDiffuseColor(new Color(0.25, 0.25, 0.25, 0.75)); + if (csg.isHole()) { + material.setDiffuseColor(new Color(0.25, 0.25, 0.25, 0.75)); + meshView.setMaterial(material); + meshView.setOpacity(0.25); + } material.setSpecularColor(javafx.scene.paint.Color.WHITE); - meshView.setMaterial(material); - meshView.setOpacity(0.25); + meshView.setCullFace(CullFace.BACK); + root.getChildren().add(meshView); + }catch(Throwable t) { + t.printStackTrace(); } - meshView.setCullFace(CullFace.BACK); - root.getChildren().add(meshView); } // Calculate the bounds of all CSGs combined diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index ef5c7368..7e0898e4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -594,13 +594,18 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { // cachedCopy.add(c); } cache.put(op, cachedCopy); - Runtime runtime = Runtime.getRuntime(); - long totalMemory = runtime.totalMemory(); // Current heap size - long freeMemory = runtime.freeMemory(); // Free memory in the heap - long maxMemory = runtime.maxMemory(); // Maximum heap size - long usedMemory = totalMemory - freeMemory; + System.out.println("\n\nUpdated Memory use: "+getFreeMemory()+"\n\n"); } + public static double getFreeMemory() { + Runtime runtime = Runtime.getRuntime(); + long maxMemory = runtime.maxMemory(); // Maximum memory the JVM will attempt to use + long totalMemory = runtime.totalMemory(); // Total memory currently allocated to the JVM + long freeMemory = runtime.freeMemory(); // Free memory within the allocated memory + long usedMemory = totalMemory - freeMemory; // Actually used memory + // Calculate the percentage of maximum memory that's currently being used + return (usedMemory * 100.0) / maxMemory; + } private CSG cloneCSG(CSG dyingCSG) { CSG csg = new CSG(); @@ -930,7 +935,8 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr ex.printStackTrace(); return null; } - while (holder.size() == 0) + long start = System.currentTimeMillis(); + while (holder.size() == 0) { try { Thread.sleep(16); // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); @@ -939,6 +945,10 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr e.printStackTrace(); break; } + if(System.currentTimeMillis()-start>2500 && holder.size()==0) { + throw new RuntimeException("Failed to create image"); + } + } return holder.get(0); } From 425366b484e656e3d75e3ae5a3f263933ace7d29 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 15 May 2025 10:26:41 -0400 Subject: [PATCH 391/635] Null check any incoming cadoodle operation and throw an exception into any program that tries to add one. --- .../scripting/cadoodle/CaDoodleFile.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7e0898e4..43b39937 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -159,6 +159,8 @@ public void initialize() { setPercentInitialized(0); for (int i = 0; i < getOpperations().size(); i++) { ICaDoodleOpperation op = getOpperations().get(i); + if(op==null) + continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); try { process(op); @@ -231,7 +233,7 @@ private static String getCadoodleFileLocation() { public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) return null; - if (isRegenerating() || isOperationRunning()) { + if (isRegenerating() || isOperationRunning()||source==null) { new Exception("Operation Running, bailing").printStackTrace(); return null; } @@ -374,6 +376,8 @@ public boolean isOperationRunning() { } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { + if(o==null) + throw new NullPointerException(); toProcess.add(o); if (isOperationRunning()) { new Exception("Operation Running, bailing").printStackTrace(); @@ -384,14 +388,12 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc public void run() { timeOfLastUpdate = System.currentTimeMillis(); - boolean prune = false; while (toProcess.size() > 0) { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); ICaDoodleOpperation op = toProcess.remove(0); if (getCurrentIndex() != getOpperations().size()) { try { - prune = true; fireRegenerateStart(); setResult(pruneForward(op)); } catch (Exception e) { @@ -433,6 +435,8 @@ public void run() { } public Thread deleteOperation(ICaDoodleOpperation op) { + if(op==null) + throw new NullPointerException(); if (isOperationRunning()) { new Exception("Operation Running, bailing").printStackTrace(); return opperationRunner.get(0); @@ -550,6 +554,8 @@ public File getTimelineImageFile(int i) { } private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { + if(op==null) + throw new NullPointerException(); OperationResult res = OperationResult.INSERT; if (getAccept() != null) { res = getAccept().accept(); From 3f62a5860ce63e182e6a35b0621812fbdd4eae59 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 15 May 2025 15:24:24 -0400 Subject: [PATCH 392/635] filter out nulls --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 43b39937..4e79620c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -11,13 +11,16 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Random; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Collectors; import javax.imageio.ImageIO; import javafx.scene.image.WritableImage; import org.apache.commons.io.FileUtils; +import org.apache.hc.client5.http.impl.Operations; import org.python.google.common.io.Files; import com.google.gson.Gson; @@ -157,6 +160,11 @@ public void initialize() { int indexStarting = getCurrentIndex(); setCurrentIndex(0); setPercentInitialized(0); + opperations = opperations.stream() + .filter(Objects::nonNull) + .collect(Collectors.toCollection(ArrayList::new)); + if(indexStarting>opperations.size()) + indexStarting=opperations.size(); for (int i = 0; i < getOpperations().size(); i++) { ICaDoodleOpperation op = getOpperations().get(i); if(op==null) From 5cd05abf48c09b0d7a5af1fffe16b9e6e88655be Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 16 May 2025 09:05:40 -0400 Subject: [PATCH 393/635] only show splash when timeline is open --- .../scripting/cadoodle/CaDoodleFile.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4e79620c..7f680c84 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -94,6 +94,7 @@ public void renderSplashFrame(int percent, String message) { } }; private ICadoodleSaveStatusUpdate saveUpdate =null; + private boolean timelineOpen; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); @@ -839,7 +840,8 @@ public File save() throws IOException { String contents = toJson(); List currentState = getCurrentState(); int currentIndex2 = getCurrentIndex(); - getSaveUpdate().renderSplashFrame(1, "Save Doodle to "+selfInternal.getName()); + + if(isTimelineOpen())getSaveUpdate().renderSplashFrame(1, "Save Doodle to "+selfInternal.getName()); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); // } int num=0; @@ -851,7 +853,7 @@ public File save() throws IOException { if (!f.exists()) try { num++; - getSaveUpdate().renderSplashFrame(percent, "Save Timeline Image "+i+".png"); + if(isTimelineOpen())getSaveUpdate().renderSplashFrame(percent, "Save Timeline Image "+i+".png"); setSaveImage(process, op); @@ -862,7 +864,7 @@ public File save() throws IOException { } if (bom != null) bom.save(); - getSaveUpdate().renderSplashFrame(100, "Doofle save Done "); + if(isTimelineOpen())getSaveUpdate().renderSplashFrame(100, "Doofle save Done "); fireTimelineUpdate(num); // System.gc(); return getSelf(); @@ -1112,4 +1114,12 @@ public ICadoodleSaveStatusUpdate getSaveUpdate() { public void setSaveUpdate(ICadoodleSaveStatusUpdate saveUpdate) { this.saveUpdate = saveUpdate; } + + public void setTimelineVisable(boolean timelineOpen) { + this.timelineOpen = timelineOpen; + } + + public boolean isTimelineOpen() { + return timelineOpen; + } } From d9c129ecc2dc75cf188f5f9b6425ab89553003ea Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 17 May 2025 08:44:31 -0400 Subject: [PATCH 394/635] Updating the JavaCAD to include sweep method for the sweep Adding spiral terms to the sweep operation --- build.gradle | 2 +- .../scripting/cadoodle/Sweep.java | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 351d01c7..dd565bce 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.5.0' + api 'com.neuronrobotics:JavaCad:2.6.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 0c81e4f4..a7627241 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -23,6 +23,7 @@ import eu.mihosoft.vrl.v3d.Plane; import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.ITransformProvider; import eu.mihosoft.vrl.v3d.Vector3d; import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; @@ -44,6 +45,7 @@ public class Sweep extends AbstractAddFrom { private LengthParameter rad = null; private LengthParameter step = null; private LengthParameter angle = null; + private LengthParameter spiral = null; @Expose(serialize = true, deserialize = true) private double defz = 0; @Expose(serialize = true, deserialize = true) @@ -52,7 +54,9 @@ public class Sweep extends AbstractAddFrom { private double defstep=30; @Expose(serialize = true, deserialize = true) private double defangle=360; - + @Expose(serialize = true, deserialize = true) + private double defSpiral=0; + public Sweep set(File source) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); @@ -81,11 +85,15 @@ public CSG sweep(Polygon p, String name, Bounds b) { double radius = radius(name).getMM(); if (angle < 0) angle = -angle; + double sprl = spiralStep(name).getMM(); Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY()); Transform increment = new Transform().rotY(-angle).movey(z); Transform radiusT = new Transform().movex(radius); Polygon transformedP = p.transformed(centerandAllignedPolygon); - return Extrude.sweep(transformedP, increment, radiusT, steps).rotx(-90).setName(name); + ITransformProvider pr = (unit,domain)->{ + return new Transform().movex(sprl*unit*d); + }; + return Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90).setName(name); } public LengthParameter radius(String name) { @@ -121,7 +129,14 @@ public LengthParameter angle(String name) { angle.setMM(0.001); return angle; } - + public LengthParameter spiralStep(String name) { + String key = name + "_CaDoodle_Spiral"; + if (spiral == null) + spiral = new LengthParameter(key, defSpiral, nopt); + if (spiral.getMM()<0) + spiral.setMM(0); + return spiral; + } @Override @@ -229,7 +244,7 @@ private CSG processGiven(Polygon p, Bounds b, int j, String name) { Parameter radius = radius(name); parameter.setStrValue(pathname); CSG processedCSG = csg.transformed(nrToCSG).syncProperties(csg).setParameter(parameter).setParameter(steps) - .setParameter(angle).setParameter(z).setParameter(radius).setColor(c).setIsHole(hole) + .setParameter(angle).setParameter(z).setParameter(radius).setParameter(spiralStep(pathname)).setColor(c).setIsHole(hole) .setRegenerate(previous -> { try { File file = getFile(); From fdd1b9c4a14e04de93dd715d5c22681138528d73 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 17 May 2025 09:18:41 -0400 Subject: [PATCH 395/635] updated jcsg to avoid the spiral bug --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index dd565bce..5209248e 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.6.0' + api 'com.neuronrobotics:JavaCad:2.6.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 630d7a93d0500a6d44e8dc2065fa102233beb1bc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 17 May 2025 09:22:34 -0400 Subject: [PATCH 396/635] getter and setter for default spiral --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index a7627241..1f630ce2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -132,7 +132,7 @@ public LengthParameter angle(String name) { public LengthParameter spiralStep(String name) { String key = name + "_CaDoodle_Spiral"; if (spiral == null) - spiral = new LengthParameter(key, defSpiral, nopt); + spiral = new LengthParameter(key, getDefSpiral(), nopt); if (spiral.getMM()<0) spiral.setMM(0); return spiral; @@ -312,4 +312,12 @@ public void setDefangle(double defangle) { this.defangle = defangle; } + public double getDefSpiral() { + return defSpiral; + } + + public void setDefSpiral(double defSpiral) { + this.defSpiral = defSpiral; + } + } From 258f70dd524a309877a4aa0951ef2ae8edafd2c2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 17 May 2025 11:07:44 -0400 Subject: [PATCH 397/635] default value for timeline showing and a setter for the created time to enable copies to have a new creation time --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7f680c84..b432cdb8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -94,7 +94,7 @@ public void renderSplashFrame(int percent, String message) { } }; private ICadoodleSaveStatusUpdate saveUpdate =null; - private boolean timelineOpen; + private boolean timelineOpen=false; public void close() { for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); @@ -1122,4 +1122,8 @@ public void setTimelineVisable(boolean timelineOpen) { public boolean isTimelineOpen() { return timelineOpen; } + + public void setTimeCreated(long timeCreated) { + this.timeCreated = timeCreated; + } } From 8e97c0853dd3b42d7076f99bebcb6470c2459dc3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 18 May 2025 18:24:43 -0400 Subject: [PATCH 398/635] Adding the new JCSG --- build.gradle | 2 +- .../scripting/cadoodle/AddFromScript.java | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5209248e..2a288cdc 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.6.1' + api 'com.neuronrobotics:JavaCad:2.7.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 9242e2f9..c0009210 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -2,6 +2,8 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -22,6 +24,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.Parameter; public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -55,6 +59,7 @@ public List process(List incoming, String fileName) { nameIndex = 0; ArrayList back = new ArrayList(); back.addAll(incoming); + boolean isDoodle = fileName.toLowerCase().endsWith(".doodle"); try { ArrayList args = new ArrayList<>(); @@ -63,20 +68,37 @@ public List process(List incoming, String fileName) { configs.put("name", getName()); configs.put("PreventBomAdd", preventBoM); args.add(configs); + File currentdb = CSGDatabase.getDbFile(); + if(isDoodle) { + CSGDatabase.saveDatabase(); + Path tempFile = Files.createTempFile(currentdb.getName(), ".tmp"); + CSGDatabase.setDbFile(tempFile.toFile()); + CSGDatabase.clear(); + } List flaten = ScriptingEngine.flaten(gitULR, fileName, CSG.class, args); ArrayList collect = new ArrayList<>(); collect.addAll(flaten); for(int i=0;i Date: Sun, 18 May 2025 18:29:07 -0400 Subject: [PATCH 399/635] use CSGDatabaseInstance swapping to maintain state when running a doodle file --- .../scripting/cadoodle/AddFromScript.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index c0009210..86f8a2a6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -25,6 +25,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.Parameter; public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { @@ -68,12 +69,10 @@ public List process(List incoming, String fileName) { configs.put("name", getName()); configs.put("PreventBomAdd", preventBoM); args.add(configs); - File currentdb = CSGDatabase.getDbFile(); + CSGDatabaseInstance instance = CSGDatabase.getInstance(); if(isDoodle) { - CSGDatabase.saveDatabase(); - Path tempFile = Files.createTempFile(currentdb.getName(), ".tmp"); - CSGDatabase.setDbFile(tempFile.toFile()); - CSGDatabase.clear(); + Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); + CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); } List flaten = ScriptingEngine.flaten(gitULR, fileName, CSG.class, args); ArrayList collect = new ArrayList<>(); @@ -94,10 +93,7 @@ public List process(List incoming, String fileName) { MoveCenter.set(getName(), tmp, nrToCSG); } if(isDoodle) { - Path tempFile = Files.createTempFile(currentdb.getName(), ".tmp"); - CSGDatabase.setDbFile(tempFile.toFile()); - CSGDatabase.clear(); - CSGDatabase.setDbFile(currentdb); + CSGDatabase.setInstance(instance); } back.addAll(collect); } catch (Exception e) { From edfae77e9588df18a024f3503df58fc275baa75f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 09:05:34 -0400 Subject: [PATCH 400/635] Updating the JavaCAD to include sweep method for the sweep --- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 86f8a2a6..63bf081a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -7,26 +7,19 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Random; -import java.util.stream.Collectors; - import org.eclipse.jgit.api.errors.GitAPIException; import com.google.gson.annotations.Expose; -import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; -import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; -import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; -import eu.mihosoft.vrl.v3d.parametrics.Parameter; public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { @Expose(serialize = true, deserialize = true) @@ -81,6 +74,7 @@ public List process(List incoming, String fileName) { CSG csg=collect.get(i); if(isDoodle) { csg.getMapOfparametrics().clear(); + csg.setStorage(new PropertyStorage()); } Transform nrToCSG = TransformFactory.nrToCSG( getLocation() ); String orderedName = getOrderedName(); From 0b169e974221b78e4e8fd5592ed14af05c9ae481 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 14:16:42 -0400 Subject: [PATCH 401/635] Adding a doodle file loader --- .../scripting/cadoodle/AddFromFile.java | 240 ++++++++++++++---- .../scripting/cadoodle/CaDoodleFile.java | 14 +- 2 files changed, 196 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 9251ea90..ef13fc00 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -15,15 +15,17 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; -import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { @@ -31,15 +33,23 @@ public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation private TransformNR location = null; private ArrayList options = new ArrayList(); @Expose(serialize = true, deserialize = true) - private Boolean preventBoM =false; + private Boolean preventBoM = false; + public AddFromFile set(File source) { - for(String s:ScriptingEngine.getAllExtentions()) { - if(source.getName().toLowerCase().endsWith(s.toLowerCase())) { - toLocal(source,getName()); + for (String s : ScriptingEngine.getAllExtentions()) { + if (source.getName().toLowerCase().endsWith(s.toLowerCase())) { + toLocal(source, getName()); + try { + getFile(); + } catch (NoSuchFileException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + break; + } return this; } } - throw new RuntimeException("File Extention not supported: "+source.getName()); + throw new RuntimeException("File Extention not supported: " + source.getName()); } @Override @@ -60,26 +70,37 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); - if(!file.exists()) { + if (!file.exists()) { throw new RuntimeException("Failed to find file"); } - - ArrayListargs = new ArrayList<>(); - args.addAll(Arrays.asList(name )); - HashMap configs =new HashMap(); + + ArrayList args = new ArrayList<>(); + args.addAll(Arrays.asList(name)); + HashMap configs = new HashMap(); configs.put("name", name); configs.put("PreventBomAdd", preventBoM); args.add(configs); + boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); + CSGDatabaseInstance instance = CSGDatabase.getInstance(); + if(isDoodle) { + Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); + CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); + } List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); + if(isDoodle) { + csg.getMapOfparametrics().clear(); + csg.setStorage(new PropertyStorage()); + } try { - CSG processedCSG = processGiven(csg, i, getOrderedName()); + CSG processedCSG = processGiven(csg, i, getOrderedName(),file); collect.add(processedCSG); - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } + CSGDatabase.setInstance(instance); back.addAll(collect); // VitaminBomManager boM = CaDoodleFile.getBoM(); // VitaminLocation loc = boM.getByName(name); @@ -122,54 +143,172 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); return targetFile; } + public static File toLocal(File file, String name) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFileIncoming = file.getParentFile(); - File parentFile = new File(loc.getStrValue()).getParentFile(); -// if(parentFile==null) -// try { -// parentFile=File.createTempFile(name, name).getParentFile(); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } + String strValue = loc.getStrValue(); + File parentFile = new File(strValue).getParentFile(); String source = parentFile.getAbsolutePath(); + boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); if (parentFileIncoming != null) { String parentIncoming = parentFileIncoming.getAbsolutePath(); - String lowerCase = parentIncoming.toLowerCase(); String lowerCase2 = source.toLowerCase(); boolean b = !lowerCase.contentEquals(lowerCase2); boolean exists = file.exists(); if (b && exists) { - File copied; + if (!isDoodle) { + File copied; + try { + copied = copyFileToNewDirectory(file, parentFile, name); + file = copied; + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } + } else { + // doodle copy + File doodleParent = file.getParentFile(); + File targetParent = new File(parentFile.getAbsoluteFile() + delim() + name); + targetParent.mkdirs(); + recursiveCopy(doodleParent.getAbsolutePath(),targetParent.getAbsolutePath()); +// for (File f : doodleParent.listFiles()) { +// File file2 = new File(targetParent.getAbsolutePath() + delim() + f.getName()); +// try { +// Files.copy(f.toPath(), file2.toPath(), StandardCopyOption.REPLACE_EXISTING); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// if (f.getName().toLowerCase().endsWith(".doodle")) { +// file = file2; +// } +// } + } + } + } + if (!isDoodle) + file = new File(source + delim() + file.getName()); + return file; + } + + /** + * Recursively copies all files and folders from the source directory to the + * target directory. + * + * @param sourceDir The source directory path + * @param targetDir The target directory path + * @return true if the copy operation was successful, false otherwise + */ + public static boolean recursiveCopy(String sourceDir, String targetDir) { + File source = new File(sourceDir); + File target = new File(targetDir); + + // Validate inputs + if (!source.exists()) { + System.err.println("Error: Source directory '" + sourceDir + "' does not exist."); + return false; + } + + if (!source.isDirectory()) { + System.err.println("Error: Source '" + sourceDir + "' is not a directory."); + return false; + } + + // Create target directory if it doesn't exist + if (!target.exists()) { + if (!target.mkdirs()) { + System.err.println("Error: Could not create target directory '" + targetDir + "'."); + return false; + } + System.out.println("Created target directory: " + targetDir); + } + + try { + return copyDirectory(source, target); + } catch (IOException e) { + System.err.println("Error during copy operation: " + e.getMessage()); + return false; + } + } + + /** + * Helper method to copy a directory recursively. + * + * @param sourceDir The source directory + * @param targetDir The target directory + * @return true if the copy operation was successful + * @throws IOException If an I/O error occurs + */ + private static boolean copyDirectory(File sourceDir, File targetDir) throws IOException { + // Get all files and directories in the source directory + File[] files = sourceDir.listFiles(); + + if (files == null) { + System.err.println("Warning: Could not list contents of directory: " + sourceDir.getAbsolutePath()); + return false; + } + + for (File file : files) { + // Construct the target path + File targetFile = new File(targetDir, file.getName()); + + if (file.isDirectory()) { + // Create the target directory if it doesn't exist + if (!targetFile.exists() && !targetFile.mkdirs()) { + System.err.println("Error: Could not create directory: " + targetFile.getAbsolutePath()); + return false; + } + + // Recursively copy the subdirectory + if (!copyDirectory(file, targetFile)) { + return false; + } + } else { + // Copy the file, preserving attributes try { - copied = copyFileToNewDirectory(file, parentFile, name); - file = copied; + Path sourcePath = file.toPath(); + Path targetPath = targetFile.toPath(); + + Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.COPY_ATTRIBUTES); + + System.out.println("Copied: " + sourcePath + " -> " + targetPath); } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); + System.err.println("Error copying file " + file.getAbsolutePath() + ": " + e.getMessage()); + throw e; } } } - file = new File(source + DownloadManager.delim() + file.getName()); - return file; + + return true; } - + public static File getFile(String name) { StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); File parentFile = new File(loc.getStrValue()).getParentFile(); - for(String f:parentFile.list()) { - if(f.contains(name)) { - for(String s:ScriptingEngine.getAllExtentions()) { - if(f.toLowerCase().endsWith(s.toLowerCase())) { - String pathname = parentFile.getAbsolutePath() + DownloadManager.delim() + f; - return new File(pathname); + for (File f : parentFile.listFiles()) { + if (f.getName().contains(name)) { + if (f.isDirectory()) { + // is a doodle file + for (File d : f.listFiles()) { + if (d.getName().toLowerCase().endsWith(".doodle")) { + return d; + } + } + } else { + for (String s : ScriptingEngine.getAllExtentions()) { + if (f.getName().toLowerCase().endsWith(s.toLowerCase())) { + String pathname = parentFile.getAbsolutePath() + delim() + f; + return new File(pathname); + } } } } + } - throw new RuntimeException("File not found! "+name); + throw new RuntimeException("File not found! " + name); } // // private String getStrValue() { @@ -177,25 +316,36 @@ public static File getFile(String name) { // return getParameter("UnKnown").getStrValue(); // } - private CSG processGiven(CSG csg, int i, String n) { + private CSG processGiven(CSG csg, int i, String n, File f) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); - String pathname = getFile(this.name).getAbsolutePath(); + String pathname =f.getAbsolutePath(); - StringParameter parameter=new StringParameter(n + "_CaDoodle_File", pathname, options); + StringParameter parameter = new StringParameter(n + "_CaDoodle_File", pathname, options); parameter.setStrValue(pathname); + CSG processedCSG = csg // .moveToCenterX() // .moveToCenterY() // .toZMin() - .transformed(nrToCSG).syncProperties(csg).setParameter(parameter) - .setRegenerate(previous -> { + .transformed(nrToCSG).syncProperties(csg).setParameter(parameter).setRegenerate(previous -> { try { - File file = getFile(); + File file =f; + CSGDatabaseInstance instance = CSGDatabase.getInstance(); + boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); + if(isDoodle) { + Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); + CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); + } String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); - return processGiven(csg1, i, n); + if(isDoodle) { + csg1.getMapOfparametrics().clear(); + csg1.setStorage(new PropertyStorage()); + } + CSGDatabase.setInstance(instance); + return processGiven(csg1, i, n,f); } catch (Exception e) { e.printStackTrace(); } @@ -216,8 +366,6 @@ public AddFromFile setLocation(TransformNR location) { return this; } - - public Boolean getPreventBoM() { return preventBoM; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b432cdb8..a58fe1e1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -42,6 +42,7 @@ import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.IParametric; import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; @@ -138,18 +139,7 @@ public void initialize() { if (!imageCacheDir.exists()) imageCacheDir.mkdir(); File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); - try { - // set a temp file for the database to clear - // this ensures that parameters are not cleared from another project :/ - File createTempFile = File.createTempFile(projectName, ".json"); - CSGDatabase.setDbFile(createTempFile); - CSGDatabase.clear(); - createTempFile.delete(); - } catch (IOException e) { - // Auto-generated catch block - e.printStackTrace(); - } - CSGDatabase.setDbFile(db); + CSGDatabase.setInstance(new CSGDatabaseInstance(db)); StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), new ArrayList()); loc.setStrValue(selfInternal.getAbsolutePath()); From d9fef48aa3b608b4babf0ae29f03cec7a360fa88 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 14:34:21 -0400 Subject: [PATCH 402/635] remove comment --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index ef13fc00..1e6acc0c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -173,18 +173,6 @@ public static File toLocal(File file, String name) { File targetParent = new File(parentFile.getAbsoluteFile() + delim() + name); targetParent.mkdirs(); recursiveCopy(doodleParent.getAbsolutePath(),targetParent.getAbsolutePath()); -// for (File f : doodleParent.listFiles()) { -// File file2 = new File(targetParent.getAbsolutePath() + delim() + f.getName()); -// try { -// Files.copy(f.toPath(), file2.toPath(), StandardCopyOption.REPLACE_EXISTING); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// if (f.getName().toLowerCase().endsWith(".doodle")) { -// file = file2; -// } -// } } } } From 3688cfffab84fe9f2beb5834588279e6249fe8e3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 16:55:24 -0400 Subject: [PATCH 403/635] formatting --- .../bowlerstudio/assets/AssetFactory.java | 339 +++++++++--------- 1 file changed, 169 insertions(+), 170 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 0b227df2..0d7990ee 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -25,175 +25,174 @@ public class AssetFactory { - public static final String repo = "BowlerStudioImageAssets"; - private static String gitSource = "https://github.com/CommonWealthRobotics/" + repo + ".git"; - private static HashMap cache = new HashMap<>(); - private static HashMap loaders = new HashMap<>(); - private static String assetRepoBranch = ""; - - private AssetFactory() { - } - static { - com.neuronrobotics.sdk.common.Log.error("AssetFactory loaded"); - //new RuntimeException().printStackTrace(); - } - - public static FXMLLoader loadLayout(String file, boolean refresh) throws Exception { - File fxmlFIle = loadFile(file); - URL fileURL = fxmlFIle.toURI().toURL(); - - if (loaders.get(file) == null || refresh) { - loaders.put(file, new FXMLLoader(fileURL)); - } - - loaders.get(file).setLocation(fileURL); - return loaders.get(file); - } - - public static FXMLLoader loadLayout(String file) throws Exception { - return loadLayout(file, false); - } - - public static File loadFile(String file) throws Exception { - return ScriptingEngine - .fileFromGit( - getGitSource(),// git repo, change this if you fork this demo - getAssetRepoBranch(), - file// File from within the Git repo - ); - } - - public static void writeImage(Image img, File file) { - int width = (int) img.getWidth(); - int height = (int) img.getHeight(); - PixelReader reader = img.getPixelReader(); - byte[] buffer = new byte[width * height * 4]; - javafx.scene.image.WritablePixelFormat format = javafx.scene.image.PixelFormat.getByteBgraInstance(); - reader.getPixels(0, 0, width, height, format, buffer, 0, width * 4); - try { - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); - for(int count = 0; count < buffer.length; count += 4) { - out.write(buffer[count + 2]); - out.write(buffer[count + 1]); - out.write(buffer[count]); - out.write(buffer[count + 3]); - } - out.flush(); - out.close(); - } catch(IOException e) { - e.printStackTrace(); - } - } - - @SuppressWarnings("restriction") - public static Image loadAsset(String file) throws Exception { - if (cache.get(file) == null) { - File f = loadFile(file); - if (f.getName().endsWith(".fxml")) { - loadLayout(file); - return null; - } else if ((f == null || !f.exists()) && f.getName().endsWith(".png")) { - WritableImage obj_img = new WritableImage(30, 30); - byte alpha = (byte) 0; - for (int cx = 0; cx < obj_img.getWidth(); cx++) { - for (int cy = 0; cy < obj_img.getHeight(); cy++) { - int color = obj_img.getPixelReader().getArgb(cx, cy); - int mc = (alpha << 24) | 0x00ffffff; - int newColor = color & mc; - obj_img.getPixelWriter().setArgb(cx, cy, newColor); - } - } - - cache.put(file, obj_img); - com.neuronrobotics.sdk.common.Log.error("No image at " + file); - - try { - new RuntimeException().printStackTrace(); - File imageFile = ScriptingEngine.createFile(getGitSource(), file, "create file"); - try { - String fileName = imageFile.getName(); - writeImage(obj_img, imageFile); - - } catch (Exception ignored) { - } - ScriptingEngine.createFile(getGitSource(), file, "saving new content"); - } catch (Exception e) { - e.printStackTrace(); - } - } else if (f.getName().endsWith(".png")) { - cache.put(file, new Image(f.toURI().toString())); - }else { - return null; - } - } - return cache.get(file); - } - - public static javafx.scene.image.ImageView loadIcon(String file) { - try { - ImageView imageView = new ImageView(loadAsset(file)); - FontSizeManager.addListener(fontNum->{ - imageView.setScaleX(FontSizeManager.getImageScale()); - imageView.setScaleY(FontSizeManager.getImageScale()); - }); - return imageView; - } catch (Exception e) { - e.printStackTrace(); - try { - return new ImageView(loadAsset("BowlerStudio.png")); - } catch (Exception e1) { - new IssueReportingExceptionHandler().except(e1); - throw new RuntimeException(e1); + public static final String repo = "BowlerStudioImageAssets"; + private static String gitSource = "https://github.com/CommonWealthRobotics/" + repo + ".git"; + private static HashMap cache = new HashMap<>(); + private static HashMap loaders = new HashMap<>(); + private static String assetRepoBranch = ""; + + private AssetFactory() { + } + + static { + com.neuronrobotics.sdk.common.Log.error("AssetFactory loaded"); + // new RuntimeException().printStackTrace(); + } + + public static FXMLLoader loadLayout(String file, boolean refresh) throws Exception { + File fxmlFIle = loadFile(file); + URL fileURL = fxmlFIle.toURI().toURL(); + + if (loaders.get(file) == null || refresh) { + loaders.put(file, new FXMLLoader(fileURL)); + } + + loaders.get(file).setLocation(fileURL); + return loaders.get(file); + } + + public static FXMLLoader loadLayout(String file) throws Exception { + return loadLayout(file, false); + } + + public static File loadFile(String file) throws Exception { + return ScriptingEngine.fileFromGit(getGitSource(), // git repo, change this if you fork this demo + getAssetRepoBranch(), file// File from within the Git repo + ); + } + + public static void writeImage(Image img, File file) { + int width = (int) img.getWidth(); + int height = (int) img.getHeight(); + PixelReader reader = img.getPixelReader(); + byte[] buffer = new byte[width * height * 4]; + javafx.scene.image.WritablePixelFormat format = javafx.scene.image.PixelFormat + .getByteBgraInstance(); + reader.getPixels(0, 0, width, height, format, buffer, 0, width * 4); + try { + BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + for (int count = 0; count < buffer.length; count += 4) { + out.write(buffer[count + 2]); + out.write(buffer[count + 1]); + out.write(buffer[count]); + out.write(buffer[count + 3]); + } + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("restriction") + public static Image loadAsset(String file) throws Exception { + if (cache.get(file) == null) { + File f = loadFile(file); + if (f.getName().endsWith(".fxml")) { + loadLayout(file); + return null; + } else if (f.getName().endsWith(".png")) { + cache.put(file, new Image(f.toURI().toString())); + } else if ((f == null || !f.exists()) && f.getName().endsWith(".png")) { + WritableImage obj_img = new WritableImage(30, 30); + byte alpha = (byte) 0; + for (int cx = 0; cx < obj_img.getWidth(); cx++) { + for (int cy = 0; cy < obj_img.getHeight(); cy++) { + int color = obj_img.getPixelReader().getArgb(cx, cy); + int mc = (alpha << 24) | 0x00ffffff; + int newColor = color & mc; + obj_img.getPixelWriter().setArgb(cx, cy, newColor); + } + } + + cache.put(file, obj_img); + com.neuronrobotics.sdk.common.Log.error("No image at " + file); + + try { + new RuntimeException().printStackTrace(); + File imageFile = ScriptingEngine.createFile(getGitSource(), file, "create file"); + try { + String fileName = imageFile.getName(); + writeImage(obj_img, imageFile); + + } catch (Exception ignored) { + } + ScriptingEngine.createFile(getGitSource(), file, "saving new content"); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + return null; + } + } + return cache.get(file); + } + + public static javafx.scene.image.ImageView loadIcon(String file) { + try { + ImageView imageView = new ImageView(loadAsset(file)); + FontSizeManager.addListener(fontNum -> { + imageView.setScaleX(FontSizeManager.getImageScale()); + imageView.setScaleY(FontSizeManager.getImageScale()); + }); + return imageView; + } catch (Exception e) { + e.printStackTrace(); + try { + return new ImageView(loadAsset("BowlerStudio.png")); + } catch (Exception e1) { + new IssueReportingExceptionHandler().except(e1); + throw new RuntimeException(e1); + } + } + } + + public static String getGitSource() throws Exception { + return gitSource; + } + + public static void setGitSource(String gitSource, String assetRepoBranch) throws Exception { + com.neuronrobotics.sdk.common.Log.error("Assets from: " + gitSource + "#" + assetRepoBranch); + // new Exception().printStackTrace(); + setAssetRepoBranch(assetRepoBranch); + AssetFactory.gitSource = gitSource; + cache.clear(); + loadAllAssets(); + } + + public static void loadAllAssets() throws Exception { + com.neuronrobotics.sdk.common.Log.error("Loading assets"); + List files; + try { + files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); + } catch (Exception ex) { + files = ScriptingEngine.filesInGit(getGitSource()); + } + for (String file : files) { + com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file); + loadAsset(file); + } + } + + public static String getAssetRepoBranch() { + return assetRepoBranch; + } + + public static void setAssetRepoBranch(String assetRepoBranch) { + AssetFactory.assetRepoBranch = assetRepoBranch; + } + + public static void deleteFolder(File folder) { + File[] files = folder.listFiles(); + if (files != null) { // some JVMs return null for empty dirs + for (File f : files) { + if (f.isDirectory()) { + deleteFolder(f); + } else { + f.delete(); + } + } + } + folder.delete(); } - } - } - - public static String getGitSource() throws Exception { - return gitSource; - } - - public static void setGitSource(String gitSource, String assetRepoBranch) throws Exception { - com.neuronrobotics.sdk.common.Log.error("Assets from: " + gitSource + "#" + assetRepoBranch); - //new Exception().printStackTrace(); - setAssetRepoBranch(assetRepoBranch); - AssetFactory.gitSource = gitSource; - cache.clear(); - loadAllAssets(); - } - - public static void loadAllAssets() throws Exception { - com.neuronrobotics.sdk.common.Log.error("Loading assets"); - List files; - try { - files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); - }catch(Exception ex) { - files = ScriptingEngine.filesInGit(getGitSource()); - } - for (String file : files) { - com.neuronrobotics.sdk.common.Log.error("Loading asset file: "+file); - loadAsset(file); - } - } - - public static String getAssetRepoBranch() { - return assetRepoBranch; - } - - public static void setAssetRepoBranch(String assetRepoBranch) { - AssetFactory.assetRepoBranch = assetRepoBranch; - } - - public static void deleteFolder(File folder) { - File[] files = folder.listFiles(); - if (files != null) { //some JVMs return null for empty dirs - for (File f : files) { - if (f.isDirectory()) { - deleteFolder(f); - } else { - f.delete(); - } - } - } - folder.delete(); - } } From d89ac204b0038d9ff3303400687ea73e911e0936 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 17:28:50 -0400 Subject: [PATCH 404/635] branch error checking --- .../neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index a16411a5..6a02b94a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -1112,6 +1112,9 @@ public static File fileFromGit(String remoteURI, String fileInRepo) // https://github.com/CommonWealthRobotics/BowlerStudioVitamins.git public static File fileFromGit(String remoteURI, String branch, String fileInRepo) throws InvalidRemoteException, TransportException, GitAPIException, IOException { + if(branch!=null) + if(branch.length()==0) + branch=null; File gitRepoFile = cloneRepo(remoteURI, branch); return new File(gitRepoFile.getAbsolutePath() + "/" + fileInRepo); } From 4b93e62943cd01a15dc9a232773b304ab9cdad11 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 17:29:25 -0400 Subject: [PATCH 405/635] add the file paraameter after the database is reattached --- .../scripting/cadoodle/AddFromFile.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 1e6acc0c..a45bba1f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -89,10 +89,7 @@ public List process(List incoming) { List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); - if(isDoodle) { - csg.getMapOfparametrics().clear(); - csg.setStorage(new PropertyStorage()); - } + try { CSG processedCSG = processGiven(csg, i, getOrderedName(),file); collect.add(processedCSG); @@ -101,13 +98,9 @@ public List process(List incoming) { } } CSGDatabase.setInstance(instance); + for(CSG csg1:collect) + csg1.setParameter(getFileLocationparam(file)); back.addAll(collect); -// VitaminBomManager boM = CaDoodleFile.getBoM(); -// VitaminLocation loc = boM.getByName(name); -// if(loc!=null) { -// loc.setLocation(location); -// boM.save(); -// } } catch (Exception e) { // Auto-generated catch block e.printStackTrace(); @@ -306,20 +299,16 @@ public static File getFile(String name) { private CSG processGiven(CSG csg, int i, String n, File f) { Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); - String pathname =f.getAbsolutePath(); - - StringParameter parameter = new StringParameter(n + "_CaDoodle_File", pathname, options); - parameter.setStrValue(pathname); + boolean isDoodle = f.getName().toLowerCase().endsWith(".doodle"); + if(isDoodle) { + csg.setStorage(new PropertyStorage()); + } CSG processedCSG = csg -// .moveToCenterX() -// .moveToCenterY() -// .toZMin() - .transformed(nrToCSG).syncProperties(csg).setParameter(parameter).setRegenerate(previous -> { + .transformed(nrToCSG).syncProperties(csg).setRegenerate(previous -> { try { File file =f; CSGDatabaseInstance instance = CSGDatabase.getInstance(); - boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); @@ -333,6 +322,7 @@ private CSG processGiven(CSG csg, int i, String n, File f) { csg1.setStorage(new PropertyStorage()); } CSGDatabase.setInstance(instance); + csg1.setParameter(getFileLocationparam(f)); return processGiven(csg1, i, n,f); } catch (Exception e) { e.printStackTrace(); @@ -343,6 +333,12 @@ private CSG processGiven(CSG csg, int i, String n, File f) { return processedCSG; } + private StringParameter getFileLocationparam( File pathname) { + StringParameter stringParameter = new StringParameter(name + "_CaDoodle_File", pathname.getAbsolutePath(), options); + stringParameter.setStrValue(pathname.getAbsolutePath()); + return stringParameter; + } + public TransformNR getLocation() { if (location == null) location = new TransformNR(); From b7d389ae72c0773f1f86fef450453708b6a364d8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 17:29:50 -0400 Subject: [PATCH 406/635] set the asset factory to use the correct default branch --- .../com/neuronrobotics/bowlerstudio/assets/AssetFactory.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 0d7990ee..372afabd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -29,7 +29,7 @@ public class AssetFactory { private static String gitSource = "https://github.com/CommonWealthRobotics/" + repo + ".git"; private static HashMap cache = new HashMap<>(); private static HashMap loaders = new HashMap<>(); - private static String assetRepoBranch = ""; + private static String assetRepoBranch = "main"; private AssetFactory() { } @@ -87,11 +87,12 @@ public static void writeImage(Image img, File file) { @SuppressWarnings("restriction") public static Image loadAsset(String file) throws Exception { if (cache.get(file) == null) { + System.out.println("Loading asset "+file); File f = loadFile(file); if (f.getName().endsWith(".fxml")) { loadLayout(file); return null; - } else if (f.getName().endsWith(".png")) { + } else if (f.getName().endsWith(".png") && f.exists()) { cache.put(file, new Image(f.toURI().toString())); } else if ((f == null || !f.exists()) && f.getName().endsWith(".png")) { WritableImage obj_img = new WritableImage(30, 30); From 724a783d6fbc10f05052a8818bec90a3bd973074 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 17:35:09 -0400 Subject: [PATCH 407/635] only create files when logged in --- .../bowlerstudio/assets/AssetFactory.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 372afabd..4b5953a9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.assets; import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; +import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; //import javafx.embed.swing.SwingFXUtils; @@ -87,7 +88,7 @@ public static void writeImage(Image img, File file) { @SuppressWarnings("restriction") public static Image loadAsset(String file) throws Exception { if (cache.get(file) == null) { - System.out.println("Loading asset "+file); + System.out.println("Loading asset " + file); File f = loadFile(file); if (f.getName().endsWith(".fxml")) { loadLayout(file); @@ -107,20 +108,22 @@ public static Image loadAsset(String file) throws Exception { } cache.put(file, obj_img); - com.neuronrobotics.sdk.common.Log.error("No image at " + file); + if (PasswordManager.loggedIn()) { + com.neuronrobotics.sdk.common.Log.error("No image at " + file); - try { - new RuntimeException().printStackTrace(); - File imageFile = ScriptingEngine.createFile(getGitSource(), file, "create file"); try { - String fileName = imageFile.getName(); - writeImage(obj_img, imageFile); - - } catch (Exception ignored) { + new RuntimeException().printStackTrace(); + File imageFile = ScriptingEngine.createFile(getGitSource(), file, "create file"); + try { + String fileName = imageFile.getName(); + writeImage(obj_img, imageFile); + + } catch (Exception ignored) { + } + ScriptingEngine.createFile(getGitSource(), file, "saving new content"); + } catch (Exception e) { + e.printStackTrace(); } - ScriptingEngine.createFile(getGitSource(), file, "saving new content"); - } catch (Exception e) { - e.printStackTrace(); } } else { return null; From b60e80b56f41202bd539b2eacd8c49f7f84e2638 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 20:00:32 -0400 Subject: [PATCH 408/635] Add an STL save to the save for use as a thumbnail --- .../scripting/cadoodle/AddFromFile.java | 3 +- .../scripting/cadoodle/CaDoodleFile.java | 34 +++++++++++++++++-- .../scripting/cadoodle/Sweep.java | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index a45bba1f..bcceff58 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -281,8 +281,7 @@ public static File getFile(String name) { } else { for (String s : ScriptingEngine.getAllExtentions()) { if (f.getName().toLowerCase().endsWith(s.toLowerCase())) { - String pathname = parentFile.getAbsolutePath() + delim() + f; - return new File(pathname); + return f; } } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a58fe1e1..bc6b50d7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -6,6 +6,7 @@ import java.lang.reflect.Type; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -39,6 +40,7 @@ import com.neuronrobotics.sdk.common.TickToc; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.Polygon; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; @@ -825,13 +827,30 @@ public String toJson() { } public File save() throws IOException { - - // synchronized (selfInternal) { String contents = toJson(); List currentState = getCurrentState(); + CSG thumb = null; + for(CSG c:currentState) { + if(c.isInGroup()) + continue; + if(c.isHide()) + continue; + if(thumb==null) + thumb=c; + else { + thumb=thumb.dumbUnion(c); + } + } + String string = getSTLThumbnailLocation(); int currentIndex2 = getCurrentIndex(); - if(isTimelineOpen())getSaveUpdate().renderSplashFrame(1, "Save Doodle to "+selfInternal.getName()); + boolean manif=CSG.isPreventNonManifoldTriangles(); + if(manif) + CSG.setPreventNonManifoldTriangles(false); + FileUtil.write(Paths.get(string), + thumb.toStlString()); + if(manif) + CSG.setPreventNonManifoldTriangles(true); FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); // } int num=0; @@ -859,6 +878,15 @@ public File save() throws IOException { // System.gc(); return getSelf(); } + public File getSTLThumbnailFile() { + File back = new File(getSTLThumbnailLocation()); + return back; + } + public String getSTLThumbnailLocation() { + File folder = selfInternal.getParentFile(); + String string = folder.getAbsolutePath()+delim()+"thumbnail.stl"; + return string; + } private void setSaveImage(List currentState, ICaDoodleOpperation op) throws IOException { if (selfInternal == null) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 1f630ce2..143ea8d1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -152,6 +152,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); + System.out.println("Loading File "+file.getAbsolutePath()); if (!file.exists()) { throw new RuntimeException("Failed to find file"); } From a4d7b88a1fa7596046480fba656d76e0beb05366 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 19 May 2025 20:43:14 -0400 Subject: [PATCH 409/635] formatting --- .../scripting/cadoodle/CaDoodleFile.java | 125 ++++++++++-------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index bc6b50d7..25bc63b1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -90,14 +90,15 @@ public class CaDoodleFile { private IAcceptPruneForward accept = null; private long timeOfLastUpdate = 0; private OperationResult result = OperationResult.APPEND; - private ICadoodleSaveStatusUpdate defaultSaver=new ICadoodleSaveStatusUpdate() { + private ICadoodleSaveStatusUpdate defaultSaver = new ICadoodleSaveStatusUpdate() { @Override public void renderSplashFrame(int percent, String message) { - System.out.println(percent+"% "+message); + System.out.println(percent + "% " + message); } }; - private ICadoodleSaveStatusUpdate saveUpdate =null; - private boolean timelineOpen=false; + private ICadoodleSaveStatusUpdate saveUpdate = null; + private boolean timelineOpen = false; + public void close() { for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); @@ -153,14 +154,12 @@ public void initialize() { int indexStarting = getCurrentIndex(); setCurrentIndex(0); setPercentInitialized(0); - opperations = opperations.stream() - .filter(Objects::nonNull) - .collect(Collectors.toCollection(ArrayList::new)); - if(indexStarting>opperations.size()) - indexStarting=opperations.size(); + opperations = opperations.stream().filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new)); + if (indexStarting > opperations.size()) + indexStarting = opperations.size(); for (int i = 0; i < getOpperations().size(); i++) { ICaDoodleOpperation op = getOpperations().get(i); - if(op==null) + if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); try { @@ -234,7 +233,7 @@ private static String getCadoodleFileLocation() { public Thread regenerateFrom(ICaDoodleOpperation source) { if (initializing) return null; - if (isRegenerating() || isOperationRunning()||source==null) { + if (isRegenerating() || isOperationRunning() || source == null) { new Exception("Operation Running, bailing").printStackTrace(); return null; } @@ -265,13 +264,15 @@ public void run() { setCurrentIndex(opIndex); try { for (; getCurrentIndex() < size;) { - int percent =(int)( ((double )getCurrentIndex())/((double)getOpperations().size())*100.0); + int percent = (int) (((double) getCurrentIndex()) / ((double) getOpperations().size()) + * 100.0); setCurrentIndex(getCurrentIndex() + 1); setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; ICaDoodleOpperation op = getOpperations().get(currentIndex2); - getSaveUpdate().renderSplashFrame(percent, "Regenerating "+op.getType()+" "+currentIndex2); + getSaveUpdate().renderSplashFrame(percent, + "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); try { List process = op.process(getPreviouState()); @@ -377,7 +378,7 @@ public boolean isOperationRunning() { } public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { - if(o==null) + if (o == null) throw new NullPointerException(); toProcess.add(o); if (isOperationRunning()) { @@ -387,7 +388,7 @@ public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyExc Thread t = null; t = new Thread() { public void run() { - + timeOfLastUpdate = System.currentTimeMillis(); while (toProcess.size() > 0) { result = OperationResult.APPEND; @@ -420,7 +421,7 @@ public void run() { } updateCurrentFromCache(); } - if(getResult()==OperationResult.ABORT) { + if (getResult() == OperationResult.ABORT) { setCurrentState(getCurrentOpperation(), getCurrentState()); } } @@ -436,7 +437,7 @@ public void run() { } public Thread deleteOperation(ICaDoodleOpperation op) { - if(op==null) + if (op == null) throw new NullPointerException(); if (isOperationRunning()) { new Exception("Operation Running, bailing").printStackTrace(); @@ -457,7 +458,7 @@ public void run() { if (index < 1) index = 1; ICaDoodleOpperation newTar = getOpperations().get(index - 1); - setCurrentIndex(index ); + setCurrentIndex(index); try { regenerateFrom(newTar).join(); } catch (InterruptedException e) { @@ -490,7 +491,7 @@ public static int applyToAllConstituantElements(boolean addRet, List tar CSG c = getByName(back, s); if (c.isInGroup()) continue; - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } applyToAllConstituantElements(addRet, s, back, p, depth); @@ -555,7 +556,7 @@ public File getTimelineImageFile(int i) { } private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { - if(op==null) + if (op == null) throw new NullPointerException(); OperationResult res = OperationResult.INSERT; if (getAccept() != null) { @@ -564,18 +565,18 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { return res; } } - if( getCurrentIndex() >0) - for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { - ICaDoodleOpperation key = getOpperations().get(i); - if (i >= getCurrentIndex()) { - List back = cache.remove(key); - if (back != null) - back.clear(); + if (getCurrentIndex() > 0) + for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { + ICaDoodleOpperation key = getOpperations().get(i); + if (i >= getCurrentIndex()) { + List back = cache.remove(key); + if (back != null) + back.clear(); + } + File imageCache = getTimelineImageFile(i); + // System.err.println("Deleting " + imageCache.getAbsolutePath()); + imageCache.delete(); } - File imageCache = getTimelineImageFile(i); - // System.err.println("Deleting " + imageCache.getAbsolutePath()); - imageCache.delete(); - } if (res == OperationResult.PRUNE) { List subList = (List) getOpperations().subList(0, getCurrentIndex()); @@ -601,8 +602,9 @@ private void storeResultInCache(ICaDoodleOpperation op, List process) { // cachedCopy.add(c); } cache.put(op, cachedCopy); - System.out.println("\n\nUpdated Memory use: "+getFreeMemory()+"\n\n"); + System.out.println("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); } + public static double getFreeMemory() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); // Maximum memory the JVM will attempt to use @@ -613,6 +615,7 @@ public static double getFreeMemory() { // Calculate the percentage of maximum memory that's currently being used return (usedMemory * 100.0) / maxMemory; } + private CSG cloneCSG(CSG dyingCSG) { CSG csg = new CSG(); @@ -712,6 +715,7 @@ public CaDoodleFile setSelf(File self) { public List getCurrentState() { return getStateAtOperation(getCurrentOpperation()); } + public List getStateAtOperation(ICaDoodleOpperation op) { if (getCurrentIndex() == 0) return new ArrayList(); @@ -739,7 +743,7 @@ public List getPreviouState() { if (getCurrentIndex() < 2) return new ArrayList(); ICaDoodleOpperation key = getOpperations().get(getCurrentIndex() - 2); - + return cache.get(key); } @@ -830,42 +834,45 @@ public File save() throws IOException { String contents = toJson(); List currentState = getCurrentState(); CSG thumb = null; - for(CSG c:currentState) { - if(c.isInGroup()) + for (CSG c : currentState) { + if (c.isInGroup()) continue; - if(c.isHide()) + if (c.isHide()) continue; - if(thumb==null) - thumb=c; + if (thumb == null) + thumb = c; else { - thumb=thumb.dumbUnion(c); + thumb = thumb.dumbUnion(c); } } String string = getSTLThumbnailLocation(); int currentIndex2 = getCurrentIndex(); - if(isTimelineOpen())getSaveUpdate().renderSplashFrame(1, "Save Doodle to "+selfInternal.getName()); - boolean manif=CSG.isPreventNonManifoldTriangles(); - if(manif) - CSG.setPreventNonManifoldTriangles(false); - FileUtil.write(Paths.get(string), - thumb.toStlString()); - if(manif) - CSG.setPreventNonManifoldTriangles(true); + if (isTimelineOpen()) + getSaveUpdate().renderSplashFrame(1, "Save Doodle to " + selfInternal.getName()); + if (thumb != null) { + boolean manif = CSG.isPreventNonManifoldTriangles(); + if (manif) + CSG.setPreventNonManifoldTriangles(false); + FileUtil.write(Paths.get(string), thumb.toStlString()); + if (manif) + CSG.setPreventNonManifoldTriangles(true); + } FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); // } - int num=0; + int num = 0; for (int i = 0; i < opperations.size(); i++) { File f = getTimelineImageFile(i); ICaDoodleOpperation op = opperations.get(i); - int percent =(int)( ((double )i)/((double)opperations.size())*100.0); + int percent = (int) (((double) i) / ((double) opperations.size()) * 100.0); List process = cache.get(op); if (!f.exists()) try { num++; - if(isTimelineOpen())getSaveUpdate().renderSplashFrame(percent, "Save Timeline Image "+i+".png"); + if (isTimelineOpen()) + getSaveUpdate().renderSplashFrame(percent, "Save Timeline Image " + i + ".png"); setSaveImage(process, op); - + } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); @@ -873,18 +880,21 @@ public File save() throws IOException { } if (bom != null) bom.save(); - if(isTimelineOpen())getSaveUpdate().renderSplashFrame(100, "Doofle save Done "); + if (isTimelineOpen()) + getSaveUpdate().renderSplashFrame(100, "Doofle save Done "); fireTimelineUpdate(num); // System.gc(); return getSelf(); } + public File getSTLThumbnailFile() { File back = new File(getSTLThumbnailLocation()); return back; } + public String getSTLThumbnailLocation() { File folder = selfInternal.getParentFile(); - String string = folder.getAbsolutePath()+delim()+"thumbnail.stl"; + String string = folder.getAbsolutePath() + delim() + "thumbnail.stl"; return string; } @@ -925,7 +935,8 @@ private void setSaveImage(List currentState, ICaDoodleOpperation op) throws if (getOpperations().get(getOpperations().size() - 1) == op) { Files.copy(imageCache, image); } - //System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); + // System.err.println("Thumbnail saved successfully to " + + // imageCache.getAbsolutePath()); } } catch (Throwable t) { t.printStackTrace(); @@ -979,7 +990,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr e.printStackTrace(); break; } - if(System.currentTimeMillis()-start>2500 && holder.size()==0) { + if (System.currentTimeMillis() - start > 2500 && holder.size() == 0) { throw new RuntimeException("Failed to create image"); } } @@ -1124,7 +1135,7 @@ public void setResult(OperationResult result) { } public ICadoodleSaveStatusUpdate getSaveUpdate() { - if(saveUpdate==null) + if (saveUpdate == null) return defaultSaver; return saveUpdate; } @@ -1134,7 +1145,7 @@ public void setSaveUpdate(ICadoodleSaveStatusUpdate saveUpdate) { } public void setTimelineVisable(boolean timelineOpen) { - this.timelineOpen = timelineOpen; + this.timelineOpen = timelineOpen; } public boolean isTimelineOpen() { From 52e2faa9af033c3fe54d54f5b625c25f81929356 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 20 May 2025 10:55:20 -0400 Subject: [PATCH 410/635] Adding string getters annd setters for the op result for storage in the database as well as adding the ASK option --- .../scripting/cadoodle/OperationResult.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java index 23a60392..4e857b01 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/OperationResult.java @@ -1,5 +1,19 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; public enum OperationResult { - PRUNE,INSERT,ABORT,APPEND; + PRUNE, INSERT, ABORT, APPEND, ASK; + + // Static factory method (case-insensitive) + public static OperationResult fromString(String name) { + for (OperationResult value : OperationResult.values()) { + if (value.name().equalsIgnoreCase(name)) { + return value; + } + } + throw new IllegalArgumentException("No enum constant OperationResult with name: " + name); + } + @Override + public String toString() { + return name(); // Or name().toLowerCase(), etc. + } } From c631888e3a36601a68e1d639c67137a5596772c9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 25 May 2025 15:42:01 -0400 Subject: [PATCH 411/635] Clean up class heiarchy and add the cadoodle file to each object --- .../scripting/cadoodle/AbstractAddFrom.java | 2 +- .../cadoodle/AbstractCaDoodleFileAccepter.java | 14 ++++++++++++++ .../scripting/cadoodle/AddFromFile.java | 2 +- .../scripting/cadoodle/AddFromScript.java | 2 +- .../bowlerstudio/scripting/cadoodle/Allign.java | 2 +- .../bowlerstudio/scripting/cadoodle/Delete.java | 2 +- .../bowlerstudio/scripting/cadoodle/Group.java | 2 +- .../bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../bowlerstudio/scripting/cadoodle/Lock.java | 2 +- .../bowlerstudio/scripting/cadoodle/Mirror.java | 2 +- .../scripting/cadoodle/MoveCenter.java | 2 +- .../bowlerstudio/scripting/cadoodle/Paste.java | 2 +- .../bowlerstudio/scripting/cadoodle/Resize.java | 2 +- .../bowlerstudio/scripting/cadoodle/Show.java | 2 +- .../bowlerstudio/scripting/cadoodle/ToHole.java | 2 +- .../bowlerstudio/scripting/cadoodle/ToSolid.java | 2 +- .../bowlerstudio/scripting/cadoodle/UnGroup.java | 2 +- .../bowlerstudio/scripting/cadoodle/UnLock.java | 2 +- 18 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 3a0788a3..4cd74bc3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -8,7 +8,7 @@ import com.google.gson.annotations.Expose; -public abstract class AbstractAddFrom implements ICaDoodleOpperation { +public abstract class AbstractAddFrom extends AbstractCaDoodleFileAccepter{ @Expose (serialize = false, deserialize = false) protected HashSet namesAdded = new HashSet<>(); @Expose (serialize = false, deserialize = false) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java new file mode 100644 index 00000000..d97087c9 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java @@ -0,0 +1,14 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public abstract class AbstractCaDoodleFileAccepter implements ICaDoodleOpperation{ + private CaDoodleFile cf = null; + + public CaDoodleFile getCaDoodleFile() { + return cf; + } + + public void setCaDoodleFile(CaDoodleFile cf) { + this.cf = cf; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index bcceff58..fa1cc707 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -28,7 +28,7 @@ import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; -public class AddFromFile extends AbstractAddFrom implements ICaDoodleOpperation { +public class AddFromFile extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private TransformNR location = null; private ArrayList options = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 63bf081a..f993b08d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -21,7 +21,7 @@ import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; -public class AddFromScript extends AbstractAddFrom implements ICaDoodleOpperation { +public class AddFromScript extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private String gitULR = ""; @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index dc54b32d..d0843525 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -13,7 +13,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class Allign implements ICaDoodleOpperation { +public class Allign extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 4d4afb8f..24d63e4d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -13,7 +13,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Delete implements ICaDoodleOpperation { +public class Delete extends AbstractCaDoodleFileAccepter { @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 21a43356..fdde6c83 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -12,7 +12,7 @@ import eu.mihosoft.vrl.v3d.parametrics.IParametric; import javafx.scene.paint.Color; -public class Group extends AbstractAddFrom implements ICaDoodleOpperation { +public class Group extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 38389fb4..6facb852 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Hide implements ICaDoodleOpperation { +public class Hide extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index ff2e3e41..554a9137 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Lock implements ICaDoodleOpperation { +public class Lock extends AbstractCaDoodleFileAccepter { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 832ffb7d..1b94e42f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -11,7 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class Mirror implements ICaDoodleOpperation { +public class Mirror extends AbstractCaDoodleFileAccepter { @Expose(serialize = true, deserialize = true) private MirrorOrentation location; @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 0cf6df40..78fe909e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -16,7 +16,7 @@ import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; -public class MoveCenter implements ICaDoodleOpperation { +public class MoveCenter extends AbstractCaDoodleFileAccepter{ @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 10ff19fa..c50d9c85 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -22,7 +22,7 @@ import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; import eu.mihosoft.vrl.v3d.parametrics.Parameter; -public class Paste extends AbstractAddFrom implements ICaDoodleOpperation { +public class Paste extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 00b27704..963b8150 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -16,7 +16,7 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.Vector3d; -public class Resize implements ICaDoodleOpperation { +public class Resize extends AbstractCaDoodleFileAccepter{ @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 8471fc03..f9fa3b82 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Show implements ICaDoodleOpperation { +public class Show extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index 323f37ed..41ec3960 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class ToHole implements ICaDoodleOpperation { +public class ToHole extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 7900166b..fc47f696 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -8,7 +8,7 @@ import eu.mihosoft.vrl.v3d.CSG; import javafx.scene.paint.Color; -public class ToSolid implements ICaDoodleOpperation { +public class ToSolid extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 92774521..35abab29 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -11,7 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class UnGroup implements ICaDoodleOpperation { +public class UnGroup extends AbstractCaDoodleFileAccepter{ @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index 8f12e0bb..eebce59e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class UnLock implements ICaDoodleOpperation { +public class UnLock extends AbstractCaDoodleFileAccepter{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override From 25340be56e21b401610d60041ce45ff5b0c54572 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 25 May 2025 15:47:32 -0400 Subject: [PATCH 412/635] use the updated class instead of the interface --- .../scripting/cadoodle/CaDoodleFile.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 25bc63b1..297f9853 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -55,7 +55,7 @@ public class CaDoodleFile { public static final String NO_NAME = "NoName"; @Expose(serialize = true, deserialize = true) - private ArrayList opperations = new ArrayList(); + private ArrayList opperations = new ArrayList(); @Expose(serialize = true, deserialize = true) private int currentIndex = 0; @Expose(serialize = true, deserialize = true) @@ -73,7 +73,7 @@ public class CaDoodleFile { @Expose(serialize = false, deserialize = false) private double percentInitialized = 0; @Expose(serialize = false, deserialize = false) - private HashMap> cache = new HashMap>(); + private HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() @@ -82,7 +82,7 @@ public class CaDoodleFile { private ArrayList listeners = new ArrayList(); private final ArrayList opperationRunner = new ArrayList(); private boolean regenerating; - private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); + private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; private static HashMap bomManagers = new HashMap<>(); @@ -158,7 +158,7 @@ public void initialize() { if (indexStarting > opperations.size()) indexStarting = opperations.size(); for (int i = 0; i < getOpperations().size(); i++) { - ICaDoodleOpperation op = getOpperations().get(i); + AbstractCaDoodleFileAccepter op = getOpperations().get(i); if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); @@ -270,7 +270,7 @@ public void run() { setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; - ICaDoodleOpperation op = getOpperations().get(currentIndex2); + AbstractCaDoodleFileAccepter op = getOpperations().get(currentIndex2); getSaveUpdate().renderSplashFrame(percent, "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); @@ -326,7 +326,7 @@ public void run() { this.setName("regenerateCurrent Thread"); - ICaDoodleOpperation op = getCurrentOpperation(); + AbstractCaDoodleFileAccepter op = getCurrentOpperation(); TickToc.tic("Start regenerate"); List process = op.process(getPreviouState()); TickToc.tic("Finish regenerate"); @@ -350,7 +350,8 @@ public void run() { } - private void process(ICaDoodleOpperation op) { + private void process(AbstractCaDoodleFileAccepter op) { + op.setCaDoodleFile(this); List process = op.process(getCurrentState()); int currentIndex2 = getCurrentIndex(); storeResultInCache(op, process); @@ -377,7 +378,7 @@ public boolean isOperationRunning() { return false; } - public Thread addOpperation(ICaDoodleOpperation o) throws CadoodleConcurrencyException { + public Thread addOpperation(AbstractCaDoodleFileAccepter o) throws CadoodleConcurrencyException { if (o == null) throw new NullPointerException(); toProcess.add(o); @@ -393,7 +394,7 @@ public void run() { while (toProcess.size() > 0) { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); - ICaDoodleOpperation op = toProcess.remove(0); + AbstractCaDoodleFileAccepter op = toProcess.remove(0); if (getCurrentIndex() != getOpperations().size()) { try { fireRegenerateStart(); @@ -578,9 +579,9 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { imageCache.delete(); } if (res == OperationResult.PRUNE) { - List subList = (List) getOpperations().subList(0, + List subList = (List) getOpperations().subList(0, getCurrentIndex()); - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); @@ -589,7 +590,7 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { return res; } - private void storeResultInCache(ICaDoodleOpperation op, List process) { + private void storeResultInCache(AbstractCaDoodleFileAccepter op, List process) { ArrayList cachedCopy = new ArrayList(); HashSet names = new HashSet<>(); for (CSG c : process) { @@ -678,7 +679,7 @@ private void updateCurrentFromCache() { setCurrentState(key, getCurrentState()); } - public ICaDoodleOpperation getCurrentOpperation() { + public AbstractCaDoodleFileAccepter getCurrentOpperation() { if (getCurrentIndex() == 0) return null; return getOpperations().get(getCurrentIndex() - 1); @@ -1039,11 +1040,11 @@ public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boole return file; } - public ArrayList getOpperations() { + public ArrayList getOpperations() { return opperations; } - public void setOpperations(ArrayList opperations) { + public void setOpperations(ArrayList opperations) { this.opperations = opperations; currentIndex = opperations.size(); } From 3d88eea0a2dc67ca78eb24ccd3f6c2a271ee8e03 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 25 May 2025 15:58:22 -0400 Subject: [PATCH 413/635] Set the cadoodle file into each opperation --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 297f9853..a24cf028 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -245,6 +245,8 @@ public Thread regenerateFrom(ICaDoodleOpperation source) { // .printStackTrace(); } Thread t = null; + CaDoodleFile cf = this; + t = new Thread() { public void run() { this.setName("Regeneration Threads"); @@ -275,6 +277,7 @@ public void run() { "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); try { + op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); storeResultInCache(op, process); setCurrentState(op, process); @@ -318,6 +321,7 @@ public Thread regenerateCurrent() { } fireRegenerateStart(); Thread t = null; + CaDoodleFile cf = this; t = new Thread() { public void run() { timeOfLastUpdate = System.currentTimeMillis(); @@ -328,6 +332,7 @@ public void run() { AbstractCaDoodleFileAccepter op = getCurrentOpperation(); TickToc.tic("Start regenerate"); + op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); TickToc.tic("Finish regenerate"); int currentIndex2 = getCurrentIndex(); From 6545f10b37665c047888382bd4e1a3b16a8d752e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 25 May 2025 16:24:20 -0400 Subject: [PATCH 414/635] close loaded cadoodle files after use --- .../neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java | 1 + .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index ef220884..4730e889 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -40,6 +40,7 @@ public static Object process(CaDoodleFile loaded) { back.remove(c); } } + loaded.close(); return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a24cf028..a665dea2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -100,6 +100,9 @@ public void renderSplashFrame(int percent, String message) { private boolean timelineOpen = false; public void close() { + for(AbstractCaDoodleFileAccepter op:getOpperations()) { + op.setCaDoodleFile(null); + } for (ICaDoodleOpperation op : cache.keySet()) { cache.get(op).clear(); } @@ -112,6 +115,7 @@ public void close() { img = null; for (Thread t : opperationRunner) t.interrupt(); + } public CaDoodleFile clearListeners() { From 350c437a97f61e61da01d46351dbea034991f552 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 25 May 2025 16:39:19 -0400 Subject: [PATCH 415/635] life cycle the loaded file, but don not close in the helper method --- .../bowlerstudio/scripting/CaDoodleLoader.java | 9 ++++++--- .../scripting/cadoodle/CaDoodleFile.java | 15 ++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index 4730e889..9fbcd782 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -22,13 +22,17 @@ public class CaDoodleLoader implements IScriptingLanguage { @Override public Object inlineScriptRun(File code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromFile(code); - return process(loaded); + Object process = process(loaded); + loaded.close(); + return process; } @Override public Object inlineScriptRun(String code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromJsonString(code); - return process(loaded); + Object process = process(loaded); + loaded.close(); + return process; } public static Object process(CaDoodleFile loaded) { @@ -40,7 +44,6 @@ public static Object process(CaDoodleFile loaded) { back.remove(c); } } - loaded.close(); return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a665dea2..7f75b935 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -65,24 +65,23 @@ public class CaDoodleFile { @Expose(serialize = true, deserialize = true) private TransformNR rulerLocation = new TransformNR(); @Expose(serialize = true, deserialize = true) + + // Non Serialised private variables private TransformNR workplane = new TransformNR(); - @Expose(serialize = false, deserialize = false) private File selfInternal; // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); - @Expose(serialize = false, deserialize = false) private double percentInitialized = 0; - @Expose(serialize = false, deserialize = false) - private HashMap> cache = new HashMap>(); + private final HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) .create(); - private ArrayList listeners = new ArrayList(); + private final ArrayList listeners = new ArrayList(); private final ArrayList opperationRunner = new ArrayList(); private boolean regenerating; - private CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; private static HashMap bomManagers = new HashMap<>(); @@ -100,6 +99,7 @@ public void renderSplashFrame(int percent, String message) { private boolean timelineOpen = false; public void close() { + //new Exception("CaDoodle File Closed here").printStackTrace(); for(AbstractCaDoodleFileAccepter op:getOpperations()) { op.setCaDoodleFile(null); } @@ -107,11 +107,8 @@ public void close() { cache.get(op).clear(); } cache.clear(); - cache = null; clearListeners(); - listeners = null; toProcess.clear(); - toProcess = null; img = null; for (Thread t : opperationRunner) t.interrupt(); From d8d920a1c6e91de1db77dbb2c5b2ebfd048c5863 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 29 May 2025 09:54:44 -0400 Subject: [PATCH 416/635] Adding the JCSG server --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2a288cdc..e8ea7320 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.7.0' + api 'com.neuronrobotics:JavaCad:2.8.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 36067055758b7742202654ff9c90cf926250f7f8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 29 May 2025 10:16:19 -0400 Subject: [PATCH 417/635] Adding a server launch to the kernel --- .../bowlerstudio/BowlerKernel.java | 111 +++++++++++------- 1 file changed, 71 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 5c43cfbf..0b2c75b0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -57,6 +57,7 @@ import com.neuronrobotics.sdk.addons.kinematics.MobileBase; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.CSGServer; import eu.mihosoft.vrl.v3d.ICSGProgress; import eu.mihosoft.vrl.v3d.JavaFXInitializer; import javafx.application.Platform; @@ -72,7 +73,7 @@ public class BowlerKernel { // private static final String CSG = null; private static File historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history"); - private static boolean kernelMode=true; + private static boolean kernelMode = true; private static void loadHistoryLocal() { historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history"); @@ -108,8 +109,9 @@ private static void fail() { "java -jar BowlerScriptKernel.jar -p .. # This will load one script then take the list of objects returned and pss them to the next script as its 'args' variable "); com.neuronrobotics.sdk.common.Log.error( "java -jar BowlerScriptKernel.jar -r (Optional)(-s or -p) .. # This will start a shell in the requested langauge and run the files provided. "); - com.neuronrobotics.sdk.common.Log.error("java -jar BowlerScriptKernel.jar -g # this will run a file from git"); - if(isKernelMode()) + com.neuronrobotics.sdk.common.Log + .error("java -jar BowlerScriptKernel.jar -g # this will run a file from git"); + if (isKernelMode()) System.exit(1); } @@ -130,8 +132,10 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) boolean gitRun = false; String gitRepo = null; String gitFile = null; + boolean runCSGServer = false; + File keys = null; + int port = 3742; for (String s : args) { - if (gitRun) { if (gitRepo == null) { gitRepo = s; @@ -142,7 +146,34 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) if (s.startsWith("-g")) { gitRun = true; } + if (s.toLowerCase().contains("-csgserver")) { + runCSGServer = true; + continue; + } + if (runCSGServer) { + if (keys == null) { + keys = new File(s); + continue; + } else { + try { + port = Integer.parseInt(s); + }catch(NumberFormatException ex) { + ex.printStackTrace(); + } + } + } + } + if (runCSGServer) { + CSGServer.setDirectory(ScriptingEngine.getWorkspace()); + CSGServer server = new CSGServer(port, keys); + try { + server.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return; } + Object ret = null; File baseWorkspaceFile = null; if (gitRun && gitRepo != null) { @@ -198,21 +229,21 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) File f = new File(s); String location; try { - location =ScriptingEngine.locateGitTopLevelDirectory(f).getAbsolutePath(); - }catch(Exception ex) { - location= new File(".").getAbsolutePath(); + location = ScriptingEngine.locateGitTopLevelDirectory(f).getAbsolutePath(); + } catch (Exception ex) { + location = new File(".").getAbsolutePath(); + } + if (location.endsWith(".")) { + location = location.substring(0, location.length() - 1); } - if(location.endsWith(".")) { - location=location.substring(0,location.length()-1); - } - if(!location.endsWith("/")) { - location+="/"; + if (!location.endsWith("/")) { + location += "/"; } baseWorkspaceFile = new File(location); - - System.out.println("Using working directory "+baseWorkspaceFile.getAbsolutePath()); - f=new File(baseWorkspaceFile.getAbsolutePath()+"/"+s); - com.neuronrobotics.sdk.common.Log.error("File "+f.getName()); + + System.out.println("Using working directory " + baseWorkspaceFile.getAbsolutePath()); + f = new File(baseWorkspaceFile.getAbsolutePath() + "/" + s); + com.neuronrobotics.sdk.common.Log.error("File " + f.getName()); ret = ScriptingEngine.inlineFileScriptRun(f, null); } catch (Throwable e) { e.printStackTrace(); @@ -385,27 +416,27 @@ public void progressUpdate(int currentIndex, int finalIndex, String type, } private static void finish(long startTime) { - com.neuronrobotics.sdk.common.Log.error( - "Process took " + (((double) (System.currentTimeMillis() - startTime))) / 60000.0 + " minutes"); + com.neuronrobotics.sdk.common.Log + .error("Process took " + (((double) (System.currentTimeMillis() - startTime))) / 60000.0 + " minutes"); System.exit(0); } public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { processUIOpening(ret); - if(baseWorkspaceFile!=null) - System.out.println("Processing file in directory "+baseWorkspaceFile.getAbsolutePath()); + if (baseWorkspaceFile != null) + System.out.println("Processing file in directory " + baseWorkspaceFile.getAbsolutePath()); - if (baseWorkspaceFile != null) { - - File baseDirForFiles = new File(baseWorkspaceFile.getAbsolutePath()+"/manufacturing/"); + + File baseDirForFiles = new File(baseWorkspaceFile.getAbsolutePath() + "/manufacturing/"); if (baseDirForFiles.exists()) { // baseDirForFiles.mkdir(); File bomCSV = new File( baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomCsv()); if (bomCSV.exists()) { - File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.getManufacturingBomCsv()); + File file = new File( + baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomCsv()); // if (file.exists()) // file.delete(); try { @@ -418,7 +449,8 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil File bom = new File( baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomJson()); if (bom.exists()) { - File file = new File(baseWorkspaceFile.getAbsolutePath() + "/"+ VitaminBomManager.getManufacturingBomJson()); + File file = new File( + baseWorkspaceFile.getAbsolutePath() + "/" + VitaminBomManager.getManufacturingBomJson()); // if (file.exists()) // file.delete(); try { @@ -428,7 +460,7 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil e.printStackTrace(); } } - }else { + } else { baseDirForFiles.mkdirs(); } } @@ -436,9 +468,9 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil try { processReturnedObjects(ret, csgBits); String url = ScriptingEngine.locateGitUrl(baseWorkspaceFile); - com.neuronrobotics.sdk.common.Log.error("Loading printbed URL "+url); + com.neuronrobotics.sdk.common.Log.error("Loading printbed URL " + url); PrintBedManager printBedManager = new PrintBedManager(baseWorkspaceFile, csgBits); - if(printBedManager.hasPrintBed()) + if (printBedManager.hasPrintBed()) csgBits = printBedManager.makePrintBeds(); else { com.neuronrobotics.sdk.common.Log.error("Exporting files without print bed"); @@ -451,12 +483,12 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil } private static void processUIOpening(Object ret) { - if(Tab.class.isInstance(ret)) { + if (Tab.class.isInstance(ret)) { com.neuronrobotics.sdk.common.Log.error("Launching User Defined UI"); - Tab t=(Tab)ret; + Tab t = (Tab) ret; CompletableFuture future = new CompletableFuture<>(); - BowlerKernel.runLater(()->{ + BowlerKernel.runLater(() -> { // Get the content from the tab javafx.scene.Node content = t.getContent(); // Create a new stage @@ -482,7 +514,7 @@ private static void processUIOpening(Object ret) { newStage.setOnCloseRequest(event -> { // Exit the JVM when the window is closed future.complete(true); - BowlerKernel.runLater(()->Platform.exit()); + BowlerKernel.runLater(() -> Platform.exit()); }); FontSizeManager.addListener(fontNum -> { int tmp = fontNum - 10; @@ -491,10 +523,10 @@ private static void processUIOpening(Object ret) { root.setStyle("-fx-font-size: " + tmp + "pt"); newStage.sizeToScene(); }); - if(IStageReceiver.class.isInstance(ret)) { + if (IStageReceiver.class.isInstance(ret)) { com.neuronrobotics.sdk.common.Log.error("UI is a IStageReceiver"); - IStageReceiver r=(IStageReceiver)ret; - BowlerKernel.runLater(()->{ + IStageReceiver r = (IStageReceiver) ret; + BowlerKernel.runLater(() -> { r.receiveStage(newStage, scene); }); } @@ -505,13 +537,13 @@ private static void processUIOpening(Object ret) { scene.getRoot().layout(); }); try { - future.get(); + future.get(); System.exit(0); } catch (Exception e) { e.printStackTrace(); } } - + } private static void processReturnedObjects(Object ret, ArrayList csgBits) { @@ -524,8 +556,8 @@ private static void processReturnedObjects(Object ret, ArrayList csgBits) { if (CSG.class.isInstance(ret)) { csgBits.add((CSG) ret); } - if(CaDoodleFile.class.isInstance(ret)) { - processReturnedObjects(CaDoodleLoader.process((CaDoodleFile)ret), csgBits); + if (CaDoodleFile.class.isInstance(ret)) { + processReturnedObjects(CaDoodleLoader.process((CaDoodleFile) ret), csgBits); return; } if (MobileBase.class.isInstance(ret)) { @@ -831,5 +863,4 @@ public static void setKernelMode(boolean kernelMode) { BowlerKernel.kernelMode = kernelMode; } - } From 847405e48e38135b721d7b43816564656c9aeedf Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 1 Jun 2025 11:05:42 -0400 Subject: [PATCH 418/635] Adding checks on the server datatypes --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e8ea7320..806869f4 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.0' + api 'com.neuronrobotics:JavaCad:2.8.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From a284d310409d19128c5a37cb6acf97ce0d2712f7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 1 Jun 2025 15:14:21 -0400 Subject: [PATCH 419/635] update jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 806869f4..3dbe0e1e 100755 --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.1' + api 'com.neuronrobotics:JavaCad:2.8.2' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ea55b8faf1c980c75cc74a23891d75b7ebd46823 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 1 Jun 2025 21:48:58 -0400 Subject: [PATCH 420/635] Adding the latest client --- build.gradle | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/build.gradle b/build.gradle index 3dbe0e1e..b2322995 100755 --- a/build.gradle +++ b/build.gradle @@ -114,7 +114,6 @@ String getOsArch() { return System.getProperty("os.arch"); } -//https://oss.sonatype.org/service/local/repositories/releases/content/com/neuronrobotics/nrjavaserial/3.10.1/nrjavaserial-3.10.1.jar repositories { @@ -147,7 +146,6 @@ repositories { maven { url "https://jitpack.io" } maven { url "https://repo.eclipse.org/content/groups/releases/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://dl.bintray.com/dfki-lt/maven/" } maven { url "https://raw.github.com/marytts/marytts/master/repository/" } maven { url "https://repo.jenkins-ci.org/public/" } @@ -156,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.2' + api 'com.neuronrobotics:JavaCad:2.8.8' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') @@ -388,47 +386,4 @@ test { exceptionFormat = 'full' } } -/* - signing { - sign configurations.archives - } - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - pom.project { - name 'Bowler Scripting Kernel' - packaging 'jar' - // optionally artifactId can be defined here - description 'A command line utility for accsing the bowler framework.' - url 'http://neuronrobotics.com' - scm { - connection 'scm:git:https://github.com/NeuronRobotics/bowler-script-kernel.git' - developerConnection 'scm:git:git@github.com:NeuronRobotics/bowler-script-kernel.git' - url 'https://github.com/NeuronRobotics/bowler-script-kernel' - } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id 'madhephaestus' - name 'Kevin Harrington' - email 'kharrington@neuronrobotics.com' - } - } - } - } - } - } - */ From 14e1555c86c7c510f02710c2e29f8eafdc28bca9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 2 Jun 2025 14:49:42 -0400 Subject: [PATCH 421/635] use latest server/client --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b2322995..29e76b5d 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.8' + api 'com.neuronrobotics:JavaCad:2.8.16' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 10c15dea5e86e7facc5b009f0361773558b03d80 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 2 Jun 2025 15:02:15 -0400 Subject: [PATCH 422/635] serer --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 29e76b5d..2e1dedfe 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.16' + api 'com.neuronrobotics:JavaCad:2.8.17' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 8c0955052fa6be138635ac472218f4dccf61b02a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 2 Jun 2025 15:08:03 -0400 Subject: [PATCH 423/635] removing print statements --- .../bowlerstudio/assets/ConfigurationDatabase.java | 2 +- .../bowlerstudio/vitamins/Vitamins.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 444d86bd..60ce5d0e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -146,7 +146,7 @@ public static void save() { e.printStackTrace(); return; } - com.neuronrobotics.sdk.common.Log.error("Saved "+f.getName()); + //com.neuronrobotics.sdk.common.Log.error("Saved "+f.getName()); } @SuppressWarnings("unchecked") diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 7ba7d473..cbb92aef 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -72,7 +72,7 @@ public class Vitamins { private static ConcurrentHashMap changeListeners = new ConcurrentHashMap(); public static void clear() { - com.neuronrobotics.sdk.common.Log.error("Vitamins Database Cleraing, reloading files"); + //com.neuronrobotics.sdk.common.Log.error("Vitamins Database Cleraing, reloading files"); for (String keys : databaseSet.keySet()) { ConcurrentHashMap> data = databaseSet.get(keys); for (String key2 : data.keySet()) { @@ -351,7 +351,7 @@ public static boolean saveDatabase(String type) throws Exception { + "\n\nAuto-save inside com.neuronrobotics.bowlerstudio.vitamins.Vitamins inside bowler-scripting-kernel");// commit // message // com.neuronrobotics.sdk.common.Log.error(jsonString); - com.neuronrobotics.sdk.common.Log.error("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); + //com.neuronrobotics.sdk.common.Log.error("Database saved " + getVitaminFile(type, null, false).getAbsolutePath()); } catch (Exception ex) { if(ex.getMessage().contains("Cannot commit on a repo with state: MERGING")) { ScriptingEngine.deleteRepo(getGitRepoDatabase()); @@ -378,7 +378,7 @@ public static void saveDatabaseForkIfMissing(String type,String username) throws saveDatabase(type); } catch (Exception ex) { ex.printStackTrace(); - com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); + //com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); newRepo = github.getRepository(getSourcerepo()).fork(); while(true) { @@ -429,8 +429,8 @@ private static void processSelfPR(GHPullRequest request) throws IOException { if (request.getMergeable()) { request.merge("Auto Merging Master"); reLoadDatabaseFromFiles(); - com.neuronrobotics.sdk.common.Log.error("Merged Hardware-Dimensions madhephaestus:master into " - + PasswordManager.getUsername() + ":master"); + //com.neuronrobotics.sdk.common.Log.error("Merged Hardware-Dimensions madhephaestus:master into " + // + PasswordManager.getUsername() + ":master"); } else { try { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); @@ -503,7 +503,7 @@ public static ConcurrentHashMap> getDa if (changeListeners.get(type) == null) { changeListeners.put(type, () -> { // If the file changes, clear the database and load the new data - com.neuronrobotics.sdk.common.Log.error("Re-loading " + type); + //com.neuronrobotics.sdk.common.Log.error("Re-loading " + type); databaseSet.put(type, null); new RuntimeException().printStackTrace(); }); @@ -519,7 +519,7 @@ public static ConcurrentHashMap> getDa jsonString = IOUtils.toString(inPut); inPut.close(); - com.neuronrobotics.sdk.common.Log.error("JSON loading Loading " + type + " " + jsonString.length()); + //com.neuronrobotics.sdk.common.Log.error("JSON loading Loading " + type + " " + jsonString.length()); // perfoem the GSON parse database = gson.fromJson(jsonString, TT_mapStringString); if (database == null) From 743da4f9c7f19032c3652127aab6a02de34cbca5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 2 Jun 2025 15:19:33 -0400 Subject: [PATCH 424/635] server --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2e1dedfe..db9a25ef 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.17' + api 'com.neuronrobotics:JavaCad:2.8.18' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ad8d0e804f79e7ac3fc2d08140e153e751f29534 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 5 Jun 2025 13:25:22 -0400 Subject: [PATCH 425/635] improve triangulation --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index db9a25ef..8ecd0136 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.18' + api 'com.neuronrobotics:JavaCad:2.8.19' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ff803aef4e365b8340537e05623a09d42adb03dd Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 6 Jun 2025 12:19:00 -0400 Subject: [PATCH 426/635] jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8ecd0136..62d7e810 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.19' + api 'com.neuronrobotics:JavaCad:2.8.20' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From 80e22b59209158ded50a002e4458f78d068e66a9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 7 Jun 2025 14:58:13 -0400 Subject: [PATCH 427/635] Updateing jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 62d7e810..ceb432ed 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.8.20' + api 'com.neuronrobotics:JavaCad:2.9.0' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From d5b97f55112e1ae8cf43aed95e48c96387064322 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 7 Jun 2025 15:45:20 -0400 Subject: [PATCH 428/635] jcsg --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ceb432ed..de4dde6d 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.9.0' + api 'com.neuronrobotics:JavaCad:2.9.1' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From ecab2a205dcdbfce45d3595e2d02d2284ff96aac Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 7 Jun 2025 15:52:15 -0400 Subject: [PATCH 429/635] set client --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index de4dde6d..3846d82a 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.9.1' + api 'com.neuronrobotics:JavaCad:2.9.2' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') From a2006fd565f6f9e62ea29b01ee457c2b2753b0cd Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 7 Jun 2025 18:43:36 -0400 Subject: [PATCH 430/635] only print memory when over 50% --- build.gradle | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 3846d82a..2e5b3c9b 100755 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.9.2' + api 'com.neuronrobotics:JavaCad:2.9.5' api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 7f75b935..04fdafea 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -609,7 +609,8 @@ private void storeResultInCache(AbstractCaDoodleFileAccepter op, List proce // cachedCopy.add(c); } cache.put(op, cachedCopy); - System.out.println("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + if(getFreeMemory()>50) + System.out.println("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); } public static double getFreeMemory() { @@ -872,7 +873,7 @@ public File save() throws IOException { ICaDoodleOpperation op = opperations.get(i); int percent = (int) (((double) i) / ((double) opperations.size()) * 100.0); List process = cache.get(op); - if (!f.exists()) + if (!f.exists() && process!=null) try { num++; if (isTimelineOpen()) From 80de143a953c1cac813dbb669a3811fabb0ab7b7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 12 Jun 2025 19:29:13 -0400 Subject: [PATCH 431/635] make sure the event is not triggered when control is pressed --- .../com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 9d43c081..24e6a423 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -114,6 +114,8 @@ public EventHandler getMouseEvents() { @Override public void handle(MouseEvent event) { String name = event.getEventType().getName(); + if(event.isControlDown()) + return; switch (name) { case "MOUSE_PRESSED": if(event.isPrimaryButtonDown()) From 56aff44040853584aa0d01816dae2c38afc18dae Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 22 Jun 2025 18:57:24 -0400 Subject: [PATCH 432/635] increase file gen timeout --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 04fdafea..6aa48698 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -998,7 +998,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr e.printStackTrace(); break; } - if (System.currentTimeMillis() - start > 2500 && holder.size() == 0) { + if (System.currentTimeMillis() - start > 25000 && holder.size() == 0) { throw new RuntimeException("Failed to create image"); } } From fbab7f8d99f6a51b60ae3336753f03ef72c34880 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 9 Jul 2025 18:41:15 -0400 Subject: [PATCH 433/635] update build to use the JCSG sources --- JCSG | 2 +- build.gradle | 5 ++--- settings.gradle | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/JCSG b/JCSG index 21878fc4..6db497ac 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 21878fc49db49bd58474a3062a9d372d1f835c3b +Subproject commit 6db497acc78410d1d7c624bca08d3c6e7bae28f4 diff --git a/build.gradle b/build.gradle index 2e5b3c9b..955dbe9c 100755 --- a/build.gradle +++ b/build.gradle @@ -154,12 +154,11 @@ repositories { dependencies { - api 'com.neuronrobotics:JavaCad:2.9.5' + //api 'com.neuronrobotics:JavaCad:2.9.5' + api project('JCSG') api project('java-bowler') api project('GithubPasswordManager:GithubPasswordManager') - - //compile group: "de.swirtz", name: "ktsRunner", version: "0.0.7" api 'us.ihmc:jinput:2.0.6-ihmc2' api group: 'us.ihmc', name: 'ihmc-native-library-loader', version: '1.3.1' diff --git a/settings.gradle b/settings.gradle index 6e36ec4f..1e26e61b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ include 'java-bowler' +include 'JCSG' include 'GithubPasswordManager:GithubPasswordManager' From a34682f5c86965ddbc32ce9610c66f92002005b6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 9 Jul 2025 19:11:37 -0400 Subject: [PATCH 434/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 6db497ac..5a016e6c 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 6db497acc78410d1d7c624bca08d3c6e7bae28f4 +Subproject commit 5a016e6c5cc2c5b5d3cd668a8dbf069d90fa59af From c3262d8f1b782cc8164df96df2e737b3e1e43249 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 12 Jul 2025 11:52:16 -0400 Subject: [PATCH 435/635] Make sure every file add produces something for the user to interact with in order to adjust the file. --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index fa1cc707..5dc37f81 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -1,5 +1,6 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; +import java.awt.Color; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -22,6 +23,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Cube; import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; @@ -86,7 +88,14 @@ public List process(List incoming) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); } - List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + List flattenedCSGs; + try { + flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + }catch(Throwable t) { + t.printStackTrace(); + flattenedCSGs=new ArrayList(); + flattenedCSGs.add(new Cube(10).toCSG().setColor(javafx.scene.paint.Color.HOTPINK)); + } for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); From 3324b3b631df46fafa69634b96a1e0578ca4b7b3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Jul 2025 10:20:01 -0400 Subject: [PATCH 436/635] faster difference --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 5a016e6c..26785a91 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 5a016e6c5cc2c5b5d3cd668a8dbf069d90fa59af +Subproject commit 26785a91df7920e2f3fa37ae0e78234d9cd2f6b6 From 53449053ee31a61e9d5572256e6c4ace7c89b676 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Jul 2025 11:48:15 -0400 Subject: [PATCH 437/635] kernel revert --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 26785a91..e681525e 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 26785a91df7920e2f3fa37ae0e78234d9cd2f6b6 +Subproject commit e681525ee301b13a8d6c78fc120e2cac644a6caa From 4723fd2db2d421cc0bef958be4005da073b562e5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Jul 2025 15:29:48 -0400 Subject: [PATCH 438/635] csg refinement, not much faster --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index e681525e..f23119b1 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e681525ee301b13a8d6c78fc120e2cac644a6caa +Subproject commit f23119b1322fa303dbe6a89c2df6243ce1d0402a From ba85c394028500abf475373bde5e8b0b8c052f5e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 16 Jul 2025 15:30:28 -0400 Subject: [PATCH 439/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index f23119b1..fdcb0b90 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f23119b1322fa303dbe6a89c2df6243ce1d0402a +Subproject commit fdcb0b90ae6aae5658f66afbe569e4e8098788a4 From 9fbf522d4dadb320f983b7efd1db9172af41e96e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 21 Jul 2025 11:11:41 -0400 Subject: [PATCH 440/635] colinear point exception --- JCSG | 2 +- .../scripting/cadoodle/Sweep.java | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/JCSG b/JCSG index fdcb0b90..f7af1c6a 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit fdcb0b90ae6aae5658f66afbe569e4e8098788a4 +Subproject commit f7af1c6a7b18a73dcc38682a4a779f24454c9663 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 143ea8d1..c0277f62 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -19,6 +19,8 @@ import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.ColinearPointsException; +import eu.mihosoft.vrl.v3d.Cube; import eu.mihosoft.vrl.v3d.Extrude; import eu.mihosoft.vrl.v3d.Plane; import eu.mihosoft.vrl.v3d.Polygon; @@ -89,11 +91,19 @@ public CSG sweep(Polygon p, String name, Bounds b) { Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY()); Transform increment = new Transform().rotY(-angle).movey(z); Transform radiusT = new Transform().movex(radius); - Polygon transformedP = p.transformed(centerandAllignedPolygon); - ITransformProvider pr = (unit,domain)->{ - return new Transform().movex(sprl*unit*d); - }; - return Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90).setName(name); + Polygon transformedP; + try { + transformedP = p.transformed(centerandAllignedPolygon); + + ITransformProvider pr = (unit,domain)->{ + return new Transform().movex(sprl*unit*d); + }; + return Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90).setName(name); + } catch (ColinearPointsException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return new Cube(10).toCSG().setColor(Color.PINK); } public LengthParameter radius(String name) { From cdcb9f96e238225fc680fe6aa5ac1c45b1350f6d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 22 Jul 2025 10:48:46 -0400 Subject: [PATCH 441/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index f7af1c6a..0452fa48 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f7af1c6a7b18a73dcc38682a4a779f24454c9663 +Subproject commit 0452fa4840ce5598af5d53e5077c0645a7c9902d From 7cc2f68d9a1cd4da8a4d2c088a28be6ee31fd96c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 22 Jul 2025 13:45:29 -0400 Subject: [PATCH 442/635] JCSG --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 0452fa48..184fa527 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 0452fa4840ce5598af5d53e5077c0645a7c9902d +Subproject commit 184fa5277d1a8b5c62deeafc8e6eee87b74f3c6e From 58ef5ba2d9ed7859c884c2e20eda8123127d6a3d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 22 Jul 2025 15:38:29 -0400 Subject: [PATCH 443/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 184fa527..51784815 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 184fa5277d1a8b5c62deeafc8e6eee87b74f3c6e +Subproject commit 517848151dbb76dc1763fe28cb551a388f13512f From 7d5bc96c1373221dc3b9a2789652835de977807f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Jul 2025 11:24:32 -0400 Subject: [PATCH 444/635] update the log API --- .../bowlerstudio/scripting/DownloadManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 753a0177..e933f552 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -132,7 +132,7 @@ public void notifyOfFailure(String name) { private static GitLogProgressMonitor psudoSplash = new GitLogProgressMonitor() { @Override - public void onUpdate(String update, Exception e) { + public void onLogUpdate(String update, Exception e) { // Auto-generated method stub } @@ -703,7 +703,7 @@ private static void extractItem(IInArchive inArchive, int index, String outputPa result = inArchive.extractSlow(index, new ISequentialOutStream() { public int write(byte[] data) throws SevenZipException { try { - psudoSplash.onUpdate("Inflate 7z .. " + outputFile.getName(),null); + psudoSplash.onLogUpdate("Inflate 7z .. " + outputFile.getName(),null); fos.write(data); } catch (IOException e) { throw new SevenZipException("Error writing to file: " + e.getMessage()); @@ -839,7 +839,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc try (OutputStream out = Files.newOutputStream(outPath)) { byte[] buffer = new byte[1024]; int len; - psudoSplash.onUpdate("Inflate Tar XZ " + outPath.getFileName(),null); + psudoSplash.onLogUpdate("Inflate Tar XZ " + outPath.getFileName(),null); while ((len = tarIn.read(buffer)) != -1) { out.write(buffer, 0, len); } @@ -981,7 +981,7 @@ public static File download(String version, String URL, long sizeOfFile, String public void process(double percent) { if (System.currentTimeMillis() - timeSinceePrint > 1000) { timeSinceePrint = System.currentTimeMillis(); - psudoSplash.onUpdate((int) (percent * 100)+" % "+filename ,null); + psudoSplash.onLogUpdate((int) (percent * 100)+" % "+filename ,null); } // if(progress!=null) // Platform.runLater(() -> { @@ -1005,7 +1005,7 @@ public void process(double percent) { downloadEvents.startDownload(); rawFileDownload(pis, folder, exe); com.neuronrobotics.sdk.common.Log.error("Finished downloading " + filename); - psudoSplash.onUpdate((int) (1 * 100)+" % " +filename , null); + psudoSplash.onLogUpdate((int) (1 * 100)+" % " +filename , null); downloadEvents.finishDownload(); } else { com.neuronrobotics.sdk.common.Log.error("Not downloading, it existst " + filename); From f9c6d88bc069aaea76a24cc065203a6ef93bea0b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Jul 2025 11:24:45 -0400 Subject: [PATCH 445/635] update log name --- .../bowlerstudio/scripting/GitLogProgressMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitLogProgressMonitor.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitLogProgressMonitor.java index 3315971b..7e9a42e9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitLogProgressMonitor.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GitLogProgressMonitor.java @@ -1,5 +1,5 @@ package com.neuronrobotics.bowlerstudio.scripting; public interface GitLogProgressMonitor { - public abstract void onUpdate(String update, Exception e); + public abstract void onLogUpdate(String update, Exception e); } From b91e4515c6bc3d5adf077471a81d419147430a01 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Jul 2025 11:24:56 -0400 Subject: [PATCH 446/635] update log api --- .../bowlerstudio/scripting/ScriptingEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 6a02b94a..c0a421df 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -334,7 +334,7 @@ public void update(int completed) { // com.neuronrobotics.sdk.common.Log.error(str); for (GitLogProgressMonitor l : logListeners) { - l.onUpdate(str, e); + l.onLogUpdate(str, e); } } @@ -354,7 +354,7 @@ public void endTask() { if (printProgress) com.neuronrobotics.sdk.common.Log.error(string); for (GitLogProgressMonitor l : logListeners) { - l.onUpdate(string, e); + l.onLogUpdate(string, e); } } From 1d39bf37127360ddd745d502450f161da7fe7354 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 26 Jul 2025 15:28:25 -0400 Subject: [PATCH 447/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 51784815..f5e5ed6b 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 517848151dbb76dc1763fe28cb551a388f13512f +Subproject commit f5e5ed6b3ef9c135e3eaee028dfb31d1b7608cb0 From 428c57b8b02f9016bdb3bc28b53e796756d39f76 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 27 Jul 2025 20:05:20 -0400 Subject: [PATCH 448/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index f5e5ed6b..f7fa6ca1 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f5e5ed6b3ef9c135e3eaee028dfb31d1b7608cb0 +Subproject commit f7fa6ca1e5c35a384b4514bde3a5f77699a7ebe3 From 9e3a8bbe4bd0a4cf0c8417ad46cde7e7da9d820e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 28 Jul 2025 13:23:12 -0400 Subject: [PATCH 449/635] jcsg threaded split --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index f7fa6ca1..4ade0577 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f7fa6ca1e5c35a384b4514bde3a5f77699a7ebe3 +Subproject commit 4ade05772099834e9af8241e3dbb1e9e4ce81dfe From cd9f58e932f57231abb8f98634f6001b4466f164 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 10:23:19 -0400 Subject: [PATCH 450/635] fixing the reverted GPU split --- JCSG | 2 +- .../bowlerstudio/scripting/FreecadLoader.java | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/JCSG b/JCSG index 4ade0577..4a2d3742 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4ade05772099834e9af8241e3dbb1e9e4ce81dfe +Subproject commit 4a2d37429f7b64efd4634b481db99d1bdb338944 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index e4ea89c7..61b5f82a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -34,6 +34,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.ColinearPointsException; import eu.mihosoft.vrl.v3d.Cube; import eu.mihosoft.vrl.v3d.JavaFXInitializer; import eu.mihosoft.vrl.v3d.Polygon; @@ -113,15 +114,22 @@ public static void addCSGToFreeCAD(File freecadModel,CSG toSlice, List polygons = Slice.slice(toSlice, pose, 0); - String svgName = toSlice.getName(); - if(svgName.length()==0) - svgName="SVG_EXPORT"; - svgName+="_"+planes; - File svg = File.createTempFile(svgName, ".svg"); - SVGExporter.export(polygons, svg, false); - addSVGToFreeCAD(freecadModel,svg,pose,svgName,name+"_body"); - planes++; + List polygons; + try { + polygons = Slice.slice(toSlice, pose, 0); + String svgName = toSlice.getName(); + if(svgName.length()==0) + svgName="SVG_EXPORT"; + svgName+="_"+planes; + File svg = File.createTempFile(svgName, ".svg"); + SVGExporter.export(polygons, svg, false); + addSVGToFreeCAD(freecadModel,svg,pose,svgName,name+"_body"); + planes++; + } catch (ColinearPointsException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } addSTLToFreecad(freecadModel,tmp,name); } From ecfdb9570673c0947ea154219e477237ba688213 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 12:24:20 -0400 Subject: [PATCH 451/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 4a2d3742..396e6121 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4a2d37429f7b64efd4634b481db99d1bdb338944 +Subproject commit 396e6121962150810c01cc7ec7e706c9f626f16a From d209743f9316476c67789f13bd11d95abf319e7e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 12:54:09 -0400 Subject: [PATCH 452/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 396e6121..ebaf3500 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 396e6121962150810c01cc7ec7e706c9f626f16a +Subproject commit ebaf35002505026b43cbbc3a6c52928182c72c95 From 4d4fbe09f62e84971ad48b21d5790f06aeb1ecc5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 13:39:57 -0400 Subject: [PATCH 453/635] make sure the index is valid on start --- JCSG | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/JCSG b/JCSG index ebaf3500..186a0bfe 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit ebaf35002505026b43cbbc3a6c52928182c72c95 +Subproject commit 186a0bfe98a02882698a7c347ad4937927a15581 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6aa48698..67243ac2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -153,7 +153,10 @@ public void initialize() { } int indexStarting = getCurrentIndex(); - setCurrentIndex(0); + if(indexStarting==0) { + indexStarting=opperations.size(); + } + this.currentIndex=0; setPercentInitialized(0); opperations = opperations.stream().filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new)); if (indexStarting > opperations.size()) @@ -1073,7 +1076,8 @@ public int getCurrentIndex() { } public void setCurrentIndex(int currentIndex) { - // new Exception("Current Index set to " + currentIndex).printStackTrace(); +// if(currentIndex==0) +// new Exception("Current Index set to " + currentIndex).printStackTrace(); if ((currentIndex - 1) >= getOpperations().size()) throw new RuntimeException("Fail! Can not set an index greater than the availible operations"); this.currentIndex = currentIndex; From 62db0ccadf1b96c2cac20d33a62691ee02583389 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 14:21:22 -0400 Subject: [PATCH 454/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 186a0bfe..8e517cbf 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 186a0bfe98a02882698a7c347ad4937927a15581 +Subproject commit 8e517cbfadc664775510a36c8730fe83c7428075 From 351d5baf6422fba84857a5c16c269d43f2ee9f2b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 30 Jul 2025 15:04:15 -0400 Subject: [PATCH 455/635] removing legacy repos --- build.gradle | 5 ----- 1 file changed, 5 deletions(-) diff --git a/build.gradle b/build.gradle index 955dbe9c..579b5234 100755 --- a/build.gradle +++ b/build.gradle @@ -126,11 +126,6 @@ repositories { maven { url 'https://repo1.maven.org/maven2/'} - maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - //maven { url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } - maven { url 'https://oss.sonatype.org/content/repositories/releases/' } - //com.neuronrobotics hosting point - maven { url 'https://oss.sonatype.org/content/repositories/staging/' } // maven { // url "https://repo.myrobotlab.org/artifactory/myrobotlab/" From cc52200243ab159531cd2f910bb14cdfb4708cfe Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 31 Jul 2025 10:56:51 -0400 Subject: [PATCH 456/635] back to development after merge --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 8e517cbf..e194d242 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 8e517cbfadc664775510a36c8730fe83c7428075 +Subproject commit e194d2424244d6b68252fa45bda84d45056bd3e1 From f725f7e4a1f07f1e02cc09b64c4a07c8e76a842d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 31 Jul 2025 17:22:16 -0400 Subject: [PATCH 457/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index e194d242..586f8521 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e194d2424244d6b68252fa45bda84d45056bd3e1 +Subproject commit 586f8521630f6fd9902d1780c8fe1a9906f4064e From 43d455d97e5b5d6e5758451412fc396b7ba229c7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 31 Jul 2025 17:31:20 -0400 Subject: [PATCH 458/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 586f8521..f421f24d 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 586f8521630f6fd9902d1780c8fe1a9906f4064e +Subproject commit f421f24db419f2855affe18ec71037c211d6c210 From 0a09484a3161b82a7889cd32e174b57596657d1e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 31 Jul 2025 17:49:01 -0400 Subject: [PATCH 459/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index f421f24d..6ab0e967 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f421f24db419f2855affe18ec71037c211d6c210 +Subproject commit 6ab0e967df045254a329adb3df32f0ca602cee1b From 2f8258db6d685e7bc2f2bd1b3309079dad82b40f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 1 Aug 2025 14:03:08 -0400 Subject: [PATCH 460/635] Refactor operation name --- JCSG | 2 +- .../scripting/cadoodle/AbstractAddFrom.java | 2 +- .../scripting/cadoodle/Allign.java | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 32 +++++++++---------- ...leAccepter.java => CaDoodleOperation.java} | 2 +- .../scripting/cadoodle/Delete.java | 2 +- .../bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../bowlerstudio/scripting/cadoodle/Lock.java | 2 +- .../scripting/cadoodle/Mirror.java | 2 +- .../scripting/cadoodle/MoveCenter.java | 2 +- .../scripting/cadoodle/Resize.java | 2 +- .../bowlerstudio/scripting/cadoodle/Show.java | 2 +- .../scripting/cadoodle/ToHole.java | 2 +- .../scripting/cadoodle/ToSolid.java | 2 +- .../scripting/cadoodle/UnGroup.java | 2 +- .../scripting/cadoodle/UnLock.java | 2 +- .../scripting/cadoodle/robot/MakeRobot.java | 5 +++ 17 files changed, 36 insertions(+), 31 deletions(-) rename src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/{AbstractCaDoodleFileAccepter.java => CaDoodleOperation.java} (72%) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java diff --git a/JCSG b/JCSG index 6ab0e967..2042aed4 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 6ab0e967df045254a329adb3df32f0ca602cee1b +Subproject commit 2042aed43a091886000a953d349793e92b4e8db0 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 4cd74bc3..3b147e8b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -8,7 +8,7 @@ import com.google.gson.annotations.Expose; -public abstract class AbstractAddFrom extends AbstractCaDoodleFileAccepter{ +public abstract class AbstractAddFrom extends CaDoodleOperation{ @Expose (serialize = false, deserialize = false) protected HashSet namesAdded = new HashSet<>(); @Expose (serialize = false, deserialize = false) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index d0843525..8ef567a3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -13,7 +13,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class Allign extends AbstractCaDoodleFileAccepter{ +public class Allign extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 67243ac2..17bb3d7a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -55,7 +55,7 @@ public class CaDoodleFile { public static final String NO_NAME = "NoName"; @Expose(serialize = true, deserialize = true) - private ArrayList opperations = new ArrayList(); + private ArrayList opperations = new ArrayList(); @Expose(serialize = true, deserialize = true) private int currentIndex = 0; @Expose(serialize = true, deserialize = true) @@ -72,7 +72,7 @@ public class CaDoodleFile { // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); private double percentInitialized = 0; - private final HashMap> cache = new HashMap>(); + private final HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() @@ -81,7 +81,7 @@ public class CaDoodleFile { private final ArrayList listeners = new ArrayList(); private final ArrayList opperationRunner = new ArrayList(); private boolean regenerating; - private final CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList toProcess = new CopyOnWriteArrayList(); private javafx.scene.image.WritableImage img; private boolean initializing; private static HashMap bomManagers = new HashMap<>(); @@ -100,7 +100,7 @@ public void renderSplashFrame(int percent, String message) { public void close() { //new Exception("CaDoodle File Closed here").printStackTrace(); - for(AbstractCaDoodleFileAccepter op:getOpperations()) { + for(CaDoodleOperation op:getOpperations()) { op.setCaDoodleFile(null); } for (ICaDoodleOpperation op : cache.keySet()) { @@ -162,7 +162,7 @@ public void initialize() { if (indexStarting > opperations.size()) indexStarting = opperations.size(); for (int i = 0; i < getOpperations().size(); i++) { - AbstractCaDoodleFileAccepter op = getOpperations().get(i); + CaDoodleOperation op = getOpperations().get(i); if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); @@ -276,7 +276,7 @@ public void run() { setPercentInitialized(((double) getCurrentIndex()) / size); // com.neuronrobotics.sdk.common.Log.error("Regenerating "+currentIndex); int currentIndex2 = getCurrentIndex() - 1; - AbstractCaDoodleFileAccepter op = getOpperations().get(currentIndex2); + CaDoodleOperation op = getOpperations().get(currentIndex2); getSaveUpdate().renderSplashFrame(percent, "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); @@ -334,7 +334,7 @@ public void run() { this.setName("regenerateCurrent Thread"); - AbstractCaDoodleFileAccepter op = getCurrentOpperation(); + CaDoodleOperation op = getCurrentOpperation(); TickToc.tic("Start regenerate"); op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); @@ -359,7 +359,7 @@ public void run() { } - private void process(AbstractCaDoodleFileAccepter op) { + private void process(CaDoodleOperation op) { op.setCaDoodleFile(this); List process = op.process(getCurrentState()); int currentIndex2 = getCurrentIndex(); @@ -387,7 +387,7 @@ public boolean isOperationRunning() { return false; } - public Thread addOpperation(AbstractCaDoodleFileAccepter o) throws CadoodleConcurrencyException { + public Thread addOpperation(CaDoodleOperation o) throws CadoodleConcurrencyException { if (o == null) throw new NullPointerException(); toProcess.add(o); @@ -403,7 +403,7 @@ public void run() { while (toProcess.size() > 0) { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); - AbstractCaDoodleFileAccepter op = toProcess.remove(0); + CaDoodleOperation op = toProcess.remove(0); if (getCurrentIndex() != getOpperations().size()) { try { fireRegenerateStart(); @@ -588,9 +588,9 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { imageCache.delete(); } if (res == OperationResult.PRUNE) { - List subList = (List) getOpperations().subList(0, + List subList = (List) getOpperations().subList(0, getCurrentIndex()); - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); com.neuronrobotics.sdk.common.Log.error("Pruning forward here!"); @@ -599,7 +599,7 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { return res; } - private void storeResultInCache(AbstractCaDoodleFileAccepter op, List process) { + private void storeResultInCache(CaDoodleOperation op, List process) { ArrayList cachedCopy = new ArrayList(); HashSet names = new HashSet<>(); for (CSG c : process) { @@ -689,7 +689,7 @@ private void updateCurrentFromCache() { setCurrentState(key, getCurrentState()); } - public AbstractCaDoodleFileAccepter getCurrentOpperation() { + public CaDoodleOperation getCurrentOpperation() { if (getCurrentIndex() == 0) return null; return getOpperations().get(getCurrentIndex() - 1); @@ -1050,11 +1050,11 @@ public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boole return file; } - public ArrayList getOpperations() { + public ArrayList getOpperations() { return opperations; } - public void setOpperations(ArrayList opperations) { + public void setOpperations(ArrayList opperations) { this.opperations = opperations; currentIndex = opperations.size(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java similarity index 72% rename from src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java rename to src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index d97087c9..eea25037 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractCaDoodleFileAccepter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -1,6 +1,6 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; -public abstract class AbstractCaDoodleFileAccepter implements ICaDoodleOpperation{ +public abstract class CaDoodleOperation implements ICaDoodleOpperation{ private CaDoodleFile cf = null; public CaDoodleFile getCaDoodleFile() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 24d63e4d..8a36c1b9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -13,7 +13,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Delete extends AbstractCaDoodleFileAccepter { +public class Delete extends CaDoodleOperation { @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 6facb852..c3b2f086 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Hide extends AbstractCaDoodleFileAccepter{ +public class Hide extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index 554a9137..01eb597d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Lock extends AbstractCaDoodleFileAccepter { +public class Lock extends CaDoodleOperation { @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 1b94e42f..d3ccf51c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -11,7 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class Mirror extends AbstractCaDoodleFileAccepter { +public class Mirror extends CaDoodleOperation { @Expose(serialize = true, deserialize = true) private MirrorOrentation location; @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 78fe909e..cfe4980c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -16,7 +16,7 @@ import eu.mihosoft.vrl.v3d.PropertyStorage; import eu.mihosoft.vrl.v3d.Transform; -public class MoveCenter extends AbstractCaDoodleFileAccepter{ +public class MoveCenter extends CaDoodleOperation{ @Expose(serialize = true, deserialize = true) private TransformNR location = new TransformNR(); @Expose(serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 963b8150..3007101b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -16,7 +16,7 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.Vector3d; -public class Resize extends AbstractCaDoodleFileAccepter{ +public class Resize extends CaDoodleOperation{ @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index f9fa3b82..93cd5c23 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class Show extends AbstractCaDoodleFileAccepter{ +public class Show extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index 41ec3960..5670e716 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class ToHole extends AbstractCaDoodleFileAccepter{ +public class ToHole extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index fc47f696..4acfccd3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -8,7 +8,7 @@ import eu.mihosoft.vrl.v3d.CSG; import javafx.scene.paint.Color; -public class ToSolid extends AbstractCaDoodleFileAccepter{ +public class ToSolid extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Expose (serialize = true, deserialize = true) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 35abab29..e8f57cb8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -11,7 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; -public class UnGroup extends AbstractCaDoodleFileAccepter{ +public class UnGroup extends CaDoodleOperation{ @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index eebce59e..6acecebc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; -public class UnLock extends AbstractCaDoodleFileAccepter{ +public class UnLock extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) private List names = new ArrayList(); @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java new file mode 100644 index 00000000..d608c7ce --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -0,0 +1,5 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; + +public class MakeRobot { + +} From 402114c5cef33a79b8cd6b241b9d382867a4d5d9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 1 Aug 2025 14:08:26 -0400 Subject: [PATCH 461/635] rename the json adapter --- .../scripting/cadoodle/CaDoodleFile.java | 2 +- ... CaDoodleJsonOperationAdapterFactory.java} | 10 +++-- .../scripting/cadoodle/robot/MakeRobot.java | 39 ++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) rename src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/{ICaDoodleOperationAdapterFactory.java => CaDoodleJsonOperationAdapterFactory.java} (87%) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 17bb3d7a..78ebe8b2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -76,7 +76,7 @@ public class CaDoodleFile { private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new ICaDoodleOperationAdapterFactory()) + .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new CaDoodleJsonOperationAdapterFactory()) .create(); private final ArrayList listeners = new ArrayList(); private final ArrayList opperationRunner = new ArrayList(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java similarity index 87% rename from src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java rename to src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 6ffa0087..a5d7c724 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -4,16 +4,17 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import java.io.IOException; import java.util.HashMap; import java.util.Map; -public class ICaDoodleOperationAdapterFactory implements TypeAdapterFactory { +public class CaDoodleJsonOperationAdapterFactory implements TypeAdapterFactory { private final Map> typeRegistry = new HashMap<>(); private final Map, String> classRegistry = new HashMap<>(); - public ICaDoodleOperationAdapterFactory() { + public CaDoodleJsonOperationAdapterFactory() { registerType("AddFromFile", AddFromFile.class); registerType("AddFromScript", AddFromScript.class); registerType("Allign", Allign.class); @@ -21,6 +22,7 @@ public ICaDoodleOperationAdapterFactory() { registerType("Group", Group.class); registerType("Hide", Hide.class); registerType("Lock", Lock.class); + registerType("MakeRobot", MakeRobot.class); registerType("Mirror", Mirror.class); registerType("MoveCenter", MoveCenter.class); registerType("Paste", Paste.class); @@ -57,7 +59,7 @@ public void write(JsonWriter out, T value) throws IOException { } jsonObject.addProperty("type", typeName); @SuppressWarnings("unchecked") - TypeAdapter delegateAdapter = (TypeAdapter) gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get((Class) value.getClass())); + TypeAdapter delegateAdapter = (TypeAdapter) gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get((Class) value.getClass())); JsonElement dataElement = delegateAdapter.toJsonTree(value); jsonObject.add("data", dataElement); jsonElementAdapter.write(out, jsonObject); @@ -73,7 +75,7 @@ public T read(JsonReader in) throws IOException { if (clazz == null) { throw new JsonParseException("Unknown type: " + typeName); } - TypeAdapter delegateAdapter = gson.getDelegateAdapter(ICaDoodleOperationAdapterFactory.this, TypeToken.get(clazz)); + TypeAdapter delegateAdapter = gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); com.neuronrobotics.sdk.common.Log.error("JSON Parsing "+typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index d608c7ce..ff7f842f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -1,5 +1,42 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; -public class MakeRobot { +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleOperation; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.RandomStringFactory; + +import eu.mihosoft.vrl.v3d.CSG; + +public class MakeRobot extends CaDoodleOperation{ + @Expose(serialize = true, deserialize = true) + protected String name = null; + + + public String getName() { + if (name == null) { + setName(RandomStringFactory.generateRandomString()); + } + return name; + } + + public void setName(String name) { + this.name = name; + } + @Override + public String getType() { + return "MakeRobot"; + } + + @Override + public List process(List incoming) { + return incoming; + } + + @Override + public List getNames() { + return new ArrayList(); + } } From 5f79190cc1d39e2b2055ffc977f242bb775a81f6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 1 Aug 2025 14:12:44 -0400 Subject: [PATCH 462/635] refactor --- .../scripting/cadoodle/AbstractAddFrom.java | 4 +-- .../scripting/cadoodle/Allign.java | 4 +-- .../scripting/cadoodle/Delete.java | 2 +- .../scripting/cadoodle/Group.java | 2 +- .../bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../cadoodle/ICaDoodleOpperation.java | 2 +- .../scripting/cadoodle/INamedOperation.java | 7 +++++ .../bowlerstudio/scripting/cadoodle/Lock.java | 2 +- .../scripting/cadoodle/Mirror.java | 2 +- .../scripting/cadoodle/MoveCenter.java | 2 +- .../scripting/cadoodle/Paste.java | 2 +- .../scripting/cadoodle/Resize.java | 2 +- .../bowlerstudio/scripting/cadoodle/Show.java | 2 +- .../scripting/cadoodle/ToHole.java | 2 +- .../scripting/cadoodle/ToSolid.java | 2 +- .../scripting/cadoodle/UnGroup.java | 2 +- .../scripting/cadoodle/UnLock.java | 2 +- .../scripting/cadoodle/robot/MakeRobot.java | 30 +++++++------------ 18 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 3b147e8b..1d7c04eb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -8,7 +8,7 @@ import com.google.gson.annotations.Expose; -public abstract class AbstractAddFrom extends CaDoodleOperation{ +public abstract class AbstractAddFrom extends CaDoodleOperation implements INamedOperation{ @Expose (serialize = false, deserialize = false) protected HashSet namesAdded = new HashSet<>(); @Expose (serialize = false, deserialize = false) @@ -18,7 +18,7 @@ public abstract class AbstractAddFrom extends CaDoodleOperation{ public HashSet getNamesAdded() { return namesAdded; } - public List getNames(){ + public List getNamesAddedInThisOperation(){ ArrayList names= new ArrayList(); names.addAll(getNamesAdded()); return names; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 8ef567a3..475cdec6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -46,7 +46,7 @@ public String getType() { @Override public String toString(){ String string = getType()+" "+x+" "+y+" "+z; - for(String n:getNames()) { + for(String n:getNamesAddedInThisOperation()) { string+=" "+n; } return string; @@ -160,7 +160,7 @@ private CSG sync(CSG incoming, CSG c) { return c.syncProperties(incoming).setName(incoming.getName()).setColor(incoming.getColor()); } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java index 8a36c1b9..292a70eb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Delete.java @@ -51,7 +51,7 @@ public Delete setLocation(TransformNR location) { return this; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index fdde6c83..2c994d17 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -105,7 +105,7 @@ private CSG intersect(ArrayList solids) { return first; } @Override - public List getNames() { + public List getNamesAddedInThisOperation() { ArrayList n= new ArrayList(); n.addAll(getNamesAdded()); n.addAll(names); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index c3b2f086..088753c4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -36,7 +36,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java index 64863488..572d5701 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java @@ -8,5 +8,5 @@ public interface ICaDoodleOpperation { public String getType(); public List process(List incoming); - public List getNames(); + public List getNamesAddedInThisOperation(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java new file mode 100644 index 00000000..2b0a2672 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java @@ -0,0 +1,7 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public interface INamedOperation { + public String getName(); + + public void setName(String name); +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index 01eb597d..c996ac49 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -36,7 +36,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index d3ccf51c..1751c132 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -132,7 +132,7 @@ public Mirror setLocation(MirrorOrentation location) { return this; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index cfe4980c..dff37e7a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -119,7 +119,7 @@ public MoveCenter setLocation(TransformNR location) { return this; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index c50d9c85..bc996636 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -127,7 +127,7 @@ public Paste setLocation(TransformNR location) { return this; } - public List getNames() { + public List getNamesAddedInThisOperation() { ArrayList n= new ArrayList(); n.addAll(getNamesAdded()); n.addAll(names); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 3007101b..617d0aac 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -217,7 +217,7 @@ public Resize setResize(TransformNR h, TransformNR lf, TransformNR rr) { return this; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 93cd5c23..4d6e9b97 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -36,7 +36,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index 5670e716..b18c6b36 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -38,7 +38,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 4acfccd3..1e5120f3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -53,7 +53,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index e8f57cb8..b43cde3d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -53,7 +53,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index 6acecebc..47c69d9d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -36,7 +36,7 @@ public List process(List incoming) { return back; } - public List getNames() { + public List getNamesAddedInThisOperation() { return names; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index ff7f842f..7258b656 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -1,29 +1,15 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; +import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.List; -import com.google.gson.annotations.Expose; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleOperation; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.RandomStringFactory; - +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; import eu.mihosoft.vrl.v3d.CSG; -public class MakeRobot extends CaDoodleOperation{ - @Expose(serialize = true, deserialize = true) - protected String name = null; - - - public String getName() { - if (name == null) { - setName(RandomStringFactory.generateRandomString()); - } - return name; - } +public class MakeRobot extends AbstractAddFrom{ - public void setName(String name) { - this.name = name; - } @Override public String getType() { return "MakeRobot"; @@ -35,8 +21,14 @@ public List process(List incoming) { } @Override - public List getNames() { + public List getNamesAddedInThisOperation() { return new ArrayList(); } + @Override + public File getFile() throws NoSuchFileException { + // TODO Auto-generated method stub + return null; + } + } From a010e6846f3f18bafe3c6ffea1676aaeab1b9dba Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 11:38:01 -0400 Subject: [PATCH 463/635] adding a check for file in the URL string --- .../scripting/ScriptingEngine.java | 70 +++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index c0a421df..b9bdd65b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -737,6 +737,9 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr } public static void waitForRepo(String remoteURI, String reason) { + if (isNotURL(remoteURI)) { + return; + } try { File f = getRepository(remoteURI).getDirectory(); while (ScriptingEngine.isUrlAlreadyOpen(f)) { @@ -904,6 +907,27 @@ private static boolean ensureExistance(File desired) throws IOException { public static void commit(String id, String branch, String FileName, String content, String commitMessage, boolean flagNewFile) throws Exception { + if (isNotURL(id)) { + try { + File f = new File(id); + if (f.exists() && f.isDirectory()) { + System.out.println("remoteURI is actually a directory " + f); + OutputStream out = null; + try { + out = FileUtils.openOutputStream(new File(f + "/" + FileName), false); + IOUtils.write(content, out, Charset.defaultCharset()); + out.close(); // don't swallow close Exception if copy + // completes + // normally + } finally { + IOUtils.closeQuietly(out); + } + return; + } + } catch (Exception ex) { + // not a file i guess... + } + } openGit(id, git -> { commit(id, branch, FileName, content, commitMessage, flagNewFile, git); }); @@ -980,11 +1004,34 @@ private static void commit(String id, String branch, String FileName, String con @SuppressWarnings("deprecation") public static void pushCodeToGit(String remoteURI, String branch, String FileName, String content, String commitMessage, boolean flagNewFile) throws Exception { + if (isNotURL(remoteURI)) { + try { + File f = new File(remoteURI); + if (f.exists() && f.isDirectory()) { + System.out.println("remoteURI is actually a directory " + f); + OutputStream out = null; + try { + out = FileUtils.openOutputStream(new File(f + "/" + FileName), false); + IOUtils.write(content, out, Charset.defaultCharset()); + out.close(); // don't swallow close Exception if copy + // completes + // normally + } finally { + IOUtils.closeQuietly(out); + } + return; + } + } catch (Exception ex) { + // not a file i guess... + } + } + waitForRepo(remoteURI, "push"); if (content != null) if ("Binary File".contentEquals(content)) { content = null; } + commit(remoteURI, branch, FileName, content, commitMessage, flagNewFile); if (PasswordManager.getUsername() == null) login(); @@ -1112,9 +1159,9 @@ public static File fileFromGit(String remoteURI, String fileInRepo) // https://github.com/CommonWealthRobotics/BowlerStudioVitamins.git public static File fileFromGit(String remoteURI, String branch, String fileInRepo) throws InvalidRemoteException, TransportException, GitAPIException, IOException { - if(branch!=null) - if(branch.length()==0) - branch=null; + if (branch != null) + if (branch.length() == 0) + branch = null; File gitRepoFile = cloneRepo(remoteURI, branch); return new File(gitRepoFile.getAbsolutePath() + "/" + fileInRepo); } @@ -1684,7 +1731,18 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti * @return The local directory containing the .git */ public static File cloneRepo(String remoteURI, String branch) { - + if (isNotURL(remoteURI)) { + try { + File f = new File(remoteURI); + if (f.exists() && f.isDirectory()) { + System.out.println("remoteURI is actually a directory " + f); + return f; + } + } catch (Exception ex) { + // not a file i guess... + } + } + // Assume it is a URL File gistDir = getRepositoryCloneDirectory(remoteURI); String localPath = gistDir.getAbsolutePath(); File gitRepoFile = new File(localPath + "/.git"); @@ -1735,6 +1793,10 @@ public static File cloneRepo(String remoteURI, String branch) { } + private static boolean isNotURL(String remoteURI) { + return !remoteURI.startsWith("http") && !remoteURI.startsWith("git@"); + } + public static String locateGitUrl(File f) throws IOException { return locateGitUrl(f, null); } From 703305342de319172dad09fa1236818a0cb2dc6e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 11:38:16 -0400 Subject: [PATCH 464/635] doodle directory --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index db79a34f..cc5188e6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ physicsTest /test*.stl /test.blend1 /test.* -*.doodle +*doodle From c2b60119583460fcbe951ba27669f5c05ed39048 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 11:38:55 -0400 Subject: [PATCH 465/635] adding basic operataion of make robot --- .../scripting/cadoodle/robot/MakeRobot.java | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index 7258b656..a7dfbbf3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -5,10 +5,17 @@ import java.util.ArrayList; import java.util.List; +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.StringParameter; -public class MakeRobot extends AbstractAddFrom{ +public class MakeRobot extends AbstractAddFrom { + @Expose(serialize = true, deserialize = true) + private List assignedAsBase = new ArrayList(); + //@Expose(serialize = true, deserialize = true) + MobileBaseBuilder builder; @Override public String getType() { @@ -17,6 +24,19 @@ public String getType() { @Override public List process(List incoming) { + try { + getBuilder().build(); + for(CSG c:incoming) { + for(String s:assignedAsBase) { + if(c.getName().contentEquals(s)) { + c.setMobileBaseName(getName()); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return incoming; } @@ -27,8 +47,33 @@ public List getNamesAddedInThisOperation() { @Override public File getFile() throws NoSuchFileException { - // TODO Auto-generated method stub - return null; + try { + return getBuilder().getFile(); + } catch (Exception e) { + throw new NoSuchFileException(getName()); + } + } + + public List getAssignedAsBase() { + return assignedAsBase; + } + + public void setNames(List assignedAsBase) { + this.assignedAsBase = assignedAsBase; + } + + /** + * @return the builder + */ + public MobileBaseBuilder getBuilder() { + if (builder == null) { + StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); + String strValue = loc.getStrValue(); + File parentFile = new File(strValue).getParentFile(); + String source = parentFile.getAbsolutePath(); + builder = new MobileBaseBuilder(source, getName() + "-mobilbase.xml"); + } + return builder; } } From 89043fd4970487c028c5347fd2ca238343a9dfe9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 11:39:16 -0400 Subject: [PATCH 466/635] adding Make robot --- .../CaDoodleJsonOperationAdapterFactory.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index a5d7c724..6254db54 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -11,8 +11,8 @@ import java.util.Map; public class CaDoodleJsonOperationAdapterFactory implements TypeAdapterFactory { - private final Map> typeRegistry = new HashMap<>(); - private final Map, String> classRegistry = new HashMap<>(); + private final Map> typeRegistry = new HashMap<>(); + private final Map, String> classRegistry = new HashMap<>(); public CaDoodleJsonOperationAdapterFactory() { registerType("AddFromFile", AddFromFile.class); @@ -36,14 +36,14 @@ public CaDoodleJsonOperationAdapterFactory() { } - private void registerType(String typeName, Class clazz) { + private void registerType(String typeName, Class clazz) { typeRegistry.put(typeName, clazz); classRegistry.put(clazz, typeName); } @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ICaDoodleOpperation.class.isAssignableFrom(type.getRawType())) { + if (!CaDoodleOperation.class.isAssignableFrom(type.getRawType())) { return null; } @@ -71,11 +71,11 @@ public T read(JsonReader in) throws IOException { JsonElement typeElement = jsonObject.get("type"); JsonElement dataElement = jsonObject.get("data"); String typeName = typeElement.getAsString(); - Class clazz = typeRegistry.get(typeName); + Class clazz = typeRegistry.get(typeName); if (clazz == null) { throw new JsonParseException("Unknown type: " + typeName); } - TypeAdapter delegateAdapter = gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); + TypeAdapter delegateAdapter = gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); com.neuronrobotics.sdk.common.Log.error("JSON Parsing "+typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } From b2c852f9c70f6408f9099eca8e655ea0fde89050 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 11:39:30 -0400 Subject: [PATCH 467/635] rename interface --- java-bowler | 2 +- .../creature/ControllerInstance.java | 14 + .../creature/ControllerOption.java | 33 ++ .../creature/MobileBaseBuilder.java | 401 +++++++++++++++++- .../scripting/cadoodle/CaDoodleFile.java | 90 ++-- .../scripting/cadoodle/CaDoodleOperation.java | 26 +- .../cadoodle/ICaDoodleOpperation.java | 12 - .../cadoodle/ICaDoodleStateUpdate.java | 2 +- ...orkflow.java => CaDoodleWorkflowTest.java} | 16 +- 9 files changed, 526 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java rename test/java/src/junit/bowler/{TestCaDoodleWorkflow.java => CaDoodleWorkflowTest.java} (94%) diff --git a/java-bowler b/java-bowler index e09f747a..d9dbbcac 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit e09f747a9f805bdb9ba2e355a7cda5fb2ac5bc76 +Subproject commit d9dbbcac641b9afa7b883ceb357f2bc2cff5945a diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java new file mode 100644 index 00000000..cdf161a2 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java @@ -0,0 +1,14 @@ +package com.neuronrobotics.bowlerstudio.creature; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +public class ControllerInstance { + @Expose(serialize = true, deserialize = true) + ControllerOption type; + @Expose(serialize = true, deserialize = true) + String name; + @Expose(serialize = true, deserialize = true) + TransformNR pose; + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java new file mode 100644 index 00000000..1f6b7294 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -0,0 +1,33 @@ +package com.neuronrobotics.bowlerstudio.creature; + +import com.google.gson.annotations.Expose; + +public class ControllerOption { + @Expose(serialize = true, deserialize = true) + String type; + @Expose(serialize = true, deserialize = true) + String cadGit; + @Expose(serialize = true, deserialize = true) + String cadFile; + @Expose(serialize = true, deserialize = true) + String linkLoaderGit; + @Expose(serialize = true, deserialize = true) + String linkLoaderFile; + @Expose(serialize = true, deserialize = true) + int servoChannels; + @Expose(serialize = true, deserialize = true) + int motorChannels; + @Expose(serialize = true, deserialize = true) + int analogSensorChannels; + @Expose(serialize = true, deserialize = true) + int cameras; + @Expose(serialize = true, deserialize = true) + int digitalSensorChannels; + @Expose(serialize = true, deserialize = true) + int inertialSensors; + @Expose(serialize = true, deserialize = true) + int distanceSensors; + @Expose(serialize = true, deserialize = true) + int pointCloudSensors; + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 83023318..696afe5e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -1,36 +1,401 @@ package com.neuronrobotics.bowlerstudio.creature; +import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; +import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup; +import com.neuronrobotics.sdk.common.Log; -public class MobileBaseBuilder { +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +public class MobileBaseBuilder { + @Expose(serialize = true, deserialize = true) + ArrayList controllers = new ArrayList(); + + + private MobileBase mobileBase; private String gitURL; - private String name; - private String xmlName =null; + private String xmlName = null; + + // Channel management + private Map> deviceChannelMap = new HashMap<>(); + // Constructor for creating a new MobileBase public MobileBaseBuilder(String gitURL, String name) { this.gitURL = gitURL; - this.name = name; - + this.mobileBase = new MobileBase(); + this.mobileBase.setScriptingName(name); + initializeChannelMap(); + } + // Constructor for extending an existing MobileBase + public MobileBaseBuilder(MobileBase existingBase) { + this.gitURL = existingBase.getGitSelfSource()[0]; + this.mobileBase = existingBase; + initializeChannelMap(); + scanExistingChannels(); } - public MobileBase build() throws Exception { - MobileBase base = new MobileBase(); - base.setScriptingName(name); - String filename = name+".xml"; - if(xmlName!=null) { - filename=xmlName; - } - base.setGitSelfSource(new String[] {gitURL,filename}); - - - ScriptingEngine.pushCodeToGit(gitURL, null, filename, base.getXml(), "Builder Write XML ", true); - return base; + // Copy functionality from the menu factory + public MobileBaseBuilder copyFrom(MobileBase source, String newName) { + try { + mobileBase.setScriptingName(newName); + + // Copy engines + if (source.getGitCadEngine() != null) { + mobileBase.setGitCadEngine(copyGitFile(source.getGitCadEngine(), gitURL)); + } + if (source.getGitWalkingEngine() != null) { + mobileBase.setGitWalkingEngine( copyGitFile(source.getGitWalkingEngine(), gitURL)); + } + + // Copy appendages + for (DHParameterKinematics leg : source.getLegs()) { + DHParameterKinematics copiedLeg = copyDHParameterKinematics(leg); + mobileBase.getLegs().add(copiedLeg); + } + + for (DHParameterKinematics arm : source.getAppendages()) { + DHParameterKinematics copiedArm = copyDHParameterKinematics(arm); + mobileBase.getAppendages().add(copiedArm); + } + + for (DHParameterKinematics wheel : source.getSteerable()) { + DHParameterKinematics copiedWheel = copyDHParameterKinematics(wheel); + mobileBase.getSteerable().add(copiedWheel); + } + + for (DHParameterKinematics wheel : source.getDrivable()) { + DHParameterKinematics copiedWheel = copyDHParameterKinematics(wheel); + mobileBase.getDrivable() .add(copiedWheel); + } + + // Copy transforms + mobileBase.setFiducialToGlobalTransform(source.getRobotToFiducialTransform()); + mobileBase.setIMUFromCentroid(source.getIMUFromCentroid()); + } catch (Exception e) { + Log.error("Failed to copy from source MobileBase: " + e.getMessage()); + } + return this; + } + + + +// // Constructor for extending an existing MobileBase with new name +// public MobileBaseBuilder(String gitURL, MobileBase existingBase, String newName) { +// this.gitURL = gitURL; +// this.mobileBase = existingBase; +// this.mobileBase.setScriptingName(newName); +// initializeChannelMap(); +// scanExistingChannels(); +// } + + public MobileBase cloneMobileBase(MobileBase source) { + try { + // Create a deep copy by serializing and deserializing XML + String xml = source.getXml(); + MobileBase clone = new MobileBase(); + clone.setScriptingName(source.getScriptingName()); + + // Copy all appendages + for (DHParameterKinematics leg : source.getLegs()) { + clone.getLegs().add(copyDHParameterKinematics(leg)); + } + for (DHParameterKinematics arm : source.getAppendages()) { + clone.getAppendages().add(copyDHParameterKinematics(arm)); + } + for (DHParameterKinematics wheel : source.getSteerable()) { + clone.getSteerable().add(copyDHParameterKinematics(wheel)); + } + for (DHParameterKinematics wheel : source.getDrivable()) { + clone.getDrivable().add(copyDHParameterKinematics(wheel)); + } + + // Copy transforms + if (source.getRobotToFiducialTransform() != null) { + clone.setRobotToFiducialTransform(source.getRobotToFiducialTransform()); + } + if (source.getIMUFromCentroid() != null) { + clone.setIMUFromCentroid(source.getIMUFromCentroid()); + } + + // Copy engines + if (source.getGitCadEngine() != null) { + clone.setGitCadEngine(source.getGitCadEngine()); + } + if (source.getGitWalkingEngine() != null) { + clone.setGitWalkingEngine(source.getGitWalkingEngine()); + } + + return clone; + } catch (Exception e) { + Log.error("Failed to clone MobileBase: " + e.getMessage()); + return new MobileBase(); + } + } + + private void initializeChannelMap() { + // Initialize with empty channel maps - will be populated as needed + } + + private void scanExistingChannels() { + // Scan all existing appendages to build current channel usage map + scanAppendageChannels(mobileBase.getLegs()); + scanAppendageChannels(mobileBase.getAppendages()); + scanAppendageChannels(mobileBase.getSteerable()); + scanAppendageChannels(mobileBase.getDrivable()); + } + + private void scanAppendageChannels(List appendages) { + for (DHParameterKinematics appendage : appendages) { + for (LinkConfiguration conf : appendage.getLinkConfigurations()) { + String deviceName = conf.getDeviceScriptingName(); + int channel = conf.getHardwareIndex(); + if (deviceName != null) { + reserveDeviceChannel(deviceName, channel); + } + } + } + } + + // Getter for the current MobileBase instance + public MobileBase getMobileBase() { + return mobileBase; } public MobileBaseBuilder setXmlName(String xmlName) { this.xmlName = xmlName; return this; } -} + + public MobileBaseBuilder setGitCadEngine(String gitURL, String filename) { + mobileBase.setGitCadEngine(new String[] { gitURL, filename }); + return this; + } + + public MobileBaseBuilder setGitWalkingEngine(String gitURL, String filename) { + mobileBase.setGitWalkingEngine(new String[] { gitURL, filename }); + return this; + } + + public MobileBaseBuilder setRobotToFiducialTransform(TransformNR transform) { + mobileBase.setRobotToFiducialTransform(transform); + return this; + } + + public MobileBaseBuilder setIMUFromCentroid(TransformNR transform) { + mobileBase.setIMUFromCentroid(transform); + return this; + } + + public MobileBaseBuilder setBodyMass(double mass) { + // Note: MobileBase doesn't seem to have a setBodyMass method + // You may need to add this functionality to MobileBase or handle it differently + return this; + } + + // Leg management + public MobileBaseBuilder addLeg(DHParameterKinematics leg) { + if (leg != null) { + configureAppendage(leg); + mobileBase.getLegs().add(leg); + } + return this; + } + + public MobileBaseBuilder addDefaultLeg(String legName) { + try { + String xmlContent = ScriptingEngine.codeFromGit( + "https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", "defaultleg.xml")[0]; + DHParameterKinematics newLeg = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8")); + newLeg.setScriptingName(legName); + return addLeg(newLeg); + } catch (Exception e) { + Log.error("Failed to add default leg: " + e.getMessage()); + return this; + } + } + + // Arm management + public MobileBaseBuilder addArm(DHParameterKinematics arm) { + if (arm != null) { + configureAppendage(arm); + mobileBase.getAppendages().add(arm); + } + return this; + } + + public MobileBaseBuilder addDefaultArm(String armName) { + try { + String xmlContent = ScriptingEngine.codeFromGit( + "https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", "defaultarm.xml")[0]; + DHParameterKinematics newArm = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8")); + newArm.setScriptingName(armName); + return addArm(newArm); + } catch (Exception e) { + Log.error("Failed to add default arm: " + e.getMessage()); + return this; + } + } + + // Wheel management + public MobileBaseBuilder addSteerableWheel(DHParameterKinematics wheel) { + if (wheel != null) { + configureAppendage(wheel); + mobileBase.getSteerable().add(wheel); + } + return this; + } + + public MobileBaseBuilder addDefaultSteerableWheel(String wheelName) { + try { + String xmlContent = ScriptingEngine.codeFromGit( + "https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", "defaultSteerable.xml")[0]; + DHParameterKinematics newWheel = new DHParameterKinematics(null, + IOUtils.toInputStream(xmlContent, "UTF-8")); + newWheel.setScriptingName(wheelName); + return addSteerableWheel(newWheel); + } catch (Exception e) { + Log.error("Failed to add default steerable wheel: " + e.getMessage()); + return this; + } + } + + public MobileBaseBuilder addFixedWheel(DHParameterKinematics wheel) { + if (wheel != null) { + configureAppendage(wheel); + mobileBase.getDrivable().add(wheel); + } + return this; + } + + public MobileBaseBuilder addFixedWheelFromOptions(String wheelType) { + try { + @SuppressWarnings("unchecked") + HashMap> options = (HashMap>) ScriptingEngine + .gitScriptRun("https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", + "wheelOptions.json"); + + if (options.containsKey(wheelType)) { + HashMap values = options.get(wheelType); + + if (wheelType.toLowerCase().contains("fixed")) { + String xmlContent = ScriptingEngine.codeFromGit(values.get("scriptGit").toString(), + values.get("scriptFile").toString())[0]; + DHParameterKinematics newWheel = new DHParameterKinematics(null, + IOUtils.toInputStream(xmlContent, "UTF-8")); + return addFixedWheel(newWheel); + } else { + MobileBase base = (MobileBase) ScriptingEngine.gitScriptRun(values.get("scriptGit").toString(), + values.get("scriptFile").toString()); + DHParameterKinematics newWheel = base.getDrivable().get(0); + return addFixedWheel(newWheel); + } + } + } catch (Exception e) { + Log.error("Failed to add wheel from options: " + e.getMessage()); + } + return this; + } + + // Parallel group management + public MobileBaseBuilder addParallelGroup(ParallelGroup group) { + if (group != null) { + // Note: Need to add parallel group support to MobileBase if not already present + // mobileBase.getParallelGroups().add(group); + } + return this; + } + + // Channel management methods + public MobileBaseBuilder reserveDeviceChannel(String deviceName, int channel) { + deviceChannelMap.computeIfAbsent(deviceName, k -> new HashMap<>()).put(channel, true); + return this; + } + + private void configureAppendage(DHParameterKinematics appendage) { + // Set CAD engine if available + String[] cadEngine = mobileBase.getGitCadEngine(); + if (cadEngine != null) { + appendage.setGitCadEngine(cadEngine); + } + + // Configure channels for all links + for (LinkConfiguration conf : appendage.getLinkConfigurations()) { + assignNextAvailableChannel(conf); + } + } + + private void assignNextAvailableChannel(LinkConfiguration conf) { + // Try to find an available channel + for (Map.Entry> deviceEntry : deviceChannelMap.entrySet()) { + String deviceName = deviceEntry.getKey(); + Map channels = deviceEntry.getValue(); + + for (int i = 0; i < 48; i++) { + if (!channels.containsKey(i)) { + conf.setDeviceScriptingName(deviceName); + conf.setHardwareIndex(i); + channels.put(i, true); + return; + } + } + } + + // If no channels available, create a new device + String newDeviceName = conf.getDeviceScriptingName() + "_new"; + conf.setDeviceScriptingName(newDeviceName); + conf.setHardwareIndex(0); + reserveDeviceChannel(newDeviceName, 0); + } + + private DHParameterKinematics copyDHParameterKinematics(DHParameterKinematics source) throws Exception { + // Create a copy by serializing and deserializing XML + String xml = source.getXml(); + DHParameterKinematics copy = new DHParameterKinematics(null, IOUtils.toInputStream(xml, "UTF-8")); + + // Copy git engines + if (source.getGitCadEngine() != null) { + copy.setGitCadEngine(copyGitFile(source.getGitCadEngine(), gitURL)); + } + if (source.getGitDhEngine() != null) { + copy.setGitDhEngine(copyGitFile(source.getGitDhEngine(), gitURL)); + } + + return copy; + } + + private String[] copyGitFile(String[] sourceGit, String targetGit) { + return ScriptingEngine.copyGitFile(sourceGit[0], targetGit, sourceGit[1]); + } + + public File getFile() throws Exception { + return ScriptingEngine.fileFromGit(gitURL, mobileBase.getScriptingName() + ".xml"); + } + + public MobileBase build() throws Exception { + String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName() + ".xml"; + mobileBase.setGitSelfSource(new String[] { gitURL, filename }); + + // Push to git + ScriptingEngine.pushCodeToGit(gitURL, null, filename, mobileBase.getXml(), "Builder Write XML", true); + + return mobileBase; + } + +} \ No newline at end of file diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 78ebe8b2..c264a96c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -29,10 +29,12 @@ import com.google.gson.annotations.Expose; import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.BowlerKernel; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; import com.neuronrobotics.bowlerstudio.creature.ThumbnailImage; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; @@ -68,7 +70,7 @@ public class CaDoodleFile { // Non Serialised private variables private TransformNR workplane = new TransformNR(); - private File selfInternal; + private File self; // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); private double percentInitialized = 0; @@ -97,13 +99,14 @@ public void renderSplashFrame(int percent, String message) { }; private ICadoodleSaveStatusUpdate saveUpdate = null; private boolean timelineOpen = false; + private HashMap robots = new HashMap(); public void close() { //new Exception("CaDoodle File Closed here").printStackTrace(); for(CaDoodleOperation op:getOpperations()) { op.setCaDoodleFile(null); } - for (ICaDoodleOpperation op : cache.keySet()) { + for (CaDoodleOperation op : cache.keySet()) { cache.get(op).clear(); } cache.clear(); @@ -137,16 +140,18 @@ public void initialize() { // throw new RuntimeException("Can not initialize while initializing."); fireInitializationStart(); initializing = true; - if (selfInternal != null) { - File parent = selfInternal.getAbsoluteFile().getParentFile(); + if(timeCreated<0) + timeCreated=System.currentTimeMillis(); + if (self != null) { + File parent = self.getAbsoluteFile().getParentFile(); File imageCacheDir = new File(parent.getAbsolutePath() + delim() + "timeline"); if (!imageCacheDir.exists()) imageCacheDir.mkdir(); - File db = new File(selfInternal.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); + File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setInstance(new CSGDatabaseInstance(db)); - StringParameter loc = new StringParameter("CaDoodle_File_Location", selfInternal.getAbsolutePath(), + StringParameter loc = new StringParameter("CaDoodle_File_Location", self.getAbsolutePath(), new ArrayList()); - loc.setStrValue(selfInternal.getAbsolutePath()); + loc.setStrValue(self.getAbsolutePath()); bom = CaDoodleFile.getBillOfMaterials(); bom.clear(); bom.save(); @@ -234,7 +239,7 @@ private static String getCadoodleFileLocation() { return strValue; } - public Thread regenerateFrom(ICaDoodleOpperation source) { + public Thread regenerateFrom(CaDoodleOperation source) { if (initializing) return null; if (isRegenerating() || isOperationRunning() || source == null) { @@ -261,7 +266,7 @@ public void run() { // "+source.getType()); int opIndex = 0; for (int i = 0; i < size; i++) { - ICaDoodleOpperation op = getOpperations().get(i); + CaDoodleOperation op = getOpperations().get(i); if (source == op) { opIndex = i; break; @@ -361,7 +366,12 @@ public void run() { private void process(CaDoodleOperation op) { op.setCaDoodleFile(this); + op.setRobots(getRobots()); List process = op.process(getCurrentState()); + if(MakeRobot.class.isInstance(op)) { + MakeRobot mr = (MakeRobot)op; + getRobots().put(mr.getName(), mr.getBuilder()); + } int currentIndex2 = getCurrentIndex(); storeResultInCache(op, process); setCurrentIndex(currentIndex2 + 1); @@ -446,7 +456,7 @@ public void run() { return t; } - public Thread deleteOperation(ICaDoodleOpperation op) { + public Thread deleteOperation(CaDoodleOperation op) { if (op == null) throw new NullPointerException(); if (isOperationRunning()) { @@ -467,7 +477,7 @@ public void run() { // index -= 1; if (index < 1) index = 1; - ICaDoodleOpperation newTar = getOpperations().get(index - 1); + CaDoodleOperation newTar = getOpperations().get(index - 1); setCurrentIndex(index); try { regenerateFrom(newTar).join(); @@ -548,9 +558,9 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam return back.size(); } - public File getTimelineImageFile(ICaDoodleOpperation test) { + public File getTimelineImageFile(CaDoodleOperation test) { for (int i = 0; i < getOpperations().size(); i++) { - ICaDoodleOpperation key = getOpperations().get(i); + CaDoodleOperation key = getOpperations().get(i); if (key == test) { File file = getTimelineImageFile(i); return file; @@ -560,12 +570,12 @@ public File getTimelineImageFile(ICaDoodleOpperation test) { } public File getTimelineImageFile(int i) { - File parent = selfInternal.getAbsoluteFile().getParentFile(); + File parent = getSelf().getAbsoluteFile().getParentFile(); File file = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + (i + 1) + ".png"); return file; } - private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { + private OperationResult pruneForward(CaDoodleOperation op) throws Exception { if (op == null) throw new NullPointerException(); OperationResult res = OperationResult.INSERT; @@ -577,7 +587,7 @@ private OperationResult pruneForward(ICaDoodleOpperation op) throws Exception { } if (getCurrentIndex() > 0) for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { - ICaDoodleOpperation key = getOpperations().get(i); + CaDoodleOperation key = getOpperations().get(i); if (i >= getCurrentIndex()) { List back = cache.remove(key); if (back != null) @@ -682,7 +692,7 @@ public boolean isBackAvailible() { } private void updateCurrentFromCache() { - ICaDoodleOpperation key = getCurrentOpperation(); + CaDoodleOperation key = getCurrentOpperation(); if (key == null) return; com.neuronrobotics.sdk.common.Log.error("Current opperation results: " + key.getType()); @@ -707,19 +717,19 @@ public boolean isForwardAvailible() { } public File getSelf() { - if (selfInternal == null) { + if (self == null) { try { - selfInternal = File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); + self = File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); } } - return selfInternal; + return self; } public CaDoodleFile setSelf(File self) { - this.selfInternal = self; + this.self = self; return this; } @@ -727,7 +737,7 @@ public List getCurrentState() { return getStateAtOperation(getCurrentOpperation()); } - public List getStateAtOperation(ICaDoodleOpperation op) { + public List getStateAtOperation(CaDoodleOperation op) { if (getCurrentIndex() == 0) return new ArrayList(); List list = cache.get(op); @@ -753,12 +763,12 @@ public List getSelect(List selectedSnapshot) { public List getPreviouState() { if (getCurrentIndex() < 2) return new ArrayList(); - ICaDoodleOpperation key = getOpperations().get(getCurrentIndex() - 2); + CaDoodleOperation key = getOpperations().get(getCurrentIndex() - 2); return cache.get(key); } - private void setCurrentState(ICaDoodleOpperation op, List currentState) { + private void setCurrentState(CaDoodleOperation op, List currentState) { for (ICaDoodleStateUpdate l : listeners) { try { l.onUpdate(currentState, op, this); @@ -842,6 +852,8 @@ public String toJson() { } public File save() throws IOException { + if(timeCreated<0) + timeCreated=System.currentTimeMillis(); String contents = toJson(); List currentState = getCurrentState(); CSG thumb = null; @@ -859,7 +871,7 @@ public File save() throws IOException { String string = getSTLThumbnailLocation(); int currentIndex2 = getCurrentIndex(); if (isTimelineOpen()) - getSaveUpdate().renderSplashFrame(1, "Save Doodle to " + selfInternal.getName()); + getSaveUpdate().renderSplashFrame(1, "Save Doodle to " + getSelf().getName()); if (thumb != null) { boolean manif = CSG.isPreventNonManifoldTriangles(); if (manif) @@ -868,12 +880,12 @@ public File save() throws IOException { if (manif) CSG.setPreventNonManifoldTriangles(true); } - FileUtils.write(selfInternal, contents, StandardCharsets.UTF_8, false); + FileUtils.write( getSelf(), contents, StandardCharsets.UTF_8, false); // } int num = 0; for (int i = 0; i < opperations.size(); i++) { File f = getTimelineImageFile(i); - ICaDoodleOpperation op = opperations.get(i); + CaDoodleOperation op = opperations.get(i); int percent = (int) (((double) i) / ((double) opperations.size()) * 100.0); List process = cache.get(op); if (!f.exists() && process!=null) @@ -904,13 +916,13 @@ public File getSTLThumbnailFile() { } public String getSTLThumbnailLocation() { - File folder = selfInternal.getParentFile(); + File folder = getSelf().getAbsoluteFile().getParentFile(); String string = folder.getAbsolutePath() + delim() + "thumbnail.stl"; return string; } - private void setSaveImage(List currentState, ICaDoodleOpperation op) throws IOException { - if (selfInternal == null) + private void setSaveImage(List currentState, CaDoodleOperation op) throws IOException { + if ( getSelf() == null) return; int currentIndex2 = 0; for (int i = 0; i < getOpperations().size(); i++) @@ -918,7 +930,7 @@ private void setSaveImage(List currentState, ICaDoodleOpperation op) throws currentIndex2 = i; // if(currentIndex2==0) // return; - File parent = selfInternal.getAbsoluteFile().getParentFile(); + File parent = getSelf().getAbsoluteFile().getParentFile(); File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); @@ -962,7 +974,7 @@ private void fireTimelineUpdate(int number) { public WritableImage loadImageFromFile() { try { - File parent = selfInternal.getAbsoluteFile().getParentFile(); + File parent = getSelf().getAbsoluteFile().getParentFile(); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); if (image.exists()) { BufferedImage bufferedImage = ImageIO.read(image); @@ -1167,4 +1179,18 @@ public boolean isTimelineOpen() { public void setTimeCreated(long timeCreated) { this.timeCreated = timeCreated; } + + /** + * @return the robots + */ + public HashMap getRobots() { + return robots; + } + + /** + * @param robots the robots to set + */ + public void setRobots(HashMap robots) { + this.robots = robots; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index eea25037..a3b00968 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -1,8 +1,18 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; -public abstract class CaDoodleOperation implements ICaDoodleOpperation{ - private CaDoodleFile cf = null; +import java.util.HashMap; +import java.util.List; + +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; + +import eu.mihosoft.vrl.v3d.CSG; +public abstract class CaDoodleOperation { + private HashMap robots; + private CaDoodleFile cf = null; + public abstract String getType(); + public abstract List process(List incoming); + public abstract List getNamesAddedInThisOperation(); public CaDoodleFile getCaDoodleFile() { return cf; } @@ -10,5 +20,17 @@ public CaDoodleFile getCaDoodleFile() { public void setCaDoodleFile(CaDoodleFile cf) { this.cf = cf; } + /** + * @return the robots + */ + public HashMap getRobots() { + return robots; + } + /** + * @param robots the robots to set + */ + public void setRobots(HashMap robots) { + this.robots = robots; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java deleted file mode 100644 index 572d5701..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleOpperation.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.neuronrobotics.bowlerstudio.scripting.cadoodle; - -import java.util.List; - -import eu.mihosoft.vrl.v3d.CSG; - -public interface ICaDoodleOpperation { - - public String getType(); - public List process(List incoming); - public List getNamesAddedInThisOperation(); -} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index d4706c09..dad1aebb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -7,7 +7,7 @@ import eu.mihosoft.vrl.v3d.CSG; public interface ICaDoodleStateUpdate { - public void onUpdate(List currentState, ICaDoodleOpperation source,CaDoodleFile file ); + public void onUpdate(List currentState, CaDoodleOperation source,CaDoodleFile file ); public void onSaveSuggestion(); public void onInitializationDone(); public void onInitializationStart(); diff --git a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java similarity index 94% rename from test/java/src/junit/bowler/TestCaDoodleWorkflow.java rename to test/java/src/junit/bowler/CaDoodleWorkflowTest.java index 780a0ebd..2a3d5dfe 100644 --- a/test/java/src/junit/bowler/TestCaDoodleWorkflow.java +++ b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java @@ -26,18 +26,21 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToSolid; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.UnGroup; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.JavaFXInitializer; import javafx.scene.paint.Color; -public class TestCaDoodleWorkflow { +public class CaDoodleWorkflowTest { @Test public void test() throws Exception { + JavaFXInitializer.go(); CaDoodleFile cf = new CaDoodleFile() - .setSelf(new File("Test.doodle")) + .setSelf(new File("doodle/Test.doodle")) .setProjectName("A Test Project"); String jsonContent = cf.toJson(); @@ -224,8 +227,13 @@ public void test() throws Exception { com.neuronrobotics.sdk.common.Log.error(after); - - + MakeRobot mr = new MakeRobot(); + mr.setNames(selectAll); + while(loaded.isForwardAvailible()) + loaded.forward(); + loaded.addOpperation(mr).join(); + loaded.save(); + } From e68c03abc6ea152c7799ca482187f03c3a268942 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 4 Aug 2025 15:11:07 -0400 Subject: [PATCH 468/635] pass the mobile base name to children --- .../bowlerstudio/scripting/cadoodle/Group.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 2c994d17..0660809f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Optional; import com.google.gson.annotations.Expose; @@ -34,11 +35,20 @@ public List process(List incoming) { ArrayList back = new ArrayList(); ArrayList replace = new ArrayList(); back.addAll(incoming); + String mobileBase=null; for (CSG csg : incoming) { if (csg.isLock()) continue; for (String name : names) { if (name.contentEquals(csg.getName())) { + Optional mobileBaseName = csg.getMobileBaseName(); + if(mobileBaseName.isPresent()) { + if(mobileBase==null) + mobileBase= mobileBaseName.get(); + if(!mobileBase.contentEquals(mobileBaseName.get())) { + continue;// skip grouping any item that is of a different mobile base; + } + } replace.add(csg); CSG c = csg.clone().syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); if (csg.isHole()) { @@ -87,6 +97,8 @@ public List process(List incoming) { result.setIsHole(false); result.setColor(c); } + if(mobileBase!=null) + result.setMobileBaseName(mobileBase); HashMap mapOfparametrics = result.getMapOfparametrics(); if (mapOfparametrics != null) mapOfparametrics.clear(); From 85542a6210e187f859a73b6c5474825fc773b10e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 5 Aug 2025 14:05:09 -0400 Subject: [PATCH 469/635] Adding controller features and the option class --- .../creature/ControllerFeatures.java | 73 ++++++++++ .../creature/ControllerOption.java | 132 ++++++++++++++++-- .../scripting/cadoodle/CaDoodleVitamin.java | 10 +- .../bowlerstudio/vitamins/Vitamins.java | 42 +++--- .../junit/bowler/CaDoodleWorkflowTest.java | 8 +- 5 files changed, 226 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java new file mode 100644 index 00000000..34f947af --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -0,0 +1,73 @@ +package com.neuronrobotics.bowlerstudio.creature; + +import java.util.List; + +import com.google.gson.annotations.Expose; + +public class ControllerFeatures { + @Expose(serialize = true, deserialize = true) + int servoChannels = 0; + @Expose(serialize = true, deserialize = true) + int motorChannels = 0; + @Expose(serialize = true, deserialize = true) + int analogSensorChannels = 0; + @Expose(serialize = true, deserialize = true) + int cameras = 0; + @Expose(serialize = true, deserialize = true) + int digitalSensorChannels = 0; + @Expose(serialize = true, deserialize = true) + int inertialSensors = 0; + @Expose(serialize = true, deserialize = true) + int distanceSensors = 0; + @Expose(serialize = true, deserialize = true) + int pointCloudSensors = 0; + @Expose(serialize = true, deserialize = true) + List voltages ; + @Expose(serialize = true, deserialize = true) + double batteryWattHour = 0; + @Expose(serialize = true, deserialize = true) + double batteryPeakWatt = 0; + + public int getServoChannels() { + return servoChannels; + } + + public int getMotorChannels() { + return motorChannels; + } + + public int getAnalogSensorChannels() { + return analogSensorChannels; + } + + public int getCameras() { + return cameras; + } + + public int getDigitalSensorChannels() { + return digitalSensorChannels; + } + + public int getInertialSensors() { + return inertialSensors; + } + + public int getDistanceSensors() { + return distanceSensors; + } + + public int getPointCloudSensors() { + return pointCloudSensors; + } + + public List getBatteryVoltage() { + return voltages; + } + + public double getBatteryPeakWatts() { + return batteryPeakWatt; + } + public double getBatteryWattHours() { + return batteryWattHour; + } +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 1f6b7294..55e95402 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -1,33 +1,139 @@ package com.neuronrobotics.bowlerstudio.creature; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; +import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; public class ControllerOption { + public static final String URL_OF_OPTIONS = "https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git"; @Expose(serialize = true, deserialize = true) String type; @Expose(serialize = true, deserialize = true) - String cadGit; + String imageGit; @Expose(serialize = true, deserialize = true) - String cadFile; + String imageFile; @Expose(serialize = true, deserialize = true) - String linkLoaderGit; + List vitaminType; @Expose(serialize = true, deserialize = true) - String linkLoaderFile; + List vitaminSize; @Expose(serialize = true, deserialize = true) - int servoChannels; + String linkLoaderGit; @Expose(serialize = true, deserialize = true) - int motorChannels; + String linkLoaderFile; @Expose(serialize = true, deserialize = true) - int analogSensorChannels; + String linkDeviceName; @Expose(serialize = true, deserialize = true) - int cameras; + String linkDeviceType; @Expose(serialize = true, deserialize = true) - int digitalSensorChannels; + String firmwareGit; @Expose(serialize = true, deserialize = true) - int inertialSensors; + String firmwareFile; @Expose(serialize = true, deserialize = true) - int distanceSensors; + ControllerFeatures provides; @Expose(serialize = true, deserialize = true) - int pointCloudSensors; - + ControllerFeatures consumes; + + public File getImage() throws FileNotFoundException { + try { + return ScriptingEngine.fileFromGit(imageGit, imageFile); + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TransportException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + throw new FileNotFoundException(); + } + + public void runLinkLoader() throws FileNotFoundException { + if (linkLoaderGit == null || linkLoaderFile == null) { + System.out.println("Using built in link loaders"); + return; + } + try { + ScriptingEngine.inlineGistScriptRun(linkLoaderGit, linkLoaderFile, null); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + throw new FileNotFoundException(linkLoaderGit + "/" + linkLoaderFile); + } + + public File getFirmware() throws FileNotFoundException { + try { + return ScriptingEngine.fileFromGit(firmwareGit, firmwareFile); + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TransportException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + throw new FileNotFoundException(); + } + + public String getType() { + return type; + } + + public static ArrayList getOptions() + throws InvalidRemoteException, TransportException, GitAPIException, IOException { + try { + Type TT_CaDoodleFile = new TypeToken>() { + }.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() + .excludeFieldsWithoutExposeAnnotation().create(); + + File f = ScriptingEngine.fileFromGit(URL_OF_OPTIONS, "controllerOptions.json"); + String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); + return gson.fromJson(content, TT_CaDoodleFile); + } catch (Exception ex) { + ex.printStackTrace(); + return new ArrayList(); + } + } + + public String getLinkDeviceName() { + return linkDeviceName; + } + + public List getVitaminType() { + return vitaminType; + } + + public List getVitaminSize() { + return vitaminSize; + } + + public String getLinkDeviceType() { + return linkDeviceType; + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 6fca1af8..4f04dd60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -20,11 +20,15 @@ public static CSG get(String typencoming, ArrayList args) { String name = args.get(0).toString(); ArrayListtypes=new ArrayList<>(); types.addAll(Vitamins.listVitaminTypes()); - StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming, - types); + StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming,types); String type=typeParam.getStrValue(); ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); - return get( type, listVitaminSizes.get(0), args); + try { + return get( type, listVitaminSizes.get(0), args); + }catch(Exception ex) { + ex.printStackTrace(); + throw ex; + } } public static boolean isVitamin(CSG c) { for(String s:c.getParameters()) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index cbb92aef..681690b8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -296,7 +296,7 @@ public static ConcurrentHashMap getConfiguration(String type, St } return ConcurrentHashMap; }catch(Exception ex) { - ex.printStackTrace(); + //ex.printStackTrace(); } return new ConcurrentHashMap(); } @@ -657,26 +657,26 @@ public static ArrayList listVitaminSizes(String type) { public static String getGitRepoDatabase() { if (!checked) { checked = true; - try { - if (PasswordManager.getUsername() != null) { - // ScriptingEngine.setAutoupdate(true); - org.kohsuke.github.GitHub github = PasswordManager.getGithub(); - try { - GHRepository repo = github.getRepository(PasswordManager.getLoginID() + "/Hardware-Dimensions"); - if (repo != null) { - String myAssets = repo.getGitTransportUrl().replaceAll("git://", "https://"); - // com.neuronrobotics.sdk.common.Log.error("Using my version of Viamins: "+myAssets); - setGitRepoDatabase(myAssets); - } else { - throw new org.kohsuke.github.GHFileNotFoundException(); - } - } catch (Exception ex) { - setGitRepoDatabase(defaultGit); - } - } - } catch (Exception ex) { - new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); - } +// try { +// if (PasswordManager.getUsername() != null) { +// // ScriptingEngine.setAutoupdate(true); +// org.kohsuke.github.GitHub github = PasswordManager.getGithub(); +// try { +// GHRepository repo = github.getRepository(PasswordManager.getLoginID() + "/Hardware-Dimensions"); +// if (repo != null) { +// String myAssets = repo.getGitTransportUrl().replaceAll("git://", "https://"); +// // com.neuronrobotics.sdk.common.Log.error("Using my version of Viamins: "+myAssets); +// setGitRepoDatabase(myAssets); +// } else { +// throw new org.kohsuke.github.GHFileNotFoundException(); +// } +// } catch (Exception ex) { +// setGitRepoDatabase(defaultGit); +// } +// } +// } catch (Exception ex) { +// new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), ex); +// } ScriptingEngine.cloneRepo(gitRpoDatabase, "master"); try { ScriptingEngine.pull(gitRpoDatabase); diff --git a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java index 2a3d5dfe..5e6ab744 100644 --- a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java +++ b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java @@ -13,6 +13,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.creature.ControllerOption; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import java.lang.reflect.Type; @@ -233,8 +234,11 @@ public void test() throws Exception { loaded.forward(); loaded.addOpperation(mr).join(); loaded.save(); - - + ScriptingEngine.pull(ControllerOption.URL_OF_OPTIONS); + ArrayList controllers = ControllerOption.getOptions(); + for(ControllerOption o:controllers) { + System.out.println(o); + } } } From dabba9dd1788bc39d265bb83cd9542e5e1510943 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:51:35 -0400 Subject: [PATCH 470/635] remove the name setter to use the stable internal getter --- .../scripting/cadoodle/AbstractAddFrom.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index 1d7c04eb..eb271003 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -26,18 +26,18 @@ public List getNamesAddedInThisOperation(){ public String getName() { if (name == null) { - setName(RandomStringFactory.generateRandomString()); + name=(RandomStringFactory.generateRandomString()); } return name; } - public void setName(String name) { - this.name = name; - } +// public void setName(String name) { +// this.name = name; +// } public String getOrderedName() { if(getName()==null) { - setName(RandomStringFactory.generateRandomString()); + name=(RandomStringFactory.generateRandomString()); } String result= getName(); if(nameIndex!=0){ From d40bfb95f8ae3b0076af3691b46cc857f558de16 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:52:08 -0400 Subject: [PATCH 471/635] add a pruned operation cleanup method that can remove object connecctions made during process --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index c264a96c..9709a217 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -473,6 +473,7 @@ public void run() { if (getOpperations().get(i) == op) index = i; getOpperations().remove(op); + op.pruneCleanup(); // if (index == getOpperations().size()) // index -= 1; if (index < 1) @@ -600,6 +601,9 @@ private OperationResult pruneForward(CaDoodleOperation op) throws Exception { if (res == OperationResult.PRUNE) { List subList = (List) getOpperations().subList(0, getCurrentIndex()); + for(int i=getCurrentIndex();i newList = new ArrayList(); newList.addAll(subList); setOpperations(newList); From 2318b13c999acc2f7b003a65675706ef1e7449f6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:52:34 -0400 Subject: [PATCH 472/635] add the opperations for adding a controller and adding a limb --- .../CaDoodleJsonOperationAdapterFactory.java | 133 +++++++++--------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 6254db54..2c6c5aed 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -4,83 +4,86 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.*; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class CaDoodleJsonOperationAdapterFactory implements TypeAdapterFactory { - private final Map> typeRegistry = new HashMap<>(); - private final Map, String> classRegistry = new HashMap<>(); + private final Map> typeRegistry = new HashMap<>(); + private final Map, String> classRegistry = new HashMap<>(); - public CaDoodleJsonOperationAdapterFactory() { - registerType("AddFromFile", AddFromFile.class); - registerType("AddFromScript", AddFromScript.class); - registerType("Allign", Allign.class); - registerType("Delete", Delete.class); - registerType("Group", Group.class); - registerType("Hide", Hide.class); - registerType("Lock", Lock.class); - registerType("MakeRobot", MakeRobot.class); - registerType("Mirror", Mirror.class); - registerType("MoveCenter", MoveCenter.class); - registerType("Paste", Paste.class); - registerType("Resize", Resize.class); - registerType("Show", Show.class); - registerType("ToHole", ToHole.class); - registerType("ToSolid", ToSolid.class); - registerType("UnGroup", UnGroup.class); - registerType("UnLock", UnLock.class); - registerType("Sweep", Sweep.class); - - } + public CaDoodleJsonOperationAdapterFactory() { + registerType("AddFromFile", AddFromFile.class); + registerType("AddFromScript", AddFromScript.class); + registerType("AddRobotController", AddRobotController.class); + registerType("AddRobotLimb", AddRobotLimb.class); + registerType("Allign", Allign.class); + registerType("Delete", Delete.class); + registerType("Group", Group.class); + registerType("Hide", Hide.class); + registerType("Lock", Lock.class); + registerType("MakeRobot", MakeRobot.class); + registerType("Mirror", Mirror.class); + registerType("MoveCenter", MoveCenter.class); + registerType("Paste", Paste.class); + registerType("Resize", Resize.class); + registerType("Show", Show.class); + registerType("ToHole", ToHole.class); + registerType("ToSolid", ToSolid.class); + registerType("UnGroup", UnGroup.class); + registerType("UnLock", UnLock.class); + registerType("Sweep", Sweep.class); - private void registerType(String typeName, Class clazz) { - typeRegistry.put(typeName, clazz); - classRegistry.put(clazz, typeName); - } + } - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CaDoodleOperation.class.isAssignableFrom(type.getRawType())) { - return null; - } + private void registerType(String typeName, Class clazz) { + typeRegistry.put(typeName, clazz); + classRegistry.put(clazz, typeName); + } - final TypeAdapter jsonElementAdapter = gson.getAdapter(JsonElement.class); + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CaDoodleOperation.class.isAssignableFrom(type.getRawType())) { + return null; + } - return new TypeAdapter() { - @Override - public void write(JsonWriter out, T value) throws IOException { - JsonObject jsonObject = new JsonObject(); - String typeName = classRegistry.get(value.getClass()); - if (typeName == null) { - throw new JsonParseException("Unknown class: " + value.getClass()); - } - jsonObject.addProperty("type", typeName); - @SuppressWarnings("unchecked") - TypeAdapter delegateAdapter = (TypeAdapter) gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get((Class) value.getClass())); - JsonElement dataElement = delegateAdapter.toJsonTree(value); - jsonObject.add("data", dataElement); - jsonElementAdapter.write(out, jsonObject); - } + final TypeAdapter jsonElementAdapter = gson.getAdapter(JsonElement.class); - @Override - public T read(JsonReader in) throws IOException { - JsonObject jsonObject = jsonElementAdapter.read(in).getAsJsonObject(); - JsonElement typeElement = jsonObject.get("type"); - JsonElement dataElement = jsonObject.get("data"); - String typeName = typeElement.getAsString(); - Class clazz = typeRegistry.get(typeName); - if (clazz == null) { - throw new JsonParseException("Unknown type: " + typeName); - } - TypeAdapter delegateAdapter = gson.getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); - com.neuronrobotics.sdk.common.Log.error("JSON Parsing "+typeName); - return (T) delegateAdapter.fromJsonTree(dataElement); - } - }.nullSafe(); - } + return new TypeAdapter() { + @Override + public void write(JsonWriter out, T value) throws IOException { + JsonObject jsonObject = new JsonObject(); + String typeName = classRegistry.get(value.getClass()); + if (typeName == null) { + throw new JsonParseException("Unknown class: " + value.getClass()); + } + jsonObject.addProperty("type", typeName); + @SuppressWarnings("unchecked") + TypeAdapter delegateAdapter = (TypeAdapter) gson.getDelegateAdapter( + CaDoodleJsonOperationAdapterFactory.this, TypeToken.get((Class) value.getClass())); + JsonElement dataElement = delegateAdapter.toJsonTree(value); + jsonObject.add("data", dataElement); + jsonElementAdapter.write(out, jsonObject); + } + @Override + public T read(JsonReader in) throws IOException { + JsonObject jsonObject = jsonElementAdapter.read(in).getAsJsonObject(); + JsonElement typeElement = jsonObject.get("type"); + JsonElement dataElement = jsonObject.get("data"); + String typeName = typeElement.getAsString(); + Class clazz = typeRegistry.get(typeName); + if (clazz == null) { + throw new JsonParseException("Unknown type: " + typeName); + } + TypeAdapter delegateAdapter = gson + .getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); + com.neuronrobotics.sdk.common.Log.error("JSON Parsing " + typeName); + return (T) delegateAdapter.fromJsonTree(dataElement); + } + }.nullSafe(); + } } From 7cbb4569d420730081ec3b84937c36bca7af1a2e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:53:07 -0400 Subject: [PATCH 473/635] add getters for the builder and for the default prune cleanup --- .../scripting/cadoodle/CaDoodleOperation.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index a3b00968..e715d592 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.List; +import java.util.Optional; import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; @@ -13,6 +14,10 @@ public abstract class CaDoodleOperation { public abstract String getType(); public abstract List process(List incoming); public abstract List getNamesAddedInThisOperation(); + public void pruneCleanup() { + + } + public CaDoodleFile getCaDoodleFile() { return cf; } @@ -26,6 +31,26 @@ public void setCaDoodleFile(CaDoodleFile cf) { public HashMap getRobots() { return robots; } + + public String getBuilder(List selected, List state) { + if(selected==null) + return null; + for(CSG c: state) { + for(String s:selected) { + if(s.contentEquals(c.getName())) { + Optional mobileBaseName= c.getMobileBaseName(); + if(mobileBaseName.isPresent()) { + MobileBaseBuilder b = robots.get(mobileBaseName.get()); + if(b!=null) { + return mobileBaseName.get(); + } + } + } + } + } + return null; + } + /** * @param robots the robots to set */ From b844279be0fbb9070d5230d5e7c2999377968d04 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:53:24 -0400 Subject: [PATCH 474/635] check for always show --- .../neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index 9fbcd782..08604325 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -40,7 +40,7 @@ public static Object process(CaDoodleFile loaded) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c: incoming) { - if(c.isInGroup() || c.isHide()) { + if((c.isInGroup()&&!c.isAlwaysShow()) || c.isHide()) { back.remove(c); } } From 1af53c9b0e5000a090e0114cf28d73f5b1c00ce3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:53:42 -0400 Subject: [PATCH 475/635] make sure the vitamins are set to always show --- .../bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 4f04dd60..a8e43cd7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -115,6 +115,7 @@ public CSG regenerate(CSG previous) { } }); //back.getStorage().set("PreviousName", name); + back.setIsAlwaysShow(true); return back; } catch (Exception e) { // Auto-generated catch block From 50f1c062fe1b85f5229ab11173c5f3eaef64a91d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:54:06 -0400 Subject: [PATCH 476/635] remove redundant class, this should just be the cadoodle operaiton --- .../bowlerstudio/creature/ControllerInstance.java | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java deleted file mode 100644 index cdf161a2..00000000 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerInstance.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.neuronrobotics.bowlerstudio.creature; - -import com.google.gson.annotations.Expose; -import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; - -public class ControllerInstance { - @Expose(serialize = true, deserialize = true) - ControllerOption type; - @Expose(serialize = true, deserialize = true) - String name; - @Expose(serialize = true, deserialize = true) - TransformNR pose; - -} From 57805c0dbc7ffc22ab0e721a9d6852418abdd825 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:54:24 -0400 Subject: [PATCH 477/635] adding more to the options --- .../creature/ControllerOption.java | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 55e95402..e1cc1155 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -1,11 +1,14 @@ package com.neuronrobotics.bowlerstudio.creature; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.delim; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.apache.commons.io.FileUtils; @@ -18,6 +21,15 @@ import com.google.gson.annotations.Expose; import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import javafx.scene.image.Image; +import javafx.scene.paint.Color; public class ControllerOption { public static final String URL_OF_OPTIONS = "https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git"; @@ -32,6 +44,8 @@ public class ControllerOption { @Expose(serialize = true, deserialize = true) List vitaminSize; @Expose(serialize = true, deserialize = true) + List vitaminPose; + @Expose(serialize = true, deserialize = true) String linkLoaderGit; @Expose(serialize = true, deserialize = true) String linkLoaderFile; @@ -47,8 +61,48 @@ public class ControllerOption { ControllerFeatures provides; @Expose(serialize = true, deserialize = true) ControllerFeatures consumes; + + // Internal variables + private boolean built=false; + javafx.scene.image.Image image = null; + CSG indicator = null; + File stlFile = null; + + public void build(CaDoodleFile f) { + if(built) + return; + built=true; + image = new Image(getImageFile().toURI().toString()); + String absolutePath = ScriptingEngine.getWorkspace().getAbsolutePath() + delim() + "uicache"; + File dir = new File(absolutePath); + if (!dir.exists()) + dir.mkdirs(); + stlFile = new File(absolutePath + delim() + type + ".stl"); + if ( stlFile.exists()) { + indicator = Vitamins.get(stlFile); + getIndicator().setColor(Color.WHITE); + return; + }else { + AddRobotController arc = new AddRobotController().setController(this); + arc.setCaDoodleFile(f); + List so = arc.process(new ArrayList<>()); + for (CSG c : so) { + for (String s : c.getParameters()) { + CSGDatabase.delete(s); + } + } + indicator = so.get(0); + if (so.size() > 1) { + for(int i=1;i getOptions() public String getLinkDeviceName() { return linkDeviceName; } - + public CSG getVitaminCSG(int index) { + try { + return Vitamins.get(vitaminType.get(index), vitaminSize.get(index)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } public List getVitaminType() { return vitaminType; } - + public int getVitaminNumber() { + return vitaminSize.size(); + } public List getVitaminSize() { return vitaminSize; } @@ -136,4 +198,20 @@ public List getVitaminSize() { public String getLinkDeviceType() { return linkDeviceType; } + + public javafx.scene.image.Image getImage() { + return image; + } + public TransformNR getVitaminPose(int index) { + return getVitaminPose().get(index); + } + public List getVitaminPose() { + if(vitaminPose==null) + return new ArrayList<>(Arrays.asList(new TransformNR())); + return vitaminPose; + } + + public CSG getIndicator() { + return indicator; + } } From 5dc18b9a4f4e5072cd374fb0fe8a3bcbfad8c067 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:56:30 -0400 Subject: [PATCH 478/635] adding the noscale feature as an infectious flag so no future opjects are scaled --- .../bowlerstudio/scripting/cadoodle/Group.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 0660809f..8a107a96 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -36,11 +36,15 @@ public List process(List incoming) { ArrayList replace = new ArrayList(); back.addAll(incoming); String mobileBase=null; + boolean noscale=false; for (CSG csg : incoming) { if (csg.isLock()) continue; + for (String name : names) { if (name.contentEquals(csg.getName())) { + if(csg.isNoScale()) + noscale=true; Optional mobileBaseName = csg.getMobileBaseName(); if(mobileBaseName.isPresent()) { if(mobileBase==null) @@ -104,6 +108,8 @@ public List process(List incoming) { mapOfparametrics.clear(); result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); + result.setNoScale(noscale); + result.setIsAlwaysShow(false); namesAdded.add(result.getName()); back.add(result); return back; From a33f1eacb74bb9dcf789d4c24b0eead7a23bc0f5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:56:40 -0400 Subject: [PATCH 479/635] remove the set name --- .../bowlerstudio/scripting/cadoodle/INamedOperation.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java index 2b0a2672..f1ca524e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/INamedOperation.java @@ -2,6 +2,4 @@ public interface INamedOperation { public String getName(); - - public void setName(String name); } From c98fc5b78d0bcfdc4d4748d19b53462a88b15c9a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:56:46 -0400 Subject: [PATCH 480/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 2042aed4..b058457e 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 2042aed43a091886000a953d349793e92b4e8db0 +Subproject commit b058457e8be1e828a30fc197ab80deae6ec04ecc From 172c8baef7945c43c51602eccd5f4857deae7222 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:57:22 -0400 Subject: [PATCH 481/635] add and remove the controller options --- .../bowlerstudio/creature/MobileBaseBuilder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 696afe5e..370466ef 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; @@ -26,7 +27,7 @@ public class MobileBaseBuilder { @Expose(serialize = true, deserialize = true) - ArrayList controllers = new ArrayList(); + ArrayList controllers = new ArrayList(); private MobileBase mobileBase; @@ -397,5 +398,14 @@ public MobileBase build() throws Exception { return mobileBase; } + public void addController(AddRobotController controller) { + getControllers().add(controller); + } + public void removeController(AddRobotController addRobotController) { + getControllers().remove(addRobotController); + } + public ArrayList getControllers() { + return controllers; + } } \ No newline at end of file From dd339100d54b6400527f91c45c6bce30764ba310 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:57:56 -0400 Subject: [PATCH 482/635] enforce the noscale flag and do not scale objects that are flagged --- .../scripting/cadoodle/Resize.java | 155 +++++++++--------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 617d0aac..f40726f4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -16,7 +16,7 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.Vector3d; -public class Resize extends CaDoodleOperation{ +public class Resize extends CaDoodleOperation { @Expose(serialize = true, deserialize = true) private List names = new ArrayList(); @@ -36,7 +36,8 @@ public class Resize extends CaDoodleOperation{ public String getType() { return "Resize"; } - private class ResizeEvent{ + + private class ResizeEvent { Transform scaleZ; Transform scale; double movez; @@ -48,7 +49,7 @@ public Bounds getSellectedBounds(List incoming) { Vector3d min = null; Vector3d max = null; for (CSG i : incoming) { - CSG c=i.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); + CSG c = i.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); Vector3d min2 = c.getBounds().getMin().clone(); Vector3d max2 = c.getBounds().getMax().clone(); if (min == null) @@ -68,136 +69,128 @@ public Bounds getSellectedBounds(List incoming) { if (max.z < max2.z) max.z = max2.z; } - if(min==null||max==null) { + if (min == null || max == null) { System.out.println("Found bounds to be null "); throw new RuntimeException("Min and max can not be null"); } return new Bounds(min, max); } + @Override public List process(List incoming) { ArrayList back = new ArrayList(); back.addAll(incoming); - HashMap groupsProcessed = new HashMap<>(); + HashMap groupsProcessed = new HashMap<>(); ArrayList selected = new ArrayList(); - for(CSG c:incoming) { - if(c.isLock()) + for (CSG c : incoming) { + if (c.isLock()) + continue; + if (c.isNoScale()) continue; for (String name : names) { - if(c.getName().contentEquals(name)) { + if (c.getName().contentEquals(name)) { selected.add(c); } } } - Bounds b = getSellectedBounds(selected); - - for (String name : names) { - resizeByName(name,back,groupsProcessed,b); + if (selected.size() > 0) { + Bounds b = getSellectedBounds(selected); + for (String name : names) { + resizeByName(name, back, groupsProcessed, b); + } } return back; } - private void resizeByName(String name, ArrayList back, HashMap groupsProcessed,Bounds bounds) { + private void resizeByName(String name, ArrayList back, HashMap groupsProcessed, + Bounds bounds) { for (int i = 0; i < back.size(); i++) { CSG starting = back.get(i); - if ( starting.getName().contentEquals(name) ){ - double zScale = height.getZ()-bounds.getMin().z; - double scalez = zScale/ (bounds.getMax().z-bounds.getMin().z); - - - Transform scaleZ =new Transform().scaleZ(scalez); + if (starting.getName().contentEquals(name)) { + double zScale = height.getZ() - bounds.getMin().z; + double scalez = zScale / (bounds.getMax().z - bounds.getMin().z); + + Transform scaleZ = new Transform().scaleZ(scalez); CSG transformed = starting.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); - if(debug!=null) { + if (debug != null) { debug.setCsg(transformed, null); } - CSG resizeUp = transformed - .transformed(scaleZ); - if(debug!=null) { + CSG resizeUp = transformed.transformed(scaleZ); + if (debug != null) { debug.setCsg(resizeUp, null); } - double zMove = -(bounds.getMin().z*scalez)+bounds.getMin().z; - resizeUp=resizeUp - .movez(zMove); - if(debug!=null) { + double zMove = -(bounds.getMin().z * scalez) + bounds.getMin().z; + resizeUp = resizeUp.movez(zMove); + if (debug != null) { debug.setCsg(resizeUp, null); } - double xdimen = Math.abs(leftFront.getX()-rightRear.getX()); - double ydimen = Math.abs(leftFront.getY()-rightRear.getY()); - double scalex = xdimen/ (bounds.getMax().x-bounds.getMin().x); - double scaley = ydimen/ (bounds.getMax().y-bounds.getMin().y); + double xdimen = Math.abs(leftFront.getX() - rightRear.getX()); + double ydimen = Math.abs(leftFront.getY() - rightRear.getY()); + double scalex = xdimen / (bounds.getMax().x - bounds.getMin().x); + double scaley = ydimen / (bounds.getMax().y - bounds.getMin().y); double x = rightRear.getX(); double y = rightRear.getY(); - - if(leftFront.getX() back, HashMap groupsProcessed) { for (int i = 0; i < back.size(); i++) { CSG c = back.get(i); - if(c.isInGroup() && c.checkGroupMembership(name) ) { - - ResizeEvent ev =groupsProcessed.get(name); + if (c.isInGroup() && c.checkGroupMembership(name)) { + + ResizeEvent ev = groupsProcessed.get(name); CSG transformed = c.transformed(TransformFactory.nrToCSG(getWorkplane().inverse())); - if(debug!=null) { + if (debug != null) { debug.setCsg(transformed, null); } - CSG gc = transformed - .transformed(ev.scaleZ); - gc=gc - .movez(ev.movez); - gc=gc.transformed(ev.scale); - gc=gc - .movex(ev.movex) - .movey(ev.movey) - .transformed(TransformFactory.nrToCSG(getWorkplane())); + CSG gc = transformed.transformed(ev.scaleZ); + gc = gc.movez(ev.movez); + gc = gc.transformed(ev.scale); + gc = gc.movex(ev.movex).movey(ev.movey).transformed(TransformFactory.nrToCSG(getWorkplane())); gc.syncProperties(c).setName(c.getName()); back.set(i, gc); - if( c.isGroupResult()) { + if (c.isGroupResult()) { groupsProcessed.put(c.getName(), ev); - processCompositMembers(c.getName(),back,groupsProcessed); + processCompositMembers(c.getName(), back, groupsProcessed); } } } @@ -207,11 +200,12 @@ public Resize setResize(TransformNR h, TransformNR lf, TransformNR rr) { height = h; leftFront = lf; rightRear = rr; - if(Math.abs(lf.getZ()-rr.getZ())>0.00001) { - throw new RuntimeException("The control points of the corners must be at the same Z value \n"+lf.toSimpleString()+"\n"+rr.toSimpleString()); + if (Math.abs(lf.getZ() - rr.getZ()) > 0.00001) { + throw new RuntimeException("The control points of the corners must be at the same Z value \n" + + lf.toSimpleString() + "\n" + rr.toSimpleString()); } - if(rightRear.getY()>=leftFront.getY() && rightRear.getX()>=leftFront.getX()) - return setResize(h,rr,lf);// they were swapped, just fix it and move along + if (rightRear.getY() >= leftFront.getY() && rightRear.getX() >= leftFront.getX()) + return setResize(h, rr, lf);// they were swapped, just fix it and move along // if(rightRear.getY()>=leftFront.getY() || rightRear.getX()>=leftFront.getX()) // throw new RuntimeException("Scale must be positive!"); return this; @@ -225,15 +219,18 @@ public Resize setNames(List names) { this.names = names; return this; } + public TransformNR getWorkplane() { - if(workplane==null) - workplane=new TransformNR(); + if (workplane == null) + workplane = new TransformNR(); return workplane; } + public Resize setWorkplane(TransformNR workplane) { this.workplane = workplane; return this; } + public Resize setDebugger(IMobileBaseUI engine) { this.debug = engine; return this; From 28107f18e07f6d3381c13de873b2d8c292c1f1a0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 13:58:16 -0400 Subject: [PATCH 483/635] force all vitaamins into noscale by default --- .../java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 681690b8..1dbff5a5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -207,6 +207,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception Map configuration = Vitamins.getConfiguration(type, id); newVitamin.setName(type + "-" + id); newVitamin.setManufacturing(incoming -> null); + newVitamin.setNoScale(true); try { Transform com = new Transform() .movex(Double.parseDouble(configuration.get("massCentroidX").toString())) From a235b5db49d9360909d0dc3cc31a422810d54ab7 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 16:59:42 -0400 Subject: [PATCH 484/635] add getters --- .../bowlerstudio/creature/ControllerOption.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index e1cc1155..883c7ee7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -214,4 +214,12 @@ public List getVitaminPose() { public CSG getIndicator() { return indicator; } + + public ControllerFeatures getProvides() { + return provides; + } + + public ControllerFeatures getConsumes() { + return consumes; + } } From 174c0b8a878839bdfc33bc812b495d6c129c0d3b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 17:00:09 -0400 Subject: [PATCH 485/635] create accumulator and multi-dimentional add/subtract --- .../creature/ControllerFeatures.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java index 34f947af..3dc14046 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -1,9 +1,12 @@ package com.neuronrobotics.bowlerstudio.creature; +import java.util.ArrayList; import java.util.List; import com.google.gson.annotations.Expose; +import eu.mihosoft.vrl.v3d.Plane; + public class ControllerFeatures { @Expose(serialize = true, deserialize = true) int servoChannels = 0; @@ -28,6 +31,47 @@ public class ControllerFeatures { @Expose(serialize = true, deserialize = true) double batteryPeakWatt = 0; + public void add(ControllerFeatures f) { + if(f==null) + return; + servoChannels+=f.servoChannels; + motorChannels+=f.motorChannels; + analogSensorChannels+=f.analogSensorChannels; + cameras+=f.cameras; + digitalSensorChannels+=f.digitalSensorChannels; + inertialSensors+=f.inertialSensors; + distanceSensors+=f.distanceSensors; + pointCloudSensors+=f.pointCloudSensors; + ArrayList toadd=new ArrayList(); + for(Double v:f.getBatteryVoltage()) { + boolean found=false; + for(Double d:getBatteryVoltage()) { + if(Math.abs(v-d) getBatteryVoltage() { + if(voltages==null) + voltages=new ArrayList(); return voltages; } From 8480b3677b21306d52a0a9b7a13c4762d85317b6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:21:06 -0400 Subject: [PATCH 486/635] make the recursion take the existing applied names into account the recursion checks it it has been applied, and then returns early. --- .../bowlerstudio/scripting/CaDoodleLoader.java | 2 +- .../bowlerstudio/scripting/cadoodle/Allign.java | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 +++++++--- .../bowlerstudio/scripting/cadoodle/Mirror.java | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index 08604325..f54ca4bc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -35,7 +35,7 @@ public Object inlineScriptRun(String code, ArrayList args) throws Except return process; } - public static Object process(CaDoodleFile loaded) { + public static Object process(CaDoodleFile loaded,boolean includeAlwaysShow) { List incoming = loaded.getCurrentState(); ArrayList back = new ArrayList(); back.addAll(incoming); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index 475cdec6..d7b539ca 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -87,7 +87,7 @@ public List process(List incoming) { MoveCenter.set(getName() , c, times); b.add(c); return b; - }, 1); + }, 1,new HashSet()); } return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9709a217..5ece8d58 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -506,6 +506,7 @@ public static CSG getByName(List back, String name) { public static int applyToAllConstituantElements(boolean addRet, List targetNames, ArrayList back, ICadoodleRecursiveEvent p, int depth) { + HashSet appliedMemory = new HashSet(); for (int i = 0; i < targetNames.size(); i++) { String s = targetNames.get(i); try { @@ -515,13 +516,16 @@ public static int applyToAllConstituantElements(boolean addRet, List tar } catch (Exception ex) { ex.printStackTrace(); } - applyToAllConstituantElements(addRet, s, back, p, depth); + applyToAllConstituantElements(addRet, s, back, p, depth,appliedMemory); } return back.size(); } public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - ICadoodleRecursiveEvent p, int depth) { + ICadoodleRecursiveEvent p, int depth,HashSet appliedMemory) { + if(appliedMemory.contains(targetName)) + return back.size(); + appliedMemory.add(targetName); ArrayList immutable = new ArrayList<>(); immutable.addAll(back); for (int i = 0; i < immutable.size(); i++) { @@ -552,7 +556,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } if (thisCSGIsInGroupNamedAfterTarget) { // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, p, depth + 1); + applyToAllConstituantElements(addRet, thisCSGName, back, p, depth + 1,appliedMemory); } } back.removeAll(Collections.singleton(null)); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 1751c132..7491ec40 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -82,7 +83,8 @@ public List process(List incoming) { MoveCenter.set(getName()+(index++) , tf, wp); b.add(tf); return b; - }, 1); + }, 1,new HashSet() +); } } return back; From 04bac9508bdb3d0f37500822b3f695823aa64b22 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:21:55 -0400 Subject: [PATCH 487/635] make the prep static --- .../scripting/cadoodle/AddFromFile.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 5dc37f81..c9d52f3b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -33,7 +33,7 @@ public class AddFromFile extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private TransformNR location = null; - private ArrayList options = new ArrayList(); + //private ArrayList options = new ArrayList(); @Expose(serialize = true, deserialize = true) private Boolean preventBoM = false; @@ -100,7 +100,7 @@ public List process(List incoming) { CSG csg = flattenedCSGs.get(i); try { - CSG processedCSG = processGiven(csg, i, getOrderedName(),file); + CSG processedCSG = processGiven(csg, i, getOrderedName(),file,name,getLocation()); collect.add(processedCSG); } catch (Exception ex) { ex.printStackTrace(); @@ -108,7 +108,7 @@ public List process(List incoming) { } CSGDatabase.setInstance(instance); for(CSG csg1:collect) - csg1.setParameter(getFileLocationparam(file)); + csg1.setParameter(getFileLocationparam(file,name)); back.addAll(collect); } catch (Exception e) { // Auto-generated catch block @@ -305,8 +305,8 @@ public static File getFile(String name) { // return getParameter("UnKnown").getStrValue(); // } - private CSG processGiven(CSG csg, int i, String n, File f) { - Transform nrToCSG = TransformFactory.nrToCSG(getLocation()); + private static CSG processGiven(CSG csg, int i, String name, File f,String task,TransformNR location) { + Transform nrToCSG = TransformFactory.nrToCSG(location); boolean isDoodle = f.getName().toLowerCase().endsWith(".doodle"); if(isDoodle) { csg.setStorage(new PropertyStorage()); @@ -330,19 +330,19 @@ private CSG processGiven(CSG csg, int i, String n, File f) { csg1.setStorage(new PropertyStorage()); } CSGDatabase.setInstance(instance); - csg1.setParameter(getFileLocationparam(f)); - return processGiven(csg1, i, n,f); + csg1.setParameter(getFileLocationparam(f,task)); + return processGiven(csg1, i, name,f,task,location); } catch (Exception e) { e.printStackTrace(); } return previous; - }).setName(n); - MoveCenter.set(getName(), processedCSG, nrToCSG); + }).setName(name); + MoveCenter.set(task, processedCSG, nrToCSG); return processedCSG; } - private StringParameter getFileLocationparam( File pathname) { - StringParameter stringParameter = new StringParameter(name + "_CaDoodle_File", pathname.getAbsolutePath(), options); + private static StringParameter getFileLocationparam( File pathname,String task) { + StringParameter stringParameter = new StringParameter(task + "_CaDoodle_File", pathname.getAbsolutePath(), new ArrayList()); stringParameter.setStrValue(pathname.getAbsolutePath()); return stringParameter; } From e2dbde15ed21250400bd24303036d232cc90e397 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:22:46 -0400 Subject: [PATCH 488/635] differentiate between the always show and not --- .../java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 2 +- .../bowlerstudio/scripting/CaDoodleLoader.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 0b2c75b0..f71c3571 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -557,7 +557,7 @@ private static void processReturnedObjects(Object ret, ArrayList csgBits) { csgBits.add((CSG) ret); } if (CaDoodleFile.class.isInstance(ret)) { - processReturnedObjects(CaDoodleLoader.process((CaDoodleFile) ret), csgBits); + processReturnedObjects(CaDoodleLoader.process((CaDoodleFile) ret,false), csgBits); return; } if (MobileBase.class.isInstance(ret)) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index f54ca4bc..8b673d2f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -22,7 +22,7 @@ public class CaDoodleLoader implements IScriptingLanguage { @Override public Object inlineScriptRun(File code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromFile(code); - Object process = process(loaded); + Object process = process(loaded,false); loaded.close(); return process; } @@ -30,7 +30,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio @Override public Object inlineScriptRun(String code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromJsonString(code); - Object process = process(loaded); + Object process = process(loaded,false); loaded.close(); return process; } @@ -40,7 +40,7 @@ public static Object process(CaDoodleFile loaded,boolean includeAlwaysShow) { ArrayList back = new ArrayList(); back.addAll(incoming); for(CSG c: incoming) { - if((c.isInGroup()&&!c.isAlwaysShow()) || c.isHide()) { + if((c.isInGroup() && (!c.isAlwaysShow() && includeAlwaysShow )) || c.isHide()) { back.remove(c); } } From d6523a7c5d3171b655a3dfbc41912eb8fda57deb Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:23:15 -0400 Subject: [PATCH 489/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index b058457e..6cb38c23 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit b058457e8be1e828a30fc197ab80deae6ec04ecc +Subproject commit 6cb38c2316385b9ad53062486d229e9d56d574e2 From 49a8e631f4c34144fe5a6f1de6f1febb611c0fab Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:23:35 -0400 Subject: [PATCH 490/635] whitespace --- .../java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 1dbff5a5..f857e240 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -215,7 +215,6 @@ private static CSG get(String type, String id, int depthGauge) throws Exception .movez(Double.parseDouble(configuration.get("massCentroidZ").toString())); newVitamin.getStorage().set("massKg", configuration.get("massKg")); newVitamin.getStorage().set("massCentroid", com); - return newVitamin; } catch (Exception ex) { // com.neuronrobotics.sdk.common.Log.error(type +"-"+ id+" Failed"); From b35c8cdbc42a69ebc147831550fbf7f942495c74 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 6 Aug 2025 20:24:04 -0400 Subject: [PATCH 491/635] add the limb type and options --- .../bowlerstudio/creature/LimbOption.java | 41 ++++++++++++++++++ .../bowlerstudio/creature/LimbType.java | 11 +++++ .../creature/MobileBaseBuilder.java | 42 +++++++++++++------ 3 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbType.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java new file mode 100644 index 00000000..7d597309 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -0,0 +1,41 @@ +package com.neuronrobotics.bowlerstudio.creature; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; + +import org.apache.commons.io.FileUtils; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; +import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +public class LimbOption { + @Expose(serialize = true, deserialize = true) + LimbType type; + @Expose(serialize = true, deserialize = true) + String name; + + public static ArrayList getOptions() + throws InvalidRemoteException, TransportException, GitAPIException, IOException { + try { + Type TT_CaDoodleFile = new TypeToken>() { + }.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() + .excludeFieldsWithoutExposeAnnotation().create(); + File f = ScriptingEngine.fileFromGit(ControllerOption.URL_OF_OPTIONS, "limbOptions.json"); + String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); + return gson.fromJson(content, TT_CaDoodleFile); + } catch (Exception ex) { + ex.printStackTrace(); + return new ArrayList(); + } + } +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbType.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbType.java new file mode 100644 index 00000000..c9d3b73f --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbType.java @@ -0,0 +1,11 @@ +package com.neuronrobotics.bowlerstudio.creature; + +public enum LimbType { + arm, + leg, + wheel, + steerable, + head, + flap, + hand +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 370466ef..089b2ce3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -3,6 +3,7 @@ import com.google.gson.annotations.Expose; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; @@ -26,10 +27,9 @@ import java.util.Map; public class MobileBaseBuilder { - @Expose(serialize = true, deserialize = true) ArrayList controllers = new ArrayList(); - - + ArrayList limbs = new ArrayList(); + private MobileBase mobileBase; private String gitURL; private String xmlName = null; @@ -44,6 +44,7 @@ public MobileBaseBuilder(String gitURL, String name) { this.mobileBase.setScriptingName(name); initializeChannelMap(); } + // Constructor for extending an existing MobileBase public MobileBaseBuilder(MobileBase existingBase) { this.gitURL = existingBase.getGitSelfSource()[0]; @@ -51,7 +52,7 @@ public MobileBaseBuilder(MobileBase existingBase) { initializeChannelMap(); scanExistingChannels(); } - + // Copy functionality from the menu factory public MobileBaseBuilder copyFrom(MobileBase source, String newName) { try { @@ -62,7 +63,7 @@ public MobileBaseBuilder copyFrom(MobileBase source, String newName) { mobileBase.setGitCadEngine(copyGitFile(source.getGitCadEngine(), gitURL)); } if (source.getGitWalkingEngine() != null) { - mobileBase.setGitWalkingEngine( copyGitFile(source.getGitWalkingEngine(), gitURL)); + mobileBase.setGitWalkingEngine(copyGitFile(source.getGitWalkingEngine(), gitURL)); } // Copy appendages @@ -83,7 +84,7 @@ public MobileBaseBuilder copyFrom(MobileBase source, String newName) { for (DHParameterKinematics wheel : source.getDrivable()) { DHParameterKinematics copiedWheel = copyDHParameterKinematics(wheel); - mobileBase.getDrivable() .add(copiedWheel); + mobileBase.getDrivable().add(copiedWheel); } // Copy transforms @@ -95,8 +96,6 @@ public MobileBaseBuilder copyFrom(MobileBase source, String newName) { return this; } - - // // Constructor for extending an existing MobileBase with new name // public MobileBaseBuilder(String gitURL, MobileBase existingBase, String newName) { // this.gitURL = gitURL; @@ -384,7 +383,7 @@ private DHParameterKinematics copyDHParameterKinematics(DHParameterKinematics so private String[] copyGitFile(String[] sourceGit, String targetGit) { return ScriptingEngine.copyGitFile(sourceGit[0], targetGit, sourceGit[1]); } - + public File getFile() throws Exception { return ScriptingEngine.fileFromGit(gitURL, mobileBase.getScriptingName() + ".xml"); } @@ -398,14 +397,33 @@ public MobileBase build() throws Exception { return mobileBase; } + public void addController(AddRobotController controller) { - getControllers().add(controller); + if (!controllers.contains(controller)) + getControllers().add(controller); } - public void removeController(AddRobotController addRobotController) { - getControllers().remove(addRobotController); + + public void removeController(AddRobotController controller) { + if (controllers.contains(controller)) + getControllers().remove(controller); } + public ArrayList getControllers() { return controllers; } + public void addLimb(AddRobotLimb controller) { + if (!getLimmbs().contains(controller)) + getLimmbs().add(controller); + } + + public void removeLimb(AddRobotLimb controller) { + if (getLimmbs().contains(controller)) + getLimmbs().remove(controller); + } + + public ArrayList getLimmbs() { + return limbs; + } + } \ No newline at end of file From 9e1a10e06ceb1e86a6a2e4534c700535362fc0f1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 10:39:27 -0400 Subject: [PATCH 492/635] add the limb options --- .../src/junit/bowler/CaDoodleWorkflowTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java index 5e6ab744..48898d3b 100644 --- a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java +++ b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java @@ -14,6 +14,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.creature.ControllerOption; +import com.neuronrobotics.bowlerstudio.creature.LimbOption; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import java.lang.reflect.Type; @@ -27,6 +28,8 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToHole; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ToSolid; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.UnGroup; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -238,7 +241,21 @@ public void test() throws Exception { ArrayList controllers = ControllerOption.getOptions(); for(ControllerOption o:controllers) { System.out.println(o); + AddRobotController con = new AddRobotController() + .setNames(selectAll) + .setController(o); + loaded.addOpperation(con).join(); } + loaded.save(); + ArrayList limbs = LimbOption.getOptions(); + for(LimbOption o:limbs) { + System.out.println(o); + AddRobotLimb limb = new AddRobotLimb() + .setLimb(o) + .setNames(selectAll); + loaded.addOpperation(limb).join(); + } + loaded.save(); } } From a920c9579d44515499408edb509a4ad82336c95d Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 10:39:39 -0400 Subject: [PATCH 493/635] print statement for features --- .../creature/ControllerFeatures.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java index 3dc14046..d03d5351 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -71,6 +71,21 @@ public void subtract(ControllerFeatures f) { batteryPeakWatt-=f.batteryPeakWatt; batteryWattHour-=f.batteryWattHour; } + @Override + public String toString() { + return "\n\tServos: "+servoChannels+"\n"+ + "\tmotorChannels: "+motorChannels+"\n"+ + "\tanalogSensorChannels: "+analogSensorChannels+"\n"+ + "\tcameras: "+cameras+"\n"+ + "\tdigitalSensorChannels: "+digitalSensorChannels+"\n"+ + "\tinertialSensors: "+inertialSensors+"\n"+ + "\tdistanceSensors: "+distanceSensors+"\n"+ + "\tpointCloudSensors: "+pointCloudSensors+"\n"+ + "\tbatteryPeakWatt: "+batteryPeakWatt+"\n"+ + "\tbatteryWattHour: "+batteryWattHour+"\n"+ + "\tVoltages: "+voltages+"\n" + ; + } public int getServoChannels() { return servoChannels; @@ -116,4 +131,5 @@ public double getBatteryPeakWatts() { public double getBatteryWattHours() { return batteryWattHour; } + } From e10196b08594ca2b5cc6e44b04609bfaa7ff5c61 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 10:39:57 -0400 Subject: [PATCH 494/635] adding the builder factory class --- .../bowlerstudio/creature/LimbOption.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 7d597309..39272d6c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.TransportException; @@ -16,13 +17,28 @@ import com.google.gson.annotations.Expose; import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; public class LimbOption { @Expose(serialize = true, deserialize = true) LimbType type; @Expose(serialize = true, deserialize = true) String name; + @Expose(serialize = true, deserialize = true) + String url; + @Expose(serialize = true, deserialize = true) + String file; + @Expose(serialize = true, deserialize = true) + ControllerFeatures consumes; + @Expose(serialize = true, deserialize = true) + ControllerFeatures provides; + public DHParameterKinematics getLimb() throws Exception { + String xmlContent = ScriptingEngine.codeFromGit(url, file)[0]; + DHParameterKinematics newLimb = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8")); + newLimb.setScriptingName(name); + return newLimb; + } public static ArrayList getOptions() throws InvalidRemoteException, TransportException, GitAPIException, IOException { try { @@ -38,4 +54,8 @@ public static ArrayList getOptions() return new ArrayList(); } } + @Override + public String toString() { + return type+" "+name+" "+url+"/"+file+"\n\tConsumes:"+consumes+"\n\tProvides:"+provides; + } } From 98e6095f4958d3ccccaa5cfdd2247cf342a2268b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 10:40:14 -0400 Subject: [PATCH 495/635] remove junk .xml from name --- .../neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 089b2ce3..e364fb3c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -389,7 +389,7 @@ public File getFile() throws Exception { } public MobileBase build() throws Exception { - String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName() + ".xml"; + String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName() ; mobileBase.setGitSelfSource(new String[] { gitURL, filename }); // Push to git From a87347f3e0fbba73ba82bf2416f938d9e42084d8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:06:15 -0400 Subject: [PATCH 496/635] make the missing folders --- .../scripting/cadoodle/CaDoodleFile.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 5ece8d58..a053e5c6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -36,6 +36,7 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -100,7 +101,13 @@ public void renderSplashFrame(int percent, String message) { private ICadoodleSaveStatusUpdate saveUpdate = null; private boolean timelineOpen = false; private HashMap robots = new HashMap(); - + public ArrayList getMobileBases(){ + ArrayList back = new ArrayList(); + for(MobileBaseBuilder b:robots.values()) { + back.add(b.getMobileBase()); + } + return back; + } public void close() { //new Exception("CaDoodle File Closed here").printStackTrace(); for(CaDoodleOperation op:getOpperations()) { @@ -626,7 +633,7 @@ private void storeResultInCache(CaDoodleOperation op, List process) { + " opperation! " + c.getName()); names.add(c.getName()); cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) - .setRegenerate(c.getRegenerate())); + .setRegenerate(c.getRegenerate()).setManipulator(c.getManipulator())); // cachedCopy.add(c); } cache.put(op, cachedCopy); @@ -925,6 +932,8 @@ public File getSTLThumbnailFile() { public String getSTLThumbnailLocation() { File folder = getSelf().getAbsoluteFile().getParentFile(); + if(!folder.exists()) + folder.mkdirs(); String string = folder.getAbsolutePath() + delim() + "thumbnail.stl"; return string; } @@ -939,6 +948,9 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I // if(currentIndex2==0) // return; File parent = getSelf().getAbsoluteFile().getParentFile(); + File imageFolder=new File(parent.getAbsolutePath() + delim() + "timeline" + delim()); + if(!imageFolder.exists()) + imageFolder.mkdirs(); File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); @@ -966,8 +978,8 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I if (getOpperations().get(getOpperations().size() - 1) == op) { Files.copy(imageCache, image); } - // System.err.println("Thumbnail saved successfully to " + - // imageCache.getAbsolutePath()); + System.err.println("Thumbnail saved successfully to " + + imageCache.getAbsolutePath()); } } catch (Throwable t) { t.printStackTrace(); From 02e6a82988f909b59326010282572df0975cf748 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:06:28 -0400 Subject: [PATCH 497/635] add a controller and limb --- .../junit/bowler/CaDoodleWorkflowTest.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java index 48898d3b..e7ce726b 100644 --- a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java +++ b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java @@ -31,6 +31,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; @@ -230,11 +231,15 @@ public void test() throws Exception { loaded.setSelf(cf.getSelf()); com.neuronrobotics.sdk.common.Log.error(after); - - MakeRobot mr = new MakeRobot(); - mr.setNames(selectAll); while(loaded.isForwardAvailible()) loaded.forward(); + selectAll = new ArrayList(); + for(CSG c:loaded.getCurrentState()) { + selectAll.add(c.getName()); + } + MakeRobot mr = new MakeRobot(); + mr.setNames(selectAll); + loaded.addOpperation(mr).join(); loaded.save(); ScriptingEngine.pull(ControllerOption.URL_OF_OPTIONS); @@ -248,14 +253,24 @@ public void test() throws Exception { } loaded.save(); ArrayList limbs = LimbOption.getOptions(); + TransformNR tf = new TransformNR(); for(LimbOption o:limbs) { System.out.println(o); + tf = new TransformNR(0,0,30).times(tf); AddRobotLimb limb = new AddRobotLimb() .setLimb(o) - .setNames(selectAll); + .setNames(selectAll) + .setLocation(tf); loaded.addOpperation(limb).join(); + break; + } + for(MobileBase mb:loaded.getMobileBases()) { + System.out.println("Base "+mb); + mb.disconnect(); } + System.out.println("Saving"); loaded.save(); + System.out.println("Save finished"); } } From d0ed589f663a7b10a31db2cda198ad25420be085 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:06:46 -0400 Subject: [PATCH 498/635] adding serial bus servos --- .../creature/ControllerFeatures.java | 153 ++++++++++++------ 1 file changed, 105 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java index d03d5351..b0c3d55e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -11,6 +11,14 @@ public class ControllerFeatures { @Expose(serialize = true, deserialize = true) int servoChannels = 0; @Expose(serialize = true, deserialize = true) + int vexV5Motors = 0; + @Expose(serialize = true, deserialize = true) + int hiwonderBus = 0; + @Expose(serialize = true, deserialize = true) + int dynamixelBus = 0; + @Expose(serialize = true, deserialize = true) + int steppers = 0; + @Expose(serialize = true, deserialize = true) int motorChannels = 0; @Expose(serialize = true, deserialize = true) int analogSensorChannels = 0; @@ -25,68 +33,116 @@ public class ControllerFeatures { @Expose(serialize = true, deserialize = true) int pointCloudSensors = 0; @Expose(serialize = true, deserialize = true) - List voltages ; + List voltages; @Expose(serialize = true, deserialize = true) double batteryWattHour = 0; @Expose(serialize = true, deserialize = true) double batteryPeakWatt = 0; - + public void add(ControllerFeatures f) { - if(f==null) + if (f == null) return; - servoChannels+=f.servoChannels; - motorChannels+=f.motorChannels; - analogSensorChannels+=f.analogSensorChannels; - cameras+=f.cameras; - digitalSensorChannels+=f.digitalSensorChannels; - inertialSensors+=f.inertialSensors; - distanceSensors+=f.distanceSensors; - pointCloudSensors+=f.pointCloudSensors; - ArrayList toadd=new ArrayList(); - for(Double v:f.getBatteryVoltage()) { - boolean found=false; - for(Double d:getBatteryVoltage()) { - if(Math.abs(v-d) toadd = new ArrayList(); + for (Double v : f.getBatteryVoltage()) { + boolean found = false; + for (Double d : getBatteryVoltage()) { + if (Math.abs(v - d) < Plane.getEPSILON()) { + found = true; } } - if(!found) + if (!found) toadd.add(v); } getBatteryVoltage().addAll(toadd); - batteryPeakWatt+=f.batteryPeakWatt; - batteryWattHour+=f.batteryWattHour; + batteryPeakWatt += f.batteryPeakWatt; + batteryWattHour += f.batteryWattHour; } + + public boolean check(ControllerFeatures f) { + if (f == null) + return false; + if (vexV5Motors < f.vexV5Motors) + return false; + if (hiwonderBus < f.hiwonderBus) + return false; + if (dynamixelBus < f.dynamixelBus) + return false; + if (steppers < f.steppers) + return false; + if (servoChannels < f.servoChannels) + return false; + if (motorChannels < f.motorChannels) + return false; + if (analogSensorChannels < f.analogSensorChannels) + return false; + if (cameras < f.cameras) + return false; + if (digitalSensorChannels < f.digitalSensorChannels) + return false; + if (inertialSensors < f.inertialSensors) + return false; + if (distanceSensors < f.distanceSensors) + return false; + if (pointCloudSensors < f.pointCloudSensors) + return false; + for (Double v : f.getBatteryVoltage()) { + boolean found = false; + for (Double d : getBatteryVoltage()) { + if (Math.abs(v - d) < Plane.getEPSILON()) { + found = true; + } + } + if (!found) + return false; + } + if (batteryPeakWatt < f.batteryPeakWatt) + return false; + if (batteryWattHour < f.batteryWattHour) + return false; + return true; + } + public void subtract(ControllerFeatures f) { - if( f== null) + if (f == null) return; - servoChannels-=f.servoChannels; - motorChannels-=f.motorChannels; - analogSensorChannels-=f.analogSensorChannels; - cameras-=f.cameras; - digitalSensorChannels-=f.digitalSensorChannels; - inertialSensors-=f.inertialSensors; - distanceSensors-=f.distanceSensors; - pointCloudSensors-=f.pointCloudSensors; - batteryPeakWatt-=f.batteryPeakWatt; - batteryWattHour-=f.batteryWattHour; + vexV5Motors -= f.vexV5Motors; + hiwonderBus -= f.hiwonderBus; + dynamixelBus -= f.dynamixelBus; + steppers -= f.steppers; + servoChannels -= f.servoChannels; + motorChannels -= f.motorChannels; + analogSensorChannels -= f.analogSensorChannels; + cameras -= f.cameras; + digitalSensorChannels -= f.digitalSensorChannels; + inertialSensors -= f.inertialSensors; + distanceSensors -= f.distanceSensors; + pointCloudSensors -= f.pointCloudSensors; + batteryPeakWatt -= f.batteryPeakWatt; + batteryWattHour -= f.batteryWattHour; } - @Override + + @Override public String toString() { - return "\n\tServos: "+servoChannels+"\n"+ - "\tmotorChannels: "+motorChannels+"\n"+ - "\tanalogSensorChannels: "+analogSensorChannels+"\n"+ - "\tcameras: "+cameras+"\n"+ - "\tdigitalSensorChannels: "+digitalSensorChannels+"\n"+ - "\tinertialSensors: "+inertialSensors+"\n"+ - "\tdistanceSensors: "+distanceSensors+"\n"+ - "\tpointCloudSensors: "+pointCloudSensors+"\n"+ - "\tbatteryPeakWatt: "+batteryPeakWatt+"\n"+ - "\tbatteryWattHour: "+batteryWattHour+"\n"+ - "\tVoltages: "+voltages+"\n" - ; + return "\n\tServos: " + servoChannels + "\n" + "\tmotorChannels: " + motorChannels + "\n" + + "\tanalogSensorChannels: " + analogSensorChannels + "\n" + "\tcameras: " + cameras + "\n" + + "\tdigitalSensorChannels: " + digitalSensorChannels + "\n" + "\tinertialSensors: " + inertialSensors + + "\n" + "\tdistanceSensors: " + distanceSensors + "\n" + "\tpointCloudSensors: " + pointCloudSensors + + "\n" + "\tbatteryPeakWatt: " + batteryPeakWatt + "\n" + "\tbatteryWattHour: " + batteryWattHour + "\n" + + "\tVoltages: " + voltages + "\n"; } - + public int getServoChannels() { return servoChannels; } @@ -120,16 +176,17 @@ public int getPointCloudSensors() { } public List getBatteryVoltage() { - if(voltages==null) - voltages=new ArrayList(); + if (voltages == null) + voltages = new ArrayList(); return voltages; } public double getBatteryPeakWatts() { return batteryPeakWatt; } + public double getBatteryWattHours() { return batteryWattHour; } - + } From dbd3f3d80b31f7007e06bdc2105d37abd8a075d3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:07:28 -0400 Subject: [PATCH 499/635] convert the vitamin data into vitamin locations --- .../bowlerstudio/creature/ControllerOption.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 883c7ee7..7d831212 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -24,6 +24,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; @@ -67,6 +68,8 @@ public class ControllerOption { javafx.scene.image.Image image = null; CSG indicator = null; File stlFile = null; + private ArrayList back; + private String baseName; public void build(CaDoodleFile f) { if(built) @@ -222,4 +225,17 @@ public ControllerFeatures getProvides() { public ControllerFeatures getConsumes() { return consumes; } + + public ArrayList getVitamins(TransformNR location, String baseName) { + if(back==null ) { + this.baseName = baseName; + back = new ArrayList(); + for (int i = 0; i < getVitaminNumber(); i++) { + TransformNR offset = location.times(getVitaminPose(i)); + back.add(new VitaminLocation(false,baseName+"_"+i, vitaminType.get(i), vitaminSize.get(i), offset) + ); + } + } + return back; + } } From a9aa56ff0b09b8cc01813ab3f33f698b41d13df4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:09:00 -0400 Subject: [PATCH 500/635] adding helper methods --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index d9dbbcac..58791e9a 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit d9dbbcac641b9afa7b883ceb357f2bc2cff5945a +Subproject commit 58791e9a9efe670143d3c502b293536f6d65e3db From e4c0ccdaec66d5868592c3ea0891ec3d0d7bff0f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:09:30 -0400 Subject: [PATCH 501/635] load the limb from the url --- .../bowlerstudio/creature/LimbOption.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 39272d6c..57f43f98 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -18,6 +18,7 @@ import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; public class LimbOption { @Expose(serialize = true, deserialize = true) @@ -29,16 +30,26 @@ public class LimbOption { @Expose(serialize = true, deserialize = true) String file; @Expose(serialize = true, deserialize = true) + boolean composite; + @Expose(serialize = true, deserialize = true) ControllerFeatures consumes; @Expose(serialize = true, deserialize = true) ControllerFeatures provides; - - public DHParameterKinematics getLimb() throws Exception { + + public DHParameterKinematics getLimb(String uniqueName) throws Exception { String xmlContent = ScriptingEngine.codeFromGit(url, file)[0]; - DHParameterKinematics newLimb = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8")); - newLimb.setScriptingName(name); - return newLimb; + if (!composite) { + DHParameterKinematics newLimb = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8")); + newLimb.setScriptingName(uniqueName); + return newLimb; + } else { + MobileBase base = (MobileBase) ScriptingEngine.gitScriptRun(url, file); + DHParameterKinematics newLimb = base.getAllDHChains().get(0); + newLimb.setScriptingName(uniqueName); + return newLimb; + } } + public static ArrayList getOptions() throws InvalidRemoteException, TransportException, GitAPIException, IOException { try { @@ -54,8 +65,9 @@ public static ArrayList getOptions() return new ArrayList(); } } + @Override public String toString() { - return type+" "+name+" "+url+"/"+file+"\n\tConsumes:"+consumes+"\n\tProvides:"+provides; + return type + " " + name + " " + url + "/" + file + "\n\tConsumes:" + consumes + "\n\tProvides:" + provides; } } From 6bd8384c6a18bcf1b61a31d53d31936c833cc669 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:09:42 -0400 Subject: [PATCH 502/635] refactor --- .../scripting/cadoodle/robot/MakeRobot.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index a7dfbbf3..02160603 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -13,7 +13,7 @@ public class MakeRobot extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) - private List assignedAsBase = new ArrayList(); + private List names = new ArrayList(); //@Expose(serialize = true, deserialize = true) MobileBaseBuilder builder; @@ -27,7 +27,7 @@ public List process(List incoming) { try { getBuilder().build(); for(CSG c:incoming) { - for(String s:assignedAsBase) { + for(String s:names) { if(c.getName().contentEquals(s)) { c.setMobileBaseName(getName()); } @@ -54,12 +54,14 @@ public File getFile() throws NoSuchFileException { } } - public List getAssignedAsBase() { - return assignedAsBase; + public List getNames() { + return names; } public void setNames(List assignedAsBase) { - this.assignedAsBase = assignedAsBase; + if(assignedAsBase.size()==0) + throw new RuntimeException("Can not create a robot without specifying a base"); + this.names = assignedAsBase; } /** From b733386a487f67fa348a002a40b8b9cce5c15e0e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:10:14 -0400 Subject: [PATCH 503/635] add the limbs and controllers to the mobil base --- .../creature/MobileBaseBuilder.java | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index e364fb3c..5e9b570f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -7,6 +7,7 @@ import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup; import com.neuronrobotics.sdk.common.Log; @@ -389,12 +390,54 @@ public File getFile() throws Exception { } public MobileBase build() throws Exception { + if(!mobileBase.isAvailable()) + mobileBase.connect(); String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName() ; mobileBase.setGitSelfSource(new String[] { gitURL, filename }); - + for (int i = 0; i < controllers.size(); i++) { + AddRobotController con = controllers.get(i); + for(VitaminLocation l:con.getVitamins(con.getName()+"_"+i)) { + try { + if(!mobileBase.hasVitamin(l)) + mobileBase.addVitamin(l); + }catch(Exception ex) { + ex.printStackTrace(); + } + } + } + for(int i=0;i getControllers() { @@ -420,10 +473,18 @@ public void addLimb(AddRobotLimb controller) { public void removeLimb(AddRobotLimb controller) { if (getLimmbs().contains(controller)) getLimmbs().remove(controller); + mobileBase.deleteLimbByName(controller.getName()); } public ArrayList getLimmbs() { return limbs; } + public MobileBaseCadManager getCadManager() { + MobileBaseCadManager mobileBaseCadManager = MobileBaseCadManager.get(mobileBase); + mobileBaseCadManager.setAutoRegen(false); + mobileBaseCadManager.setConfigurationViewerMode(false); + return mobileBaseCadManager; + } + } \ No newline at end of file From cba6550a2aa791e940cdf76b7a4811a87606e07f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 16:10:37 -0400 Subject: [PATCH 504/635] make the variables readable is exception caught --- .../com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index f857e240..bfd67f4e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -189,13 +189,14 @@ public static CSG get(String type, String id) throws Exception { private static CSG get(String type, String id, int depthGauge) throws Exception { String key = type + id; Map script = getMeta(type); - + Object file = null; + Object repostring =null; try { CSG newVitamin = null; StringParameter size = new StringParameter(type + " Default", id, Vitamins.listVitaminSizes(type)); size.setStrValue(id); - Object file = script.get("scriptGit"); - Object repostring = script.get("scriptFile"); + file = script.get("scriptGit"); + repostring = script.get("scriptFile"); Object repo = repostring; if (file != null && repo != null) { ArrayList servoMeasurments = new ArrayList(); From f13ce4131794df466d53848898f1e045bfdde95b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 17:34:58 -0400 Subject: [PATCH 505/635] formatting --- .../junit/bowler/CaDoodleWorkflowTest.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java index e7ce726b..171c46c3 100644 --- a/test/java/src/junit/bowler/CaDoodleWorkflowTest.java +++ b/test/java/src/junit/bowler/CaDoodleWorkflowTest.java @@ -255,14 +255,18 @@ public void test() throws Exception { ArrayList limbs = LimbOption.getOptions(); TransformNR tf = new TransformNR(); for(LimbOption o:limbs) { - System.out.println(o); - tf = new TransformNR(0,0,30).times(tf); - AddRobotLimb limb = new AddRobotLimb() - .setLimb(o) - .setNames(selectAll) - .setLocation(tf); - loaded.addOpperation(limb).join(); - break; + if(mr.getBuilder().checkOptionSupported(o)) { + System.out.println(o); + tf = new TransformNR(0,0,30).times(tf); + AddRobotLimb limb = new AddRobotLimb() + .setLimb(o) + .setNames(selectAll) + .setLocation(tf); + loaded.addOpperation(limb).join(); + }else { + System.out.println("Unsupported limb "+o); + } + //break; } for(MobileBase mb:loaded.getMobileBases()) { System.out.println("Base "+mb); From 98633f5b327b99812897329ebab8a6b6bde28f11 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 17:35:18 -0400 Subject: [PATCH 506/635] break out of the voltage search when match found --- .../bowlerstudio/creature/ControllerFeatures.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java index b0c3d55e..3d1ebc55 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -106,6 +106,8 @@ public boolean check(ControllerFeatures f) { } if (!found) return false; + else + break; } if (batteryPeakWatt < f.batteryPeakWatt) return false; From c32298d100b3530957a1ee98a60ef6e193ea4e93 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 17:35:27 -0400 Subject: [PATCH 507/635] getters --- .../bowlerstudio/creature/LimbOption.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 57f43f98..d33b84c3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -68,6 +68,14 @@ public static ArrayList getOptions() @Override public String toString() { - return type + " " + name + " " + url + "/" + file + "\n\tConsumes:" + consumes + "\n\tProvides:" + provides; + return type + " " + name + " " + url + "/" + file + "\n\tConsumes:" + getConsumes() + "\n\tProvides:" + getProvides(); + } + + public ControllerFeatures getConsumes() { + return consumes; + } + + public ControllerFeatures getProvides() { + return provides; } } From df5e5e59efa9b62b5e099cc09d19bb437518a50e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 7 Aug 2025 17:35:54 -0400 Subject: [PATCH 508/635] getter for the full builders capibilities --- .../creature/MobileBaseBuilder.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 5e9b570f..b1d35a45 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -464,12 +464,31 @@ public void removeController(AddRobotController controller) { public ArrayList getControllers() { return controllers; } - + public ControllerFeatures getCapibilities() { + ControllerFeatures test = new ControllerFeatures(); + for(AddRobotController c:controllers) { + test.add(c.getController().getProvides()); + test.subtract(c.getController().getConsumes()); + } + for(AddRobotLimb c:limbs) { + test.add(c.getLimb().getProvides()); + test.subtract(c.getLimb().getConsumes()); + } + return test; + } public void addLimb(AddRobotLimb controller) { + LimbOption consumes = controller.getLimb(); + if(!checkOptionSupported(consumes)) { + throw new RuntimeException("Robot doesnt have enough resources to support "+controller.getLimb()); + } if (!getLimmbs().contains(controller)) getLimmbs().add(controller); } + public boolean checkOptionSupported(LimbOption consumes) { + return getCapibilities().check(consumes.consumes); + } + public void removeLimb(AddRobotLimb controller) { if (getLimmbs().contains(controller)) getLimmbs().remove(controller); From d28c77d80eacc056129736610e313d8b5e03411f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 8 Aug 2025 11:19:30 -0400 Subject: [PATCH 509/635] add getters for the bus features --- .../creature/ControllerFeatures.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java index 3d1ebc55..19d74d04 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerFeatures.java @@ -42,10 +42,10 @@ public class ControllerFeatures { public void add(ControllerFeatures f) { if (f == null) return; - vexV5Motors += f.vexV5Motors; - hiwonderBus += f.hiwonderBus; - dynamixelBus += f.dynamixelBus; - steppers += f.steppers; + vexV5Motors = getVexV5Motors() + f.vexV5Motors; + hiwonderBus = getHiwonderBus() + f.hiwonderBus; + dynamixelBus = getDynamixelBus() + f.dynamixelBus; + steppers = getSteppers() + f.steppers; servoChannels += f.servoChannels; motorChannels += f.motorChannels; analogSensorChannels += f.analogSensorChannels; @@ -73,13 +73,13 @@ public void add(ControllerFeatures f) { public boolean check(ControllerFeatures f) { if (f == null) return false; - if (vexV5Motors < f.vexV5Motors) + if (getVexV5Motors() < f.getVexV5Motors()) return false; - if (hiwonderBus < f.hiwonderBus) + if (getHiwonderBus() < f.getHiwonderBus()) return false; - if (dynamixelBus < f.dynamixelBus) + if (getDynamixelBus() < f.getDynamixelBus()) return false; - if (steppers < f.steppers) + if (getSteppers() < f.getSteppers()) return false; if (servoChannels < f.servoChannels) return false; @@ -119,10 +119,10 @@ public boolean check(ControllerFeatures f) { public void subtract(ControllerFeatures f) { if (f == null) return; - vexV5Motors -= f.vexV5Motors; - hiwonderBus -= f.hiwonderBus; - dynamixelBus -= f.dynamixelBus; - steppers -= f.steppers; + vexV5Motors = getVexV5Motors() - f.vexV5Motors; + hiwonderBus = getHiwonderBus() - f.hiwonderBus; + dynamixelBus = getDynamixelBus() - f.dynamixelBus; + steppers = getSteppers() - f.steppers; servoChannels -= f.servoChannels; motorChannels -= f.motorChannels; analogSensorChannels -= f.analogSensorChannels; @@ -191,4 +191,20 @@ public double getBatteryWattHours() { return batteryWattHour; } + public int getVexV5Motors() { + return vexV5Motors; + } + + public int getHiwonderBus() { + return hiwonderBus; + } + + public int getDynamixelBus() { + return dynamixelBus; + } + + public int getSteppers() { + return steppers; + } + } From 87ee3ccc8d3133f78d16389465a52004e4dda481 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 8 Aug 2025 11:44:07 -0400 Subject: [PATCH 510/635] improve the svg loading --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 6cb38c23..7bd8ccab 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 6cb38c2316385b9ad53062486d229e9d56d574e2 +Subproject commit 7bd8ccab8383540a5a40eb0cbd9dd83d3abcfa6a From 610c44aa5acb68afc165258ac02caab3cd0b28cc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 8 Aug 2025 11:44:34 -0400 Subject: [PATCH 511/635] fix the formatting that broke loading files --- .../bowlerstudio/scripting/cadoodle/robot/MakeRobot.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index 02160603..d6f90d51 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -13,7 +13,7 @@ public class MakeRobot extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) - private List names = new ArrayList(); + private List assignedAsBase = new ArrayList(); //@Expose(serialize = true, deserialize = true) MobileBaseBuilder builder; @@ -27,7 +27,7 @@ public List process(List incoming) { try { getBuilder().build(); for(CSG c:incoming) { - for(String s:names) { + for(String s:assignedAsBase) { if(c.getName().contentEquals(s)) { c.setMobileBaseName(getName()); } @@ -55,13 +55,13 @@ public File getFile() throws NoSuchFileException { } public List getNames() { - return names; + return assignedAsBase; } public void setNames(List assignedAsBase) { if(assignedAsBase.size()==0) throw new RuntimeException("Can not create a robot without specifying a base"); - this.names = assignedAsBase; + this.assignedAsBase = assignedAsBase; } /** From 2c70d1a59d8170a87d6a6317b9ecf1a18c010da9 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 09:13:39 -0400 Subject: [PATCH 512/635] remove redundant object dupication --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index a053e5c6..0d74c4a3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -373,7 +373,6 @@ public void run() { private void process(CaDoodleOperation op) { op.setCaDoodleFile(this); - op.setRobots(getRobots()); List process = op.process(getCurrentState()); if(MakeRobot.class.isInstance(op)) { MakeRobot mr = (MakeRobot)op; From 2a26606f0778aafd464dd747a2fa127b75352192 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 09:14:01 -0400 Subject: [PATCH 513/635] remove redundant object, reference the source --- .../scripting/cadoodle/CaDoodleOperation.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index e715d592..f6de810a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -9,7 +9,6 @@ import eu.mihosoft.vrl.v3d.CSG; public abstract class CaDoodleOperation { - private HashMap robots; private CaDoodleFile cf = null; public abstract String getType(); public abstract List process(List incoming); @@ -29,7 +28,7 @@ public void setCaDoodleFile(CaDoodleFile cf) { * @return the robots */ public HashMap getRobots() { - return robots; + return cf.getRobots(); } public String getBuilder(List selected, List state) { @@ -40,7 +39,7 @@ public String getBuilder(List selected, List state) { if(s.contentEquals(c.getName())) { Optional mobileBaseName= c.getMobileBaseName(); if(mobileBaseName.isPresent()) { - MobileBaseBuilder b = robots.get(mobileBaseName.get()); + MobileBaseBuilder b = getRobots().get(mobileBaseName.get()); if(b!=null) { return mobileBaseName.get(); } @@ -51,11 +50,4 @@ public String getBuilder(List selected, List state) { return null; } - /** - * @param robots the robots to set - */ - public void setRobots(HashMap robots) { - this.robots = robots; - } - } From 3ccf2e43e2e2d549516b1796976e5b891b1c0199 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 09:14:20 -0400 Subject: [PATCH 514/635] adding the button resources to the build --- .../bowlerstudio/creature/LimbOption.java | 111 +++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index d33b84c3..90959a69 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -1,10 +1,18 @@ package com.neuronrobotics.bowlerstudio.creature; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.delim; + +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; +import java.util.List; + +import javax.imageio.ImageIO; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -16,9 +24,23 @@ import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.reflect.TypeToken; +import com.neuronrobotics.bowlerstudio.BowlerKernel; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; +import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.FileUtil; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import javafx.embed.swing.SwingFXUtils; +import javafx.scene.image.Image; +import javafx.scene.paint.Color; public class LimbOption { @Expose(serialize = true, deserialize = true) @@ -35,6 +57,10 @@ public class LimbOption { ControllerFeatures consumes; @Expose(serialize = true, deserialize = true) ControllerFeatures provides; + public static final TransformNR LimbRotationOffset=new TransformNR(new RotationNR(0, 90, -90)); + + private CSG indicator; + private Image image; public DHParameterKinematics getLimb(String uniqueName) throws Exception { String xmlContent = ScriptingEngine.codeFromGit(url, file)[0]; @@ -68,7 +94,7 @@ public static ArrayList getOptions() @Override public String toString() { - return type + " " + name + " " + url + "/" + file + "\n\tConsumes:" + getConsumes() + "\n\tProvides:" + getProvides(); + return getType() + " " + getName() + " " + url + "/" + file + "\n\tConsumes:" + getConsumes() + "\n\tProvides:" + getProvides(); } public ControllerFeatures getConsumes() { @@ -78,4 +104,87 @@ public ControllerFeatures getConsumes() { public ControllerFeatures getProvides() { return provides; } + + public LimbType getType() { + return type; + } + + public String getName() { + return name; + } + + public void build(CaDoodleFile f) throws IOException { + String absolutePath = ScriptingEngine.getWorkspace().getAbsolutePath() + delim() + "uicache"; + File dir = new File(absolutePath); + if (!dir.exists()) + dir.mkdirs(); + File imageFile = new File(absolutePath + delim() + type + name + ".png"); + File stlFile = new File(absolutePath + delim() + type + name + ".stl"); + if (imageFile.exists() && stlFile.exists()) { + indicator = Vitamins.get(stlFile); + indicator=indicator.transformed(TransformFactory.nrToCSG(LimbRotationOffset)); + indicator.setColor(Color.WHITE); + image = new Image(imageFile.toURI().toString()); + return; + } + AddRobotLimb add = new AddRobotLimb().setLimb(this) + .setLocation(new TransformNR()); + add.setCaDoodleFile(f); + add.forceLoad=true; + MobileBaseBuilder value = new MobileBaseBuilder(Files.createTempDirectory(name + "-").toFile().getAbsolutePath(), "testfile"); + add.setBuilderName("tmp"); + add.getRobots().put("tmp", value); + List so = add.process(new ArrayList<>()); + add.getRobots().remove("tmp"); + for (CSG c : so) { + for (String s : c.getParameters()) { + CSGDatabase.delete(s); + } + } + BowlerKernel.runLater(() -> { + image = ThumbnailImage.get(so); + }); + while(image==null) { + try { + Thread.sleep(20); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + try { + BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null); + ImageIO.write(bufferedImage, "png", imageFile); + System.err.println("Thumbnail saved successfully to " + imageFile.getAbsolutePath()); + } catch (Exception e) { + // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + + // e.getMessage()); + e.printStackTrace(); + } + indicator = get(so.get(0)); + if (so.size() > 1) { + for(int i=1;i Date: Mon, 11 Aug 2025 09:15:17 -0400 Subject: [PATCH 515/635] allow building when the limb is used to make the button images and reference shapes --- .../bowlerstudio/creature/MobileBaseBuilder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index b1d35a45..a9a3237b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -414,7 +414,7 @@ public MobileBase build() throws Exception { //TODO add the channel mapping here kin.connect(); kin.zero(); - switch(limb.getLimb().type) { + switch(limb.getLimb().getType()) { case arm: case flap: case hand: @@ -431,7 +431,7 @@ public MobileBase build() throws Exception { mobileBase.getFixed().add(kin); break; default: - throw new RuntimeException("Unknown limb type in builder! "+limb.getLimb().type); + throw new RuntimeException("Unknown limb type in builder! "+limb.getLimb().getType()); } } } @@ -477,8 +477,11 @@ public ControllerFeatures getCapibilities() { return test; } public void addLimb(AddRobotLimb controller) { + addLimb(controller,false); + } + public void addLimb(AddRobotLimb controller, boolean forceLoad) { LimbOption consumes = controller.getLimb(); - if(!checkOptionSupported(consumes)) { + if(!checkOptionSupported(consumes) && !forceLoad) { throw new RuntimeException("Robot doesnt have enough resources to support "+controller.getLimb()); } if (!getLimmbs().contains(controller)) From 06fe85811902f673489840c4b12968835fbcf19c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 09:57:01 -0400 Subject: [PATCH 516/635] adding a limb name --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 7bd8ccab..36aa54a5 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 7bd8ccab8383540a5a40eb0cbd9dd83d3abcfa6a +Subproject commit 36aa54a5c1f68bb9981a040eb9c166f77c7273dc From 80f6a10cbbebc365429eff0fac4563ddad5bc6a1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 10:55:04 -0400 Subject: [PATCH 517/635] transfer the manipulator on a move --- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index dff37e7a..264c4c91 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -26,15 +26,11 @@ public class MoveCenter extends CaDoodleOperation{ public String getName() { if (name == null) { - setName(RandomStringFactory.generateRandomString()); + name=(RandomStringFactory.generateRandomString()); } return name; } - public void setName(String name) { - this.name = name; - } - @Override public String getType() { return "Move Center"; @@ -100,6 +96,7 @@ public List process(List incoming) { public ArrayList process(CSG incoming, int depth) { Transform nrToCSG2 = TransformFactory.nrToCSG(location); CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); + tmpToAdd.setManipulator(incoming.getManipulator()); ArrayList b = new ArrayList<>(); b.add(tmpToAdd); set(getName(), tmpToAdd, location); From 90887544c7cfb40c90d651eada2945bd56cd4eb8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 11:36:20 -0400 Subject: [PATCH 518/635] add affine to allign --- .../bowlerstudio/scripting/cadoodle/Allign.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java index d7b539ca..c781c9fc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Allign.java @@ -12,6 +12,7 @@ import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; +import javafx.scene.transform.Affine; public class Allign extends CaDoodleOperation{ @Expose (serialize = true, deserialize = true) @@ -64,19 +65,21 @@ public List process(List incoming) { throw new RuntimeException("Allign can not be initialized without bounds!"); } HashMap moves= new HashMap<>(); + HashMap objects = new HashMap(); for(String name :names) { for(CSG tmp:back) { if(!tmp.getName().contentEquals(name)) continue; - CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + objects.put(name, tmp); + CSG c = tmp.transformed(TransformFactory.nrToCSG(getWorkplane(tmp)).inverse()); TransformNR tf = performTransform(bounds2, c); moves.put(c.getName(),tf); } } for(String name:moves.keySet()) { - TransformNR wpinv = getWorkplane().inverse(); TransformNR nr = moves.get(name); - TransformNR wp = getWorkplane(); + TransformNR wp = getWorkplane(objects.get(name)); + TransformNR wpinv = wp.inverse(); TransformNR times = wp.times(nr.times(wpinv)); Transform tf = TransformFactory.nrToCSG(times); @@ -175,10 +178,12 @@ public Allign setAllignParams(Allignment X, Allignment Y,Allignment Z) { return this; } - public TransformNR getWorkplane() { + public TransformNR getWorkplane(CSG c) { if(workplane==null) workplane= new TransformNR(); - return workplane; + Affine af = c.getManipulator(); + TransformNR afNR = TransformFactory.affineToNr(af).inverse(); + return afNR.times(workplane); } public Allign setWorkplane(TransformNR workplane) { From cf89718a83e9e95f6cb5bf2d0d79ad1deb85ab97 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 11:36:36 -0400 Subject: [PATCH 519/635] add manipulator --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 088753c4..af02ee42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c).setManipulator(c.getManipulator()); b.setIsHide(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 4d6e9b97..cb990033 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c).setManipulator(c.getManipulator()); b.setIsHide(false); back.add(b); } From 9dca5a8218a2711cd473e963ef44b844384d8941 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 11:36:45 -0400 Subject: [PATCH 520/635] add manipulator to mirror --- JCSG | 2 +- .../scripting/cadoodle/Mirror.java | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/JCSG b/JCSG index 36aa54a5..f2cb2472 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 36aa54a5c1f68bb9981a040eb9c166f77c7273dc +Subproject commit f2cb247207e9ca628d5a47bbae7fb605596d51b2 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 7491ec40..3da6eb47 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -11,6 +11,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Transform; +import javafx.scene.transform.Affine; public class Mirror extends CaDoodleOperation { @Expose(serialize = true, deserialize = true) @@ -50,7 +51,9 @@ public List process(List incoming) { for (CSG csg : incoming) { if(!csg.getName().contentEquals(name)) continue; - CSG base = csg.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); +// if(csg.isNoScale()) +// continue; + CSG base = csg.transformed(TransformFactory.nrToCSG(getWorkplane(csg)).inverse()); Transform mirroringCenter = new Transform().movex(base.getCenterX()).movey(base.getCenterY()) .movez(base.getCenterZ()); Transform sc = new Transform(); @@ -67,12 +70,12 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, name, back, (incoming1, depth) -> { ArrayList b = new ArrayList<>(); - Transform inverse = TransformFactory.nrToCSG(getWorkplane()).inverse(); + Transform inverse = TransformFactory.nrToCSG(getWorkplane(incoming1)).inverse(); CSG t = incoming1.transformed(inverse); CSG centered = t.transformed(mirroringCenter.inverse()); centered = centered.transformed(scale); centered = centered.transformed(mirroringCenter); - Transform wp = TransformFactory.nrToCSG(getWorkplane()); + Transform wp = TransformFactory.nrToCSG(getWorkplane(incoming1)); centered = centered.transformed(wp); CSG tf = centered.setName(name).syncProperties(incoming1); sync(incoming1, tf); @@ -107,7 +110,7 @@ public List process(List incoming) { } private CSG mirror(CSG csg, String name) { - CSG t = csg.transformed(TransformFactory.nrToCSG(getWorkplane()).inverse()); + CSG t = csg.transformed(TransformFactory.nrToCSG(getWorkplane(csg)).inverse()); Transform mirroringCenter = new Transform().movex(t.getCenterX()).movex(t.getCenterY()).movez(t.getCenterZ()); CSG centered = t.transformed(mirroringCenter.inverse()); @@ -121,7 +124,7 @@ private CSG mirror(CSG csg, String name) { centered = centered.mirrorz(); } centered = centered.transformed(mirroringCenter); - centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane())); + centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane(csg))); return centered.setName(name).syncProperties(csg); } @@ -143,10 +146,12 @@ public Mirror setNames(List names) { return this; } - public TransformNR getWorkplane() { + public TransformNR getWorkplane(CSG c) { if (workplane == null) workplane = new TransformNR(); - return workplane; + Affine af = c.getManipulator(); + TransformNR afNR = TransformFactory.affineToNr(af).inverse(); + return afNR.times(workplane); } public Mirror setWorkplane(TransformNR workplane) { From 1ffb86b550b969c9978e8e23d3b390126d717c3e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 11:52:02 -0400 Subject: [PATCH 521/635] remove the setting of the maniulator and let the sync handle it --- JCSG | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 1 - .../neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/JCSG b/JCSG index f2cb2472..56f026a2 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit f2cb247207e9ca628d5a47bbae7fb605596d51b2 +Subproject commit 56f026a203079f5745210f73cc8452811765c717 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 0d74c4a3..3228ed99 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -632,7 +632,7 @@ private void storeResultInCache(CaDoodleOperation op, List process) { + " opperation! " + c.getName()); names.add(c.getName()); cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) - .setRegenerate(c.getRegenerate()).setManipulator(c.getManipulator())); + .setRegenerate(c.getRegenerate())); // cachedCopy.add(c); } cache.put(op, cachedCopy); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index af02ee42..088753c4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c).setManipulator(c.getManipulator()); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsHide(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 264c4c91..c29f8c4a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -96,7 +96,6 @@ public List process(List incoming) { public ArrayList process(CSG incoming, int depth) { Transform nrToCSG2 = TransformFactory.nrToCSG(location); CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); - tmpToAdd.setManipulator(incoming.getManipulator()); ArrayList b = new ArrayList<>(); b.add(tmpToAdd); set(getName(), tmpToAdd, location); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index cb990033..4d6e9b97 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c).setManipulator(c.getManipulator()); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); b.setIsHide(false); back.add(b); } From 39ab70b259f26cec6d7a170639b1ad4a3694a928 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 11:52:26 -0400 Subject: [PATCH 522/635] adding manipulator to the group operation to add items to the links --- .../bowlerstudio/scripting/cadoodle/Group.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 8a107a96..2c4ca558 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -8,10 +8,12 @@ import java.util.Optional; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.IParametric; import javafx.scene.paint.Color; +import javafx.scene.transform.Affine; public class Group extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) @@ -37,6 +39,7 @@ public List process(List incoming) { back.addAll(incoming); String mobileBase=null; boolean noscale=false; + Affine manip = null; for (CSG csg : incoming) { if (csg.isLock()) continue; @@ -53,12 +56,19 @@ public List process(List incoming) { continue;// skip grouping any item that is of a different mobile base; } } + if(csg.hasManipulator()) + manip=csg.getManipulator(); replace.add(csg); - CSG c = csg.clone().syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + CSG clone = csg.clone(); + if(csg.hasManipulator()) { + clone=clone.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(manip))); + } + CSG c = clone.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); if (csg.isHole()) { holes.add(c); } else solids.add(c); + c.addGroupMembership(getGroupID()); back.add(c); } @@ -101,6 +111,10 @@ public List process(List incoming) { result.setIsHole(false); result.setColor(c); } + if(manip!=null) { + result=result.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(manip).inverse())); + result.setManipulator(manip); + } if(mobileBase!=null) result.setMobileBaseName(mobileBase); HashMap mapOfparametrics = result.getMapOfparametrics(); From e10a04810a7e53bbe1cab67681d2580e036af301 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 14:31:09 -0400 Subject: [PATCH 523/635] adding a lock feature to th emanipulator --- .../neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 24e6a423..d2a1bec2 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -45,6 +45,7 @@ private enum DragState { } private DragState state = DragState.IDLE; + private boolean resizeAllowed=true; public void addEventListener(EventHandler r) { if (eventListeners.contains(r)) @@ -171,6 +172,7 @@ private void release(MouseEvent event) { } private void dragged(MouseEvent event, MouseEvent event2) { + if(resizeAllowed) if(state==DragState.Dragging) { getUi().runLater(() -> { setDragging(event); @@ -354,4 +356,8 @@ public void setFrameOfReference(IFrameProvider frameOfReference) { this.frameOfReference = frameOfReference; } + public void setUnlocked(boolean resizeAllowed) { + this.resizeAllowed = resizeAllowed; + } + } From a7a106e80b54bc18f0687bc081fb0687110b9b2c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 14:48:57 -0400 Subject: [PATCH 524/635] adding the nomove to the group operation --- JCSG | 2 +- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 56f026a2..ea3ec004 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 56f026a203079f5745210f73cc8452811765c717 +Subproject commit ea3ec00412f2710504d03ea33a9be1f7f7f38ac1 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 2c4ca558..c51e4a24 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -40,6 +40,7 @@ public List process(List incoming) { String mobileBase=null; boolean noscale=false; Affine manip = null; + boolean nomove=false; for (CSG csg : incoming) { if (csg.isLock()) continue; @@ -48,6 +49,8 @@ public List process(List incoming) { if (name.contentEquals(csg.getName())) { if(csg.isNoScale()) noscale=true; + if(csg.isMotionLock()) + nomove=true; Optional mobileBaseName = csg.getMobileBaseName(); if(mobileBaseName.isPresent()) { if(mobileBase==null) @@ -123,6 +126,7 @@ public List process(List incoming) { result.addIsGroupResult(getGroupID()); result.setName(getGroupID()); result.setNoScale(noscale); + result.setIsMotionLock(nomove); result.setIsAlwaysShow(false); namesAdded.add(result.getName()); back.add(result); From f196f800d609831e9270d97589d5110741e5d78f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 15:05:40 -0400 Subject: [PATCH 525/635] make sure to preserver the unmoved affine supported object for ungrouping consistancy --- .../bowlerstudio/scripting/cadoodle/Group.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index c51e4a24..42d26e80 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -63,17 +63,20 @@ public List process(List incoming) { manip=csg.getManipulator(); replace.add(csg); CSG clone = csg.clone(); + + CSG c = clone.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + c.addGroupMembership(getGroupID()); + back.add(c); if(csg.hasManipulator()) { - clone=clone.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(manip))); + c=c.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(manip))) + .syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + c.addGroupMembership(getGroupID()); } - CSG c = clone.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); if (csg.isHole()) { holes.add(c); } else solids.add(c); - - c.addGroupMembership(getGroupID()); - back.add(c); + } } } From 273ee65d799e9d80fdb1940060abb9481e9e7abe Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 15:49:37 -0400 Subject: [PATCH 526/635] reject and more on a locked object --- .../bowlerstudio/scripting/cadoodle/MoveCenter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index c29f8c4a..18436c3b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -94,7 +94,11 @@ public List process(List incoming) { CaDoodleFile.applyToAllConstituantElements(false, names, back, new ICadoodleRecursiveEvent() { @Override public ArrayList process(CSG incoming, int depth) { + Transform nrToCSG2 = TransformFactory.nrToCSG(location); + if(incoming.isMotionLock()) { + nrToCSG2=new Transform(); + } CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); ArrayList b = new ArrayList<>(); b.add(tmpToAdd); From c08e0a7a90649f21db229ba42ac9b2947c079531 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 16:32:25 -0400 Subject: [PATCH 527/635] direct import? --- .../cadoodle/CaDoodleJsonOperationAdapterFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 2c6c5aed..1b774ead 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -4,7 +4,9 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.*; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; import java.io.IOException; import java.util.HashMap; From ca6ee3bcc8fc00dbeccb758d34a5a0e795c84557 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 16:37:06 -0400 Subject: [PATCH 528/635] fixig the doodle folder ignore that was preventing the add robot and controller from getting added --- .gitignore | 2 +- .../cadoodle/robot/AddRobotController.java | 116 ++++++++++++++++++ .../cadoodle/robot/AddRobotLimb.java | 107 ++++++++++++++++ 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java diff --git a/.gitignore b/.gitignore index cc5188e6..57e9b71b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ physicsTest /test*.stl /test.blend1 /test.* -*doodle +/doodle/ diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java new file mode 100644 index 00000000..755d3172 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java @@ -0,0 +1,116 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; + +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.NoSuchFileException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.creature.ControllerOption; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; +import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Group; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.MoveCenter; +import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.Transform; + +public class AddRobotController extends AbstractAddFrom { + @Expose(serialize = true, deserialize = true) + private String builderName; + @Expose(serialize = true, deserialize = true) + private ControllerOption controller; + @Expose(serialize = true, deserialize = true) + private TransformNR location = null; + @Expose(serialize = true, deserialize = true) + private List names; + + @Override + public void pruneCleanup() { + if (builderName != null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + builder.removeController(this); + } + } + + @Override + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(""); + } + + @Override + public String getType() { + return "AddRobotController"; + } + + public ArrayList getVitamins(String prefix){ + return controller.getVitamins(location,prefix); + } + + public AddRobotController setNames(List names) { + this.names = names; + return this; + } + + @Override + public List process(List incoming) { + nameIndex = 0; + ArrayList back = new ArrayList(); + back.addAll(incoming); + builderName = getBuilder(names, incoming); + try { + controller.runLinkLoader(); + } catch (FileNotFoundException e) { + } + for (int i = 0; i < controller.getVitaminNumber(); i++) { + CSG csg = controller.getVitaminCSG(i).cloneShallow(); + TransformNR offset = getLocation().times(controller.getVitaminPose(i)); + Transform nrToCSG = TransformFactory.nrToCSG(offset); + String orderedName = getOrderedName(); + csg.setIsHole(true); + csg.setNoScale(true); + csg.setIsAlwaysShow(true); + if (getBuilderName() != null) { + csg.setMobileBaseName(getBuilderName()); + } + CSG tmp = csg.transformed(nrToCSG).syncProperties(csg).setRegenerate(csg.getRegenerate()) + .setName(orderedName); + back.add(tmp); + MoveCenter.set(getName(), tmp, nrToCSG); + } + if(builderName!=null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + builder.addController(this); + } + return back; + } + + public ControllerOption getController() { + return controller; + } + + public AddRobotController setController(ControllerOption controller) { + this.controller = controller; + return this; + } + + public TransformNR getLocation() { + if (location == null) + location = new TransformNR(); + return location; + } + + public AddRobotController setLocation(TransformNR location) { + this.location = location; + return this; + } + + public String getBuilderName() { + return builderName; + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java new file mode 100644 index 00000000..0fcef2d4 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java @@ -0,0 +1,107 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; + +import java.io.File; +import java.nio.file.NoSuchFileException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.creature.ControllerOption; +import com.neuronrobotics.bowlerstudio.creature.LimbOption; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.Group; +import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; +import com.neuronrobotics.sdk.addons.kinematics.MobileBase; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; + +import eu.mihosoft.vrl.v3d.CSG; + +public class AddRobotLimb extends AbstractAddFrom{ + @Expose(serialize = true, deserialize = true) + private String builderName; + @Expose(serialize = true, deserialize = true) + private LimbOption limb; + @Expose(serialize = true, deserialize = true) + private TransformNR location = null; + @Expose(serialize = true, deserialize = true) + private List names; + public boolean forceLoad = false; + @Override + public void pruneCleanup() { + if (getBuilderName() != null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + builder.removeLimb(this); + } + } + @Override + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(""); + } + + @Override + public String getType() { + return "AddRobotLimb"; + } + + @Override + public List process(List incoming) { + nameIndex=0; + if(builderName==null) + setBuilderName(getBuilder(names, incoming)); + ArrayList back = new ArrayList(); + back.addAll(incoming); + if(getBuilderName()!=null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + builder.addLimb(this,forceLoad); + try { + builder.build(); + } catch (Exception e) { + e.printStackTrace(); + } + + DHParameterKinematics newLimb = builder.getMobileBase().getLimbByName(getName()); + if(newLimb==null) + throw new RuntimeException("Failed to create a limb!"); + MobileBaseCadManager manager=builder.getCadManager(); + ArrayList limbCad = manager.generateCad(newLimb); + for(CSG c:limbCad) { + c.setName(getOrderedName()); + c.setLimbName(name); + c.setMobileBaseName(getBuilderName()); + c.setNoScale(true); + c.setIsMotionLock(true); + back.add(c); + } + manager.render(); + } + return back; + } + public AddRobotLimb setLimb(LimbOption o) { + limb = o; + return this; + } + public AddRobotLimb setNames(List names) { + this.names = names; + return this; + } + public LimbOption getLimb() { + return limb; + } + public AddRobotLimb setLocation(TransformNR location) { + this.location = location; + return this; + } + public TransformNR getLocation() { + if(location==null) + location=new TransformNR(); + return location; + } + public String getBuilderName() { + return builderName; + } + public void setBuilderName(String builderName) { + this.builderName = builderName; + } +} From ecf6b123711c790bd824e9275c75c0de83938351 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 11 Aug 2025 16:55:19 -0400 Subject: [PATCH 529/635] make sure any object that is grouped with an object in a group already must then move --- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 42d26e80..07e82425 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -49,7 +49,7 @@ public List process(List incoming) { if (name.contentEquals(csg.getName())) { if(csg.isNoScale()) noscale=true; - if(csg.isMotionLock()) + if(csg.isMotionLock() || csg.isInGroup()) nomove=true; Optional mobileBaseName = csg.getMobileBaseName(); if(mobileBaseName.isPresent()) { From a545032f74b376a028bb981510fd3e1e0d4ac5b2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 13:49:12 -0400 Subject: [PATCH 530/635] nerf CL on windows --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index ea3ec004..ef698686 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit ea3ec00412f2710504d03ea33a9be1f7f7f38ac1 +Subproject commit ef698686343486eb6a0b88c24f938f1b6c9ae130 From cc25ba0ec3ae43d0ca98e664c6efe4d1c48da0a4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 14:37:53 -0400 Subject: [PATCH 531/635] refactor --- .../CaDoodleJsonOperationAdapterFactory.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 1b774ead..87a1f826 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -7,6 +7,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.ModifyLimb; import java.io.IOException; import java.util.HashMap; @@ -17,30 +18,32 @@ public class CaDoodleJsonOperationAdapterFactory implements TypeAdapterFactory { private final Map, String> classRegistry = new HashMap<>(); public CaDoodleJsonOperationAdapterFactory() { - registerType("AddFromFile", AddFromFile.class); - registerType("AddFromScript", AddFromScript.class); - registerType("AddRobotController", AddRobotController.class); - registerType("AddRobotLimb", AddRobotLimb.class); - registerType("Allign", Allign.class); - registerType("Delete", Delete.class); - registerType("Group", Group.class); - registerType("Hide", Hide.class); - registerType("Lock", Lock.class); - registerType("MakeRobot", MakeRobot.class); - registerType("Mirror", Mirror.class); - registerType("MoveCenter", MoveCenter.class); - registerType("Paste", Paste.class); - registerType("Resize", Resize.class); - registerType("Show", Show.class); - registerType("ToHole", ToHole.class); - registerType("ToSolid", ToSolid.class); - registerType("UnGroup", UnGroup.class); - registerType("UnLock", UnLock.class); - registerType("Sweep", Sweep.class); + registerType( AddFromFile.class); + registerType( AddFromScript.class); + registerType( AddRobotController.class); + registerType( AddRobotLimb.class); + registerType( Allign.class); + registerType( Delete.class); + registerType( Group.class); + registerType(Hide.class); + registerType(Lock.class); + registerType( MakeRobot.class); + registerType( Mirror.class); + registerType( ModifyLimb.class); + registerType( MoveCenter.class); + registerType( Paste.class); + registerType( Resize.class); + registerType( Show.class); + registerType(ToHole.class); + registerType( ToSolid.class); + registerType( UnGroup.class); + registerType( UnLock.class); + registerType( Sweep.class); } - private void registerType(String typeName, Class clazz) { + private void registerType(Class clazz) { + String typeName=clazz.getSimpleName(); typeRegistry.put(typeName, clazz); classRegistry.put(clazz, typeName); } From 71a9415ed9d99d958d7bb795c928a23195985dfc Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 14:38:06 -0400 Subject: [PATCH 532/635] Add a modify limb command --- .../scripting/cadoodle/robot/ModifyLimb.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java new file mode 100644 index 00000000..4076fb02 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -0,0 +1,28 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; + +import java.util.ArrayList; +import java.util.List; + +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleOperation; + +import eu.mihosoft.vrl.v3d.CSG; + +public class ModifyLimb extends CaDoodleOperation{ + + @Override + public String getType() { + return "ModifyLimb"; + } + + @Override + public List process(List incoming) { + + return incoming; + } + + @Override + public List getNamesAddedInThisOperation() { + return new ArrayList(); + } + +} From e48c02282a03774af1346ec7d045cba22d83da85 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 16:37:36 -0400 Subject: [PATCH 533/635] Adding modify limb code --- .../scripting/cadoodle/robot/ModifyLimb.java | 150 +++++++++++++++++- 1 file changed, 144 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index 4076fb02..29b7bf88 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -1,14 +1,62 @@ package com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot; +import java.io.File; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleOperation; +import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.creature.LimbOption; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; +import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; +import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; +import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; -public class ModifyLimb extends CaDoodleOperation{ - +public class ModifyLimb extends AbstractAddFrom{ + @Expose(serialize = true, deserialize = true) + String limbName; + @Expose(serialize = true, deserialize = true) + private TransformNR base = null; + @Expose(serialize = true, deserialize = true) + private TransformNR tip = null; + @Expose(serialize = true, deserialize = true) + private TransformNR elbow = null; + + @Expose(serialize = true, deserialize = true) + private TransformNR basePrevious = null; + @Expose(serialize = true, deserialize = true) + private TransformNR tipPrevious = null; + @Expose(serialize = true, deserialize = true) + private TransformNR elbowPrevious = null; + @Expose(serialize = true, deserialize = true) + private List names; + + private String builderName; + @Override + public void pruneCleanup() { + if (getBuilderName() != null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + base = basePrevious; + tip=tipPrevious; + elbow=elbowPrevious; + try { + builder.build(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + public String getBuilderName() { + return builderName; + } + public void setBuilderName(String builderName) { + this.builderName = builderName; + } @Override public String getType() { return "ModifyLimb"; @@ -16,13 +64,103 @@ public String getType() { @Override public List process(List incoming) { + if(names==null) + throw new RuntimeException("Names can not be null"); + nameIndex=0; + if(builderName==null) + setBuilderName(getBuilder(names, incoming)); + limbName = getLimbName(names, incoming); - return incoming; + ArrayList back = new ArrayList(); + back.addAll(incoming); + if(getBuilderName()!=null && limbName!=null) { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + builder.addModification(this); + try { + builder.build(); + } catch (Exception e) { + e.printStackTrace(); + } + + DHParameterKinematics newLimb = builder.getMobileBase().getLimbByName(limbName); + if(newLimb==null) + throw new RuntimeException("Failed to create a limb!"); + MobileBaseCadManager manager=builder.getCadManager(); + ArrayList limbCad = manager.generateCad(newLimb); + for(CSG c: incoming) { + Optional limbName2 = c.getLimbName(); + if(limbName2.isPresent()) + if(limbName2.get().contains(limbName)) { + back.remove(c); + } + } + for(CSG c:limbCad) { + c.setName(getOrderedName()); + c.setLimbName(limbName); + c.setMobileBaseName(getBuilderName()); + c.setNoScale(true); + c.setIsMotionLock(true); + back.add(c); + } + manager.render(); + }else { + throw new RuntimeException("Failed to find builder or limb "+limbName+" "+builderName); + } + return back; } @Override - public List getNamesAddedInThisOperation() { - return new ArrayList(); + public File getFile() throws NoSuchFileException { + throw new NoSuchFileException(""); + } + + /** + * @return the base + */ + public TransformNR getBase() { + return base; + } + + /** + * @param base the base to set + */ + public ModifyLimb setBase(TransformNR base) { + this.base = base; + return this; + } + + /** + * @return the tip + */ + public TransformNR getTip() { + return tip; + } + + /** + * @param tip the tip to set + */ + public ModifyLimb setTip(TransformNR tip) { + this.tip = tip; + return this; + } + + /** + * @return the elbow + */ + public TransformNR getElbow() { + return elbow; + } + + /** + * @param elbow the elbow to set + */ + public ModifyLimb setElbow(TransformNR elbow) { + this.elbow = elbow; + return this; + } + public ModifyLimb setNames(List names) { + this.names = names; + return this; } } From 36dadc086d20e23af01b92308e1f2f5fe221f859 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 16:37:52 -0400 Subject: [PATCH 534/635] remove dead code --- .../bowlerstudio/scripting/cadoodle/AbstractAddFrom.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java index eb271003..3f454eb2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AbstractAddFrom.java @@ -36,9 +36,6 @@ public String getName() { // } public String getOrderedName() { - if(getName()==null) { - name=(RandomStringFactory.generateRandomString()); - } String result= getName(); if(nameIndex!=0){ result+= "_"+nameIndex; From 53da87a198fe7fb79d9e6a8f84884eca891f0075 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 16:38:04 -0400 Subject: [PATCH 535/635] add search for limmbs --- .../scripting/cadoodle/CaDoodleOperation.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index f6de810a..ddd465ca 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -49,5 +49,23 @@ public String getBuilder(List selected, List state) { } return null; } - + public String getLimbName(List selected, List state) { + if(selected==null) + return null; + for(CSG c: state) { + for(String s:selected) { + if(s.contentEquals(c.getName())) { + Optional limbNameOption= c.getLimbName(); + if(limbNameOption.isPresent()) { + MobileBaseBuilder b = getRobots().get(limbNameOption.get()); + if(b!=null) { + if(b.getMobileBase().getLimbByName(limbNameOption.get())!=null) + return limbNameOption.get(); + } + } + } + } + } + return null; + } } From b4978e2948d3a995e51d37e0f33ed4907b71f368 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 12 Aug 2025 16:38:29 -0400 Subject: [PATCH 536/635] Add and remove modification object --- .../bowlerstudio/creature/MobileBaseBuilder.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index a9a3237b..03c7509d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -4,6 +4,7 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.ModifyLimb; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; @@ -30,7 +31,7 @@ public class MobileBaseBuilder { ArrayList controllers = new ArrayList(); ArrayList limbs = new ArrayList(); - + ArrayList mods = new ArrayList(); private MobileBase mobileBase; private String gitURL; private String xmlName = null; @@ -491,7 +492,14 @@ public void addLimb(AddRobotLimb controller, boolean forceLoad) { public boolean checkOptionSupported(LimbOption consumes) { return getCapibilities().check(consumes.consumes); } - + public void addModification(ModifyLimb modifyLimb) { + if(!mods.contains(modifyLimb)) + mods.add(modifyLimb); + } + public void removeModification(ModifyLimb modifyLimb) { + if(mods.contains(modifyLimb)) + mods.remove(modifyLimb); + } public void removeLimb(AddRobotLimb controller) { if (getLimmbs().contains(controller)) getLimmbs().remove(controller); @@ -509,4 +517,6 @@ public MobileBaseCadManager getCadManager() { return mobileBaseCadManager; } + + } \ No newline at end of file From b23de4f655fffb27506b6608945444385a28bfaf Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 10:55:38 -0400 Subject: [PATCH 537/635] adding the undo op interface --- .../scripting/cadoodle/ICadoodleOperationUndo.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleOperationUndo.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleOperationUndo.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleOperationUndo.java new file mode 100644 index 00000000..4f25890d --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICadoodleOperationUndo.java @@ -0,0 +1,6 @@ +package com.neuronrobotics.bowlerstudio.scripting.cadoodle; + +public interface ICadoodleOperationUndo { + public void undo(); + public void redo(); +} From e7f97f4efd2fd012ffbdddf5e2900440c082dbb2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 10:56:06 -0400 Subject: [PATCH 538/635] use the undo operation interface in the forward and back operations --- .../scripting/cadoodle/CaDoodleFile.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 3228ed99..207085cf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -685,9 +685,25 @@ private CSG cloneCSG(CSG dyingCSG) { } public void back() { + CaDoodleOperation op = getCurrentOpperation(); if (isBackAvailible()) setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); + if(ICadoodleOperationUndo.class.isInstance(op)) { + ICadoodleOperationUndo un = (ICadoodleOperationUndo)op; + un.undo(); + } + fireSaveSuggestion(); + } + public void forward() { + if (isForwardAvailible()) + setCurrentIndex(getCurrentIndex() + 1); + updateCurrentFromCache(); + CaDoodleOperation op = getCurrentOpperation(); + if(ICadoodleOperationUndo.class.isInstance(op)) { + ICadoodleOperationUndo un = (ICadoodleOperationUndo)op; + un.redo(); + } fireSaveSuggestion(); } @@ -719,13 +735,6 @@ public CaDoodleOperation getCurrentOpperation() { return getOpperations().get(getCurrentIndex() - 1); } - public void forward() { - if (isForwardAvailible()) - setCurrentIndex(getCurrentIndex() + 1); - updateCurrentFromCache(); - fireSaveSuggestion(); - } - public boolean isForwardAvailible() { return getCurrentIndex() < getOpperations().size(); } From ab9a39447b77a406df7ce6f7b6ff870589692c13 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 11:35:07 -0400 Subject: [PATCH 539/635] add the undo/redo options into the index skip --- .../scripting/cadoodle/CaDoodleFile.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 207085cf..2ecd913b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -712,7 +712,27 @@ public void moveToOpIndex(int newIndex) { return; if (newIndex < 0) return; - setCurrentIndex(newIndex + 1); + int ci =getCurrentIndex(); + int ni=newIndex + 1; + boolean forward= ci Date: Thu, 14 Aug 2025 11:35:27 -0400 Subject: [PATCH 540/635] add basic mod operations to builder --- .../bowlerstudio/creature/MobileBaseBuilder.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 03c7509d..021d7995 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -436,6 +436,14 @@ public MobileBase build() throws Exception { } } } + for(int i=0;i Date: Thu, 14 Aug 2025 11:35:48 -0400 Subject: [PATCH 541/635] add the undo/redo interface --- .../scripting/cadoodle/robot/ModifyLimb.java | 138 ++++++++++++------ 1 file changed, 91 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index 29b7bf88..95f26875 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -11,12 +11,13 @@ import com.neuronrobotics.bowlerstudio.creature.MobileBaseBuilder; import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.AbstractAddFrom; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.ICadoodleOperationUndo; import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; -public class ModifyLimb extends AbstractAddFrom{ +public class ModifyLimb extends AbstractAddFrom implements ICadoodleOperationUndo { @Expose(serialize = true, deserialize = true) String limbName; @Expose(serialize = true, deserialize = true) @@ -25,7 +26,10 @@ public class ModifyLimb extends AbstractAddFrom{ private TransformNR tip = null; @Expose(serialize = true, deserialize = true) private TransformNR elbow = null; - + + @Expose(serialize = true, deserialize = true) + boolean undo = false; + @Expose(serialize = true, deserialize = true) private TransformNR basePrevious = null; @Expose(serialize = true, deserialize = true) @@ -34,29 +38,27 @@ public class ModifyLimb extends AbstractAddFrom{ private TransformNR elbowPrevious = null; @Expose(serialize = true, deserialize = true) private List names; - + private String builderName; + private DHParameterKinematics newLimb; + @Override public void pruneCleanup() { if (getBuilderName() != null) { MobileBaseBuilder builder = getRobots().get(getBuilderName()); - base = basePrevious; - tip=tipPrevious; - elbow=elbowPrevious; - try { - builder.build(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + undo(); + builder.removeModification(this); } } + public String getBuilderName() { return builderName; } + public void setBuilderName(String builderName) { this.builderName = builderName; } + @Override public String getType() { return "ModifyLimb"; @@ -64,47 +66,45 @@ public String getType() { @Override public List process(List incoming) { - if(names==null) + if (names == null) throw new RuntimeException("Names can not be null"); - nameIndex=0; - if(builderName==null) + nameIndex = 0; + if (builderName == null) setBuilderName(getBuilder(names, incoming)); - limbName = getLimbName(names, incoming); - + limbName = getLimbName(names, incoming); + ArrayList back = new ArrayList(); back.addAll(incoming); - if(getBuilderName()!=null && limbName!=null) { + if (getBuilderName() != null && limbName != null) { MobileBaseBuilder builder = getRobots().get(getBuilderName()); builder.addModification(this); - try { - builder.build(); - } catch (Exception e) { - e.printStackTrace(); - } - - DHParameterKinematics newLimb = builder.getMobileBase().getLimbByName(limbName); - if(newLimb==null) + if (getLimb() == null) + setLimb(builder.getMobileBase().getLimbByName(limbName)); + if (getLimb() == null) throw new RuntimeException("Failed to create a limb!"); - MobileBaseCadManager manager=builder.getCadManager(); - ArrayList limbCad = manager.generateCad(newLimb); - for(CSG c: incoming) { - Optional limbName2 = c.getLimbName(); - if(limbName2.isPresent()) - if(limbName2.get().contains(limbName)) { - back.remove(c); - } - } - for(CSG c:limbCad) { - c.setName(getOrderedName()); - c.setLimbName(limbName); - c.setMobileBaseName(getBuilderName()); - c.setNoScale(true); - c.setIsMotionLock(true); - back.add(c); + redo(); + MobileBaseCadManager manager = builder.getCadManager(); + if (elbow != null) { + ArrayList limbCad = manager.generateCad(getLimb()); + for (CSG c : incoming) { + Optional limbName2 = c.getLimbName(); + if (limbName2.isPresent()) + if (limbName2.get().contains(limbName)) { + back.remove(c); + } + } + for (CSG c : limbCad) { + c.setName(getOrderedName()); + c.setLimbName(limbName); + c.setMobileBaseName(getBuilderName()); + c.setNoScale(true); + c.setIsMotionLock(true); + back.add(c); + } } manager.render(); - }else { - throw new RuntimeException("Failed to find builder or limb "+limbName+" "+builderName); + } else { + throw new RuntimeException("Failed to find builder or limb " + limbName + " " + builderName); } return back; } @@ -118,7 +118,7 @@ public File getFile() throws NoSuchFileException { * @return the base */ public TransformNR getBase() { - return base; + return undo ? base : basePrevious; } /** @@ -133,7 +133,7 @@ public ModifyLimb setBase(TransformNR base) { * @return the tip */ public TransformNR getTip() { - return tip; + return undo ? tip : tipPrevious; } /** @@ -148,7 +148,7 @@ public ModifyLimb setTip(TransformNR tip) { * @return the elbow */ public TransformNR getElbow() { - return elbow; + return undo ? elbow : elbowPrevious; } /** @@ -158,9 +158,53 @@ public ModifyLimb setElbow(TransformNR elbow) { this.elbow = elbow; return this; } + public ModifyLimb setNames(List names) { this.names = names; return this; } + /** + * @return the newLimb + */ + public DHParameterKinematics getLimb() { + return newLimb; + } + + /** + * @param newLimb the newLimb to set + */ + public void setLimb(DHParameterKinematics newLimb) { + this.newLimb = newLimb; + basePrevious = newLimb.getRobotToFiducialTransform(); + tipPrevious = newLimb.getCurrentPoseTarget(); + + } + + @Override + public void undo() { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + undo = true; + System.out.println("Undo ModifyLimb"); + try { + builder.build(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void redo() { + MobileBaseBuilder builder = getRobots().get(getBuilderName()); + undo = false; + System.out.println("Redo ModifyLimb"); + try { + builder.build(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } From 3d3c187f1c895d6e15df1192890e0d00f7cf56b2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 12:11:13 -0400 Subject: [PATCH 542/635] mods --- .../bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index 95f26875..4930c308 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -185,7 +185,7 @@ public void setLimb(DHParameterKinematics newLimb) { public void undo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); undo = true; - System.out.println("Undo ModifyLimb"); + //System.out.println("Undo ModifyLimb"); try { builder.build(); } catch (Exception e) { @@ -198,7 +198,7 @@ public void undo() { public void redo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); undo = false; - System.out.println("Redo ModifyLimb"); + //System.out.println("Redo ModifyLimb"); try { builder.build(); } catch (Exception e) { From dc9d8a9072760a3a9ee0526367c1d156efe97cae Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 12:31:46 -0400 Subject: [PATCH 543/635] adding a transform helper --- .../bowlerstudio/physics/TransformFactory.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java index caa193cb..8cf94cbe 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/physics/TransformFactory.java @@ -8,6 +8,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import eu.mihosoft.vrl.v3d.Transform; import javafx.application.Platform; import javafx.scene.transform.Affine; @@ -189,4 +190,8 @@ public static TransformNR csgToNR(eu.mihosoft.vrl.v3d.Transform csg) { return new TransformNR(t1.x, t1.y, t1.z, new RotationNR(q1.w, q1.x, q1.y, q1.z)); } + public static Transform affineToCSG(Affine manipulator) { + return nrToCSG(affineToNr(manipulator)); + } + } From cfcea792ee9b4daacc8662c13fe031905e64b8b0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 19:02:20 -0400 Subject: [PATCH 544/635] make sure the location is a copy --- .../bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java index 0fcef2d4..e1fcba9f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java @@ -90,7 +90,7 @@ public LimbOption getLimb() { return limb; } public AddRobotLimb setLocation(TransformNR location) { - this.location = location; + this.location = location.copy(); return this; } public TransformNR getLocation() { From 37c8dcbd07ed75f5201c1fc93eab7b8970805d93 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 19:02:49 -0400 Subject: [PATCH 545/635] correct tne name search to get the mobile base builder --- .../bowlerstudio/scripting/cadoodle/CaDoodleOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java index ddd465ca..7a6443c0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleOperation.java @@ -57,7 +57,7 @@ public String getLimbName(List selected, List state) { if(s.contentEquals(c.getName())) { Optional limbNameOption= c.getLimbName(); if(limbNameOption.isPresent()) { - MobileBaseBuilder b = getRobots().get(limbNameOption.get()); + MobileBaseBuilder b = getRobots().get(c.getMobileBaseName().get()); if(b!=null) { if(b.getMobileBase().getLimbByName(limbNameOption.get())!=null) return limbNameOption.get(); From 781dbf97c9bc0ce70a5489dd7baed191d5f0daac Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 19:03:08 -0400 Subject: [PATCH 546/635] public the global --- .../com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index d2a1bec2..5831e0c6 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -257,7 +257,7 @@ private double round(double in) { return Math.round(in / increment) * increment; } - private void setGlobal(TransformNR global) { + public void setGlobal(TransformNR global) { // newx = global.getX(); // newy = global.getY(); // newz = global.getZ(); From 8feeaef7c109ba245796cf9d56eb9f56bfb6040f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 19:03:27 -0400 Subject: [PATCH 547/635] set the limb root to copy --- .../bowlerstudio/creature/MobileBaseBuilder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 021d7995..e13972c6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -411,7 +411,7 @@ public MobileBase build() throws Exception { if(mobileBase.getLimbByName(limb.getName())==null) { TransformNR location = limb.getLocation(); DHParameterKinematics kin = limb.getLimb().getLimb(limb.getName()); - kin.setRobotToFiducialTransform(location); + kin.setRobotToFiducialTransform(location.copy()); //TODO add the channel mapping here kin.connect(); kin.zero(); @@ -441,7 +441,9 @@ public MobileBase build() throws Exception { DHParameterKinematics kin=mod.getLimb(); if(kin==null) continue; - kin.setRobotToFiducialTransform(mod.getBase()); + TransformNR base = mod.getBase(); + System.out.println("Base set to "+base); + kin.setRobotToFiducialTransform(base); kin.setDesiredTaskSpaceTransform(mod.getTip(), 0); } getCadManager().render(); From a828b31584b6bcf04553cef954634db61386498b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 14 Aug 2025 19:04:12 -0400 Subject: [PATCH 548/635] Updat eth modify limb to work --- .../scripting/cadoodle/robot/ModifyLimb.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index 4930c308..9a7bab65 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -104,7 +104,7 @@ public List process(List incoming) { } manager.render(); } else { - throw new RuntimeException("Failed to find builder or limb " + limbName + " " + builderName); + throw new RuntimeException("Failed to find limb: " + limbName + " or builder: " + builderName); } return back; } @@ -118,7 +118,7 @@ public File getFile() throws NoSuchFileException { * @return the base */ public TransformNR getBase() { - return undo ? base : basePrevious; + return !isUndo() ? base : basePrevious; } /** @@ -133,7 +133,7 @@ public ModifyLimb setBase(TransformNR base) { * @return the tip */ public TransformNR getTip() { - return undo ? tip : tipPrevious; + return !isUndo() ? tip : tipPrevious; } /** @@ -148,7 +148,7 @@ public ModifyLimb setTip(TransformNR tip) { * @return the elbow */ public TransformNR getElbow() { - return undo ? elbow : elbowPrevious; + return !isUndo() ? elbow : elbowPrevious; } /** @@ -174,17 +174,17 @@ public DHParameterKinematics getLimb() { /** * @param newLimb the newLimb to set */ - public void setLimb(DHParameterKinematics newLimb) { + public ModifyLimb setLimb(DHParameterKinematics newLimb) { this.newLimb = newLimb; - basePrevious = newLimb.getRobotToFiducialTransform(); - tipPrevious = newLimb.getCurrentPoseTarget(); - + basePrevious = newLimb.getRobotToFiducialTransform().copy(); + tipPrevious = newLimb.getCurrentTaskSpaceTransform().copy(); + return this; } @Override public void undo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); - undo = true; + setUndo(true); //System.out.println("Undo ModifyLimb"); try { builder.build(); @@ -197,7 +197,7 @@ public void undo() { @Override public void redo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); - undo = false; + setUndo(false); //System.out.println("Redo ModifyLimb"); try { builder.build(); @@ -207,4 +207,18 @@ public void redo() { } } + /** + * @return the undo + */ + public boolean isUndo() { + return undo; + } + + /** + * @param undo the undo to set + */ + public void setUndo(boolean undo) { + this.undo = undo; + } + } From c6099f076621707ad3455487dc81618b9c362c3e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 16 Aug 2025 10:24:21 -0400 Subject: [PATCH 549/635] add a reset method to the manipulation --- .../bowlerkernel/Bezier3d/Manipulation.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index 5831e0c6..a1399253 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -76,6 +76,7 @@ private void fireMove(TransformNR trans, MouseEvent event2) { for (Manipulation R : dependants) { R.performMove(trans,event2); } + //System.out.println("Mouse event "+event2.getEventType()); for (EventHandler R : eventListeners) { R.handle(event2); } @@ -276,7 +277,15 @@ public static IInteractiveUIElementProvider getUi() { public static void setUi(IInteractiveUIElementProvider ui) { Manipulation.ui = ui; } - + public void reset() { + newx = 0; + newy = 0; + newz = 0; + getGlobalPose().setX(0); + getGlobalPose().setY(0); + getGlobalPose().setZ(0); + setGlobal(new TransformNR(0, 0, 0, new RotationNR())); + } public void set(double newX, double newY, double newZ) { newx = newX; newy = newY; @@ -302,11 +311,6 @@ public void setInReferenceFrame(double newX, double newY, double newZ) { } } - public void reset() { - // Auto-generated method stub - - } - public TransformNR getGlobalPose() { return globalPose; } From 5ff53765ad35c57b803e904aea112a463adfdfb2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 16 Aug 2025 10:24:30 -0400 Subject: [PATCH 550/635] prit adding op --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 2ecd913b..b994a6f0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -420,6 +420,7 @@ public void run() { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); CaDoodleOperation op = toProcess.remove(0); + System.out.println("Adding Operation "+op); if (getCurrentIndex() != getOpperations().size()) { try { fireRegenerateStart(); From 1deae8d1d96485cb66cd094eb144b04613a41cce Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 16 Aug 2025 10:24:38 -0400 Subject: [PATCH 551/635] formatting --- .../creature/MobileBaseBuilder.java | 76 +++++++++++-------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index e13972c6..9af9958d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -391,31 +391,31 @@ public File getFile() throws Exception { } public MobileBase build() throws Exception { - if(!mobileBase.isAvailable()) + if (!mobileBase.isAvailable()) mobileBase.connect(); - String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName() ; + String filename = (xmlName != null) ? xmlName : mobileBase.getScriptingName(); mobileBase.setGitSelfSource(new String[] { gitURL, filename }); for (int i = 0; i < controllers.size(); i++) { AddRobotController con = controllers.get(i); - for(VitaminLocation l:con.getVitamins(con.getName()+"_"+i)) { + for (VitaminLocation l : con.getVitamins(con.getName() + "_" + i)) { try { - if(!mobileBase.hasVitamin(l)) + if (!mobileBase.hasVitamin(l)) mobileBase.addVitamin(l); - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } } - for(int i=0;i toRemove = new ArrayList(); + for (int i = 0; i < mods.size(); i++) { + ModifyLimb mod = mods.get(i); + DHParameterKinematics kin = mod.getLimb(); + if (kin == null) continue; + TransformNR base = mod.getBase(); - System.out.println("Base set to "+base); - kin.setRobotToFiducialTransform(base); - kin.setDesiredTaskSpaceTransform(mod.getTip(), 0); + if (base != null) { + //System.out.println("Base set to " + base); + kin.setRobotToFiducialTransform(base); + } + if (mod.getTip() != null) { + try { + kin.setDesiredTaskSpaceTransform(mod.getTip(), 0); + }catch(Exception ex) { + ex.printStackTrace(); + toRemove.add(mod); + } + } } + mods.removeAll(toRemove); getCadManager().render(); // Push to git ScriptingEngine.pushCodeToGit(gitURL, null, filename, mobileBase.getXml(), "Builder Write XML", true); @@ -462,10 +474,10 @@ public void removeController(AddRobotController controller) { getControllers().remove(controller); for (int i = 0; i < controllers.size(); i++) { AddRobotController con = controllers.get(i); - for(VitaminLocation l:con.getVitamins(con.getName()+"_"+i)) { + for (VitaminLocation l : con.getVitamins(con.getName() + "_" + i)) { try { mobileBase.removeVitamin(l); - }catch(Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); } } @@ -475,25 +487,28 @@ public void removeController(AddRobotController controller) { public ArrayList getControllers() { return controllers; } + public ControllerFeatures getCapibilities() { ControllerFeatures test = new ControllerFeatures(); - for(AddRobotController c:controllers) { + for (AddRobotController c : controllers) { test.add(c.getController().getProvides()); test.subtract(c.getController().getConsumes()); } - for(AddRobotLimb c:limbs) { + for (AddRobotLimb c : limbs) { test.add(c.getLimb().getProvides()); test.subtract(c.getLimb().getConsumes()); } return test; } + public void addLimb(AddRobotLimb controller) { - addLimb(controller,false); + addLimb(controller, false); } + public void addLimb(AddRobotLimb controller, boolean forceLoad) { LimbOption consumes = controller.getLimb(); - if(!checkOptionSupported(consumes) && !forceLoad) { - throw new RuntimeException("Robot doesnt have enough resources to support "+controller.getLimb()); + if (!checkOptionSupported(consumes) && !forceLoad) { + throw new RuntimeException("Robot doesnt have enough resources to support " + controller.getLimb()); } if (!getLimmbs().contains(controller)) getLimmbs().add(controller); @@ -502,14 +517,17 @@ public void addLimb(AddRobotLimb controller, boolean forceLoad) { public boolean checkOptionSupported(LimbOption consumes) { return getCapibilities().check(consumes.consumes); } + public void addModification(ModifyLimb modifyLimb) { - if(!mods.contains(modifyLimb)) + if (!mods.contains(modifyLimb)) mods.add(modifyLimb); } + public void removeModification(ModifyLimb modifyLimb) { - if(mods.contains(modifyLimb)) + if (mods.contains(modifyLimb)) mods.remove(modifyLimb); } + public void removeLimb(AddRobotLimb controller) { if (getLimmbs().contains(controller)) getLimmbs().remove(controller); @@ -527,6 +545,4 @@ public MobileBaseCadManager getCadManager() { return mobileBaseCadManager; } - - } \ No newline at end of file From bd44db3d8d7a26f541d2efd0850163c4e0d8d618 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 16 Aug 2025 10:43:50 -0400 Subject: [PATCH 552/635] make the drag state accessible --- .../bowlerkernel/Bezier3d/Manipulation.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index a1399253..bf863c06 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -40,7 +40,7 @@ public class Manipulation { //private PhongMaterial color;// = new PhongMaterial(getColor()); //private PhongMaterial highlight = new PhongMaterial(Color.GOLD); - private enum DragState { + public enum DragState { IDLE, Dragging } @@ -149,7 +149,7 @@ public void handle(MouseEvent event) { } private void pressed(MouseEvent event) { - state = DragState.Dragging; + setState(DragState.Dragging); new Thread(() -> { event.consume(); dragging = false; @@ -168,13 +168,13 @@ private void release(MouseEvent event) { mouseRelease(event); for (Manipulation R : dependants) R.mouseRelease(event); - state = DragState.IDLE; + setState(DragState.IDLE); //manip.getMesh().setMaterial(color); } private void dragged(MouseEvent event, MouseEvent event2) { if(resizeAllowed) - if(state==DragState.Dragging) { + if(getState()==DragState.Dragging) { getUi().runLater(() -> { setDragging(event); double deltx = (startx - event.getScreenX()); @@ -194,7 +194,7 @@ private void dragged(MouseEvent event, MouseEvent event2) { } public boolean isMoving() { - return state == DragState.Dragging; + return getState() == DragState.Dragging; } private void mouseRelease(MouseEvent event) { @@ -364,4 +364,12 @@ public void setUnlocked(boolean resizeAllowed) { this.resizeAllowed = resizeAllowed; } + public DragState getState() { + return state; + } + + public void setState(DragState state) { + this.state = state; + } + } From f02fa55ce7432f8afcb41437f3cf8d072f3db9d2 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 24 Aug 2025 13:13:35 -0400 Subject: [PATCH 553/635] revert the parsing error --- .../CaDoodleJsonOperationAdapterFactory.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 87a1f826..1b774ead 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -7,7 +7,6 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; -import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.ModifyLimb; import java.io.IOException; import java.util.HashMap; @@ -18,32 +17,30 @@ public class CaDoodleJsonOperationAdapterFactory implements TypeAdapterFactory { private final Map, String> classRegistry = new HashMap<>(); public CaDoodleJsonOperationAdapterFactory() { - registerType( AddFromFile.class); - registerType( AddFromScript.class); - registerType( AddRobotController.class); - registerType( AddRobotLimb.class); - registerType( Allign.class); - registerType( Delete.class); - registerType( Group.class); - registerType(Hide.class); - registerType(Lock.class); - registerType( MakeRobot.class); - registerType( Mirror.class); - registerType( ModifyLimb.class); - registerType( MoveCenter.class); - registerType( Paste.class); - registerType( Resize.class); - registerType( Show.class); - registerType(ToHole.class); - registerType( ToSolid.class); - registerType( UnGroup.class); - registerType( UnLock.class); - registerType( Sweep.class); + registerType("AddFromFile", AddFromFile.class); + registerType("AddFromScript", AddFromScript.class); + registerType("AddRobotController", AddRobotController.class); + registerType("AddRobotLimb", AddRobotLimb.class); + registerType("Allign", Allign.class); + registerType("Delete", Delete.class); + registerType("Group", Group.class); + registerType("Hide", Hide.class); + registerType("Lock", Lock.class); + registerType("MakeRobot", MakeRobot.class); + registerType("Mirror", Mirror.class); + registerType("MoveCenter", MoveCenter.class); + registerType("Paste", Paste.class); + registerType("Resize", Resize.class); + registerType("Show", Show.class); + registerType("ToHole", ToHole.class); + registerType("ToSolid", ToSolid.class); + registerType("UnGroup", UnGroup.class); + registerType("UnLock", UnLock.class); + registerType("Sweep", Sweep.class); } - private void registerType(Class clazz) { - String typeName=clazz.getSimpleName(); + private void registerType(String typeName, Class clazz) { typeRegistry.put(typeName, clazz); classRegistry.put(clazz, typeName); } From ec7f602c6a48c8ed7b1749df8b34da72f550945e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 24 Aug 2025 13:16:04 -0400 Subject: [PATCH 554/635] readd the modify limb --- .../scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 1b774ead..52c63de4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -7,6 +7,7 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.MakeRobot; +import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.ModifyLimb; import java.io.IOException; import java.util.HashMap; @@ -29,6 +30,7 @@ public CaDoodleJsonOperationAdapterFactory() { registerType("MakeRobot", MakeRobot.class); registerType("Mirror", Mirror.class); registerType("MoveCenter", MoveCenter.class); + registerType("ModifyLimb", ModifyLimb.class); registerType("Paste", Paste.class); registerType("Resize", Resize.class); registerType("Show", Show.class); From ae889e6451bc051c4ffed4dffd05b70fbb0ce09f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 25 Aug 2025 16:39:28 -0400 Subject: [PATCH 555/635] make sure the manifold is set --- src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index f71c3571..894610d9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -422,6 +422,7 @@ private static void finish(long startTime) { } public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFile) { + CSG.setPreventNonManifoldTriangles(true); processUIOpening(ret); if (baseWorkspaceFile != null) System.out.println("Processing file in directory " + baseWorkspaceFile.getAbsolutePath()); From 77f1d20ee2259a3e2199c9adf8b036ed0c4dcb41 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 25 Aug 2025 17:27:41 -0400 Subject: [PATCH 556/635] shunt windows files into the Appdata --- .../scripting/ScriptingEngine.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index b9bdd65b..c0b06571 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -561,7 +561,22 @@ public static void createSymlinkInDocuments(File appDataDir) throws IOException Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); } - + private static Path getWindowsAppData(String appName) { + // Try APPDATA first, then LOCALAPPDATA, then fallback + String appData = System.getenv("APPDATA"); + if (appData != null) { + return Paths.get(appData, appName); + } + + String localAppData = System.getenv("LOCALAPPDATA"); + if (localAppData != null) { + return Paths.get(localAppData, appName); + } + + // Fallback + String userHome = System.getProperty("user.home"); + return Paths.get(userHome, "AppData", "Roaming", appName); + } public static File getWorkingDirectory() { String relative = Paths.get(System.getProperty("user.home"), "Documents").toString(); if (OSUtil.isOSX()) { @@ -586,10 +601,7 @@ public static File getWorkingDirectory() { relative = relative + delim + "Documents"; } if (OSUtil.isWindows()) { - delim = "\\"; - if (!relative.endsWith("Documents")) { - relative = relative + delim + "Documents"; - } + relative = getWindowsAppData(appName).toString(); } File file = new File(relative + delim); file.mkdirs(); From 75e799e1c726e689fff3d649f7276cf370981277 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 25 Aug 2025 19:48:24 -0400 Subject: [PATCH 557/635] revert the documents folder --- .../bowlerstudio/scripting/ScriptingEngine.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index c0b06571..0e533def 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -601,7 +601,10 @@ public static File getWorkingDirectory() { relative = relative + delim + "Documents"; } if (OSUtil.isWindows()) { - relative = getWindowsAppData(appName).toString(); + delim = "\\"; + if (!relative.endsWith("Documents")) { + relative = relative + delim + "Documents"; + } } File file = new File(relative + delim); file.mkdirs(); From df50cbe97a3a04e448b3191529f604e9a1e558fb Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 26 Aug 2025 23:28:06 -0400 Subject: [PATCH 558/635] Make the configurations database file into the appdata directory --- .../assets/ConfigurationDatabase.java | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 60ce5d0e..108bb4a9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -22,6 +22,10 @@ import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import java.nio.charset.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + import org.apache.commons.io.*; public class ConfigurationDatabase { @@ -173,7 +177,7 @@ public static void getDatabase() { } public static File loadFile() { - File f = new File(ScriptingEngine.getWorkspace().getAbsolutePath()+"/ConfigurationDatabase.json"); + File f = new File(getAppDataDirectory()+"/ConfigurationDatabase.json"); if(!f.exists()) { try { f.createNewFile(); @@ -183,6 +187,78 @@ public static File loadFile() { } return f; } + public static Path getAppDataDirectory() { + String appName="CaDoodle"; + String os = System.getProperty("os.name").toLowerCase(); + + if (os.contains("win")) { + return getWindowsAppData(appName); + } else if (os.contains("mac")) { + return getMacAppData(appName); + } else { + return getLinuxAppData(appName); + } + } + + public static Path getWindowsAppData(String appName) { + // Try LOCALAPPDATA first (safe, never synced to OneDrive) + String localAppData = System.getenv("LOCALAPPDATA"); + if (localAppData != null && !localAppData.isEmpty()) { + return Paths.get(localAppData, appName); + } + + // Next try APPDATA + String appData = System.getenv("APPDATA"); + if (appData != null && !appData.isEmpty()) { + return ensureNoOneDrive(Paths.get(appData), appName); + } + + // Fallback to user.home + String userHome = System.getProperty("user.home"); + Path homePath = Paths.get(userHome); + homePath = stripOneDrive(homePath); // sanitize + return homePath.resolve("AppData").resolve("Local").resolve(appName); + } + + private static Path ensureNoOneDrive(Path path, String appName) { + Path sanitized = stripOneDrive(path); + return sanitized.resolve(appName); + } + + private static Path stripOneDrive(Path path) { + // Look for "OneDrive" component in the path and cut everything after it + for (int i = 0; i < path.getNameCount(); i++) { + if (path.getName(i).toString().equalsIgnoreCase("OneDrive")) { + // Return path up to but not including "OneDrive" + return path.getRoot().resolve(path.subpath(0, i)); + } + } + return path; + } + + private static Path getMacAppData(String appName) { + String userHome = System.getProperty("user.home"); + return Paths.get(userHome, "Library", "Application Support", appName); + } + + private static Path getLinuxAppData(String appName) { + // Follow XDG Base Directory Specification + String xdgConfigHome = System.getenv("XDG_CONFIG_HOME"); + if (xdgConfigHome != null && !xdgConfigHome.isEmpty()) { + return Paths.get(xdgConfigHome, appName); + } + + String userHome = System.getProperty("user.home"); + return Paths.get(userHome, ".config", appName); + } + + public static void ensureDirectoryExists(Path directory) { + try { + Files.createDirectories(directory); + } catch (IOException e) { + throw new RuntimeException("Failed to create app data directory: " + directory, e); + } + } From d6b77a63a96d53aac14bbab23b6684d2360300b5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 27 Aug 2025 00:15:01 -0400 Subject: [PATCH 559/635] Add a more stable location for config file --- JCSG | 2 +- .../bowlerstudio/assets/ConfigurationDatabase.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/JCSG b/JCSG index ef698686..922618b6 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit ef698686343486eb6a0b88c24f938f1b6c9ae130 +Subproject commit 922618b6844262df09578a5df25a067b9116a16d diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 108bb4a9..0a4ba4ef 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -177,7 +177,12 @@ public static void getDatabase() { } public static File loadFile() { - File f = new File(getAppDataDirectory()+"/ConfigurationDatabase.json"); + Path appDataDirectory = getAppDataDirectory(); + File dir = appDataDirectory.toFile(); + if(!dir.exists()) { + dir.mkdirs(); + } + File f = new File(appDataDirectory+"/ConfigurationDatabase.json"); if(!f.exists()) { try { f.createNewFile(); From b924f961a456b3ac95e066b7c63281b26ccf562c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 27 Aug 2025 00:31:49 -0400 Subject: [PATCH 560/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 922618b6..5c5f78a4 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 922618b6844262df09578a5df25a067b9116a16d +Subproject commit 5c5f78a43861b499d52ffa353d9c4c778cf8426f From 55f12203d707e16ea4f7871d44b00771ac836030 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 27 Aug 2025 08:52:05 -0400 Subject: [PATCH 561/635] make sure the loading of doodle files is only the results not the rest of the parts --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index c9d52f3b..f9353dda 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -98,7 +98,8 @@ public List process(List incoming) { } for (int i = 0; i < flattenedCSGs.size(); i++) { CSG csg = flattenedCSGs.get(i); - + if(isDoodle && csg.isInGroup()) + continue; try { CSG processedCSG = processGiven(csg, i, getOrderedName(),file,name,getLocation()); collect.add(processedCSG); From 41c6a2d9871985b4e8824c7ebc5ebeb2cfec891b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 29 Aug 2025 17:35:33 -0400 Subject: [PATCH 562/635] always use us format --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 5c5f78a4..47fc7abd 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 5c5f78a43861b499d52ffa353d9c4c778cf8426f +Subproject commit 47fc7abd97e7727e85b435513c89076a121312ad From bbf82679a76212f82fd8460a70b9f41a1c4d009a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 4 Sep 2025 09:32:19 -0400 Subject: [PATCH 563/635] https://github.com/jdegenstein/cadoodle-build123d-portable/issues/2 Adding the loader --- .../scripting/Build123dLoader.java | 91 +++++++++++++++++++ .../bowlerstudio/scripting/JythonHelper.java | 2 +- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java new file mode 100644 index 00000000..d4ea4cc5 --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java @@ -0,0 +1,91 @@ +package com.neuronrobotics.bowlerstudio.scripting; +import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; + +import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; + +import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.FileUtil; +import eu.mihosoft.vrl.v3d.STL; +import javafx.scene.paint.Color; + +public class Build123dLoader implements IScriptingLanguage { + + @Override + public Object inlineScriptRun(File code, ArrayList args) throws Exception { + File stl = File.createTempFile(sanitizeString(code.getName()), ".stl"); + stl.deleteOnExit(); + HashMap params=new HashMap(); + if(args!=null) { + Object o = args.get(0); + if(HashMap.class.isInstance(o)) { + params=(HashMap)o; + } + } + + toSTLFile(code,stl,params); + CSG back = Vitamins.get(stl,true); + back.setColor(Color.ANTIQUEWHITE); + return back; + } + + @Override + public Object inlineScriptRun(String code, ArrayList args) throws Exception { + throw new RuntimeException("Build123d can not run from a string"); + } + + @Override + public String getShellType() { + return "Build123d"; + } + + @Override + public ArrayList getFileExtenetion() { + ArrayList ext = new ArrayList<>(); + ext.add("py"); + ext.add("build123d"); + return ext; + } + + + + + public static void toSTLFile(File openscadfile,File stlout, HashMap params) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + File exe = getConfigExecutable("build123d", null); + if(params==null) + params=new HashMap(); + ArrayList args = new ArrayList<>(); + + if(stlout.exists()) + stlout.delete(); + args.add(exe.getAbsolutePath()); + for(String key:params.keySet()) { + args.add("-D"); + args.add(key+"="+params.get(key)); + } + args.add("-o"); + args.add(stlout.getAbsolutePath()); + args.add(openscadfile.getAbsolutePath()); + legacySystemRun(null, stlout.getAbsoluteFile().getParentFile(), System.out, args); + } + @Override + public String getDefaultContents() { + return "cube([30, 20, 10]);"; + } + + @Override + public boolean getIsTextFile() { + return true; + } + + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java index ec46ca87..fc62265e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java @@ -110,7 +110,7 @@ public boolean getIsTextFile() { @Override public ArrayList getFileExtenetion() { // Auto-generated method stub - return new ArrayList<>(Arrays.asList("py", "jy")); + return new ArrayList<>(Arrays.asList( "jy")); } } From e3efa370d5097e43a5284761decc3fc82e1ef33e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 4 Sep 2025 09:37:06 -0400 Subject: [PATCH 564/635] https://github.com/jdegenstein/cadoodle-build123d-portable/issues/2 Adding testing code --- build123dTest.py | 3 +++ .../bowlerstudio/scripting/Build123dLoader.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 build123dTest.py diff --git a/build123dTest.py b/build123dTest.py new file mode 100644 index 00000000..2f383604 --- /dev/null +++ b/build123dTest.py @@ -0,0 +1,3 @@ +from build123d import * + +cube = Box(10, 10, 10) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java index d4ea4cc5..9d9a22a2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java @@ -79,7 +79,9 @@ public static void toSTLFile(File openscadfile,File stlout, HashMap params = new HashMap(); + toSTLFile(testblend, new File("build123dTest.py.stl"),params); + } } From 2c77b88e67bde7c4d79b2ba97e0a10c503bbc189 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 7 Sep 2025 11:35:34 -0400 Subject: [PATCH 565/635] throw file not found exceptions, do not swallow --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index f9353dda..f967077b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -112,8 +112,7 @@ public List process(List incoming) { csg1.setParameter(getFileLocationparam(file,name)); back.addAll(collect); } catch (Exception e) { - // Auto-generated catch block - e.printStackTrace(); + throw new RuntimeException(e); } return back; } From 59d6a3ad87884a21fce009237779cfee1e4ff697 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 7 Sep 2025 12:35:08 -0400 Subject: [PATCH 566/635] Use passed in value for the cadoodle file location and do not relu on the database --- .../scripting/cadoodle/AddFromFile.java | 19 +++++++++---------- .../scripting/cadoodle/CaDoodleFile.java | 15 +++++++-------- .../scripting/cadoodle/Sweep.java | 4 ++-- .../scripting/cadoodle/robot/MakeRobot.java | 3 +-- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index f967077b..738d2c04 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -40,7 +40,7 @@ public class AddFromFile extends AbstractAddFrom { public AddFromFile set(File source) { for (String s : ScriptingEngine.getAllExtentions()) { if (source.getName().toLowerCase().endsWith(s.toLowerCase())) { - toLocal(source, getName()); + toLocal(source, getName(),getCaDoodleFile()); try { getFile(); } catch (NoSuchFileException e) { @@ -146,10 +146,9 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, return targetFile; } - public static File toLocal(File file, String name) { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); + public static File toLocal(File file, String name,CaDoodleFile cf ) { File parentFileIncoming = file.getParentFile(); - String strValue = loc.getStrValue(); + String strValue = cf.getSelf().getAbsolutePath(); File parentFile = new File(strValue).getParentFile(); String source = parentFile.getAbsolutePath(); boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); @@ -157,9 +156,9 @@ public static File toLocal(File file, String name) { String parentIncoming = parentFileIncoming.getAbsolutePath(); String lowerCase = parentIncoming.toLowerCase(); String lowerCase2 = source.toLowerCase(); - boolean b = !lowerCase.contentEquals(lowerCase2); + boolean namesNotEqual = !lowerCase.contentEquals(lowerCase2); boolean exists = file.exists(); - if (b && exists) { + if (namesNotEqual && exists) { if (!isDoodle) { File copied; try { @@ -275,9 +274,9 @@ private static boolean copyDirectory(File sourceDir, File targetDir) throws IOEx return true; } - public static File getFile(String name) { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); - File parentFile = new File(loc.getStrValue()).getParentFile(); + public static File getFile(String name,CaDoodleFile cf) { + String strValue = cf.getSelf().getAbsolutePath(); + File parentFile = new File(strValue).getParentFile(); for (File f : parentFile.listFiles()) { if (f.getName().contains(name)) { if (f.isDirectory()) { @@ -369,6 +368,6 @@ public AddFromFile setPreventBoM(Boolean preventBoM) { @Override public File getFile() throws NoSuchFileException { - return AddFromFile.getFile(name); + return getFile(name,getCaDoodleFile()); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b994a6f0..9840acd3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -159,7 +159,7 @@ public void initialize() { StringParameter loc = new StringParameter("CaDoodle_File_Location", self.getAbsolutePath(), new ArrayList()); loc.setStrValue(self.getAbsolutePath()); - bom = CaDoodleFile.getBillOfMaterials(); + bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); @@ -230,9 +230,9 @@ private void updateBoM() { bom.save(); } - public static VitaminBomManager getBillOfMaterials() { + public static VitaminBomManager getBillOfMaterials(CaDoodleFile cf) { - String strValue = getCadoodleFileLocation(); + String strValue = cf.getSelf().getAbsolutePath() ; File file = new File(strValue).getParentFile(); if (bomManagers.get(strValue) == null) { bomManagers.put(strValue, new VitaminBomManager(file)); @@ -240,11 +240,10 @@ public static VitaminBomManager getBillOfMaterials() { return bomManagers.get(strValue); } - private static String getCadoodleFileLocation() { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "", new ArrayList()); - String strValue = loc.getStrValue(); - return strValue; - } +// private static String getCadoodleFileLocation() { +// +// return get; +// } public Thread regenerateFrom(CaDoodleOperation source) { if (initializing) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index c0277f62..3c68fcb5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -63,7 +63,7 @@ public Sweep set(File source) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); System.out.println("Saving Local Copy of "+source.getAbsolutePath()); - AddFromFile.toLocal(source, getName()); + AddFromFile.toLocal(source, getName(),getCaDoodleFile()); try { getFile(); } catch (Exception ex) { @@ -230,7 +230,7 @@ public Bounds getBounds(HashMap> polygons) { @Override public File getFile() throws NoSuchFileException { - return AddFromFile.getFile(name); + return AddFromFile.getFile(name,getCaDoodleFile()); } private CSG processGiven(Polygon p, Bounds b, int j, String name) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index d6f90d51..893d9b24 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -69,8 +69,7 @@ public void setNames(List assignedAsBase) { */ public MobileBaseBuilder getBuilder() { if (builder == null) { - StringParameter loc = new StringParameter("CaDoodle_File_Location", "NotSet", new ArrayList()); - String strValue = loc.getStrValue(); + String strValue = getCaDoodleFile().getSelf().getAbsolutePath(); File parentFile = new File(strValue).getParentFile(); String source = parentFile.getAbsolutePath(); builder = new MobileBaseBuilder(source, getName() + "-mobilbase.xml"); From 169926a42702e4b6658aa512ca85bb82422cf0f0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 7 Sep 2025 12:45:16 -0400 Subject: [PATCH 567/635] add a null check to the loading --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 738d2c04..9ed61dd4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -147,6 +147,8 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory, } public static File toLocal(File file, String name,CaDoodleFile cf ) { + if(cf==null) + return file; File parentFileIncoming = file.getParentFile(); String strValue = cf.getSelf().getAbsolutePath(); File parentFile = new File(strValue).getParentFile(); From 89f3eb68f64c70234fe56636275fc1e9e2cb9a56 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 7 Sep 2025 12:52:28 -0400 Subject: [PATCH 568/635] enforce that the set file includes the cadoodle file that will recive the new file --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 9ed61dd4..8a960946 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -37,10 +37,10 @@ public class AddFromFile extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private Boolean preventBoM = false; - public AddFromFile set(File source) { + public AddFromFile set(File source, CaDoodleFile cf) { for (String s : ScriptingEngine.getAllExtentions()) { if (source.getName().toLowerCase().endsWith(s.toLowerCase())) { - toLocal(source, getName(),getCaDoodleFile()); + toLocal(source, getName(),cf); try { getFile(); } catch (NoSuchFileException e) { From d2dcb56c5e9da081cf35e8e753dbbf8c3d6a8576 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 9 Sep 2025 14:53:10 -0400 Subject: [PATCH 569/635] set the cadoodle file when it is passed in --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 8a960946..dc536ef6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -38,6 +38,7 @@ public class AddFromFile extends AbstractAddFrom { private Boolean preventBoM = false; public AddFromFile set(File source, CaDoodleFile cf) { + setCaDoodleFile(cf); for (String s : ScriptingEngine.getAllExtentions()) { if (source.getName().toLowerCase().endsWith(s.toLowerCase())) { toLocal(source, getName(),cf); From 1e58807bebb1c006e046a35dd7579fc2bb2f28ce Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 15 Sep 2025 21:40:47 -0400 Subject: [PATCH 570/635] Updating the external editor interface --- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 2 +- .../neuronrobotics/bowlerstudio/scripting/IExternalEditor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index e933f552..0f697839 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -464,7 +464,7 @@ public String nameOfEditor() { } @Override - public void launch(File file, Button advanced) { + public void launch(File file, Button advanced,Runnable r) { // Auto-generated method stub } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IExternalEditor.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IExternalEditor.java index 3f2e7f5e..5f71675f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IExternalEditor.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IExternalEditor.java @@ -31,7 +31,7 @@ default boolean isSupportedByExtention(File file) { return false; } - void launch(File file, Button advanced); + void launch(File file, Button advanced,Runnable onExit); String nameOfEditor(); From df541a5feb291e423adf47361f5be6962abdd521 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 20 Sep 2025 11:43:11 -0400 Subject: [PATCH 571/635] Switch prints over to the Log system --- java-bowler | 2 +- .../bowlerkernel/Bezier3d/Manipulation.java | 2 +- .../neuronrobotics/bowlerstudio/BowlerKernel.java | 4 ++-- .../bowlerstudio/CoquiDockerManager.java | 2 +- .../bowlerstudio/assets/AssetFactory.java | 2 +- .../bowlerstudio/creature/CadFileExporter.java | 12 ++++++------ .../bowlerstudio/creature/ControllerOption.java | 2 +- .../bowlerstudio/creature/MobileBaseBuilder.java | 2 +- .../bowlerstudio/scripting/ScriptingEngine.java | 10 +++++----- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 4 ++-- .../scripting/cadoodle/CaDoodleFile.java | 6 +++--- .../scripting/cadoodle/CaDoodleVitamin.java | 12 ++++++------ .../bowlerstudio/scripting/cadoodle/Paste.java | 2 +- .../bowlerstudio/scripting/cadoodle/Resize.java | 2 +- .../bowlerstudio/scripting/cadoodle/Sweep.java | 4 ++-- .../scripting/cadoodle/robot/ModifyLimb.java | 4 ++-- 16 files changed, 36 insertions(+), 36 deletions(-) diff --git a/java-bowler b/java-bowler index 58791e9a..519c1aec 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 58791e9a9efe670143d3c502b293536f6d65e3db +Subproject commit 519c1aec0a9054f0635dd00f3382f91a31f84fb5 diff --git a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java index bf863c06..2d3cb742 100644 --- a/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java +++ b/src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/Manipulation.java @@ -76,7 +76,7 @@ private void fireMove(TransformNR trans, MouseEvent event2) { for (Manipulation R : dependants) { R.performMove(trans,event2); } - //System.out.println("Mouse event "+event2.getEventType()); + //com.neuronrobotics.sdk.common.Log.debug("Mouse event "+event2.getEventType()); for (EventHandler R : eventListeners) { R.handle(event2); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index 894610d9..f33f5e8f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -241,7 +241,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } baseWorkspaceFile = new File(location); - System.out.println("Using working directory " + baseWorkspaceFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Using working directory " + baseWorkspaceFile.getAbsolutePath()); f = new File(baseWorkspaceFile.getAbsolutePath() + "/" + s); com.neuronrobotics.sdk.common.Log.error("File " + f.getName()); ret = ScriptingEngine.inlineFileScriptRun(f, null); @@ -425,7 +425,7 @@ public static void processReturnedObjectsStart(Object ret, File baseWorkspaceFil CSG.setPreventNonManifoldTriangles(true); processUIOpening(ret); if (baseWorkspaceFile != null) - System.out.println("Processing file in directory " + baseWorkspaceFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Processing file in directory " + baseWorkspaceFile.getAbsolutePath()); if (baseWorkspaceFile != null) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java index 2f6f1d3e..0704e968 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/CoquiDockerManager.java @@ -143,7 +143,7 @@ private CoquiDockerManager(String voice) throws InterruptedException, InvalidRem @Override public void onNext(BuildResponseItem item) { // Handle build output (optional) - System.out.println(item.getStream()); + com.neuronrobotics.sdk.common.Log.debug(item.getStream()); super.onNext(item); } }).awaitImageId(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 4b5953a9..0c70b362 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -88,7 +88,7 @@ public static void writeImage(Image img, File file) { @SuppressWarnings("restriction") public static Image loadAsset(String file) throws Exception { if (cache.get(file) == null) { - System.out.println("Loading asset " + file); + com.neuronrobotics.sdk.common.Log.debug("Loading asset " + file); File f = loadFile(file); if (f.getName().endsWith(".fxml")) { loadLayout(file); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 9bcd296f..c360e0a2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -154,12 +154,12 @@ public ArrayList generateManufacturingParts(List totalAssembly , File if(freecadParts.size()>0){ allCadStl.add(makeFreecad(nameBase,freecadParts));// default to stl } - System.out.println("Finished Export!"); + com.neuronrobotics.sdk.common.Log.debug("Finished Export!"); return allCadStl; } private File makeFreecad(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".FCStd"); - System.out.println("Writing "+blend.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) FreecadLoader.addCSGToFreeCAD( blend,tmp); return blend; @@ -171,20 +171,20 @@ private File makeStl(String nameBase,CSG tmp ) throws IOException{ // CSG.setPreventNonManifoldTriangles(false); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); //CSG.setPreventNonManifoldTriangles(manifold); - System.out.println("Writing "+stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Writing "+stl.getAbsolutePath()); return stl; } private File makeObj(String nameBase,CSG tmp ) throws IOException{ File stl = new File(nameBase + ".obj"); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toObjString()); - System.out.println("Writing "+stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Writing "+stl.getAbsolutePath()); return stl; } private File makeBlender(String nameBase,List current ) throws IOException{ File blend = new File(nameBase + ".blend"); - System.out.println("Writing "+blend.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) BlenderLoader.toBlenderFile(tmp, blend); return blend; @@ -215,7 +215,7 @@ private File makeSvg(String nameBase, List currentCsg) throws IOException { } - System.out.println("Writing " + stl.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Writing " + stl.getAbsolutePath()); } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error("ERROR, NO pixelization engine availible for slicing"); t.printStackTrace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 7d831212..5a67e540 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -126,7 +126,7 @@ public File getImageFile() { public void runLinkLoader() throws FileNotFoundException { if (linkLoaderGit == null || linkLoaderFile == null) { - System.out.println("Using built in link loaders"); + com.neuronrobotics.sdk.common.Log.debug("Using built in link loaders"); return; } try { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 9af9958d..f411eeee 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -445,7 +445,7 @@ public MobileBase build() throws Exception { TransformNR base = mod.getBase(); if (base != null) { - //System.out.println("Base set to " + base); + //com.neuronrobotics.sdk.common.Log.debug("Base set to " + base); kin.setRobotToFiducialTransform(base); } if (mod.getTip() != null) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 0e533def..68bff26a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -926,7 +926,7 @@ public static void commit(String id, String branch, String FileName, String cont try { File f = new File(id); if (f.exists() && f.isDirectory()) { - System.out.println("remoteURI is actually a directory " + f); + com.neuronrobotics.sdk.common.Log.debug("remoteURI is actually a directory " + f); OutputStream out = null; try { out = FileUtils.openOutputStream(new File(f + "/" + FileName), false); @@ -1023,7 +1023,7 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam try { File f = new File(remoteURI); if (f.exists() && f.isDirectory()) { - System.out.println("remoteURI is actually a directory " + f); + com.neuronrobotics.sdk.common.Log.debug("remoteURI is actually a directory " + f); OutputStream out = null; try { out = FileUtils.openOutputStream(new File(f + "/" + FileName), false); @@ -1104,7 +1104,7 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam git.push().setCredentialsProvider(PasswordManager.getCredentialProvider()) .setProgressMonitor(getProgressMoniter("Pushing ", remoteURI)).call(); }); - System.out.println("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); + com.neuronrobotics.sdk.common.Log.debug("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); } catch (Exception ex) { ex.printStackTrace(); String[] gitID = ScriptingEngine.findGitTagFromFile(desired); @@ -1750,7 +1750,7 @@ public static File cloneRepo(String remoteURI, String branch) { try { File f = new File(remoteURI); if (f.exists() && f.isDirectory()) { - System.out.println("remoteURI is actually a directory " + f); + com.neuronrobotics.sdk.common.Log.debug("remoteURI is actually a directory " + f); return f; } } catch (Exception ex) { @@ -2245,7 +2245,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi } String[] newFileCode; try { - System.out.println("Opening " + targetFilename + " from " + targetGit); + com.neuronrobotics.sdk.common.Log.debug("Opening " + targetFilename + " from " + targetGit); newFileCode = ScriptingEngine.codeFromGit(targetGit, targetFilename); if (newFileCode == null) newFileCode = new String[] { "" }; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index dc536ef6..8d6f19dc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -214,7 +214,7 @@ public static boolean recursiveCopy(String sourceDir, String targetDir) { System.err.println("Error: Could not create target directory '" + targetDir + "'."); return false; } - System.out.println("Created target directory: " + targetDir); + com.neuronrobotics.sdk.common.Log.debug("Created target directory: " + targetDir); } try { @@ -266,7 +266,7 @@ private static boolean copyDirectory(File sourceDir, File targetDir) throws IOEx Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES); - System.out.println("Copied: " + sourcePath + " -> " + targetPath); + com.neuronrobotics.sdk.common.Log.debug("Copied: " + sourcePath + " -> " + targetPath); } catch (IOException e) { System.err.println("Error copying file " + file.getAbsolutePath() + ": " + e.getMessage()); throw e; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9840acd3..e203286d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -95,7 +95,7 @@ public class CaDoodleFile { private ICadoodleSaveStatusUpdate defaultSaver = new ICadoodleSaveStatusUpdate() { @Override public void renderSplashFrame(int percent, String message) { - System.out.println(percent + "% " + message); + com.neuronrobotics.sdk.common.Log.debug(percent + "% " + message); } }; private ICadoodleSaveStatusUpdate saveUpdate = null; @@ -419,7 +419,7 @@ public void run() { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); CaDoodleOperation op = toProcess.remove(0); - System.out.println("Adding Operation "+op); + com.neuronrobotics.sdk.common.Log.debug("Adding Operation "+op); if (getCurrentIndex() != getOpperations().size()) { try { fireRegenerateStart(); @@ -637,7 +637,7 @@ private void storeResultInCache(CaDoodleOperation op, List process) { } cache.put(op, cachedCopy); if(getFreeMemory()>50) - System.out.println("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + com.neuronrobotics.sdk.common.Log.debug("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); } public static double getFreeMemory() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index a8e43cd7..10c980b7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -74,13 +74,13 @@ public static CSG get(String typencoming,String defaultValue, ArrayList if (!(Boolean) object.get("PreventBomAdd")) { // VitaminLocation vl = new VitaminLocation(false, name, type, word.getStrValue(), new TransformNR()); -// //System.out.println("BoM update "+vl); +// //com.neuronrobotics.sdk.common.Log.debug("BoM update "+vl); // CaDoodleFile.getBoM().addVitamin(vl, true); } } CSG part; try { -// System.out.println("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); +// com.neuronrobotics.sdk.common.Log.debug("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); Set params = part.getParameters(); @@ -89,9 +89,9 @@ public static CSG get(String typencoming,String defaultValue, ArrayList part.setParameter(typeParam); params = part.getParameters(); part.setName(name); -// System.out.println("Parameters on Vitamin: "+name); +// com.neuronrobotics.sdk.common.Log.debug("Parameters on Vitamin: "+name); // for(String s:params) { -// System.out.println("\t"+s); +// com.neuronrobotics.sdk.common.Log.debug("\t"+s); // } CSG back = part.setRegenerate(new IRegenerate() { @Override @@ -102,14 +102,14 @@ public CSG regenerate(CSG previous) { name2=pv.get().toString(); else name2=name; - //System.out.println("Regenerating source \n\t"+name+" on part \n\t"+name2); + //com.neuronrobotics.sdk.common.Log.debug("Regenerating source \n\t"+name+" on part \n\t"+name2); ArrayList ar = new ArrayList<>(); ar.addAll(args); ar.set(0, previous.getName()); Parameter s = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Size"); Parameter t = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Type"); if(t==null) { - System.out.println(" Error, type is null, previous "+name2+" has no parameters somehow??"); + com.neuronrobotics.sdk.common.Log.debug(" Error, type is null, previous "+name2+" has no parameters somehow??"); } return CaDoodleVitamin.get(t.getStrValue(),s.getStrValue(), ar); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index bc996636..05b07a62 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -113,7 +113,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { ArrayList b = new ArrayList<>(); b.add(c); b.add(newOne); - //System.out.println("Copy "+c.getName()+" to "+newOne.getName()); + //com.neuronrobotics.sdk.common.Log.debug("Copy "+c.getName()+" to "+newOne.getName()); cpMap.put(c.getName(), newOne.getName()); return b; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index f40726f4..08c0fcd2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -70,7 +70,7 @@ public Bounds getSellectedBounds(List incoming) { max.z = max2.z; } if (min == null || max == null) { - System.out.println("Found bounds to be null "); + com.neuronrobotics.sdk.common.Log.debug("Found bounds to be null "); throw new RuntimeException("Min and max can not be null"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 3c68fcb5..a214c622 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -62,7 +62,7 @@ public class Sweep extends AbstractAddFrom { public Sweep set(File source) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); - System.out.println("Saving Local Copy of "+source.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Saving Local Copy of "+source.getAbsolutePath()); AddFromFile.toLocal(source, getName(),getCaDoodleFile()); try { getFile(); @@ -162,7 +162,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); - System.out.println("Loading File "+file.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Loading File "+file.getAbsolutePath()); if (!file.exists()) { throw new RuntimeException("Failed to find file"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index 9a7bab65..e02d294c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -185,7 +185,7 @@ public ModifyLimb setLimb(DHParameterKinematics newLimb) { public void undo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); setUndo(true); - //System.out.println("Undo ModifyLimb"); + //com.neuronrobotics.sdk.common.Log.debug("Undo ModifyLimb"); try { builder.build(); } catch (Exception e) { @@ -198,7 +198,7 @@ public void undo() { public void redo() { MobileBaseBuilder builder = getRobots().get(getBuilderName()); setUndo(false); - //System.out.println("Redo ModifyLimb"); + //com.neuronrobotics.sdk.common.Log.debug("Redo ModifyLimb"); try { builder.build(); } catch (Exception e) { From eaca686d042de77562c6827c0436325207341f94 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 20 Sep 2025 16:54:11 -0400 Subject: [PATCH 572/635] Update the sweep to pass in th cadoodle file --- .../bowlerstudio/scripting/cadoodle/Sweep.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index a214c622..4f5b6745 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -59,11 +59,12 @@ public class Sweep extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private double defSpiral=0; - public Sweep set(File source) throws Exception { + public Sweep set(File source,CaDoodleFile cf) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); com.neuronrobotics.sdk.common.Log.debug("Saving Local Copy of "+source.getAbsolutePath()); - AddFromFile.toLocal(source, getName(),getCaDoodleFile()); + AddFromFile.toLocal(source, getName(),cf); + setCaDoodleFile(cf); try { getFile(); } catch (Exception ex) { From b4d830140988fb1d4dd3d320d5d32a7ab6db3a33 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 21 Sep 2025 10:14:55 -0400 Subject: [PATCH 573/635] use the log for exception printing --- .../creature/CadFileExporter.java | 4 +- .../creature/ControllerOption.java | 20 +++---- .../bowlerstudio/creature/LimbOption.java | 8 +-- .../creature/MobileBaseBuilder.java | 6 +- .../creature/MobileBaseCadManager.java | 57 +++++++++--------- .../creature/MobileBaseLoader.java | 2 +- .../bowlerstudio/creature/ThumbnailImage.java | 2 +- .../bowlerstudio/scripting/BlenderLoader.java | 10 ++-- .../bowlerstudio/scripting/ClojureHelper.java | 2 +- .../scripting/DownloadManager.java | 32 +++++----- .../bowlerstudio/scripting/FreecadLoader.java | 12 ++-- .../scripting/IScriptingLanguage.java | 4 +- .../bowlerstudio/scripting/JythonHelper.java | 10 ++-- .../bowlerstudio/scripting/RobotHelper.java | 8 +-- .../scripting/ScriptingEngine.java | 56 +++++++++--------- .../bowlerstudio/scripting/SvgLoader.java | 2 +- .../scripting/cadoodle/AddFromFile.java | 10 ++-- .../scripting/cadoodle/AddFromScript.java | 6 +- .../scripting/cadoodle/CaDoodleFile.java | 58 +++++++++---------- .../scripting/cadoodle/CaDoodleVitamin.java | 4 +- .../scripting/cadoodle/MoveCenter.java | 2 +- .../scripting/cadoodle/Sweep.java | 8 +-- .../cadoodle/robot/AddRobotLimb.java | 2 +- .../scripting/cadoodle/robot/MakeRobot.java | 2 +- .../scripting/cadoodle/robot/ModifyLimb.java | 4 +- .../bowlerstudio/vitamins/Purchasing.java | 4 +- .../vitamins/VitaminBomManager.java | 12 ++-- .../bowlerstudio/vitamins/Vitamins.java | 42 +++++++------- 28 files changed, 195 insertions(+), 194 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index c360e0a2..4a4b0855 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -105,7 +105,7 @@ public ArrayList generateManufacturingParts(List totalAssembly , File allCadStl.add(makeStl(nameBase,manufactured));// default to stl }catch(Throwable t) { com.neuronrobotics.sdk.common.Log.error("Failed to generate "+part.getName()); - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } }else{ @@ -218,7 +218,7 @@ private File makeSvg(String nameBase, List currentCsg) throws IOException { com.neuronrobotics.sdk.common.Log.debug("Writing " + stl.getAbsolutePath()); } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error("ERROR, NO pixelization engine availible for slicing"); - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } return stl; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 5a67e540..2eec1dae 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -110,16 +110,16 @@ public File getImageFile() { return ScriptingEngine.fileFromGit(imageGit, imageFile); } catch (InvalidRemoteException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (TransportException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (GitAPIException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new RuntimeException(imageGit+"/"+ imageFile); } @@ -133,7 +133,7 @@ public void runLinkLoader() throws FileNotFoundException { ScriptingEngine.inlineGistScriptRun(linkLoaderGit, linkLoaderFile, null); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new FileNotFoundException(linkLoaderGit + "/" + linkLoaderFile); } @@ -143,16 +143,16 @@ public File getFirmware() throws FileNotFoundException { return ScriptingEngine.fileFromGit(firmwareGit, firmwareFile); } catch (InvalidRemoteException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (TransportException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (GitAPIException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new FileNotFoundException(); } @@ -173,7 +173,7 @@ public static ArrayList getOptions() String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); return gson.fromJson(content, TT_CaDoodleFile); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; return new ArrayList(); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 90959a69..fb4f545a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -87,7 +87,7 @@ public static ArrayList getOptions() String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); return gson.fromJson(content, TT_CaDoodleFile); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; return new ArrayList(); } } @@ -149,7 +149,7 @@ public void build(CaDoodleFile f) throws IOException { Thread.sleep(20); } catch (InterruptedException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } try { @@ -159,7 +159,7 @@ public void build(CaDoodleFile f) throws IOException { } catch (Exception e) { // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + // e.getMessage()); - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } indicator = get(so.get(0)); if (so.size() > 1) { @@ -173,7 +173,7 @@ public void build(CaDoodleFile f) throws IOException { System.err.println("Indicator STL saved successfully to " + stlFile.getAbsolutePath()); } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } indicator=indicator.transformed(TransformFactory.nrToCSG(LimbRotationOffset)); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index f411eeee..68c67c69 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -402,7 +402,7 @@ public MobileBase build() throws Exception { if (!mobileBase.hasVitamin(l)) mobileBase.addVitamin(l); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } } @@ -452,7 +452,7 @@ public MobileBase build() throws Exception { try { kin.setDesiredTaskSpaceTransform(mod.getTip(), 0); }catch(Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; toRemove.add(mod); } } @@ -478,7 +478,7 @@ public void removeController(AddRobotController controller) { try { mobileBase.removeVitamin(l); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 807f0ad2..95bde861 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -130,7 +130,7 @@ private ArrayList toVitaminCad(ArrayList vitamins, Affine parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } return parts; @@ -163,7 +163,7 @@ public CSG getVitamin(VitaminLocation vitamin, Affine manipulator, TransformNR o starting.syncProperties(origin); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return null; } vitaminCad.put(vitamin, starting); @@ -195,7 +195,7 @@ public CSG getVitaminDisplay(VitaminLocation vitamin, Affine manipulator, Transf } } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return null; } starting.setManipulator(manipulator); @@ -264,7 +264,7 @@ public ArrayList vitaminsToDisplay(ArrayList l, Affine man parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } return parts; @@ -470,8 +470,9 @@ private static class IMobileBaseUIlocal implements IMobileBaseUI { @Override public void highlightException(File fileEngineRunByName, Throwable ex) { - new Exception("Caught here:").printStackTrace(); - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new Exception("Caught here:")); + com.neuronrobotics.sdk.common.Log.error(ex); + ; } @Override @@ -620,7 +621,7 @@ public void run() { TransformFactory.nrToAffine(vals[i], af); } } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } rendering = false; fireIRenderSynchronizationEvent(); @@ -643,7 +644,7 @@ public void run() { } t.clear(); } catch (Throwable tr) { - tr.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(tr); } }); Thread.sleep(32); @@ -652,7 +653,7 @@ public void run() { // rendering not availible com.neuronrobotics.sdk.common.Log .error("Exception for render engine " + base.getScriptingName()); - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); try { Thread.sleep(100); } catch (InterruptedException e) { @@ -752,7 +753,7 @@ private TransformNR updateBase(MobileBase base, TransformNR baseLoc, HashMap generateBody(MobileBase base, boolean clear) { } else getUi().highlightException(null, new Exception()); ArrayList arrayList = getBasetoCadMap().get(device); - if (arrayList== null) { - arrayList=new ArrayList(); + if (arrayList == null) { + arrayList = new ArrayList(); getBasetoCadMap().put(device, arrayList); } @@ -1076,7 +1077,7 @@ public File getCadScriptFromLimnb(DHParameterKinematics l) { return ScriptingEngine.fileFromGit(l.getGitCadEngine()[0], l.getGitCadEngine()[1]); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return null; } @@ -1086,7 +1087,7 @@ public File getCadScriptFromMobileBase(MobileBase device) { return ScriptingEngine.fileFromGit(device.getGitCadEngine()[0], device.getGitCadEngine()[1]); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return null; } @@ -1214,7 +1215,7 @@ public ArrayList _generateStls(MobileBase base, File baseDirForFiles, bool com.neuronrobotics.sdk.common.Log .error("Writing STL for " + name + " to " + stl.getAbsolutePath()); boolean manifold = CSG.isPreventNonManifoldTriangles(); - //CSG.setPreventNonManifoldTriangles(false); + // CSG.setPreventNonManifoldTriangles(false); FileUtil.write(Paths.get(stl.getAbsolutePath()), tmp.toStlString()); CSG.setPreventNonManifoldTriangles(manifold); @@ -1311,8 +1312,8 @@ public void setMobileBase(MobileBase b) { @Override public void onDisconnect(BowlerAbstractDevice arg0) { if (arg0 != base) { - new Exception("This listener called from the wrong device!! " + arg0.getScriptingName()) - .printStackTrace(); + com.neuronrobotics.sdk.common.Log.error( + new Exception("This listener called from the wrong device!! " + arg0.getScriptingName())); return; } base.setRenderWrangler(null); @@ -1411,7 +1412,7 @@ public void onLinkLimit(AbstractLink arg0, PIDLimitEvent arg1) { } } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); getUi().highlightException(getCadScriptFromLimnb(dh), e); } return dhLinks; @@ -1496,14 +1497,14 @@ public void run() { Thread.sleep(100); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } setProgress(1); if (done != null) { try { done.run(); } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } System.gc(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java index ac604351..3447af7f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java @@ -90,7 +90,7 @@ public void setGitWalkingEngine(String git, String file, MobileBase device) { try { code = ScriptingEngine.fileFromGit(git, file); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; ScriptingEngine.deleteRepo(git); try { code = ScriptingEngine.fileFromGit(git, file); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index d11e167d..6717923a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -96,7 +96,7 @@ public static WritableImage get(List c) { meshView.setCullFace(CullFace.BACK); root.getChildren().add(meshView); }catch(Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index 746864ed..b42bc53c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -59,7 +59,7 @@ public static void toBlenderFile(File stl,File blenderfile) { stlIn = File.createTempFile(stl.getName(), ".stl"); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return; } stlIn.deleteOnExit(); @@ -86,7 +86,7 @@ public static void toBlenderFile(File stl,File blenderfile) { } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return; } } @@ -100,7 +100,7 @@ public static void scaleStl(File incoming, File outgoing, double scale) { CSG.setPreventNonManifoldTriangles(manifold); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { @@ -178,10 +178,10 @@ public void getDefaultContents(File source) { DownloadManager.legacySystemRun(null, parent, System.out, args); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java index db314245..3086d77a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java @@ -70,7 +70,7 @@ public Object inlineScriptRun(File code, ArrayList args) { return inlineScriptRun(s, args); } catch (IOException e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); return null; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 0f697839..953d57f9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -276,7 +276,7 @@ private static void startOutputReader(final InputStream is, final String type, P out.println(line); } } catch (IOException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } }).start(); } @@ -312,7 +312,7 @@ public static Map getEnvironment(String exeType) { } } } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } return new HashMap<>(); @@ -338,7 +338,7 @@ private static void retryLoop(String exeType, IExternalEditor editor, String exe if(getExecutable(exeType, editor, executable,justChecking).exists()) { return; } - new RuntimeException("Download or extraction failed, retrying").printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new RuntimeException("Download or extraction failed, retrying")); } if(!failedURLs.contains(jvmURL)) { failedURLs.add(jvmURL); @@ -520,7 +520,7 @@ public Image getImage() { } } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new RuntimeException("Executable for OS: " + key + " has no entry for " + exeType); @@ -531,7 +531,7 @@ private static void saveFile(File file, String json) { FileUtils.writeStringToFile(file, json, Charset.forName("UTF-8")); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -550,7 +550,7 @@ private static void runInstaller(List installerList) { tcopy.join(); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } }else { Thread tcopy = run(null, new File("."), System.out, Arrays.asList(installerFile.getAbsolutePath())); @@ -558,7 +558,7 @@ private static void runInstaller(List installerList) { tcopy.join(); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -583,7 +583,7 @@ private static void standaloneEXE(String type, String name, String targetdir, St Files.move(Paths.get(bindir + name + "." + type), Paths.get(cmd), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } new File(cmd).setExecutable(true); } @@ -621,7 +621,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { tdetach.join(); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return; } // wait for the mount to finish @@ -657,10 +657,10 @@ private static void extract7zSystemCall(String archivePath, String outputPath) { legacySystemRun(null, outputDir, System.out, args); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -682,7 +682,7 @@ public static void extract7zArchive(String archivePath, String outputPath) { } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error extracting archive: " + e.getMessage()); - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -772,7 +772,7 @@ public static void unzip(File path, String dir) throws Exception { continue; } } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } try (OutputStream out = new FileOutputStream(entryPath.toFile())) { IOUtils.copy(in, out); @@ -855,7 +855,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc } }catch(Throwable ex) { downloadEvents.finishDownload(); - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; new File(inputFile).delete(); throw ex; } @@ -1032,7 +1032,7 @@ private static void rawFileDownload(ProcessInputStream pis, File folder, File ou out.flush(); out.close(); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; output.delete(); } exe.delete(); @@ -1062,7 +1062,7 @@ public static String delim() { // PasswordManager.login(); // } catch (IOException e) { // // Auto-generated catch block -// e.printStackTrace(); +// com.neuronrobotics.sdk.common.Log.error(e); // } // File f = getRunExecutable("eclipse",null); // String ws = EclipseExternalEditor.getEclipseWorkspace(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index 61b5f82a..a1d35ce7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -98,7 +98,7 @@ public void getDefaultContents(File freecadGenFile) { args.add(freecadGenFile.getAbsolutePath()); legacySystemRun(null, freecadGenFile.getAbsoluteFile().getParentFile(), System.out, args); }catch(Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } @@ -127,7 +127,7 @@ public static void addCSGToFreeCAD(File freecadModel,CSG toSlice, List args) { // .cast(bad)); // } catch (ClassNotFoundException e) { // // Auto-generated catch block -// e.printStackTrace(); +// com.neuronrobotics.sdk.common.Log.error(e); // } // com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " // + bad); @@ -57,17 +57,17 @@ public Object inlineScriptRun(String code, ArrayList args) { try { results.add(interp.get("csg", CSG.class)); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } try { results.add(interp.get("tab", Tab.class)); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } try { results.add(interp.get("device", BowlerAbstractDevice.class)); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } Log.debug("Jython return = " + results); @@ -83,7 +83,7 @@ public Object inlineScriptRun(File code, ArrayList args) { return inlineScriptRun(s, args); } catch (IOException e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java index 2b38c878..2624d6e6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java @@ -32,12 +32,12 @@ public Object inlineScriptRun(File code, ArrayList args) { return MobileBaseLoader.get(mb).getBase(); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return null; } } catch (IOException e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } // com.neuronrobotics.sdk.common.Log.error("Clojure returned of type="+ret.getClass()+" value="+ret); return null; @@ -51,7 +51,7 @@ public Object inlineScriptRun(String code, ArrayList args) { mb = new MobileBase(IOUtils.toInputStream(code, "UTF-8")); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return null; } @@ -122,7 +122,7 @@ public void getDefaultContents(String gitURL, String slug) { out.close(); // don't swallow close Exception if copy completes // normally } catch(Throwable t){ - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); }finally { try { out.close(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 68bff26a..319d4562 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -258,7 +258,7 @@ private static void cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean accessor.run(git); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } gitclose(git); } @@ -385,7 +385,7 @@ public static void openGit(String url, IGitAccessor accessor) { return; } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new RuntimeException("IOException making repo"); } @@ -592,7 +592,7 @@ public static File getWorkingDirectory() { createSymlinkInDocuments(appDataDir); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } delim = "/"; @@ -763,7 +763,7 @@ public static void waitForRepo(String remoteURI, String reason) { } } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -802,7 +802,7 @@ private static void deleteFolder(File folder) { com.neuronrobotics.sdk.common.Log.error("File failed to delete! " + f); } } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } // com.neuronrobotics.sdk.common.Log.error("Deleting " + f.getAbsolutePath()); } @@ -812,7 +812,7 @@ private static void deleteFolder(File folder) { com.neuronrobotics.sdk.common.Log.error("Deleting Folder " + folder.getAbsolutePath()); folder.delete(); } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } if (folder.exists()) { com.neuronrobotics.sdk.common.Log.error("Folder failed to delete! " + folder); @@ -1012,7 +1012,7 @@ private static void commit(String id, String branch, String FileName, String con } } catch (Exception e) { // ignore CSG database - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -1106,7 +1106,7 @@ public static void pushCodeToGit(String remoteURI, String branch, String FileNam }); com.neuronrobotics.sdk.common.Log.debug("PUSH OK! file: " + desired + " on branch " + getBranch(remoteURI)); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; String[] gitID = ScriptingEngine.findGitTagFromFile(desired); String id = gitID[0]; @@ -1304,7 +1304,7 @@ public static void newBranch(String remoteURI, String newBranch, RevCommit sourc } } } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } openGit(localRepo, git -> { @@ -1335,7 +1335,7 @@ private static void newBranchLocal(String newBranch, String remoteURI, Git git, com.neuronrobotics.sdk.common.Log.error("Created new branch " + remoteURI + "\t\t" + newBranch); } catch (org.eclipse.jgit.api.errors.RefNotFoundException ex) { com.neuronrobotics.sdk.common.Log.error("ERROR Creating " + newBranch + " in " + remoteURI); - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } catch (org.eclipse.jgit.api.errors.RefAlreadyExistsException ex) { // just checkout the existing branch then } @@ -1487,7 +1487,7 @@ public static void pull(String remoteURI, String branch) throws IOException, Che PasswordManager.checkInternet(); throw ex; } catch (WrongRepositoryStateException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); PasswordManager.checkInternet(); // deleteRepo(remoteURI); @@ -1527,7 +1527,7 @@ public static void pull(String remoteURI, String branch) throws IOException, Che }); } } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + ex.getMessage()); } } catch (NoHeadException e) { @@ -1543,7 +1543,7 @@ public static void pull(String remoteURI, String branch) throws IOException, Che // } } catch (TransportException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); PasswordManager.checkInternet(); if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) { @@ -1559,7 +1559,7 @@ public static void pull(String remoteURI, String branch) throws IOException, Che } } catch (GitAPIException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); PasswordManager.checkInternet(); throw new RuntimeException("remoteURI " + remoteURI + " branch " + branch + " " + e.getMessage()); } @@ -1712,11 +1712,11 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti "auto-save in ScriptingEngine.resolveConflict", false, git); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } catch (IOException e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } } @@ -1734,7 +1734,7 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti } } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return true; } @@ -1787,7 +1787,7 @@ public static File cloneRepo(String remoteURI, String branch) { checkout(remoteURI, branch); } } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } @@ -2071,9 +2071,9 @@ public static String fork(String sourceURL, String newRepoName, String newRepoDe back.add(PasswordManager.getGithub().getRepository(PasswordManager.getLoginID() + "/" + newRepoName) .getHttpTransportUrl()); } - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } catch (Throwable ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } if (back.size() == 0) throw new RuntimeException("Repo could not be forked and does not exist"); @@ -2093,13 +2093,13 @@ public static GHRepository makeNewRepoNoFailOver(String newName, String descript repo = github.getRepositoryById("" + repo.getId()); return repo; } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } try { Thread.sleep(1000); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } return repo; @@ -2124,7 +2124,7 @@ public static GHRepository makeNewRepo(String newName, String description) throw newBranch(url, "main"); } catch (IOException | GitAPIException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } catch (org.kohsuke.github.HttpException ex) { if (ex.getMessage().contains("name already exists on this account")) { @@ -2147,7 +2147,7 @@ public static String locateGitUrlString(File f) { return back.get(0); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return null; } @@ -2361,7 +2361,7 @@ private static void commit(String url, String branch, String message, Git passed try { r.run(); } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } } @@ -2423,7 +2423,7 @@ public static List getAllTags(String gitRepo) { } } catch (Throwable e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } Collections.sort(tags, new Comparator() { public int compare(String object1, String object2) { @@ -2455,7 +2455,7 @@ public static void tagRepo(String remoteURI, String newTag) { try { git.tag().setName(newTag).setForceUpdate(true).call(); } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } if (git.getRepository().getConfig().getString("remote", "origin", "url").startsWith("git@")) git.push().setPushTags().setTransportConfigCallback(transportConfigCallback) @@ -2495,7 +2495,7 @@ public static void ignore(String url, String filepattern) throws Exception { } reader.close(); } catch (IOException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } contents += filepattern; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index 86c836b0..40a4740f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -22,7 +22,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio SVGLoad s = new SVGLoad(code.toURI()); return run(s); }catch(Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); com.neuronrobotics.sdk.common.Log.error("SVG had error, attempting to fix "+code.getAbsolutePath()); File tmp=GeometrySimplification.simplifySVG(code); SVGLoad s = new SVGLoad(tmp.toURI()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 8d6f19dc..7ac6ebd0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -46,7 +46,7 @@ public AddFromFile set(File source, CaDoodleFile cf) { getFile(); } catch (NoSuchFileException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); break; } return this; @@ -93,7 +93,7 @@ public List process(List incoming) { try { flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); }catch(Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); flattenedCSGs=new ArrayList(); flattenedCSGs.add(new Cube(10).toCSG().setColor(javafx.scene.paint.Color.HOTPINK)); } @@ -105,7 +105,7 @@ public List process(List incoming) { CSG processedCSG = processGiven(csg, i, getOrderedName(),file,name,getLocation()); collect.add(processedCSG); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } CSGDatabase.setInstance(instance); @@ -169,7 +169,7 @@ public static File toLocal(File file, String name,CaDoodleFile cf ) { file = copied; } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } else { // doodle copy @@ -335,7 +335,7 @@ private static CSG processGiven(CSG csg, int i, String name, File f,String task, csg1.setParameter(getFileLocationparam(f,task)); return processGiven(csg1, i, name,f,task,location); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return previous; }).setName(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index f993b08d..216b37c4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -91,12 +91,12 @@ public List process(List incoming, String fileName) { } back.addAll(collect); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); if (!fileName.contains("generated")) { try { return process(incoming, "generated/" + fileRel); } catch (Exception e2) { - e2.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e2); } } throw new RuntimeException(e); @@ -125,7 +125,7 @@ public File getFile() { return ScriptingEngine.fileFromGit(gitULR, fileRel); } catch (GitAPIException | IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return null; } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e203286d..cd84d0b6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -181,7 +181,7 @@ public void initialize() { try { process(op); } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); indexStarting = i + 1; break; // opperations.remove(op); @@ -195,7 +195,7 @@ public void initialize() { try { l.onInitializationDone(); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } updateBoM(); @@ -249,7 +249,7 @@ public Thread regenerateFrom(CaDoodleOperation source) { if (initializing) return null; if (isRegenerating() || isOperationRunning() || source == null) { - new Exception("Operation Running, bailing").printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new Exception("Operation Running, bailing")); return null; } fireRegenerateStart(); @@ -297,7 +297,7 @@ public void run() { storeResultInCache(op, process); setCurrentState(op, process); } catch (Throwable tr) { - tr.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(tr); } } if (getCurrentIndex() != endIndex) { @@ -305,7 +305,7 @@ public void run() { updateCurrentFromCache(); } } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } setPercentInitialized(1); updateBoM(); @@ -313,7 +313,7 @@ public void run() { fireSaveSuggestion(); fireRegenerateDone(); } catch (Throwable th) { - th.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(th); } opperationRunner.remove(this); } @@ -325,7 +325,7 @@ public void run() { public Thread regenerateCurrent() { if (isOperationRunning()) { - new Exception("Operation Running, bailing").printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new Exception("Operation Running, bailing")); return opperationRunner.get(0); } @@ -407,7 +407,7 @@ public Thread addOpperation(CaDoodleOperation o) throws CadoodleConcurrencyExcep throw new NullPointerException(); toProcess.add(o); if (isOperationRunning()) { - new Exception("Operation Running, bailing").printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new Exception("Operation Running, bailing")); return opperationRunner.get(0); } Thread t = null; @@ -425,7 +425,7 @@ public void run() { fireRegenerateStart(); setResult(pruneForward(op)); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); break; } } @@ -434,7 +434,7 @@ public void run() { getOpperations().add(op); process(op); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } if (getResult() == OperationResult.INSERT) { @@ -443,7 +443,7 @@ public void run() { try { regenerateFrom(op).join(); } catch (InterruptedException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } updateCurrentFromCache(); } @@ -466,7 +466,7 @@ public Thread deleteOperation(CaDoodleOperation op) { if (op == null) throw new NullPointerException(); if (isOperationRunning()) { - new Exception("Operation Running, bailing").printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new Exception("Operation Running, bailing")); return opperationRunner.get(0); } Thread t = null; @@ -489,7 +489,7 @@ public void run() { try { regenerateFrom(newTar).join(); } catch (InterruptedException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } updateCurrentFromCache(); updateBoM(); @@ -520,7 +520,7 @@ public static int applyToAllConstituantElements(boolean addRet, List tar if (c.isInGroup()) continue; } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } applyToAllConstituantElements(addRet, s, back, p, depth,appliedMemory); } @@ -661,7 +661,7 @@ private CSG cloneCSG(CSG dyingCSG) { try { collect.add(p); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } csg.setPolygons(collect); @@ -765,7 +765,7 @@ public File getSelf() { self = File.createTempFile(DownloadManager.sanitizeString(projectName), ".doodle"); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } return self; @@ -816,7 +816,7 @@ private void setCurrentState(CaDoodleOperation op, List currentState) { try { l.onUpdate(currentState, op, this); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -827,7 +827,7 @@ private void fireSaveSuggestion() { try { l.onSaveSuggestion(); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -838,7 +838,7 @@ private void fireInitializationStart() { try { l.onInitializationStart(); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -850,7 +850,7 @@ private void fireRegenerateDone() { TickToc.tic("Fire " + l.getClass()); l.onRegenerateDone(); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -861,7 +861,7 @@ private void fireRegenerateStart() { try { l.onRegenerateStart(); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -872,7 +872,7 @@ private void fireWorkplaneChange() { try { l.onWorkplaneChange(workplane); } catch (Throwable e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } @@ -941,7 +941,7 @@ public File save() throws IOException { } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } if (bom != null) @@ -993,13 +993,13 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I } catch (IOException e) { // com.neuronrobotics.sdk.common.Log.error("Error saving image: " + // e.getMessage()); - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } do { try { Thread.sleep(10); } catch (InterruptedException e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); return; } } while (!imageCache.exists()); @@ -1010,7 +1010,7 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I imageCache.getAbsolutePath()); } } catch (Throwable t) { - t.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(t); } } @@ -1034,7 +1034,7 @@ public WritableImage loadImageFromFile() { } } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error loading image: " + e.getMessage()); - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return img; } @@ -1048,7 +1048,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr holder.add(ThumbnailImage.get(currentState)); }); } catch (Throwable ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; return null; } long start = System.currentTimeMillis(); @@ -1058,7 +1058,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr // com.neuronrobotics.sdk.common.Log.error("Waiting for image to write"); } catch (InterruptedException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); break; } if (System.currentTimeMillis() - start > 25000 && holder.size() == 0) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 10c980b7..bb310700 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -26,7 +26,7 @@ public static CSG get(String typencoming, ArrayList args) { try { return get( type, listVitaminSizes.get(0), args); }catch(Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; throw ex; } } @@ -119,7 +119,7 @@ public CSG regenerate(CSG previous) { return back; } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } throw new RuntimeException("Failed to load vitamin of type " + type); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 18436c3b..2a0aae7f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -78,7 +78,7 @@ public static Transform getTotalOffset(CSG c) { Transform transTmp = new Transform().apply((Transform) storage.getValue(s).get()); start = transTmp.apply(start); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } nrToCSG = start; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 4f5b6745..240baa47 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -68,7 +68,7 @@ public Sweep set(File source,CaDoodleFile cf) throws Exception { try { getFile(); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } return this; } @@ -102,7 +102,7 @@ public CSG sweep(Polygon p, String name, Bounds b) { return Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90).setName(name); } catch (ColinearPointsException e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return new Cube(10).toCSG().setColor(Color.PINK); } @@ -192,7 +192,7 @@ public List process(List incoming) { back.addAll(collect); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return back; } @@ -264,7 +264,7 @@ private CSG processGiven(Polygon p, Bounds b, int j, String name) { com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); return processGiven(p, b, j, name); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return previous; }).setName(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java index e1fcba9f..3b608be3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotLimb.java @@ -58,7 +58,7 @@ public List process(List incoming) { try { builder.build(); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } DHParameterKinematics newLimb = builder.getMobileBase().getLimbByName(getName()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java index 893d9b24..d7156a4e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/MakeRobot.java @@ -35,7 +35,7 @@ public List process(List incoming) { } } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return incoming; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java index e02d294c..a3c2fc62 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/ModifyLimb.java @@ -190,7 +190,7 @@ public void undo() { builder.build(); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } @@ -203,7 +203,7 @@ public void redo() { builder.build(); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java index addaf30f..068779eb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Purchasing.java @@ -185,7 +185,7 @@ public static ArrayList listVitaminTypes() { } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return types; } @@ -231,7 +231,7 @@ public static ArrayList listVitaminVariants(String type, String size) { } catch (java.net.ConnectException ce) { // server or cart is not availible, reject vitamin } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index f18dd7d4..148ffaf1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -59,7 +59,7 @@ public VitaminBomManager(File parentFile) { bom.createNewFile(); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } else { String source; @@ -70,7 +70,7 @@ public VitaminBomManager(File parentFile) { if (source.length() > 0) database = gson.fromJson(source, type); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } if (database == null) { @@ -148,7 +148,7 @@ public CSG get(String name) { } catch (Exception e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } return null; } @@ -171,7 +171,7 @@ public double getMassKg(String name) { try { return (double) getConfiguration(name).get("massKg"); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; return 0.001; } } @@ -228,7 +228,7 @@ private synchronized void saveLocal() { URL = (String) configuration.get("source"); object = configuration.get("price"); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } if (URL == null) { @@ -257,7 +257,7 @@ private synchronized void saveLocal() { write(getManufacturingBomCsv(), csv); } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } saving = false; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index bfd67f4e..3a2a3114 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -116,11 +116,11 @@ public static CSG get(File resource, boolean forceRefresh) { // }); // } catch (IOException e) { // // Auto-generated catch block -// e.printStackTrace(); +// com.neuronrobotics.sdk.common.Log.error(e); // } } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } CSG csg = fileLastLoaded.get(resource.getAbsolutePath()); @@ -142,7 +142,7 @@ public static CSG get(String type, String id, String purchasingVariant) throws E try { fileLastLoaded.put(key, get(type, id)); } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); setGitRepoDatabase(gitRpoDatabase); clear(); @@ -165,7 +165,7 @@ public static boolean isGitURL(String text2) { new java.net.URL(text2); } catch (Exception ex) { if (!text2.startsWith("git@")) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; return false; } } @@ -219,7 +219,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception return newVitamin; } catch (Exception ex) { // com.neuronrobotics.sdk.common.Log.error(type +"-"+ id+" Failed"); - // ex.printStackTrace(); + // com.neuronrobotics.sdk.common.Log.error(ex);; return newVitamin; } } else { @@ -227,7 +227,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception return null; } } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); setGitRepoDatabase(gitRpoDatabase); //ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); @@ -259,16 +259,16 @@ public static File getScriptFile(String type) { return ScriptingEngine.fileFromGit(script.get("scriptGit").toString(), script.get("scriptFile").toString()); } catch (InvalidRemoteException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (TransportException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (GitAPIException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } catch (IOException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } return null; } @@ -297,7 +297,7 @@ public static ConcurrentHashMap getConfiguration(String type, St } return ConcurrentHashMap; }catch(Exception ex) { - //ex.printStackTrace(); + //com.neuronrobotics.sdk.common.Log.error(ex);; } return new ConcurrentHashMap(); } @@ -359,7 +359,7 @@ public static boolean saveDatabase(String type) throws Exception { saveDatabase(type); return true; } - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; throw ex; } return true; @@ -378,7 +378,7 @@ public static void saveDatabaseForkIfMissing(String type,String username) throws if(type!=null) saveDatabase(type); } catch (Exception ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; //com.neuronrobotics.sdk.common.Log.error("Forked repo is missing!"); newRepo = github.getRepository(getSourcerepo()).fork(); @@ -390,7 +390,7 @@ public static void saveDatabaseForkIfMissing(String type,String username) throws break; }catch(Exception exc) { System.err.println("Waiting for repo to finish forking"); - exc.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(exc); } } saveDatabase(type); @@ -437,11 +437,11 @@ private static void processSelfPR(GHPullRequest request) throws IOException { BowlerKernel.upenURL(request.getHtmlUrl().toURI()); } catch (URISyntaxException e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } } } catch (java.lang.NullPointerException ex) { - ex.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(ex);; } } @@ -506,7 +506,7 @@ public static ConcurrentHashMap> getDa // If the file changes, clear the database and load the new data //com.neuronrobotics.sdk.common.Log.error("Re-loading " + type); databaseSet.put(type, null); - new RuntimeException().printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(new RuntimeException()); }); onChange = changeListeners.get(type); } @@ -537,7 +537,7 @@ public static ConcurrentHashMap> getDa double num = Double.parseDouble(conf.get(confKey).toString()); conf.put(confKey, num); } catch (NumberFormatException ex) { - // ex.printStackTrace(); + // com.neuronrobotics.sdk.common.Log.error(ex);; // leave as a string conf.put(confKey, conf.get(confKey).toString()); } @@ -545,7 +545,7 @@ public static ConcurrentHashMap> getDa } } catch (Exception e) { - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); databaseSet.put(type, new ConcurrentHashMap>()); } } @@ -632,7 +632,7 @@ public static CopyOnWriteArrayList listVitaminTypes() { } catch (Exception e) { // Auto-generated catch block - e.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e); } Collections.sort(types); return types; @@ -701,7 +701,7 @@ public static void reLoadDatabaseFromFiles() { ScriptingEngine.pull(getGitRepoDatabase()); } catch (Exception e1) { // Auto-generated catch block - e1.printStackTrace(); + com.neuronrobotics.sdk.common.Log.error(e1); } } catch (Exception e) { new IssueReportingExceptionHandler().uncaughtException(Thread.currentThread(), e); From 7f467d36f3f6d5cbc1c68e82b41ff9d565f86951 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 22 Sep 2025 08:35:05 -0400 Subject: [PATCH 574/635] java --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 519c1aec..b33bce6d 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 519c1aec0a9054f0635dd00f3382f91a31f84fb5 +Subproject commit b33bce6ddc7e31416f561813ab783f6886b3c121 From 7df77d3d5c3354a66031fcdfed196177f3d240d0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 22 Sep 2025 09:08:32 -0400 Subject: [PATCH 575/635] log flush --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index b33bce6d..ced47095 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit b33bce6ddc7e31416f561813ab783f6886b3c121 +Subproject commit ced470954021660497413bc6293958039d50fcb3 From 37908504ffb8078b5608a1ae4a4568533ece83d8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 22 Sep 2025 10:02:57 -0400 Subject: [PATCH 576/635] always specify local when formatting --- JCSG | 2 +- java-bowler | 2 +- .../neuronrobotics/bowlerstudio/scripting/DownloadManager.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/JCSG b/JCSG index 47fc7abd..728c8f2e 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 47fc7abd97e7727e85b435513c89076a121312ad +Subproject commit 728c8f2edfba2921a36bdae9aa031f40a35eb6a5 diff --git a/java-bowler b/java-bowler index ced47095..4ec63fa5 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit ced470954021660497413bc6293958039d50fcb3 +Subproject commit 4ec63fa519490fbe935eb70752d0941fec23ff9c diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index 953d57f9..71126386 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -902,7 +903,7 @@ public static void untar(File tarFile, String dir) throws Exception { } private static String bits(byte b) { - return String.format("%6s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'); + return String.format(Locale.US,"%6s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'); } public static boolean isWin() { From d56d4cbb3207fab6df1ed9e59b295c2e838d227b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 23 Sep 2025 09:07:27 -0400 Subject: [PATCH 577/635] logfile --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 4ec63fa5..2f8f22b0 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 4ec63fa519490fbe935eb70752d0941fec23ff9c +Subproject commit 2f8f22b0c630f687ef18b6324b81f780b9a1ff1b From 636b5e854304758a433f89b30e93cc74810b5d3f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Tue, 23 Sep 2025 10:17:13 -0400 Subject: [PATCH 578/635] logs --- java-bowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-bowler b/java-bowler index 2f8f22b0..c802de44 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 2f8f22b0c630f687ef18b6324b81f780b9a1ff1b +Subproject commit c802de4418aa7ca8a2ba6e0138ead5fd0e22a705 From 3d1c71fa3ca47757bffc8d3032b911104294f711 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 24 Sep 2025 10:28:03 -0400 Subject: [PATCH 579/635] change errors to debug when it is a debug statement --- .../bowlerstudio/assets/AssetFactory.java | 8 ++-- .../scripting/ScriptingEngine.java | 46 +++++++++---------- .../scripting/cadoodle/CaDoodleFile.java | 6 +-- .../CaDoodleJsonOperationAdapterFactory.java | 2 +- .../bowlerstudio/util/FileChangeWatcher.java | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 0c70b362..1c58f0ad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -36,7 +36,7 @@ private AssetFactory() { } static { - com.neuronrobotics.sdk.common.Log.error("AssetFactory loaded"); + com.neuronrobotics.sdk.common.Log.info("AssetFactory loaded"); // new RuntimeException().printStackTrace(); } @@ -88,7 +88,7 @@ public static void writeImage(Image img, File file) { @SuppressWarnings("restriction") public static Image loadAsset(String file) throws Exception { if (cache.get(file) == null) { - com.neuronrobotics.sdk.common.Log.debug("Loading asset " + file); + //com.neuronrobotics.sdk.common.Log.debug("Loading asset " + file); File f = loadFile(file); if (f.getName().endsWith(".fxml")) { loadLayout(file); @@ -165,7 +165,7 @@ public static void setGitSource(String gitSource, String assetRepoBranch) throws } public static void loadAllAssets() throws Exception { - com.neuronrobotics.sdk.common.Log.error("Loading assets"); + com.neuronrobotics.sdk.common.Log.info("Loading assets"); List files; try { files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); @@ -173,7 +173,7 @@ public static void loadAllAssets() throws Exception { files = ScriptingEngine.filesInGit(getGitSource()); } for (String file : files) { - com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file); + //com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file); loadAsset(file); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 319d4562..fd5d5c86 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -203,7 +203,7 @@ public static List flaten(File f, Class type, ArrayList args) public static void setWorkspace(File file) { workspace = file; - com.neuronrobotics.sdk.common.Log.error("Workspace: " + workspace.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Workspace: " + workspace.getAbsolutePath()); if (!workspace.exists()) { workspace.mkdir(); } @@ -328,7 +328,7 @@ public void update(int completed) { String str = format + "% " + stage + " " + reponame + " " + tasks + " of task " + type; if (timeofLastUpdate + 500 < System.currentTimeMillis()) { if (printProgress) - com.neuronrobotics.sdk.common.Log.error(str); + com.neuronrobotics.sdk.common.Log.debug(str); timeofLastUpdate = System.currentTimeMillis(); } // com.neuronrobotics.sdk.common.Log.error(str); @@ -352,7 +352,7 @@ public boolean isCancelled() { public void endTask() { String string = "100% " + stage + " " + reponame + " " + type; if (printProgress) - com.neuronrobotics.sdk.common.Log.error(string); + com.neuronrobotics.sdk.common.Log.debug(string); for (GitLogProgressMonitor l : logListeners) { l.onLogUpdate(string, e); } @@ -559,7 +559,7 @@ public static void createSymlinkInDocuments(File appDataDir) throws IOException // Create the symlink Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); - com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); + com.neuronrobotics.sdk.common.Log.debug("Symlink created: " + symlinkPath); } private static Path getWindowsAppData(String appName) { // Try APPDATA first, then LOCALAPPDATA, then fallback @@ -737,7 +737,7 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr com.neuronrobotics.sdk.common.Log.error("No login api key found!"); return; } - com.neuronrobotics.sdk.common.Log.error("Performing Login"); + com.neuronrobotics.sdk.common.Log.debug("Performing Login"); PasswordManager.waitForLogin(); if (!PasswordManager.loggedIn()) { @@ -797,9 +797,9 @@ private static void deleteFolder(File folder) { try { FileChangeWatcher.notifyOfDelete(f); FileChangeWatcher.close(f); - com.neuronrobotics.sdk.common.Log.error("Deleting File " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Deleting File " + f.getAbsolutePath()); if (!f.delete()) { - com.neuronrobotics.sdk.common.Log.error("File failed to delete! " + f); + com.neuronrobotics.sdk.common.Log.debug("File failed to delete! " + f); } } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error(t); @@ -1135,7 +1135,7 @@ private static String[] codeFromGistID(String id, String FileName) throws Except File targetFile = fileFromGit(giturl, FileName); if (targetFile.exists()) { - com.neuronrobotics.sdk.common.Log.error("Gist at GIT : " + giturl); + com.neuronrobotics.sdk.common.Log.debug("Gist at GIT : " + giturl); // Target file is ready to go String text = new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())), StandardCharsets.UTF_8); @@ -1332,9 +1332,9 @@ private static void newBranchLocal(String newBranch, String remoteURI, Git git, setName.setForce(true); } setName.call(); - com.neuronrobotics.sdk.common.Log.error("Created new branch " + remoteURI + "\t\t" + newBranch); + com.neuronrobotics.sdk.common.Log.debug("Created new branch " + remoteURI + "\t\t" + newBranch); } catch (org.eclipse.jgit.api.errors.RefNotFoundException ex) { - com.neuronrobotics.sdk.common.Log.error("ERROR Creating " + newBranch + " in " + remoteURI); + com.neuronrobotics.sdk.common.Log.debug("ERROR Creating " + newBranch + " in " + remoteURI); com.neuronrobotics.sdk.common.Log.error(ex);; } catch (org.eclipse.jgit.api.errors.RefAlreadyExistsException ex) { // just checkout the existing branch then @@ -1579,7 +1579,7 @@ public static void checkoutCommit(String remoteURI, String branch, String commit waitForRepo(remoteURI, "checkoutCommit"); File gitRepoFile = ScriptingEngine.uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } Repository localRepo = new FileRepository(gitRepoFile); @@ -1611,7 +1611,7 @@ public static void checkout(String remoteURI, String branch) // cloneRepo(remoteURI, branch); File gitRepoFile = uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } @@ -1631,7 +1631,7 @@ public static void checkout(String remoteURI, String branch) openGit(localRepo, git -> { for (Ref R : branches) { if (R.getName().endsWith(br)) { - com.neuronrobotics.sdk.common.Log.error("\nFound upstream " + R.getName()); + com.neuronrobotics.sdk.common.Log.debug("Found upstream " + R.getName()); shallowCheckout(remoteURI, br, git); } } @@ -1699,9 +1699,9 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti Status stat = git.status().call(); Set changed = stat.getModified(); if (changed.size() > 0) { - com.neuronrobotics.sdk.common.Log.error("Modified "); + com.neuronrobotics.sdk.common.Log.debug("Modified "); for (String p : changed) { - com.neuronrobotics.sdk.common.Log.error("Modified Conflict with: " + p); + com.neuronrobotics.sdk.common.Log.debug("Modified Conflict with: " + p); byte[] bytes; String content = ""; try { @@ -1767,10 +1767,10 @@ public static File cloneRepo(String remoteURI, String branch) { if (!hasNetwork()) return null;// No login info means there is no way to publish waitForRepo(remoteURI, "cloneRepo"); - com.neuronrobotics.sdk.common.Log.error("Cloning files from: " + remoteURI); + com.neuronrobotics.sdk.common.Log.debug("Cloning files from: " + remoteURI); if (branch != null) - com.neuronrobotics.sdk.common.Log.error(" branch: " + branch); - com.neuronrobotics.sdk.common.Log.error(" to: " + localPath); + com.neuronrobotics.sdk.common.Log.debug(" branch: " + branch); + com.neuronrobotics.sdk.common.Log.debug(" to: " + localPath); Throwable ex = null; // Clone the repo try { @@ -2158,7 +2158,7 @@ public static String urlToString(URL htmlUrl) { public static String urlToGist(URL htmlUrl) { String externalForm = urlToString(htmlUrl); - com.neuronrobotics.sdk.common.Log.error(externalForm); + com.neuronrobotics.sdk.common.Log.debug(externalForm); return ScriptingEngine.urlToGist(externalForm); } @@ -2250,7 +2250,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi if (newFileCode == null) newFileCode = new String[] { "" }; if (newFileCode[0].length() < 10) { - com.neuronrobotics.sdk.common.Log.error("Copy Content to " + targetGit + "/" + targetFilename); + com.neuronrobotics.sdk.common.Log.debug("Copy Content to " + targetGit + "/" + targetFilename); ScriptingEngine.pushCodeToGit(targetGit, ScriptingEngine.getFullBranch(targetGit), targetFilename, WalkingEngine[0], "copy file content"); } @@ -2437,7 +2437,7 @@ public int compare(String object1, String object2) { public static boolean tagExists(String remoteURI, String newTag) { List tags = getAllTags(remoteURI); for (String s : tags) { - com.neuronrobotics.sdk.common.Log.error("Checking " + newTag + " against " + s); + com.neuronrobotics.sdk.common.Log.debug("Checking " + newTag + " against " + s); if (s.contentEquals(newTag)) { return true; } @@ -2446,7 +2446,7 @@ public static boolean tagExists(String remoteURI, String newTag) { } public static void tagRepo(String remoteURI, String newTag) { - com.neuronrobotics.sdk.common.Log.error("Tagging " + remoteURI + " at " + newTag); + com.neuronrobotics.sdk.common.Log.debug("Tagging " + remoteURI + " at " + newTag); if (tagExists(remoteURI, newTag)) { com.neuronrobotics.sdk.common.Log.error("ERROR! Tag exists " + remoteURI + "@" + newTag); return; @@ -2485,7 +2485,7 @@ public static void ignore(String url, String filepattern) throws Exception { while (line != null) { if (line.contains(filepattern)) { com.neuronrobotics.sdk.common.Log - .error("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); + .debug("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); reader.close(); return; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index cd84d0b6..cb377ef1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -745,7 +745,7 @@ private void updateCurrentFromCache() { CaDoodleOperation key = getCurrentOpperation(); if (key == null) return; - com.neuronrobotics.sdk.common.Log.error("Current opperation results: " + key.getType()); + com.neuronrobotics.sdk.common.Log.debug("Current opperation results: " + key.getType()); setCurrentState(key, getCurrentState()); } @@ -1097,14 +1097,14 @@ public static CaDoodleFile fromFile(File f) throws Exception { } public static String getProjectName(File f) throws Exception { - com.neuronrobotics.sdk.common.Log.error("CaDoodle file reading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("CaDoodle file reading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, null, f, false); return file.getMyProjectName(); } public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boolean initialize) throws Exception { - com.neuronrobotics.sdk.common.Log.error("CaDoodle file loading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("CaDoodle file loading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, listener, f, initialize); return file; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 52c63de4..da4daedc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -84,7 +84,7 @@ public T read(JsonReader in) throws IOException { } TypeAdapter delegateAdapter = gson .getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); - com.neuronrobotics.sdk.common.Log.error("JSON Parsing " + typeName); + //com.neuronrobotics.sdk.common.Log.error("JSON Parsing " + typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } }.nullSafe(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java index 7d9325e3..9c8a8d5b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java @@ -114,7 +114,7 @@ public static FileChangeWatcher watch(File fileToWatch) throws IOException { String path = fileToWatch.getAbsolutePath(); if (activeListener.get(path) == null) { activeListener.put(path, new FileChangeWatcher(fileToWatch)); - com.neuronrobotics.sdk.common.Log.error("Adding file to listening " + fileToWatch.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Adding file to listening " + fileToWatch.getAbsolutePath()); } return activeListener.get(path); } From df72a3659848bfb10b43b241fcf625ed93cebd71 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 24 Sep 2025 10:28:03 -0400 Subject: [PATCH 580/635] update the download manager to include a CLI setup script --- .../bowlerstudio/assets/AssetFactory.java | 8 ++-- .../scripting/Build123dLoader.java | 16 ++++--- .../scripting/DownloadManager.java | 33 +++++++++++-- .../scripting/ScriptingEngine.java | 46 +++++++++---------- .../scripting/cadoodle/CaDoodleFile.java | 6 +-- .../CaDoodleJsonOperationAdapterFactory.java | 2 +- .../bowlerstudio/util/FileChangeWatcher.java | 2 +- 7 files changed, 70 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java index 0c70b362..1c58f0ad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java @@ -36,7 +36,7 @@ private AssetFactory() { } static { - com.neuronrobotics.sdk.common.Log.error("AssetFactory loaded"); + com.neuronrobotics.sdk.common.Log.info("AssetFactory loaded"); // new RuntimeException().printStackTrace(); } @@ -88,7 +88,7 @@ public static void writeImage(Image img, File file) { @SuppressWarnings("restriction") public static Image loadAsset(String file) throws Exception { if (cache.get(file) == null) { - com.neuronrobotics.sdk.common.Log.debug("Loading asset " + file); + //com.neuronrobotics.sdk.common.Log.debug("Loading asset " + file); File f = loadFile(file); if (f.getName().endsWith(".fxml")) { loadLayout(file); @@ -165,7 +165,7 @@ public static void setGitSource(String gitSource, String assetRepoBranch) throws } public static void loadAllAssets() throws Exception { - com.neuronrobotics.sdk.common.Log.error("Loading assets"); + com.neuronrobotics.sdk.common.Log.info("Loading assets"); List files; try { files = ScriptingEngine.filesInGit(gitSource, StudioBuildInfo.getVersion(), null); @@ -173,7 +173,7 @@ public static void loadAllAssets() throws Exception { files = ScriptingEngine.filesInGit(getGitSource()); } for (String file : files) { - com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file); + //com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file); loadAsset(file); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java index 9d9a22a2..88e14edc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java @@ -12,6 +12,7 @@ import org.eclipse.jgit.api.errors.TransportException; import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; +import com.neuronrobotics.sdk.common.Log; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; @@ -59,8 +60,9 @@ public ArrayList getFileExtenetion() { - public static void toSTLFile(File openscadfile,File stlout, HashMap params) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + public static void toSTLFile(File build123dScript,File stlout, HashMap params) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { File exe = getConfigExecutable("build123d", null); + File dir = getDestinationDir("build123d"); if(params==null) params=new HashMap(); ArrayList args = new ArrayList<>(); @@ -68,14 +70,16 @@ public static void toSTLFile(File openscadfile,File stlout, HashMap vm = (Map) database.get(key); if (vm != null) { String targetdir = exeType; - com.neuronrobotics.sdk.common.Log.error("Configuration found for " + exeType + " on " + key); + com.neuronrobotics.sdk.common.Log.debug("Configuration found for " + exeType + " on " + key); String baseURL = vm.get("url").toString(); String type = vm.get("type").toString(); String name = vm.get("name").toString(); @@ -443,6 +448,12 @@ private static File getExecutable(String exeType, IExternalEditor editor, String if (installer != null) { runInstaller((List) installer); } + Object setup = vm.get("setup"); + if (setup != null) { + String setupScript = setup.toString(); + File setupEXE = new File(getDestinationDir(exeType).getAbsolutePath()+delim()+setupScript); + runInstaller(setupEXE,exeType); + } Object configurations = database.get("Meta-Configuration"); if (configurations != null) { @@ -535,10 +546,14 @@ private static void saveFile(File file, String json) { com.neuronrobotics.sdk.common.Log.error(e); } } - private static void runInstaller(List installerList) { for (String installer : installerList) { File installerFile = getRunExecutable(installer, null); + runInstaller( installerFile, installer); + } + } + private static void runInstaller(File installerFile,String installer) { + if(installerFile.getAbsolutePath().toLowerCase().endsWith("msi")) { List command = new ArrayList<>(); command.add("msiexec.exe"); @@ -553,8 +568,16 @@ private static void runInstaller(List installerList) { // Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e); } + }else if(installerFile.getAbsolutePath().toLowerCase().endsWith("sh")) { + Thread tcopy = run(null, getDestinationDir(installer), System.out, Arrays.asList("bash",installerFile.getAbsolutePath())); + try { + tcopy.join(); + } catch (InterruptedException e) { + // Auto-generated catch block + com.neuronrobotics.sdk.common.Log.error(e); + } }else { - Thread tcopy = run(null, new File("."), System.out, Arrays.asList(installerFile.getAbsolutePath())); + Thread tcopy = run(null, getDestinationDir(installer), System.out, Arrays.asList(installerFile.getAbsolutePath())); try { tcopy.join(); } catch (InterruptedException e) { @@ -562,7 +585,7 @@ private static void runInstaller(List installerList) { com.neuronrobotics.sdk.common.Log.error(e); } } - } + } private static boolean deleteDirectory(File directoryToBeDeleted) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 319d4562..fd5d5c86 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -203,7 +203,7 @@ public static List flaten(File f, Class type, ArrayList args) public static void setWorkspace(File file) { workspace = file; - com.neuronrobotics.sdk.common.Log.error("Workspace: " + workspace.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Workspace: " + workspace.getAbsolutePath()); if (!workspace.exists()) { workspace.mkdir(); } @@ -328,7 +328,7 @@ public void update(int completed) { String str = format + "% " + stage + " " + reponame + " " + tasks + " of task " + type; if (timeofLastUpdate + 500 < System.currentTimeMillis()) { if (printProgress) - com.neuronrobotics.sdk.common.Log.error(str); + com.neuronrobotics.sdk.common.Log.debug(str); timeofLastUpdate = System.currentTimeMillis(); } // com.neuronrobotics.sdk.common.Log.error(str); @@ -352,7 +352,7 @@ public boolean isCancelled() { public void endTask() { String string = "100% " + stage + " " + reponame + " " + type; if (printProgress) - com.neuronrobotics.sdk.common.Log.error(string); + com.neuronrobotics.sdk.common.Log.debug(string); for (GitLogProgressMonitor l : logListeners) { l.onLogUpdate(string, e); } @@ -559,7 +559,7 @@ public static void createSymlinkInDocuments(File appDataDir) throws IOException // Create the symlink Files.createSymbolicLink(symlinkPath, appDataDir.toPath()); - com.neuronrobotics.sdk.common.Log.error("Symlink created: " + symlinkPath); + com.neuronrobotics.sdk.common.Log.debug("Symlink created: " + symlinkPath); } private static Path getWindowsAppData(String appName) { // Try APPDATA first, then LOCALAPPDATA, then fallback @@ -737,7 +737,7 @@ public static void waitForLogin() throws IOException, InvalidRemoteException, Tr com.neuronrobotics.sdk.common.Log.error("No login api key found!"); return; } - com.neuronrobotics.sdk.common.Log.error("Performing Login"); + com.neuronrobotics.sdk.common.Log.debug("Performing Login"); PasswordManager.waitForLogin(); if (!PasswordManager.loggedIn()) { @@ -797,9 +797,9 @@ private static void deleteFolder(File folder) { try { FileChangeWatcher.notifyOfDelete(f); FileChangeWatcher.close(f); - com.neuronrobotics.sdk.common.Log.error("Deleting File " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Deleting File " + f.getAbsolutePath()); if (!f.delete()) { - com.neuronrobotics.sdk.common.Log.error("File failed to delete! " + f); + com.neuronrobotics.sdk.common.Log.debug("File failed to delete! " + f); } } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error(t); @@ -1135,7 +1135,7 @@ private static String[] codeFromGistID(String id, String FileName) throws Except File targetFile = fileFromGit(giturl, FileName); if (targetFile.exists()) { - com.neuronrobotics.sdk.common.Log.error("Gist at GIT : " + giturl); + com.neuronrobotics.sdk.common.Log.debug("Gist at GIT : " + giturl); // Target file is ready to go String text = new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())), StandardCharsets.UTF_8); @@ -1332,9 +1332,9 @@ private static void newBranchLocal(String newBranch, String remoteURI, Git git, setName.setForce(true); } setName.call(); - com.neuronrobotics.sdk.common.Log.error("Created new branch " + remoteURI + "\t\t" + newBranch); + com.neuronrobotics.sdk.common.Log.debug("Created new branch " + remoteURI + "\t\t" + newBranch); } catch (org.eclipse.jgit.api.errors.RefNotFoundException ex) { - com.neuronrobotics.sdk.common.Log.error("ERROR Creating " + newBranch + " in " + remoteURI); + com.neuronrobotics.sdk.common.Log.debug("ERROR Creating " + newBranch + " in " + remoteURI); com.neuronrobotics.sdk.common.Log.error(ex);; } catch (org.eclipse.jgit.api.errors.RefAlreadyExistsException ex) { // just checkout the existing branch then @@ -1579,7 +1579,7 @@ public static void checkoutCommit(String remoteURI, String branch, String commit waitForRepo(remoteURI, "checkoutCommit"); File gitRepoFile = ScriptingEngine.uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } Repository localRepo = new FileRepository(gitRepoFile); @@ -1611,7 +1611,7 @@ public static void checkout(String remoteURI, String branch) // cloneRepo(remoteURI, branch); File gitRepoFile = uriToFile(remoteURI); if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(".git")) { - com.neuronrobotics.sdk.common.Log.error("Invailid git file!" + gitRepoFile.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Invailid git file!" + gitRepoFile.getAbsolutePath()); throw new RuntimeException("Invailid git file!" + gitRepoFile.getAbsolutePath()); } @@ -1631,7 +1631,7 @@ public static void checkout(String remoteURI, String branch) openGit(localRepo, git -> { for (Ref R : branches) { if (R.getName().endsWith(br)) { - com.neuronrobotics.sdk.common.Log.error("\nFound upstream " + R.getName()); + com.neuronrobotics.sdk.common.Log.debug("Found upstream " + R.getName()); shallowCheckout(remoteURI, br, git); } } @@ -1699,9 +1699,9 @@ private static boolean resolveConflict(String remoteURI, CheckoutConflictExcepti Status stat = git.status().call(); Set changed = stat.getModified(); if (changed.size() > 0) { - com.neuronrobotics.sdk.common.Log.error("Modified "); + com.neuronrobotics.sdk.common.Log.debug("Modified "); for (String p : changed) { - com.neuronrobotics.sdk.common.Log.error("Modified Conflict with: " + p); + com.neuronrobotics.sdk.common.Log.debug("Modified Conflict with: " + p); byte[] bytes; String content = ""; try { @@ -1767,10 +1767,10 @@ public static File cloneRepo(String remoteURI, String branch) { if (!hasNetwork()) return null;// No login info means there is no way to publish waitForRepo(remoteURI, "cloneRepo"); - com.neuronrobotics.sdk.common.Log.error("Cloning files from: " + remoteURI); + com.neuronrobotics.sdk.common.Log.debug("Cloning files from: " + remoteURI); if (branch != null) - com.neuronrobotics.sdk.common.Log.error(" branch: " + branch); - com.neuronrobotics.sdk.common.Log.error(" to: " + localPath); + com.neuronrobotics.sdk.common.Log.debug(" branch: " + branch); + com.neuronrobotics.sdk.common.Log.debug(" to: " + localPath); Throwable ex = null; // Clone the repo try { @@ -2158,7 +2158,7 @@ public static String urlToString(URL htmlUrl) { public static String urlToGist(URL htmlUrl) { String externalForm = urlToString(htmlUrl); - com.neuronrobotics.sdk.common.Log.error(externalForm); + com.neuronrobotics.sdk.common.Log.debug(externalForm); return ScriptingEngine.urlToGist(externalForm); } @@ -2250,7 +2250,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi if (newFileCode == null) newFileCode = new String[] { "" }; if (newFileCode[0].length() < 10) { - com.neuronrobotics.sdk.common.Log.error("Copy Content to " + targetGit + "/" + targetFilename); + com.neuronrobotics.sdk.common.Log.debug("Copy Content to " + targetGit + "/" + targetFilename); ScriptingEngine.pushCodeToGit(targetGit, ScriptingEngine.getFullBranch(targetGit), targetFilename, WalkingEngine[0], "copy file content"); } @@ -2437,7 +2437,7 @@ public int compare(String object1, String object2) { public static boolean tagExists(String remoteURI, String newTag) { List tags = getAllTags(remoteURI); for (String s : tags) { - com.neuronrobotics.sdk.common.Log.error("Checking " + newTag + " against " + s); + com.neuronrobotics.sdk.common.Log.debug("Checking " + newTag + " against " + s); if (s.contentEquals(newTag)) { return true; } @@ -2446,7 +2446,7 @@ public static boolean tagExists(String remoteURI, String newTag) { } public static void tagRepo(String remoteURI, String newTag) { - com.neuronrobotics.sdk.common.Log.error("Tagging " + remoteURI + " at " + newTag); + com.neuronrobotics.sdk.common.Log.debug("Tagging " + remoteURI + " at " + newTag); if (tagExists(remoteURI, newTag)) { com.neuronrobotics.sdk.common.Log.error("ERROR! Tag exists " + remoteURI + "@" + newTag); return; @@ -2485,7 +2485,7 @@ public static void ignore(String url, String filepattern) throws Exception { while (line != null) { if (line.contains(filepattern)) { com.neuronrobotics.sdk.common.Log - .error("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); + .debug("" + filepattern + " exists in " + ignorefile.getAbsolutePath()); reader.close(); return; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index cd84d0b6..cb377ef1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -745,7 +745,7 @@ private void updateCurrentFromCache() { CaDoodleOperation key = getCurrentOpperation(); if (key == null) return; - com.neuronrobotics.sdk.common.Log.error("Current opperation results: " + key.getType()); + com.neuronrobotics.sdk.common.Log.debug("Current opperation results: " + key.getType()); setCurrentState(key, getCurrentState()); } @@ -1097,14 +1097,14 @@ public static CaDoodleFile fromFile(File f) throws Exception { } public static String getProjectName(File f) throws Exception { - com.neuronrobotics.sdk.common.Log.error("CaDoodle file reading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("CaDoodle file reading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, null, f, false); return file.getMyProjectName(); } public static CaDoodleFile fromFile(File f, ICaDoodleStateUpdate listener, boolean initialize) throws Exception { - com.neuronrobotics.sdk.common.Log.error("CaDoodle file loading from " + f.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("CaDoodle file loading from " + f.getAbsolutePath()); String content = FileUtils.readFileToString(f, StandardCharsets.UTF_8); CaDoodleFile file = fromJsonString(content, listener, f, initialize); return file; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java index 52c63de4..da4daedc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleJsonOperationAdapterFactory.java @@ -84,7 +84,7 @@ public T read(JsonReader in) throws IOException { } TypeAdapter delegateAdapter = gson .getDelegateAdapter(CaDoodleJsonOperationAdapterFactory.this, TypeToken.get(clazz)); - com.neuronrobotics.sdk.common.Log.error("JSON Parsing " + typeName); + //com.neuronrobotics.sdk.common.Log.error("JSON Parsing " + typeName); return (T) delegateAdapter.fromJsonTree(dataElement); } }.nullSafe(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java index 7d9325e3..9c8a8d5b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/FileChangeWatcher.java @@ -114,7 +114,7 @@ public static FileChangeWatcher watch(File fileToWatch) throws IOException { String path = fileToWatch.getAbsolutePath(); if (activeListener.get(path) == null) { activeListener.put(path, new FileChangeWatcher(fileToWatch)); - com.neuronrobotics.sdk.common.Log.error("Adding file to listening " + fileToWatch.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Adding file to listening " + fileToWatch.getAbsolutePath()); } return activeListener.get(path); } From 359c30209ff95babe6e51944d3aec901fe6bd02c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 26 Sep 2025 14:52:24 -0400 Subject: [PATCH 581/635] debug prints --- .../scripting/DownloadManager.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java index cc5aa604..eb500bb5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/DownloadManager.java @@ -119,7 +119,7 @@ public static File getTmpSTL(CSG stlIn) throws IOException { @Override public boolean get(String name, String url) { - com.neuronrobotics.sdk.common.Log.error("Command line mode, assuming yes to downloading \n" + name + " \nfrom \n" + url); + com.neuronrobotics.sdk.common.Log.debug("Command line mode, assuming yes to downloading \n" + name + " \nfrom \n" + url); return true; } @@ -183,7 +183,7 @@ public static void legacySystemRun(Map envincoming, File dir, Pr if (envincoming != null) { envir.putAll(envincoming); for (String s : envincoming.keySet()) { - com.neuronrobotics.sdk.common.Log.error("Environment var set: " + s + " to " + envir.get(s)); + com.neuronrobotics.sdk.common.Log.debug("Environment var set: " + s + " to " + envir.get(s)); } } // setting the directory @@ -306,7 +306,7 @@ public static Map getEnvironment(String exeType) { Map environment; Object o = vm.get("environment"); if (o != null) { - com.neuronrobotics.sdk.common.Log.error("Environment found for " + exeType + " on " + key); + com.neuronrobotics.sdk.common.Log.debug("Environment found for " + exeType + " on " + key); return (Map) o; } @@ -631,7 +631,7 @@ private static void dmgExtract(File jvmArchive, String string, String appDir) { after.removeAll(before); Object[] array = after.toArray(); String newMount = (String) array[0]; - com.neuronrobotics.sdk.common.Log.error("Extracted " + jvmArchive.getAbsolutePath() + " is mounted at " + newMount); + com.neuronrobotics.sdk.common.Log.debug("Extracted " + jvmArchive.getAbsolutePath() + " is mounted at " + newMount); // asr restore --source "$MOUNT_POINT" --target "$DEST_PATH" --erase --noprompt if (!location.exists()) { location.mkdirs(); @@ -692,8 +692,8 @@ public static void extract7zArchive(String archivePath, String outputPath) { try (RandomAccessFile randomAccessFile = new RandomAccessFile(archivePath, "r"); IInArchive inArchive = SevenZip.openInArchive(null, new RandomAccessFileInStream(randomAccessFile))) { - com.neuronrobotics.sdk.common.Log.error("Archive size: " + randomAccessFile.length() + " bytes"); - com.neuronrobotics.sdk.common.Log.error("Items in archive: " + inArchive.getNumberOfItems()); + com.neuronrobotics.sdk.common.Log.debug("Archive size: " + randomAccessFile.length() + " bytes"); + com.neuronrobotics.sdk.common.Log.debug("Items in archive: " + inArchive.getNumberOfItems()); for (int i = 0; i < inArchive.getNumberOfItems(); i++) { Boolean isFolder = (Boolean) inArchive.getProperty(i, PropID.IS_FOLDER); @@ -702,7 +702,7 @@ public static void extract7zArchive(String archivePath, String outputPath) { } } - com.neuronrobotics.sdk.common.Log.error("Extraction completed successfully."); + com.neuronrobotics.sdk.common.Log.debug("Extraction completed successfully."); } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error("Error extracting archive: " + e.getMessage()); @@ -738,7 +738,7 @@ public int write(byte[] data) throws SevenZipException { } downloadEvents.finishDownload(); if (result == ExtractOperationResult.OK) { - com.neuronrobotics.sdk.common.Log.error("Extracted: " + path); + com.neuronrobotics.sdk.common.Log.debug("Extracted: " + path); } else { com.neuronrobotics.sdk.common.Log.error("Error extracting " + path + ": " + result); } @@ -769,7 +769,7 @@ public int write(byte[] data) throws SevenZipException { * } */ public static void unzip(File path, String dir) throws Exception { - com.neuronrobotics.sdk.common.Log.error("Unzipping " + path.getName() + " into " + dir); + com.neuronrobotics.sdk.common.Log.debug("Unzipping " + path.getName() + " into " + dir); String fileBaseName = FilenameUtils.getBaseName(path.getName().toString()); Path destFolderPath = new File(dir).toPath(); @@ -790,7 +790,7 @@ public static void unzip(File path, String dir) throws Exception { String text = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)) .lines().collect(Collectors.joining("\n")); Path target = Paths.get(".", text); - com.neuronrobotics.sdk.common.Log.error("Creating symlink " + entryPath + " with " + target); + com.neuronrobotics.sdk.common.Log.debug("Creating symlink " + entryPath + " with " + target); Files.createSymbolicLink(entryPath, target); continue; @@ -800,7 +800,7 @@ public static void unzip(File path, String dir) throws Exception { } try (OutputStream out = new FileOutputStream(entryPath.toFile())) { IOUtils.copy(in, out); - com.neuronrobotics.sdk.common.Log.error("Inflating " + entryPath); + com.neuronrobotics.sdk.common.Log.debug("Inflating " + entryPath); } if (isExecutable(entry)) { @@ -887,7 +887,7 @@ public static void extractTarXz(String inputFile, String outputDir) throws IOExc } public static void untar(File tarFile, String dir) throws Exception { - com.neuronrobotics.sdk.common.Log.error("Untaring " + tarFile.getName() + " into " + dir); + com.neuronrobotics.sdk.common.Log.debug("Untaring " + tarFile.getName() + " into " + dir); File dest = new File(dir); dest.mkdir(); @@ -903,7 +903,7 @@ public static void untar(File tarFile, String dir) throws Exception { // tarIn is a TarArchiveInputStream while (tarEntry != null) {// create a file with the same name as the tarEntry File destPath = new File(dest.toString() + System.getProperty("file.separator") + tarEntry.getName()); - com.neuronrobotics.sdk.common.Log.error("Inflating: " + destPath.getCanonicalPath()); + com.neuronrobotics.sdk.common.Log.debug("Inflating: " + destPath.getCanonicalPath()); if (tarEntry.isDirectory()) { destPath.mkdirs(); } else { @@ -1019,8 +1019,8 @@ public void process(double percent) { if (!folder.exists() || !exe.exists()) { if (approval.get(downloadName, URL)) { - com.neuronrobotics.sdk.common.Log.error("Start Downloading " + filename); - com.neuronrobotics.sdk.common.Log.error("From "+URL); + com.neuronrobotics.sdk.common.Log.debug("Start Downloading " + filename); + com.neuronrobotics.sdk.common.Log.debug("From "+URL); } else { pis.close(); @@ -1028,11 +1028,11 @@ public void process(double percent) { } downloadEvents.startDownload(); rawFileDownload(pis, folder, exe); - com.neuronrobotics.sdk.common.Log.error("Finished downloading " + filename); + com.neuronrobotics.sdk.common.Log.debug("Finished downloading " + filename); psudoSplash.onLogUpdate((int) (1 * 100)+" % " +filename , null); downloadEvents.finishDownload(); } else { - com.neuronrobotics.sdk.common.Log.error("Not downloading, it existst " + filename); + com.neuronrobotics.sdk.common.Log.debug("Not downloading, it existst " + filename); } return exe; } From 0cc7e87b54ccc7d8d6e25a485d046ec8e5144025 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 2 Oct 2025 07:49:41 -0400 Subject: [PATCH 582/635] jcsg error --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 728c8f2e..4615b67a 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 728c8f2edfba2921a36bdae9aa031f40a35eb6a5 +Subproject commit 4615b67a8e6187bf734bfd362cfbff6919d216c9 From 91f4c6e7983b5c27cc0731f154ee1dfe151cc3d5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 2 Oct 2025 12:13:41 -0400 Subject: [PATCH 583/635] change the name of a doodle when adding it to a doodle --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 7ac6ebd0..4f47c52f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -21,6 +21,7 @@ import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager; import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import com.neuronrobotics.sdk.common.Log; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Cube; @@ -177,11 +178,18 @@ public static File toLocal(File file, String name,CaDoodleFile cf ) { File targetParent = new File(parentFile.getAbsoluteFile() + delim() + name); targetParent.mkdirs(); recursiveCopy(doodleParent.getAbsolutePath(),targetParent.getAbsolutePath()); + file = new File(targetParent.getAbsolutePath()+delim()+file.getName()); + try { + CaDoodleFile f = CaDoodleFile.fromFile(file); + f.setProjectName(cf.getMyProjectName()+"->"+f.getMyProjectName()); + f.save(); + } catch (Exception e) { + com.neuronrobotics.sdk.common.Log.error(e); + throw new RuntimeException(e); + } } } } - if (!isDoodle) - file = new File(source + delim() + file.getName()); return file; } From 6ecc61004ff9ab65e04c513ff8bfa17f837ff756 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 2 Oct 2025 14:47:12 -0400 Subject: [PATCH 584/635] remove unused parameter --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index cb377ef1..858b257a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -156,9 +156,6 @@ public void initialize() { imageCacheDir.mkdir(); File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); CSGDatabase.setInstance(new CSGDatabaseInstance(db)); - StringParameter loc = new StringParameter("CaDoodle_File_Location", self.getAbsolutePath(), - new ArrayList()); - loc.setStrValue(self.getAbsolutePath()); bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); From cc1dde87a78fc4316a461403628616024d5a64f8 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 2 Oct 2025 17:17:50 -0400 Subject: [PATCH 585/635] remove re run --- .../bowlerstudio/scripting/cadoodle/AddFromScript.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 216b37c4..c9ee8afa 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -91,14 +91,6 @@ public List process(List incoming, String fileName) { } back.addAll(collect); } catch (Exception e) { - com.neuronrobotics.sdk.common.Log.error(e); - if (!fileName.contains("generated")) { - try { - return process(incoming, "generated/" + fileRel); - } catch (Exception e2) { - com.neuronrobotics.sdk.common.Log.error(e2); - } - } throw new RuntimeException(e); } From 228f796a46a851e7c6dd621afbe59feca4327792 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Thu, 2 Oct 2025 17:18:09 -0400 Subject: [PATCH 586/635] add intitialize api --- .../scripting/cadoodle/CaDoodleFile.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 858b257a..d7303d07 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -1148,12 +1148,20 @@ public javafx.scene.image.WritableImage setImage(javafx.scene.image.WritableImag this.img = img; return img; } - + public boolean isInitialized() { + return !(percentInitialized<1); + } + /** + * A value from 0 to 1 representing how complete the initialization is + * @return + */ public double getPercentInitialized() { return percentInitialized; } - public void setPercentInitialized(double percentInitialized) { + private void setPercentInitialized(double percentInitialized) { + if(percentInitialized>1||percentInitialized<0) + throw new NumberFormatException("Number must be between 0 and 1"); this.percentInitialized = percentInitialized; } From 3b09d1b82e11c7280753832732303b74dbacf820 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:49:00 -0400 Subject: [PATCH 587/635] formatting --- .../bowlerstudio/scripting/GroovyHelper.java | 127 +++++++++--------- 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index c5e13ed6..27e86fd9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -18,15 +18,13 @@ public class GroovyHelper implements IScriptingLanguage, IScriptingLanguageDebugger { + private Object inline(Object code, ArrayList args) throws Exception { + CompilerConfiguration cc = new CompilerConfiguration(); + cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(ScriptingEngine.getImports()) - private Object inline(Object code, ArrayList args) throws Exception { - CompilerConfiguration cc = new CompilerConfiguration(); - cc.addCompilationCustomizers(new ImportCustomizer() - .addStarImports(ScriptingEngine.getImports()) + ); - ); - - Binding binding = new Binding(); + Binding binding = new Binding(); // for (String pm : DeviceManager.listConnectedDevice()) { // BowlerAbstractDevice bad = DeviceManager.getSpecificDevice(null, pm); // try { @@ -42,28 +40,29 @@ private Object inline(Object code, ArrayList args) throws Exception { //// com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " //// + bad); // } - binding.setVariable("args", args); - - GroovyShell shell = new GroovyShell(GroovyHelper.class - .getClassLoader(), binding, cc); - //com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); - Script script; - if (String.class.isInstance(code)) { - script = shell.parse((String) code); - } else if (File.class.isInstance(code)) { - script = shell.parse((File) code); - } else { - return null; - } - return script.run(); - - } - - - @Override - public String getShellType() { - return "Groovy"; - } + + binding.setVariable("args", args); + + GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); + // com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); + Script script; + if (String.class.isInstance(code)) { + script = shell.parse((String) code); + } else if (File.class.isInstance(code)) { + + script = shell.parse((File) code); + } else { + return null; + } + return script.run(); + + } + + @Override + public String getShellType() { + return "Groovy"; + } + /** * Get the contents of an empty file * @@ -73,41 +72,39 @@ public String getDefaultContents() { return "// code here"; } - @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { - return inline(code, args); - } - - - @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { - return inline(code, args); - } - - - @Override - public boolean getIsTextFile() { - // Auto-generated method stub - return true; - } - - @Override - public ArrayList getFileExtenetion() { - // Auto-generated method stub - return new ArrayList<>(Arrays.asList( "groovy","java")); - } - - @Override - public IDebugScriptRunner compileDebug(File f) { - // Auto-generated method stub - return new IDebugScriptRunner() { - - @Override - public String[] step() { - // Auto-generated method stub - return new String[]{"fileame.groovy", "345"}; - } - }; - } + @Override + public Object inlineScriptRun(File code, ArrayList args) throws Exception { + return inline(code, args); + } + + @Override + public Object inlineScriptRun(String code, ArrayList args) throws Exception { + return inline(code, args); + } + + @Override + public boolean getIsTextFile() { + // Auto-generated method stub + return true; + } + + @Override + public ArrayList getFileExtenetion() { + // Auto-generated method stub + return new ArrayList<>(Arrays.asList("groovy", "java")); + } + + @Override + public IDebugScriptRunner compileDebug(File f) { + // Auto-generated method stub + return new IDebugScriptRunner() { + + @Override + public String[] step() { + // Auto-generated method stub + return new String[] { "fileame.groovy", "345" }; + } + }; + } } From 86899f50e558bf695dcc7134b282ca0d6e455352 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:49:15 -0400 Subject: [PATCH 588/635] move the instance set reset out --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 4f47c52f..d5962f7e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -69,6 +69,7 @@ public List process(List incoming) { if (getName() == null) { } + CSGDatabaseInstance instance = CSGDatabase.getInstance(); try { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); @@ -85,7 +86,6 @@ public List process(List incoming) { configs.put("PreventBomAdd", preventBoM); args.add(configs); boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); - CSGDatabaseInstance instance = CSGDatabase.getInstance(); if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); @@ -114,6 +114,7 @@ public List process(List incoming) { csg1.setParameter(getFileLocationparam(file,name)); back.addAll(collect); } catch (Exception e) { + CSGDatabase.setInstance(instance); throw new RuntimeException(e); } return back; From 19aba5ae0889edcdeff5b8f1e1b745764472e7a1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:49:35 -0400 Subject: [PATCH 589/635] add an instance of the csgdatabase --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index d7303d07..9969b8ec 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -101,6 +101,7 @@ public void renderSplashFrame(int percent, String message) { private ICadoodleSaveStatusUpdate saveUpdate = null; private boolean timelineOpen = false; private HashMap robots = new HashMap(); + private CSGDatabaseInstance csgDBinstance; public ArrayList getMobileBases(){ ArrayList back = new ArrayList(); for(MobileBaseBuilder b:robots.values()) { @@ -155,7 +156,8 @@ public void initialize() { if (!imageCacheDir.exists()) imageCacheDir.mkdir(); File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); - CSGDatabase.setInstance(new CSGDatabaseInstance(db)); + setCsgDBinstance(new CSGDatabaseInstance(db)); + CSGDatabase.setInstance(getCsgDBinstance()); bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); @@ -1246,4 +1248,10 @@ public HashMap getRobots() { public void setRobots(HashMap robots) { this.robots = robots; } + public CSGDatabaseInstance getCsgDBinstance() { + return csgDBinstance; + } + private void setCsgDBinstance(CSGDatabaseInstance csgDBinstance) { + this.csgDBinstance = csgDBinstance; + } } From 13b7cffb2d477f5b893f67f40fa88047b32be46a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:49:54 -0400 Subject: [PATCH 590/635] pass the CSG instance into the script --- .../bowlerstudio/scripting/GroovyHelper.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 27e86fd9..c71c18ef 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -16,6 +16,9 @@ import com.neuronrobotics.sdk.common.BowlerAbstractDevice; import com.neuronrobotics.sdk.common.DeviceManager; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; + public class GroovyHelper implements IScriptingLanguage, IScriptingLanguageDebugger { private Object inline(Object code, ArrayList args) throws Exception { @@ -42,17 +45,27 @@ private Object inline(Object code, ArrayList args) throws Exception { // } binding.setVariable("args", args); - + File code2 = null; + if (File.class.isInstance(code)) { + code2 = (File)code; + if (!code2.getName().toLowerCase().contentEquals("csgdatabase.json")) { + File p = code2.getParentFile(); + for (String s : p.list()) { + if (s.toLowerCase().contentEquals("csgdatabase.json")) { + CSGDatabaseInstance db =new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s)); + binding.setVariable("csgdb", db); + } + } + } + } GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); // com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); Script script; - if (String.class.isInstance(code)) { + + if(code2==null) { script = shell.parse((String) code); - } else if (File.class.isInstance(code)) { - - script = shell.parse((File) code); - } else { - return null; + } else { + script = shell.parse(code2); } return script.run(); From 76613106c3e82a560780c6a0c953e15f39cd5504 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:50:15 -0400 Subject: [PATCH 591/635] pass the csg instance on script runs --- .../scripting/ScriptingEngine.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index fd5d5c86..cf22de2a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -8,6 +8,8 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.eclipse.jgit.api.CloneCommand; @@ -497,11 +499,26 @@ public static Object inlineScriptRun(File code, ArrayList args, String s filesRun.put(code.getName(), code); // com.neuronrobotics.sdk.common.Log.error("Loading "+code.getAbsolutePath()); } - + CSGDatabaseInstance prevDB = CSGDatabase.getInstance(); + try { + if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { + File p = code.getParentFile(); + for (String s : p.list()) { + if (s.toLowerCase().contentEquals("csgdatabase.json")) { + CSGDatabase.setInstance(new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s) )); + } + } + } + } catch (Exception e) { + Log.error(e); + } IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); if (iScriptingLanguage != null) { - return iScriptingLanguage.inlineScriptRun(code, args); + Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(code, args); + CSGDatabase.setInstance(prevDB); + return inlineScriptRun; } + CSGDatabase.setInstance(prevDB); return null; } @@ -1002,7 +1019,7 @@ private static void commit(String id, String branch, String FileName, String con File dbFile = ScriptingEngine.fileFromGit(gitID[0], s); if (!CSGDatabase.getDbFile().equals(dbFile)) - CSGDatabase.setDbFile(dbFile); + CSGDatabase.setInstance(new CSGDatabaseInstance(dbFile)); CSGDatabase.saveDatabase(); @SuppressWarnings("resource") String c = new Scanner(dbFile).useDelimiter("\\Z").next(); From 1a7ae9437d64d826c398d0e14cd358307a68b24e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 3 Oct 2025 07:50:22 -0400 Subject: [PATCH 592/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 4615b67a..ca726409 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4615b67a8e6187bf734bfd362cfbff6919d216c9 +Subproject commit ca7264094863576dccdd015bb5e4187c2a4be5df From 3438ea95746d00b4c8ed0efb94c8721e038a53d5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 10:53:33 -0400 Subject: [PATCH 593/635] exclude the timeline from copies --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index d5962f7e..5b58bf32 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -216,6 +216,8 @@ public static boolean recursiveCopy(String sourceDir, String targetDir) { System.err.println("Error: Source '" + sourceDir + "' is not a directory."); return false; } + if(source.getName().contentEquals("timeline")) + return true; // Create target directory if it doesn't exist if (!target.exists()) { From 7f818e0196a5433b62f503badb8649124de80d0e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 16:53:33 -0400 Subject: [PATCH 594/635] use disk as cache for old items --- .../scripting/cadoodle/CaDoodleFile.java | 78 +++++++++++++++---- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9969b8ec..79bc82a9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -2,7 +2,11 @@ import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.lang.reflect.Type; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -40,8 +44,10 @@ import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation; import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import com.neuronrobotics.sdk.common.Log; import com.neuronrobotics.sdk.common.TickToc; + import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.Polygon; @@ -75,7 +81,7 @@ public class CaDoodleFile { // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); private double percentInitialized = 0; - private final HashMap> cache = new HashMap>(); +// private final HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() @@ -102,6 +108,7 @@ public void renderSplashFrame(int percent, String message) { private boolean timelineOpen = false; private HashMap robots = new HashMap(); private CSGDatabaseInstance csgDBinstance; + private File objectDir; public ArrayList getMobileBases(){ ArrayList back = new ArrayList(); for(MobileBaseBuilder b:robots.values()) { @@ -114,10 +121,10 @@ public void close() { for(CaDoodleOperation op:getOpperations()) { op.setCaDoodleFile(null); } - for (CaDoodleOperation op : cache.keySet()) { - cache.get(op).clear(); - } - cache.clear(); +// for (CaDoodleOperation op : cache.keySet()) { +// clearCache(op); +// } +// cache.clear(); clearListeners(); toProcess.clear(); img = null; @@ -125,7 +132,48 @@ public void close() { t.interrupt(); } - + private int opToIndex(CaDoodleOperation op) { + for(int i=0;i getCachedCSGs(CaDoodleOperation op) { + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { + return (List) ois.readObject(); + } catch (Exception ex) { + Log.error(ex); + } + return null; + } + + private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + if(cacheFile.exists()) + cacheFile.delete(); + try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { + oos.writeObject(cachedCopy); + }catch(Exception ex) { + Log.error(ex); + } + //cache.put(op, cachedCopy); + } + private void clearCache(CaDoodleOperation key) { + int opIndex = opToIndex(key); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + if(cacheFile.exists()) + cacheFile.delete(); + +// List back = cache.remove(key); +// if (back != null) +// back.clear(); + } + + public CaDoodleFile clearListeners() { listeners.clear(); return this; @@ -155,13 +203,15 @@ public void initialize() { File imageCacheDir = new File(parent.getAbsolutePath() + delim() + "timeline"); if (!imageCacheDir.exists()) imageCacheDir.mkdir(); + objectDir = new File(parent.getAbsolutePath() + delim() + "timeline"+ delim()+"objectCache"); + if (!objectDir.exists()) + objectDir.mkdir(); File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); setCsgDBinstance(new CSGDatabaseInstance(db)); CSGDatabase.setInstance(getCsgDBinstance()); bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); - } int indexStarting = getCurrentIndex(); if(indexStarting==0) { @@ -599,9 +649,7 @@ private OperationResult pruneForward(CaDoodleOperation op) throws Exception { for (int i = getCurrentIndex() - 1; i < getOpperations().size(); i++) { CaDoodleOperation key = getOpperations().get(i); if (i >= getCurrentIndex()) { - List back = cache.remove(key); - if (back != null) - back.clear(); + clearCache(key); } File imageCache = getTimelineImageFile(i); // System.err.println("Deleting " + imageCache.getAbsolutePath()); @@ -622,6 +670,7 @@ private OperationResult pruneForward(CaDoodleOperation op) throws Exception { return res; } + private void storeResultInCache(CaDoodleOperation op, List process) { ArrayList cachedCopy = new ArrayList(); HashSet names = new HashSet<>(); @@ -634,11 +683,12 @@ private void storeResultInCache(CaDoodleOperation op, List process) { .setRegenerate(c.getRegenerate())); // cachedCopy.add(c); } - cache.put(op, cachedCopy); + placeCSGsInCache(op, cachedCopy); if(getFreeMemory()>50) com.neuronrobotics.sdk.common.Log.debug("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); } + public static double getFreeMemory() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); // Maximum memory the JVM will attempt to use @@ -782,7 +832,7 @@ public List getCurrentState() { public List getStateAtOperation(CaDoodleOperation op) { if (getCurrentIndex() == 0) return new ArrayList(); - List list = cache.get(op); + List list = getCachedCSGs(op); if (list == null) list = new ArrayList(); return list; @@ -807,7 +857,7 @@ public List getPreviouState() { return new ArrayList(); CaDoodleOperation key = getOpperations().get(getCurrentIndex() - 2); - return cache.get(key); + return getCachedCSGs(key); } private void setCurrentState(CaDoodleOperation op, List currentState) { @@ -929,7 +979,7 @@ public File save() throws IOException { File f = getTimelineImageFile(i); CaDoodleOperation op = opperations.get(i); int percent = (int) (((double) i) / ((double) opperations.size()) * 100.0); - List process = cache.get(op); + List process = getCachedCSGs(op); if (!f.exists() && process!=null) try { num++; From 3b1426e7178f173e30286ad052fac7e087e88687 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 18:22:55 -0400 Subject: [PATCH 595/635] Switching API ove to the context-based Database --- JCSG | 2 +- .../creature/ControllerOption.java | 2 +- .../bowlerstudio/creature/LimbOption.java | 2 +- .../creature/MobileBaseCadManager.java | 12 ++--- .../scripting/cadoodle/AddFromFile.java | 21 ++++---- .../scripting/cadoodle/AddFromScript.java | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 8 +-- .../scripting/cadoodle/CaDoodleVitamin.java | 23 +++++---- .../scripting/cadoodle/Group.java | 2 +- .../scripting/cadoodle/Paste.java | 2 +- .../scripting/cadoodle/Sweep.java | 49 +++++++++++-------- .../scripting/cadoodle/UnGroup.java | 2 +- 12 files changed, 71 insertions(+), 56 deletions(-) diff --git a/JCSG b/JCSG index ca726409..e1e05440 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit ca7264094863576dccdd015bb5e4187c2a4be5df +Subproject commit e1e05440372990f946a782ae379b5bda560b8e1f diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 2eec1dae..3937e1cb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -90,7 +90,7 @@ public void build(CaDoodleFile f) { arc.setCaDoodleFile(f); List so = arc.process(new ArrayList<>()); for (CSG c : so) { - for (String s : c.getParameters()) { + for (String s : c.getParameters(f.getCsgDBinstance())) { CSGDatabase.delete(s); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index fb4f545a..c9a417f8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -137,7 +137,7 @@ public void build(CaDoodleFile f) throws IOException { List so = add.process(new ArrayList<>()); add.getRobots().remove("tmp"); for (CSG c : so) { - for (String s : c.getParameters()) { + for (String s : c.getParameters(f.getCsgDBinstance())) { CSGDatabase.delete(s); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 95bde861..a178c79a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -1540,12 +1540,12 @@ public ArrayList getAllCad() { } public void setAllCad(ArrayList allCad) { - for (CSG part : allCad) - for (String p : part.getParameters()) { - CSGDatabase.addParameterListener(p, (arg0, arg1) -> { - // generateCad(); //TODO Undo this after debugging - }); - } +// for (CSG part : allCad) +// for (String p : part.getParameters()) { +// CSGDatabase.addParameterListener(p, (arg0, arg1) -> { +// // generateCad(); //TODO Undo this after debugging +// }); +// } if (this.allCad != null && this.allCad != allCad) this.allCad.clear(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 5b58bf32..0305e0ba 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -103,7 +103,7 @@ public List process(List incoming) { if(isDoodle && csg.isInGroup()) continue; try { - CSG processedCSG = processGiven(csg, i, getOrderedName(),file,name,getLocation()); + CSG processedCSG = processGiven(csg, i, getOrderedName(),file,name,getLocation(),getCaDoodleFile().getCsgDBinstance()); collect.add(processedCSG); } catch (Exception ex) { com.neuronrobotics.sdk.common.Log.error(ex);; @@ -111,7 +111,7 @@ public List process(List incoming) { } CSGDatabase.setInstance(instance); for(CSG csg1:collect) - csg1.setParameter(getFileLocationparam(file,name)); + csg1.setParameter(getCaDoodleFile().getCsgDBinstance(),getFileLocationparam(file,name)); back.addAll(collect); } catch (Exception e) { CSGDatabase.setInstance(instance); @@ -318,33 +318,36 @@ public static File getFile(String name,CaDoodleFile cf) { // return getParameter("UnKnown").getStrValue(); // } - private static CSG processGiven(CSG csg, int i, String name, File f,String task,TransformNR location) { + private static CSG processGiven(CSG csg, int i, String name, File f,String task,TransformNR location,CSGDatabaseInstance instance) { Transform nrToCSG = TransformFactory.nrToCSG(location); boolean isDoodle = f.getName().toLowerCase().endsWith(".doodle"); if(isDoodle) { csg.setStorage(new PropertyStorage()); } - + CSG processedCSG = csg .transformed(nrToCSG).syncProperties(csg).setRegenerate(previous -> { try { File file =f; - CSGDatabaseInstance instance = CSGDatabase.getInstance(); + //CSGDatabaseInstance instance = CSGDatabase.getInstance(); + CSGDatabaseInstance instancetmp = null; + if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); - CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); + instancetmp = new CSGDatabaseInstance(tempFile.toFile()); + CSGDatabase.setInstance(instancetmp); } String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); if(isDoodle) { - csg1.getMapOfparametrics().clear(); + csg1.getMapOfparametrics(instancetmp ).clear(); csg1.setStorage(new PropertyStorage()); } CSGDatabase.setInstance(instance); - csg1.setParameter(getFileLocationparam(f,task)); - return processGiven(csg1, i, name,f,task,location); + csg1.setParameter(instance,getFileLocationparam(f,task)); + return processGiven(csg1, i, name,f,task,location,instance); } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error(e); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index c9ee8afa..3b5a8a3e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -73,7 +73,7 @@ public List process(List incoming, String fileName) { for(int i=0;i params = dyingCSG.getParameters(); + Set params = dyingCSG.getParameters(getCsgDBinstance()); for (String param : params) { boolean existing = false; - for (String s : csg.getParameters()) { + for (String s : csg.getParameters(getCsgDBinstance())) { if (s.contentEquals(param)) existing = true; } if (!existing) { Parameter vals = CSGDatabase.get(param); if (vals != null) - csg.setParameter(vals, dyingCSG.getMapOfparametrics().get(param)); + csg.setParameter(getCsgDBinstance(),vals, getCsgDBinstance().getMapOfparametrics(dyingCSG).get(param)); } } if (csg.getName().length() == 0) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index bb310700..6b6c774d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -11,12 +11,17 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.IRegenerate; import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; public class CaDoodleVitamin { - public static CSG get(String typencoming, ArrayList args) { + private CSGDatabaseInstance instance; + public CaDoodleVitamin(CSGDatabaseInstance myinstance) { + instance=myinstance; + } + public CSG get(String typencoming, ArrayList args) { String name = args.get(0).toString(); ArrayListtypes=new ArrayList<>(); types.addAll(Vitamins.listVitaminTypes()); @@ -30,15 +35,15 @@ public static CSG get(String typencoming, ArrayList args) { throw ex; } } - public static boolean isVitamin(CSG c) { - for(String s:c.getParameters()) { + public boolean isVitamin(CSG c) { + for(String s:instance.getParameters(c)) { if(s.contains("_CaDoodle_Vitamin_") && s.contains(c.getName())) { return true; } } return false; } - public static CSG get(String typencoming,String defaultValue, ArrayList args) { + public CSG get(String typencoming,String defaultValue, ArrayList args) { String name = args.get(0).toString(); ArrayListtypes=new ArrayList<>(); @@ -83,11 +88,11 @@ public static CSG get(String typencoming,String defaultValue, ArrayList // com.neuronrobotics.sdk.common.Log.debug("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); part = Vitamins.get(type, word.getStrValue()).setIsHole(true); CSGDatabase.saveDatabase(); - Set params = part.getParameters(); + Set params = part.getParameters(instance); - part.setParameter(word); - part.setParameter(typeParam); - params = part.getParameters(); + part.setParameter(instance,word); + part.setParameter(instance,typeParam); + params = part.getParameters(instance); part.setName(name); // com.neuronrobotics.sdk.common.Log.debug("Parameters on Vitamin: "+name); // for(String s:params) { @@ -111,7 +116,7 @@ public CSG regenerate(CSG previous) { if(t==null) { com.neuronrobotics.sdk.common.Log.debug(" Error, type is null, previous "+name2+" has no parameters somehow??"); } - return CaDoodleVitamin.get(t.getStrValue(),s.getStrValue(), ar); + return get(t.getStrValue(),s.getStrValue(), ar); } }); //back.getStorage().set("PreviousName", name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 07e82425..ddd775ef 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -123,7 +123,7 @@ public List process(List incoming) { } if(mobileBase!=null) result.setMobileBaseName(mobileBase); - HashMap mapOfparametrics = result.getMapOfparametrics(); + HashMap mapOfparametrics = result.getMapOfparametrics(getCaDoodleFile().getCsgDBinstance()); if (mapOfparametrics != null) mapOfparametrics.clear(); result.addIsGroupResult(getGroupID()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index 05b07a62..ec720fbd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -98,7 +98,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { Transform nrToCSG2 = TransformFactory.nrToCSG(location); CSG newOne = null; - if (CaDoodleVitamin.isVitamin(c)) { + if (new CaDoodleVitamin(getCaDoodleFile().getCsgDBinstance()).isVitamin(c)) { CSG regenerate = clone.getRegenerate().regenerate(clone); newOne = regenerate.transformed(nrToCSG).transformed(nrToCSG2); newOne.setRegenerate(regenerate.getRegenerate()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 240baa47..8bf280da 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -51,24 +51,25 @@ public class Sweep extends AbstractAddFrom { @Expose(serialize = true, deserialize = true) private double defz = 0; @Expose(serialize = true, deserialize = true) - private double defrad= 10; + private double defrad = 10; @Expose(serialize = true, deserialize = true) - private double defstep=30; + private double defstep = 30; @Expose(serialize = true, deserialize = true) - private double defangle=360; + private double defangle = 360; @Expose(serialize = true, deserialize = true) - private double defSpiral=0; - - public Sweep set(File source,CaDoodleFile cf) throws Exception { + private double defSpiral = 0; + + public Sweep set(File source, CaDoodleFile cf) throws Exception { if (!source.getName().toLowerCase().endsWith(".svg")) throw new Exception("Sweep can only take files with the .svg extention"); - com.neuronrobotics.sdk.common.Log.debug("Saving Local Copy of "+source.getAbsolutePath()); - AddFromFile.toLocal(source, getName(),cf); + com.neuronrobotics.sdk.common.Log.debug("Saving Local Copy of " + source.getAbsolutePath()); + AddFromFile.toLocal(source, getName(), cf); setCaDoodleFile(cf); try { getFile(); } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; } return this; } @@ -96,10 +97,10 @@ public CSG sweep(Polygon p, String name, Bounds b) { try { transformedP = p.transformed(centerandAllignedPolygon); - ITransformProvider pr = (unit,domain)->{ - return new Transform().movex(sprl*unit*d); + ITransformProvider pr = (unit, domain) -> { + return new Transform().movex(sprl * unit * d); }; - return Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90).setName(name); + return Extrude.sweep(transformedP, increment, radiusT, steps, pr).rotx(-90).setName(name); } catch (ColinearPointsException e) { // TODO Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e); @@ -111,7 +112,7 @@ public LengthParameter radius(String name) { String key = name + "_CaDoodle_Rad"; if (rad == null) rad = new LengthParameter(key, getDefrad(), nopt); - if(rad.getMM()<0) + if (rad.getMM() < 0) rad.setMM(0); return rad; } @@ -127,7 +128,7 @@ public LengthParameter steps(String name) { String key = name + "_CaDoodle_Step"; if (step == null) step = new LengthParameter(key, getDefstep(), nopt); - if(step.getMM()<3) + if (step.getMM() < 3) step.setMM(3); return step; } @@ -136,20 +137,20 @@ public LengthParameter angle(String name) { String key = name + "_CaDoodle_Angle"; if (angle == null) angle = new LengthParameter(key, getDefangle(), nopt); - if (angle.getMM()<0.001) + if (angle.getMM() < 0.001) angle.setMM(0.001); return angle; } + public LengthParameter spiralStep(String name) { String key = name + "_CaDoodle_Spiral"; if (spiral == null) spiral = new LengthParameter(key, getDefSpiral(), nopt); - if (spiral.getMM()<0) + if (spiral.getMM() < 0) spiral.setMM(0); return spiral; } - @Override public List process(List incoming) { nameIndex = 0; @@ -163,7 +164,7 @@ public List process(List incoming) { // args.addAll(Arrays.asList(getName() )); ArrayList collect = new ArrayList<>(); File file = getFile(); - com.neuronrobotics.sdk.common.Log.debug("Loading File "+file.getAbsolutePath()); + com.neuronrobotics.sdk.common.Log.debug("Loading File " + file.getAbsolutePath()); if (!file.exists()) { throw new RuntimeException("Failed to find file"); } @@ -231,7 +232,7 @@ public Bounds getBounds(HashMap> polygons) { @Override public File getFile() throws NoSuchFileException { - return AddFromFile.getFile(name,getCaDoodleFile()); + return AddFromFile.getFile(name, getCaDoodleFile()); } private CSG processGiven(Polygon p, Bounds b, int j, String name) { @@ -255,8 +256,14 @@ private CSG processGiven(Polygon p, Bounds b, int j, String name) { Parameter z = zoffset(name); Parameter radius = radius(name); parameter.setStrValue(pathname); - CSG processedCSG = csg.transformed(nrToCSG).syncProperties(csg).setParameter(parameter).setParameter(steps) - .setParameter(angle).setParameter(z).setParameter(radius).setParameter(spiralStep(pathname)).setColor(c).setIsHole(hole) + CSG processedCSG = csg.transformed(nrToCSG).syncProperties(csg) + .setParameter(getCaDoodleFile().getCsgDBinstance(), parameter) + .setParameter(getCaDoodleFile().getCsgDBinstance(), steps) + .setParameter(getCaDoodleFile().getCsgDBinstance(), angle) + .setParameter(getCaDoodleFile().getCsgDBinstance(), z) + .setParameter(getCaDoodleFile().getCsgDBinstance(), radius) + .setParameter(getCaDoodleFile().getCsgDBinstance(), spiralStep(pathname)) + .setColor(c).setIsHole(hole) .setRegenerate(previous -> { try { File file = getFile(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index b43cde3d..8bc6d9dc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -35,7 +35,7 @@ public List process(List incoming) { // release this object from the group Transform nrToCSG = MoveCenter.getTotalOffset(csg); CSG transformed=csg; - if(CaDoodleVitamin.isVitamin(csg)) { + if(new CaDoodleVitamin(getCaDoodleFile().getCsgDBinstance()).isVitamin(csg)) { CSG regenerate = csg.getRegenerate().regenerate(csg); transformed = regenerate.transformed(nrToCSG); } From 8c41a73c141205eeed81ee0ba7c172ad1e057d29 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 18:28:40 -0400 Subject: [PATCH 596/635] upadted the api to add static mode --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index e1e05440..74bbf583 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e1e05440372990f946a782ae379b5bda560b8e1f +Subproject commit 74bbf5835c6e6ff1621c4421aade678209a0dee8 From b27f2c2cc229c29b634ef48af69b12c08e1cd483 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 19:00:45 -0400 Subject: [PATCH 597/635] Add the CSG batabase as a 1st class apraameter to the scripts --- JCSG | 2 +- .../bowlerstudio/scripting/ArduinoLoader.java | 6 +- .../bowlerstudio/scripting/BashLoader.java | 6 +- .../bowlerstudio/scripting/BlenderLoader.java | 5 +- .../scripting/Build123dLoader.java | 5 +- .../scripting/CaDoodleLoader.java | 5 +- .../bowlerstudio/scripting/ClojureHelper.java | 7 +- .../scripting/FXMLBowlerLoader.java | 4 +- .../bowlerstudio/scripting/FreecadLoader.java | 4 +- .../bowlerstudio/scripting/GroovyHelper.java | 23 ++---- .../scripting/IScriptingLanguage.java | 7 +- .../bowlerstudio/scripting/JsonRunner.java | 6 +- .../bowlerstudio/scripting/JythonHelper.java | 6 +- .../bowlerstudio/scripting/ObjLoader.java | 4 +- .../scripting/OpenSCADLoader.java | 4 +- .../bowlerstudio/scripting/RobotHelper.java | 4 +- .../scripting/ScriptingEngine.java | 73 ++++++++++++------- .../scripting/SequenceRunner.java | 6 +- .../bowlerstudio/scripting/StlLoader.java | 4 +- .../bowlerstudio/scripting/SvgLoader.java | 4 +- 20 files changed, 103 insertions(+), 82 deletions(-) diff --git a/JCSG b/JCSG index 74bbf583..3491011a 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 74bbf5835c6e6ff1621c4421aade678209a0dee8 +Subproject commit 3491011aa24363ce952db27f47ad8463b2a71d99 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java index 6f6307dd..6f786eb8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ArduinoLoader.java @@ -6,6 +6,8 @@ import java.util.Arrays; import java.util.HashMap; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; + public class ArduinoLoader implements IScriptingLanguage { @@ -14,7 +16,7 @@ public class ArduinoLoader implements IScriptingLanguage { @SuppressWarnings("unchecked") @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { if (args == null) { args = new ArrayList<>(); } @@ -82,7 +84,7 @@ private File findIno(File start) { } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { // Auto-generated method stub return null; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java index b648b7d4..d1021f6c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BashLoader.java @@ -9,10 +9,12 @@ import com.neuronrobotics.video.OSUtil; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; + public class BashLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { // List asList = Arrays.asList("bash",code.getAbsolutePath()); ArrayList commands = new ArrayList<>(); commands.add("bash"); @@ -55,7 +57,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("Bash scripts have to be sent as files"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index b42bc53c..45da01bc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -15,12 +15,13 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.STL; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.paint.Color; public class BlenderLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { File stl = File.createTempFile(code.getName(), ".stl"); stl.deleteOnExit(); toSTLFile(code,stl); @@ -30,7 +31,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("Blender can not run from a string"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java index 88e14edc..2a3910ab 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java @@ -17,12 +17,13 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.STL; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.paint.Color; public class Build123dLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { File stl = File.createTempFile(sanitizeString(code.getName()), ".stl"); stl.deleteOnExit(); HashMap params=new HashMap(); @@ -40,7 +41,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("Build123d can not run from a string"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java index 8b673d2f..3ed1a246 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/CaDoodleLoader.java @@ -17,10 +17,11 @@ import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; public class CaDoodleLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromFile(code); Object process = process(loaded,false); loaded.close(); @@ -28,7 +29,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { CaDoodleFile loaded = CaDoodleFile.fromJsonString(code); Object process = process(loaded,false); loaded.close(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java index 3086d77a..3ba56c4f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ClojureHelper.java @@ -9,6 +9,7 @@ import clojure.lang.RT; import clojure.lang.Symbol; import clojure.lang.Var; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; /** * Class containing static utility methods for Java to Clojure interop @@ -62,12 +63,12 @@ public static Object eval(String string) { } @Override - public Object inlineScriptRun(File code, ArrayList args) { + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) { byte[] bytes; try { bytes = Files.readAllBytes(code.toPath()); String s = new String(bytes, "UTF-8"); - return inlineScriptRun(s, args); + return inlineScriptRun( db,s, args); } catch (IOException e1) { // Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e1); @@ -77,7 +78,7 @@ public Object inlineScriptRun(File code, ArrayList args) { } @Override - public Object inlineScriptRun(String code, ArrayList args) { + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) { return ClojureHelper.eval(code); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java index c802f1d7..eaf676cd 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FXMLBowlerLoader.java @@ -7,7 +7,7 @@ public class FXMLBowlerLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File xml, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File xml, ArrayList args) throws Exception { javafx.fxml.FXMLLoader loader = new javafx.fxml.FXMLLoader(xml.toURI().toURL()); javafx.scene.layout.Pane newLoadedPane = loader.load(); // Create a tab @@ -18,7 +18,7 @@ public Object inlineScriptRun(File xml, ArrayList args) throws Exception } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("This engine only supports files"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java index a1d35ce7..b5b8b4ff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/FreecadLoader.java @@ -49,7 +49,7 @@ public class FreecadLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { File stl = File.createTempFile(code.getName(), ".stl"); stl.deleteOnExit(); toSTLFile(code,stl); @@ -59,7 +59,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("Freecad file can not be instantiated from a string"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index c71c18ef..6e63b7e8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -21,7 +21,7 @@ public class GroovyHelper implements IScriptingLanguage, IScriptingLanguageDebugger { - private Object inline(Object code, ArrayList args) throws Exception { + private Object inline(Object code, ArrayList args, CSGDatabaseInstance db2) throws Exception { CompilerConfiguration cc = new CompilerConfiguration(); cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(ScriptingEngine.getImports()) @@ -46,18 +46,7 @@ private Object inline(Object code, ArrayList args) throws Exception { binding.setVariable("args", args); File code2 = null; - if (File.class.isInstance(code)) { - code2 = (File)code; - if (!code2.getName().toLowerCase().contentEquals("csgdatabase.json")) { - File p = code2.getParentFile(); - for (String s : p.list()) { - if (s.toLowerCase().contentEquals("csgdatabase.json")) { - CSGDatabaseInstance db =new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s)); - binding.setVariable("csgdb", db); - } - } - } - } + binding.setVariable("csgdb", db2); GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); // com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); Script script; @@ -86,13 +75,13 @@ public String getDefaultContents() { } @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { - return inline(code, args); + public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { + return inline(code, args,db); } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { - return inline(code, args); + public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { + return inline(code, args,db); } @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java index c4a4cb6c..e356eed5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/IScriptingLanguage.java @@ -11,6 +11,7 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.util.io.AutoLFInputStream.IsBinaryException; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.Group; /** @@ -23,7 +24,7 @@ * @author hephaestus */ public interface IScriptingLanguage { - + /** * This interface is for adding additional language support. * @@ -31,7 +32,7 @@ public interface IScriptingLanguage { * @param args the incoming arguments as a list of objects * @return the objects returned form the code that ran */ - public abstract Object inlineScriptRun(File code, ArrayList args) throws Exception; + public abstract Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception; /** * This interface is for adding additional language support. @@ -40,7 +41,7 @@ public interface IScriptingLanguage { * @param args the incoming arguments as a list of objects * @return the objects returned form the code that ran */ - public abstract Object inlineScriptRun(String code, ArrayList args) throws Exception; + public abstract Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception; /** * Returns the HashMap key for this language diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java index 0c2f2997..c4bd1636 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JsonRunner.java @@ -24,16 +24,16 @@ public class JsonRunner implements IScriptingLanguage { private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { String jsonString = null; InputStream inPut = null; inPut = FileUtils.openInputStream(code); jsonString = IOUtils.toString(inPut); - return inlineScriptRun(jsonString, args); + return inlineScriptRun( db,jsonString, args); } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { // perfoem the GSON parse HashMap> database = gson.fromJson(code, TT_mapStringString); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java index dede2c8e..a338e7b0 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/JythonHelper.java @@ -24,7 +24,7 @@ public class JythonHelper implements IScriptingLanguage { @Override - public Object inlineScriptRun(String code, ArrayList args) { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) { Properties props = new Properties(); PythonInterpreter.initialize(System.getProperties(), props, new String[]{""}); @@ -75,12 +75,12 @@ public Object inlineScriptRun(String code, ArrayList args) { } @Override - public Object inlineScriptRun(File code, ArrayList args) { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) { byte[] bytes; try { bytes = Files.readAllBytes(code.toPath()); String s = new String(bytes, "UTF-8"); - return inlineScriptRun(s, args); + return inlineScriptRun( db,s, args); } catch (IOException e1) { // Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e1); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java index 3bab3dc5..7364fb4c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ObjLoader.java @@ -11,13 +11,13 @@ public class ObjLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { CSG sllLoaded = Vitamins.get(code); return sllLoaded; } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("This engine only supports files"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java index 90469837..387215e8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java @@ -21,7 +21,7 @@ public class OpenSCADLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { File stl = File.createTempFile(sanitizeString(code.getName()), ".stl"); stl.deleteOnExit(); HashMap params=new HashMap(); @@ -39,7 +39,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("Blender can not run from a string"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java index 2624d6e6..9b0e5870 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java @@ -20,7 +20,7 @@ public class RobotHelper implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) { byte[] bytes; try { bytes = Files.readAllBytes(code.toPath()); @@ -44,7 +44,7 @@ public Object inlineScriptRun(File code, ArrayList args) { } @Override - public Object inlineScriptRun(String code, ArrayList args) { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) { MobileBase mb = null; try { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index cf22de2a..e6f20f21 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -494,34 +494,45 @@ public static void removeOnCommitEventListeners(String url, Runnable event) { * @param args the incoming arguments as a list of objects * @return the objects returned form the code that ran */ - public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception { + public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception{ + return inlineScriptRun(null, code, args, shellTypeStorage); + } + /** + * This interface is for adding additional language support. + * + * @param code file content of the code to be executed + * @param args the incoming arguments as a list of objects + * @return the objects returned form the code that ran + */ + public static Object inlineScriptRun(CSGDatabaseInstance instance,File code, ArrayList args, String shellTypeStorage) throws Exception { if (filesRun.get(code.getName()) == null) { filesRun.put(code.getName(), code); // com.neuronrobotics.sdk.common.Log.error("Loading "+code.getAbsolutePath()); } - CSGDatabaseInstance prevDB = CSGDatabase.getInstance(); + CSGDatabaseInstance prevDB = instance; + if(prevDB==null) try { if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { File p = code.getParentFile(); for (String s : p.list()) { if (s.toLowerCase().contentEquals("csgdatabase.json")) { - CSGDatabase.setInstance(new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s) )); + prevDB=(new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s) )); } } } } catch (Exception e) { Log.error(e); } + if(prevDB==null) + prevDB=CSGDatabase.getInstance(); IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); if (iScriptingLanguage != null) { - Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(code, args); + Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(prevDB,code, args); CSGDatabase.setInstance(prevDB); return inlineScriptRun; } - CSGDatabase.setInstance(prevDB); return null; } - /** * This interface is for adding additional language support. * @@ -529,14 +540,26 @@ public static Object inlineScriptRun(File code, ArrayList args, String s * @param args the incoming arguments as a list of objects * @return the objects returned form the code that ran */ - public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) + public static Object inlineScriptStringRun(CSGDatabaseInstance instance, String line, ArrayList args, String shellTypeStorage) throws Exception { if (langauges.get(shellTypeStorage) != null) { - return langauges.get(shellTypeStorage).inlineScriptRun(line, args); + return langauges.get(shellTypeStorage).inlineScriptRun(instance,line, args); } return null; } + /** + * This interface is for adding additional language support. + * + * @param line the text content of the code to be executed + * @param args the incoming arguments as a list of objects + * @return the objects returned form the code that ran + */ + public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) + throws Exception { + + return inlineScriptStringRun(CSGDatabase.getInstance(),line,args,shellTypeStorage); + } public static void addScriptingLanguage(IScriptingLanguage lang) { langauges.put(lang.getShellType(), lang); @@ -1010,23 +1033,23 @@ private static void commit(String id, String branch, String FileName, String con throw ex; } try { - if (!desired.getName().contentEquals("csgDatabase.json")) { - String[] gitID = ScriptingEngine.findGitTagFromFile(desired, gitRef); - String remoteURI = gitID[0]; - ArrayList f = ScriptingEngine.filesInGit(remoteURI, gitRef); - for (String s : f) { - if (s.contentEquals("csgDatabase.json")) { - - File dbFile = ScriptingEngine.fileFromGit(gitID[0], s); - if (!CSGDatabase.getDbFile().equals(dbFile)) - CSGDatabase.setInstance(new CSGDatabaseInstance(dbFile)); - CSGDatabase.saveDatabase(); - @SuppressWarnings("resource") - String c = new Scanner(dbFile).useDelimiter("\\Z").next(); - commit(remoteURI, branch, s, c, "saving CSG database", false, gitRef); - } - } - } +// if (!desired.getName().contentEquals("csgDatabase.json")) { +// String[] gitID = ScriptingEngine.findGitTagFromFile(desired, gitRef); +// String remoteURI = gitID[0]; +// ArrayList f = ScriptingEngine.filesInGit(remoteURI, gitRef); +// for (String s : f) { +// if (s.contentEquals("csgDatabase.json")) { +// +// File dbFile = ScriptingEngine.fileFromGit(gitID[0], s); +// if (!CSGDatabase.getDbFile().equals(dbFile)) +// CSGDatabase.setInstance(new CSGDatabaseInstance(dbFile)); +// CSGDatabase.saveDatabase(); +// @SuppressWarnings("resource") +// String c = new Scanner(dbFile).useDelimiter("\\Z").next(); +// commit(remoteURI, branch, s, c, "saving CSG database", false, gitRef); +// } +// } +// } } catch (Exception e) { // ignore CSG database com.neuronrobotics.sdk.common.Log.error(e); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java index 32d33319..1dd0f45c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SequenceRunner.java @@ -19,16 +19,16 @@ public class SequenceRunner implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { String jsonString = null; InputStream inPut = null; inPut = FileUtils.openInputStream(code); jsonString = IOUtils.toString(inPut); - return inlineScriptRun(jsonString, args); + return inlineScriptRun( db,jsonString, args); } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { new TimeSequence().execute(code); return null; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java index 1b6c704b..6544a7f8 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java @@ -11,13 +11,13 @@ public class StlLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { CSG sllLoaded = Vitamins.get(code); return sllLoaded; } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { throw new RuntimeException("This engine only supports files"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java index 40a4740f..b6b3dfe4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/SvgLoader.java @@ -17,7 +17,7 @@ public class SvgLoader implements IScriptingLanguage { @Override - public Object inlineScriptRun(File code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { try { SVGLoad s = new SVGLoad(code.toURI()); return run(s); @@ -31,7 +31,7 @@ public Object inlineScriptRun(File code, ArrayList args) throws Exceptio } @Override - public Object inlineScriptRun(String code, ArrayList args) throws Exception { + public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,String code, ArrayList args) throws Exception { SVGLoad s = new SVGLoad(code); return run(s); } From f58ae9bbf49847d35a60ec6b9fcbdba6a30c7c2b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 19:44:42 -0400 Subject: [PATCH 598/635] Remove all of the static methods from internal use --- .../creature/ControllerOption.java | 7 +- .../bowlerstudio/creature/LimbOption.java | 2 +- .../creature/MobileBaseCadManager.java | 85 ++++++++++--------- .../scripting/ScriptingEngine.java | 40 +++++---- .../scripting/cadoodle/AddFromFile.java | 22 ++--- .../scripting/cadoodle/CaDoodleFile.java | 6 +- .../scripting/cadoodle/CaDoodleVitamin.java | 16 ++-- .../scripting/cadoodle/Sweep.java | 12 +-- .../cadoodle/robot/AddRobotController.java | 2 +- .../vitamins/VitaminBomManager.java | 5 +- .../bowlerstudio/vitamins/Vitamins.java | 72 ++++++++-------- 11 files changed, 142 insertions(+), 127 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 3937e1cb..87c8ad59 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -29,6 +29,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.image.Image; import javafx.scene.paint.Color; @@ -91,7 +92,7 @@ public void build(CaDoodleFile f) { List so = arc.process(new ArrayList<>()); for (CSG c : so) { for (String s : c.getParameters(f.getCsgDBinstance())) { - CSGDatabase.delete(s); + f.getCsgDBinstance().delete(s); } } indicator = so.get(0); @@ -181,9 +182,9 @@ public static ArrayList getOptions() public String getLinkDeviceName() { return linkDeviceName; } - public CSG getVitaminCSG(int index) { + public CSG getVitaminCSG(CSGDatabaseInstance instance,int index) { try { - return Vitamins.get(vitaminType.get(index), vitaminSize.get(index)); + return Vitamins.get(instance,vitaminType.get(index), vitaminSize.get(index)); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index c9a417f8..9ae04925 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -138,7 +138,7 @@ public void build(CaDoodleFile f) throws IOException { add.getRobots().remove("tmp"); for (CSG c : so) { for (String s : c.getParameters(f.getCsgDBinstance())) { - CSGDatabase.delete(s); + f.getCsgDBinstance().delete(s); } } BowlerKernel.runLater(() -> { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index a178c79a..1a72023f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -57,6 +57,7 @@ import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.Vector3d; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.beans.property.*; import javafx.scene.transform.Affine; import javafx.application.Platform; @@ -97,36 +98,36 @@ public class MobileBaseCadManager implements Runnable { private ArrayList rendersync = new ArrayList<>(); private boolean forceChage = true; - public CSG getVitamin(VitaminLocation vitamin) throws Exception { - return getVitamin(vitamin, new Affine(), null); + public CSG getVitamin(CSGDatabaseInstance db,VitaminLocation vitamin) throws Exception { + return getVitamin(db,vitamin, new Affine(), null); } - public ArrayList getVitamins(IVitaminHolder link, Affine manipulator) { + public ArrayList getVitamins(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getVitamins(); - return toVitaminCad(vitamins, manipulator, null); + return toVitaminCad(db,vitamins, manipulator, null); } - public ArrayList getOriginVitamins(IVitaminHolder link, Affine manipulator, TransformNR offset) { + public ArrayList getOriginVitamins(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator, TransformNR offset) { ArrayList vitamins = link.getOriginVitamins(); - return toVitaminCad(vitamins, manipulator, offset); + return toVitaminCad(db,vitamins, manipulator, offset); } - public ArrayList getDefaultVitamins(IVitaminHolder link, Affine manipulator) { + public ArrayList getDefaultVitamins(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getDefaultVitamins(); - return toVitaminCad(vitamins, manipulator, null); + return toVitaminCad(db,vitamins, manipulator, null); } - public ArrayList getPreviousLinkVitamins(IVitaminHolder link, Affine manipulator) { + public ArrayList getPreviousLinkVitamins(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getPreviousLinkVitamins(); - return toVitaminCad(vitamins, manipulator, null); + return toVitaminCad(db,vitamins, manipulator, null); } - private ArrayList toVitaminCad(ArrayList vitamins, Affine manipulator, TransformNR offset) { + private ArrayList toVitaminCad(CSGDatabaseInstance db,ArrayList vitamins, Affine manipulator, TransformNR offset) { ArrayList parts = new ArrayList(); for (VitaminLocation vi : vitamins) { CSG vitamin; try { - vitamin = getVitamin(vi, manipulator, offset); + vitamin = getVitamin(db,vi, manipulator, offset); parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block @@ -136,26 +137,26 @@ private ArrayList toVitaminCad(ArrayList vitamins, Affine return parts; } - public ArrayList getVitamins(AbstractLink link) { + public ArrayList getVitamins(CSGDatabaseInstance db,AbstractLink link) { LinkConfiguration conf = link.getLinkConfiguration(); - return getVitamins(conf, (Affine) link.getGlobalPositionListener()); + return getVitamins(db,conf, (Affine) link.getGlobalPositionListener()); } - public ArrayList getVitamins(AbstractLink link, Affine manipulator) { + public ArrayList getVitamins(CSGDatabaseInstance db,AbstractLink link, Affine manipulator) { LinkConfiguration conf = link.getLinkConfiguration(); - return getVitamins(conf, manipulator); + return getVitamins(db,conf, manipulator); } - public ArrayList getVitamins(MobileBase base) { + public ArrayList getVitamins(CSGDatabaseInstance db,MobileBase base) { Affine rootListener = (Affine) base.getRootListener(); - return getVitamins(base, rootListener); + return getVitamins(db,base, rootListener); } - public CSG getVitamin(VitaminLocation vitamin, Affine manipulator, TransformNR offset) { + public CSG getVitamin(CSGDatabaseInstance instance,VitaminLocation vitamin, Affine manipulator, TransformNR offset) { if (!vitaminCad.containsKey(vitamin)) { CSG starting; try { - CSG origin = vitaminMakeCSG(vitamin); + CSG origin = vitaminMakeCSG(instance,vitamin); starting = origin.transformed(TransformFactory.nrToCSG(vitamin.getLocation())); if (offset != null) starting = starting.transformed(TransformFactory.nrToCSG(offset)); @@ -172,22 +173,22 @@ public CSG getVitamin(VitaminLocation vitamin, Affine manipulator, TransformNR o return vitaminCad.get(vitamin); } - public static CSG vitaminMakeCSG(VitaminLocation vitamin) throws Exception { + public static CSG vitaminMakeCSG(CSGDatabaseInstance instance,VitaminLocation vitamin) throws Exception { if (vitamin.isScript()) { Object o = ScriptingEngine.gitScriptRun(vitamin.getType(), vitamin.getSize()); ArrayList flat = new ArrayList(); Vitamins.flatten(flat, o); return CSG.unionAll(flat); } else - return Vitamins.get(vitamin.getType(), vitamin.getSize()); + return Vitamins.get(instance,vitamin.getType(), vitamin.getSize()); } - public CSG getVitaminDisplay(VitaminLocation vitamin, Affine manipulator, TransformNR offset) { + public CSG getVitaminDisplay(CSGDatabaseInstance instance,VitaminLocation vitamin, Affine manipulator, TransformNR offset) { if (!vitaminDisplay.containsKey(vitamin)) { CSG starting; Affine offsetDisplay = new Affine(); try { - starting = vitaminMakeCSG(vitamin); + starting = vitaminMakeCSG(instance,vitamin); if (offset != null) { BowlerKernel.runLater(() -> { TransformFactory.nrToAffine(offset, offsetDisplay); @@ -231,36 +232,36 @@ public Affine getVitaminAffine(VitaminLocation vitamin) { throw new RuntimeException("Affine not present! " + vitamin.getName()); } - public ArrayList getOriginVitaminsDisplay(IVitaminHolder link, Affine manipulator, TransformNR offset) { + public ArrayList getOriginVitaminsDisplay(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator, TransformNR offset) { ArrayList vitamins = link.getOriginVitamins(); - return vitaminsToDisplay(vitamins, manipulator, offset); + return vitaminsToDisplay(db,vitamins, manipulator, offset); } - public ArrayList getDefaultVitaminsDisplay(IVitaminHolder link, Affine manipulator) { + public ArrayList getDefaultVitaminsDisplay(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getDefaultVitamins(); - return vitaminsToDisplay(vitamins, manipulator); + return vitaminsToDisplay(db,vitamins, manipulator); } - public ArrayList getPreviousLinkVitaminsDisplay(IVitaminHolder link, Affine manipulator) { + public ArrayList getPreviousLinkVitaminsDisplay(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { ArrayList vitamins = link.getPreviousLinkVitamins(); - return vitaminsToDisplay(vitamins, manipulator); + return vitaminsToDisplay(db,vitamins, manipulator); } - public ArrayList getVitaminsDisplay(IVitaminHolder link, Affine manipulator) { + public ArrayList getVitaminsDisplay(CSGDatabaseInstance db,IVitaminHolder link, Affine manipulator) { - return vitaminsToDisplay(link.getVitamins(), manipulator); + return vitaminsToDisplay(db,link.getVitamins(), manipulator); } - public ArrayList vitaminsToDisplay(ArrayList l, Affine manipulator) { - return vitaminsToDisplay(l, manipulator, null); + public ArrayList vitaminsToDisplay(CSGDatabaseInstance db,ArrayList l, Affine manipulator) { + return vitaminsToDisplay(db,l, manipulator, null); } - public ArrayList vitaminsToDisplay(ArrayList l, Affine manipulator, TransformNR offset) { + public ArrayList vitaminsToDisplay(CSGDatabaseInstance db,ArrayList l, Affine manipulator, TransformNR offset) { ArrayList parts = new ArrayList(); for (VitaminLocation vi : l) { CSG vitamin; try { - vitamin = getVitaminDisplay(vi, manipulator, offset); + vitamin = getVitaminDisplay(db,vi, manipulator, offset); parts.add(vitamin); } catch (Exception e) { // Auto-generated catch block @@ -270,19 +271,19 @@ public ArrayList vitaminsToDisplay(ArrayList l, Affine man return parts; } - public ArrayList getVitaminsDisplay(AbstractLink link) { + public ArrayList getVitaminsDisplay(CSGDatabaseInstance db,AbstractLink link) { LinkConfiguration conf = link.getLinkConfiguration(); - return getVitaminsDisplay(conf, (Affine) link.getGlobalPositionListener()); + return getVitaminsDisplay(db,conf, (Affine) link.getGlobalPositionListener()); } - public ArrayList getVitaminsDisplay(AbstractLink link, Affine manipulator) { + public ArrayList getVitaminsDisplay(CSGDatabaseInstance db,AbstractLink link, Affine manipulator) { LinkConfiguration conf = link.getLinkConfiguration(); - return getVitaminsDisplay(conf, manipulator); + return getVitaminsDisplay(db,conf, manipulator); } - public ArrayList getVitaminsDisplay(MobileBase base) { + public ArrayList getVitaminsDisplay(CSGDatabaseInstance db,MobileBase base) { Affine rootListener = (Affine) base.getRootListener(); - return getVitaminsDisplay(base, rootListener); + return getVitaminsDisplay(db,base, rootListener); } public void render() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index e6f20f21..f8aa73f7 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -131,9 +131,9 @@ public static List flaten(String git, String file, Class type, ArrayLi return flattened; } - public static List flaten(File f, Class type, ArrayList args) throws Exception { + public static List flaten(CSGDatabaseInstance instance,File f, Class type, ArrayList args) throws Exception { ArrayList flattened = new ArrayList(); - Object o = inlineFileScriptRun(f, args); + Object o = inlineFileScriptRun(instance,f, args); flatenInterna(o, type, flattened); return flattened; } @@ -511,18 +511,19 @@ public static Object inlineScriptRun(CSGDatabaseInstance instance,File code, Arr } CSGDatabaseInstance prevDB = instance; if(prevDB==null) - try { - if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { - File p = code.getParentFile(); - for (String s : p.list()) { - if (s.toLowerCase().contentEquals("csgdatabase.json")) { - prevDB=(new CSGDatabaseInstance(new File(p.getAbsoluteFile()+DownloadManager.delim()+s) )); + try { + if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { + File p = code.getParentFile(); + for (String s : p.list()) { + if (s.toLowerCase().contentEquals("csgdatabase.json")) { + prevDB = (new CSGDatabaseInstance( + new File(p.getAbsoluteFile() + DownloadManager.delim() + s))); + } } } + } catch (Exception e) { + Log.error(e); } - } catch (Exception e) { - Log.error(e); - } if(prevDB==null) prevDB=CSGDatabase.getInstance(); IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); @@ -1184,11 +1185,14 @@ private static String[] codeFromGistID(String id, String FileName) throws Except return null; } - public static Object inlineFileScriptRun(File f, ArrayList args) throws Exception { return inlineScriptRun(f, args, getShellType(f.getName())); } + public static Object inlineFileScriptRun(CSGDatabaseInstance instance,File f, ArrayList args) throws Exception { + + return inlineScriptRun(instance,f, args, getShellType(f.getName())); + } public static Object inlineGistScriptRun(String gistID, String Filename, ArrayList args) throws Exception { String[] gistData = codeFromGistID(gistID, Filename); @@ -1196,12 +1200,16 @@ public static Object inlineGistScriptRun(String gistID, String Filename, ArrayLi } public static Object gitScriptRun(String gitURL, String Filename) throws Exception { - return gitScriptRun(gitURL, Filename, null); + return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); + } + public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename) throws Exception { + return gitScriptRun(db,gitURL, Filename, null); } - public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { - String[] gistData = codeFromGit(gitURL, Filename); - return inlineScriptRun(new File(gistData[2]), args, getShellType(gistData[1])); + return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); + } + public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename, ArrayList args) throws Exception { + return inlineScriptRun(db,fileFromGit(gitURL, Filename), args, getShellType(Filename)); } public static File fileFromGit(String remoteURI, String fileInRepo) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 0305e0ba..7e94df5a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -69,7 +69,7 @@ public List process(List incoming) { if (getName() == null) { } - CSGDatabaseInstance instance = CSGDatabase.getInstance(); + //CSGDatabaseInstance instance = CSGDatabase.getInstance(); try { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); @@ -92,7 +92,7 @@ public List process(List incoming) { } List flattenedCSGs; try { - flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, args); + flattenedCSGs = ScriptingEngine.flaten(getCaDoodleFile().getCsgDBinstance(),file, CSG.class, args); }catch(Throwable t) { com.neuronrobotics.sdk.common.Log.error(t); flattenedCSGs=new ArrayList(); @@ -109,12 +109,12 @@ public List process(List incoming) { com.neuronrobotics.sdk.common.Log.error(ex);; } } - CSGDatabase.setInstance(instance); + //CSGDatabase.setInstance(instance); for(CSG csg1:collect) - csg1.setParameter(getCaDoodleFile().getCsgDBinstance(),getFileLocationparam(file,name)); + csg1.setParameter(getCaDoodleFile().getCsgDBinstance(),getFileLocationparam(getCaDoodleFile().getCsgDBinstance(),file,name)); back.addAll(collect); } catch (Exception e) { - CSGDatabase.setInstance(instance); + //CSGDatabase.setInstance(instance); throw new RuntimeException(e); } return back; @@ -335,18 +335,18 @@ private static CSG processGiven(CSG csg, int i, String name, File f,String task, if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); instancetmp = new CSGDatabaseInstance(tempFile.toFile()); - CSGDatabase.setInstance(instancetmp); + //CSGDatabase.setInstance(instancetmp); } String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); - List flattenedCSGs = ScriptingEngine.flaten(file, CSG.class, null); + List flattenedCSGs = ScriptingEngine.flaten(instancetmp,file, CSG.class, null); CSG csg1 = flattenedCSGs.get(i); if(isDoodle) { csg1.getMapOfparametrics(instancetmp ).clear(); csg1.setStorage(new PropertyStorage()); } - CSGDatabase.setInstance(instance); - csg1.setParameter(instance,getFileLocationparam(f,task)); + //CSGDatabase.setInstance(instance); + csg1.setParameter(instance,getFileLocationparam(instance,f,task)); return processGiven(csg1, i, name,f,task,location,instance); } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error(e); @@ -357,8 +357,8 @@ private static CSG processGiven(CSG csg, int i, String name, File f,String task, return processedCSG; } - private static StringParameter getFileLocationparam( File pathname,String task) { - StringParameter stringParameter = new StringParameter(task + "_CaDoodle_File", pathname.getAbsolutePath(), new ArrayList()); + private static StringParameter getFileLocationparam(CSGDatabaseInstance instance, File pathname,String task) { + StringParameter stringParameter = new StringParameter(instance,task + "_CaDoodle_File", pathname.getAbsolutePath(), new ArrayList()); stringParameter.setStrValue(pathname.getAbsolutePath()); return stringParameter; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index b640037b..6d904057 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -263,11 +263,11 @@ private void updateBoM() { if (!param.contains(c.getName())) continue; if (param.contains("_CaDoodle_Vitamin_Type")) { - Parameter p = CSGDatabase.get(param); + Parameter p = getCsgDBinstance().get(param); type = p.getStrValue(); } if (param.contains("_CaDoodle_Vitamin_Size")) { - Parameter p = CSGDatabase.get(param); + Parameter p = getCsgDBinstance().get(param); size = p.getStrValue(); } if (type != null && size != null) { @@ -722,7 +722,7 @@ private CSG cloneCSG(CSG dyingCSG) { existing = true; } if (!existing) { - Parameter vals = CSGDatabase.get(param); + Parameter vals = getCsgDBinstance().get(param); if (vals != null) csg.setParameter(getCsgDBinstance(),vals, getCsgDBinstance().getMapOfparametrics(dyingCSG).get(param)); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index 6b6c774d..bb54ec10 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -25,7 +25,7 @@ public CSG get(String typencoming, ArrayList args) { String name = args.get(0).toString(); ArrayListtypes=new ArrayList<>(); types.addAll(Vitamins.listVitaminTypes()); - StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming,types); + StringParameter typeParam = new StringParameter(instance,name + "_CaDoodle_Vitamin_Type", typencoming,types); String type=typeParam.getStrValue(); ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); try { @@ -48,19 +48,19 @@ public CSG get(String typencoming,String defaultValue, ArrayList args) ArrayListtypes=new ArrayList<>(); types.addAll(Vitamins.listVitaminTypes()); - StringParameter typeParam = new StringParameter(name + "_CaDoodle_Vitamin_Type", typencoming, + StringParameter typeParam = new StringParameter(instance,name + "_CaDoodle_Vitamin_Type", typencoming, types); String type=typeParam.getStrValue(); ArrayList listVitaminSizes = Vitamins.listVitaminSizes(type); - StringParameter size = new StringParameter(type + " Default", defaultValue, listVitaminSizes); + StringParameter size = new StringParameter(instance,type + " Default", defaultValue, listVitaminSizes); String strValue = size.getStrValue(); if(strValue.length() == 0) { size.setStrValue(listVitaminSizes.get(0)); } String string = "_CaDoodle_Vitamin_Size"; - StringParameter word = new StringParameter(name + string, strValue, + StringParameter word = new StringParameter(instance,name + string, strValue, listVitaminSizes); boolean sizeExists=false; for(String s:Vitamins.listVitaminSizes(type)) { @@ -86,8 +86,8 @@ public CSG get(String typencoming,String defaultValue, ArrayList args) CSG part; try { // com.neuronrobotics.sdk.common.Log.debug("Generating Vitamin "+type+" "+word.getStrValue()+" for vitamin named "+name); - part = Vitamins.get(type, word.getStrValue()).setIsHole(true); - CSGDatabase.saveDatabase(); + part = Vitamins.get(instance,type, word.getStrValue()).setIsHole(true); + instance.saveDatabase(); Set params = part.getParameters(instance); part.setParameter(instance,word); @@ -111,8 +111,8 @@ public CSG regenerate(CSG previous) { ArrayList ar = new ArrayList<>(); ar.addAll(args); ar.set(0, previous.getName()); - Parameter s = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Size"); - Parameter t = CSGDatabase.get(name2+"_CaDoodle_Vitamin_Type"); + Parameter s = instance.get(name2+"_CaDoodle_Vitamin_Size"); + Parameter t = instance.get(name2+"_CaDoodle_Vitamin_Type"); if(t==null) { com.neuronrobotics.sdk.common.Log.debug(" Error, type is null, previous "+name2+" has no parameters somehow??"); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index 8bf280da..ad0b901a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -111,7 +111,7 @@ public CSG sweep(Polygon p, String name, Bounds b) { public LengthParameter radius(String name) { String key = name + "_CaDoodle_Rad"; if (rad == null) - rad = new LengthParameter(key, getDefrad(), nopt); + rad = new LengthParameter(getCaDoodleFile().getCsgDBinstance(),key, getDefrad(), nopt); if (rad.getMM() < 0) rad.setMM(0); return rad; @@ -120,14 +120,14 @@ public LengthParameter radius(String name) { public LengthParameter zoffset(String name) { String key = name + "_CaDoodle_Z-per"; if (z == null) - z = new LengthParameter(key, getDefz(), nopt); + z = new LengthParameter(getCaDoodleFile().getCsgDBinstance(),key, getDefz(), nopt); return z; } public LengthParameter steps(String name) { String key = name + "_CaDoodle_Step"; if (step == null) - step = new LengthParameter(key, getDefstep(), nopt); + step = new LengthParameter(getCaDoodleFile().getCsgDBinstance(),key, getDefstep(), nopt); if (step.getMM() < 3) step.setMM(3); return step; @@ -136,7 +136,7 @@ public LengthParameter steps(String name) { public LengthParameter angle(String name) { String key = name + "_CaDoodle_Angle"; if (angle == null) - angle = new LengthParameter(key, getDefangle(), nopt); + angle = new LengthParameter(getCaDoodleFile().getCsgDBinstance(),key, getDefangle(), nopt); if (angle.getMM() < 0.001) angle.setMM(0.001); return angle; @@ -145,7 +145,7 @@ public LengthParameter angle(String name) { public LengthParameter spiralStep(String name) { String key = name + "_CaDoodle_Spiral"; if (spiral == null) - spiral = new LengthParameter(key, getDefSpiral(), nopt); + spiral = new LengthParameter(getCaDoodleFile().getCsgDBinstance(),key, getDefSpiral(), nopt); if (spiral.getMM() < 0) spiral.setMM(0); return spiral; @@ -250,7 +250,7 @@ private CSG processGiven(Polygon p, Bounds b, int j, String name) { throw new RuntimeException(e); } - StringParameter parameter = new StringParameter(name + "_CaDoodle_File", pathname, options); + StringParameter parameter = new StringParameter(getCaDoodleFile().getCsgDBinstance(),name + "_CaDoodle_File", pathname, options); Parameter steps = steps(name); Parameter angle = angle(name); Parameter z = zoffset(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java index 755d3172..758ced61 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java @@ -67,7 +67,7 @@ public List process(List incoming) { } catch (FileNotFoundException e) { } for (int i = 0; i < controller.getVitaminNumber(); i++) { - CSG csg = controller.getVitaminCSG(i).cloneShallow(); + CSG csg = controller.getVitaminCSG(getCaDoodleFile().getCsgDBinstance(),i).cloneShallow(); TransformNR offset = getLocation().times(controller.getVitaminPose(i)); Transform nrToCSG = TransformFactory.nrToCSG(offset); String orderedName = getOrderedName(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java index 148ffaf1..365d1207 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/VitaminBomManager.java @@ -26,6 +26,7 @@ import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.paint.Color; public class VitaminBomManager { @@ -132,13 +133,13 @@ public VitaminBomManager addVitamin(VitaminLocation newElement, boolean save) { return this; } - public CSG get(String name) { + public CSG get(CSGDatabaseInstance db,String name) { VitaminLocation e = getElement(name); if (e == null) throw new RuntimeException("Vitamin must be defined before it is used: " + name); try { - CSG transformed = MobileBaseCadManager.vitaminMakeCSG(e) + CSG transformed = MobileBaseCadManager.vitaminMakeCSG(db,e) .transformed(TransformFactory.nrToCSG(e.getLocation())); transformed.setManufacturing(incominng -> { return null; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 3a2a3114..12a7e456 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -17,6 +17,8 @@ import eu.mihosoft.vrl.v3d.STL; import eu.mihosoft.vrl.v3d.Transform; import eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.ObjImporter; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.parametrics.LengthParameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; import javafx.scene.paint.Color; @@ -128,33 +130,33 @@ public static CSG get(File resource, boolean forceRefresh) { return csg.clone().setRegenerate(csg.getRegenerate()).syncProperties(csg); } - public static CSG get(String type, String id, String purchasingVariant) throws Exception { - String key = type + id + purchasingVariant; - if (fileLastLoaded.get(key) == null) { - PurchasingData purchasData = Purchasing.get(type, id, purchasingVariant); - for (String variable : purchasData.getVariantParameters().keySet()) { - double data = purchasData.getVariantParameters().get(variable); - LengthParameter parameter = new LengthParameter(variable, data, - (ArrayList) Arrays.asList(data, data)); - parameter.setMM(data); - } - - try { - fileLastLoaded.put(key, get(type, id)); - } catch (Exception e) { - com.neuronrobotics.sdk.common.Log.error(e); - - setGitRepoDatabase(gitRpoDatabase); - clear(); - return get(type, id); - } - - } - - CSG vitToGet = fileLastLoaded.get(type + id); - // com.neuronrobotics.sdk.common.Log.error("Loading "+vitToGet); - return vitToGet; - } +// public static CSG get(String type, String id, String purchasingVariant) throws Exception { +// String key = type + id + purchasingVariant; +// if (fileLastLoaded.get(key) == null) { +//// PurchasingData purchasData = Purchasing.get(type, id, purchasingVariant); +//// for (String variable : purchasData.getVariantParameters().keySet()) { +//// double data = purchasData.getVariantParameters().get(variable); +//// LengthParameter parameter = new LengthParameter(variable, data, +//// (ArrayList) Arrays.asList(data, data)); +//// parameter.setMM(data); +//// } +// +// try { +// fileLastLoaded.put(key, get(type, id)); +// } catch (Exception e) { +// com.neuronrobotics.sdk.common.Log.error(e); +// +// setGitRepoDatabase(gitRpoDatabase); +// clear(); +// return get(type, id); +// } +// +// } +// +// CSG vitToGet = fileLastLoaded.get(type + id); +// // com.neuronrobotics.sdk.common.Log.error("Loading "+vitToGet); +// return vitToGet; +// } public static boolean isGitURL(String text2) { if (!text2.endsWith(".git")) @@ -175,25 +177,27 @@ public static boolean isGitURL(String text2) { public static void flatten(ArrayList flat, Object o) { ScriptingEngine.flatten(flat, o); } - - public static CSG get(String type, String id) throws Exception { +// public static CSG get(String type, String id) throws Exception { +// return get(CSGDatabase.getInstance(),type,id); +// } + public static CSG get(CSGDatabaseInstance instance,String type, String id) throws Exception { if (isGitURL(type)) { Object o = ScriptingEngine.gitScriptRun(type, id); ArrayList flat = new ArrayList(); Vitamins.flatten(flat, o); return CSG.unionAll(flat); } - return get(type, id, 0); + return get(instance,type, id, 0); } - private static CSG get(String type, String id, int depthGauge) throws Exception { + private static CSG get(CSGDatabaseInstance instance,String type, String id, int depthGauge) throws Exception { String key = type + id; Map script = getMeta(type); Object file = null; Object repostring =null; try { CSG newVitamin = null; - StringParameter size = new StringParameter(type + " Default", id, Vitamins.listVitaminSizes(type)); + StringParameter size = new StringParameter(instance,type + " Default", id, Vitamins.listVitaminSizes(type)); size.setStrValue(id); file = script.get("scriptGit"); repostring = script.get("scriptFile"); @@ -201,7 +205,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception if (file != null && repo != null) { ArrayList servoMeasurments = new ArrayList(); servoMeasurments.add(id); - newVitamin = (CSG) ScriptingEngine.gitScriptRun(script.get("scriptGit").toString(), // git location of + newVitamin = (CSG) ScriptingEngine.gitScriptRun(instance,script.get("scriptGit").toString(), // git location of // the library repostring.toString(), // file to load servoMeasurments); @@ -232,7 +236,7 @@ private static CSG get(String type, String id, int depthGauge) throws Exception //ScriptingEngine.deleteRepo(script.get("scriptGit").toString()); clear(); if (depthGauge < 2) { - return get(type, id, depthGauge + 1); + return get(instance,type, id, depthGauge + 1); } else { return new Cube(20).toCSG().setColor(Color.RED); } From f6ce82415138e673edde4d7acf8b2632d2670e61 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 4 Oct 2025 21:52:51 -0400 Subject: [PATCH 599/635] Use the database instance to sync properties --- JCSG | 2 +- .../bowlerstudio/creature/LimbOption.java | 2 +- .../creature/MobileBaseCadManager.java | 2 +- .../bowlerstudio/creature/ThumbnailImage.java | 6 +- .../bowlerstudio/scripting/BlenderLoader.java | 4 +- .../bowlerstudio/scripting/GroovyHelper.java | 48 +++++++-------- .../scripting/ScriptingEngine.java | 21 ++++--- .../scripting/cadoodle/AddFromFile.java | 8 +-- .../scripting/cadoodle/AddFromScript.java | 19 +++--- .../scripting/cadoodle/Allign.java | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 61 ++++++++++--------- .../scripting/cadoodle/Group.java | 4 +- .../bowlerstudio/scripting/cadoodle/Hide.java | 2 +- .../bowlerstudio/scripting/cadoodle/Lock.java | 2 +- .../scripting/cadoodle/Mirror.java | 6 +- .../scripting/cadoodle/MoveCenter.java | 2 +- .../scripting/cadoodle/Paste.java | 2 +- .../scripting/cadoodle/Resize.java | 4 +- .../bowlerstudio/scripting/cadoodle/Show.java | 2 +- .../scripting/cadoodle/Sweep.java | 2 +- .../scripting/cadoodle/ToHole.java | 2 +- .../scripting/cadoodle/ToSolid.java | 2 +- .../scripting/cadoodle/UnGroup.java | 2 +- .../scripting/cadoodle/UnLock.java | 2 +- .../cadoodle/robot/AddRobotController.java | 2 +- .../util/GeometrySimplification.java | 5 +- .../bowlerstudio/vitamins/Vitamins.java | 2 +- .../src/junit/bowler/BlenderLoadingTest.java | 3 +- 28 files changed, 114 insertions(+), 107 deletions(-) diff --git a/JCSG b/JCSG index 3491011a..c17329ba 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 3491011aa24363ce952db27f47ad8463b2a71d99 +Subproject commit c17329ba5aceec001dd370c9e661a62197b34db5 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 9ae04925..7e78ba42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -142,7 +142,7 @@ public void build(CaDoodleFile f) throws IOException { } } BowlerKernel.runLater(() -> { - image = ThumbnailImage.get(so); + image = ThumbnailImage.get(f.getCsgDBinstance(),so); }); while(image==null) { try { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 1a72023f..06d6cd38 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -161,7 +161,7 @@ public CSG getVitamin(CSGDatabaseInstance instance,VitaminLocation vitamin, Affi if (offset != null) starting = starting.transformed(TransformFactory.nrToCSG(offset)); starting.setIsWireFrame(true); - starting.syncProperties(origin); + starting.syncProperties(instance,origin); } catch (Exception e) { // Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java index 6717923a..37aa0d42 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ThumbnailImage.java @@ -10,6 +10,8 @@ import eu.mihosoft.vrl.v3d.Bounds; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Vector3d; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.SceneAntialiasing; @@ -61,12 +63,12 @@ public static Bounds getSellectedBounds(List incoming) { return new Bounds(min, max); } - public static WritableImage get(List c) { + public static WritableImage get(CSGDatabaseInstance instance,List c) { ArrayList csgList=new ArrayList() ; for(CSG cs:c) { if(cs.getManipulator()!=null) { TransformNR nr = TransformFactory.affineToNr(cs.getManipulator()); - csgList.add(cs.transformed(TransformFactory.nrToCSG(nr)).syncProperties(cs)); + csgList.add(cs.transformed(TransformFactory.nrToCSG(nr)).syncProperties(instance,cs)); }else csgList.add(cs); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index 45da01bc..bc569c8b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -104,11 +104,11 @@ public static void scaleStl(File incoming, File outgoing, double scale) { com.neuronrobotics.sdk.common.Log.error(e); } } - public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { + public static CSG remesh(CSG incoming, double MMVoxel,CSGDatabaseInstance instance) throws Exception { File stl = DownloadManager.getTmpSTL(incoming); remeshSTLFile(stl, MMVoxel); CSG back = Vitamins.get(stl,true); - return back.syncProperties(incoming).setName(incoming.getName()); + return back.syncProperties(instance,incoming).setName(incoming.getName()); } public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { File blend = File.createTempFile(stlout.getName(), ".blend"); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 6e63b7e8..9e6c0639 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -6,9 +6,12 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.control.customizers.*; @@ -21,41 +24,30 @@ public class GroovyHelper implements IScriptingLanguage, IScriptingLanguageDebugger { - private Object inline(Object code, ArrayList args, CSGDatabaseInstance db2) throws Exception { + private Object inline(String code, ArrayList args, CSGDatabaseInstance db2) throws Exception { CompilerConfiguration cc = new CompilerConfiguration(); cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(ScriptingEngine.getImports()) ); Binding binding = new Binding(); -// for (String pm : DeviceManager.listConnectedDevice()) { -// BowlerAbstractDevice bad = DeviceManager.getSpecificDevice(null, pm); -// try { -// // groovy needs the objects cas to thier actual type befor -// // passing into the scipt -// -// binding.setVariable(bad.getScriptingName(), -// Class.forName(bad.getClass().getName()) -// .cast(bad)); -// } catch (Throwable e) { -// //throw e; -// } -//// com.neuronrobotics.sdk.common.Log.error("Device " + bad.getScriptingName() + " is " -//// + bad); -// } binding.setVariable("args", args); - File code2 = null; binding.setVariable("csgdb", db2); GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); // com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); Script script; - - if(code2==null) { - script = shell.parse((String) code); - } else { - script = shell.parse(code2); + if(!code.contains("csgdb")) { + code=code.replace("StringParameter(", "StringParameter(csgdb,"); + code=code.replace("LengthParameter(", "LengthParameter(csgdb,"); + code=code.replace("setParameter(", "setParameter(csgdb,"); + + code=code.replace("import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase", ""); + code=code.replace("CSGDatabase", "csgdb"); } + + script = shell.parse(code); + return script.run(); } @@ -75,13 +67,17 @@ public String getDefaultContents() { } @Override - public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { - return inline(code, args,db); + public Object inlineScriptRun(CSGDatabaseInstance db, File code, ArrayList args) throws Exception { + String jsonString = null; + InputStream inPut = null; + inPut = FileUtils.openInputStream(code); + jsonString = IOUtils.toString(inPut); + return inline(jsonString, args, db); } @Override - public Object inlineScriptRun(CSGDatabaseInstance db,String code, ArrayList args) throws Exception { - return inline(code, args,db); + public Object inlineScriptRun(CSGDatabaseInstance db, String code, ArrayList args) throws Exception { + return inline(code, args, db); } @Override diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index f8aa73f7..2f02a9b4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -108,33 +108,33 @@ public static void flatten(ArrayList flat, Object o) { } - public static void flatenInterna(Object o, Class type, ArrayList flattened) { + public static void flatenInterna(CSGDatabaseInstance instance,Object o, Class type, ArrayList flattened) { if (type.isInstance(o)) flattened.add((T) o); else if (List.class.isInstance(o)) { for (Object ob : (List) o) { - flatenInterna(ob, type, flattened); + flatenInterna(instance,ob, type, flattened); } } else if (Map.class.isInstance(o)) { Map m = (Map) o; for (Object key : m.keySet()) { - flatenInterna(m.get(key), type, flattened); - flatenInterna(key, type, flattened); + flatenInterna(instance,m.get(key), type, flattened); + flatenInterna(instance,key, type, flattened); } } } - public static List flaten(String git, String file, Class type, ArrayList args) throws Exception { + public static List flaten(CSGDatabaseInstance instance,String git, String file, Class type, ArrayList args) throws Exception { ArrayList flattened = new ArrayList(); - Object o = gitScriptRun(git, file, args); - flatenInterna(o, type, flattened); + Object o = gitScriptRun(instance,git, file, args); + flatenInterna(instance,o, type, flattened); return flattened; } public static List flaten(CSGDatabaseInstance instance,File f, Class type, ArrayList args) throws Exception { ArrayList flattened = new ArrayList(); Object o = inlineFileScriptRun(instance,f, args); - flatenInterna(o, type, flattened); + flatenInterna(instance,o, type, flattened); return flattened; } @@ -529,7 +529,6 @@ public static Object inlineScriptRun(CSGDatabaseInstance instance,File code, Arr IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); if (iScriptingLanguage != null) { Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(prevDB,code, args); - CSGDatabase.setInstance(prevDB); return inlineScriptRun; } return null; @@ -556,6 +555,7 @@ public static Object inlineScriptStringRun(CSGDatabaseInstance instance, String * @param args the incoming arguments as a list of objects * @return the objects returned form the code that ran */ + @Deprecated public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) throws Exception { @@ -1198,13 +1198,14 @@ public static Object inlineGistScriptRun(String gistID, String Filename, ArrayLi String[] gistData = codeFromGistID(gistID, Filename); return inlineScriptRun(new File(gistData[2]), args, getShellType(gistData[1])); } - + @Deprecated public static Object gitScriptRun(String gitURL, String Filename) throws Exception { return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); } public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename) throws Exception { return gitScriptRun(db,gitURL, Filename, null); } + @Deprecated public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 7e94df5a..a160435b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -69,7 +69,7 @@ public List process(List incoming) { if (getName() == null) { } - //CSGDatabaseInstance instance = CSGDatabase.getInstance(); + CSGDatabaseInstance instance = getCaDoodleFile().getCsgDBinstance(); try { // ArrayListargs = new ArrayList<>(); // args.addAll(Arrays.asList(getName() )); @@ -88,11 +88,11 @@ public List process(List incoming) { boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); - CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); + instance=(new CSGDatabaseInstance(tempFile.toFile())); } List flattenedCSGs; try { - flattenedCSGs = ScriptingEngine.flaten(getCaDoodleFile().getCsgDBinstance(),file, CSG.class, args); + flattenedCSGs = ScriptingEngine.flaten(instance,file, CSG.class, args); }catch(Throwable t) { com.neuronrobotics.sdk.common.Log.error(t); flattenedCSGs=new ArrayList(); @@ -326,7 +326,7 @@ private static CSG processGiven(CSG csg, int i, String name, File f,String task, } CSG processedCSG = csg - .transformed(nrToCSG).syncProperties(csg).setRegenerate(previous -> { + .transformed(nrToCSG).syncProperties(instance,csg).setRegenerate(previous -> { try { File file =f; //CSGDatabaseInstance instance = CSGDatabase.getInstance(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java index 3b5a8a3e..e3eda102 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromScript.java @@ -14,6 +14,7 @@ import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR; +import com.neuronrobotics.sdk.common.Log; import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.PropertyStorage; @@ -62,35 +63,37 @@ public List process(List incoming, String fileName) { configs.put("name", getName()); configs.put("PreventBomAdd", preventBoM); args.add(configs); - CSGDatabaseInstance instance = CSGDatabase.getInstance(); + CSGDatabaseInstance instance = getCaDoodleFile().getCsgDBinstance(); if(isDoodle) { Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); - CSGDatabase.setInstance(new CSGDatabaseInstance(tempFile.toFile())); + instance=(new CSGDatabaseInstance(tempFile.toFile())); + } + List flaten = ScriptingEngine.flaten(instance,gitULR, fileName, CSG.class, args); + for(CSG c:flaten) + for(String s:c.getParameters(instance)) { + Log.debug("Parameter added "+s); } - List flaten = ScriptingEngine.flaten(gitULR, fileName, CSG.class, args); ArrayList collect = new ArrayList<>(); collect.addAll(flaten); for(int i=0;i getNamesAddedInThisOperation() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 6d904057..debd6a78 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -81,7 +81,7 @@ public class CaDoodleFile { // @Expose (serialize = false, deserialize = false) // private List currentState = new ArrayList(); private double percentInitialized = 0; -// private final HashMap> cache = new HashMap>(); + private final HashMap> cache = new HashMap>(); private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() @@ -140,37 +140,40 @@ private int opToIndex(CaDoodleOperation op) { throw new IndexOutOfBoundsException(); } private List getCachedCSGs(CaDoodleOperation op) { - int opIndex = opToIndex(op); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { - return (List) ois.readObject(); - } catch (Exception ex) { - Log.error(ex); - } - return null; +// int opIndex = opToIndex(op); +// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); +// try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { +// return (List) ois.readObject(); +// } catch (Exception ex) { +// Log.error(ex); +// } +// return null; + + return cache.get(op); } private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { - int opIndex = opToIndex(op); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - if(cacheFile.exists()) - cacheFile.delete(); - try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { - oos.writeObject(cachedCopy); - }catch(Exception ex) { - Log.error(ex); - } - //cache.put(op, cachedCopy); +// int opIndex = opToIndex(op); +// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); +// if(cacheFile.exists()) +// cacheFile.delete(); +// try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { +// oos.writeObject(cachedCopy); +// }catch(Exception ex) { +// Log.error(ex); +// throw new RuntimeException(ex); +// } + cache.put(op, cachedCopy); } private void clearCache(CaDoodleOperation key) { - int opIndex = opToIndex(key); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - if(cacheFile.exists()) - cacheFile.delete(); +// int opIndex = opToIndex(key); +// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); +// if(cacheFile.exists()) +// cacheFile.delete(); -// List back = cache.remove(key); -// if (back != null) -// back.clear(); + List back = cache.remove(key); + if (back != null) + back.clear(); } @@ -208,7 +211,7 @@ public void initialize() { objectDir.mkdir(); File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); setCsgDBinstance(new CSGDatabaseInstance(db)); - CSGDatabase.setInstance(getCsgDBinstance()); + //CSGDatabase.setInstance(getCsgDBinstance()); bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); @@ -679,7 +682,7 @@ private void storeResultInCache(CaDoodleOperation op, List process) { throw new RuntimeException("There can not be 2 objects with the same name after an " + op.getType() + " opperation! " + c.getName()); names.add(c.getName()); - cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(c).setName(c.getName()) + cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(getCsgDBinstance(),c).setName(c.getName()) .setRegenerate(c.getRegenerate())); // cachedCopy.add(c); } @@ -1094,7 +1097,7 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr ArrayList holder = new ArrayList(); try { BowlerKernel.runLater(() -> { - holder.add(ThumbnailImage.get(currentState)); + holder.add(ThumbnailImage.get(getCsgDBinstance(),currentState)); }); } catch (Throwable ex) { com.neuronrobotics.sdk.common.Log.error(ex);; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index ddd775ef..0d1ac6f1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -64,12 +64,12 @@ public List process(List incoming) { replace.add(csg); CSG clone = csg.clone(); - CSG c = clone.syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + CSG c = clone.syncProperties(getCaDoodleFile().getCsgDBinstance(),csg).setRegenerate(csg.getRegenerate()).setName(name); c.addGroupMembership(getGroupID()); back.add(c); if(csg.hasManipulator()) { c=c.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(manip))) - .syncProperties(csg).setRegenerate(csg.getRegenerate()).setName(name); + .syncProperties(getCaDoodleFile().getCsgDBinstance(),csg).setRegenerate(csg.getRegenerate()).setName(name); c.addGroupMembership(getGroupID()); } if (csg.isHole()) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java index 088753c4..41b3c468 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Hide.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); b.setIsHide(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java index c996ac49..8953ccd3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Lock.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); b.setIsLock(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java index 3da6eb47..d9520603 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Mirror.java @@ -39,7 +39,7 @@ public String getType() { } private CSG sync(CSG incoming, CSG c) { - return c.syncProperties(incoming).setName(incoming.getName()).setColor(incoming.getColor()); + return c.syncProperties(getCaDoodleFile().getCsgDBinstance(),incoming).setName(incoming.getName()).setColor(incoming.getColor()); } @Override @@ -77,7 +77,7 @@ public List process(List incoming) { centered = centered.transformed(mirroringCenter); Transform wp = TransformFactory.nrToCSG(getWorkplane(incoming1)); centered = centered.transformed(wp); - CSG tf = centered.setName(name).syncProperties(incoming1); + CSG tf = centered.setName(name).syncProperties(getCaDoodleFile().getCsgDBinstance(),incoming1); sync(incoming1, tf); MoveCenter.set(getName()+(index++) , tf, inverse); MoveCenter.set(getName()+(index++) , tf, mirroringCenter.inverse()); @@ -125,7 +125,7 @@ private CSG mirror(CSG csg, String name) { } centered = centered.transformed(mirroringCenter); centered = centered.transformed(TransformFactory.nrToCSG(getWorkplane(csg))); - return centered.setName(name).syncProperties(csg); + return centered.setName(name).syncProperties(getCaDoodleFile().getCsgDBinstance(),csg); } public MirrorOrentation getLocation() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java index 2a0aae7f..5140e99f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java @@ -99,7 +99,7 @@ public ArrayList process(CSG incoming, int depth) { if(incoming.isMotionLock()) { nrToCSG2=new Transform(); } - CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(incoming).setName(incoming.getName()); + CSG tmpToAdd = incoming.transformed(nrToCSG2).syncProperties(getCaDoodleFile().getCsgDBinstance(),incoming).setName(incoming.getName()); ArrayList b = new ArrayList<>(); b.add(tmpToAdd); set(getName(), tmpToAdd, location); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index ec720fbd..cbd866f4 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -106,7 +106,7 @@ private ArrayList copyPasteMoved(ArrayList back, CSG c, int depth) { newOne = clone.transformed(nrToCSG2); newOne.setRegenerate(c.getRegenerate()); } - newOne.syncProperties(c).setName(name); + newOne.syncProperties(getCaDoodleFile().getCsgDBinstance(),c).setName(name); MoveCenter.set(name, newOne, location); index++; getNamesAdded().add(name); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java index 08c0fcd2..da16c3a6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Resize.java @@ -154,7 +154,7 @@ private void resizeByName(String name, ArrayList back, HashMap back, gc = gc.movez(ev.movez); gc = gc.transformed(ev.scale); gc = gc.movex(ev.movex).movey(ev.movey).transformed(TransformFactory.nrToCSG(getWorkplane())); - gc.syncProperties(c).setName(c.getName()); + gc.syncProperties(getCaDoodleFile().getCsgDBinstance(),c).setName(c.getName()); back.set(i, gc); if (c.isGroupResult()) { groupsProcessed.put(c.getName(), ev); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java index 4d6e9b97..240d6cd5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Show.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); b.setIsHide(false); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java index ad0b901a..3de56ecb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Sweep.java @@ -256,7 +256,7 @@ private CSG processGiven(Polygon p, Bounds b, int j, String name) { Parameter z = zoffset(name); Parameter radius = radius(name); parameter.setStrValue(pathname); - CSG processedCSG = csg.transformed(nrToCSG).syncProperties(csg) + CSG processedCSG = csg.transformed(nrToCSG).syncProperties(getCaDoodleFile().getCsgDBinstance(),csg) .setParameter(getCaDoodleFile().getCsgDBinstance(), parameter) .setParameter(getCaDoodleFile().getCsgDBinstance(), steps) .setParameter(getCaDoodleFile().getCsgDBinstance(), angle) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java index b18c6b36..a4db3cc5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToHole.java @@ -26,7 +26,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); b.setIsHole(true); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java index 1e5120f3..5c3209ec 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ToSolid.java @@ -38,7 +38,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG t=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG t=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); t.setIsHole(false); if(useColor) { t.setColor(getColor()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java index 8bc6d9dc..965382b9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnGroup.java @@ -39,7 +39,7 @@ public List process(List incoming) { CSG regenerate = csg.getRegenerate().regenerate(csg); transformed = regenerate.transformed(nrToCSG); } - CSG readd= transformed.setRegenerate(csg.getRegenerate()).syncProperties(csg).setName(csg.getName()); + CSG readd= transformed.setRegenerate(csg.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),csg).setName(csg.getName()); readd.removeGroupMembership(name); back.remove(csg); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java index 47c69d9d..f4e1b3a6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/UnLock.java @@ -24,7 +24,7 @@ public List process(List incoming) { for(String name:names) { if(name.contentEquals(c.getName())) { replace.add(c); - CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(c); + CSG b=c.clone().setRegenerate(c.getRegenerate()).syncProperties(getCaDoodleFile().getCsgDBinstance(),c); b.setIsLock(false); back.add(b); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java index 758ced61..86b6448e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/robot/AddRobotController.java @@ -77,7 +77,7 @@ public List process(List incoming) { if (getBuilderName() != null) { csg.setMobileBaseName(getBuilderName()); } - CSG tmp = csg.transformed(nrToCSG).syncProperties(csg).setRegenerate(csg.getRegenerate()) + CSG tmp = csg.transformed(nrToCSG).syncProperties(getCaDoodleFile().getCsgDBinstance(),csg).setRegenerate(csg.getRegenerate()) .setName(orderedName); back.add(tmp); MoveCenter.set(getName(), tmp, nrToCSG); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java index a2f155d6..ac6ae47c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -10,6 +10,7 @@ import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import eu.mihosoft.vrl.v3d.CSG; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; public class GeometrySimplification { /** @@ -19,8 +20,8 @@ public class GeometrySimplification { * @return a re-meshed CSG * @throws Exception */ - public static CSG remesh(CSG incoming, double MMVoxel) throws Exception { - return BlenderLoader.remesh(incoming, MMVoxel); + public static CSG remesh(CSG incoming, double MMVoxel,CSGDatabaseInstance instance) throws Exception { + return BlenderLoader.remesh(incoming, MMVoxel,instance); } /** * RE-mesh an STL file in place diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 12a7e456..25cea472 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -127,7 +127,7 @@ public static CSG get(File resource, boolean forceRefresh) { } CSG csg = fileLastLoaded.get(resource.getAbsolutePath()); - return csg.clone().setRegenerate(csg.getRegenerate()).syncProperties(csg); + return csg.clone().setRegenerate(csg.getRegenerate()); } // public static CSG get(String type, String id, String purchasingVariant) throws Exception { diff --git a/test/java/src/junit/bowler/BlenderLoadingTest.java b/test/java/src/junit/bowler/BlenderLoadingTest.java index 2212461c..18fc1659 100644 --- a/test/java/src/junit/bowler/BlenderLoadingTest.java +++ b/test/java/src/junit/bowler/BlenderLoadingTest.java @@ -9,6 +9,7 @@ import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.Cube; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; public class BlenderLoadingTest { @@ -21,7 +22,7 @@ public void test() throws Exception { fail("Failed to load polygon!"); com.neuronrobotics.sdk.common.Log.error("Blender file loaded num polys: "+loaded.getPolygons().size()); CSG cube = new Cube(100).toCSG(); - CSG remeshed = GeometrySimplification.remesh(cube, 10.0); + CSG remeshed = GeometrySimplification.remesh(cube, 10.0,CSGDatabase.getInstance()); if(remeshed.getPolygons().size()!=1452) fail("Blender failed to remesh"); com.neuronrobotics.sdk.common.Log.error("Remeshing produced: "+remeshed.getPolygons().size()); From 7f3c5c2b9a7c879ec4ce0e1be9c39cef20fc7369 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 11:07:45 -0400 Subject: [PATCH 600/635] Switching explicatly to the non depricated API --- JCSG | 2 +- .../bowlerstudio/BowlerKernel.java | 14 +- .../assets/ConfigurationDatabase.java | 5 +- .../creature/ControllerOption.java | 2 +- .../bowlerstudio/creature/LimbOption.java | 3 +- .../creature/MobileBaseBuilder.java | 7 +- .../creature/MobileBaseCadManager.java | 30 ++-- .../creature/MobileBaseLoader.java | 42 +++++- .../bowlerstudio/scripting/RobotHelper.java | 24 ++++ .../scripting/ScriptingEngine.java | 131 ++++++++++-------- .../bowlerstudio/sequence/TimeSequence.java | 5 +- .../bowlerstudio/vitamins/Vitamins.java | 2 +- .../src/junit/bowler/ArduinoLoaderTest.java | 4 +- .../src/junit/bowler/BlenderLoadingTest.java | 2 +- test/java/src/junit/bowler/SequenceTest.java | 4 +- 15 files changed, 192 insertions(+), 85 deletions(-) diff --git a/JCSG b/JCSG index c17329ba..a5e12b5d 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit c17329ba5aceec001dd370c9e661a62197b34db5 +Subproject commit a5e12b5d820852473b02ba24388f4c685a655313 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java index f33f5e8f..345e24e1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java @@ -60,6 +60,8 @@ import eu.mihosoft.vrl.v3d.CSGServer; import eu.mihosoft.vrl.v3d.ICSGProgress; import eu.mihosoft.vrl.v3d.JavaFXInitializer; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import javafx.application.Platform; import javafx.scene.control.Tab; import javafx.scene.transform.Affine; @@ -198,7 +200,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) } if (gitFile != null) try { - ret = ScriptingEngine.gitScriptRun(gitRepo, gitFile, null); + ret = ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(),gitRepo, gitFile, null); url = gitRepo; baseWorkspaceFile = ScriptingEngine.getRepositoryCloneDirectory(url); @@ -244,7 +246,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) com.neuronrobotics.sdk.common.Log.debug("Using working directory " + baseWorkspaceFile.getAbsolutePath()); f = new File(baseWorkspaceFile.getAbsolutePath() + "/" + s); com.neuronrobotics.sdk.common.Log.error("File " + f.getName()); - ret = ScriptingEngine.inlineFileScriptRun(f, null); + ret = ScriptingEngine.inlineFileScriptRun(CSGDatabase.getInstance(),f, null); } catch (Throwable e) { e.printStackTrace(); fail(); @@ -265,7 +267,7 @@ public static void runArgumentsAfterStartup(String[] args, long startTime) if (startLoadingScripts) { try { - ret = ScriptingEngine.inlineFileScriptRun(new File(s), (ArrayList) ret); + ret = ScriptingEngine.inlineFileScriptRun(CSGDatabase.getInstance(),new File(s), (ArrayList) ret); } catch (Throwable e) { e.printStackTrace(); fail(); @@ -374,7 +376,7 @@ public void run() { continue; } try { - ret = ScriptingEngine.inlineScriptStringRun(line, null, shellTypeStorage); + ret = ScriptingEngine.inlineScriptStringRun(CSGDatabase.getInstance(),line, null, shellTypeStorage); if (ret != null) { com.neuronrobotics.sdk.common.Log.error(ret); } @@ -402,7 +404,9 @@ private static void startupProcedures(String[] args) if (args.length == 0) { fail(); } - ScriptingEngine.gitScriptRun("https://github.com/CommonWealthRobotics/DeviceProviders.git", "loadAll.groovy", + CSGDatabase.setInstance(new CSGDatabaseInstance(new File(ScriptingEngine.getWorkspace().getAbsoluteFile() + "/csgDatabase.json"))); + + ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(),"https://github.com/CommonWealthRobotics/DeviceProviders.git", "loadAll.groovy", null); CSG.setPreventNonManifoldTriangles(true); CSG.setProgressMoniter(new ICSGProgress() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 0a4ba4ef..3bca4e17 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -21,6 +21,9 @@ import com.neuronrobotics.bowlerstudio.scripting.IGithubLoginListener; import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; + +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; + import java.nio.charset.*; import java.nio.file.Files; import java.nio.file.Path; @@ -161,7 +164,7 @@ public static void getDatabase() { File loadFile = loadFile(); if(loadFile.exists()) try { - Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(loadFile, null); + Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(CSGDatabase.getInstance(),loadFile, null); database = Collections.synchronizedMap((HashMap>) inlineFileScriptRun); } catch (Exception e) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 87c8ad59..61cd2f9e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -131,7 +131,7 @@ public void runLinkLoader() throws FileNotFoundException { return; } try { - ScriptingEngine.inlineGistScriptRun(linkLoaderGit, linkLoaderFile, null); + ScriptingEngine.inlineGistScriptRun(CSGDatabase.getInstance(),linkLoaderGit, linkLoaderFile, null); } catch (Exception e) { // TODO Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 7e78ba42..67a1d21d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -26,6 +26,7 @@ import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.BowlerKernel; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; +import com.neuronrobotics.bowlerstudio.scripting.RobotHelper; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.CaDoodleFile; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; @@ -69,7 +70,7 @@ public DHParameterKinematics getLimb(String uniqueName) throws Exception { newLimb.setScriptingName(uniqueName); return newLimb; } else { - MobileBase base = (MobileBase) ScriptingEngine.gitScriptRun(url, file); + MobileBase base = RobotHelper.fileToRobot(url, file); DHParameterKinematics newLimb = base.getAllDHChains().get(0); newLimb.setScriptingName(uniqueName); return newLimb; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java index 68c67c69..5b827d31 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseBuilder.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio.creature; import com.google.gson.annotations.Expose; +import com.neuronrobotics.bowlerstudio.scripting.RobotHelper; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotController; import com.neuronrobotics.bowlerstudio.scripting.cadoodle.robot.AddRobotLimb; @@ -13,6 +14,8 @@ import com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup; import com.neuronrobotics.sdk.common.Log; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.eclipse.jgit.api.errors.GitAPIException; @@ -290,7 +293,7 @@ public MobileBaseBuilder addFixedWheelFromOptions(String wheelType) { try { @SuppressWarnings("unchecked") HashMap> options = (HashMap>) ScriptingEngine - .gitScriptRun("https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", + .gitScriptRun(CSGDatabase.getInstance(),"https://github.com/CommonWealthRobotics/BowlerStudioExampleRobots.git", "wheelOptions.json"); if (options.containsKey(wheelType)) { @@ -303,7 +306,7 @@ public MobileBaseBuilder addFixedWheelFromOptions(String wheelType) { IOUtils.toInputStream(xmlContent, "UTF-8")); return addFixedWheel(newWheel); } else { - MobileBase base = (MobileBase) ScriptingEngine.gitScriptRun(values.get("scriptGit").toString(), + MobileBase base = RobotHelper.fileToRobot(values.get("scriptGit").toString(), values.get("scriptFile").toString()); DHParameterKinematics newWheel = base.getDrivable().get(0); return addFixedWheel(newWheel); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 06d6cd38..899051fb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -24,6 +24,7 @@ import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.printbed.PrintBedManager; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.util.FileChangeWatcher; import com.neuronrobotics.bowlerstudio.util.FileWatchDeviceWrapper; @@ -49,6 +50,7 @@ import com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup; import com.neuronrobotics.sdk.common.BowlerAbstractDevice; import com.neuronrobotics.sdk.common.IDeviceConnectionEventListener; +import com.neuronrobotics.sdk.common.Log; import com.neuronrobotics.sdk.pid.PIDLimitEvent; import com.neuronrobotics.sdk.util.ThreadUtil; @@ -97,6 +99,7 @@ public class MobileBaseCadManager implements Runnable { private static ArrayList toRun = new ArrayList(); private ArrayList rendersync = new ArrayList<>(); private boolean forceChage = true; + public CSG getVitamin(CSGDatabaseInstance db,VitaminLocation vitamin) throws Exception { return getVitamin(db,vitamin, new Affine(), null); @@ -175,7 +178,7 @@ public CSG getVitamin(CSGDatabaseInstance instance,VitaminLocation vitamin, Affi public static CSG vitaminMakeCSG(CSGDatabaseInstance instance,VitaminLocation vitamin) throws Exception { if (vitamin.isScript()) { - Object o = ScriptingEngine.gitScriptRun(vitamin.getType(), vitamin.getSize()); + Object o = ScriptingEngine.gitScriptRun(instance,vitamin.getType(), vitamin.getSize()); ArrayList flat = new ArrayList(); Vitamins.flatten(flat, o); return CSG.unionAll(flat); @@ -781,12 +784,12 @@ private MobileBaseCadManager(MobileBase base, IMobileBaseUI myUI) { setMobileBase(base); } - private Object scriptFromFileInfo(String name, String[] args, Runnable runner) throws Throwable { + private Object scriptFromFileInfo(CSGDatabaseInstance db,String name, String[] args, Runnable runner) throws Throwable { String key = args[0] + ":" + args[1]; try { File f = ScriptingEngine.fileFromGit(args[0], args[1]); if (cadScriptCache.get(key) == null) { - build(key, f); + build(db,key, f); FileChangeWatcher watcher = FileChangeWatcher.watch(f); Exception ex = new Exception("CAD script declared here and regenerated"); IFileChangeListener l = new IFileChangeListener() { @@ -799,7 +802,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event) { com.neuronrobotics.sdk.common.Log.error("Clearing the compiled CAD script for " + key); cadScriptCache.remove(key); try { - build(key, f); + build(db,key, f); } catch (Throwable e) { // Auto-generated catch block com.neuronrobotics.sdk.common.Log.error(e); @@ -840,11 +843,11 @@ public void onConnect(BowlerAbstractDevice source) { } - private void build(String key, File f) throws Throwable { + private void build(CSGDatabaseInstance db,String key, File f) throws Throwable { try { com.neuronrobotics.sdk.common.Log .error("Building the compiled CAD script for " + key + " " + base + " " + base.getScriptingName()); - cadScriptCache.put(key, ScriptingEngine.inlineFileScriptRun(f, null)); + cadScriptCache.put(key, ScriptingEngine.inlineFileScriptRun(db,f, null)); } catch (Throwable e) { getUi().highlightException(f, e); throw e; @@ -877,7 +880,7 @@ private void closeScriptFromFileInfo(String[] args) { private IgenerateBody getIgenerateBody(MobileBase b) throws Throwable { if (isConfigMode()) return getConfigurationDisplay(); - Object cadForBodyEngine = scriptFromFileInfo(b.getScriptingName(), b.getGitCadEngine(), () -> { + Object cadForBodyEngine = scriptFromFileInfo(getDb(),b.getScriptingName(), b.getGitCadEngine(), () -> { run(); generateCad(); }); @@ -890,7 +893,7 @@ private IgenerateBody getIgenerateBody(MobileBase b) throws Throwable { private IgenerateCad getIgenerateCad(DHParameterKinematics dh) throws Throwable { if (isConfigMode()) return getConfigurationDisplay(); - Object cadForBodyEngine = scriptFromFileInfo(dh.getScriptingName(), dh.getGitCadEngine(), () -> { + Object cadForBodyEngine = scriptFromFileInfo(getDb(),dh.getScriptingName(), dh.getGitCadEngine(), () -> { run(); generateCad(); }); @@ -901,7 +904,7 @@ private IgenerateCad getIgenerateCad(DHParameterKinematics dh) throws Throwable } public IgenerateBed getIgenerateBed() throws Throwable { - Object cadForBodyEngine = scriptFromFileInfo(base.getScriptingName(), base.getGitCadEngine(), () -> { + Object cadForBodyEngine = scriptFromFileInfo(getDb(),base.getScriptingName(), base.getGitCadEngine(), () -> { run(); }); if (IgenerateBed.class.isInstance(cadForBodyEngine)) { @@ -914,7 +917,7 @@ private ICadGenerator getConfigurationDisplay() throws Throwable { if (cadEngineConfiguration == null) { String[] args = new String[] { "https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy" }; - Object cadForBodyEngine = scriptFromFileInfo("ConfigDisplay", args, () -> { + Object cadForBodyEngine = scriptFromFileInfo(getDb(),"ConfigDisplay", args, () -> { cadEngineConfiguration = null; try { getConfigurationDisplay(); @@ -942,6 +945,10 @@ private ICadGenerator getConfigurationDisplay() throws Throwable { return cadEngineConfiguration; } + private CSGDatabaseInstance getDb() { + return MobileBaseLoader.get(base).getDb(); + } + public ArrayList generateBody() { return generateBody(getMobileBase(), true); } @@ -1294,6 +1301,7 @@ public void setMobileBase(MobileBase b) { } } this.base = b; + cadmap.put(base, this); MobileBaseLoader.get(base);// load the dependant scripts base.updatePositions(); @@ -1728,4 +1736,6 @@ private static MobileBaseCadManager checkforBase(IVitaminHolder holder, MobileBa return null; } + + } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java index 3447af7f..b0ae48cf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java @@ -6,8 +6,11 @@ import java.util.HashMap; import org.apache.commons.io.IOUtils; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.TransportException; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import com.neuronrobotics.bowlerstudio.util.FileWatchDeviceWrapper; import com.neuronrobotics.bowlerstudio.util.IFileChangeListener; @@ -17,12 +20,23 @@ import com.neuronrobotics.sdk.addons.kinematics.IDriveEngine; import com.neuronrobotics.sdk.addons.kinematics.MobileBase; import com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup; +import com.neuronrobotics.sdk.common.Log; + +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; public class MobileBaseLoader { private static HashMap map = new HashMap<>(); private MobileBase base; private IDriveEngine defaultDriveEngine; + private CSGDatabaseInstance db; + public CSGDatabaseInstance getDb() { + return db; + } + public void setDb(CSGDatabaseInstance db) { + this.db = db; + } private MobileBaseLoader(MobileBase base) { this.setBase(base); @@ -41,7 +55,7 @@ public File setDefaultDhParameterKinematics(DHParameterKinematics device) { File code = null; try { code = ScriptingEngine.fileFromGit(device.getGitDhEngine()[0], device.getGitDhEngine()[1]); - DhInverseSolver defaultDHSolver = (DhInverseSolver) ScriptingEngine.inlineFileScriptRun(code, null); + DhInverseSolver defaultDHSolver = (DhInverseSolver) ScriptingEngine.inlineFileScriptRun(getDb(),code, null); File c = code; FileWatchDeviceWrapper.watch(device, code,new IFileChangeListener() { @@ -57,7 +71,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event) { try { com.neuronrobotics.sdk.common.Log.error("D-H Solver changed, updating " + device.getScriptingName()); - DhInverseSolver d = (DhInverseSolver) ScriptingEngine.inlineFileScriptRun(c, null); + DhInverseSolver d = (DhInverseSolver) ScriptingEngine.inlineFileScriptRun(getDb(),c, null); device.setInverseSolver(d); } catch (Exception ex) { MobileBaseCadManager.get(base).getUi().highlightException(c, ex); @@ -114,7 +128,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event){ try { com.neuronrobotics.sdk.common.Log.error("Walking Gait Script changed, updating " + device.getScriptingName()); - defaultDriveEngine = (IDriveEngine) ScriptingEngine.inlineFileScriptRun(c, null); + defaultDriveEngine = (IDriveEngine) ScriptingEngine.inlineFileScriptRun(getDb(),c, null); device.setWalkingDriveEngine(defaultDriveEngine); } catch (Exception ex) { MobileBaseCadManager.get(base).getUi().highlightException(c, ex); @@ -123,7 +137,7 @@ public void onFileChange(File fileThatChanged, WatchEvent event){ }); try { - defaultDriveEngine = (IDriveEngine) ScriptingEngine.inlineFileScriptRun(c, null); + defaultDriveEngine = (IDriveEngine) ScriptingEngine.inlineFileScriptRun(getDb(),c, null); device.setWalkingDriveEngine(defaultDriveEngine); } catch (Exception ex) { MobileBaseCadManager.get(base).getUi().highlightException(c, ex); @@ -170,6 +184,26 @@ public MobileBase getBase() { public void setBase(MobileBase base) { this.base = base; + setDb(CSGDatabase.getInstance()); + try { + String[] self = base.getGitSelfSource(); + File selfFile =ScriptingEngine.fileFromGit(self); + File parent = selfFile.getParentFile(); + File database = new File(parent.getAbsolutePath()+DownloadManager.delim()+"csgDatabase.json"); + setDb(new CSGDatabaseInstance(database)); + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + Log.error(e); + } catch (TransportException e) { + // TODO Auto-generated catch block + Log.error(e); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + Log.error(e); + } catch (IOException e) { + // TODO Auto-generated catch block + Log.error(e); + } } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java index 9b0e5870..40578f60 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/RobotHelper.java @@ -10,6 +10,9 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; import com.neuronrobotics.bowlerstudio.creature.MobileBaseLoader; import com.neuronrobotics.sdk.addons.kinematics.DHLink; @@ -21,6 +24,27 @@ public class RobotHelper implements IScriptingLanguage { @Override public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) { + return fileToRobot(code); + } + public static MobileBase fileToRobot(String url,String file) { + try { + return fileToRobot(ScriptingEngine.fileFromGit(url, file)) ; + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TransportException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + public static MobileBase fileToRobot(File code) { byte[] bytes; try { bytes = Files.readAllBytes(code.toPath()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 2f02a9b4..5c97983e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -487,16 +487,7 @@ public static void removeOnCommitEventListeners(String url, Runnable event) { } } - /** - * This interface is for adding additional language support. - * - * @param code file content of the code to be executed - * @param args the incoming arguments as a list of objects - * @return the objects returned form the code that ran - */ - public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception{ - return inlineScriptRun(null, code, args, shellTypeStorage); - } + /** * This interface is for adding additional language support. * @@ -509,26 +500,10 @@ public static Object inlineScriptRun(CSGDatabaseInstance instance,File code, Arr filesRun.put(code.getName(), code); // com.neuronrobotics.sdk.common.Log.error("Loading "+code.getAbsolutePath()); } - CSGDatabaseInstance prevDB = instance; - if(prevDB==null) - try { - if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { - File p = code.getParentFile(); - for (String s : p.list()) { - if (s.toLowerCase().contentEquals("csgdatabase.json")) { - prevDB = (new CSGDatabaseInstance( - new File(p.getAbsoluteFile() + DownloadManager.delim() + s))); - } - } - } - } catch (Exception e) { - Log.error(e); - } - if(prevDB==null) - prevDB=CSGDatabase.getInstance(); + IScriptingLanguage iScriptingLanguage = langauges.get(shellTypeStorage); if (iScriptingLanguage != null) { - Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(prevDB,code, args); + Object inlineScriptRun = iScriptingLanguage.inlineScriptRun(instance,code, args); return inlineScriptRun; } return null; @@ -548,19 +523,7 @@ public static Object inlineScriptStringRun(CSGDatabaseInstance instance, String } return null; } - /** - * This interface is for adding additional language support. - * - * @param line the text content of the code to be executed - * @param args the incoming arguments as a list of objects - * @return the objects returned form the code that ran - */ - @Deprecated - public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) - throws Exception { - return inlineScriptStringRun(CSGDatabase.getInstance(),line,args,shellTypeStorage); - } public static void addScriptingLanguage(IScriptingLanguage lang) { langauges.put(lang.getShellType(), lang); @@ -1185,34 +1148,92 @@ private static String[] codeFromGistID(String id, String FileName) throws Except return null; } - public static Object inlineFileScriptRun(File f, ArrayList args) throws Exception { - return inlineScriptRun(f, args, getShellType(f.getName())); - } public static Object inlineFileScriptRun(CSGDatabaseInstance instance,File f, ArrayList args) throws Exception { return inlineScriptRun(instance,f, args, getShellType(f.getName())); } - - public static Object inlineGistScriptRun(String gistID, String Filename, ArrayList args) throws Exception { + public static Object inlineGistScriptRun(CSGDatabaseInstance db,String gistID, String Filename, ArrayList args) throws Exception { String[] gistData = codeFromGistID(gistID, Filename); - return inlineScriptRun(new File(gistData[2]), args, getShellType(gistData[1])); - } - @Deprecated - public static Object gitScriptRun(String gitURL, String Filename) throws Exception { - return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); + return inlineScriptRun(db,new File(gistData[2]), args, getShellType(gistData[1])); } + + +// @Deprecated +// public static Object inlineGistScriptRun(String gistID, String Filename, ArrayList args) throws Exception { +// String[] gistData = codeFromGistID(gistID, Filename); +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// return inlineScriptRun(CSGDatabase.getInstance(),new File(gistData[2]), args, getShellType(gistData[1])); +// } +// @Deprecated +// public static Object inlineFileScriptRun(File f, ArrayList args) throws Exception { +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// return inlineScriptRun(CSGDatabase.getInstance(),f, args, getShellType(f.getName())); +// } + +// @Deprecated +// public static Object gitScriptRun(String gitURL, String Filename) throws Exception { +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// +// return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); +// } +// /** +// * This interface is for adding additional language support. +// * +// * @param code file content of the code to be executed +// * @param args the incoming arguments as a list of objects +// * @return the objects returned form the code that ran +// */ +// @Deprecated +// public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception{ +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// CSGDatabaseInstance prevDB = CSGDatabase.getInstance(); +// try { +// if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { +// File p = code.getParentFile(); +// for (String s : p.list()) { +// if (s.toLowerCase().contentEquals("csgdatabase.json")) { +// prevDB = (new CSGDatabaseInstance( +// new File(p.getAbsoluteFile() + DownloadManager.delim() + s))); +// } +// } +// } +// } catch (Exception e) { +// Log.error(e); +// } +// return inlineScriptRun(prevDB, code, args, shellTypeStorage); +// } +// /** +// * This interface is for adding additional language support. +// * +// * @param line the text content of the code to be executed +// * @param args the incoming arguments as a list of objects +// * @return the objects returned form the code that ran +// */ +// @Deprecated +// public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) +// throws Exception { +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// return inlineScriptStringRun(CSGDatabase.getInstance(),line,args,shellTypeStorage); +// } +// @Deprecated +// public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { +// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); +// return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); +// } + + public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename) throws Exception { return gitScriptRun(db,gitURL, Filename, null); } - @Deprecated - public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { - return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); - } + public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename, ArrayList args) throws Exception { return inlineScriptRun(db,fileFromGit(gitURL, Filename), args, getShellType(Filename)); } - + public static File fileFromGit(String[] self) + throws InvalidRemoteException, TransportException, GitAPIException, IOException { + return fileFromGit(self[0], null, self[1]); + } public static File fileFromGit(String remoteURI, String fileInRepo) throws InvalidRemoteException, TransportException, GitAPIException, IOException { return fileFromGit(remoteURI, null, fileInRepo); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java index 9b591be8..09978e5b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/sequence/TimeSequence.java @@ -16,6 +16,9 @@ import com.neuronrobotics.sdk.common.DeviceManager; import com.neuronrobotics.sdk.util.ThreadUtil; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; + import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; @@ -91,7 +94,7 @@ public void execute(String content) throws Exception { public void runSequence() throws Exception { com.neuronrobotics.sdk.common.Log.error("Initialize Sequence"); - ScriptingEngine.gitScriptRun(getUrl(), getFile()); + ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(),getUrl(), getFile()); HashMap devices = getDevices(); long start = System.currentTimeMillis(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 25cea472..06ff44c3 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -182,7 +182,7 @@ public static void flatten(ArrayList flat, Object o) { // } public static CSG get(CSGDatabaseInstance instance,String type, String id) throws Exception { if (isGitURL(type)) { - Object o = ScriptingEngine.gitScriptRun(type, id); + Object o = ScriptingEngine.gitScriptRun(instance,type, id); ArrayList flat = new ArrayList(); Vitamins.flatten(flat, o); return CSG.unionAll(flat); diff --git a/test/java/src/junit/bowler/ArduinoLoaderTest.java b/test/java/src/junit/bowler/ArduinoLoaderTest.java index de813d2e..7484f0c4 100644 --- a/test/java/src/junit/bowler/ArduinoLoaderTest.java +++ b/test/java/src/junit/bowler/ArduinoLoaderTest.java @@ -13,6 +13,8 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import gnu.io.NRSerialPort; public class ArduinoLoaderTest { @@ -32,7 +34,7 @@ public void test() throws Exception { ArrayList params = new ArrayList<>(); params.add(board); params.add(portname); - ScriptingEngine.gitScriptRun("https://github.com/madhephaestus/Blink.git", "Blink.ino", params); + ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(),"https://github.com/madhephaestus/Blink.git", "Blink.ino", params); } } diff --git a/test/java/src/junit/bowler/BlenderLoadingTest.java b/test/java/src/junit/bowler/BlenderLoadingTest.java index 18fc1659..0d3c2e5b 100644 --- a/test/java/src/junit/bowler/BlenderLoadingTest.java +++ b/test/java/src/junit/bowler/BlenderLoadingTest.java @@ -15,7 +15,7 @@ public class BlenderLoadingTest { @Test public void test() throws Exception { - CSG loaded =(CSG)ScriptingEngine.gitScriptRun( + CSG loaded =(CSG)ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(), "https://github.com/madhephaestus/TestRepo.git", "TestRepo4.blend"); if(loaded.getPolygons().size()!=12) diff --git a/test/java/src/junit/bowler/SequenceTest.java b/test/java/src/junit/bowler/SequenceTest.java index 518f0897..5c1944b9 100644 --- a/test/java/src/junit/bowler/SequenceTest.java +++ b/test/java/src/junit/bowler/SequenceTest.java @@ -9,12 +9,14 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; + public class SequenceTest { @Test public void test() throws Exception { try { - ScriptingEngine.gitScriptRun("https://github.com/madhephaestus/sequencetest.git", "test.sequence"); + ScriptingEngine.gitScriptRun(CSGDatabase.getInstance(),"https://github.com/madhephaestus/sequencetest.git", "test.sequence"); }catch(Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); From 6c0f31a2436f8a9a06607dab5ccf851f54998e50 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 11:20:53 -0400 Subject: [PATCH 601/635] unblock the scripting engine depricated api --- .../scripting/ScriptingEngine.java | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java index 5c97983e..680067f1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingEngine.java @@ -1159,68 +1159,67 @@ public static Object inlineGistScriptRun(CSGDatabaseInstance db,String gistID, S } -// @Deprecated -// public static Object inlineGistScriptRun(String gistID, String Filename, ArrayList args) throws Exception { -// String[] gistData = codeFromGistID(gistID, Filename); -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// return inlineScriptRun(CSGDatabase.getInstance(),new File(gistData[2]), args, getShellType(gistData[1])); -// } -// @Deprecated -// public static Object inlineFileScriptRun(File f, ArrayList args) throws Exception { -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// return inlineScriptRun(CSGDatabase.getInstance(),f, args, getShellType(f.getName())); -// } - -// @Deprecated -// public static Object gitScriptRun(String gitURL, String Filename) throws Exception { -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// -// return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); -// } -// /** -// * This interface is for adding additional language support. -// * -// * @param code file content of the code to be executed -// * @param args the incoming arguments as a list of objects -// * @return the objects returned form the code that ran -// */ -// @Deprecated -// public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception{ -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// CSGDatabaseInstance prevDB = CSGDatabase.getInstance(); -// try { -// if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { -// File p = code.getParentFile(); -// for (String s : p.list()) { -// if (s.toLowerCase().contentEquals("csgdatabase.json")) { -// prevDB = (new CSGDatabaseInstance( -// new File(p.getAbsoluteFile() + DownloadManager.delim() + s))); -// } -// } -// } -// } catch (Exception e) { -// Log.error(e); -// } -// return inlineScriptRun(prevDB, code, args, shellTypeStorage); -// } -// /** -// * This interface is for adding additional language support. -// * -// * @param line the text content of the code to be executed -// * @param args the incoming arguments as a list of objects -// * @return the objects returned form the code that ran -// */ -// @Deprecated -// public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) -// throws Exception { -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// return inlineScriptStringRun(CSGDatabase.getInstance(),line,args,shellTypeStorage); -// } -// @Deprecated -// public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { -// Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); -// return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); -// } + @Deprecated + public static Object inlineGistScriptRun(String gistID, String Filename, ArrayList args) throws Exception { + String[] gistData = codeFromGistID(gistID, Filename); + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + return inlineScriptRun(CSGDatabase.getInstance(),new File(gistData[2]), args, getShellType(gistData[1])); + } + @Deprecated + public static Object inlineFileScriptRun(File f, ArrayList args) throws Exception { + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + return inlineScriptRun(CSGDatabase.getInstance(),f, args, getShellType(f.getName())); + } + @Deprecated + public static Object gitScriptRun(String gitURL, String Filename) throws Exception { + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + + return gitScriptRun(CSGDatabase.getInstance(),gitURL, Filename, null); + } + /** + * This interface is for adding additional language support. + * + * @param code file content of the code to be executed + * @param args the incoming arguments as a list of objects + * @return the objects returned form the code that ran + */ + @Deprecated + public static Object inlineScriptRun(File code, ArrayList args, String shellTypeStorage) throws Exception{ + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + CSGDatabaseInstance prevDB = CSGDatabase.getInstance(); + try { + if (!code.getName().toLowerCase().contentEquals("csgdatabase.json")) { + File p = code.getParentFile(); + for (String s : p.list()) { + if (s.toLowerCase().contentEquals("csgdatabase.json")) { + prevDB = (new CSGDatabaseInstance( + new File(p.getAbsoluteFile() + DownloadManager.delim() + s))); + } + } + } + } catch (Exception e) { + Log.error(e); + } + return inlineScriptRun(prevDB, code, args, shellTypeStorage); + } + /** + * This interface is for adding additional language support. + * + * @param line the text content of the code to be executed + * @param args the incoming arguments as a list of objects + * @return the objects returned form the code that ran + */ + @Deprecated + public static Object inlineScriptStringRun(String line, ArrayList args, String shellTypeStorage) + throws Exception { + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + return inlineScriptStringRun(CSGDatabase.getInstance(),line,args,shellTypeStorage); + } + @Deprecated + public static Object gitScriptRun(String gitURL, String Filename, ArrayList args) throws Exception { + Log.error(new Exception("Depricated script mode, use CSGDatabaseInstance")); + return gitScriptRun(CSGDatabase.getInstance(), gitURL, Filename, args); + } public static Object gitScriptRun(CSGDatabaseInstance db,String gitURL, String Filename) throws Exception { From 118de13c91237d74b91d69d899892c157d0aec48 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 11:21:29 -0400 Subject: [PATCH 602/635] Add pre-processing to groovy scripts to ensure the new API is used, even on legacy scripts --- .../bowlerstudio/scripting/GroovyHelper.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 9e6c0639..42b9cc85 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -35,8 +35,6 @@ private Object inline(String code, ArrayList args, CSGDatabaseInstance d binding.setVariable("args", args); binding.setVariable("csgdb", db2); GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); - // com.neuronrobotics.sdk.common.Log.error(code + "\n\nStart\n\n"); - Script script; if(!code.contains("csgdb")) { code=code.replace("StringParameter(", "StringParameter(csgdb,"); code=code.replace("LengthParameter(", "LengthParameter(csgdb,"); @@ -44,10 +42,15 @@ private Object inline(String code, ArrayList args, CSGDatabaseInstance d code=code.replace("import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase", ""); code=code.replace("CSGDatabase", "csgdb"); + + code=code.replace("inlineGistScriptRun(", "inlineGistScriptRun(csgdb,"); + code=code.replace("inlineFileScriptRun(", "inlineFileScriptRun(csgdb,"); + code=code.replace("inlineScriptRun(", "inlineScriptRun(csgdb,"); + code=code.replace("inlineScriptStringRun(", "inlineScriptStringRun(csgdb,"); + code=code.replace("gitScriptRun(", "gitScriptRun(csgdb,"); } - script = shell.parse(code); - + Script script = shell.parse(code); return script.run(); } From 30823378e13baf9104fcda878236f8498d272361 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 11:28:54 -0400 Subject: [PATCH 603/635] add file caching --- .../scripting/cadoodle/CaDoodleFile.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index debd6a78..e1d6e718 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -153,16 +153,16 @@ private List getCachedCSGs(CaDoodleOperation op) { } private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { -// int opIndex = opToIndex(op); -// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); -// if(cacheFile.exists()) -// cacheFile.delete(); -// try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { -// oos.writeObject(cachedCopy); -// }catch(Exception ex) { -// Log.error(ex); -// throw new RuntimeException(ex); -// } + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + if(cacheFile.exists()) + cacheFile.delete(); + try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { + oos.writeObject(cachedCopy); + }catch(Exception ex) { + Log.error(ex); + throw new RuntimeException(ex); + } cache.put(op, cachedCopy); } private void clearCache(CaDoodleOperation key) { From 34dc6790f2840190843d51631c570c9845ceaf0a Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 11:56:57 -0400 Subject: [PATCH 604/635] build 123d test --- test/java/src/junit/bowler/Build123dTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/java/src/junit/bowler/Build123dTest.java diff --git a/test/java/src/junit/bowler/Build123dTest.java b/test/java/src/junit/bowler/Build123dTest.java new file mode 100644 index 00000000..ac794358 --- /dev/null +++ b/test/java/src/junit/bowler/Build123dTest.java @@ -0,0 +1,37 @@ +package junit.bowler; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; + +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; +import org.junit.Test; + +import com.neuronrobotics.bowlerstudio.scripting.Build123dLoader; +import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; +import com.neuronrobotics.sdk.common.Log; + +public class Build123dTest { + + @Test + public void test() throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + Build123dLoader loader = new Build123dLoader(); + Log.enableDebugPrint(); + // create test file + File testblend = new File("build123dTest.py"); + if(!testblend.exists()) + loader.getDefaultContents(testblend); + HashMap params = new HashMap(); + Build123dLoader.toSTLFile(testblend, new File("build123dTest.py.stl"),params); + + File gears = ScriptingEngine.fileFromGit("https://github.com/GarryBGoode/gggears.git", "examples/examples.py"); + Build123dLoader.toSTLFile(gears, new File("gears.stl"),params); + + + } + +} From 39db9bed164835e09e0c734ec93784ec3fe4cb23 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 12:00:00 -0400 Subject: [PATCH 605/635] find replace for CaDoodleVitamin --- .../com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 42b9cc85..ff4ccabc 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -36,6 +36,8 @@ private Object inline(String code, ArrayList args, CSGDatabaseInstance d binding.setVariable("csgdb", db2); GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); if(!code.contains("csgdb")) { + //CaDoodleVitamin. + code=code.replace("CaDoodleVitamin.", "new CaDoodleVitamin(csgdb)"); code=code.replace("StringParameter(", "StringParameter(csgdb,"); code=code.replace("LengthParameter(", "LengthParameter(csgdb,"); code=code.replace("setParameter(", "setParameter(csgdb,"); From 7ccc32c101d571a183150ecb9bbdc6308783d2ff Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 12:11:11 -0400 Subject: [PATCH 606/635] Add error print --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index a160435b..73959e7b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -115,6 +115,7 @@ public List process(List incoming) { back.addAll(collect); } catch (Exception e) { //CSGDatabase.setInstance(instance); + Log.error(e); throw new RuntimeException(e); } return back; From 57acbce55a887db646ea0645ff579de3dd4d2187 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 12:18:38 -0400 Subject: [PATCH 607/635] Correcting the Groovy helper to include the CaDoodleVitamin API update --- .../com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java | 2 +- .../bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index ff4ccabc..84e7b9ad 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -37,7 +37,7 @@ private Object inline(String code, ArrayList args, CSGDatabaseInstance d GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); if(!code.contains("csgdb")) { //CaDoodleVitamin. - code=code.replace("CaDoodleVitamin.", "new CaDoodleVitamin(csgdb)"); + code=code.replace("CaDoodleVitamin.", "new CaDoodleVitamin(csgdb)."); code=code.replace("StringParameter(", "StringParameter(csgdb,"); code=code.replace("LengthParameter(", "LengthParameter(csgdb,"); code=code.replace("setParameter(", "setParameter(csgdb,"); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java index bb54ec10..1e6194ff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleVitamin.java @@ -120,7 +120,7 @@ public CSG regenerate(CSG previous) { } }); //back.getStorage().set("PreviousName", name); - back.setIsAlwaysShow(true); + //back.setIsAlwaysShow(true); return back; } catch (Exception e) { // Auto-generated catch block From f6df86f766c00365fa18097f082a4c7230d7c235 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 13:03:40 -0400 Subject: [PATCH 608/635] use the cache judiciously, keep the CSG in cold storage untill needed. --- .../scripting/cadoodle/CaDoodleFile.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e1d6e718..1a16e88b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -140,21 +140,31 @@ private int opToIndex(CaDoodleOperation op) { throw new IndexOutOfBoundsException(); } private List getCachedCSGs(CaDoodleOperation op) { -// int opIndex = opToIndex(op); -// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); -// try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { -// return (List) ois.readObject(); -// } catch (Exception ex) { -// Log.error(ex); -// } -// return null; + if(cache.get(op)==null) { + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + Log.debug("Loading Cached Objects from file: "+cacheFile.getAbsolutePath()); + try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { + if(getFreeMemory()>50) { + com.neuronrobotics.sdk.common.Log.error("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + cache.clear(); + }else { + com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); + } + cache.put( op,(List) ois.readObject()); + + } catch (Exception ex) { + Log.error(ex); + } + } return cache.get(op); } private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { int opIndex = opToIndex(op); File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + if(cacheFile.exists()) cacheFile.delete(); try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { @@ -163,17 +173,17 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { Log.error(ex); throw new RuntimeException(ex); } - cache.put(op, cachedCopy); +// cache.put(op, cachedCopy); } private void clearCache(CaDoodleOperation key) { -// int opIndex = opToIndex(key); -// File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); -// if(cacheFile.exists()) -// cacheFile.delete(); + int opIndex = opToIndex(key); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + if(cacheFile.exists()) + cacheFile.delete(); - List back = cache.remove(key); - if (back != null) - back.clear(); +// List back = cache.remove(key); +// if (back != null) +// back.clear(); } @@ -687,8 +697,7 @@ private void storeResultInCache(CaDoodleOperation op, List process) { // cachedCopy.add(c); } placeCSGsInCache(op, cachedCopy); - if(getFreeMemory()>50) - com.neuronrobotics.sdk.common.Log.debug("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + } From 767e13217be4f7e18552aa6a5f6811e17ff141b5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 14:02:14 -0400 Subject: [PATCH 609/635] lad from cache if the cache is availible on initialization --- .../scripting/cadoodle/CaDoodleFile.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1a16e88b..bc75215d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -139,12 +139,18 @@ private int opToIndex(CaDoodleOperation op) { } throw new IndexOutOfBoundsException(); } + private boolean inCache(CaDoodleOperation op) { + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); + return cacheFile.exists(); + } private List getCachedCSGs(CaDoodleOperation op) { if(cache.get(op)==null) { int opIndex = opToIndex(op); File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); Log.debug("Loading Cached Objects from file: "+cacheFile.getAbsolutePath()); + //Log.error(new Exception()); try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { if(getFreeMemory()>50) { com.neuronrobotics.sdk.common.Log.error("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); @@ -240,14 +246,15 @@ public void initialize() { if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); - try { - process(op); - } catch (Throwable t) { - com.neuronrobotics.sdk.common.Log.error(t); - indexStarting = i + 1; - break; - // opperations.remove(op); - } + if(!inCache(op)) + try { + process(op); + } catch (Throwable t) { + com.neuronrobotics.sdk.common.Log.error(t); + indexStarting = i + 1; + break; + // opperations.remove(op); + } } setCurrentIndex(indexStarting); updateCurrentFromCache(); From 9c8d0a3d940d68f7e3662230317d99217f0dbac1 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 15:24:23 -0400 Subject: [PATCH 610/635] add the objects loaded to the cache on saving --- .../scripting/cadoodle/CaDoodleFile.java | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index bc75215d..f54f5064 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -152,12 +152,7 @@ private List getCachedCSGs(CaDoodleOperation op) { Log.debug("Loading Cached Objects from file: "+cacheFile.getAbsolutePath()); //Log.error(new Exception()); try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { - if(getFreeMemory()>50) { - com.neuronrobotics.sdk.common.Log.error("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); - cache.clear(); - }else { - com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); - } + memoryCheck(); cache.put( op,(List) ois.readObject()); } catch (Exception ex) { @@ -166,6 +161,15 @@ private List getCachedCSGs(CaDoodleOperation op) { } return cache.get(op); } + private void memoryCheck() { + if(getFreeMemory()>50) { + com.neuronrobotics.sdk.common.Log.error("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + cache.clear(); + System.gc(); + }else { + //com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); + } + } private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { int opIndex = opToIndex(op); @@ -175,11 +179,30 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { cacheFile.delete(); try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { oos.writeObject(cachedCopy); +// ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile)); +// List readback = (List) ois.readObject(); +// ois.close(); +// for(int i=0;i back = cache.remove(key); -// if (back != null) -// back.clear(); + List back = cache.remove(key); + if (back != null) + back.clear(); } @@ -246,7 +269,7 @@ public void initialize() { if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); - if(!inCache(op)) + //if(!inCache(op)) try { process(op); } catch (Throwable t) { From d5f448ef63cde1c03495f6d6ca319efd0cea1950 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 15:24:32 -0400 Subject: [PATCH 611/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index a5e12b5d..e454dcff 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit a5e12b5d820852473b02ba24388f4c685a655313 +Subproject commit e454dcfff849a32472fbda759626762ae92b49f5 From eb997a7b0b47ccf80ed35e18b5501243f4cd835b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 16:08:19 -0400 Subject: [PATCH 612/635] remember to clear the cache file when regenerating as well as the image --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f54f5064..e912f5fa 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -383,6 +383,7 @@ public void run() { getSaveUpdate().renderSplashFrame(percent, "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); + clearCache(op); try { op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); From b75b0add7414b5b27603c75da19c39712da6ba3b Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 16:12:07 -0400 Subject: [PATCH 613/635] disabled the auto-mem caching of the operations --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index e912f5fa..193a4553 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -202,7 +202,7 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { throw new RuntimeException(ex); } memoryCheck(); - cache.put(op, cachedCopy); + //cache.put(op, cachedCopy); } private void clearCache(CaDoodleOperation key) { int opIndex = opToIndex(key); From b1219e223c92d0e091fdf3b4753cfb3ec5c74299 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 16:18:21 -0400 Subject: [PATCH 614/635] cache ought to be cleared once the in-memenory copy becomes stale. --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 193a4553..9855b0f1 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -202,7 +202,10 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { throw new RuntimeException(ex); } memoryCheck(); - //cache.put(op, cachedCopy); + // clear the stale cache value + List back = cache.remove(op); + if (back != null) + back.clear(); } private void clearCache(CaDoodleOperation key) { int opIndex = opToIndex(key); From 5bc7a219caf86996669d2514e0d7409ade63b8da Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 16:39:17 -0400 Subject: [PATCH 615/635] update the Vitamins.get API as well --- JCSG | 2 +- .../bowlerstudio/creature/MobileBaseCadManager.java | 1 + .../neuronrobotics/bowlerstudio/scripting/GroovyHelper.java | 4 +++- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/JCSG b/JCSG index e454dcff..be36eba1 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit e454dcfff849a32472fbda759626762ae92b49f5 +Subproject commit be36eba1b4e6dae5472ae7c2c809c98008e73c92 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java index 899051fb..6a8a8b41 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseCadManager.java @@ -1374,6 +1374,7 @@ public ArrayList generateCad(DHParameterKinematics dh) { try { newcad = generatorToUse.generateCad(dh, i); } catch (Throwable t) { + Log.error(t); getUi().highlightException(null, t); } if (newcad == null) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java index 84e7b9ad..ca546593 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/GroovyHelper.java @@ -36,7 +36,9 @@ private Object inline(String code, ArrayList args, CSGDatabaseInstance d binding.setVariable("csgdb", db2); GroovyShell shell = new GroovyShell(GroovyHelper.class.getClassLoader(), binding, cc); if(!code.contains("csgdb")) { - //CaDoodleVitamin. + //Vitamins.get( + code=code.replace("Vitamins.get(", "Vitamins.get(csgdb,"); + code=code.replace("CaDoodleVitamin.", "new CaDoodleVitamin(csgdb)."); code=code.replace("StringParameter(", "StringParameter(csgdb,"); code=code.replace("LengthParameter(", "LengthParameter(csgdb,"); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 9855b0f1..f0e24110 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -206,6 +206,7 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { List back = cache.remove(op); if (back != null) back.clear(); + cache.put(op, cachedCopy); } private void clearCache(CaDoodleOperation key) { int opIndex = opToIndex(key); @@ -386,7 +387,7 @@ public void run() { getSaveUpdate().renderSplashFrame(percent, "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); - clearCache(op); + //clearCache(op); try { op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); From 8f13af92ccce1773ceee5e9de98fbd588f09e209 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 16:57:34 -0400 Subject: [PATCH 616/635] clearing memory on low memory system --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index f0e24110..141a31c9 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -162,8 +162,8 @@ private List getCachedCSGs(CaDoodleOperation op) { return cache.get(op); } private void memoryCheck() { - if(getFreeMemory()>50) { - com.neuronrobotics.sdk.common.Log.error("\n\nUpdated Memory use: " + getFreeMemory() + "\n\n"); + if(getFreeMemory()>75) { + com.neuronrobotics.sdk.common.Log.error("\n\nClearing Memory use: " + getFreeMemory() + "\n\n"); cache.clear(); System.gc(); }else { From 4de0c86eaa8d073c2ea471f83c6c6256632a39ec Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 17:35:30 -0400 Subject: [PATCH 617/635] Added missing API to catch the precompiler edits to the get methods --- .../neuronrobotics/bowlerstudio/vitamins/Vitamins.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index 06ff44c3..e0d5506b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -86,12 +86,18 @@ public static void clear() { databaseSet.clear(); fileLastLoaded.clear(); } - public static CSG get(File resource) { - return get(resource, false); + return get(CSGDatabase.getInstance(),resource, false); } public static CSG get(File resource, boolean forceRefresh) { + return get(CSGDatabase.getInstance(), resource, forceRefresh); + } + public static CSG get(CSGDatabaseInstance db,File resource) { + return get(db,resource, false); + } + + public static CSG get(CSGDatabaseInstance db,File resource, boolean forceRefresh) { if (fileLastLoaded.get(resource.getAbsolutePath()) == null || forceRefresh) { // forces the first time the files is accessed by the application tou pull an From 059a7a84fbb6e78e9137360c0b4a55d0011c19ef Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 21:40:54 -0400 Subject: [PATCH 618/635] use memory untill the memcheck fails, then clear the cache to disk in a slow operation instead of slowing down loading. --- .../scripting/cadoodle/CaDoodleFile.java | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 141a31c9..685a0f4e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -164,6 +164,28 @@ private List getCachedCSGs(CaDoodleOperation op) { private void memoryCheck() { if(getFreeMemory()>75) { com.neuronrobotics.sdk.common.Log.error("\n\nClearing Memory use: " + getFreeMemory() + "\n\n"); + Set keySet = cache.keySet(); + int index=0; + for (CaDoodleOperation op : keySet) { + List cachedCopy = cache.get(op); + getSaveUpdate().renderSplashFrame((int) (((double) index) / ((double) keySet.size()) * 100), + "Clearing Ram to Disk"); + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); + if (!isInitialized()) + if (cacheFile.exists()) + return; + if (cacheFile.exists()) + cacheFile.delete(); + try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { + oos.writeObject(cachedCopy); + Log.debug("Saved " + cacheFile.getAbsolutePath()); + } catch (Exception ex) { + Log.error(ex); + throw new RuntimeException(ex); + } + index++; + } cache.clear(); System.gc(); }else { @@ -172,35 +194,6 @@ private void memoryCheck() { } private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { - int opIndex = opToIndex(op); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - - if(cacheFile.exists()) - cacheFile.delete(); - try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { - oos.writeObject(cachedCopy); -// ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile)); -// List readback = (List) ois.readObject(); -// ois.close(); -// for(int i=0;i back = cache.remove(op); @@ -727,8 +720,13 @@ private void storeResultInCache(CaDoodleOperation op, List process) { throw new RuntimeException("There can not be 2 objects with the same name after an " + op.getType() + " opperation! " + c.getName()); names.add(c.getName()); - cachedCopy.add(cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(getCsgDBinstance(),c).setName(c.getName()) - .setRegenerate(c.getRegenerate())); + CSG cachedVer = cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(getCsgDBinstance(),c).setName(c.getName()) + .setRegenerate(c.getRegenerate()); + if(cachedVer.isHole() != c.isHole()|| + cachedVer.isHide() != c.isHide() ) { + throw new RuntimeException("Lost properties"); + } + cachedCopy.add(cachedVer); // cachedCopy.add(c); } placeCSGsInCache(op, cachedCopy); From 123cc3394d3a24121c5cb8763fc32c08e9416eec Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 21:41:03 -0400 Subject: [PATCH 619/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index be36eba1..2aaf159c 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit be36eba1b4e6dae5472ae7c2c809c98008e73c92 +Subproject commit 2aaf159cbd0f1fa41786c46f72680a52b6086db8 From 93027ef5706fcc4ce0f30092979e63dfe2030ed4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sun, 5 Oct 2025 22:55:17 -0400 Subject: [PATCH 620/635] Add the source to the regeneratio event --- .../scripting/cadoodle/CaDoodleFile.java | 13 +++++++------ .../scripting/cadoodle/ICaDoodleStateUpdate.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 685a0f4e..1af6c20f 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -341,7 +341,7 @@ public Thread regenerateFrom(CaDoodleOperation source) { com.neuronrobotics.sdk.common.Log.error(new Exception("Operation Running, bailing")); return null; } - fireRegenerateStart(); + fireRegenerateStart(source); int endIndex = getCurrentIndex(); double size = getOpperations().size(); if (endIndex != size) { @@ -424,7 +424,9 @@ public Thread regenerateCurrent() { t.start(); return t; } - fireRegenerateStart(); + CaDoodleOperation op = getCurrentOpperation(); + + fireRegenerateStart(op); Thread t = null; CaDoodleFile cf = this; t = new Thread() { @@ -435,7 +437,6 @@ public void run() { this.setName("regenerateCurrent Thread"); - CaDoodleOperation op = getCurrentOpperation(); TickToc.tic("Start regenerate"); op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); @@ -512,7 +513,7 @@ public void run() { com.neuronrobotics.sdk.common.Log.debug("Adding Operation "+op); if (getCurrentIndex() != getOpperations().size()) { try { - fireRegenerateStart(); + fireRegenerateStart(op); setResult(pruneForward(op)); } catch (Exception e) { com.neuronrobotics.sdk.common.Log.error(e); @@ -949,11 +950,11 @@ private void fireRegenerateDone() { } } - private void fireRegenerateStart() { + private void fireRegenerateStart(CaDoodleOperation source) { for (ICaDoodleStateUpdate l : listeners) { try { - l.onRegenerateStart(); + l.onRegenerateStart(source); } catch (Throwable e) { com.neuronrobotics.sdk.common.Log.error(e); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java index dad1aebb..df56ab1b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/ICaDoodleStateUpdate.java @@ -12,7 +12,7 @@ public interface ICaDoodleStateUpdate { public void onInitializationDone(); public void onInitializationStart(); public void onRegenerateDone(); - public void onRegenerateStart(); + public void onRegenerateStart(CaDoodleOperation source); public void onWorkplaneChange(TransformNR newWP); public void onTimelineUpdate(int numberOfNew); } From f2b3254dbfe6cb54a2a0fac5b8cd3d01756f2558 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 6 Oct 2025 12:45:51 -0400 Subject: [PATCH 621/635] catch the exception on the roll-forward --- JCSG | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/JCSG b/JCSG index 2aaf159c..67f0b866 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 2aaf159cbd0f1fa41786c46f72680a52b6086db8 +Subproject commit 67f0b86615da299adb65f72b8fe374996a098cc0 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 1af6c20f..05462c1d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -812,10 +812,14 @@ public void moveToOpIndex(int newIndex) { boolean forward= ci Date: Mon, 6 Oct 2025 19:09:36 -0400 Subject: [PATCH 622/635] move the updates into the operation runner --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 05462c1d..912bce6c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -541,10 +541,10 @@ public void run() { if (getResult() == OperationResult.ABORT) { setCurrentState(getCurrentOpperation(), getCurrentState()); } + updateBoM(); + fireSaveSuggestion(); + fireRegenerateDone(); } - updateBoM(); - fireSaveSuggestion(); - fireRegenerateDone(); opperationRunner.remove(this); } }; From 48d8ff916883a929d472b636e4bd5cdbaa14f6d0 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 6 Oct 2025 20:03:32 -0400 Subject: [PATCH 623/635] no hole the text --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 67f0b866..4a7e8290 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 67f0b86615da299adb65f72b8fe374996a098cc0 +Subproject commit 4a7e829063f51707ede86b9042e41e59ac7a5413 From edaba5daa51bca4fe03ae23f755dbf0067a568ee Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 6 Oct 2025 20:50:03 -0400 Subject: [PATCH 624/635] removing depricated API --- java-bowler | 2 +- .../assets/ConfigurationDatabase.java | 3 +- .../creature/CadFileExporter.java | 3 +- .../creature/ControllerOption.java | 2 +- .../bowlerstudio/creature/LimbOption.java | 2 +- .../bowlerstudio/scripting/BlenderLoader.java | 38 +-- .../scripting/Build123dLoader.java | 2 +- .../bowlerstudio/scripting/FreecadLoader.java | 4 +- .../bowlerstudio/scripting/ObjLoader.java | 2 +- .../scripting/OpenSCADLoader.java | 2 +- .../bowlerstudio/scripting/StlLoader.java | 2 +- .../scripting/cadoodle/CaDoodleFile.java | 229 +++++++++--------- .../util/GeometrySimplification.java | 4 +- .../bowlerstudio/vitamins/Vitamins.java | 3 +- 14 files changed, 157 insertions(+), 141 deletions(-) diff --git a/java-bowler b/java-bowler index c802de44..25ef9486 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit c802de4418aa7ca8a2ba6e0138ead5fd0e22a705 +Subproject commit 25ef9486f40d44b503bacec67158883b3be2f86c diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index 3bca4e17..ede0289a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -23,6 +23,7 @@ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import java.nio.charset.*; import java.nio.file.Files; @@ -164,7 +165,7 @@ public static void getDatabase() { File loadFile = loadFile(); if(loadFile.exists()) try { - Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(CSGDatabase.getInstance(),loadFile, null); + Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(new CSGDatabaseInstance(new File("CSGdatabase.json")),loadFile, null); database = Collections.synchronizedMap((HashMap>) inlineFileScriptRun); } catch (Exception e) { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java index 4a4b0855..57d2ff6c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java @@ -16,6 +16,7 @@ import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.JavaFXInitializer; import eu.mihosoft.vrl.v3d.Transform; +import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance; import eu.mihosoft.vrl.v3d.svg.SVGExporter; import javafx.scene.transform.Affine; @@ -186,7 +187,7 @@ private File makeBlender(String nameBase,List current ) throws IOException File blend = new File(nameBase + ".blend"); com.neuronrobotics.sdk.common.Log.debug("Writing "+blend.getAbsolutePath()); for(CSG tmp:current) - BlenderLoader.toBlenderFile(tmp, blend); + BlenderLoader.toBlenderFile(null,tmp, blend); return blend; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java index 61cd2f9e..07f0358b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/ControllerOption.java @@ -83,7 +83,7 @@ public void build(CaDoodleFile f) { dir.mkdirs(); stlFile = new File(absolutePath + delim() + type + ".stl"); if ( stlFile.exists()) { - indicator = Vitamins.get(stlFile); + indicator = Vitamins.get(f.getCsgDBinstance(),stlFile); getIndicator().setColor(Color.WHITE); return; }else { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java index 67a1d21d..b6d17a31 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java @@ -122,7 +122,7 @@ public void build(CaDoodleFile f) throws IOException { File imageFile = new File(absolutePath + delim() + type + name + ".png"); File stlFile = new File(absolutePath + delim() + type + name + ".stl"); if (imageFile.exists() && stlFile.exists()) { - indicator = Vitamins.get(stlFile); + indicator = Vitamins.get(f.getCsgDBinstance(),stlFile); indicator=indicator.transformed(TransformFactory.nrToCSG(LimbRotationOffset)); indicator.setColor(Color.WHITE); image = new Image(imageFile.toURI().toString()); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java index bc569c8b..4d9f045d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/BlenderLoader.java @@ -24,8 +24,8 @@ public class BlenderLoader implements IScriptingLanguage { public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { File stl = File.createTempFile(code.getName(), ".stl"); stl.deleteOnExit(); - toSTLFile(code,stl); - CSG back = Vitamins.get(stl,true); + toSTLFile(db,code,stl); + CSG back = Vitamins.get(db,stl,true); back.setColor(Color.ORANGE); return back; } @@ -46,13 +46,13 @@ public ArrayList getFileExtenetion() { ext.add("blend"); return ext; } - public static void toBlenderFile(CSG stlIn,File blenderfile) throws IOException { + public static void toBlenderFile(CSGDatabaseInstance db,CSG stlIn,File blenderfile) throws IOException { File stl = getTmpSTL(stlIn); - toBlenderFile(stl, blenderfile); + toBlenderFile(db,stl, blenderfile); } - public static void toBlenderFile(File stl,File blenderfile) { + public static void toBlenderFile(CSGDatabaseInstance db,File stl,File blenderfile) { com.neuronrobotics.sdk.common.Log.error("Converting to Blender file before loading"); File stlIn; @@ -64,7 +64,7 @@ public static void toBlenderFile(File stl,File blenderfile) { return; } stlIn.deleteOnExit(); - scaleStl(stl,stlIn,0.001); + scaleStl(db,stl,stlIn,0.001); File dir = stlIn.getAbsoluteFile().getParentFile(); try { @@ -91,8 +91,8 @@ public static void toBlenderFile(File stl,File blenderfile) { return; } } - public static void scaleStl(File incoming, File outgoing, double scale) { - CSG back = Vitamins.get(incoming,true).scale(scale); + public static void scaleStl(CSGDatabaseInstance db,File incoming, File outgoing, double scale) { + CSG back = Vitamins.get(db,incoming,true).scale(scale); try { boolean manifold=CSG.isPreventNonManifoldTriangles(); CSG.setPreventNonManifoldTriangles(false); @@ -104,19 +104,19 @@ public static void scaleStl(File incoming, File outgoing, double scale) { com.neuronrobotics.sdk.common.Log.error(e); } } - public static CSG remesh(CSG incoming, double MMVoxel,CSGDatabaseInstance instance) throws Exception { + public static CSG remesh(CSGDatabaseInstance db,CSG incoming, double MMVoxel,CSGDatabaseInstance instance) throws Exception { File stl = DownloadManager.getTmpSTL(incoming); - remeshSTLFile(stl, MMVoxel); - CSG back = Vitamins.get(stl,true); + remeshSTLFile(db,stl, MMVoxel); + CSG back = Vitamins.get(db,stl,true); return back.syncProperties(instance,incoming).setName(incoming.getName()); } - public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { + public static void remeshSTLFile(CSGDatabaseInstance db,File stlout,double MMVoxel) throws Exception { File blend = File.createTempFile(stlout.getName(), ".blend"); blend.delete(); - toBlenderFile(stlout, blend); - remeshToSTLFile(blend, stlout, MMVoxel); + toBlenderFile(db,stlout, blend); + remeshToSTLFile(db,blend, stlout, MMVoxel); } - public static void remeshToSTLFile(File blenderfile,File stlout,double MMVoxel) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + public static void remeshToSTLFile(CSGDatabaseInstance db,File blenderfile,File stlout,double MMVoxel) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { File exe = getConfigExecutable("blender", null); File export = ScriptingEngine.fileFromGit( "https://github.com/CommonWealthRobotics/blender-bowler-cli.git", @@ -135,9 +135,9 @@ public static void remeshToSTLFile(File blenderfile,File stlout,double MMVoxel) args.add(""+(MMVoxel/1000.0)); args.add(stlout.getAbsolutePath()); legacySystemRun(null, stlout.getAbsoluteFile().getParentFile(), System.out, args); - scaleStl(stlout,stlout,1000.0); + scaleStl(db,stlout,stlout,1000.0); } - public static void toSTLFile(File blenderfile,File stlout) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { + public static void toSTLFile(CSGDatabaseInstance db,File blenderfile,File stlout) throws InvalidRemoteException, TransportException, GitAPIException, IOException, InterruptedException { File exe = getConfigExecutable("blender", null); File export = ScriptingEngine.fileFromGit( "https://github.com/CommonWealthRobotics/blender-bowler-cli.git", @@ -155,7 +155,7 @@ public static void toSTLFile(File blenderfile,File stlout) throws InvalidRemoteE args.add(blenderfile.getAbsolutePath()); args.add(stlout.getAbsolutePath()); legacySystemRun(null, stlout.getAbsoluteFile().getParentFile(), System.out, args); - scaleStl(stlout,stlout,1000.0); + scaleStl(db,stlout,stlout,1000.0); } @Override public void getDefaultContents(File source) { @@ -200,7 +200,7 @@ public static void main(String[] args) throws InvalidRemoteException, TransportE File testblend = new File("test.blend"); if(!testblend.exists()) loader.getDefaultContents(testblend); - loader.toSTLFile(testblend, new File("testBlender.stl")); + loader.toSTLFile(null,testblend, new File("testBlender.stl")); } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java index 2a3910ab..89db491b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/Build123dLoader.java @@ -35,7 +35,7 @@ public Object inlineScriptRun(CSGDatabaseInstance db,File code, ArrayList args) throws Exception { - CSG sllLoaded = Vitamins.get(code); + CSG sllLoaded = Vitamins.get(db,code); return sllLoaded; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java index 387215e8..e16948c2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/OpenSCADLoader.java @@ -33,7 +33,7 @@ public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstanc } toSTLFile(code,stl,params); - CSG back = Vitamins.get(stl,true); + CSG back = Vitamins.get(db,stl,true); back.setColor(Color.YELLOW); return back; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java index 6544a7f8..c2c3275a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/StlLoader.java @@ -12,7 +12,7 @@ public class StlLoader implements IScriptingLanguage { @Override public Object inlineScriptRun(eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance db,File code, ArrayList args) throws Exception { - CSG sllLoaded = Vitamins.get(code); + CSG sllLoaded = Vitamins.get(db,code); return sllLoaded; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 912bce6c..4a379721 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -47,7 +47,6 @@ import com.neuronrobotics.sdk.common.Log; import com.neuronrobotics.sdk.common.TickToc; - import eu.mihosoft.vrl.v3d.CSG; import eu.mihosoft.vrl.v3d.FileUtil; import eu.mihosoft.vrl.v3d.Polygon; @@ -74,7 +73,7 @@ public class CaDoodleFile { @Expose(serialize = true, deserialize = true) private TransformNR rulerLocation = new TransformNR(); @Expose(serialize = true, deserialize = true) - + // Non Serialised private variables private TransformNR workplane = new TransformNR(); private File self; @@ -85,8 +84,8 @@ public class CaDoodleFile { private static Type TT_CaDoodleFile = new TypeToken() { }.getType(); private static Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation().registerTypeAdapterFactory(new CaDoodleJsonOperationAdapterFactory()) - .create(); + .excludeFieldsWithoutExposeAnnotation() + .registerTypeAdapterFactory(new CaDoodleJsonOperationAdapterFactory()).create(); private final ArrayList listeners = new ArrayList(); private final ArrayList opperationRunner = new ArrayList(); private boolean regenerating; @@ -106,19 +105,21 @@ public void renderSplashFrame(int percent, String message) { }; private ICadoodleSaveStatusUpdate saveUpdate = null; private boolean timelineOpen = false; - private HashMap robots = new HashMap(); + private HashMap robots = new HashMap(); private CSGDatabaseInstance csgDBinstance; private File objectDir; - public ArrayList getMobileBases(){ + + public ArrayList getMobileBases() { ArrayList back = new ArrayList(); - for(MobileBaseBuilder b:robots.values()) { + for (MobileBaseBuilder b : robots.values()) { back.add(b.getMobileBase()); } return back; } + public void close() { - //new Exception("CaDoodle File Closed here").printStackTrace(); - for(CaDoodleOperation op:getOpperations()) { + // new Exception("CaDoodle File Closed here").printStackTrace(); + for (CaDoodleOperation op : getOpperations()) { op.setCaDoodleFile(null); } // for (CaDoodleOperation op : cache.keySet()) { @@ -130,42 +131,47 @@ public void close() { img = null; for (Thread t : opperationRunner) t.interrupt(); - + } + private int opToIndex(CaDoodleOperation op) { - for(int i=0;i getCachedCSGs(CaDoodleOperation op) { - - if(cache.get(op)==null) { - int opIndex = opToIndex(op); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - Log.debug("Loading Cached Objects from file: "+cacheFile.getAbsolutePath()); - //Log.error(new Exception()); - try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile))) { + + if (cache.get(op) == null && objectDir !=null) { + try { + int opIndex = opToIndex(op); + File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); + Log.debug("Loading Cached Objects from file: " + cacheFile.getAbsolutePath()); + // Log.error(new Exception()); + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile)); memoryCheck(); - cache.put( op,(List) ois.readObject()); - + cache.put(op, (List) ois.readObject()); + ois.close(); } catch (Exception ex) { Log.error(ex); } - } + } return cache.get(op); } + private void memoryCheck() { - if(getFreeMemory()>75) { + if (getFreeMemory() > 75) { com.neuronrobotics.sdk.common.Log.error("\n\nClearing Memory use: " + getFreeMemory() + "\n\n"); Set keySet = cache.keySet(); - int index=0; + int index = 0; for (CaDoodleOperation op : keySet) { List cachedCopy = cache.get(op); getSaveUpdate().renderSplashFrame((int) (((double) index) / ((double) keySet.size()) * 100), @@ -188,11 +194,11 @@ private void memoryCheck() { } cache.clear(); System.gc(); - }else { - //com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); + } else { + // com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); } } - + private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { memoryCheck(); // clear the stale cache value @@ -201,18 +207,18 @@ private void placeCSGsInCache(CaDoodleOperation op, List cachedCopy) { back.clear(); cache.put(op, cachedCopy); } + private void clearCache(CaDoodleOperation key) { int opIndex = opToIndex(key); - File cacheFile = new File(objectDir.getAbsolutePath()+delim()+opIndex); - if(cacheFile.exists()) + File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); + if (cacheFile.exists()) cacheFile.delete(); - + List back = cache.remove(key); if (back != null) back.clear(); } - - + public CaDoodleFile clearListeners() { listeners.clear(); return this; @@ -235,28 +241,28 @@ public void initialize() { // throw new RuntimeException("Can not initialize while initializing."); fireInitializationStart(); initializing = true; - if(timeCreated<0) - timeCreated=System.currentTimeMillis(); + if (timeCreated < 0) + timeCreated = System.currentTimeMillis(); if (self != null) { File parent = self.getAbsoluteFile().getParentFile(); File imageCacheDir = new File(parent.getAbsolutePath() + delim() + "timeline"); if (!imageCacheDir.exists()) imageCacheDir.mkdir(); - objectDir = new File(parent.getAbsolutePath() + delim() + "timeline"+ delim()+"objectCache"); + objectDir = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + "objectCache"); if (!objectDir.exists()) objectDir.mkdir(); File db = new File(self.getAbsoluteFile().getParent() + delim() + "CSGdatabase.json"); setCsgDBinstance(new CSGDatabaseInstance(db)); - //CSGDatabase.setInstance(getCsgDBinstance()); + // CSGDatabase.setInstance(getCsgDBinstance()); bom = CaDoodleFile.getBillOfMaterials(this); bom.clear(); bom.save(); } int indexStarting = getCurrentIndex(); - if(indexStarting==0) { - indexStarting=opperations.size(); + if (indexStarting == 0) { + indexStarting = opperations.size(); } - this.currentIndex=0; + this.currentIndex = 0; setPercentInitialized(0); opperations = opperations.stream().filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new)); if (indexStarting > opperations.size()) @@ -266,15 +272,15 @@ public void initialize() { if (op == null) continue; setPercentInitialized(((double) i) / (double) getOpperations().size()); - //if(!inCache(op)) - try { - process(op); - } catch (Throwable t) { - com.neuronrobotics.sdk.common.Log.error(t); - indexStarting = i + 1; - break; - // opperations.remove(op); - } + // if(!inCache(op)) + try { + process(op); + } catch (Throwable t) { + com.neuronrobotics.sdk.common.Log.error(t); + indexStarting = i + 1; + break; + // opperations.remove(op); + } } setCurrentIndex(indexStarting); updateCurrentFromCache(); @@ -321,7 +327,7 @@ private void updateBoM() { public static VitaminBomManager getBillOfMaterials(CaDoodleFile cf) { - String strValue = cf.getSelf().getAbsolutePath() ; + String strValue = cf.getSelf().getAbsolutePath(); File file = new File(strValue).getParentFile(); if (bomManagers.get(strValue) == null) { bomManagers.put(strValue, new VitaminBomManager(file)); @@ -380,7 +386,7 @@ public void run() { getSaveUpdate().renderSplashFrame(percent, "Regenerating " + op.getType() + " " + currentIndex2); getTimelineImageFile(op).delete(); - //clearCache(op); + // clearCache(op); try { op.setCaDoodleFile(cf); List process = op.process(getPreviouState()); @@ -395,7 +401,8 @@ public void run() { updateCurrentFromCache(); } } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; } setPercentInitialized(1); updateBoM(); @@ -464,8 +471,8 @@ public void run() { private void process(CaDoodleOperation op) { op.setCaDoodleFile(this); List process = op.process(getCurrentState()); - if(MakeRobot.class.isInstance(op)) { - MakeRobot mr = (MakeRobot)op; + if (MakeRobot.class.isInstance(op)) { + MakeRobot mr = (MakeRobot) op; getRobots().put(mr.getName(), mr.getBuilder()); } int currentIndex2 = getCurrentIndex(); @@ -510,7 +517,7 @@ public void run() { result = OperationResult.APPEND; this.setName("addOpperation Thread " + toProcess.size()); CaDoodleOperation op = toProcess.remove(0); - com.neuronrobotics.sdk.common.Log.debug("Adding Operation "+op); + com.neuronrobotics.sdk.common.Log.debug("Adding Operation " + op); if (getCurrentIndex() != getOpperations().size()) { try { fireRegenerateStart(op); @@ -525,7 +532,8 @@ public void run() { getOpperations().add(op); process(op); } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; } } if (getResult() == OperationResult.INSERT) { @@ -611,16 +619,17 @@ public static int applyToAllConstituantElements(boolean addRet, List tar if (c.isInGroup()) continue; } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; } - applyToAllConstituantElements(addRet, s, back, p, depth,appliedMemory); + applyToAllConstituantElements(addRet, s, back, p, depth, appliedMemory); } return back.size(); } public static int applyToAllConstituantElements(boolean addRet, String targetName, ArrayList back, - ICadoodleRecursiveEvent p, int depth,HashSet appliedMemory) { - if(appliedMemory.contains(targetName)) + ICadoodleRecursiveEvent p, int depth, HashSet appliedMemory) { + if (appliedMemory.contains(targetName)) return back.size(); appliedMemory.add(targetName); ArrayList immutable = new ArrayList<>(); @@ -653,7 +662,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam } if (thisCSGIsInGroupNamedAfterTarget) { // composite group - applyToAllConstituantElements(addRet, thisCSGName, back, p, depth + 1,appliedMemory); + applyToAllConstituantElements(addRet, thisCSGName, back, p, depth + 1, appliedMemory); } } back.removeAll(Collections.singleton(null)); @@ -672,7 +681,7 @@ public File getTimelineImageFile(CaDoodleOperation test) { } public File getTimelineImageFile(int i) { - File parent = getSelf().getAbsoluteFile().getParentFile(); + File parent = getSelf().getAbsoluteFile().getParentFile(); File file = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + (i + 1) + ".png"); return file; } @@ -698,9 +707,8 @@ private OperationResult pruneForward(CaDoodleOperation op) throws Exception { imageCache.delete(); } if (res == OperationResult.PRUNE) { - List subList = (List) getOpperations().subList(0, - getCurrentIndex()); - for(int i=getCurrentIndex();i subList = (List) getOpperations().subList(0, getCurrentIndex()); + for (int i = getCurrentIndex(); i < getOpperations().size(); i++) { getOpperations().get(i).pruneCleanup(); } ArrayList newList = new ArrayList(); @@ -712,7 +720,6 @@ private OperationResult pruneForward(CaDoodleOperation op) throws Exception { return res; } - private void storeResultInCache(CaDoodleOperation op, List process) { ArrayList cachedCopy = new ArrayList(); HashSet names = new HashSet<>(); @@ -721,10 +728,9 @@ private void storeResultInCache(CaDoodleOperation op, List process) { throw new RuntimeException("There can not be 2 objects with the same name after an " + op.getType() + " opperation! " + c.getName()); names.add(c.getName()); - CSG cachedVer = cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(getCsgDBinstance(),c).setName(c.getName()) - .setRegenerate(c.getRegenerate()); - if(cachedVer.isHole() != c.isHole()|| - cachedVer.isHide() != c.isHide() ) { + CSG cachedVer = cloneCSG(c).setStorage(new PropertyStorage()).syncProperties(getCsgDBinstance(), c) + .setName(c.getName()).setRegenerate(c.getRegenerate()); + if (cachedVer.isHole() != c.isHole() || cachedVer.isHide() != c.isHide()) { throw new RuntimeException("Lost properties"); } cachedCopy.add(cachedVer); @@ -734,7 +740,6 @@ private void storeResultInCache(CaDoodleOperation op, List process) { } - public static double getFreeMemory() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); // Maximum memory the JVM will attempt to use @@ -756,7 +761,8 @@ private CSG cloneCSG(CSG dyingCSG) { try { collect.add(p); } catch (Exception ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; } } csg.setPolygons(collect); @@ -770,7 +776,8 @@ private CSG cloneCSG(CSG dyingCSG) { if (!existing) { Parameter vals = getCsgDBinstance().get(param); if (vals != null) - csg.setParameter(getCsgDBinstance(),vals, getCsgDBinstance().getMapOfparametrics(dyingCSG).get(param)); + csg.setParameter(getCsgDBinstance(), vals, + getCsgDBinstance().getMapOfparametrics(dyingCSG).get(param)); } } if (csg.getName().length() == 0) @@ -784,19 +791,20 @@ public void back() { if (isBackAvailible()) setCurrentIndex(getCurrentIndex() - 1); updateCurrentFromCache(); - if(ICadoodleOperationUndo.class.isInstance(op)) { - ICadoodleOperationUndo un = (ICadoodleOperationUndo)op; + if (ICadoodleOperationUndo.class.isInstance(op)) { + ICadoodleOperationUndo un = (ICadoodleOperationUndo) op; un.undo(); } fireSaveSuggestion(); } + public void forward() { if (isForwardAvailible()) setCurrentIndex(getCurrentIndex() + 1); updateCurrentFromCache(); CaDoodleOperation op = getCurrentOpperation(); - if(ICadoodleOperationUndo.class.isInstance(op)) { - ICadoodleOperationUndo un = (ICadoodleOperationUndo)op; + if (ICadoodleOperationUndo.class.isInstance(op)) { + ICadoodleOperationUndo un = (ICadoodleOperationUndo) op; un.redo(); } fireSaveSuggestion(); @@ -807,11 +815,11 @@ public void moveToOpIndex(int newIndex) { return; if (newIndex < 0) return; - int ci =getCurrentIndex(); - int ni=newIndex + 1; - boolean forward= ci currentState = getCurrentState(); CSG thumb = null; @@ -1013,7 +1021,7 @@ public File save() throws IOException { String string = getSTLThumbnailLocation(); int currentIndex2 = getCurrentIndex(); if (isTimelineOpen()) - getSaveUpdate().renderSplashFrame(1, "Save Doodle to " + getSelf().getName()); + getSaveUpdate().renderSplashFrame(1, "Save Doodle to " + getSelf().getName()); if (thumb != null) { boolean manif = CSG.isPreventNonManifoldTriangles(); if (manif) @@ -1022,7 +1030,7 @@ public File save() throws IOException { if (manif) CSG.setPreventNonManifoldTriangles(true); } - FileUtils.write( getSelf(), contents, StandardCharsets.UTF_8, false); + FileUtils.write(getSelf(), contents, StandardCharsets.UTF_8, false); // } int num = 0; for (int i = 0; i < opperations.size(); i++) { @@ -1030,7 +1038,7 @@ public File save() throws IOException { CaDoodleOperation op = opperations.get(i); int percent = (int) (((double) i) / ((double) opperations.size()) * 100.0); List process = getCachedCSGs(op); - if (!f.exists() && process!=null) + if (!f.exists() && process != null) try { num++; if (isTimelineOpen()) @@ -1058,15 +1066,15 @@ public File getSTLThumbnailFile() { } public String getSTLThumbnailLocation() { - File folder = getSelf().getAbsoluteFile().getParentFile(); - if(!folder.exists()) + File folder = getSelf().getAbsoluteFile().getParentFile(); + if (!folder.exists()) folder.mkdirs(); String string = folder.getAbsolutePath() + delim() + "thumbnail.stl"; return string; } private void setSaveImage(List currentState, CaDoodleOperation op) throws IOException { - if ( getSelf() == null) + if (getSelf() == null) return; int currentIndex2 = 0; for (int i = 0; i < getOpperations().size(); i++) @@ -1074,9 +1082,9 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I currentIndex2 = i; // if(currentIndex2==0) // return; - File parent = getSelf().getAbsoluteFile().getParentFile(); - File imageFolder=new File(parent.getAbsolutePath() + delim() + "timeline" + delim()); - if(!imageFolder.exists()) + File parent = getSelf().getAbsoluteFile().getParentFile(); + File imageFolder = new File(parent.getAbsolutePath() + delim() + "timeline" + delim()); + if (!imageFolder.exists()) imageFolder.mkdirs(); File imageCache = new File(parent.getAbsolutePath() + delim() + "timeline" + delim() + currentIndex2 + ".png"); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); @@ -1105,8 +1113,7 @@ private void setSaveImage(List currentState, CaDoodleOperation op) throws I if (getOpperations().get(getOpperations().size() - 1) == op) { Files.copy(imageCache, image); } - System.err.println("Thumbnail saved successfully to " + - imageCache.getAbsolutePath()); + System.err.println("Thumbnail saved successfully to " + imageCache.getAbsolutePath()); } } catch (Throwable t) { com.neuronrobotics.sdk.common.Log.error(t); @@ -1121,7 +1128,7 @@ private void fireTimelineUpdate(int number) { public WritableImage loadImageFromFile() { try { - File parent = getSelf().getAbsoluteFile().getParentFile(); + File parent = getSelf().getAbsoluteFile().getParentFile(); File image = new File(parent.getAbsolutePath() + delim() + "snapshot.png"); if (image.exists()) { BufferedImage bufferedImage = ImageIO.read(image); @@ -1144,10 +1151,11 @@ private javafx.scene.image.WritableImage loadingImageFromUIThread(List curr ArrayList holder = new ArrayList(); try { BowlerKernel.runLater(() -> { - holder.add(ThumbnailImage.get(getCsgDBinstance(),currentState)); + holder.add(ThumbnailImage.get(getCsgDBinstance(), currentState)); }); } catch (Throwable ex) { - com.neuronrobotics.sdk.common.Log.error(ex);; + com.neuronrobotics.sdk.common.Log.error(ex); + ; return null; } long start = System.currentTimeMillis(); @@ -1250,11 +1258,14 @@ public javafx.scene.image.WritableImage setImage(javafx.scene.image.WritableImag this.img = img; return img; } + public boolean isInitialized() { - return !(percentInitialized<1); + return !(percentInitialized < 1); } + /** * A value from 0 to 1 representing how complete the initialization is + * * @return */ public double getPercentInitialized() { @@ -1262,7 +1273,7 @@ public double getPercentInitialized() { } private void setPercentInitialized(double percentInitialized) { - if(percentInitialized>1||percentInitialized<0) + if (percentInitialized > 1 || percentInitialized < 0) throw new NumberFormatException("Number must be between 0 and 1"); this.percentInitialized = percentInitialized; } @@ -1338,19 +1349,21 @@ public void setTimeCreated(long timeCreated) { /** * @return the robots */ - public HashMap getRobots() { + public HashMap getRobots() { return robots; } /** * @param robots the robots to set */ - public void setRobots(HashMap robots) { + public void setRobots(HashMap robots) { this.robots = robots; } + public CSGDatabaseInstance getCsgDBinstance() { return csgDBinstance; } + private void setCsgDBinstance(CSGDatabaseInstance csgDBinstance) { this.csgDBinstance = csgDBinstance; } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java index ac6ae47c..46f1648d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/util/GeometrySimplification.java @@ -21,7 +21,7 @@ public class GeometrySimplification { * @throws Exception */ public static CSG remesh(CSG incoming, double MMVoxel,CSGDatabaseInstance instance) throws Exception { - return BlenderLoader.remesh(incoming, MMVoxel,instance); + return BlenderLoader.remesh(null,incoming, MMVoxel,instance); } /** * RE-mesh an STL file in place @@ -31,7 +31,7 @@ public static CSG remesh(CSG incoming, double MMVoxel,CSGDatabaseInstance instan * @throws Exception */ public static void remeshSTLFile(File stlout,double MMVoxel) throws Exception { - BlenderLoader.remeshSTLFile(stlout, MMVoxel); + BlenderLoader.remeshSTLFile(null,stlout, MMVoxel); } /** * Simplify an SVG file diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java index e0d5506b..1c528384 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/vitamins/Vitamins.java @@ -86,10 +86,11 @@ public static void clear() { databaseSet.clear(); fileLastLoaded.clear(); } + @Deprecated public static CSG get(File resource) { return get(CSGDatabase.getInstance(),resource, false); } - + @Deprecated public static CSG get(File resource, boolean forceRefresh) { return get(CSGDatabase.getInstance(), resource, forceRefresh); } From 4fcdffb1733cacd0775261611ceace313f87d3ef Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Mon, 6 Oct 2025 21:32:38 -0400 Subject: [PATCH 625/635] remove the junk database set on the event of the passing a doodle --- JCSG | 2 +- java-bowler | 2 +- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/JCSG b/JCSG index 4a7e8290..4d94fcf4 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4a7e829063f51707ede86b9042e41e59ac7a5413 +Subproject commit 4d94fcf4c6504bfe9610eeb3949b18ca3b3ea78a diff --git a/java-bowler b/java-bowler index 25ef9486..23f29281 160000 --- a/java-bowler +++ b/java-bowler @@ -1 +1 @@ -Subproject commit 25ef9486f40d44b503bacec67158883b3be2f86c +Subproject commit 23f29281be61bacbd0313509bacf74746a63ccb8 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 73959e7b..44e9ed59 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -86,10 +86,10 @@ public List process(List incoming) { configs.put("PreventBomAdd", preventBoM); args.add(configs); boolean isDoodle = file.getName().toLowerCase().endsWith(".doodle"); - if(isDoodle) { - Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); - instance=(new CSGDatabaseInstance(tempFile.toFile())); - } +// if(isDoodle) { +// Path tempFile = Files.createTempFile("CSGDatabase", ".tmp"); +// instance=(new CSGDatabaseInstance(tempFile.toFile())); +// } List flattenedCSGs; try { flattenedCSGs = ScriptingEngine.flaten(instance,file, CSG.class, args); From 2eda2dcbb9be8130352a70f56b7c8d561e605fc4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 17:52:17 -0400 Subject: [PATCH 626/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 4d94fcf4..e79d98b2 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4d94fcf4c6504bfe9610eeb3949b18ca3b3ea78a +Subproject commit e79d98b26fb26e2de7a6f92d50d615e65889064e From eb990479725d2d6ed15d17f5a22d4fa47e9d22df Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:20:20 -0400 Subject: [PATCH 627/635] no need to clear parmeters from a discarded database --- .../bowlerstudio/scripting/cadoodle/AddFromFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java index 44e9ed59..6fbd2494 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/AddFromFile.java @@ -341,9 +341,9 @@ private static CSG processGiven(CSG csg, int i, String name, File f,String task, String fileLocation = file.getAbsolutePath(); com.neuronrobotics.sdk.common.Log.error("Regenerating " + fileLocation); List flattenedCSGs = ScriptingEngine.flaten(instancetmp,file, CSG.class, null); + CSG csg1 = flattenedCSGs.get(i); if(isDoodle) { - csg1.getMapOfparametrics(instancetmp ).clear(); csg1.setStorage(new PropertyStorage()); } //CSGDatabase.setInstance(instance); From 5eb0aceb5f52dbba430a74e56146dd5bdbfe24e4 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:20:40 -0400 Subject: [PATCH 628/635] ensure the cache is accessed outside of the UI thread --- .../scripting/cadoodle/CaDoodleFile.java | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 4a379721..5722925d 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -56,6 +56,7 @@ import eu.mihosoft.vrl.v3d.parametrics.IParametric; import eu.mihosoft.vrl.v3d.parametrics.Parameter; import eu.mihosoft.vrl.v3d.parametrics.StringParameter; +import javafx.application.Platform; import javafx.embed.swing.SwingFXUtils; import static com.neuronrobotics.bowlerstudio.scripting.DownloadManager.*; @@ -149,17 +150,21 @@ private boolean inCache(CaDoodleOperation op) { } private List getCachedCSGs(CaDoodleOperation op) { - + if (Platform.isFxApplicationThread()) { + new RuntimeException("This should not be called from the UI thread!").printStackTrace();; + } if (cache.get(op) == null && objectDir !=null) { try { int opIndex = opToIndex(op); File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); - Log.debug("Loading Cached Objects from file: " + cacheFile.getAbsolutePath()); - // Log.error(new Exception()); - ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile)); - memoryCheck(); - cache.put(op, (List) ois.readObject()); - ois.close(); + if(cacheFile.exists()) { + Log.debug("Loading Cached Objects from file: " + cacheFile.getAbsolutePath()); + // Log.error(new Exception()); + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cacheFile)); + memoryCheck(); + cache.put(op, (List) ois.readObject()); + ois.close(); + } } catch (Exception ex) { Log.error(ex); } @@ -170,29 +175,29 @@ private List getCachedCSGs(CaDoodleOperation op) { private void memoryCheck() { if (getFreeMemory() > 75) { com.neuronrobotics.sdk.common.Log.error("\n\nClearing Memory use: " + getFreeMemory() + "\n\n"); - Set keySet = cache.keySet(); - int index = 0; - for (CaDoodleOperation op : keySet) { - List cachedCopy = cache.get(op); - getSaveUpdate().renderSplashFrame((int) (((double) index) / ((double) keySet.size()) * 100), - "Clearing Ram to Disk"); - int opIndex = opToIndex(op); - File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); - if (!isInitialized()) - if (cacheFile.exists()) - return; - if (cacheFile.exists()) - cacheFile.delete(); - try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { - oos.writeObject(cachedCopy); - Log.debug("Saved " + cacheFile.getAbsolutePath()); - } catch (Exception ex) { - Log.error(ex); - throw new RuntimeException(ex); - } - index++; - } - cache.clear(); +// Set keySet = cache.keySet(); +// int index = 0; +// for (CaDoodleOperation op : keySet) { +// List cachedCopy = cache.get(op); +// getSaveUpdate().renderSplashFrame((int) (((double) index) / ((double) keySet.size()) * 100), +// "Clearing Ram to Disk"); +// int opIndex = opToIndex(op); +// File cacheFile = new File(objectDir.getAbsolutePath() + delim() + opIndex); +// if (!isInitialized()) +// if (cacheFile.exists()) +// return; +// if (cacheFile.exists()) +// cacheFile.delete(); +// try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cacheFile))) { +// oos.writeObject(cachedCopy); +// Log.debug("Saved " + cacheFile.getAbsolutePath()); +// } catch (Exception ex) { +// Log.error(ex); +// throw new RuntimeException(ex); +// } +// index++; +// } +// cache.clear(); System.gc(); } else { // com.neuronrobotics.sdk.common.Log.debug("Memory use: " + getFreeMemory()); From 6f3c4a90405f72c5caf53832bab480c23e2a17a6 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:21:09 -0400 Subject: [PATCH 629/635] use an explicate database location --- .../bowlerstudio/assets/ConfigurationDatabase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java index ede0289a..ff824bbb 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/assets/ConfigurationDatabase.java @@ -18,6 +18,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; +import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.IGithubLoginListener; import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; @@ -165,7 +166,10 @@ public static void getDatabase() { File loadFile = loadFile(); if(loadFile.exists()) try { - Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(new CSGDatabaseInstance(new File("CSGdatabase.json")),loadFile, null); + File parent =loadFile.getParentFile(); + File db = new File(parent.getAbsolutePath()+DownloadManager.delim()+"CSGdatabase.json"); + CSGDatabaseInstance instance = new CSGDatabaseInstance(db); + Object inlineFileScriptRun = ScriptingEngine.inlineFileScriptRun(instance,loadFile, null); database = Collections.synchronizedMap((HashMap>) inlineFileScriptRun); } catch (Exception e) { From 7143f5b1f3d61f8ee3ee03b1a7c3d5b9a34c8e4f Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:21:18 -0400 Subject: [PATCH 630/635] jcsg --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index 4d94fcf4..b491054c 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit 4d94fcf4c6504bfe9610eeb3949b18ca3b3ea78a +Subproject commit b491054c75f341fadceaf0d59f3bdb276341c5de From f713d5b91f868d2edcfbb52f2b7268f85174402e Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:37:30 -0400 Subject: [PATCH 631/635] safer exception handeling in the saveDatabase(); --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index b491054c..c49e1784 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit b491054c75f341fadceaf0d59f3bdb276341c5de +Subproject commit c49e17847c87b596d6c3aa838925ba590ebe6ef9 From ea9275769c6334983f0974e0cca36dcb5ac88bb5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 19:41:49 -0400 Subject: [PATCH 632/635] safer paste operation --- .../bowlerstudio/scripting/cadoodle/Paste.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java index cbd866f4..afebc98b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Paste.java @@ -56,8 +56,10 @@ public ArrayList process(CSG ic, int depth) { CSG source = CaDoodleFile.getByName(back, from); if (source.isGroupResult()) { ArrayList c = constituants(back, from); - if(c.size()<1) - throw new RuntimeException("A group result must have at least 1 constituants!"); + if(c.size()<1) { + new RuntimeException("A group result must have at least 1 constituants!").printStackTrace();; + continue; + } String newGroupName = CaDoodleFile.getByName(back, cpMap.get(from)).getName(); for (String s : c) { CSG dest = CaDoodleFile.getByName(back, s); From 1e5a69a6f0356430924c2850518b37192999ce77 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 20:51:19 -0400 Subject: [PATCH 633/635] faster touching --- JCSG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JCSG b/JCSG index c49e1784..da55c5d6 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit c49e17847c87b596d6c3aa838925ba590ebe6ef9 +Subproject commit da55c5d63e7663e8104ff061b1cf97d25e388429 From 7575865c82df15f87861ab9909976b7e4c47216c Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 8 Oct 2025 21:50:45 -0400 Subject: [PATCH 634/635] skip null enteries --- .../bowlerstudio/scripting/cadoodle/CaDoodleFile.java | 2 +- .../neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java index 5722925d..950d12b2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java @@ -641,7 +641,7 @@ public static int applyToAllConstituantElements(boolean addRet, String targetNam immutable.addAll(back); for (int i = 0; i < immutable.size(); i++) { CSG csg = immutable.get(i); - if (csg.isLock()) + if ( csg==null || csg.isLock()) continue; // boolean inGroup = csg.isInGroup(); boolean thisCSGIsInGroupNamedAfterTarget = csg.checkGroupMembership(targetName); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java index 0d1ac6f1..7cd5bf41 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/Group.java @@ -49,7 +49,7 @@ public List process(List incoming) { if (name.contentEquals(csg.getName())) { if(csg.isNoScale()) noscale=true; - if(csg.isMotionLock() || csg.isInGroup()) + if(csg.isMotionLock() ) nomove=true; Optional mobileBaseName = csg.getMobileBaseName(); if(mobileBaseName.isPresent()) { From 633e815956374b6d1b17bbb13df9efcf5beb78f5 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Sat, 11 Oct 2025 07:16:07 -0400 Subject: [PATCH 635/635] use only the localized csg database --- JCSG | 2 +- .../neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/JCSG b/JCSG index da55c5d6..7d28ab20 160000 --- a/JCSG +++ b/JCSG @@ -1 +1 @@ -Subproject commit da55c5d63e7663e8104ff061b1cf97d25e388429 +Subproject commit 7d28ab20c12b936b32e527d32017b22bdd955c87 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java index b0ae48cf..dfd7e745 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobileBaseLoader.java @@ -184,7 +184,6 @@ public MobileBase getBase() { public void setBase(MobileBase base) { this.base = base; - setDb(CSGDatabase.getInstance()); try { String[] self = base.getGitSelfSource(); File selfFile =ScriptingEngine.fileFromGit(self);