Chunks for at least n points (at least one chunk). Separate segments and ribbons: chunks hold whole pairs (n should be even).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(LineChain), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | n |
number of points to hold |
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