Skip to content

Commit fd7de89

Browse files
committed
Add an exception to getting the manipulator without checking it first.
also do not set an invalid one
1 parent 739c4b4 commit fd7de89

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,12 @@ public MeshView newMesh() {
346346
current.getTransforms().clear();
347347

348348
if (hasManipulator)
349-
current.getTransforms().add(getManipulator());
349+
try {
350+
current.getTransforms().add(getManipulator());
351+
} catch (MissingManipulatorException e) {
352+
// TODO Auto-generated catch block
353+
e.printStackTrace();
354+
}
350355
if (hasAssembly)
351356
current.getTransforms().add((Affine) getAssemblyStorage().getValue("AssembleAffine").get());
352357

@@ -2913,9 +2918,9 @@ public CSG makeKeepaway(Number sn) {
29132918
public boolean hasManipulator() {
29142919
return manipulator.get(uniqueId) != null;
29152920
}
2916-
public Affine getManipulator() {
2921+
public Affine getManipulator() throws MissingManipulatorException{
29172922
if (!hasManipulator() )
2918-
manipulator.put(uniqueId, new Affine());
2923+
throw new MissingManipulatorException("Can not get a manipulator that does not exist");
29192924
return manipulator.get(uniqueId);
29202925
}
29212926

@@ -3140,7 +3145,12 @@ public CSG regenerate() {
31403145
CSG regenerate2 = regenerate.get(getUniqueId()).regenerate(this);
31413146
if (regenerate2 != null) {
31423147
if(hasManipulator())
3143-
regenerate2.setManipulator(this.getManipulator());
3148+
try {
3149+
regenerate2.setManipulator(this.getManipulator());
3150+
} catch (MissingManipulatorException e) {
3151+
// TODO Auto-generated catch block
3152+
e.printStackTrace();
3153+
}
31443154
return regenerate2.historySync(this);
31453155
}
31463156
return this;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package eu.mihosoft.vrl.v3d;
2+
3+
public class MissingManipulatorException extends Exception {
4+
5+
public MissingManipulatorException(String string) {
6+
super(string);
7+
}
8+
9+
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.google.gson.reflect.TypeToken;
1919

2020
import eu.mihosoft.vrl.v3d.CSG;
21+
import eu.mihosoft.vrl.v3d.MissingManipulatorException;
2122

2223
public class CSGDatabaseInstance {
2324

@@ -101,7 +102,12 @@ public CSGDatabaseInstance setParameterNewValue(CSG instance, String key, double
101102
if (function != null) {
102103
CSG setManipulator = function.change(instance, key, new Long((long) (newValue * 1000)));
103104
if(setManipulator.hasManipulator())
104-
setManipulator.setManipulator(instance.getManipulator());
105+
try {
106+
setManipulator.setManipulator(instance.getManipulator());
107+
} catch (MissingManipulatorException e) {
108+
// TODO Auto-generated catch block
109+
e.printStackTrace();
110+
}
105111
setManipulator.setColor(instance.getColor());
106112
return this;
107113
}

src/main/java/eu/mihosoft/vrl/v3d/thumbnail/ThumbnailImage.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import eu.mihosoft.vrl.v3d.Bounds;
1212
import eu.mihosoft.vrl.v3d.CSG;
13+
import eu.mihosoft.vrl.v3d.MissingManipulatorException;
1314
import eu.mihosoft.vrl.v3d.Vector3d;
1415
import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance;
1516
import javafx.scene.Group;
@@ -71,7 +72,12 @@ public static WritableImage get(List<CSG> c,CSGDatabaseInstance instance) {
7172
ArrayList<CSG> csgList = new ArrayList<CSG>();
7273
for (CSG cs : c) {
7374
if (cs.hasManipulator()) {
74-
csgList.add(cs.transformed(TransformConverter.fromAffine(cs.getManipulator())).syncProperties(instance,cs));
75+
try {
76+
csgList.add(cs.transformed(TransformConverter.fromAffine(cs.getManipulator())).syncProperties(instance,cs));
77+
} catch (MissingManipulatorException e) {
78+
// TODO Auto-generated catch block
79+
e.printStackTrace();
80+
}
7581
} else
7682
csgList.add(cs);
7783
}

0 commit comments

Comments
 (0)