GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
DesignLab
map_file_importer.cpp
[詳解]
1
3
4
// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5
// Released under the MIT license
6
// https://opensource.org/licenses/mit-license.php
7
8
#include "
map_file_importer.h
"
9
10
#include <fstream>
11
#include <sstream>
12
#include <vector>
13
14
#include "
cmdio_util.h
"
15
16
17
namespace
designlab
18
{
19
20
std::optional<MapState>
MapFileImporter::ImportMap
(
const
std::string& file_path)
const
noexcept
21
{
22
// ファイルを開く.
23
std::ifstream ifs(file_path);
24
25
// ファイルが開けないならば false を返す.
26
if
(!ifs.is_open())
27
{
28
CmdIOUtil::Output
(
"ファイルを開けませんでした."
,
OutputDetail::kError
);
29
30
return
std::nullopt;
31
}
32
33
// ファイルを1行ずつ読み込み,Mapに追加する.
34
std::vector<Vector3> map_point;
35
36
std::string line;
37
38
while
(std::getline(ifs, line))
39
{
40
std::istringstream iss(line);
41
42
try
43
{
44
Vector3
point;
45
iss >> point;
46
47
map_point.push_back(point);
48
}
49
catch
(...)
50
{
51
CmdIOUtil::Output
(
"読み込むことができないデータがあったため無視します."
,
52
OutputDetail::kWarning
);
53
}
54
}
55
56
return
MapState
(map_point);
57
}
58
59
}
// namespace designlab
designlab::CmdIOUtil::Output
static void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
Definition
cmdio_util.cpp:56
designlab::MapFileImporter::ImportMap
std::optional< MapState > ImportMap(const std::string &file_path) const noexcept
マップを csv に出力したものを読み込む.
Definition
map_file_importer.cpp:20
designlab::MapState
マップを表すクラス.
Definition
map_state.h:32
cmdio_util.h
map_file_importer.h
designlab
Definition
abstract_dxlib_gui.cpp:18
designlab::OutputDetail::kError
@ kError
エラーメッセージ.
designlab::OutputDetail::kWarning
@ kWarning
警告メッセージ,エラーではないが注意が必要なメッセージ.
designlab::Vector3
3次元の位置ベクトルを表す構造体.
Definition
math_vector3.h:40
構築:
1.9.8