parse_face_line Subroutine

public subroutine parse_face_line(line, nvert, idx)

f 行の頂点参照を抽出し、v/vt/vn 形式から頂点インデックスのみを取り出す。

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: line

OBJ面行(f i j k ...)。

integer(kind=i32), intent(in) :: nvert

負インデックス解決に使う現在有効な頂点数。

integer(kind=i32), intent(out), allocatable :: idx(:)

Calls

proc~~parse_face_line~~CallsGraph proc~parse_face_line parse_face_line proc~count_face_tokens count_face_tokens proc~parse_face_line->proc~count_face_tokens proc~next_face_token next_face_token proc~parse_face_line->proc~next_face_token proc~count_face_tokens->proc~next_face_token

Called by

proc~~parse_face_line~~CalledByGraph proc~parse_face_line parse_face_line proc~parse_obj parse_obj proc~parse_obj->proc~parse_face_line proc~load_obj_mesh load_obj_mesh proc~load_obj_mesh->proc~parse_obj proc~build_parts_mesh build_parts_mesh proc~build_parts_mesh->proc~load_obj_mesh proc~build_mesh_from_config build_mesh_from_config proc~build_mesh_from_config->proc~build_parts_mesh proc~load_or_init_run_state load_or_init_run_state proc~load_or_init_run_state->proc~build_mesh_from_config program~main main program~main->proc~load_or_init_run_state

Source Code

  subroutine parse_face_line(line, nvert, idx)
    character(len=*), intent(in) :: line
    integer(i32), intent(in) :: nvert
    integer(i32), allocatable, intent(out) :: idx(:)
    character(len=:), allocatable :: s
    integer :: pos, first, last, slash, k
    integer(i32) :: vi

    s = trim(adjustl(line))
    allocate (idx(count_face_tokens(s)))
    pos = 3
    do k = 1, size(idx)
      call next_face_token(s, pos, first, last)
      slash = index(s(first:last), '/')
      if (slash > 0) last = first + slash - 2
      read (s(first:last), *) vi
      if (vi < 0) vi = nvert + vi + 1
      if (vi <= 0 .or. vi > nvert) error stop "OBJ face index out of range"
      idx(k) = vi
    end do
  end subroutine parse_face_line