旧実装と同じ線形探索で最初の命中要素を探索する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| real(kind=dp), | intent(in) | :: | seg_min(3) | |||
| real(kind=dp), | intent(in) | :: | seg_max(3) | |||
| type(hit_info), | intent(inout) | :: | hit | |||
| real(kind=dp), | intent(inout) | :: | best_t | |||
| logical, | intent(in) | :: | use_box_filter | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | box_tol | |||
| logical, | intent(in) | :: | require_elem_inside |
subroutine find_first_hit_base_linear( & mesh, p0, p1, seg_min, seg_max, hit, best_t, use_box_filter, box_min, box_max, box_tol, require_elem_inside & ) type(mesh_type), intent(in) :: mesh real(dp), intent(in) :: p0(3), p1(3), seg_min(3), seg_max(3) type(hit_info), intent(inout) :: hit real(dp), intent(inout) :: best_t logical, intent(in) :: use_box_filter real(dp), intent(in) :: box_min(3), box_max(3), box_tol logical, intent(in) :: require_elem_inside integer(i32) :: i logical :: ok real(dp) :: t, h(3) do i = 1, mesh%nelem if (use_box_filter) then if (.not. segment_bbox_overlap_precomputed(mesh%bb_min(:, i), mesh%bb_max(:, i), box_min, box_max)) cycle if (require_elem_inside) then if (.not. bbox_inside_box(mesh%bb_min(:, i), mesh%bb_max(:, i), box_min, box_max, box_tol)) cycle end if end if if (.not. segment_bbox_overlap_precomputed(seg_min, seg_max, mesh%bb_min(:, i), mesh%bb_max(:, i))) cycle call segment_triangle_intersect(p0, p1, mesh%v0(:, i), mesh%v1(:, i), mesh%v2(:, i), ok, t, h) if (.not. ok) cycle if (use_box_filter) then if (.not. point_inside_box(h, box_min, box_max, box_tol)) cycle end if if (t < best_t) then best_t = t hit%has_hit = .true. hit%elem_idx = i hit%t = t hit%pos = h hit%pos_wrapped = h hit%image_shift = 0_i32 end if end do end subroutine find_first_hit_base_linear