segment_artist_pick Subroutine

private subroutine segment_artist_pick(a, frame, cam, m, hits, n)

A segment artist's best hit: on the segments drawn (as drawn: relative ends included; a segment of no length isn't drawn).

Arguments

Type IntentOptional Attributes Name
class(SegmentArtist), intent(in), target :: a

the artist

class(ReferenceFrame), intent(in), target :: frame

the frame drawing it (for the hit)

type(PickCamera), intent(in) :: cam

the pick camera

real(kind=wp), intent(in) :: m(4,4)

the frame's transform to the root frame

type(PickHit), intent(inout), allocatable :: hits(:)

hits are added to hits(1:n)

integer, intent(inout) :: n

number of hits


Calls

proc~~segment_artist_pick~~CallsGraph proc~segment_artist_pick segment_artist_pick num_times num_times proc~segment_artist_pick->num_times proc~add_pick_hit add_pick_hit proc~segment_artist_pick->proc~add_pick_hit proc~better better proc~segment_artist_pick->proc~better proc~drawn_segment SegmentArtist%drawn_segment proc~segment_artist_pick->proc~drawn_segment proc~segment_pick segment_pick proc~segment_artist_pick->proc~segment_pick proc~point LineChain%point proc~drawn_segment->proc~point proc~project project proc~segment_pick->proc~project proc~line_buffer line_buffer proc~point->proc~line_buffer interface~vkf_line_points vkf_line_points proc~line_buffer->interface~vkf_line_points

Called by

proc~~segment_artist_pick~~CalledByGraph proc~segment_artist_pick segment_artist_pick proc~drawable_pick DrawableTrajectory%drawable_pick proc~drawable_pick->proc~segment_artist_pick

Source Code

    subroutine segment_artist_pick(a, frame, cam, m, hits, n)
        class(SegmentArtist), intent(in), target :: a !! the artist
        class(ReferenceFrame), intent(in), target :: frame  !! the frame drawing it (for the hit)
        type(PickCamera), intent(in) :: cam         !! the pick camera
        real(wp), intent(in) :: m(4,4)              !! the frame's transform to the root frame
        type(PickHit), allocatable, intent(inout) :: hits(:)  !! hits are added to hits(1:n)
        integer, intent(inout) :: n                 !! number of hits
        real(wp) :: extra, a0(3), b0(3), px, s, depth, best_px, best_depth, best_s
        integer :: k, best_k
        type(PickHit) :: h
        if (.not. associated(a%traj) .or. a%n_drawn < 1) return
        extra = 0.5_wp * a%width_ * cam%pixel_ratio
        best_px = huge(1.0_wp)
        best_depth = huge(1.0_wp)
        best_k = 0
        best_s = 0.0_wp
        do k = a%first_drawn_, a%first_drawn_ + a%n_drawn - 1
            call a%drawn_segment(k, a0, b0)
            if (all(a0 == b0)) cycle
            if (segment_pick(cam, matmul(m(1:3, 1:3), a0) + m(1:3, 4), matmul(m(1:3, 1:3), b0) + m(1:3, 4), &
                             px, s, depth, extra)) then
                if (better(px, depth, best_px, best_depth)) then
                    best_px = px
                    best_depth = depth
                    best_k = k
                    best_s = s
                end if
            end if
        end do
        if (best_k == 0) return
        call a%drawn_segment(best_k, a0, b0)
        h%kind = PICK_SEGMENT
        h%frame => frame
        h%artist => a
        h%trajectory => a%traj
        h%index = best_k
        h%time = a%traj%time(min(a%traj%num_times(), 1 + (best_k - 1) * a%stride_))
        h%local = a0 + best_s * (b0 - a0)
        h%position = matmul(m(1:3, 1:3), h%local) + m(1:3, 4)
        h%distance = best_depth
        h%pixels = best_px
        call add_pick_hit(hits, n, h)
    end subroutine segment_artist_pick