Repository navigation
Expand file tree
/
Copy pathmesh.interface
More file actions
76 lines (60 loc) · 1.9 KB
/
Copy pathmesh.interface
File metadata and controls
76 lines (60 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Mesh {
public:
// Default contructor. Assignment operator/constructor
Mesh();
Mesh(const Mesh& m);
Mesh& operator = (const Mesh& m);
// Mesh::Vertex class
struct Vertex {
// position is 2D, and must be in the square[-1,1]x [-1,1]
Cvec2 getPosition() const;
Cvec3 getNormal() const;
void setPosition(const Cvec2& p) const;
void setNormal(const Cvec3& n) const;
VertexIterator getIterator() const;
int getIndex() const;
};
// Mesh::Face class
struct Face {
int getNumVertices() const;
Cvec3 getNormal() const;
Vertex getVertex(const int i) const;
};
// Mesh::Edge class
struct Edge {
Vertex getVertex(const int i) const;
Face getFace(const int i) const;
};
// Mesh::VertexIterator
struct VertexIterator {
Vertex getVertex() const;
Face getFace() const;
VertexIterator& operator ++ ();
bool operator == (const VertexIterator& vi) const;
bool operator != (const VertexIterator& vi) const;
};
int getNumFaces() const;
int getNumEdges() const;
int getNumVertices() const;
Vertex getVertex(const int i);
Edge getEdge(const int i);
Face getFace(const int i);
Cvec3 getNewFaceVertex(const Face& f) const;
Cvec3 getNewEdgeVertex(const Edge& e) const;
Cvec3 getNewVertexVertex(const Vertex& v) const;
void setNewFaceVertex(const Face& f, const Cvec3& p);
void setNewEdgeVertex(const Edge& e, const Cvec3& p);
void setNewVertexVertex(const Vertex& v, const Cvec3& p);
void subdivide();
void load(const char filename[]);
};
// Sample usage for VertexIterator:
for (int i = 0; i < mesh.getNumVertices(); ++i) {
const Mesh::Vertex v = mesh.getVertex(i);
Mesh::VertexIterator it(v.getIterator()), it0(it);
do
{
[...] // can use here it.getVertex(), it.getFace()
}
while (++it != it0); // go around once the 1ring
}