GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
map_file_exporter.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_exporter.h"
9
10#include <fstream>
11
12#include "cmdio_util.h"
13
14
15namespace designlab
16{
17
18bool MapFileExporter::ExportMap(const std::string& file_path,
19 const MapState& map_state) const noexcept
20{
21 // ファイルを開く.
22 std::ofstream ofs(file_path);
23
24 // ファイルが開けないならば false を返す.
25 if (!ofs.is_open())
26 {
27 CmdIOUtil::Output("ファイルを開けませんでした.", OutputDetail::kError);
28
29 return false;
30 }
31
32 // ファイルを1行ずつ書き込む.
33 const size_t map_point_size = map_state.GetMapPointSize();
34
35 for (size_t i = 0; i < map_point_size; ++i)
36 {
37 ofs << map_state.GetMapPoint(i) << std::endl;
38 }
39
40 return true;
41}
42
43} // namespace designlab
static void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
bool ExportMap(const std::string &file_path, const MapState &map_state) const noexcept
マップを csv に出力する.
マップを表すクラス.
Definition map_state.h:32
@ kError
エラーメッセージ.