You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
FluidKDTree : FluidModelObject
|
|
{
|
|
|
|
var neighbours,radius;
|
|
|
|
*new{ |server, numNeighbours = 1, radius = 0|
|
|
^super.new(server,[numNeighbours,radius ? -1])
|
|
.numNeighbours_(numNeighbours)
|
|
.radius_(radius);
|
|
}
|
|
|
|
numNeighbours_{|k|neighbours = k.asInteger; }
|
|
numNeighbours{ ^neighbours; }
|
|
|
|
radius_{|r| radius = r.asUGenInput;}
|
|
radius{ ^radius; }
|
|
|
|
prGetParams{^[this.id, this.numNeighbours,this.radius];}
|
|
|
|
fitMsg{ |dataSet| ^this.prMakeMsg(\fit,this.id,dataSet.id);}
|
|
|
|
fit{|dataSet,action|
|
|
actions[\fit] = [nil,action];
|
|
this.prSendMsg(this.fitMsg(dataSet));
|
|
}
|
|
|
|
kNearestMsg{|buffer|
|
|
^this.prMakeMsg(\kNearest,id,this.prEncodeBuffer(buffer));
|
|
}
|
|
|
|
kNearest{ |buffer, action|
|
|
actions[\kNearest] = [strings(FluidMessageResponse,_,_),action];
|
|
this.prSendMsg(this.kNearestMsg(buffer));
|
|
}
|
|
|
|
kNearestDistMsg {|buffer|
|
|
^this.prMakeMsg(\kNearestDist,id,this.prEncodeBuffer(buffer));
|
|
}
|
|
|
|
kNearestDist { |buffer, action|
|
|
actions[\kNearestDist] = [numbers(FluidMessageResponse,_,nil,_),action];
|
|
this.prSendMsg(this.kNearestDistMsg(buffer));
|
|
}
|
|
|
|
kr{|trig, inputBuffer,outputBuffer, numNeighbours = 1, lookupDataSet|
|
|
/* this.numNeighbours_(numNeighbours);
|
|
lookupDataSet = lookupDataSet ? -1;
|
|
this.lookupDataSet_(lookupDataSet);*/
|
|
|
|
^FluidKDTreeQuery.kr(trig,
|
|
this, numNeighbours, this.radius,lookupDataSet.asUGenInput,
|
|
inputBuffer,outputBuffer);
|
|
}
|
|
|
|
}
|
|
|
|
FluidKDTreeQuery : FluidRTMultiOutUGen
|
|
{
|
|
*kr{ |trig, tree, numNeighbours, radius,lookupDataSet, inputBuffer, outputBuffer |
|
|
^this.multiNew('control',trig, tree.asUGenInput, numNeighbours, radius,lookupDataSet!?(_.asUGenInput)??{-1}, inputBuffer.asUGenInput, outputBuffer.asUGenInput)
|
|
}
|
|
|
|
init { arg ... theInputs;
|
|
inputs = theInputs;
|
|
^this.initOutputs(1, rate);
|
|
}
|
|
|
|
}
|