|
![](/i/fill.gif) |
Some time ago I promised to prepare macros for arrays.inc. Here they are.
I prepared multi resize version, asked for inclusion and I'm sure it was
atached at least in one beta distribution but I can't find it at this
moment so I don't know should I add multi dimensional exceptions of below
macros. I hope my interpretation of destination is correct.
related posts :
http://news.povray.org/madqttov353hsu8gaef92809kscol9pre3%404ax.com
http://news.povray.org/jsl5rt43ngjm9bsg59ishf03u4ghm4621c%404ax.com
#macro Insert_In_Array(Item, DestArray, Index)
#if( dimensions( DestArray ) = 1 )
#local Size = dimension_size( DestArray , 1 );
#if(Index>=Size)
Resize_Array( DestArray , Index + 1 )
#end
#declare DestArray[ Index ] = Item;
#else
#error "Can't insert in multi dimensional array"
#end
#end
#macro Insert_Array_In_Array(ItemArray, DestArray, Index)
#if( dimensions( DestArray ) = 1 )
#if( dimensions( ItemArray ) = 1 )
#local Size = dimension_size( DestArray , 1 );
#local Insert_Size = dimension_size( ItemArray , 1 );
#if((Index+Insert_Size)>Size)
Resize_Array( DestArray , Index+Insert_Size )
#end
#local C=0;
#while (C<Insert_Size)
#ifdef(ItemArray[C])
#declare DestArray[C+Index] = ItemArray[C];
#end
#local C=C+1;
#end
#else
#error "Can't insert multi dimensional array in single dimensional array"
#end
#else
#error "Can't insert in multi dimensional array"
#end
#end
#macro Append_To_Array(Item, DestArray, Index)
#if( dimensions( DestArray ) = 1 )
#local Size = dimension_size( DestArray , 1 );
#if(Index>=Size)
Insert_In_Array(Item, DestArray, Index)
#else
#local Array = array[ Size+1 ];
#local Array[ Index ] = Item;
#local C=0;
#while (C<Size)
#ifdef( DestArray[ C ] )
#declare Array[ C+(C>=Index) ] = DestArray[ C ];
#end
#local C=C+1;
#end
#declare DestArray = Array;
#end
#else
#error "Can't append to multi dimensional array"
#end
#end
#macro Append_Array_To_Array(ItemArray, DestArray, Index)
#if( dimensions( DestArray ) = 1 )
#if( dimensions( ItemArray ) = 1 )
#local Size = dimension_size( DestArray , 1 );
#if(Index>=Size)
Insert_Array_In_Array(ItemArray, DestArray, Index)
#else
#local Insert_Size = dimension_size( ItemArray , 1 );
#local Array = array[ Size + Insert_Size ];
#local C=Insert_Size;
#while (C>0)
#local C=C-1;
#ifdef( ItemArray[ C ] )
#local Array[ Index + C] = ItemArray[ C ];
#end
#end
#while (C<Size)
#ifdef( DestArray[ C ] )
#local Array[ C+Insert_Size*(C>=Index) ] = DestArray[ C ];
#end
#local C=C+1;
#end
#declare DestArray = Array;
#end
#else
#error "Can't append multi dimensional array to single dimensional array"
#end
#else
#error "Can't append to multi dimensional array"
#end
#end
ABX
Post a reply to this message
|
![](/i/fill.gif) |