reserve Subroutine

private subroutine reserve(self, n)

Chunks for at least n points (at least one chunk). Separate segments and ribbons: chunks hold whole pairs (n should be even).

Type Bound

LineChain

Arguments

Type IntentOptional Attributes Name
class(LineChain), intent(inout) :: self
integer, intent(in) :: n

number of points to hold


Calls

proc~~reserve~~CallsGraph proc~reserve LineChain%reserve interface~vkf_compile_node vkf_compile_node proc~reserve->interface~vkf_compile_node interface~vkf_line_create vkf_line_create proc~reserve->interface~vkf_line_create interface~vkf_line_create_colored vkf_line_create_colored proc~reserve->interface~vkf_line_create_colored interface~vkf_marker_create vkf_marker_create proc~reserve->interface~vkf_marker_create interface~vkf_node_add_child vkf_node_add_child proc~reserve->interface~vkf_node_add_child interface~vkf_ribbon_create vkf_ribbon_create proc~reserve->interface~vkf_ribbon_create proc~apply_style apply_style proc~reserve->proc~apply_style proc~check_status check_status proc~reserve->proc~check_status proc~line_set_segments line_set_segments proc~reserve->proc~line_set_segments proc~move_chunks move_chunks proc~reserve->proc~move_chunks proc~apply_style->proc~check_status interface~vkf_line_set_dash_mode vkf_line_set_dash_mode proc~apply_style->interface~vkf_line_set_dash_mode interface~vkf_line_set_highlight vkf_line_set_highlight proc~apply_style->interface~vkf_line_set_highlight interface~vkf_line_set_trail vkf_line_set_trail proc~apply_style->interface~vkf_line_set_trail proc~line_set_pattern line_set_pattern proc~apply_style->proc~line_set_pattern proc~line_set_style line_set_style proc~apply_style->proc~line_set_style proc~marker_set_style marker_set_style proc~apply_style->proc~marker_set_style interface~vkf_line_style vkf_line_style proc~line_set_segments->interface~vkf_line_style interface~vkf_line_style_changed vkf_line_style_changed proc~line_set_segments->interface~vkf_line_style_changed proc~line_set_pattern->interface~vkf_line_style proc~line_set_pattern->interface~vkf_line_style_changed proc~line_set_style->interface~vkf_line_style proc~line_set_style->interface~vkf_line_style_changed proc~marker_set_style->interface~vkf_line_style proc~marker_set_style->interface~vkf_line_style_changed

Called by

proc~~reserve~~CalledByGraph proc~reserve LineChain%reserve proc~build_marker_nodes build_marker_nodes proc~build_marker_nodes->proc~reserve proc~chain_build ChainArtist%chain_build proc~chain_build->proc~reserve proc~segment_build SegmentArtist%segment_build proc~segment_build->proc~reserve proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~reserve proc~segments_build_contents CustomLineSegments%segments_build_contents proc~segments_build_contents->proc~reserve proc~write_changed write_changed proc~write_changed->proc~reserve proc~write_intermediates write_intermediates proc~write_intermediates->proc~reserve proc~write_segments~2 write_segments proc~write_segments~2->proc~reserve proc~add_intermediates add_intermediates proc~add_intermediates->proc~write_intermediates proc~chain_update ChainArtist%chain_update proc~chain_update->proc~write_changed proc~curve_update CurveArtist%curve_update proc~curve_update->proc~write_changed proc~marker_build MarkerArtist%marker_build proc~marker_build->proc~build_marker_nodes proc~rebuild_markers rebuild_markers proc~rebuild_markers->proc~build_marker_nodes proc~segments_late_update CustomLineSegments%segments_late_update proc~segments_late_update->proc~write_segments~2 proc~marker_set_point_colors MarkerArtist%marker_set_point_colors proc~marker_set_point_colors->proc~rebuild_markers proc~marker_update MarkerArtist%marker_update proc~marker_update->proc~add_intermediates proc~marker_update->proc~rebuild_markers proc~set_marker_image MarkerArtist%set_marker_image proc~set_marker_image->proc~rebuild_markers

Source Code

    subroutine reserve(self, n)
        class(LineChain), intent(inout) :: self
        integer, intent(in) :: n                !! number of points to hold
        type(LineChunk), allocatable :: tmp(:)
        type(LineChunk) :: c
        integer :: covered
        covered = 0
        if (self%n_chunks > 0) covered = self%chunks(self%n_chunks)%first + self%chunks(self%n_chunks)%capacity - 1
        do while (self%n_chunks == 0 .or. covered < n)
            if (self%n_chunks == 0) then
                c%first = 1
                c%capacity = max(min_chunk, min(max_chunk, n))       ! the data so far, up to max_chunk
            else if (self%kind == CHAIN_STRIP) then
                c%first = covered                              ! sharing the previous chunk's last point
                c%capacity = min(max_chunk, max(min_chunk, covered, n - covered + 1))
            else if (self%kind == CHAIN_RIBBON) then
                c%first = covered - 1                          ! sharing the previous chunk's last pair
                c%capacity = min(max_chunk, max(min_chunk, covered, n - covered + 2))
            else
                c%first = covered + 1
                c%capacity = min(max_chunk, max(min_chunk, covered, n - covered))
            end if
            if (self%kind == CHAIN_SEGMENTS .or. self%kind == CHAIN_RIBBON) c%capacity = c%capacity + modulo(c%capacity, 2)
            if (self%kind == CHAIN_MARKERS) then
                c%line = vkf_marker_create(int(c%capacity, c_int), self%image, merge(1_c_int, 0_c_int, self%colored))
            else if (self%kind == CHAIN_RIBBON) then
                c%line = vkf_ribbon_create(int(c%capacity, c_int), merge(1_c_int, 0_c_int, self%colored))
            else
                if (self%colored) then
                    c%line = vkf_line_create_colored(int(c%capacity, c_int))
                else
                    c%line = vkf_line_create(int(c%capacity, c_int))
                end if
            end if
            if (.not. c_associated(c%line)) return
            if (self%kind == CHAIN_SEGMENTS) call check_status(line_set_segments(c%line, .true.), 'trajectory artists')
            call apply_style(self, c%line)
            if (self%compile_new) call check_status(vkf_compile_node(c%line), 'trajectory artists')
            call check_status(vkf_node_add_child(self%group, c%line), 'trajectory artists')
            if (.not. allocated(self%chunks)) allocate(self%chunks(4))
            if (self%n_chunks == size(self%chunks)) then
                allocate(tmp(2 * self%n_chunks))
                call move_chunks(self%chunks(1:self%n_chunks), tmp(1:self%n_chunks))
                call move_alloc(tmp, self%chunks)
            end if
            self%n_chunks = self%n_chunks + 1
            self%chunks(self%n_chunks) = c
            covered = c%first + c%capacity - 1
        end do
    end subroutine reserve