Skip to content

Commit 654f2f4

Browse files
committed
make the move operation validate the names against the current state.
1 parent 2909fe1 commit 654f2f4

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/CaDoodleFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public static int applyToAllConstituantElements(boolean addRet, List<String> tar
626626
continue;
627627
} catch (Exception ex) {
628628
com.neuronrobotics.sdk.common.Log.error(ex);
629-
continue;
629+
//continue;
630630
}
631631
applyToAllConstituantElements(addRet, s, back, p, depth, appliedMemory);
632632
}

src/main/java/com/neuronrobotics/bowlerstudio/scripting/cadoodle/MoveCenter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,17 @@ public List<String> getNamesAddedInThisOperation() {
126126
return names;
127127
}
128128

129-
public MoveCenter setNames(List<String> names) {
129+
public MoveCenter setNames(List<String> names,CaDoodleFile f) {
130+
131+
for(String s:names) {
132+
boolean found=false;
133+
for(CSG c:f.getCurrentState()) {
134+
if(c.getName().contentEquals(s))
135+
found=true;
136+
}
137+
if(!found)
138+
throw new RuntimeException("Set a name that does not exist!!");
139+
}
130140
this.names = names;
131141
return this;
132142
}

test/java/src/junit/bowler/CaDoodleWorkflowTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void test() throws Exception {
7676
double distaance =10;
7777
MoveCenter move = new MoveCenter()
7878
.setLocation(new TransformNR(distaance,0,0))
79-
.setNames(Arrays.asList(nameTwo))
79+
.setNames(Arrays.asList(nameTwo),cf)
8080
;
8181
cf.addOpperation(move).join();;
8282
back=cf.getCurrentState();
@@ -106,11 +106,11 @@ public void test() throws Exception {
106106
loaded.back();
107107
MoveCenter move2 = new MoveCenter()
108108
.setLocation(new TransformNR(distaance,distaance,0))
109-
.setNames(Arrays.asList(nameOne))
109+
.setNames(Arrays.asList(nameOne),loaded)
110110
;
111111
MoveCenter move3 = new MoveCenter()
112112
.setLocation(new TransformNR(0,0,0,new RotationNR(0,45,0)))
113-
.setNames(Arrays.asList(nameOne))
113+
.setNames(Arrays.asList(nameOne),loaded)
114114
;
115115
loaded.addOpperation(move3).join();;
116116
back=loaded.getCurrentState();

0 commit comments

Comments
 (0)