forked from kamalpreetgrewal/textToDrawing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
139 lines (122 loc) · 3.61 KB
/
main.cpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <QFile>
#include <QRegularExpression>
#include <QDebug>
#include <QTextStream>
#include <QIODevice>
#include <QProcess>
#include "entity.h"
int main()
{
// reading the input file
QFile ifile("in.txt");
QString content;
QStringList list;
ifile.open(QIODevice::ReadOnly);
// read whole content
while (!ifile.atEnd()) {
// defining the regexp by which splitting of contents is to be done
QRegularExpression exp("(\\(|\\)|\\,|\\=)");
content = ifile.readAll();
list = content.split(exp);
}
// closing the file after reading has been done
ifile.close();
// opening the file to write the splitted data
QFile ofile("out.txt");
ofile.open(QIODevice::WriteOnly);
QTextStream out(&ofile);
out << list.join("\n");
ofile.close();
// defining regexp to save only numbers in the parsed data in a list
//QRegularExpression exp1("^[0-9]*$");
QVector<QVector<QString>*> bigV;
QVector<QString>* v;
QString c;
int count = -1;
ofile.open(QIODevice::ReadOnly);
// read whole content
while (!ofile.atEnd())
{
c = ofile.readLine();
if(c == "wall\n")
{
++count;
v = new QVector<QString>(5);
(*v)[0] = c;
// qDebug() << "wall";
}
if(c == "ball\n")
{
++count;
v = new QVector<QString>(4);
(*v)[0] = c;
// qDebug() << "ball";
}
if(c == "l\n" && count >= 0 && v != NULL)
{
// qDebug() << "l";
(*v)[1] = ofile.readLine();
}
if(c == "h\n" && count >= 0 && v != NULL)
{
// qDebug() << "h";
(*v)[2] = ofile.readLine();
}
if(c == "bx\n" && count >= 0 && v != NULL)
{
(*v)[3] = ofile.readLine();
}
if(c == "by\n" && count >= 0 && v != NULL)
{
(*v)[4] = ofile.readLine();
}
if(c == "r\n" && count >= 0 && v != NULL)
{
(*v)[1] = ofile.readLine();
}
if(c == "cx\n" && count >= 0 && v != NULL)
{
(*v)[2] = ofile.readLine();
}
if(c == "cy\n" && count >= 0 && v != NULL)
{
(*v)[3] = ofile.readLine();
}
if(c == "\n" && count >= 0 && v != NULL)
{
// qDebug() << "v : " << v;
bigV.append(v);
//delete v;
//v = 0;
}
}
// qDebug() << bigV.count();
ofile.close();
// creating the entity class' object and calling its function
entity e;
// dxfRW *abc = e.return_dxf();
// DL_WriterA *def = e.return_dw();
// e.startDXF(abc);
e.createWall(10, 20, 30, 30, "wall", 256, 1, "CONTINUOUS");
// for (int i = 0; i < bigV.size(); ++i)
// {
// QVector<QString>* ab = bigV.at(i);
// if (ab->at(0) == "wall\n")
// {
// int j = 1;
// e.createWall(abc, ab->at(j).toFloat(), ab->at(j+1).toFloat(),
// ab->at(j+2).toFloat(), ab->at(j+3).toFloat(),
// "wall", 256, 1, "CONINUOUS");
// }
// if (ab->at(0) == "ball\n")
// {
// int j = 1;
// // e.createWall(abc, def, ab->at(j).toFloat(), ab->at(j+1).toFloat(),
// // ab->at(j+2).toFloat(), ab->at(j+3).toFloat(),
// // "wall", 256, 1, "CONINUOUS");
// }
// }
// e.createFlange(abc, def, 20, 60, 100);
e.closeDXF();
QProcess::execute("librecad file.dxf");
}