Skip to content

Commit 1e25269

Browse files
committed
removed namespace obj_io
1 parent 311522e commit 1e25269

File tree

11 files changed

+573
-502
lines changed

11 files changed

+573
-502
lines changed

.vscode/settings.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,72 @@
33
"cmake.ctestArgs": [
44
"--verbose"
55
],
6+
"files.associations": {
7+
"algorithm": "cpp",
8+
"array": "cpp",
9+
"cctype": "cpp",
10+
"chrono": "cpp",
11+
"cmath": "cpp",
12+
"cstddef": "cpp",
13+
"cstdint": "cpp",
14+
"cstdio": "cpp",
15+
"cstdlib": "cpp",
16+
"cstring": "cpp",
17+
"ctime": "cpp",
18+
"cwchar": "cpp",
19+
"deque": "cpp",
20+
"exception": "cpp",
21+
"fstream": "cpp",
22+
"functional": "cpp",
23+
"initializer_list": "cpp",
24+
"iomanip": "cpp",
25+
"ios": "cpp",
26+
"iosfwd": "cpp",
27+
"iostream": "cpp",
28+
"istream": "cpp",
29+
"iterator": "cpp",
30+
"limits": "cpp",
31+
"list": "cpp",
32+
"locale": "cpp",
33+
"map": "cpp",
34+
"memory": "cpp",
35+
"new": "cpp",
36+
"optional": "cpp",
37+
"ostream": "cpp",
38+
"random": "cpp",
39+
"ratio": "cpp",
40+
"regex": "cpp",
41+
"set": "cpp",
42+
"sstream": "cpp",
43+
"stack": "cpp",
44+
"stdexcept": "cpp",
45+
"streambuf": "cpp",
46+
"string": "cpp",
47+
"string_view": "cpp",
48+
"system_error": "cpp",
49+
"tuple": "cpp",
50+
"type_traits": "cpp",
51+
"typeinfo": "cpp",
52+
"unordered_map": "cpp",
53+
"utility": "cpp",
54+
"variant": "cpp",
55+
"vector": "cpp",
56+
"xfacet": "cpp",
57+
"xhash": "cpp",
58+
"xiosbase": "cpp",
59+
"xlocale": "cpp",
60+
"xlocbuf": "cpp",
61+
"xlocinfo": "cpp",
62+
"xlocmes": "cpp",
63+
"xlocmon": "cpp",
64+
"xlocnum": "cpp",
65+
"xloctime": "cpp",
66+
"xmemory": "cpp",
67+
"xmemory0": "cpp",
68+
"xstddef": "cpp",
69+
"xstring": "cpp",
70+
"xtr1common": "cpp",
71+
"xtree": "cpp",
72+
"xutility": "cpp"
73+
},
674
}

