init_historyStack Function

private function init_historyStack(filename, id)

Uses

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(in) :: id

Return Value type(history_stack_t)


Source Code

    type(history_stack_t) function init_historyStack(filename, id)

        use utils, only : str
        use constants,    only : fileplace

        character(*), intent(in) :: filename
        integer, intent(in) :: id

        character(len=:), allocatable :: new_filename
        integer :: idx
        logical :: res
        
        idx = index(filename, ".")
        new_filename = filename(1:idx-1)//"_"//str(id,3)//filename(idx:)

        init_historyStack%filename = new_filename

        if(index(new_filename, "obj") /= 0)then
            init_historyStack%type="obj"
        elseif(index(new_filename, "ply") /= 0)then
            init_historyStack%type="ply"
        elseif(index(new_filename, "json") /= 0)then
            init_historyStack%type="json"
        else
            error stop "Unsupported filetype for track History!"
        end if

        inquire(file=trim(fileplace)//new_filename, exist=res)
        if(res)then
            print*,"Deleting existing trackHistory files!"
            call execute_command_line("rm "//trim(fileplace)//new_filename)
            call execute_command_line("rm "//trim(fileplace)//"scalars000.dat")
            call execute_command_line("rm "//trim(fileplace)//new_filename//"2")
        end if

        init_historyStack%size = 0
        init_historyStack%vertex_counter = 0
        init_historyStack%edge_counter = 0

    end function init_historyStack