#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
struct Vector3 { float x, y, z; };
struct Mesh {
vector<Vector3> positions;
vector<int> indices;
};
ostream& operator<<(ostream& os, const Mesh& m) {
for (const auto& pos : m.positions) cout << "(" << pos.x << ", " << pos.y << ", " << pos.z << "), ";
for (const auto& index : m.indices) cout << index << ", ";
cout << endl;
return os;
}
int main() {
// initialize a Mesh with explicit verts and indices
Mesh myMesh { { { 0.f, 0.f, 0.f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f } },
{ 0, 1, 2 } };
// initialize a Mesh with iterator pairs
Mesh mySecondMesh { { begin(myMesh.positions), end(myMesh.positions) },
{ begin(myMesh.indices), end(myMesh.indices) } };
// initialize a Mesh as a copy of an existing mesh
Mesh myThirdMesh = myMesh;
cout << myMesh << mySecondMesh << myThirdMesh;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDx2ZWN0b3I+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IFZlY3RvcjMgeyBmbG9hdCB4LCB5LCB6OyB9OwoKc3RydWN0IE1lc2ggewogICAgdmVjdG9yPFZlY3RvcjM+IHBvc2l0aW9uczsKICAgIHZlY3RvcjxpbnQ+IGluZGljZXM7Cn07Cgpvc3RyZWFtJiBvcGVyYXRvcjw8KG9zdHJlYW0mIG9zLCBjb25zdCBNZXNoJiBtKSB7CiAgICBmb3IgKGNvbnN0IGF1dG8mIHBvcyA6IG0ucG9zaXRpb25zKSBjb3V0IDw8ICIoIiA8PCBwb3MueCA8PCAiLCAiIDw8IHBvcy55IDw8ICIsICIgPDwgcG9zLnogPDwgIiksICI7CiAgICBmb3IgKGNvbnN0IGF1dG8mIGluZGV4IDogbS5pbmRpY2VzKSBjb3V0IDw8IGluZGV4IDw8ICIsICI7CiAgICBjb3V0IDw8IGVuZGw7Ci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