Skip to content

Commit fd071bd

Browse files
Merge pull request #73 from NeuronRobotics/kh/CSGParametersUpdate
Kh/csg parameters update
2 parents ca72640 + 7d28ab2 commit fd071bd

18 files changed

Lines changed: 500 additions & 292 deletions

src/main/java/eu/mihosoft/vrl/v3d/CSG.java

Lines changed: 193 additions & 129 deletions
Large diffs are not rendered by default.

src/main/java/eu/mihosoft/vrl/v3d/Cube.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public Cube(Vector3d center, Vector3d dimensions) {
105105
public Cube(double w, double h, double d) {
106106
this(Vector3d.ZERO, new Vector3d(w, h, d));
107107
}
108-
public Cube(LengthParameter w, LengthParameter h, LengthParameter d) {
109-
this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
110-
parametrics.add(w);
111-
parametrics.add(h);
112-
parametrics.add(d);
113-
}
114-
public Cube(LengthParameter size) {
115-
this(size,size,size);
116-
}
108+
// public Cube(LengthParameter w, LengthParameter h, LengthParameter d) {
109+
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
110+
//// parametrics.add(w);
111+
//// parametrics.add(h);
112+
//// parametrics.add(d);
113+
// }
114+
// public Cube(LengthParameter size) {
115+
// this(size,size,size);
116+
// }
117117
/* (non-Javadoc)
118118
* @see eu.mihosoft.vrl.v3d.Primitive#toPolygons()
119119
*/

src/main/java/eu/mihosoft/vrl/v3d/Cylinder.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,24 @@ public Cylinder(double startRadius, double endRadius, double height) {
186186
this.startRadius = startRadius<MINIMUM_RADIUS?MINIMUM_RADIUS:startRadius;
187187
this.endRadius = endRadius<MINIMUM_RADIUS?MINIMUM_RADIUS:endRadius;
188188
}
189-
public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height, int numSlices) {
190-
this(startRadius.getMM(),endRadius.getMM(),height.getMM(),numSlices);
191-
parametrics.add(startRadius);
192-
parametrics.add(endRadius);
193-
parametrics.add(height);
194-
}
195-
public Cylinder(LengthParameter startRadius, LengthParameter height, int numSlices) {
196-
this(startRadius,startRadius,height,numSlices);
197-
}
198-
public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height) {
199-
this(startRadius.getMM(),endRadius.getMM(),height.getMM());
200-
parametrics.add(startRadius);
201-
parametrics.add(endRadius);
202-
parametrics.add(height);
203-
}
204-
public Cylinder(LengthParameter startRadius, LengthParameter height) {
205-
this(startRadius,startRadius,height);
206-
}
189+
// public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height, int numSlices) {
190+
// this(startRadius.getMM(),endRadius.getMM(),height.getMM(),numSlices);
191+
//// parametrics.add(startRadius);
192+
//// parametrics.add(endRadius);
193+
//// parametrics.add(height);
194+
// }
195+
// public Cylinder(LengthParameter startRadius, LengthParameter height, int numSlices) {
196+
// this(startRadius,startRadius,height,numSlices);
197+
// }
198+
// public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height) {
199+
// this(startRadius.getMM(),endRadius.getMM(),height.getMM());
200+
//// parametrics.add(startRadius);
201+
//// parametrics.add(endRadius);
202+
//// parametrics.add(height);
203+
// }
204+
// public Cylinder(LengthParameter startRadius, LengthParameter height) {
205+
// this(startRadius,startRadius,height);
206+
// }
207207
/* (non-Javadoc)
208208
* @see eu.mihosoft.vrl.v3d.Primitive#toPolygons()
209209
*/

