2022-03-31 22:14:11 +02:00
|
|
|
!-----------------------------------------------------
|
|
|
|
! VOXELIZE
|
|
|
|
! ========
|
2022-04-03 06:44:24 +02:00
|
|
|
! this is the main program, see also mkvoxvidz.sh
|
|
|
|
! showvoxels.pov and vox2inc.awk
|
2022-03-31 22:14:11 +02:00
|
|
|
!-----------------------------------------------------
|
|
|
|
program voxelize
|
|
|
|
use fraktals
|
|
|
|
|
2022-04-03 06:44:24 +02:00
|
|
|
integer, parameter :: DIM = 100
|
2022-03-31 22:14:11 +02:00
|
|
|
integer, dimension(:,:,:), allocatable :: cube
|
|
|
|
type(t_point3d), dimension(:), allocatable :: points
|
2022-04-03 06:44:24 +02:00
|
|
|
integer :: errcode, foo, maxi
|
2022-03-31 22:14:11 +02:00
|
|
|
integer :: ix, iy, iz
|
|
|
|
double precision, dimension(4) :: coefs
|
2022-04-03 06:44:24 +02:00
|
|
|
double precision :: dval
|
2022-03-31 22:14:11 +02:00
|
|
|
|
2022-04-03 06:44:24 +02:00
|
|
|
! XXX foo = (DIM*DIM*DIM) / (1024)
|
|
|
|
! XXX PRINT *, "memory request for cube (in Kwords) ", foo
|
2022-03-31 22:14:11 +02:00
|
|
|
|
|
|
|
allocate (cube(DIM,DIM,DIM), stat=errcode)
|
|
|
|
if (0 .NE. errcode) then
|
|
|
|
STOP " : NO ENOUGH MEMORY FOR CUBE"
|
|
|
|
endif
|
|
|
|
|
2022-04-03 06:44:24 +02:00
|
|
|
nbr_points = 3500000
|
2022-03-31 22:14:11 +02:00
|
|
|
allocate(points(nbr_points), stat=errcode)
|
|
|
|
if (0 .NE. errcode) then
|
|
|
|
STOP " : NO ENOUGH MEMORY FOR POINTS"
|
|
|
|
endif
|
|
|
|
|
|
|
|
coefs(1) = 2.24 ; coefs(2) = 0.43
|
|
|
|
coefs(3) = -0.65 ; coefs(4) = -2.43
|
|
|
|
call compute_pickover(points, coefs)
|
|
|
|
|
|
|
|
call clear_cube(cube)
|
|
|
|
|
2022-04-03 06:44:24 +02:00
|
|
|
! and now, we loop over all the pre-computed
|
|
|
|
! points of the attractor
|
|
|
|
!
|
2022-03-31 22:14:11 +02:00
|
|
|
do foo=1, nbr_points
|
2022-04-03 06:44:24 +02:00
|
|
|
call fcoor2icoor(points(foo)%x, ix)
|
|
|
|
call fcoor2icoor(points(foo)%y, iy)
|
|
|
|
call fcoor2icoor(points(foo)%z, iz)
|
|
|
|
cube(ix,iy,iz) = cube(ix,iy,iz) + 1
|
2022-03-31 22:14:11 +02:00
|
|
|
enddo
|
2022-04-03 06:44:24 +02:00
|
|
|
|
|
|
|
dval = DBLE(MAXVAL(cube))
|
|
|
|
|
|
|
|
write(0, *) "--- cube maximum = ", dval
|
|
|
|
|
|
|
|
do foo=1, nbr_points
|
|
|
|
call fcoor2icoor(points(foo)%x, ix)
|
|
|
|
call fcoor2icoor(points(foo)%y, iy)
|
|
|
|
call fcoor2icoor(points(foo)%z, iz)
|
|
|
|
print *, ix, iy, iz, &
|
|
|
|
cube(ix,iy,iz), &
|
|
|
|
DBLE(cube(ix,iy,iz)) / dval
|
|
|
|
enddo
|
|
|
|
|
2022-03-31 22:14:11 +02:00
|
|
|
!-----------------------------------------------------
|
|
|
|
contains
|
|
|
|
!-----------------------------------------------------
|
2022-04-03 06:44:24 +02:00
|
|
|
! or maybe, we can write a function ?
|
|
|
|
subroutine fcoor2icoor(in, out)
|
|
|
|
double precision, intent(in) :: in
|
|
|
|
integer, intent(out) :: out
|
|
|
|
double precision :: invalue
|
|
|
|
integer :: outvalue
|
|
|
|
|
|
|
|
invalue = (in + 2.0) / 2.0
|
|
|
|
outvalue = int(invalue * real(DIM/2))
|
|
|
|
|
|
|
|
! add molly-guard here
|
|
|
|
out = outvalue
|
|
|
|
if (outvalue .LT. 1) out = 1
|
|
|
|
if (outvalue .GE. DIM) out = DIM-1
|
|
|
|
|
|
|
|
end subroutine
|
|
|
|
!-----------------------------------------------------
|
|
|
|
|
|
|
|
subroutine clear_cube(cube)
|
|
|
|
type(integer), dimension(:,:,:), intent(out) :: cube
|
|
|
|
|
|
|
|
integer :: i, j, k
|
|
|
|
|
|
|
|
do i=lbound(cube, 1), ubound(cube, 1)
|
|
|
|
do j=lbound(cube, 2), ubound(cube, 2)
|
|
|
|
do k=lbound(cube, 3), ubound(cube, 3)
|
|
|
|
cube(i, j, k) = 0
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
end subroutine
|
2022-03-31 22:14:11 +02:00
|
|
|
!-----------------------------------------------------
|
|
|
|
end program voxelize
|
|
|
|
!-----------------------------------------------------
|
|
|
|
|