From 2bd52f055432d639157cc2598db93d7bb9982a2e Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 20 Jul 2024 18:09:34 -0400 Subject: [PATCH 001/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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/345] 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();