GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
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
17namespace designlab
18{
19
20std::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("読み込むことができないデータがあったため無視します.",
53 }
54 }
55
56 return MapState(map_point);
57}
58
59} // namespace designlab
static void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
std::optional< MapState > ImportMap(const std::string &file_path) const noexcept
マップを csv に出力したものを読み込む.
マップを表すクラス.
Definition map_state.h:32
@ kError
エラーメッセージ.
@ kWarning
警告メッセージ,エラーではないが注意が必要なメッセージ.
3次元の位置ベクトルを表す構造体.