check for 0 size and use sexy doAdjacentPairs in slicer util

nix
Pierre Alexandre Tremblay 6 years ago
parent f9fb3f869d
commit f3f1d2d2c2

@ -75,26 +75,29 @@ FluidSliceCorpus {
idx = counter; idx = counter;
OSCFunc({ OSCFunc({
tmpIndices.loadToFloatArray(action:{ |a| tmpIndices.loadToFloatArray(action:{ |a|
var sliceindex = 1;
completed = completed + 1; completed = completed + 1;
("FluidSliceCorpus:" + ( completed.asString ++ "/" ++ total)).postln; ("FluidSliceCorpus:" + ( completed.asString ++ "/" ++ total)).postln;
if(a[0] != -1){ if(a[0] != -1){
var rawPoints,slicePoints; var rawPoints = Array.newFrom(a).asInteger;
rawPoints = Array.newFrom(a).asInteger;
if(rawPoints[0] != [v[\bounds][0]]){rawPoints = [v[\bounds][0]] ++ rawPoints}; if(rawPoints[0] != [v[\bounds][0]]){rawPoints = [v[\bounds][0]] ++ rawPoints};
if(rawPoints.last != [v[\bounds][1]]){rawPoints=rawPoints ++ [v[\bounds][1]]}; if(rawPoints.last != [v[\bounds][1]]){rawPoints=rawPoints ++ [v[\bounds][1]]};
slicePoints = Array.newFrom(rawPoints).slide(2).clump(2); rawPoints.postln;
slicePoints.do{|s,j| rawPoints.doAdjacentPairs{|a,b|
var dict,label = (k ++ j).asSymbol; var dict;
dict = IdentityDictionary(); if ((b - a) >= 1){
dict.putAll(v); dict = IdentityDictionary();
dict[\bounds] = s; dict.putAll(v);
index.add(label->dict); dict[\bounds] = [a,b];
index.add(((k ++ "-" ++sliceindex).asSymbol)->dict);
sliceindex = sliceindex + 1;
}
} }
}{ }{
var dict = IdentityDictionary(); var dict = IdentityDictionary();
dict.putAll(v); dict.putAll(v);
index.add((k ++ '0').asSymbol->dict); index.add((k ++ "-1").asSymbol->dict);
}; };
if(jobs.size > 0){perf.value(tmpIndices)}{ tmpIndices.free }; if(jobs.size > 0){perf.value(tmpIndices)}{ tmpIndices.free };
if(completed == total) {action !? action.value(index)}; if(completed == total) {action !? action.value(index)};

Loading…
Cancel
Save