-
Notifications
You must be signed in to change notification settings - Fork 8
/
drw_classes.cpp
115 lines (105 loc) · 4.02 KB
/
drw_classes.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
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
** **
** This library is free software, licensed under the terms of the GNU **
** General Public License as published by the Free Software Foundation, **
** either version 2 of the License, or (at your option) any later version. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include "drw_classes.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
#include "intern/dwgbuffer.h"
#include "intern/drw_dbg.h"
void DRW_Class::parseCode(int code, dxfReader *reader){
switch (code) {
case 1:
recName = reader->getUtf8String();
break;
case 2:
className = reader->getUtf8String();
break;
case 3:
appName = reader->getUtf8String();
break;
case 90:
proxyFlag = reader->getInt32();
break;
case 91:
instanceCount = reader->getInt32();
break;
case 280:
wasaProxyFlag = reader->getInt32();
break;
case 281:
entityFlag = reader->getInt32();
break;
default:
break;
}
}
bool DRW_Class::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf){
DRW_DBG("\n***************************** parsing Class *********************************************\n");
classNum = buf->getBitShort();
DRW_DBG("Class number: "); DRW_DBG(classNum);
proxyFlag = buf->getBitShort(); //in dwg specs says "version"
appName = strBuf->getVariableText(version, false);
className = strBuf->getVariableText(version, false);
recName = strBuf->getVariableText(version, false);
DRW_DBG("\napp name: "); DRW_DBG(appName.c_str());
DRW_DBG("\nclass name: "); DRW_DBG(className.c_str());
DRW_DBG("\ndxf rec name: "); DRW_DBG(recName.c_str());
wasaProxyFlag = buf->getBit(); //in dwg says wasazombie
entityFlag = buf->getBitShort();
entityFlag = entityFlag == 0x1F2 ? 1: 0;
DRW_DBG("\nProxy capabilities flag: "); DRW_DBG(proxyFlag);
DRW_DBG(", proxy flag (280): "); DRW_DBG(wasaProxyFlag);
DRW_DBG(", entity flag: "); DRW_DBGH(entityFlag);
if (version > DRW::AC1015) {//2004+
instanceCount = buf->getBitLong();
DRW_DBG("\nInstance Count: "); DRW_DBG(instanceCount);
duint32 dwgVersion = buf->getBitLong();
DRW_DBG("\nDWG version: "); DRW_DBG(dwgVersion);
DRW_DBG("\nmaintenance version: "); DRW_DBG(buf->getBitLong());
DRW_DBG("\nunknown 1: "); DRW_DBG(buf->getBitLong());
DRW_DBG("\nunknown 2: "); DRW_DBG(buf->getBitLong());
}
DRW_DBG("\n");
toDwgType();
return buf->isGood();
}
void DRW_Class::write(dxfWriter *writer, DRW::Version ver){
if (ver > DRW::AC1009) {
writer->writeString(0, "CLASS");
writer->writeString(1, recName);
writer->writeString(2, className);
writer->writeString(3, appName);
writer->writeInt32(90, proxyFlag);
if (ver > DRW::AC1015) { //2004+
writer->writeInt32(91, instanceCount);
}
writer->writeInt16(280, wasaProxyFlag);
writer->writeInt16(281, entityFlag);
}
}
void DRW_Class::toDwgType(){
if (recName == "LWPOLYLINE")
dwgType = 77;
else if (recName == "HATCH")
dwgType = 78;
else if (recName == "GROUP")
dwgType = 72;
/* else if (recName == "GROUP")
dwgType = 72;*/
else if (recName == "LAYOUT")
dwgType = 82;
else if (recName == "IMAGE")
dwgType = 101;
else if (recName == "IMAGEDEF")
dwgType = 102;
else
dwgType =0;
}