// -------------------------------------------------------------------------- // Some functions to manipulate arrays dynamically* // -------------------------------------------------------------------------- // // // -------------------------------------------------------------------------- // // ArrayPush() // This function is used to push a value onto the end of an array, which // increases the number of elements. The new values then become the last // elements in the array. // // Parameters : // thisArray : the array where to add element // thisValue : the value he value to be added // Return : // none - the original array is modified // // -------------------------------------------------------------------------- // // ArrayPop() // This function remove the last element of array passed to it and return // this last value. // Parameters : // thisArray : the array where to add element // Return : // the value removed // the original array is modified // // -------------------------------------------------------------------------- // // ArraySliceLeft() // This function splice the array and return a new array that contain // value from the begining to slice position (used internally). // // Parameters : // thisArray : the array // slicePos : position of the cutoff // Return : // new array // // -------------------------------------------------------------------------- // // ArraySliceRight() // This function splice the array and return a new array that contain // value from slice position to the end of the array (used internally). // Parameters : // thisArray : the array // slicePos : position of the cutoff // Return : // new array // // -------------------------------------------------------------------------- // // ArrayInsert() // This function inserts a value in the array at the index position. // The index position is clamped between zero and the size of the array. // No "out of range error". // // Parameters : // thisArray : the array // valuePos : position where to insert the element // thisValue : element value // // Return : // new array with new element // the original array is modified // // -------------------------------------------------------------------------- // // ArrayDeleteAt() // This function deletes the element at the given position. // The index position is clamped between zero and the size of the array. // No "out of range error". // // Parameters : // thisArray : the array // valuePos : position where to delete the element // thisValue : element value // // Return : // new array without new element // the original array is modified // // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // // To be used without restriction ... // Feel free to contact me kurtzlepirate@yahoo.fr - March 2023 // // -------------------------------------------------------------------------- // * : This is not true dynamic array management. With languages that have this // feature, the memory space occupied by the array is unique. Here, this is // not the case and it is not possible with POVRay. During the execution of // these macros, we can have around twice the memory used at one time. // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- #macro ArrayPush(thisArray, thisValue) #local actualSize = dimension_size(thisArray,1); #local newSize = actualSize+1; #local tmpArray = array[newSize] #local i=0; #while(i=actualSize) #local i = 0; #while(i=actualSize) #local i=0; #while(i