--- C:/BRL-CAD/BRL-CAD GCI/voxelize/voxelizeOriginal.c ne 1 15 19:18:32 2017 +++ C:/BRL-CAD/BRL-CAD GCI/voxelize/newVoxelize2.c po 1 16 16:45:07 2017 @@ -31,0 +32 @@ +#include "bu/list.h" @@ -91,0 +93,27 @@ create_boxes(void *callBackData, int x, int y, int +struct bu_list *StreightTree(struct bu_list* stack) +{ + struct bu_list* l = stack; + if(stack->forw != BU_LIST_NULL) l->forw = StreightTree(stack-forw); + if(stack->forw != BU_LIST_NULL) BU_LIST_APPEND(StreightTree(stack-forw)); + return l; +} + +struct bu_list * +BalanceTree(struct bu_list* stack, float count) +{ + struct bu_list* l = stack; + if(stack->forw != BU_LIST_NULL && count >= 1) { + l->forw = BalanceTree(stack->forw, count / 2); + stack = stack->forw; + } + else l->forw = BU_LIST_NULL; //count is for tree end detection + + if(stack->forw != BU_LIST_NULL && count >= 1) { + l->back = BalanceTree(stack->forw, count / 2); + stack = stack->forw; + } + else l->back = BU_LIST_NULL; + + return l; +} + @@ -211,0 +240,3 @@ ged_voxelize(struct ged *gedp, int argc, const cha + + voxDat.content.l = *StreightTree(&voxDat.content.l); + voxDat.content.l = *BalanceTree(&voxDat.content.l, bu_list_len(&voxDat.content.l));