OBJメッシュを走査・解析し、内部 mesh_type へ変換するインポートモジュール。
与えられた行がOBJ頂点行(v)かを判定する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
判定対象の1行文字列。 |
与えられた行がOBJ面行(f)かを判定する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
判定対象の1行文字列。 |
面行に含まれる頂点トークン数を数え、扇形分割時の三角形数算出に使う。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
|
OBJファイルを2パス(件数取得→実データ読込)で読み込み、メッシュを構築する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
読み込むOBJファイルのパス。 |
||
| type(mesh_type), | intent(out) | :: | mesh |
OBJから構築した三角形メッシュ。 |
頂点配列と三角形インデックス配列から面頂点配列(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 |
展開後に初期化した三角形メッシュ。 |
OBJを行走査して頂点数と三角形分割後の面数を事前計数する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
走査対象のOBJファイルパス。 |
||
| integer(kind=i32), | intent(out) | :: | nvert |
頂点行 |
||
| integer(kind=i32), | intent(out) | :: | ntri |
頂点行 |
OBJの頂点/面行を解析し、負インデックス対応で配列へ格納する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
読み込み対象のOBJファイルパス。 |
||
| real(kind=dp), | intent(out) | :: | vertices(:,:) | |||
| integer(kind=i32), | intent(out) | :: | faces(:,:) |
OBJの1行を長さ制限なしで読み、行末の CR を除く。 固定長バッファで読むと長い面行が短い有効な面へ切り詰められるため、 非前進読込で行末まで連結する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | u |
読み込み中の装置番号。 |
||
| character(len=:), | intent(out), | allocatable | :: | line |
読み込んだ1行(行末の改行と CR を除く)。 |
|
| integer, | intent(out) | :: | ios |
0 なら1行を読んだ。ファイル終端または読込失敗では非0。 |
面行の pos 以降にある次の空白区切りトークンの範囲を返す。
計数パスと解析パスが同じ規則でトークンを数えるための共通 tokenizer。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s |
|
||
| integer, | intent(inout) | :: | pos |
走査開始位置。戻り値はトークン直後の位置。 |
||
| integer, | intent(out) | :: | first |
トークン先頭位置。トークンがなければ |
||
| integer, | intent(out) | :: | last |
トークン先頭位置。トークンがなければ |
v x y z 形式の頂点行を3次元座標へ変換する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
OBJ頂点行(例: |
||
| real(kind=dp), | intent(out) | :: | p(3) |
f 行の頂点参照を抽出し、v/vt/vn 形式から頂点インデックスのみを取り出す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
OBJ面行( |
||
| integer(kind=i32), | intent(in) | :: | nvert |
負インデックス解決に使う現在有効な頂点数。 |
||
| integer(kind=i32), | intent(out), | allocatable | :: | idx(:) |
行末の CR 文字 (char 13) をスペースに置換し、CRLF 改行の OBJ に対応する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | line |
処理対象の行文字列。 |