ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
FileFormatIO.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "io/FileFormatIO.h"
9 
10 #include <FileSystem.h>
11 
12 #include <map>
13 
14 namespace cloudViewer {
15 namespace io {
16 static std::map<std::string, FileGeometry (*)(const std::string&)> gExt2Func = {
17  {"glb", ReadFileGeometryTypeGLTF},
18  {"gltf", ReadFileGeometryTypeGLTF},
19  {"obj", ReadFileGeometryTypeOBJ},
20  {"fbx", ReadFileGeometryTypeFBX},
21  {"off", ReadFileGeometryTypeOFF},
22  {"pcd", ReadFileGeometryTypePCD},
23  {"ply", ReadFileGeometryTypePLY},
24  {"pts", ReadFileGeometryTypePTS},
25  {"stl", ReadFileGeometryTypeSTL},
26  {"xyz", ReadFileGeometryTypeXYZ},
27  {"xyzn", ReadFileGeometryTypeXYZN},
28  {"xyzrgb", ReadFileGeometryTypeXYZRGB},
29 };
30 
31 FileGeometry ReadFileGeometryType(const std::string& path) {
32  auto ext =
34  auto it = gExt2Func.find(ext);
35  if (it != gExt2Func.end()) {
36  return it->second(path);
37  } else {
38  return CONTENTS_UNKNOWN;
39  }
40 }
41 
42 } // namespace io
43 } // namespace cloudViewer
FileGeometry ReadFileGeometryTypePCD(const std::string &path)
FileGeometry ReadFileGeometryTypePTS(const std::string &path)
FileGeometry ReadFileGeometryType(const std::string &path)
static std::map< std::string, FileGeometry(*)(const std::string &)> gExt2Func
FileGeometry ReadFileGeometryTypeOFF(const std::string &path)
FileGeometry ReadFileGeometryTypeXYZ(const std::string &path)
FileGeometry ReadFileGeometryTypeOBJ(const std::string &path)
FileGeometry ReadFileGeometryTypeGLTF(const std::string &path)
FileGeometry ReadFileGeometryTypeXYZN(const std::string &path)
FileGeometry ReadFileGeometryTypePLY(const std::string &path)
FileGeometry ReadFileGeometryTypeSTL(const std::string &path)
FileGeometry ReadFileGeometryTypeFBX(const std::string &path)
FileGeometry ReadFileGeometryTypeXYZRGB(const std::string &path)
static const std::string path
Definition: PointCloud.cpp:59
std::string GetFileExtensionInLowerCase(const std::string &filename)
Definition: FileSystem.cpp:281
Generic file read and write utility for python interface.