-
Notifications
You must be signed in to change notification settings - Fork 0
/
face3d.h
59 lines (51 loc) · 1.12 KB
/
face3d.h
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
#ifndef FACE3D_H
#define FACE3D_H
#include <QObject>
#include <QString>
#include <QVector>
#include "base.h"
class Face3d
{
QVector<objoff> nums;
public:
Face3d()
{
}
Face3d(objoff *faces, int len) { add(faces, len); }
void add(objoff* faces, int len)
{
for (int i = 0; i < len; ++i)
nums.append(faces[i]);
}
void clear()
{
nums.clear();
}
void add(int f) { nums.append(f); }
static void createVstr(objoff *faces, objoff len, QString &out)
{
out = "f ";
for (objoff i = 0; i < len - 1; ++i)
out += QString::number(faces[i]) + " ";
out += QString::number(faces[len - 1]) + nl;
}
static void createVstr(objoff *faces, objoff *texts, objoff len, QString &out)
{
out = "f ";
for (objoff i = 0; i < len - 1; ++i)
out += QString::number(faces[i]) +"/"+ QString::number(texts[i]) + " ";
out += QString::number(faces[len - 1]) +"/"+ QString::number(texts[len-1]) + nl;
}
QString buildStr(objoff offset=0)
{
QString st = "f ";
for(auto v : nums)
st += QString::number(v + offset) + " ";
return st.remove(st.length() - 1, 1);
}
~Face3d()
{
clear();
}
};
#endif // FACE3D_H