-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeConverter.h
More file actions
54 lines (47 loc) · 1.74 KB
/
TypeConverter.h
File metadata and controls
54 lines (47 loc) · 1.74 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
#ifndef _TYPE_CONVERTER_
#define _TYPE_CONVERTER_
#include "Solid.h"
#include <Math/Vector.h>
#include <list>
using namespace OpenEngine;
class TypeConverter {
public:
static VertexPool* ConvertToVertexPool(std::list< Math::Vector<3,float> > vertexpool) {
VertexPool* vp = new VertexPool(vertexpool.size());
Point* points = vp->data;
std::list< Math::Vector<3,float> >::iterator itr2 = vertexpool.begin();
for (unsigned int i=0; itr2 != vertexpool.end(); itr2++, i++) {
Math::Vector<3,float> vert = *itr2;
points[i].x = vert[0];
points[i].y = vert[1];
points[i].z = vert[2];
}
return vp;
}
static Surface* ConvertToSurface(std::list< Math::Vector<3, unsigned int> > sid) {
Surface* surface = new Surface(sid.size());
Triangle* faces = surface->faces;
std::list< Math::Vector<3,unsigned int> >::iterator itr = sid.begin();
for (unsigned int i=0; itr != sid.end(); itr++, i++) {
Math::Vector<3,unsigned int> ids = *itr;
faces[i].x = ids[0];
faces[i].y = ids[1];
faces[i].z = ids[2];
}
return surface;
}
static Body* ConvertToBody(std::list< Math::Vector<4, unsigned int> > bid) {
Body* body = new Body(bid.size());
Tetrahedron* tets = body->tetrahedra;
std::list< Math::Vector<4,unsigned int> >::iterator itr = bid.begin();
for (unsigned int i=0; itr != bid.end(); itr++, i++) {
Math::Vector<4,unsigned int> ids = *itr;
tets[i].x = ids[0];
tets[i].y = ids[1];
tets[i].z = ids[2];
tets[i].w = ids[3];
}
return body;
}
};
#endif // _TYPE_CONVERTER_