Horizon
step_importer.hpp
1 #pragma once
2 #include <deque>
3 #include <string>
4 #include <vector>
5 #include <tuple>
6 
7 namespace horizon::STEPImporter {
8 class Color {
9 public:
10  float r;
11  float g;
12  float b;
13  Color(double ir, double ig, double ib) : r(ir), g(ig), b(ib)
14  {
15  }
16  Color() : r(0), g(0), b(0)
17  {
18  }
19 };
20 
21 class Vertex {
22 private:
23  auto as_tuple() const
24  {
25  return std::make_tuple(x, y, z);
26  }
27 
28 public:
29  Vertex(float ix, float iy, float iz) : x(ix), y(iy), z(iz)
30  {
31  }
32 
33  float x, y, z;
34 
35  bool operator==(const Vertex &other) const
36  {
37  return x == other.x && y == other.y && z == other.z;
38  }
39 
40  bool operator<(const Vertex &other) const
41  {
42  return as_tuple() < other.as_tuple();
43  }
44 
45  auto &operator+=(const Vertex &other)
46  {
47  x += other.x;
48  y += other.y;
49  z += other.z;
50  return *this;
51  }
52 
53  auto &operator/=(float other)
54  {
55  x /= other;
56  y /= other;
57  z /= other;
58  return *this;
59  }
60 };
61 
62 class Face {
63 public:
64  Color color;
65  std::vector<Vertex> vertices;
66  std::vector<Vertex> normals;
67  std::vector<std::tuple<size_t, size_t, size_t>> triangle_indices;
68 };
69 
70 std::deque<Face> import(const std::string &filename);
71 } // namespace horizon::STEPImporter
Definition: step_importer.hpp:8
Definition: step_importer.hpp:62
Definition: step_importer.hpp:21