@@ -24,8 +24,8 @@ public class BlenderLoader implements IScriptingLanguage {
2424 public Object inlineScriptRun (CSGDatabaseInstance db ,File code , ArrayList <Object > args ) throws Exception {
2525 File stl = File .createTempFile (code .getName (), ".stl" );
2626 stl .deleteOnExit ();
27- toSTLFile (code ,stl );
28- CSG back = Vitamins .get (stl ,true );
27+ toSTLFile (db , code ,stl );
28+ CSG back = Vitamins .get (db , stl ,true );
2929 back .setColor (Color .ORANGE );
3030 return back ;
3131 }
@@ -46,13 +46,13 @@ public ArrayList<String> getFileExtenetion() {
4646 ext .add ("blend" );
4747 return ext ;
4848 }
49- public static void toBlenderFile (CSG stlIn ,File blenderfile ) throws IOException {
49+ public static void toBlenderFile (CSGDatabaseInstance db , CSG stlIn ,File blenderfile ) throws IOException {
5050 File stl = getTmpSTL (stlIn );
51- toBlenderFile (stl , blenderfile );
51+ toBlenderFile (db , stl , blenderfile );
5252 }
5353
5454
55- public static void toBlenderFile (File stl ,File blenderfile ) {
55+ public static void toBlenderFile (CSGDatabaseInstance db , File stl ,File blenderfile ) {
5656 com .neuronrobotics .sdk .common .Log .error ("Converting to Blender file before loading" );
5757
5858 File stlIn ;
@@ -64,7 +64,7 @@ public static void toBlenderFile(File stl,File blenderfile) {
6464 return ;
6565 }
6666 stlIn .deleteOnExit ();
67- scaleStl (stl ,stlIn ,0.001 );
67+ scaleStl (db , stl ,stlIn ,0.001 );
6868 File dir = stlIn .getAbsoluteFile ().getParentFile ();
6969
7070 try {
@@ -91,8 +91,8 @@ public static void toBlenderFile(File stl,File blenderfile) {
9191 return ;
9292 }
9393 }
94- public static void scaleStl (File incoming , File outgoing , double scale ) {
95- CSG back = Vitamins .get (incoming ,true ).scale (scale );
94+ public static void scaleStl (CSGDatabaseInstance db , File incoming , File outgoing , double scale ) {
95+ CSG back = Vitamins .get (db , incoming ,true ).scale (scale );
9696 try {
9797 boolean manifold =CSG .isPreventNonManifoldTriangles ();
9898 CSG .setPreventNonManifoldTriangles (false );
@@ -104,19 +104,19 @@ public static void scaleStl(File incoming, File outgoing, double scale) {
104104 com .neuronrobotics .sdk .common .Log .error (e );
105105 }
106106 }
107- public static CSG remesh (CSG incoming , double MMVoxel ,CSGDatabaseInstance instance ) throws Exception {
107+ public static CSG remesh (CSGDatabaseInstance db , CSG incoming , double MMVoxel ,CSGDatabaseInstance instance ) throws Exception {
108108 File stl = DownloadManager .getTmpSTL (incoming );
109- remeshSTLFile (stl , MMVoxel );
110- CSG back = Vitamins .get (stl ,true );
109+ remeshSTLFile (db , stl , MMVoxel );
110+ CSG back = Vitamins .get (db , stl ,true );
111111 return back .syncProperties (instance ,incoming ).setName (incoming .getName ());
112112 }
113- public static void remeshSTLFile (File stlout ,double MMVoxel ) throws Exception {
113+ public static void remeshSTLFile (CSGDatabaseInstance db , File stlout ,double MMVoxel ) throws Exception {
114114 File blend = File .createTempFile (stlout .getName (), ".blend" );
115115 blend .delete ();
116- toBlenderFile (stlout , blend );
117- remeshToSTLFile (blend , stlout , MMVoxel );
116+ toBlenderFile (db , stlout , blend );
117+ remeshToSTLFile (db , blend , stlout , MMVoxel );
118118 }
119- public static void remeshToSTLFile (File blenderfile ,File stlout ,double MMVoxel ) throws InvalidRemoteException , TransportException , GitAPIException , IOException , InterruptedException {
119+ public static void remeshToSTLFile (CSGDatabaseInstance db , File blenderfile ,File stlout ,double MMVoxel ) throws InvalidRemoteException , TransportException , GitAPIException , IOException , InterruptedException {
120120 File exe = getConfigExecutable ("blender" , null );
121121 File export = ScriptingEngine .fileFromGit (
122122 "https://github.com/CommonWealthRobotics/blender-bowler-cli.git" ,
@@ -135,9 +135,9 @@ public static void remeshToSTLFile(File blenderfile,File stlout,double MMVoxel)
135135 args .add ("" +(MMVoxel /1000.0 ));
136136 args .add (stlout .getAbsolutePath ());
137137 legacySystemRun (null , stlout .getAbsoluteFile ().getParentFile (), System .out , args );
138- scaleStl (stlout ,stlout ,1000.0 );
138+ scaleStl (db , stlout ,stlout ,1000.0 );
139139 }
140- public static void toSTLFile (File blenderfile ,File stlout ) throws InvalidRemoteException , TransportException , GitAPIException , IOException , InterruptedException {
140+ public static void toSTLFile (CSGDatabaseInstance db , File blenderfile ,File stlout ) throws InvalidRemoteException , TransportException , GitAPIException , IOException , InterruptedException {
141141 File exe = getConfigExecutable ("blender" , null );
142142 File export = ScriptingEngine .fileFromGit (
143143 "https://github.com/CommonWealthRobotics/blender-bowler-cli.git" ,
@@ -155,7 +155,7 @@ public static void toSTLFile(File blenderfile,File stlout) throws InvalidRemoteE
155155 args .add (blenderfile .getAbsolutePath ());
156156 args .add (stlout .getAbsolutePath ());
157157 legacySystemRun (null , stlout .getAbsoluteFile ().getParentFile (), System .out , args );
158- scaleStl (stlout ,stlout ,1000.0 );
158+ scaleStl (db , stlout ,stlout ,1000.0 );
159159 }
160160 @ Override
161161 public void getDefaultContents (File source ) {
@@ -200,7 +200,7 @@ public static void main(String[] args) throws InvalidRemoteException, TransportE
200200 File testblend = new File ("test.blend" );
201201 if (!testblend .exists ())
202202 loader .getDefaultContents (testblend );
203- loader .toSTLFile (testblend , new File ("testBlender.stl" ));
203+ loader .toSTLFile (null , testblend , new File ("testBlender.stl" ));
204204 }
205205
206206}
0 commit comments