src/main/java/eu/mihosoft/vrl/v3d/Primitive.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @author Michael Hoffer &lt;info@michaelhoffer.de&gt;
4343
*/
4444
public abstract class Primitive implements ItoCSG{
45-
ArrayList<Parameter> parametrics=new ArrayList<>();
45+
// ArrayList<Parameter> parametrics=new ArrayList<>();
4646

4747

4848
/**
@@ -62,9 +62,9 @@ public abstract class Primitive implements ItoCSG{
6262
*/
6363
public CSG toCSG() {
6464
CSG tmp = CSG.fromPolygons(getProperties(),new ArrayList<>(toPolygons()));
65-
if(parametrics!=null)
66-
for(Parameter p:parametrics)
67-
tmp.setParameter(p);
65+
// if(parametrics!=null)
66+
// for(Parameter p:parametrics)
67+
// tmp.setParameter(p);
6868
//tmp.triangulate();
6969
return tmp;
7070
}

src/main/java/eu/mihosoft/vrl/v3d/PropertyStorage.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.Map;
4141
import java.util.Optional;
4242
import java.util.Set;
43+
import java.util.concurrent.ConcurrentHashMap;
4344

4445
import javafx.scene.paint.Color;
4546

@@ -50,8 +51,10 @@
5051
*/
5152
public class PropertyStorage implements Serializable{
5253

53-
/** The map. */
54-
private final Map<String, Object> map = new HashMap<>();
54+
private static final long serialVersionUID = 1460815261025940141L;
55+
56+
/** The map. */
57+
private final ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
5558

5659
/** The Constant colors. */
5760
private static final Color[] colors = {

src/main/java/eu/mihosoft/vrl/v3d/RoundedCube.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public RoundedCube(double size) {
5959
}
6060

6161

62-
public RoundedCube(LengthParameter w, LengthParameter h, LengthParameter d) {
63-
this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
64-
parametrics.add(w);
65-
parametrics.add(h);
66-
parametrics.add(d);
67-
}
68-
public RoundedCube(LengthParameter size) {
69-
this(size,size,size);
70-
}
62+
// public RoundedCube(LengthParameter w, LengthParameter h, LengthParameter d) {
63+
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
64+
// parametrics.add(w);
65+
// parametrics.add(h);
66+
// parametrics.add(d);
67+
// }
68+
// public RoundedCube(LengthParameter size) {
69+
// this(size,size,size);
70+
// }
7171

7272
/**
7373
* Constructor. Creates a new rounded cuboid with the specified center and

src/main/java/eu/mihosoft/vrl/v3d/Sphere.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ public Sphere(double radius) {
9191
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
9292
//
9393
// }
94-
public Sphere(LengthParameter size) {
95-
this(size.getMM());
96-
parametrics.add(size);
97-
}
98-
public Sphere(LengthParameter size, int numSlices, int numStacks) {
99-
this(size.getMM(), numSlices, numStacks);
100-
parametrics.add(size);
101-
}
94+
// public Sphere(LengthParameter size) {
95+
// this(size.getMM());
96+
// parametrics.add(size);
97+
// }
98+
// public Sphere(LengthParameter size, int numSlices, int numStacks) {
99+
// this(size.getMM(), numSlices, numStacks);
100+
// parametrics.add(size);
101+
// }
102102
/**
103103
* Constructor. Creates a sphere with the specified radius, number of slices
104104
* and stacks.

src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ private TextExtrude(String text, Font font, double dir) {
168168
// subtract.getElements().forEach(this::getPoints);
169169

170170
for (int i = 0; i < sections.size(); i++) {
171+
sections.get(i).setIsHole(false);
171172
for (CSG h : holes) {
172173
try {
173174
if (sections.get(i).isBoundsTouching(h)) {
174175
// println "Hole found "
175-
CSG nl = sections.get(i).difference(h);
176-
176+
CSG nl = sections.get(i).difference(h).setIsHole(false);
177177
sections.set(i, nl);
178178
}
179179
} catch (Exception e) {

src/main/java/eu/mihosoft/vrl/v3d/parametrics/CSGDatabase.java

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,81 @@
11
package eu.mihosoft.vrl.v3d.parametrics;
22

33
import java.io.File;
4+
import java.io.IOException;
5+
import java.nio.file.Files;
6+
import java.util.HashMap;
47
import java.util.concurrent.CopyOnWriteArrayList;
58

6-
public class CSGDatabase {
7-
private static CSGDatabaseInstance instance = new CSGDatabaseInstance(new File("CSGdatabase.json"));
8-
9-
public static void set(String key, Parameter value) {
10-
getInstance().set(key, value);
11-
}
12-
13-
public static Parameter get(String key) {
14-
return getInstance().get(key);
15-
}
16-
17-
public static void clear() {
18-
getInstance().clear();
19-
}
20-
21-
public static void addParameterListener(String key, IParameterChanged l) {
22-
getInstance().addParameterListener(key, l);
23-
}
24-
25-
public static void clearParameterListeners(String key) {
26-
getInstance().clearParameterListeners(key);
27-
}
28-
29-
public static void removeParameterListener(String key, IParameterChanged l) {
30-
getInstance().removeParameterListener(key, l);
31-
}
32-
33-
public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) {
34-
return getInstance().getParamListeners(key);
35-
}
36-
37-
public static void delete(String key) {
38-
getInstance().delete(key);
39-
}
40-
41-
public static void loadDatabaseFromFile(File f) {
42-
getInstance().loadDatabaseFromFile(f);
43-
}
44-
45-
public static String getDataBaseString() {
46-
return getInstance().getDataBaseString();
47-
}
489

49-
public static void saveDatabase() {
50-
getInstance().saveDatabase();
51-
}
52-
53-
54-
public static File getDbFile() {
55-
return getInstance().getDbFile();
56-
}
10+
import eu.mihosoft.vrl.v3d.CSG;
5711

58-
public static void reLoadDbFile() {
59-
getInstance().reLoadDbFile();
60-
}
12+
public class CSGDatabase {
13+
private static CSGDatabaseInstance instance ;
14+
// public static void set(String key, Parameter value) {
15+
// getInstance().set(key, value);
16+
// }
17+
//
18+
// public static Parameter get(String key) {
19+
// return getInstance().get(key);
20+
// }
21+
//
22+
// public static void clear() {
23+
// getInstance().clear();
24+
// }
25+
//
26+
// public static void addParameterListener(String key, IParameterChanged l) {
27+
// getInstance().addParameterListener(key, l);
28+
// }
29+
//
30+
// public static void clearParameterListeners(String key) {
31+
// getInstance().clearParameterListeners(key);
32+
// }
33+
//
34+
// public static void removeParameterListener(String key, IParameterChanged l) {
35+
// getInstance().removeParameterListener(key, l);
36+
// }
37+
//
38+
// public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) {
39+
// return getInstance().getParamListeners(key);
40+
// }
41+
//
42+
// public static void delete(String key) {
43+
// getInstance().delete(key);
44+
// }
45+
//
46+
// public static void loadDatabaseFromFile(File f) {
47+
// getInstance().loadDatabaseFromFile(f);
48+
// }
49+
//
50+
// public static String getDataBaseString() {
51+
// return getInstance().getDataBaseString();
52+
// }
53+
//
54+
// public static void saveDatabase() {
55+
// getInstance().saveDatabase();
56+
// }
57+
//
58+
//
59+
// public static File getDbFile() {
60+
// return getInstance().getDbFile();
61+
// }
62+
//
63+
// public static void reLoadDbFile() {
64+
// getInstance().reLoadDbFile();
65+
// }
6166

6267
public static CSGDatabaseInstance getInstance() {
68+
new Exception("Depricated database access!").printStackTrace();
69+
if(instance==null) {
70+
try {
71+
instance = new CSGDatabaseInstance( Files.createTempFile("CSGDatabase", ".json").toFile());
72+
} catch (IOException e) {
73+
throw new RuntimeException(e);
74+
}
75+
76+
}
6377
return instance;
6478
}
65-
6679
public static void setInstance(CSGDatabaseInstance instance) {
6780
System.out.println("\n\nCSG Instance Set here to "+instance.getDbFile().getAbsolutePath()+"\n\n");
6881
CSGDatabase.instance = instance;

0 commit comments

Comments
 (0)