|
![](/i/fill.gif) |
In article <38C816BE.35E35A1C@hotmail.com>, Tor Olav Kristensen
<tor### [at] hotmail com> wrote:
> But what if the loop control variable is a vector that is shared
> between several nested loops? (See my example macro below.)
>
> Would this be possible with nested for-loops?
It would be possible, but not necessarily the best way to do it.
Something like this:
#macro ObjectSplit(Thing, Point1, Point2, nnv)
// Cuts an object into several "box"-parts
// Result is returned in an array of such parts
//#local nnv = <nx, ny, nz>;
#local ThingArray = array[nnv.x][nnv.y][nnv.z]
#local dPoint = (Point2 - Point1)/nnv;
#for(Cntv = <0,0,0>; Cntv.z < nnv.z; Cntv.z += 1)
#for(Cntv.y = 0; Cntv.y < nnv.y; Cntv.y += 1)
#for(Cntv.x = 0; Cntv.x < nnv.x; Cntv.x += 1)
#local ThingArray[Cntv.x][Cntv.y][Cntv.z] =
intersection {
object { Thing }
box { Point1 + dPoint*Cntv, Point1 + dPoint*(Cntv+Unitv) }
}
#end // for
#end // for
#end // for
ThingArray
#end // macro ObjectSplit
--
Chris Huff
e-mail: chr### [at] yahoo com
Web page: http://chrishuff.dhs.org/
Post a reply to this message
|
![](/i/fill.gif) |