examples/index_group_example.cc

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,21 @@ Mesh ReadMesh(const std::string& filename) {
2929
auto mesh = Mesh{};
3030

3131
// Positions.
32-
auto add_position = thinks::obj_io::MakeAddFunc<
33-
thinks::obj_io::Position<float, 3>>([&mesh](const auto& pos) {
32+
auto add_position = thinks::MakeObjAddFunc<
33+
thinks::ObjPosition<float, 3>>([&mesh](const auto& pos) {
3434
mesh.positions.push_back(Vec3{pos.values[0], pos.values[1], pos.values[2]});
3535
});
3636

3737
// Normals.
38-
auto add_normal = thinks::obj_io::MakeAddFunc<
39-
thinks::obj_io::Normal<float>>([&mesh](const auto& nml) {
38+
auto add_normal = thinks::MakeObjAddFunc<
39+
thinks::ObjNormal<float>>([&mesh](const auto& nml) {
4040
mesh.normals.push_back(Vec3{nml.values[0], nml.values[1], nml.values[2]});
4141
});
4242

4343
// Faces.
44-
using ObjFaceType =
45-
thinks::obj_io::TriangleFace<thinks::obj_io::IndexGroup<uint16_t>>;
44+
using ObjFaceType = thinks::ObjTriangleFace<thinks::ObjIndexGroup<uint16_t>>;
4645
auto add_face =
47-
thinks::obj_io::MakeAddFunc<ObjFaceType>([&mesh](const auto& face) {
46+
thinks::MakeObjAddFunc<ObjFaceType>([&mesh](const auto& face) {
4847
mesh.position_indices.push_back(face.values[0].position_index.value);
4948
mesh.position_indices.push_back(face.values[1].position_index.value);
5049
mesh.position_indices.push_back(face.values[2].position_index.value);
@@ -61,9 +60,9 @@ Mesh ReadMesh(const std::string& filename) {
6160

6261
auto ifs = std::ifstream(filename);
6362
assert(ifs);
64-
const auto result = thinks::obj_io::Read(ifs, add_position, add_face,
65-
nullptr, // no texture coordinates.
66-
add_normal);
63+
const auto result = thinks::ReadObj(ifs, add_position, add_face,
64+
nullptr, // no texture coordinates.
65+
add_normal);
6766
ifs.close();
6867

6968
return mesh;
@@ -74,14 +73,14 @@ void WriteMesh(const std::string& filename, const Mesh& mesh) {
7473
const auto pos_iend = std::end(mesh.positions);
7574
auto pos_iter = std::begin(mesh.positions);
7675
auto pos_mapper = [&pos_iter, pos_iend]() {
77-
using ObjPositionType = thinks::obj_io::Position<float, 3>;
76+
using ObjPositionType = thinks::ObjPosition<float, 3>;
7877

7978
if (pos_iter == pos_iend) {
80-
return thinks::obj_io::End<ObjPositionType>();
79+
return thinks::ObjEnd<ObjPositionType>();
8180
}
8281

8382
const auto pos = *pos_iter++;
84-
return thinks::obj_io::Map(ObjPositionType(pos.x, pos.y, pos.z));
83+
return thinks::ObjMap(ObjPositionType(pos.x, pos.y, pos.z));
8584
};
8685

8786
// Faces.
@@ -91,12 +90,12 @@ void WriteMesh(const std::string& filename, const Mesh& mesh) {
9190
auto nml_idx_iter = std::begin(mesh.normal_indices);
9291
auto face_mapper = [&pos_idx_iter, &nml_idx_iter, pos_idx_iend,
9392
nml_idx_iend]() {
94-
using ObjIndexType = thinks::obj_io::IndexGroup<uint16_t>;
95-
using ObjFaceType = thinks::obj_io::TriangleFace<ObjIndexType>;
93+
using ObjIndexType = thinks::ObjIndexGroup<uint16_t>;
94+
using ObjFaceType = thinks::ObjTriangleFace<ObjIndexType>;
9695

9796
if (distance(pos_idx_iter, pos_idx_iend) < 3 ||
9897
distance(nml_idx_iter, nml_idx_iend) < 3) {
99-
return thinks::obj_io::End<ObjFaceType>();
98+
return thinks::ObjEnd<ObjFaceType>();
10099
}
101100

102101
const auto pos_idx0 = *pos_idx_iter++;
@@ -107,40 +106,34 @@ void WriteMesh(const std::string& filename, const Mesh& mesh) {
107106
const auto nml_idx2 = *nml_idx_iter++;
108107

109108
// No texture coordinates.
110-
return thinks::obj_io::Map(
111-
ObjFaceType(ObjIndexType(
112-
pos_idx0,
113-
std::make_pair(0, false),
114-
std::make_pair(nml_idx0, true)),
115-
ObjIndexType(
116-
pos_idx1,
117-
std::make_pair(0, false),
118-
std::make_pair(nml_idx1, true)),
119-
ObjIndexType(
120-
pos_idx2,
121-
std::make_pair(0, false),
122-
std::make_pair(nml_idx2, true))));
109+
return thinks::ObjMap(
110+
ObjFaceType(ObjIndexType(pos_idx0, std::make_pair(0, false),
111+
std::make_pair(nml_idx0, true)),
112+
ObjIndexType(pos_idx1, std::make_pair(0, false),
113+
std::make_pair(nml_idx1, true)),
114+
ObjIndexType(pos_idx2, std::make_pair(0, false),
115+
std::make_pair(nml_idx2, true))));
123116
};
124117

125118
// Normals.
126119
const auto nml_iend = end(mesh.normals);
127120
auto nml_iter = begin(mesh.normals);
128121
auto nml_mapper = [&nml_iter, nml_iend]() {
129-
using ObjNormalType = thinks::obj_io::Normal<float>;
122+
using ObjNormalType = thinks::ObjNormal<float>;
130123

131124
if (nml_iter == nml_iend) {
132-
return thinks::obj_io::End<ObjNormalType>();
125+
return thinks::ObjEnd<ObjNormalType>();
133126
}
134127

135128
const auto nml = *nml_iter++;
136-
return thinks::obj_io::Map(ObjNormalType(nml.x, nml.y, nml.z));
129+
return thinks::ObjMap(ObjNormalType(nml.x, nml.y, nml.z));
137130
};
138131

139132
auto ofs = std::ofstream(filename);
140133
assert(ofs);
141-
const auto result = thinks::obj_io::Write(ofs, pos_mapper, face_mapper,
142-
nullptr, // No texture coordinates.
143-
nml_mapper);
134+
const auto result = thinks::WriteObj(ofs, pos_mapper, face_mapper,
135+
nullptr, // No texture coordinates.
136+
nml_mapper);
144137
ofs.close();
145138
}
146139

examples/polygon_example.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ Mesh ReadMesh(const std::string& filename) {
3131
auto mesh = Mesh{};
3232

3333
// Positions.
34-
auto add_position = thinks::obj_io::MakeAddFunc<
35-
thinks::obj_io::Position<float, 3>>([&mesh](const auto& pos) {
34+
auto add_position = thinks::MakeObjAddFunc<
35+
thinks::ObjPosition<float, 3>>([&mesh](const auto& pos) {
3636
mesh.positions.push_back(Vec3{pos.values[0], pos.values[1], pos.values[2]});
3737
});
3838

3939
// Faces.
4040
using ObjFaceType =
41-
thinks::obj_io::PolygonFace<thinks::obj_io::Index<uint16_t>>;
41+
thinks::ObjPolygonFace<thinks::ObjIndex<uint16_t>>;
4242
auto add_face =
43-
thinks::obj_io::MakeAddFunc<ObjFaceType>([&mesh](const auto& face) {
43+
thinks::MakeObjAddFunc<ObjFaceType>([&mesh](const auto& face) {
4444
auto polygon = PolygonFace{};
4545
for (const auto index : face.values) {
4646
polygon.indices.push_back(index.value);
@@ -50,7 +50,7 @@ Mesh ReadMesh(const std::string& filename) {
5050

5151
auto ifs = std::ifstream(filename);
5252
assert(ifs);
53-
const auto result = thinks::obj_io::Read(ifs, add_position, add_face);
53+
const auto result = thinks::ReadObj(ifs, add_position, add_face);
5454
ifs.close();
5555

5656
return mesh;
@@ -61,25 +61,25 @@ void WriteMesh(const std::string& filename, const Mesh& mesh) {
6161
const auto pos_iend = std::end(mesh.positions);
6262
auto pos_iter = std::begin(mesh.positions);
6363
auto pos_mapper = [&pos_iter, pos_iend]() {
64-
using ObjPositionType = thinks::obj_io::Position<float, 3>;
64+
using ObjPositionType = thinks::ObjPosition<float, 3>;
6565

6666
if (pos_iter == pos_iend) {
67-
return thinks::obj_io::End<ObjPositionType>();
67+
return thinks::ObjEnd<ObjPositionType>();
6868
}
6969

7070
const auto pos = *pos_iter++;
71-
return thinks::obj_io::Map(ObjPositionType(pos.x, pos.y, pos.z));
71+
return thinks::ObjMap(ObjPositionType(pos.x, pos.y, pos.z));
7272
};
7373

7474
// Faces.
7575
const auto face_iend = std::end(mesh.faces);
7676
auto face_iter = std::begin(mesh.faces);
7777
auto face_mapper = [&face_iter, face_iend]() {
78-
using ObjIndexType = thinks::obj_io::IndexGroup<uint16_t>;
79-
using ObjFaceType = thinks::obj_io::PolygonFace<ObjIndexType>;
78+
using ObjIndexType = thinks::ObjIndexGroup<uint16_t>;
79+
using ObjFaceType = thinks::ObjPolygonFace<ObjIndexType>;
8080

8181
if (face_iter == face_iend) {
82-
return thinks::obj_io::End<ObjFaceType>();
82+
return thinks::ObjEnd<ObjFaceType>();
8383
}
8484

8585
auto face = *face_iter++;
@@ -88,12 +88,12 @@ void WriteMesh(const std::string& filename, const Mesh& mesh) {
8888
obj_face.values.push_back(ObjIndexType(index));
8989
}
9090

91-
return thinks::obj_io::Map(obj_face);
91+
return thinks::ObjMap(obj_face);
9292
};
9393

9494
auto ofs = std::ofstream(filename);
9595
assert(ofs);
96-
const auto result = thinks::obj_io::Write(ofs, pos_mapper, face_mapper);
96+
const auto result = thinks::WriteObj(ofs, pos_mapper, face_mapper);
9797
ofs.close();
9898
}
9999

0 commit comments

Comments
 (0)