頂点配列と三角形インデックス配列から面頂点配列(v0,v1,v2)を展開して初期化する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | vertices(:,:) | |||
| integer(kind=i32), | intent(in) | :: | faces(:,:) | |||
| type(mesh_type), | intent(out) | :: | mesh |
展開後に初期化した三角形メッシュ。 |
subroutine build_mesh_from_indexed(vertices, faces, mesh) real(dp), intent(in) :: vertices(:, :) integer(i32), intent(in) :: faces(:, :) type(mesh_type), intent(out) :: mesh real(dp), allocatable :: v0(:, :), v1(:, :), v2(:, :) integer(i32) :: i, ntri if (size(vertices, 1) /= 3 .or. size(faces, 1) /= 3) then error stop "vertices/faces shape mismatch" end if ntri = size(faces, 2) allocate (v0(3, ntri), v1(3, ntri), v2(3, ntri)) do i = 1, ntri v0(:, i) = vertices(:, faces(1, i)) v1(:, i) = vertices(:, faces(2, i)) v2(:, i) = vertices(:, faces(3, i)) end do call init_mesh(mesh, v0, v1, v2) end subroutine build_mesh_from_indexed