diff --git a/index.html b/index.html new file mode 100644 index 0000000..0a9840c --- /dev/null +++ b/index.html @@ -0,0 +1,101 @@ + +
+User: | runner@fv-az1491-737 |
---|---|
Working Directory: | /home/runner/work/LibreCAD/LibreCAD |
Command Line: | make release -j4 |
Clang Version: | Ubuntu clang version 11.0.0-2~ubuntu20.04.1 + |
Date: | Sat Aug 31 03:56:26 2024 |
Bug Type | Quantity | Display? |
All Bugs | 3 | |
Dead store | ||
---|---|---|
Dead assignment | 2 | |
Dead initialization | 1 |
Bug Group | +Bug Type ▾ | +File | +Function/Method | +Line | +Path Length | ++ + |
Dead store | Dead assignment | intern/dwgreader.cpp | readDwgTables | 685 | 1 | View Report | + +
Dead store | Dead assignment | intern/dwgreader.cpp | readDwgTables | 687 | 1 | View Report | + +
Dead store | Dead initialization | drw_header.cpp | parseDwg | 2407 | 1 | View Report | + +
File: | intern/dwgreader.cpp |
Warning: | line 687, column 21 Value stored to 'bs' is never read |
Press '?' + to see keyboard shortcuts
+ + +Keyboard shortcuts:
+1 | /****************************************************************************** |
2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** |
3 | ** ** |
4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** |
5 | ** ** |
6 | ** This library is free software, licensed under the terms of the GNU ** |
7 | ** General Public License as published by the Free Software Foundation, ** |
8 | ** either version 2 of the License, or (at your option) any later version. ** |
9 | ** You should have received a copy of the GNU General Public License ** |
10 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. ** |
11 | ******************************************************************************/ |
12 | |
13 | #include <cstdlib> |
14 | #include <iostream> |
15 | #include <fstream> |
16 | #include <string> |
17 | #include <sstream> |
18 | #include "dwgreader.h" |
19 | #include "drw_textcodec.h" |
20 | #include "drw_dbg.h" |
21 | |
22 | namespace { |
23 | //helper function to cleanup pointers in Look Up Tables |
24 | template<typename T> |
25 | void mapCleanUp(std::unordered_map<duint32, T*>& table) |
26 | { |
27 | for (auto& item: table) |
28 | delete item.second; |
29 | } |
30 | } |
31 | |
32 | dwgReader::~dwgReader() { |
33 | mapCleanUp(ltypemap); |
34 | mapCleanUp(layermap); |
35 | mapCleanUp(blockmap); |
36 | mapCleanUp(stylemap); |
37 | mapCleanUp(dimstylemap); |
38 | mapCleanUp(vportmap); |
39 | mapCleanUp(classesmap); |
40 | mapCleanUp(blockRecordmap); |
41 | mapCleanUp(appIdmap); |
42 | } |
43 | |
44 | void dwgReader::parseAttribs(DRW_Entity* e) { |
45 | if (nullptr == e) { |
46 | return; |
47 | } |
48 | |
49 | duint32 ltref =e->lTypeH.ref; |
50 | duint32 lyref =e->layerH.ref; |
51 | auto lt_it = ltypemap.find(ltref); |
52 | if (lt_it != ltypemap.end()) { |
53 | e->lineType = (lt_it->second)->name; |
54 | } |
55 | auto ly_it = layermap.find(lyref); |
56 | if (ly_it != layermap.end()) { |
57 | e->layer = (ly_it->second)->name; |
58 | } |
59 | } |
60 | |
61 | std::string dwgReader::findTableName(DRW::TTYPE table, dint32 handle){ |
62 | std::string name; |
63 | switch (table){ |
64 | case DRW::STYLE:{ |
65 | auto st_it = stylemap.find(handle); |
66 | if (st_it != stylemap.end()) |
67 | name = (st_it->second)->name; |
68 | break;} |
69 | case DRW::DIMSTYLE:{ |
70 | auto ds_it = dimstylemap.find(handle); |
71 | if (ds_it != dimstylemap.end()) |
72 | name = (ds_it->second)->name; |
73 | break;} |
74 | case DRW::BLOCK_RECORD:{ //use DRW_Block because name are more correct |
75 | // auto bk_it = blockmap.find(handle); |
76 | // if (bk_it != blockmap.end()) |
77 | auto bk_it = blockRecordmap.find(handle); |
78 | if (bk_it != blockRecordmap.end()) |
79 | name = (bk_it->second)->name; |
80 | break;} |
81 | /* case DRW::VPORT:{ |
82 | auto vp_it = vportmap.find(handle); |
83 | if (vp_it != vportmap.end()) |
84 | name = (vp_it->second)->name; |
85 | break;}*/ |
86 | case DRW::LAYER:{ |
87 | auto ly_it = layermap.find(handle); |
88 | if (ly_it != layermap.end()) |
89 | name = (ly_it->second)->name; |
90 | break;} |
91 | case DRW::LTYPE:{ |
92 | auto lt_it = ltypemap.find(handle); |
93 | if (lt_it != ltypemap.end()) |
94 | name = (lt_it->second)->name; |
95 | break;} |
96 | default: |
97 | break; |
98 | } |
99 | return name; |
100 | } |
101 | |
102 | bool dwgReader::readDwgHeader(DRW_Header& hdr, dwgBuffer *buf, dwgBuffer *hBuf){ |
103 | bool ret = hdr.parseDwg(version, buf, hBuf, maintenanceVersion); |
104 | //RLZ: copy objectControl handles |
105 | return ret; |
106 | } |
107 | |
108 | //RLZ: TODO add check instead print |
109 | bool dwgReader::checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start){ |
110 | DRW_UNUSED(start)(void)start; |
111 | for (int i=0; i<16;i++) { |
112 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
113 | } |
114 | return true; |
115 | } |
116 | |
117 | /*********** objects map ************************/ |
118 | /** Note: object map are split in sections with max size 2035? |
119 | * heach section are 2 bytes size + data bytes + 2 bytes crc |
120 | * size value are data bytes + 2 and to calculate crc are used |
121 | * 2 bytes size + data bytes |
122 | * last section are 2 bytes size + 2 bytes crc (size value always 2) |
123 | **/ |
124 | bool dwgReader::readDwgHandles(dwgBuffer *dbuf, duint64 offset, duint64 size) { |
125 | DRW_DBG("\ndwgReader::readDwgHandles\n")DRW_dbg::getInstance()->print("\ndwgReader::readDwgHandles\n" ); |
126 | if (!dbuf->setPosition(offset)) |
127 | return false; |
128 | |
129 | duint32 maxPos = offset + size; |
130 | DRW_DBG("\nSection HANDLES offset= ")DRW_dbg::getInstance()->print("\nSection HANDLES offset= " ); DRW_DBG(offset)DRW_dbg::getInstance()->print(offset); |
131 | DRW_DBG("\nSection HANDLES size= ")DRW_dbg::getInstance()->print("\nSection HANDLES size= "); DRW_DBG(size)DRW_dbg::getInstance()->print(size); |
132 | DRW_DBG("\nSection HANDLES maxPos= ")DRW_dbg::getInstance()->print("\nSection HANDLES maxPos= " ); DRW_DBG(maxPos)DRW_dbg::getInstance()->print(maxPos); |
133 | |
134 | int startPos = offset; |
135 | |
136 | std::vector<duint8> tmpByteStr; |
137 | while (maxPos > dbuf->getPosition()) { |
138 | DRW_DBG("\nstart handles section buf->curPosition()= ")DRW_dbg::getInstance()->print("\nstart handles section buf->curPosition()= " ); DRW_DBG(dbuf->getPosition())DRW_dbg::getInstance()->print(dbuf->getPosition()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
139 | duint16 size = dbuf->getBERawShort16(); |
140 | DRW_DBG("object map section size= ")DRW_dbg::getInstance()->print("object map section size= "); DRW_DBG(size)DRW_dbg::getInstance()->print(size); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
141 | dbuf->setPosition(startPos); |
142 | tmpByteStr.resize(size); |
143 | dbuf->getBytes(tmpByteStr.data(), size); |
144 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
145 | if (size != 2){ |
146 | buff.setPosition(2); |
147 | int lastHandle = 0; |
148 | int lastLoc = 0; |
149 | //read data |
150 | while(buff.getPosition()< size){ |
151 | lastHandle += buff.getUModularChar(); |
152 | DRW_DBG("object map lastHandle= ")DRW_dbg::getInstance()->print("object map lastHandle= "); DRW_DBGH(lastHandle)DRW_dbg::getInstance()->printH(lastHandle); |
153 | lastLoc += buff.getModularChar(); |
154 | DRW_DBG(" lastLoc= ")DRW_dbg::getInstance()->print(" lastLoc= "); DRW_DBG(lastLoc)DRW_dbg::getInstance()->print(lastLoc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
155 | ObjectMap[lastHandle]= objHandle(0, lastHandle, lastLoc); |
156 | } |
157 | } |
158 | //verify crc |
159 | duint16 crcCalc = buff.crc8(0xc0c1,0,size); |
160 | duint16 crcRead = dbuf->getBERawShort16(); |
161 | DRW_DBG("object map section crc8 read= ")DRW_dbg::getInstance()->print("object map section crc8 read= " ); DRW_DBG(crcRead)DRW_dbg::getInstance()->print(crcRead); |
162 | DRW_DBG("\nobject map section crc8 calculated= ")DRW_dbg::getInstance()->print("\nobject map section crc8 calculated= " ); DRW_DBG(crcCalc)DRW_dbg::getInstance()->print(crcCalc); |
163 | DRW_DBG("\nobject section buf->curPosition()= ")DRW_dbg::getInstance()->print("\nobject section buf->curPosition()= " ); DRW_DBG(dbuf->getPosition())DRW_dbg::getInstance()->print(dbuf->getPosition()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
164 | startPos = dbuf->getPosition(); |
165 | } |
166 | |
167 | bool ret = dbuf->isGood(); |
168 | return ret; |
169 | } |
170 | |
171 | /*********** objects ************************/ |
172 | /** |
173 | * Reads all the object referenced in the object map section of the DWG file |
174 | * (using their object file offsets) |
175 | */ |
176 | bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) { |
177 | DRW_DBG("\ndwgReader::readDwgTables start\n")DRW_dbg::getInstance()->print("\ndwgReader::readDwgTables start\n" ); |
178 | bool ret = true; |
179 | bool ret2 = true; |
180 | objHandle oc; |
181 | dint16 oType; |
182 | duint32 bs = 0; //bit size of handle stream 2010+ |
183 | std::vector<duint8> tmpByteStr; |
184 | |
185 | //parse linetypes, start with linetype Control |
186 | auto mit = ObjectMap.find(hdr.linetypeCtrl); |
187 | if (mit==ObjectMap.end()) { |
188 | DRW_DBG("\nWARNING: LineType control not found\n")DRW_dbg::getInstance()->print("\nWARNING: LineType control not found\n" ); |
189 | ret = false; |
190 | } else { |
191 | DRW_DBG("\n**********Parsing LineType control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing LineType control*******\n" ); |
192 | oc = mit->second; |
193 | ObjectMap.erase(mit); |
194 | DRW_ObjControl ltControl; |
195 | dbuf->setPosition(oc.loc); |
196 | int csize = dbuf->getModularShort(); |
197 | if (version > DRW::AC1021) //2010+ |
198 | bs = dbuf->getUModularChar(); |
199 | else |
200 | bs = 0; |
201 | tmpByteStr.resize(csize); |
202 | dbuf->getBytes(tmpByteStr.data(), csize); |
203 | dwgBuffer cbuff(tmpByteStr.data(), csize, &decoder); |
204 | //verify if object are correct |
205 | oType = cbuff.getObjType(version); |
206 | if (oType != 0x38) { |
207 | DRW_DBG("\nWARNING: Not LineType control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not LineType control object, found oType " ); |
208 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x38\n")DRW_dbg::getInstance()->print(" instead 0x38\n"); |
209 | ret = false; |
210 | } else { //reset position |
211 | cbuff.resetPosition(); |
212 | ret2 = ltControl.parseDwg(version, &cbuff, bs); |
213 | if(ret) |
214 | ret = ret2; |
215 | } |
216 | for (auto it = ltControl.handlesList.begin(); it != ltControl.handlesList.end(); ++it) { |
217 | mit = ObjectMap.find(*it); |
218 | if (mit==ObjectMap.end()) { |
219 | DRW_DBG("\nWARNING: LineType not found\n")DRW_dbg::getInstance()->print("\nWARNING: LineType not found\n" ); |
220 | ret = false; |
221 | } else { |
222 | oc = mit->second; |
223 | ObjectMap.erase(mit); |
224 | DRW_DBG("\nLineType Handle= ")DRW_dbg::getInstance()->print("\nLineType Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" loc.: ")DRW_dbg::getInstance()->print(" loc.: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
225 | DRW_LType *lt = new DRW_LType(); |
226 | dbuf->setPosition(oc.loc); |
227 | int lsize = dbuf->getModularShort(); |
228 | DRW_DBG("LineType size in bytes= ")DRW_dbg::getInstance()->print("LineType size in bytes= "); DRW_DBG(lsize)DRW_dbg::getInstance()->print(lsize); |
229 | if (version > DRW::AC1021) //2010+ |
230 | bs = dbuf->getUModularChar(); |
231 | else |
232 | bs = 0; |
233 | tmpByteStr.resize(lsize); |
234 | dbuf->getBytes(tmpByteStr.data(), lsize); |
235 | dwgBuffer lbuff(tmpByteStr.data(), lsize, &decoder); |
236 | ret2 = lt->parseDwg(version, &lbuff, bs); |
237 | ltypemap[lt->handle] = lt; |
238 | if(ret) |
239 | ret = ret2; |
240 | } |
241 | } |
242 | } |
243 | |
244 | //parse layers, start with layer Control |
245 | mit = ObjectMap.find(hdr.layerCtrl); |
246 | if (mit==ObjectMap.end()) { |
247 | DRW_DBG("\nWARNING: Layer control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Layer control not found\n" ); |
248 | ret = false; |
249 | } else { |
250 | DRW_DBG("\n**********Parsing Layer control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Layer control*******\n" ); |
251 | oc = mit->second; |
252 | ObjectMap.erase(mit); |
253 | DRW_ObjControl layControl; |
254 | dbuf->setPosition(oc.loc); |
255 | int size = dbuf->getModularShort(); |
256 | if (version > DRW::AC1021) //2010+ |
257 | bs = dbuf->getUModularChar(); |
258 | else |
259 | bs = 0; |
260 | tmpByteStr.resize(size); |
261 | dbuf->getBytes(tmpByteStr.data(), size); |
262 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
263 | //verify if object are correct |
264 | oType = buff.getObjType(version); |
265 | if (oType != 0x32) { |
266 | DRW_DBG("\nWARNING: Not Layer control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Layer control object, found oType " ); |
267 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x32\n")DRW_dbg::getInstance()->print(" instead 0x32\n"); |
268 | ret = false; |
269 | } else { //reset position |
270 | buff.resetPosition(); |
271 | ret2 = layControl.parseDwg(version, &buff, bs); |
272 | if(ret) |
273 | ret = ret2; |
274 | } |
275 | for (auto it = layControl.handlesList.begin(); it != layControl.handlesList.end(); ++it) { |
276 | mit = ObjectMap.find(*it); |
277 | if (mit==ObjectMap.end()) { |
278 | DRW_DBG("\nWARNING: Layer not found\n")DRW_dbg::getInstance()->print("\nWARNING: Layer not found\n" ); |
279 | ret = false; |
280 | } else { |
281 | oc = mit->second; |
282 | ObjectMap.erase(mit); |
283 | DRW_DBG("Layer Handle= ")DRW_dbg::getInstance()->print("Layer Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
284 | DRW_Layer *la = new DRW_Layer(); |
285 | dbuf->setPosition(oc.loc); |
286 | int size = dbuf->getModularShort(); |
287 | if (version > DRW::AC1021) //2010+ |
288 | bs = dbuf->getUModularChar(); |
289 | else |
290 | bs = 0; |
291 | tmpByteStr.resize(size); |
292 | dbuf->getBytes(tmpByteStr.data(), size); |
293 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
294 | ret2 = la->parseDwg(version, &buff, bs); |
295 | layermap[la->handle] = la; |
296 | if(ret) |
297 | ret = ret2; |
298 | } |
299 | } |
300 | } |
301 | |
302 | //set linetype in layer |
303 | for (auto it=layermap.begin(); it!=layermap.end(); ++it) { |
304 | DRW_Layer *ly = it->second; |
305 | duint32 ref =ly->lTypeH.ref; |
306 | auto lt_it = ltypemap.find(ref); |
307 | if (lt_it != ltypemap.end()){ |
308 | ly->lineType = (lt_it->second)->name; |
309 | } |
310 | } |
311 | |
312 | //parse text styles, start with style Control |
313 | mit = ObjectMap.find(hdr.styleCtrl); |
314 | if (mit==ObjectMap.end()) { |
315 | DRW_DBG("\nWARNING: Style control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Style control not found\n" ); |
316 | ret = false; |
317 | } else { |
318 | DRW_DBG("\n**********Parsing Style control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Style control*******\n" ); |
319 | oc = mit->second; |
320 | ObjectMap.erase(mit); |
321 | DRW_ObjControl styControl; |
322 | dbuf->setPosition(oc.loc); |
323 | int size = dbuf->getModularShort(); |
324 | if (version > DRW::AC1021) //2010+ |
325 | bs = dbuf->getUModularChar(); |
326 | else |
327 | bs = 0; |
328 | tmpByteStr.resize(size); |
329 | dbuf->getBytes(tmpByteStr.data(), size); |
330 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
331 | //verify if object are correct |
332 | oType = buff.getObjType(version); |
333 | if (oType != 0x34) { |
334 | DRW_DBG("\nWARNING: Not Text Style control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Text Style control object, found oType " ); |
335 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x34\n")DRW_dbg::getInstance()->print(" instead 0x34\n"); |
336 | ret = false; |
337 | } else { //reset position |
338 | buff.resetPosition(); |
339 | ret2 = styControl.parseDwg(version, &buff, bs); |
340 | if(ret) |
341 | ret = ret2; |
342 | } |
343 | for (auto it = styControl.handlesList.begin(); it != styControl.handlesList.end(); ++it) { |
344 | mit = ObjectMap.find(*it); |
345 | if (mit==ObjectMap.end()) { |
346 | DRW_DBG("\nWARNING: Style not found\n")DRW_dbg::getInstance()->print("\nWARNING: Style not found\n" ); |
347 | ret = false; |
348 | } else { |
349 | oc = mit->second; |
350 | ObjectMap.erase(mit); |
351 | DRW_DBG("Style Handle= ")DRW_dbg::getInstance()->print("Style Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
352 | DRW_Textstyle *sty = new DRW_Textstyle(); |
353 | dbuf->setPosition(oc.loc); |
354 | int size = dbuf->getModularShort(); |
355 | if (version > DRW::AC1021) //2010+ |
356 | bs = dbuf->getUModularChar(); |
357 | else |
358 | bs = 0; |
359 | tmpByteStr.resize(size); |
360 | dbuf->getBytes(tmpByteStr.data(), size); |
361 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
362 | ret2 = sty->parseDwg(version, &buff, bs); |
363 | stylemap[sty->handle] = sty; |
364 | if(ret) |
365 | ret = ret2; |
366 | } |
367 | } |
368 | } |
369 | |
370 | //parse dim styles, start with dimstyle Control |
371 | mit = ObjectMap.find(hdr.dimstyleCtrl); |
372 | if (mit==ObjectMap.end()) { |
373 | DRW_DBG("\nWARNING: Dimension Style control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Dimension Style control not found\n" ); |
374 | ret = false; |
375 | } else { |
376 | DRW_DBG("\n**********Parsing Dimension Style control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Dimension Style control*******\n" ); |
377 | oc = mit->second; |
378 | ObjectMap.erase(mit); |
379 | DRW_ObjControl dimstyControl; |
380 | dbuf->setPosition(oc.loc); |
381 | duint32 size = dbuf->getModularShort(); |
382 | if (version > DRW::AC1021) //2010+ |
383 | bs = dbuf->getUModularChar(); |
384 | else |
385 | bs = 0; |
386 | tmpByteStr.resize(size); |
387 | dbuf->getBytes(tmpByteStr.data(), size); |
388 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
389 | //verify if object are correct |
390 | oType = buff.getObjType(version); |
391 | if (oType != 0x44) { |
392 | DRW_DBG("\nWARNING: Not Dim Style control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Dim Style control object, found oType " ); |
393 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x44\n")DRW_dbg::getInstance()->print(" instead 0x44\n"); |
394 | ret = false; |
395 | } else { //reset position |
396 | buff.resetPosition(); |
397 | ret2 = dimstyControl.parseDwg(version, &buff, bs); |
398 | if(ret) |
399 | ret = ret2; |
400 | } |
401 | for (auto it = dimstyControl.handlesList.begin(); it != dimstyControl.handlesList.end(); ++it) { |
402 | mit = ObjectMap.find(*it); |
403 | if (mit==ObjectMap.end()) { |
404 | DRW_DBG("\nWARNING: Dimension Style not found\n")DRW_dbg::getInstance()->print("\nWARNING: Dimension Style not found\n" ); |
405 | ret = false; |
406 | } else { |
407 | oc = mit->second; |
408 | ObjectMap.erase(mit); |
409 | DRW_DBG("Dimstyle Handle= ")DRW_dbg::getInstance()->print("Dimstyle Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
410 | DRW_Dimstyle *sty = new DRW_Dimstyle(); |
411 | dbuf->setPosition(oc.loc); |
412 | int size = dbuf->getModularShort(); |
413 | if (version > DRW::AC1021) //2010+ |
414 | bs = dbuf->getUModularChar(); |
415 | else |
416 | bs = 0; |
417 | tmpByteStr.resize(size); |
418 | dbuf->getBytes(tmpByteStr.data(), size); |
419 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
420 | ret2 = sty->parseDwg(version, &buff, bs); |
421 | dimstylemap[sty->handle] = sty; |
422 | if(ret) |
423 | ret = ret2; |
424 | } |
425 | } |
426 | } |
427 | |
428 | //parse vports, start with vports Control |
429 | mit = ObjectMap.find(hdr.vportCtrl); |
430 | if (mit==ObjectMap.end()) { |
431 | DRW_DBG("\nWARNING: vports control not found\n")DRW_dbg::getInstance()->print("\nWARNING: vports control not found\n" ); |
432 | ret = false; |
433 | } else { |
434 | DRW_DBG("\n**********Parsing vports control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing vports control*******\n" ); |
435 | oc = mit->second; |
436 | ObjectMap.erase(mit); |
437 | DRW_ObjControl vportControl; |
438 | dbuf->setPosition(oc.loc); |
439 | int size = dbuf->getModularShort(); |
440 | if (version > DRW::AC1021) //2010+ |
441 | bs = dbuf->getUModularChar(); |
442 | else |
443 | bs = 0; |
444 | tmpByteStr.resize(size); |
445 | dbuf->getBytes(tmpByteStr.data(), size); |
446 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
447 | //verify if object are correct |
448 | oType = buff.getObjType(version); |
449 | if (oType != 0x40) { |
450 | DRW_DBG("\nWARNING: Not VPorts control object, found oType: ")DRW_dbg::getInstance()->print("\nWARNING: Not VPorts control object, found oType: " ); |
451 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x40\n")DRW_dbg::getInstance()->print(" instead 0x40\n"); |
452 | ret = false; |
453 | } else { //reset position |
454 | buff.resetPosition(); |
455 | ret2 = vportControl.parseDwg(version, &buff, bs); |
456 | if(ret) |
457 | ret = ret2; |
458 | } |
459 | for (auto it = vportControl.handlesList.begin(); it != vportControl.handlesList.end(); ++it) { |
460 | mit = ObjectMap.find(*it); |
461 | if (mit==ObjectMap.end()) { |
462 | DRW_DBG("\nWARNING: vport not found\n")DRW_dbg::getInstance()->print("\nWARNING: vport not found\n" ); |
463 | ret = false; |
464 | } else { |
465 | oc = mit->second; |
466 | ObjectMap.erase(mit); |
467 | DRW_DBG("Vport Handle= ")DRW_dbg::getInstance()->print("Vport Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
468 | DRW_Vport *vp = new DRW_Vport(); |
469 | dbuf->setPosition(oc.loc); |
470 | int size = dbuf->getModularShort(); |
471 | if (version > DRW::AC1021) //2010+ |
472 | bs = dbuf->getUModularChar(); |
473 | else |
474 | bs = 0; |
475 | tmpByteStr.resize(size); |
476 | dbuf->getBytes(tmpByteStr.data(), size); |
477 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
478 | ret2 = vp->parseDwg(version, &buff, bs); |
479 | vportmap[vp->handle] = vp; |
480 | if(ret) |
481 | ret = ret2; |
482 | } |
483 | } |
484 | } |
485 | |
486 | //parse Block_records , start with Block_record Control |
487 | mit = ObjectMap.find(hdr.blockCtrl); |
488 | if (mit==ObjectMap.end()) { |
489 | DRW_DBG("\nWARNING: Block_record control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Block_record control not found\n" ); |
490 | ret = false; |
491 | } else { |
492 | DRW_DBG("\n**********Parsing Block_record control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Block_record control*******\n" ); |
493 | oc = mit->second; |
494 | ObjectMap.erase(mit); |
495 | DRW_ObjControl blockControl; |
496 | dbuf->setPosition(oc.loc); |
497 | int csize = dbuf->getModularShort(); |
498 | if (version > DRW::AC1021) //2010+ |
499 | bs = dbuf->getUModularChar(); |
500 | else |
501 | bs = 0; |
502 | tmpByteStr.resize(csize); |
503 | dbuf->getBytes(tmpByteStr.data(), csize); |
504 | dwgBuffer buff(tmpByteStr.data(), csize, &decoder); |
505 | //verify if object are correct |
506 | oType = buff.getObjType(version); |
507 | if (oType != 0x30) { |
508 | DRW_DBG("\nWARNING: Not Block Record control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Block Record control object, found oType " ); |
509 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x30\n")DRW_dbg::getInstance()->print(" instead 0x30\n"); |
510 | ret = false; |
511 | } else { //reset position |
512 | buff.resetPosition(); |
513 | ret2 = blockControl.parseDwg(version, &buff, bs); |
514 | if(ret) |
515 | ret = ret2; |
516 | } |
517 | for (auto it = blockControl.handlesList.begin(); it != blockControl.handlesList.end(); ++it) { |
518 | mit = ObjectMap.find(*it); |
519 | if (mit==ObjectMap.end()) { |
520 | DRW_DBG("\nWARNING: block record not found\n")DRW_dbg::getInstance()->print("\nWARNING: block record not found\n" ); |
521 | ret = false; |
522 | } else { |
523 | oc = mit->second; |
524 | ObjectMap.erase(mit); |
525 | DRW_DBG("block record Handle= ")DRW_dbg::getInstance()->print("block record Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
526 | DRW_Block_Record *br = new DRW_Block_Record(); |
527 | dbuf->setPosition(oc.loc); |
528 | int size = dbuf->getModularShort(); |
529 | if (version > DRW::AC1021) //2010+ |
530 | bs = dbuf->getUModularChar(); |
531 | else |
532 | bs = 0; |
533 | tmpByteStr.resize(size); |
534 | dbuf->getBytes(tmpByteStr.data(), size); |
535 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
536 | ret2 = br->parseDwg(version, &buff, bs); |
537 | blockRecordmap[br->handle] = br; |
538 | if(ret) |
539 | ret = ret2; |
540 | } |
541 | } |
542 | } |
543 | |
544 | //parse appId , start with appId Control |
545 | mit = ObjectMap.find(hdr.appidCtrl); |
546 | if (mit==ObjectMap.end()) { |
547 | DRW_DBG("\nWARNING: AppId control not found\n")DRW_dbg::getInstance()->print("\nWARNING: AppId control not found\n" ); |
548 | ret = false; |
549 | } else { |
550 | DRW_DBG("\n**********Parsing AppId control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing AppId control*******\n" ); |
551 | oc = mit->second; |
552 | ObjectMap.erase(mit); |
553 | DRW_DBG("AppId Control Obj Handle= ")DRW_dbg::getInstance()->print("AppId Control Obj Handle= " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
554 | DRW_ObjControl appIdControl; |
555 | dbuf->setPosition(oc.loc); |
556 | int size = dbuf->getModularShort(); |
557 | if (version > DRW::AC1021) //2010+ |
558 | bs = dbuf->getUModularChar(); |
559 | else |
560 | bs = 0; |
561 | tmpByteStr.resize(size); |
562 | dbuf->getBytes(tmpByteStr.data(), size); |
563 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
564 | //verify if object are correct |
565 | oType = buff.getObjType(version); |
566 | if (oType != 0x42) { |
567 | DRW_DBG("\nWARNING: Not AppId control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not AppId control object, found oType " ); |
568 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x42\n")DRW_dbg::getInstance()->print(" instead 0x42\n"); |
569 | ret = false; |
570 | } else { //reset position |
571 | buff.resetPosition(); |
572 | ret2 = appIdControl.parseDwg(version, &buff, bs); |
573 | if(ret) |
574 | ret = ret2; |
575 | } |
576 | for (auto it = appIdControl.handlesList.begin(); it != appIdControl.handlesList.end(); ++it) { |
577 | mit = ObjectMap.find(*it); |
578 | if (mit==ObjectMap.end()) { |
579 | DRW_DBG("\nWARNING: AppId not found\n")DRW_dbg::getInstance()->print("\nWARNING: AppId not found\n" ); |
580 | ret = false; |
581 | } else { |
582 | oc = mit->second; |
583 | ObjectMap.erase(mit); |
584 | DRW_DBG("AppId Handle= ")DRW_dbg::getInstance()->print("AppId Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
585 | DRW_AppId *ai = new DRW_AppId(); |
586 | dbuf->setPosition(oc.loc); |
587 | int size = dbuf->getModularShort(); |
588 | if (version > DRW::AC1021) //2010+ |
589 | bs = dbuf->getUModularChar(); |
590 | else |
591 | bs = 0; |
592 | tmpByteStr.resize(size); |
593 | dbuf->getBytes(tmpByteStr.data(), size); |
594 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
595 | ret2 = ai->parseDwg(version, &buff, bs); |
596 | appIdmap[ai->handle] = ai; |
597 | if(ret) |
598 | ret = ret2; |
599 | } |
600 | } |
601 | } |
602 | |
603 | //RLZ: parse remaining object controls, TODO: implement all |
604 | if (DRW_DBGGLDRW_dbg::getInstance()->getLevel() == DRW_dbg::Level::Debug){ |
605 | mit = ObjectMap.find(hdr.viewCtrl); |
606 | if (mit==ObjectMap.end()) { |
607 | DRW_DBG("\nWARNING: View control not found\n")DRW_dbg::getInstance()->print("\nWARNING: View control not found\n" ); |
608 | ret = false; |
609 | } else { |
610 | DRW_DBG("\n**********Parsing View control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing View control*******\n" ); |
611 | oc = mit->second; |
612 | ObjectMap.erase(mit); |
613 | DRW_DBG("View Control Obj Handle= ")DRW_dbg::getInstance()->print("View Control Obj Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
614 | DRW_ObjControl viewControl; |
615 | dbuf->setPosition(oc.loc); |
616 | int size = dbuf->getModularShort(); |
617 | if (version > DRW::AC1021) //2010+ |
618 | bs = dbuf->getUModularChar(); |
619 | else |
620 | bs = 0; |
621 | tmpByteStr.resize(size); |
622 | dbuf->getBytes(tmpByteStr.data(), size); |
623 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
624 | //verify if object are correct |
625 | oType = buff.getObjType(version); |
626 | if (oType != 0x3C) { |
627 | DRW_DBG("\nWARNING: Not View control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not View control object, found oType " ); |
628 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x3C\n")DRW_dbg::getInstance()->print(" instead 0x3C\n"); |
629 | ret = false; |
630 | } else { //reset position |
631 | buff.resetPosition(); |
632 | ret2 = viewControl.parseDwg(version, &buff, bs); |
633 | if(ret) |
634 | ret = ret2; |
635 | } |
636 | } |
637 | |
638 | mit = ObjectMap.find(hdr.ucsCtrl); |
639 | if (mit==ObjectMap.end()) { |
640 | DRW_DBG("\nWARNING: Ucs control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Ucs control not found\n" ); |
641 | ret = false; |
642 | } else { |
643 | oc = mit->second; |
644 | ObjectMap.erase(mit); |
645 | DRW_DBG("\n**********Parsing Ucs control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Ucs control*******\n" ); |
646 | DRW_DBG("Ucs Control Obj Handle= ")DRW_dbg::getInstance()->print("Ucs Control Obj Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
647 | DRW_ObjControl ucsControl; |
648 | dbuf->setPosition(oc.loc); |
649 | int size = dbuf->getModularShort(); |
650 | if (version > DRW::AC1021) //2010+ |
651 | bs = dbuf->getUModularChar(); |
652 | else |
653 | bs = 0; |
654 | tmpByteStr.resize(size); |
655 | dbuf->getBytes(tmpByteStr.data(), size); |
656 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
657 | //verify if object are correct |
658 | oType = buff.getObjType(version); |
659 | if (oType != 0x3E) { |
660 | DRW_DBG("\nWARNING: Not Ucs control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Ucs control object, found oType " ); |
661 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x3E\n")DRW_dbg::getInstance()->print(" instead 0x3E\n"); |
662 | ret = false; |
663 | } else { //reset position |
664 | buff.resetPosition(); |
665 | ret2 = ucsControl.parseDwg(version, &buff, bs); |
666 | if(ret) |
667 | ret = ret2; |
668 | } |
669 | } |
670 | |
671 | if (version < DRW::AC1018) {//r2000- |
672 | mit = ObjectMap.find(hdr.vpEntHeaderCtrl); |
673 | if (mit==ObjectMap.end()) { |
674 | DRW_DBG("\nWARNING: vpEntHeader control not found\n")DRW_dbg::getInstance()->print("\nWARNING: vpEntHeader control not found\n" ); |
675 | ret = false; |
676 | } else { |
677 | DRW_DBG("\n**********Parsing vpEntHeader control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing vpEntHeader control*******\n" ); |
678 | oc = mit->second; |
679 | ObjectMap.erase(mit); |
680 | DRW_DBG("vpEntHeader Control Obj Handle= ")DRW_dbg::getInstance()->print("vpEntHeader Control Obj Handle= " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
681 | DRW_ObjControl vpEntHeaderCtrl; |
682 | dbuf->setPosition(oc.loc); |
683 | int size = dbuf->getModularShort(); |
684 | if (version > DRW::AC1021) //2010+ |
685 | bs = dbuf->getUModularChar(); |
686 | else |
687 | bs = 0; |
Value stored to 'bs' is never read | |
688 | tmpByteStr.resize(size); |
689 | dbuf->getBytes(tmpByteStr.data(), size); |
690 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
691 | //verify if object are correct |
692 | oType = buff.getObjType(version); |
693 | if (oType != 0x46) { |
694 | DRW_DBG("\nWARNING: Not vpEntHeader control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not vpEntHeader control object, found oType " ); |
695 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x46\n")DRW_dbg::getInstance()->print(" instead 0x46\n"); |
696 | ret = false; |
697 | } else { //reset position |
698 | buff.resetPosition(); |
699 | /* RLZ: writeme ret2 = vpEntHeader.parseDwg(version, &buff, bs); |
700 | if(ret) |
701 | ret = ret2;*/ |
702 | } |
703 | } |
704 | } |
705 | } |
706 | |
707 | return ret; |
708 | } |
709 | |
710 | bool dwgReader::readDwgBlocks(DRW_Interface& intfa, dwgBuffer *dbuf){ |
711 | bool ret = true; |
712 | bool ret2 = true; |
713 | duint32 bs =0; |
714 | DRW_DBG("\nobject map total size= ")DRW_dbg::getInstance()->print("\nobject map total size= "); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
715 | |
716 | for (auto it=blockRecordmap.begin(); it != blockRecordmap.end(); ++it){ |
717 | DRW_Block_Record* bkr= it->second; |
718 | DRW_DBG("\nParsing Block, record handle= ")DRW_dbg::getInstance()->print("\nParsing Block, record handle= " ); DRW_DBGH(it->first)DRW_dbg::getInstance()->printH(it->first); DRW_DBG(" Name= ")DRW_dbg::getInstance()->print(" Name= "); DRW_DBG(bkr->name)DRW_dbg::getInstance()->print(bkr->name); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
719 | DRW_DBG("\nFinding Block, handle= ")DRW_dbg::getInstance()->print("\nFinding Block, handle= "); DRW_DBGH(bkr->block)DRW_dbg::getInstance()->printH(bkr->block); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
720 | auto mit = ObjectMap.find(bkr->block); |
721 | if (mit==ObjectMap.end()) { |
722 | DRW_DBG("\nWARNING: block entity not found\n")DRW_dbg::getInstance()->print("\nWARNING: block entity not found\n" ); |
723 | ret = false; |
724 | continue; |
725 | } |
726 | objHandle oc = mit->second; |
727 | ObjectMap.erase(mit); |
728 | DRW_DBG("Block Handle= ")DRW_dbg::getInstance()->print("Block Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" Location: ")DRW_dbg::getInstance()->print(" Location: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
729 | if ( !(dbuf->setPosition(oc.loc)) ){ |
730 | DRW_DBG("Bad Location reading blocks\n")DRW_dbg::getInstance()->print("Bad Location reading blocks\n" ); |
731 | ret = false; |
732 | continue; |
733 | } |
734 | int size = dbuf->getModularShort(); |
735 | if (version > DRW::AC1021) //2010+ |
736 | bs = dbuf->getUModularChar(); |
737 | else |
738 | bs = 0; |
739 | |
740 | std::vector<duint8> tmpByteStr(size); |
741 | dbuf->getBytes(tmpByteStr.data(), size); |
742 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
743 | DRW_Block bk; |
744 | ret2 = bk.parseDwg(version, &buff, bs); |
745 | ret = ret && ret2; |
746 | parseAttribs(&bk); |
747 | //complete block entity with block record data |
748 | bk.basePoint = bkr->basePoint; |
749 | bk.flags = bkr->flags; |
750 | intfa.addBlock(bk); |
751 | //and update block record name |
752 | bkr->name = bk.name; |
753 | |
754 | /**read & send block entities**/ |
755 | // in dwg code 330 are not set like dxf in ModelSpace & PaperSpace, set it (RLZ: only tested in 2000) |
756 | if (bk.parentHandle == DRW::NoHandle) { |
757 | // in dwg code 330 are not set like dxf in ModelSpace & PaperSpace, set it |
758 | bk.parentHandle= bkr->handle; |
759 | //and do not send block entities like dxf |
760 | } else { |
761 | if (version < DRW::AC1018) { //pre 2004 |
762 | duint32 nextH = bkr->firstEH; |
763 | while (nextH != 0){ |
764 | mit = ObjectMap.find(nextH); |
765 | if (mit==ObjectMap.end()) { |
766 | nextH = 0;//end while if entity not found |
767 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
768 | ret = false; |
769 | continue; |
770 | } else {//foud entity reads it |
771 | oc = mit->second; |
772 | ObjectMap.erase(mit); |
773 | ret2 = readDwgEntity(dbuf, oc, intfa); |
774 | ret = ret && ret2; |
775 | } |
776 | if (nextH == bkr->lastEH) |
777 | nextH = 0; //redundant, but prevent read errors |
778 | else |
779 | nextH = nextEntLink; |
780 | } |
781 | } else {//2004+ |
782 | for (std::vector<duint32>::iterator it = bkr->entMap.begin() ; it != bkr->entMap.end(); ++it){ |
783 | duint32 nextH = *it; |
784 | mit = ObjectMap.find(nextH); |
785 | if (mit==ObjectMap.end()) { |
786 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
787 | ret = false; |
788 | continue; |
789 | } else {//foud entity reads it |
790 | oc = mit->second; |
791 | ObjectMap.erase(mit); |
792 | DRW_DBG("\nBlocks, parsing entity: ")DRW_dbg::getInstance()->print("\nBlocks, parsing entity: " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(", pos: ")DRW_dbg::getInstance()->print(", pos: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
793 | ret2 = readDwgEntity(dbuf, oc, intfa); |
794 | ret = ret && ret2; |
795 | } |
796 | } |
797 | }//end 2004+ |
798 | } |
799 | |
800 | //end block entity, really needed to parse a dummy entity?? |
801 | mit = ObjectMap.find(bkr->endBlock); |
802 | if (mit==ObjectMap.end()) { |
803 | DRW_DBG("\nWARNING: end block entity not found\n")DRW_dbg::getInstance()->print("\nWARNING: end block entity not found\n" ); |
804 | ret = false; |
805 | continue; |
806 | } |
807 | oc = mit->second; |
808 | ObjectMap.erase(mit); |
809 | DRW_DBG("End block Handle= ")DRW_dbg::getInstance()->print("End block Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" Location: ")DRW_dbg::getInstance()->print(" Location: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
810 | dbuf->setPosition(oc.loc); |
811 | size = dbuf->getModularShort(); |
812 | if (version > DRW::AC1021) //2010+ |
813 | bs = dbuf->getUModularChar(); |
814 | else |
815 | bs = 0; |
816 | tmpByteStr.resize(size); |
817 | dbuf->getBytes(tmpByteStr.data(), size); |
818 | dwgBuffer buff1(tmpByteStr.data(), size, &decoder); |
819 | DRW_Block end; |
820 | end.isEnd = true; |
821 | ret2 = end.parseDwg(version, &buff1, bs); |
822 | ret = ret && ret2; |
823 | if (bk.parentHandle == DRW::NoHandle) bk.parentHandle= bkr->handle; |
824 | parseAttribs(&end); |
825 | intfa.endBlock(); |
826 | } |
827 | |
828 | return ret; |
829 | } |
830 | |
831 | bool dwgReader::readPlineVertex(DRW_Polyline& pline, dwgBuffer *dbuf){ |
832 | bool ret = true; |
833 | bool ret2 = true; |
834 | objHandle oc; |
835 | duint32 bs = 0; |
836 | |
837 | if (version < DRW::AC1018) { //pre 2004 |
838 | duint32 nextH = pline.firstEH; |
839 | while (nextH != 0){ |
840 | auto mit = ObjectMap.find(nextH); |
841 | if (mit==ObjectMap.end()) { |
842 | nextH = 0;//end while if entity not found |
843 | DRW_DBG("\nWARNING: pline vertex not found\n")DRW_dbg::getInstance()->print("\nWARNING: pline vertex not found\n" ); |
844 | ret = false; |
845 | continue; |
846 | } else {//foud entity reads it |
847 | oc = mit->second; |
848 | ObjectMap.erase(mit); |
849 | DRW_Vertex vt; |
850 | dbuf->setPosition(oc.loc); |
851 | //RLZ: verify if pos is ok |
852 | int size = dbuf->getModularShort(); |
853 | if (version > DRW::AC1021) {//2010+ |
854 | bs = dbuf->getUModularChar(); |
855 | } |
856 | std::vector<duint8> tmpByteStr(size); |
857 | dbuf->getBytes(tmpByteStr.data(), size); |
858 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
859 | dint16 oType = buff.getObjType(version); |
860 | buff.resetPosition(); |
861 | DRW_DBG(" object type= ")DRW_dbg::getInstance()->print(" object type= "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
862 | ret2 = vt.parseDwg(version, &buff, bs, pline.basePoint.z); |
863 | pline.addVertex(vt); |
864 | nextEntLink = vt.nextEntLink; \ |
865 | prevEntLink = vt.prevEntLink; |
866 | ret = ret && ret2; |
867 | } |
868 | if (nextH == pline.lastEH) |
869 | nextH = 0; //redundant, but prevent read errors |
870 | else |
871 | nextH = nextEntLink; |
872 | } |
873 | } else {//2004+ |
874 | for (std::list<duint32>::iterator it = pline.hadlesList.begin() ; it != pline.hadlesList.end(); ++it){ |
875 | duint32 nextH = *it; |
876 | auto mit = ObjectMap.find(nextH); |
877 | if (mit==ObjectMap.end()) { |
878 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
879 | ret = false; |
880 | continue; |
881 | } else {//foud entity reads it |
882 | oc = mit->second; |
883 | ObjectMap.erase(mit); |
884 | DRW_DBG("\nPline vertex, parsing entity: ")DRW_dbg::getInstance()->print("\nPline vertex, parsing entity: " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(", pos: ")DRW_dbg::getInstance()->print(", pos: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
885 | DRW_Vertex vt; |
886 | dbuf->setPosition(oc.loc); |
887 | //RLZ: verify if pos is ok |
888 | int size = dbuf->getModularShort(); |
889 | if (version > DRW::AC1021) {//2010+ |
890 | bs = dbuf->getUModularChar(); |
891 | } |
892 | std::vector<duint8> tmpByteStr(size); |
893 | dbuf->getBytes(tmpByteStr.data(), size); |
894 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
895 | dint16 oType = buff.getObjType(version); |
896 | buff.resetPosition(); |
897 | DRW_DBG(" object type= ")DRW_dbg::getInstance()->print(" object type= "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
898 | ret2 = vt.parseDwg(version, &buff, bs, pline.basePoint.z); |
899 | pline.addVertex(vt); |
900 | nextEntLink = vt.nextEntLink; \ |
901 | prevEntLink = vt.prevEntLink; |
902 | ret = ret && ret2; |
903 | } |
904 | } |
905 | }//end 2004+ |
906 | DRW_DBG("\nRemoved SEQEND entity: ")DRW_dbg::getInstance()->print("\nRemoved SEQEND entity: "); DRW_DBGH(pline.seqEndH.ref)DRW_dbg::getInstance()->printH(pline.seqEndH.ref);DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
907 | ObjectMap.erase(pline.seqEndH.ref); |
908 | |
909 | return ret; |
910 | } |
911 | |
912 | bool dwgReader::readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf){ |
913 | bool ret = true; |
914 | |
915 | DRW_DBG("\nobject map total size= ")DRW_dbg::getInstance()->print("\nobject map total size= "); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
916 | auto itB=ObjectMap.begin(); |
917 | auto itE=ObjectMap.end(); |
918 | while (itB != itE) { |
919 | if (ret) { |
920 | // once readDwgEntity() failed, just clear the ObjectMap |
921 | ret = readDwgEntity( dbuf, itB->second, intfa); |
922 | } |
923 | ObjectMap.erase( itB); |
924 | itB = ObjectMap.begin(); |
925 | } |
926 | return ret; |
927 | } |
928 | |
929 | /** |
930 | * Reads a dwg drawing entity (dwg object entity) given its offset in the file |
931 | */ |
932 | bool dwgReader::readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa){ |
933 | bool ret = true; |
934 | duint32 bs = 0; |
935 | |
936 | nextEntLink = prevEntLink = 0;// set to 0 to skip unimplemented entities |
937 | dbuf->setPosition(obj.loc); |
938 | //verify if position is ok: |
939 | if (!dbuf->isGood()){ |
940 | DRW_DBG(" Warning: readDwgEntity, bad location\n")DRW_dbg::getInstance()->print(" Warning: readDwgEntity, bad location\n" ); |
941 | return false; |
942 | } |
943 | int size = dbuf->getModularShort(); |
944 | if (version > DRW::AC1021) {//2010+ |
945 | bs = dbuf->getUModularChar(); |
946 | } |
947 | std::vector<duint8> tmpByteStr(size); |
948 | dbuf->getBytes(tmpByteStr.data(), size); |
949 | //verify if getBytes is ok: |
950 | if (!dbuf->isGood()) { |
951 | DRW_DBG(" Warning: readDwgEntity, bad size\n")DRW_dbg::getInstance()->print(" Warning: readDwgEntity, bad size\n" ); |
952 | return false; |
953 | } |
954 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
955 | dint16 oType = buff.getObjType(version); |
956 | buff.resetPosition(); |
957 | |
958 | if (oType > 499){ |
959 | auto it = classesmap.find(oType); |
960 | if (it == classesmap.end()){//fail, not found in classes set error |
961 | DRW_DBG("Class ")DRW_dbg::getInstance()->print("Class "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("not found, handle: ")DRW_dbg::getInstance()->print("not found, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
962 | return false; |
963 | } else { |
964 | DRW_Class *cl = it->second; |
965 | if (cl->dwgType != 0) |
966 | oType = cl->dwgType; |
967 | } |
968 | } |
969 | |
970 | obj.type = oType; |
971 | switch (oType) { |
972 | case 17: { |
973 | DRW_Arc e; |
974 | if (entryParse( e, buff, bs, ret)) { |
975 | intfa.addArc(e); |
976 | } |
977 | break; } |
978 | case 18: { |
979 | DRW_Circle e; |
980 | if (entryParse( e, buff, bs, ret)) { |
981 | intfa.addCircle(e); |
982 | } |
983 | break; } |
984 | case 19:{ |
985 | DRW_Line e; |
986 | if (entryParse( e, buff, bs, ret)) { |
987 | intfa.addLine(e); |
988 | } |
989 | break;} |
990 | case 27: { |
991 | DRW_Point e; |
992 | if (entryParse( e, buff, bs, ret)) { |
993 | intfa.addPoint(e); |
994 | } |
995 | break; } |
996 | case 35: { |
997 | DRW_Ellipse e; |
998 | if (entryParse( e, buff, bs, ret)) { |
999 | intfa.addEllipse(e); |
1000 | } |
1001 | break; } |
1002 | case 7: |
1003 | case 8: {//minsert = 8 |
1004 | DRW_Insert e; |
1005 | if (entryParse( e, buff, bs, ret)) { |
1006 | e.name = findTableName(DRW::BLOCK_RECORD, |
1007 | e.blockRecH.ref);//RLZ: find as block or blockrecord (ps & ps0) |
1008 | intfa.addInsert(e); |
1009 | } |
1010 | break; } |
1011 | case 77: { |
1012 | DRW_LWPolyline e; |
1013 | if (entryParse( e, buff, bs, ret)) { |
1014 | intfa.addLWPolyline(e); |
1015 | } |
1016 | break; } |
1017 | case 1: { |
1018 | DRW_Text e; |
1019 | if (entryParse( e, buff, bs, ret)) { |
1020 | e.style = findTableName(DRW::STYLE, e.styleH.ref); |
1021 | intfa.addText(e); |
1022 | } |
1023 | break; } |
1024 | case 44: { |
1025 | DRW_MText e; |
1026 | if (entryParse( e, buff, bs, ret)) { |
1027 | e.style = findTableName(DRW::STYLE, e.styleH.ref); |
1028 | intfa.addMText(e); |
1029 | } |
1030 | break; } |
1031 | case 28: { |
1032 | DRW_3Dface e; |
1033 | if (entryParse( e, buff, bs, ret)) { |
1034 | intfa.add3dFace(e); |
1035 | } |
1036 | break; } |
1037 | case 20: { |
1038 | DRW_DimOrdinate e; |
1039 | if (entryParse( e, buff, bs, ret)) { |
1040 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1041 | intfa.addDimOrdinate(&e); |
1042 | } |
1043 | break; } |
1044 | case 21: { |
1045 | DRW_DimLinear e; |
1046 | if (entryParse( e, buff, bs, ret)) { |
1047 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1048 | intfa.addDimLinear(&e); |
1049 | } |
1050 | break; } |
1051 | case 22: { |
1052 | DRW_DimAligned e; |
1053 | if (entryParse( e, buff, bs, ret)) { |
1054 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1055 | intfa.addDimAlign(&e); |
1056 | } |
1057 | break; } |
1058 | case 23: { |
1059 | DRW_DimAngular3p e; |
1060 | if (entryParse( e, buff, bs, ret)) { |
1061 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1062 | intfa.addDimAngular3P(&e); |
1063 | } |
1064 | break; } |
1065 | case 24: { |
1066 | DRW_DimAngular e; |
1067 | if (entryParse( e, buff, bs, ret)) { |
1068 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1069 | intfa.addDimAngular(&e); |
1070 | } |
1071 | break; } |
1072 | case 25: { |
1073 | DRW_DimRadial e; |
1074 | if (entryParse( e, buff, bs, ret)) { |
1075 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1076 | intfa.addDimRadial(&e); |
1077 | } |
1078 | break; } |
1079 | case 26: { |
1080 | DRW_DimDiametric e; |
1081 | if (entryParse( e, buff, bs, ret)) { |
1082 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1083 | intfa.addDimDiametric(&e); |
1084 | } |
1085 | break; } |
1086 | case 45: { |
1087 | DRW_Leader e; |
1088 | if (entryParse( e, buff, bs, ret)) { |
1089 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1090 | intfa.addLeader(&e); |
1091 | } |
1092 | break; } |
1093 | case 31: { |
1094 | DRW_Solid e; |
1095 | if (entryParse( e, buff, bs, ret)) { |
1096 | intfa.addSolid(e); |
1097 | } |
1098 | break; } |
1099 | case 78: { |
1100 | DRW_Hatch e; |
1101 | if (entryParse( e, buff, bs, ret)) { |
1102 | intfa.addHatch(&e); |
1103 | } |
1104 | break; } |
1105 | case 32: { |
1106 | DRW_Trace e; |
1107 | if (entryParse( e, buff, bs, ret)) { |
1108 | intfa.addTrace(e); |
1109 | } |
1110 | break; } |
1111 | case 34: { |
1112 | DRW_Viewport e; |
1113 | if (entryParse( e, buff, bs, ret)) { |
1114 | intfa.addViewport(e); |
1115 | } |
1116 | break; } |
1117 | case 36: { |
1118 | DRW_Spline e; |
1119 | if (entryParse( e, buff, bs, ret)) { |
1120 | intfa.addSpline(&e); |
1121 | } |
1122 | break; } |
1123 | case 40: { |
1124 | DRW_Ray e; |
1125 | if (entryParse( e, buff, bs, ret)) { |
1126 | intfa.addRay(e); |
1127 | } |
1128 | break; } |
1129 | case 15: // pline 2D |
1130 | case 16: // pline 3D |
1131 | case 29: { // pline PFACE |
1132 | DRW_Polyline e; |
1133 | if (entryParse( e, buff, bs, ret)) { |
1134 | readPlineVertex(e, dbuf); |
1135 | intfa.addPolyline(e); |
1136 | } |
1137 | break; } |
1138 | // case 30: { |
1139 | // DRW_Polyline e;// MESH (not pline) |
1140 | // ENTRY_PARSE(e) |
1141 | // intfa.addRay(e); |
1142 | // break; } |
1143 | case 41: { |
1144 | DRW_Xline e; |
1145 | if (entryParse( e, buff, bs, ret)) { |
1146 | intfa.addXline(e); |
1147 | } |
1148 | break; } |
1149 | case 101: { |
1150 | DRW_Image e; |
1151 | if (entryParse( e, buff, bs, ret)) { |
1152 | intfa.addImage(&e); |
1153 | } |
1154 | break; } |
1155 | |
1156 | default: |
1157 | //not supported or are object add to remaining map |
1158 | objObjectMap[obj.handle]= obj; |
1159 | break; |
1160 | } |
1161 | if (!ret){ |
1162 | DRW_DBG("Warning: Entity type ")DRW_dbg::getInstance()->print("Warning: Entity type "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("has failed, handle: ")DRW_dbg::getInstance()->print("has failed, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1163 | } |
1164 | |
1165 | return ret; |
1166 | } |
1167 | |
1168 | bool dwgReader::readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf){ |
1169 | bool ret = true; |
1170 | |
1171 | duint32 i=0; |
1172 | DRW_DBG("\nentities map total size= ")DRW_dbg::getInstance()->print("\nentities map total size= " ); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
1173 | DRW_DBG("\nobjects map total size= ")DRW_dbg::getInstance()->print("\nobjects map total size= " ); DRW_DBG(objObjectMap.size())DRW_dbg::getInstance()->print(objObjectMap.size()); |
1174 | auto itB=objObjectMap.begin(); |
1175 | auto itE=objObjectMap.end(); |
1176 | while (itB != itE){ |
1177 | if (ret) { |
1178 | // once readDwgObject() failed, just clear the ObjectMap |
1179 | ret = readDwgObject(dbuf, itB->second, intfa); |
1180 | } |
1181 | objObjectMap.erase(itB); |
1182 | itB=objObjectMap.begin(); |
1183 | } |
1184 | if (DRW_DBGGLDRW_dbg::getInstance()->getLevel() == DRW_dbg::Level::Debug) { |
1185 | for (auto it=remainingMap.begin(); it != remainingMap.end(); ++it){ |
1186 | DRW_DBG("\nnum.# ")DRW_dbg::getInstance()->print("\nnum.# "); DRW_DBG(i++)DRW_dbg::getInstance()->print(i++); DRW_DBG(" Remaining object Handle, loc, type= ")DRW_dbg::getInstance()->print(" Remaining object Handle, loc, type= " ); DRW_DBG(it->first)DRW_dbg::getInstance()->print(it->first); |
1187 | DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(it->second.loc)DRW_dbg::getInstance()->print(it->second.loc); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(it->second.type)DRW_dbg::getInstance()->print(it->second.type); |
1188 | } |
1189 | DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1190 | } |
1191 | return ret; |
1192 | } |
1193 | |
1194 | /** |
1195 | * Reads a dwg drawing object (dwg object object) given its offset in the file |
1196 | */ |
1197 | bool dwgReader::readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa){ |
1198 | bool ret = true; |
1199 | duint32 bs = 0; |
1200 | |
1201 | dbuf->setPosition(obj.loc); |
1202 | //verify if position is ok: |
1203 | if (!dbuf->isGood()){ |
1204 | DRW_DBG(" Warning: readDwgObject, bad location\n")DRW_dbg::getInstance()->print(" Warning: readDwgObject, bad location\n" ); |
1205 | return false; |
1206 | } |
1207 | int size = dbuf->getModularShort(); |
1208 | if (version > DRW::AC1021) {//2010+ |
1209 | bs = dbuf->getUModularChar(); |
1210 | } |
1211 | duint8 *tmpByteStr = new duint8[size]; |
1212 | dbuf->getBytes(tmpByteStr, size); |
1213 | //verify if getBytes is ok: |
1214 | if (!dbuf->isGood()){ |
1215 | DRW_DBG(" Warning: readDwgObject, bad size\n")DRW_dbg::getInstance()->print(" Warning: readDwgObject, bad size\n" ); |
1216 | delete[]tmpByteStr; |
1217 | return false; |
1218 | } |
1219 | dwgBuffer buff(tmpByteStr, size, &decoder); |
1220 | //oType are set parsing entities |
1221 | dint16 oType = obj.type; |
1222 | |
1223 | switch (oType){ |
1224 | case 102: { |
1225 | DRW_ImageDef e; |
1226 | ret = e.parseDwg(version, &buff, bs); |
1227 | intfa.linkImage(&e); |
1228 | break; } |
1229 | default: |
1230 | //not supported object or entity add to remaining map for debug |
1231 | remainingMap[obj.handle]= obj; |
1232 | break; |
1233 | } |
1234 | if (!ret){ |
1235 | DRW_DBG("Warning: Object type ")DRW_dbg::getInstance()->print("Warning: Object type "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("has failed, handle: ")DRW_dbg::getInstance()->print("has failed, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1236 | } |
1237 | delete[]tmpByteStr; |
1238 | return ret; |
1239 | } |
1240 | |
1241 | |
1242 | |
1243 | bool DRW_ObjControl::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ |
1244 | int unkData=0; |
1245 | bool ret = DRW_TableEntry::parseDwg(version, buf, nullptr, bs); |
1246 | DRW_DBG("\n***************************** parsing object control entry *********************************************\n")DRW_dbg::getInstance()->print("\n***************************** parsing object control entry *********************************************\n" ); |
1247 | if (!ret) |
1248 | return ret; |
1249 | //last parsed is: XDic Missing Flag 2004+ |
1250 | int numEntries = buf->getBitLong(); |
1251 | DRW_DBG(" num entries: ")DRW_dbg::getInstance()->print(" num entries: "); DRW_DBG(numEntries)DRW_dbg::getInstance()->print(numEntries); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1252 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1253 | |
1254 | // if (oType == 68 && version== DRW::AC1015){//V2000 dimstyle seems have one unknown byte hard handle counter?? |
1255 | if (oType == 68 && version > DRW::AC1014){//dimstyle seems have one unknown byte hard handle counter?? |
1256 | unkData = buf->getRawChar8(); |
1257 | DRW_DBG(" unknown v2000 byte: ")DRW_dbg::getInstance()->print(" unknown v2000 byte: "); DRW_DBG( unkData)DRW_dbg::getInstance()->print(unkData); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1258 | } |
1259 | if (version > DRW::AC1018){//from v2007+ have a bit for strings follows (ObjControl do not have) |
1260 | int stringBit = buf->getBit(); |
1261 | DRW_DBG(" string bit for v2007+: ")DRW_dbg::getInstance()->print(" string bit for v2007+: "); DRW_DBG( stringBit)DRW_dbg::getInstance()->print(stringBit); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1262 | } |
1263 | |
1264 | dwgHandle objectH = buf->getHandle(); |
1265 | DRW_DBG(" NULL Handle: ")DRW_dbg::getInstance()->print(" NULL Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1266 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1267 | |
1268 | // if (oType == 56 && version== DRW::AC1015){//linetype in 2004 seems not have XDicObjH or NULL handle |
1269 | if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle |
1270 | dwgHandle XDicObjH = buf->getHandle(); |
1271 | DRW_DBG(" XDicObj control Handle: ")DRW_dbg::getInstance()->print(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref)DRW_dbg::getInstance()->printHL(XDicObjH.code, XDicObjH.size ,XDicObjH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1272 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1273 | } |
1274 | //add 2 for modelspace, paperspace blocks & bylayer, byblock linetypes |
1275 | numEntries = ((oType == 48) || (oType == 56)) ? (numEntries +2) : numEntries; |
1276 | |
1277 | for (int i =0; i< numEntries; i++){ |
1278 | objectH = buf->getOffsetHandle(handle); |
1279 | if (objectH.ref != 0) //in vports R14 I found some NULL handles |
1280 | handlesList.push_back (objectH.ref); |
1281 | DRW_DBG(" objectH Handle: ")DRW_dbg::getInstance()->print(" objectH Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1282 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1283 | } |
1284 | |
1285 | for (int i =0; i< unkData; i++){ |
1286 | objectH = buf->getOffsetHandle(handle); |
1287 | DRW_DBG(" unknown Handle: ")DRW_dbg::getInstance()->print(" unknown Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1288 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1289 | } |
1290 | return buf->isGood(); |
1291 | } |
1292 |
File: | drw_header.cpp |
Warning: | line 2407, column 13 Value stored to 'sz' during its initialization is never read |
Press '?' + to see keyboard shortcuts
+ + +Keyboard shortcuts:
+1 | /****************************************************************************** |
2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** |
3 | ** ** |
4 | ** Copyright (C) 2016-2022 A. Stebich (librecad@mail.lordofbikes.de) ** |
5 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** |
6 | ** ** |
7 | ** This library is free software, licensed under the terms of the GNU ** |
8 | ** General Public License as published by the Free Software Foundation, ** |
9 | ** either version 2 of the License, or (at your option) any later version. ** |
10 | ** You should have received a copy of the GNU General Public License ** |
11 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. ** |
12 | ******************************************************************************/ |
13 | |
14 | #include "drw_header.h" |
15 | #include "intern/dxfreader.h" |
16 | #include "intern/dxfwriter.h" |
17 | #include "intern/drw_dbg.h" |
18 | #include "intern/dwgbuffer.h" |
19 | |
20 | DRW_Header::DRW_Header() { |
21 | linetypeCtrl = layerCtrl = styleCtrl = dimstyleCtrl = appidCtrl = 0; |
22 | blockCtrl = viewCtrl = ucsCtrl = vportCtrl = vpEntHeaderCtrl = 0; |
23 | version = DRW::AC1021; |
24 | } |
25 | |
26 | void DRW_Header::addComment(std::string c){ |
27 | if (!comments.empty()) |
28 | comments += '\n'; |
29 | comments += c; |
30 | } |
31 | |
32 | bool DRW_Header::parseCode(int code, dxfReader *reader){ |
33 | if (nullptr == curr && 9 != code) { |
34 | DRW_DBG("invalid header code: ")DRW_dbg::getInstance()->print("invalid header code: "); |
35 | DRW_DBG(code)DRW_dbg::getInstance()->print(code); |
36 | DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
37 | return false; |
38 | } |
39 | |
40 | switch (code) { |
41 | case 9: |
42 | curr = new DRW_Variant(); |
43 | name = reader->getString(); |
44 | if (version < DRW::AC1015 && name == "$DIMUNIT") |
45 | name="$DIMLUNIT"; |
46 | vars[name]=curr; |
47 | break; |
48 | case 1: |
49 | curr->addString(code, reader->getUtf8String()); |
50 | if (name =="$ACADVER") { |
51 | reader->setVersion(*curr->content.s, true); |
52 | version = reader->getVersion(); |
53 | } |
54 | break; |
55 | case 2: |
56 | curr->addString(code, reader->getUtf8String()); |
57 | break; |
58 | case 3: |
59 | curr->addString(code, reader->getUtf8String()); |
60 | if (name =="$DWGCODEPAGE") { |
61 | reader->setCodePage(*curr->content.s); |
62 | curr->addString(code, reader->getCodePage()); |
63 | } |
64 | break; |
65 | case 6: |
66 | curr->addString(code, reader->getUtf8String()); |
67 | break; |
68 | case 7: |
69 | curr->addString(code, reader->getUtf8String()); |
70 | break; |
71 | case 8: |
72 | curr->addString(code, reader->getUtf8String()); |
73 | break; |
74 | case 10: |
75 | curr->addCoord(code, DRW_Coord(reader->getDouble(), 0.0, 0.0)); |
76 | break; |
77 | case 20: |
78 | curr->setCoordY(reader->getDouble()); |
79 | break; |
80 | case 30: |
81 | curr->setCoordZ(reader->getDouble()); |
82 | break; |
83 | case 40: |
84 | curr->addDouble(code, reader->getDouble()); |
85 | break; |
86 | case 50: |
87 | curr->addDouble(code, reader->getDouble()); |
88 | break; |
89 | case 62: |
90 | curr->addInt(code, reader->getInt32()); |
91 | break; |
92 | case 70: |
93 | curr->addInt(code, reader->getInt32()); |
94 | break; |
95 | case 280: |
96 | curr->addInt(code, reader->getInt32()); |
97 | break; |
98 | case 290: |
99 | curr->addInt(code, reader->getInt32()); |
100 | break; |
101 | case 370: |
102 | curr->addInt(code, reader->getInt32()); |
103 | break; |
104 | case 380: |
105 | curr->addInt(code, reader->getInt32()); |
106 | break; |
107 | case 390: |
108 | curr->addString(code, reader->getUtf8String()); |
109 | break; |
110 | default: |
111 | break; |
112 | } |
113 | |
114 | return true; |
115 | } |
116 | |
117 | void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ |
118 | /*RLZ: TODO complete all vars to AC1024*/ |
119 | double varDouble; |
120 | int varInt; |
121 | std::string varStr; |
122 | DRW_Coord varCoord; |
123 | writer->writeString(2, "HEADER"); |
124 | writer->writeString(9, "$ACADVER"); |
125 | switch (ver) { |
126 | case DRW::AC1006: //unsupported version acad 10 |
127 | case DRW::AC1009: //acad 11 & 12 |
128 | varStr = "AC1009"; |
129 | break; |
130 | case DRW::AC1012: //unsupported version acad 13 |
131 | case DRW::AC1014: //acad 14 |
132 | varStr = "AC1014"; |
133 | break; |
134 | case DRW::AC1015: //acad 2000 |
135 | varStr = "AC1015"; |
136 | break; |
137 | case DRW::AC1018: //acad 2004 |
138 | varStr = "AC1018"; |
139 | break; |
140 | /* case DRW::AC1021: //acad 2007 |
141 | varStr = "AC1021"; |
142 | break;*/ |
143 | case DRW::AC1024: //acad 2010 |
144 | varStr = "AC1024"; |
145 | break; |
146 | case DRW::AC1027: //acad 2013 |
147 | varStr = "AC1027"; |
148 | break; |
149 | default: //acad 2007 default version |
150 | varStr = "AC1021"; |
151 | break; |
152 | } |
153 | writer->writeString(1, varStr); |
154 | writer->setVersion(varStr, true); |
155 | |
156 | getStr("$ACADVER", &varStr); |
157 | getStr("$ACADMAINTVER", &varStr); |
158 | |
159 | if (!getStr("$DWGCODEPAGE", &varStr)) { |
160 | varStr = "ANSI_1252"; |
161 | } |
162 | writer->writeString(9, "$DWGCODEPAGE"); |
163 | writer->setCodePage(varStr); |
164 | writer->writeString(3, writer->getCodePage() ); |
165 | writer->writeString(9, "$INSBASE"); |
166 | if (getCoord("$INSBASE", &varCoord)) { |
167 | writer->writeDouble(10, varCoord.x); |
168 | writer->writeDouble(20, varCoord.y); |
169 | writer->writeDouble(30, varCoord.z); |
170 | } else { |
171 | writer->writeDouble(10, 0.0); |
172 | writer->writeDouble(20, 0.0); |
173 | writer->writeDouble(30, 0.0); |
174 | } |
175 | writer->writeString(9, "$EXTMIN"); |
176 | if (getCoord("$EXTMIN", &varCoord)) { |
177 | writer->writeDouble(10, varCoord.x); |
178 | writer->writeDouble(20, varCoord.y); |
179 | writer->writeDouble(30, varCoord.z); |
180 | } else { |
181 | writer->writeDouble(10, 1.0000000000000000E+020); |
182 | writer->writeDouble(20, 1.0000000000000000E+020); |
183 | writer->writeDouble(30, 1.0000000000000000E+020); |
184 | } |
185 | writer->writeString(9, "$EXTMAX"); |
186 | if (getCoord("$EXTMAX", &varCoord)) { |
187 | writer->writeDouble(10, varCoord.x); |
188 | writer->writeDouble(20, varCoord.y); |
189 | writer->writeDouble(30, varCoord.z); |
190 | } else { |
191 | writer->writeDouble(10, -1.0000000000000000E+020); |
192 | writer->writeDouble(20, -1.0000000000000000E+020); |
193 | writer->writeDouble(30, -1.0000000000000000E+020); |
194 | } |
195 | writer->writeString(9, "$LIMMIN"); |
196 | if (getCoord("$LIMMIN", &varCoord)) { |
197 | writer->writeDouble(10, varCoord.x); |
198 | writer->writeDouble(20, varCoord.y); |
199 | } else { |
200 | writer->writeDouble(10, 0.0); |
201 | writer->writeDouble(20, 0.0); |
202 | } |
203 | writer->writeString(9, "$LIMMAX"); |
204 | if (getCoord("$LIMMAX", &varCoord)) { |
205 | writer->writeDouble(10, varCoord.x); |
206 | writer->writeDouble(20, varCoord.y); |
207 | } else { |
208 | writer->writeDouble(10, 420.0); |
209 | writer->writeDouble(20, 297.0); |
210 | } |
211 | writer->writeString(9, "$ORTHOMODE"); |
212 | if (getInt("$ORTHOMODE", &varInt)) |
213 | writer->writeInt16(70, varInt); |
214 | else |
215 | writer->writeInt16(70, 0); |
216 | writer->writeString(9, "$REGENMODE"); |
217 | if (getInt("$REGENMODE", &varInt)) |
218 | writer->writeInt16(70, varInt); |
219 | else |
220 | writer->writeInt16(70, 1); |
221 | writer->writeString(9, "$FILLMODE"); |
222 | if (getInt("$FILLMODE", &varInt)) |
223 | writer->writeInt16(70, varInt); |
224 | else |
225 | writer->writeInt16(70, 1); |
226 | writer->writeString(9, "$QTEXTMODE"); |
227 | if (getInt("$QTEXTMODE", &varInt)) |
228 | writer->writeInt16(70, varInt); |
229 | else |
230 | writer->writeInt16(70, 0); |
231 | writer->writeString(9, "$MIRRTEXT"); |
232 | if (getInt("$MIRRTEXT", &varInt)) |
233 | writer->writeInt16(70, varInt); |
234 | else |
235 | writer->writeInt16(70, 0); |
236 | if (ver == DRW::AC1009){ |
237 | writer->writeString(9, "$DRAGMODE"); |
238 | if (getInt("$DRAGMODE", &varInt)) |
239 | writer->writeInt16(70, varInt); |
240 | else |
241 | writer->writeInt16(70, 2); |
242 | } |
243 | writer->writeString(9, "$LTSCALE"); |
244 | if (getDouble("$LTSCALE", &varDouble)) |
245 | writer->writeDouble(40, varDouble); |
246 | else |
247 | writer->writeDouble(40, 1.0); |
248 | if (ver == DRW::AC1009){ |
249 | writer->writeString(9, "$OSMODE"); |
250 | if (getInt("$OSMODE", &varInt)) |
251 | writer->writeInt16(70, varInt); |
252 | else |
253 | writer->writeInt16(70, 0); |
254 | } |
255 | writer->writeString(9, "$ATTMODE"); |
256 | if (getInt("$ATTMODE", &varInt)) |
257 | writer->writeInt16(70, varInt); |
258 | else |
259 | writer->writeInt16(70, 0); |
260 | writer->writeString(9, "$TEXTSIZE"); |
261 | if (getDouble("$TEXTSIZE", &varDouble)) |
262 | writer->writeDouble(40, varDouble); |
263 | else |
264 | writer->writeDouble(40, 2.5); |
265 | writer->writeString(9, "$TRACEWID"); |
266 | if (getDouble("$TRACEWID", &varDouble)) |
267 | writer->writeDouble(40, varDouble); |
268 | else |
269 | writer->writeDouble(40, 15.68); |
270 | writer->writeString(9, "$TEXTSTYLE"); |
271 | if (getStr("$TEXTSTYLE", &varStr)) |
272 | if (ver == DRW::AC1009) |
273 | writer->writeUtf8Caps(7, varStr); |
274 | else |
275 | writer->writeUtf8String(7, varStr); |
276 | else |
277 | writer->writeString(7, "STANDARD"); |
278 | writer->writeString(9, "$CLAYER"); |
279 | if (getStr("$CLAYER", &varStr)) |
280 | if (ver == DRW::AC1009) |
281 | writer->writeUtf8Caps(8, varStr); |
282 | else |
283 | writer->writeUtf8String(8, varStr); |
284 | else |
285 | writer->writeString(8, "0"); |
286 | writer->writeString(9, "$CELTYPE"); |
287 | if (getStr("$CELTYPE", &varStr)) |
288 | if (ver == DRW::AC1009) |
289 | writer->writeUtf8Caps(6, varStr); |
290 | else |
291 | writer->writeUtf8String(6, varStr); |
292 | else |
293 | writer->writeString(6, "BYLAYER"); |
294 | writer->writeString(9, "$CECOLOR"); |
295 | if (getInt("$CECOLOR", &varInt)) |
296 | writer->writeInt16(62, varInt); |
297 | else |
298 | writer->writeInt16(62, 256); |
299 | if (ver > DRW::AC1009){ |
300 | writer->writeString(9, "$CELTSCALE"); |
301 | if (getDouble("$CELTSCALE", &varDouble)) |
302 | writer->writeDouble(40, varDouble); |
303 | else |
304 | writer->writeDouble(40, 1.0); |
305 | writer->writeString(9, "$DISPSILH"); |
306 | if (getInt("$DISPSILH", &varInt)) |
307 | writer->writeInt16(70, varInt); |
308 | else |
309 | writer->writeInt16(70, 0); |
310 | } |
311 | |
312 | writer->writeString(9, "$DIMSCALE"); |
313 | if (getDouble("$DIMSCALE", &varDouble)) |
314 | writer->writeDouble(40, varDouble); |
315 | else |
316 | writer->writeDouble(40, 2.5); |
317 | writer->writeString(9, "$DIMASZ"); |
318 | if (getDouble("$DIMASZ", &varDouble)) |
319 | writer->writeDouble(40, varDouble); |
320 | else |
321 | writer->writeDouble(40, 2.5); |
322 | writer->writeString(9, "$DIMEXO"); |
323 | if (getDouble("$DIMEXO", &varDouble)) |
324 | writer->writeDouble(40, varDouble); |
325 | else |
326 | writer->writeDouble(40, 0.625); |
327 | writer->writeString(9, "$DIMDLI"); |
328 | if (getDouble("$DIMDLI", &varDouble)) |
329 | writer->writeDouble(40, varDouble); |
330 | else |
331 | writer->writeDouble(40, 3.75); |
332 | writer->writeString(9, "$DIMRND"); |
333 | if (getDouble("$DIMRND", &varDouble)) |
334 | writer->writeDouble(40, varDouble); |
335 | else |
336 | writer->writeDouble(40, 0.0); |
337 | writer->writeString(9, "$DIMDLE"); |
338 | if (getDouble("$DIMDLE", &varDouble)) |
339 | writer->writeDouble(40, varDouble); |
340 | else |
341 | writer->writeDouble(40, 0.0); |
342 | writer->writeString(9, "$DIMEXE"); |
343 | if (getDouble("$DIMEXE", &varDouble)) |
344 | writer->writeDouble(40, varDouble); |
345 | else |
346 | writer->writeDouble(40, 1.25); |
347 | writer->writeString(9, "$DIMTP"); |
348 | if (getDouble("$DIMTP", &varDouble)) |
349 | writer->writeDouble(40, varDouble); |
350 | else |
351 | writer->writeDouble(40, 0.0); |
352 | writer->writeString(9, "$DIMTM"); |
353 | if (getDouble("$DIMTM", &varDouble)) |
354 | writer->writeDouble(40, varDouble); |
355 | else |
356 | writer->writeDouble(40, 0.0); |
357 | writer->writeString(9, "$DIMTXT"); |
358 | if (getDouble("$DIMTXT", &varDouble)) |
359 | writer->writeDouble(40, varDouble); |
360 | else |
361 | writer->writeDouble(40, 2.5); |
362 | writer->writeString(9, "$DIMCEN"); |
363 | if (getDouble("$DIMCEN", &varDouble)) |
364 | writer->writeDouble(40, varDouble); |
365 | else |
366 | writer->writeDouble(40, 2.5); |
367 | writer->writeString(9, "$DIMTSZ"); |
368 | if (getDouble("$DIMTSZ", &varDouble)) |
369 | writer->writeDouble(40, varDouble); |
370 | else |
371 | writer->writeDouble(40, 0.0); |
372 | writer->writeString(9, "$DIMTOL"); |
373 | if (getInt("$DIMTOL", &varInt)) |
374 | writer->writeInt16(70, varInt); |
375 | else |
376 | writer->writeInt16(70, 0); |
377 | writer->writeString(9, "$DIMLIM"); |
378 | if (getInt("$DIMLIM", &varInt)) |
379 | writer->writeInt16(70, varInt); |
380 | else |
381 | writer->writeInt16(70, 0); |
382 | writer->writeString(9, "$DIMTIH"); |
383 | if (getInt("$DIMTIH", &varInt)) |
384 | writer->writeInt16(70, varInt); |
385 | else |
386 | writer->writeInt16(70, 0); |
387 | writer->writeString(9, "$DIMTOH"); |
388 | if (getInt("$DIMTOH", &varInt)) |
389 | writer->writeInt16(70, varInt); |
390 | else |
391 | writer->writeInt16(70, 0); |
392 | writer->writeString(9, "$DIMSE1"); |
393 | if (getInt("$DIMSE1", &varInt)) |
394 | writer->writeInt16(70, varInt); |
395 | else |
396 | writer->writeInt16(70, 0); |
397 | writer->writeString(9, "$DIMSE2"); |
398 | if (getInt("$DIMSE2", &varInt)) |
399 | writer->writeInt16(70, varInt); |
400 | else |
401 | writer->writeInt16(70, 0); |
402 | writer->writeString(9, "$DIMTAD"); |
403 | if (getInt("$DIMTAD", &varInt)) |
404 | writer->writeInt16(70, varInt); |
405 | else |
406 | writer->writeInt16(70, 1); |
407 | writer->writeString(9, "$DIMZIN"); |
408 | if (getInt("$DIMZIN", &varInt)) |
409 | writer->writeInt16(70, varInt); |
410 | else |
411 | writer->writeInt16(70, 8); |
412 | writer->writeString(9, "$DIMBLK"); |
413 | if (getStr("$DIMBLK", &varStr)) |
414 | if (ver == DRW::AC1009) |
415 | writer->writeUtf8Caps(1, varStr); |
416 | else |
417 | writer->writeUtf8String(1, varStr); |
418 | else |
419 | writer->writeString(1, ""); |
420 | writer->writeString(9, "$DIMASO"); |
421 | if (getInt("$DIMASO", &varInt)) |
422 | writer->writeInt16(70, varInt); |
423 | else |
424 | writer->writeInt16(70, 1); |
425 | writer->writeString(9, "$DIMSHO"); |
426 | if (getInt("$DIMSHO", &varInt)) |
427 | writer->writeInt16(70, varInt); |
428 | else |
429 | writer->writeInt16(70, 1); |
430 | writer->writeString(9, "$DIMPOST"); |
431 | if (getStr("$DIMPOST", &varStr)) |
432 | if (ver == DRW::AC1009) |
433 | writer->writeUtf8Caps(1, varStr); |
434 | else |
435 | writer->writeUtf8String(1, varStr); |
436 | else |
437 | writer->writeString(1, ""); |
438 | writer->writeString(9, "$DIMAPOST"); |
439 | if (getStr("$DIMAPOST", &varStr)) |
440 | if (ver == DRW::AC1009) |
441 | writer->writeUtf8Caps(1, varStr); |
442 | else |
443 | writer->writeUtf8String(1, varStr); |
444 | else |
445 | writer->writeString(1, ""); |
446 | writer->writeString(9, "$DIMALT"); |
447 | if (getInt("$DIMALT", &varInt)) |
448 | writer->writeInt16(70, varInt); |
449 | else |
450 | writer->writeInt16(70, 0); |
451 | writer->writeString(9, "$DIMALTD"); |
452 | if (getInt("$DIMALTD", &varInt)) |
453 | writer->writeInt16(70, varInt); |
454 | else |
455 | writer->writeInt16(70, 3); |
456 | writer->writeString(9, "$DIMALTF"); |
457 | if (getDouble("$DIMALTF", &varDouble)) |
458 | writer->writeDouble(40, varDouble); |
459 | else |
460 | writer->writeDouble(40, 0.03937); |
461 | writer->writeString(9, "$DIMLFAC"); |
462 | if (getDouble("$DIMLFAC", &varDouble)) |
463 | writer->writeDouble(40, varDouble); |
464 | else |
465 | writer->writeDouble(40, 1.0); |
466 | writer->writeString(9, "$DIMTOFL"); |
467 | if (getInt("$DIMTOFL", &varInt)) |
468 | writer->writeInt16(70, varInt); |
469 | else |
470 | writer->writeInt16(70, 1); |
471 | writer->writeString(9, "$DIMTVP"); |
472 | if (getDouble("$DIMTVP", &varDouble)) |
473 | writer->writeDouble(40, varDouble); |
474 | else |
475 | writer->writeDouble(40, 0.0); |
476 | writer->writeString(9, "$DIMTIX"); |
477 | if (getInt("$DIMTIX", &varInt)) |
478 | writer->writeInt16(70, varInt); |
479 | else |
480 | writer->writeInt16(70, 0); |
481 | writer->writeString(9, "$DIMSOXD"); |
482 | if (getInt("$DIMSOXD", &varInt)) |
483 | writer->writeInt16(70, varInt); |
484 | else |
485 | writer->writeInt16(70, 0); |
486 | writer->writeString(9, "$DIMSAH"); |
487 | if (getInt("$DIMSAH", &varInt)) |
488 | writer->writeInt16(70, varInt); |
489 | else |
490 | writer->writeInt16(70, 0); |
491 | writer->writeString(9, "$DIMBLK1"); |
492 | if (getStr("$DIMBLK1", &varStr)) |
493 | if (ver == DRW::AC1009) |
494 | writer->writeUtf8Caps(1, varStr); |
495 | else |
496 | writer->writeUtf8String(1, varStr); |
497 | else |
498 | writer->writeString(1, ""); |
499 | writer->writeString(9, "$DIMBLK2"); |
500 | if (getStr("$DIMBLK2", &varStr)) |
501 | if (ver == DRW::AC1009) |
502 | writer->writeUtf8Caps(1, varStr); |
503 | else |
504 | writer->writeUtf8String(1, varStr); |
505 | else |
506 | writer->writeString(1, ""); |
507 | writer->writeString(9, "$DIMSTYLE"); |
508 | if (getStr("$DIMSTYLE", &varStr)) |
509 | if (ver == DRW::AC1009) |
510 | writer->writeUtf8Caps(2, varStr); |
511 | else |
512 | writer->writeUtf8String(2, varStr); |
513 | else |
514 | writer->writeString(2, "STANDARD"); |
515 | writer->writeString(9, "$DIMCLRD"); |
516 | if (getInt("$DIMCLRD", &varInt)) |
517 | writer->writeInt16(70, varInt); |
518 | else |
519 | writer->writeInt16(70, 0); |
520 | writer->writeString(9, "$DIMCLRE"); |
521 | if (getInt("$DIMCLRE", &varInt)) |
522 | writer->writeInt16(70, varInt); |
523 | else |
524 | writer->writeInt16(70, 0); |
525 | writer->writeString(9, "$DIMCLRT"); |
526 | if (getInt("$DIMCLRT", &varInt)) |
527 | writer->writeInt16(70, varInt); |
528 | else |
529 | writer->writeInt16(70, 0); |
530 | writer->writeString(9, "$DIMTFAC"); |
531 | if (getDouble("$DIMTFAC", &varDouble)) |
532 | writer->writeDouble(40, varDouble); |
533 | else |
534 | writer->writeDouble(40, 1.0); |
535 | writer->writeString(9, "$DIMGAP"); |
536 | if (getDouble("$DIMGAP", &varDouble)) |
537 | writer->writeDouble(40, varDouble); |
538 | else |
539 | writer->writeDouble(40, 0.625); |
540 | //post r12 dim vars |
541 | if (ver > DRW::AC1009) { |
542 | writer->writeString(9, "$DIMJUST"); |
543 | if (getInt("$DIMJUST", &varInt)) |
544 | writer->writeInt16(70, varInt); |
545 | else |
546 | writer->writeInt16(70, 0); |
547 | writer->writeString(9, "$DIMSD1"); |
548 | if (getInt("$DIMSD1", &varInt)) |
549 | writer->writeInt16(70, varInt); |
550 | else |
551 | writer->writeInt16(70, 0); |
552 | writer->writeString(9, "$DIMSD2"); |
553 | if (getInt("$DIMSD2", &varInt)) |
554 | writer->writeInt16(70, varInt); |
555 | else |
556 | writer->writeInt16(70, 0); |
557 | writer->writeString(9, "$DIMTOLJ"); |
558 | if (getInt("$DIMTOLJ", &varInt)) |
559 | writer->writeInt16(70, varInt); |
560 | else |
561 | writer->writeInt16(70, 0); |
562 | writer->writeString(9, "$DIMTZIN"); |
563 | if (getInt("$DIMTZIN", &varInt)) |
564 | writer->writeInt16(70, varInt); |
565 | else |
566 | writer->writeInt16(70, 8); |
567 | writer->writeString(9, "$DIMALTZ"); |
568 | if (getInt("$DIMALTZ", &varInt)) |
569 | writer->writeInt16(70, varInt); |
570 | else |
571 | writer->writeInt16(70, 0); |
572 | writer->writeString(9, "$DIMALTTZ"); |
573 | if (getInt("$DIMALTTZ", &varInt)) |
574 | writer->writeInt16(70, varInt); |
575 | else |
576 | writer->writeInt16(70, 0); |
577 | writer->writeString(9, "$DIMUPT"); |
578 | if (getInt("$DIMUPT", &varInt)) |
579 | writer->writeInt16(70, varInt); |
580 | else |
581 | writer->writeInt16(70, 0); |
582 | writer->writeString(9, "$DIMDEC"); |
583 | if (getInt("$DIMDEC", &varInt)) |
584 | writer->writeInt16(70, varInt); |
585 | else |
586 | writer->writeInt16(70, 2); |
587 | writer->writeString(9, "$DIMTDEC"); |
588 | if (getInt("$DIMTDEC", &varInt)) |
589 | writer->writeInt16(70, varInt); |
590 | else |
591 | writer->writeInt16(70, 2); |
592 | writer->writeString(9, "$DIMALTU"); |
593 | if (getInt("$DIMALTU", &varInt)) |
594 | writer->writeInt16(70, varInt); |
595 | else |
596 | writer->writeInt16(70, 2); |
597 | writer->writeString(9, "$DIMALTTD"); |
598 | if (getInt("$DIMALTTD", &varInt)) |
599 | writer->writeInt16(70, varInt); |
600 | else |
601 | writer->writeInt16(70, 3); |
602 | writer->writeString(9, "$DIMTXSTY"); |
603 | if (getStr("$DIMTXSTY", &varStr)) |
604 | if (ver == DRW::AC1009) |
605 | writer->writeUtf8Caps(7, varStr); |
606 | else |
607 | writer->writeUtf8String(7, varStr); |
608 | else |
609 | writer->writeString(7, "STANDARD"); |
610 | writer->writeString(9, "$DIMAUNIT"); |
611 | if (getInt("$DIMAUNIT", &varInt)) |
612 | writer->writeInt16(70, varInt); |
613 | else |
614 | writer->writeInt16(70, 0); |
615 | writer->writeString(9, "$DIMADEC"); |
616 | if (getInt("$DIMADEC", &varInt)) |
617 | writer->writeInt16(70, varInt); |
618 | else |
619 | writer->writeInt16(70, 0); |
620 | writer->writeString(9, "$DIMALTRND"); |
621 | if (getDouble("$DIMALTRND", &varDouble)) |
622 | writer->writeDouble(40, varDouble); |
623 | else |
624 | writer->writeDouble(40, 0.0); |
625 | writer->writeString(9, "$DIMAZIN"); |
626 | if (getInt("$DIMAZIN", &varInt)) |
627 | writer->writeInt16(70, varInt); |
628 | else |
629 | writer->writeInt16(70, 0); |
630 | writer->writeString(9, "$DIMDSEP"); |
631 | if (getInt("$DIMDSEP", &varInt)) |
632 | writer->writeInt16(70, varInt); |
633 | else |
634 | writer->writeInt16(70, 44); |
635 | writer->writeString(9, "$DIMATFIT"); |
636 | if (getInt("$DIMATFIT", &varInt)) |
637 | writer->writeInt16(70, varInt); |
638 | else |
639 | writer->writeInt16(70, 3); |
640 | writer->writeString(9, "$DIMFRAC"); |
641 | if (getInt("$DIMFRAC", &varInt)) |
642 | writer->writeInt16(70, varInt); |
643 | else |
644 | writer->writeInt16(70, 0); |
645 | writer->writeString(9, "$DIMLDRBLK"); |
646 | if (getStr("$DIMLDRBLK", &varStr)) |
647 | if (ver == DRW::AC1009) |
648 | writer->writeUtf8Caps(1, varStr); |
649 | else |
650 | writer->writeUtf8String(1, varStr); |
651 | else |
652 | writer->writeString(1, "STANDARD"); |
653 | //verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000) |
654 | if ( !getInt("$DIMLUNIT", &varInt) ){ |
655 | if (!getInt("$DIMUNIT", &varInt)) |
656 | varInt = 2; |
657 | } |
658 | //verify valid values from 1 to 6 |
659 | if (varInt<1 || varInt>6) |
660 | varInt = 2; |
661 | if (ver > DRW::AC1014) { |
662 | writer->writeString(9, "$DIMLUNIT"); |
663 | writer->writeInt16(70, varInt); |
664 | } else { |
665 | writer->writeString(9, "$DIMUNIT"); |
666 | writer->writeInt16(70, varInt); |
667 | } |
668 | writer->writeString(9, "$DIMLWD"); |
669 | if (getInt("$DIMLWD", &varInt)) |
670 | writer->writeInt16(70, varInt); |
671 | else |
672 | writer->writeInt16(70, -2); |
673 | writer->writeString(9, "$DIMLWE"); |
674 | if (getInt("$DIMLWE", &varInt)) |
675 | writer->writeInt16(70, varInt); |
676 | else |
677 | writer->writeInt16(70, -2); |
678 | writer->writeString(9, "$DIMTMOVE"); |
679 | if (getInt("$DIMTMOVE", &varInt)) |
680 | writer->writeInt16(70, varInt); |
681 | else |
682 | writer->writeInt16(70, 0); |
683 | |
684 | if (ver > DRW::AC1018) {// and post v2004 dim vars |
685 | writer->writeString(9, "$DIMFXL"); |
686 | if (getDouble("$DIMFXL", &varDouble)) |
687 | writer->writeDouble(40, varDouble); |
688 | else |
689 | writer->writeDouble(40, 1.0); |
690 | writer->writeString(9, "$DIMFXLON"); |
691 | if (getInt("$DIMFXLON", &varInt)) |
692 | writer->writeInt16(70, varInt); |
693 | else |
694 | writer->writeInt16(70, 0); |
695 | writer->writeString(9, "$DIMJOGANG"); |
696 | if (getDouble("$DIMJOGANG", &varDouble)) |
697 | writer->writeDouble(40, varDouble); |
698 | else |
699 | writer->writeDouble(40, 0.7854); |
700 | writer->writeString(9, "$DIMTFILL"); |
701 | if (getInt("$DIMTFILL", &varInt)) |
702 | writer->writeInt16(70, varInt); |
703 | else |
704 | writer->writeInt16(70, 0); |
705 | writer->writeString(9, "$DIMTFILLCLR"); |
706 | if (getInt("$DIMTFILLCLR", &varInt)) |
707 | writer->writeInt16(70, varInt); |
708 | else |
709 | writer->writeInt16(70, 0); |
710 | writer->writeString(9, "$DIMARCSYM"); |
711 | if (getInt("$DIMARCSYM", &varInt)) |
712 | writer->writeInt16(70, varInt); |
713 | else |
714 | writer->writeInt16(70, 0); |
715 | writer->writeString(9, "$DIMLTYPE"); |
716 | if (getStr("$DIMLTYPE", &varStr)) |
717 | if (ver == DRW::AC1009) |
718 | writer->writeUtf8Caps(6, varStr); |
719 | else |
720 | writer->writeUtf8String(6, varStr); |
721 | else |
722 | writer->writeString(6, ""); |
723 | writer->writeString(9, "$DIMLTEX1"); |
724 | if (getStr("$DIMLTEX1", &varStr)) |
725 | if (ver == DRW::AC1009) |
726 | writer->writeUtf8Caps(6, varStr); |
727 | else |
728 | writer->writeUtf8String(6, varStr); |
729 | else |
730 | writer->writeString(6, ""); |
731 | writer->writeString(9, "$DIMLTEX2"); |
732 | if (getStr("$DIMLTEX2", &varStr)) |
733 | if (ver == DRW::AC1009) |
734 | writer->writeUtf8Caps(6, varStr); |
735 | else |
736 | writer->writeUtf8String(6, varStr); |
737 | else |
738 | writer->writeString(6, ""); |
739 | if (ver > DRW::AC1021) {// and post v2007 dim vars |
740 | writer->writeString(9, "$DIMTXTDIRECTION"); |
741 | if (getInt("$DIMTXTDIRECTION", &varInt)) |
742 | writer->writeInt16(70, varInt); |
743 | else |
744 | writer->writeInt16(70, 0); |
745 | } |
746 | }// end post v2004 dim vars |
747 | }//end post r12 dim vars |
748 | |
749 | writer->writeString(9, "$LUNITS"); |
750 | if (getInt("$LUNITS", &varInt)) |
751 | writer->writeInt16(70, varInt); |
752 | else |
753 | writer->writeInt16(70, 2); |
754 | writer->writeString(9, "$LUPREC"); |
755 | if (getInt("$LUPREC", &varInt)) |
756 | writer->writeInt16(70, varInt); |
757 | else |
758 | writer->writeInt16(70, 4); |
759 | writer->writeString(9, "$SKETCHINC"); |
760 | if (getDouble("$SKETCHINC", &varDouble)) |
761 | writer->writeDouble(40, varDouble); |
762 | else |
763 | writer->writeDouble(40, 1.0); |
764 | writer->writeString(9, "$FILLETRAD"); |
765 | if (getDouble("$FILLETRAD", &varDouble)) |
766 | writer->writeDouble(40, varDouble); |
767 | else |
768 | writer->writeDouble(40, 0.0); |
769 | writer->writeString(9, "$AUNITS"); |
770 | if (getInt("$AUNITS", &varInt)) |
771 | writer->writeInt16(70, varInt); |
772 | else |
773 | writer->writeInt16(70, 0); |
774 | writer->writeString(9, "$AUPREC"); |
775 | if (getInt("$AUPREC", &varInt)) |
776 | writer->writeInt16(70, varInt); |
777 | else |
778 | writer->writeInt16(70, 2); |
779 | writer->writeString(9, "$MENU"); |
780 | if (getStr("$MENU", &varStr)) |
781 | if (ver == DRW::AC1009) |
782 | writer->writeUtf8Caps(1, varStr); |
783 | else |
784 | writer->writeUtf8String(1, varStr); |
785 | else |
786 | writer->writeString(1, "."); |
787 | writer->writeString(9, "$ELEVATION"); |
788 | if (getDouble("$ELEVATION", &varDouble)) |
789 | writer->writeDouble(40, varDouble); |
790 | else |
791 | writer->writeDouble(40, 0.0); |
792 | writer->writeString(9, "$PELEVATION"); |
793 | if (getDouble("$PELEVATION", &varDouble)) |
794 | writer->writeDouble(40, varDouble); |
795 | else |
796 | writer->writeDouble(40, 0.0); |
797 | writer->writeString(9, "$THICKNESS"); |
798 | if (getDouble("$THICKNESS", &varDouble)) |
799 | writer->writeDouble(40, varDouble); |
800 | else |
801 | writer->writeDouble(40, 0.0); |
802 | writer->writeString(9, "$LIMCHECK"); |
803 | if (getInt("$LIMCHECK", &varInt)) |
804 | writer->writeInt16(70, varInt); |
805 | else |
806 | writer->writeInt16(70, 0); |
807 | if (ver < DRW::AC1015) { |
808 | writer->writeString(9, "$BLIPMODE"); |
809 | if (getInt("$BLIPMODE", &varInt)) |
810 | writer->writeInt16(70, varInt); |
811 | else |
812 | writer->writeInt16(70, 0); |
813 | } |
814 | writer->writeString(9, "$CHAMFERA"); |
815 | if (getDouble("$CHAMFERA", &varDouble)) |
816 | writer->writeDouble(40, varDouble); |
817 | else |
818 | writer->writeDouble(40, 0.0); |
819 | writer->writeString(9, "$CHAMFERB"); |
820 | if (getDouble("$CHAMFERB", &varDouble)) |
821 | writer->writeDouble(40, varDouble); |
822 | else |
823 | writer->writeDouble(40, 0.0); |
824 | if (ver > DRW::AC1009) { |
825 | writer->writeString(9, "$CHAMFERC"); |
826 | if (getDouble("$CHAMFERC", &varDouble)) |
827 | writer->writeDouble(40, varDouble); |
828 | else |
829 | writer->writeDouble(40, 0.0); |
830 | writer->writeString(9, "$CHAMFERD"); |
831 | if (getDouble("$CHAMFERD", &varDouble)) |
832 | writer->writeDouble(40, varDouble); |
833 | else |
834 | writer->writeDouble(40, 0.0); |
835 | } |
836 | writer->writeString(9, "$SKPOLY"); |
837 | if (getInt("$SKPOLY", &varInt)) { |
838 | writer->writeInt16(70, varInt); |
839 | } else |
840 | writer->writeInt16(70, 0); |
841 | //rlz: todo, times |
842 | writer->writeString(9, "$USRTIMER"); |
843 | if (getInt("$USRTIMER", &varInt)) { |
844 | writer->writeInt16(70, varInt); |
845 | } else |
846 | writer->writeInt16(70, 1); |
847 | writer->writeString(9, "$ANGBASE"); |
848 | if (getDouble("$ANGBASE", &varDouble)) |
849 | writer->writeDouble(50, varDouble); |
850 | else |
851 | writer->writeDouble(50, 0.0); |
852 | writer->writeString(9, "$ANGDIR"); |
853 | if (getInt("$ANGDIR", &varInt)) { |
854 | writer->writeInt16(70, varInt); |
855 | } else |
856 | writer->writeInt16(70, 0); |
857 | writer->writeString(9, "$PDMODE"); |
858 | if (getInt("$PDMODE", &varInt)) { |
859 | writer->writeInt16(70, varInt); |
860 | } else |
861 | writer->writeInt16(70, 34); |
862 | writer->writeString(9, "$PDSIZE"); |
863 | if (getDouble("$PDSIZE", &varDouble)) |
864 | writer->writeDouble(40, varDouble); |
865 | else |
866 | writer->writeDouble(40, 0.0); |
867 | writer->writeString(9, "$PLINEWID"); |
868 | if (getDouble("$PLINEWID", &varDouble)) |
869 | writer->writeDouble(40, varDouble); |
870 | else |
871 | writer->writeDouble(40, 0.0); |
872 | if (ver < DRW::AC1012) { |
873 | writer->writeString(9, "$COORDS"); |
874 | if (getInt("$COORDS", &varInt)) { |
875 | writer->writeInt16(70, varInt); |
876 | } else |
877 | writer->writeInt16(70, 2); |
878 | } |
879 | writer->writeString(9, "$SPLFRAME"); |
880 | if (getInt("$SPLFRAME", &varInt)) { |
881 | writer->writeInt16(70, varInt); |
882 | } else |
883 | writer->writeInt16(70, 0); |
884 | writer->writeString(9, "$SPLINETYPE"); |
885 | if (getInt("$SPLINETYPE", &varInt)) { |
886 | writer->writeInt16(70, varInt); |
887 | } else |
888 | writer->writeInt16(70, 2); |
889 | writer->writeString(9, "$SPLINESEGS"); |
890 | if (getInt("$SPLINESEGS", &varInt)) { |
891 | writer->writeInt16(70, varInt); |
892 | } else |
893 | writer->writeInt16(70, 8); |
894 | if (ver < DRW::AC1012) { |
895 | writer->writeString(9, "$ATTDIA"); |
896 | if (getInt("$ATTDIA", &varInt)) { |
897 | writer->writeInt16(70, varInt); |
898 | } else |
899 | writer->writeInt16(70, 1); |
900 | writer->writeString(9, "$ATTREQ"); |
901 | if (getInt("$ATTREQ", &varInt)) { |
902 | writer->writeInt16(70, varInt); |
903 | } else |
904 | writer->writeInt16(70, 1); |
905 | writer->writeString(9, "$HANDLING"); |
906 | if (getInt("$HANDLING", &varInt)) { |
907 | writer->writeInt16(70, varInt); |
908 | } else |
909 | writer->writeInt16(70, 1); |
910 | } |
911 | writer->writeString(9, "$HANDSEED"); |
912 | //RLZ dxfHex(5, 0xFFFF); |
913 | writer->writeString(5, "20000"); |
914 | writer->writeString(9, "$SURFTAB1"); |
915 | if (getInt("$SURFTAB1", &varInt)) { |
916 | writer->writeInt16(70, varInt); |
917 | } else |
918 | writer->writeInt16(70, 6); |
919 | writer->writeString(9, "$SURFTAB2"); |
920 | if (getInt("$SURFTAB2", &varInt)) { |
921 | writer->writeInt16(70, varInt); |
922 | } else |
923 | writer->writeInt16(70, 6); |
924 | writer->writeString(9, "$SURFTYPE"); |
925 | if (getInt("$SURFTYPE", &varInt)) { |
926 | writer->writeInt16(70, varInt); |
927 | } else |
928 | writer->writeInt16(70, 6); |
929 | writer->writeString(9, "$SURFU"); |
930 | if (getInt("$SURFU", &varInt)) { |
931 | writer->writeInt16(70, varInt); |
932 | } else |
933 | writer->writeInt16(70, 6); |
934 | writer->writeString(9, "$SURFV"); |
935 | if (getInt("$SURFV", &varInt)) { |
936 | writer->writeInt16(70, varInt); |
937 | } else |
938 | writer->writeInt16(70, 6); |
939 | if (ver > DRW::AC1009) { |
940 | writer->writeString(9, "$UCSBASE"); |
941 | if (getStr("$UCSBASE", &varStr)) |
942 | if (ver == DRW::AC1009) |
943 | writer->writeUtf8Caps(2, varStr); |
944 | else |
945 | writer->writeUtf8String(2, varStr); |
946 | else |
947 | writer->writeString(2, ""); |
948 | } |
949 | writer->writeString(9, "$UCSNAME"); |
950 | if (getStr("$UCSNAME", &varStr)) |
951 | if (ver == DRW::AC1009) |
952 | writer->writeUtf8Caps(2, varStr); |
953 | else |
954 | writer->writeUtf8String(2, varStr); |
955 | else |
956 | writer->writeString(2, ""); |
957 | writer->writeString(9, "$UCSORG"); |
958 | if (getCoord("$UCSORG", &varCoord)) { |
959 | writer->writeDouble(10, varCoord.x); |
960 | writer->writeDouble(20, varCoord.y); |
961 | writer->writeDouble(30, varCoord.z); |
962 | } else { |
963 | writer->writeDouble(10, 0.0); |
964 | writer->writeDouble(20, 0.0); |
965 | writer->writeDouble(30, 0.0); |
966 | } |
967 | writer->writeString(9, "$UCSXDIR"); |
968 | if (getCoord("$UCSXDIR", &varCoord)) { |
969 | writer->writeDouble(10, varCoord.x); |
970 | writer->writeDouble(20, varCoord.y); |
971 | writer->writeDouble(30, varCoord.z); |
972 | } else { |
973 | writer->writeDouble(10, 1.0); |
974 | writer->writeDouble(20, 0.0); |
975 | writer->writeDouble(30, 0.0); |
976 | } |
977 | writer->writeString(9, "$UCSYDIR"); |
978 | if (getCoord("$UCSYDIR", &varCoord)) { |
979 | writer->writeDouble(10, varCoord.x); |
980 | writer->writeDouble(20, varCoord.y); |
981 | writer->writeDouble(30, varCoord.z); |
982 | } else { |
983 | writer->writeDouble(10, 0.0); |
984 | writer->writeDouble(20, 1.0); |
985 | writer->writeDouble(30, 0.0); |
986 | } |
987 | if (ver > DRW::AC1009) { //begin post r12 UCS vars |
988 | writer->writeString(9, "$UCSORTHOREF"); |
989 | if (getStr("$UCSORTHOREF", &varStr)) |
990 | if (ver == DRW::AC1009) |
991 | writer->writeUtf8Caps(2, varStr); |
992 | else |
993 | writer->writeUtf8String(2, varStr); |
994 | else |
995 | writer->writeString(2, ""); |
996 | writer->writeString(9, "$UCSORTHOVIEW"); |
997 | if (getInt("$UCSORTHOVIEW", &varInt)) |
998 | writer->writeInt16(70, varInt); |
999 | else |
1000 | writer->writeInt16(70, 0); |
1001 | writer->writeString(9, "$UCSORGTOP"); |
1002 | if (getCoord("$UCSORGTOP", &varCoord)) { |
1003 | writer->writeDouble(10, varCoord.x); |
1004 | writer->writeDouble(20, varCoord.y); |
1005 | writer->writeDouble(30, varCoord.z); |
1006 | } else { |
1007 | writer->writeDouble(10, 0.0); |
1008 | writer->writeDouble(20, 0.0); |
1009 | writer->writeDouble(30, 0.0); |
1010 | } |
1011 | writer->writeString(9, "$UCSORGBOTTOM"); |
1012 | if (getCoord("$UCSORGBOTTOM", &varCoord)) { |
1013 | writer->writeDouble(10, varCoord.x); |
1014 | writer->writeDouble(20, varCoord.y); |
1015 | writer->writeDouble(30, varCoord.z); |
1016 | } else { |
1017 | writer->writeDouble(10, 0.0); |
1018 | writer->writeDouble(20, 0.0); |
1019 | writer->writeDouble(30, 0.0); |
1020 | } |
1021 | writer->writeString(9, "$UCSORGLEFT"); |
1022 | if (getCoord("$UCSORGLEFT", &varCoord)) { |
1023 | writer->writeDouble(10, varCoord.x); |
1024 | writer->writeDouble(20, varCoord.y); |
1025 | writer->writeDouble(30, varCoord.z); |
1026 | } else { |
1027 | writer->writeDouble(10, 0.0); |
1028 | writer->writeDouble(20, 0.0); |
1029 | writer->writeDouble(30, 0.0); |
1030 | } |
1031 | writer->writeString(9, "$UCSORGRIGHT"); |
1032 | if (getCoord("$UCSORGRIGHT", &varCoord)) { |
1033 | writer->writeDouble(10, varCoord.x); |
1034 | writer->writeDouble(20, varCoord.y); |
1035 | writer->writeDouble(30, varCoord.z); |
1036 | } else { |
1037 | writer->writeDouble(10, 0.0); |
1038 | writer->writeDouble(20, 0.0); |
1039 | writer->writeDouble(30, 0.0); |
1040 | } |
1041 | writer->writeString(9, "$UCSORGFRONT"); |
1042 | if (getCoord("$UCSORGFRONT", &varCoord)) { |
1043 | writer->writeDouble(10, varCoord.x); |
1044 | writer->writeDouble(20, varCoord.y); |
1045 | writer->writeDouble(30, varCoord.z); |
1046 | } else { |
1047 | writer->writeDouble(10, 0.0); |
1048 | writer->writeDouble(20, 0.0); |
1049 | writer->writeDouble(30, 0.0); |
1050 | } |
1051 | writer->writeString(9, "$UCSORGBACK"); |
1052 | if (getCoord("$UCSORGBACK", &varCoord)) { |
1053 | writer->writeDouble(10, varCoord.x); |
1054 | writer->writeDouble(20, varCoord.y); |
1055 | writer->writeDouble(30, varCoord.z); |
1056 | } else { |
1057 | writer->writeDouble(10, 0.0); |
1058 | writer->writeDouble(20, 0.0); |
1059 | writer->writeDouble(30, 0.0); |
1060 | } |
1061 | writer->writeString(9, "$PUCSBASE"); |
1062 | if (getStr("$PUCSBASE", &varStr)) |
1063 | if (ver == DRW::AC1009) |
1064 | writer->writeUtf8Caps(2, varStr); |
1065 | else |
1066 | writer->writeUtf8String(2, varStr); |
1067 | else |
1068 | writer->writeString(2, ""); |
1069 | } //end post r12 UCS vars |
1070 | writer->writeString(9, "$PUCSNAME"); |
1071 | if (getStr("$PUCSNAME", &varStr)) |
1072 | if (ver == DRW::AC1009) |
1073 | writer->writeUtf8Caps(2, varStr); |
1074 | else |
1075 | writer->writeUtf8String(2, varStr); |
1076 | else |
1077 | writer->writeString(2, ""); |
1078 | writer->writeString(9, "$PUCSORG"); |
1079 | if (getCoord("$PUCSORG", &varCoord)) { |
1080 | writer->writeDouble(10, varCoord.x); |
1081 | writer->writeDouble(20, varCoord.y); |
1082 | writer->writeDouble(30, varCoord.z); |
1083 | } else { |
1084 | writer->writeDouble(10, 0.0); |
1085 | writer->writeDouble(20, 0.0); |
1086 | writer->writeDouble(30, 0.0); |
1087 | } |
1088 | writer->writeString(9, "$PUCSXDIR"); |
1089 | if (getCoord("$PUCSXDIR", &varCoord)) { |
1090 | writer->writeDouble(10, varCoord.x); |
1091 | writer->writeDouble(20, varCoord.y); |
1092 | writer->writeDouble(30, varCoord.z); |
1093 | } else { |
1094 | writer->writeDouble(10, 1.0); |
1095 | writer->writeDouble(20, 0.0); |
1096 | writer->writeDouble(30, 0.0); |
1097 | } |
1098 | writer->writeString(9, "$PUCSYDIR"); |
1099 | if (getCoord("$PUCSYDIR", &varCoord)) { |
1100 | writer->writeDouble(10, varCoord.x); |
1101 | writer->writeDouble(20, varCoord.y); |
1102 | writer->writeDouble(30, varCoord.z); |
1103 | } else { |
1104 | writer->writeDouble(10, 0.0); |
1105 | writer->writeDouble(20, 1.0); |
1106 | writer->writeDouble(30, 0.0); |
1107 | } |
1108 | if (ver > DRW::AC1009) { //begin post r12 PUCS vars |
1109 | writer->writeString(9, "$PUCSORTHOREF"); |
1110 | if (getStr("$PUCSORTHOREF", &varStr)) |
1111 | if (ver == DRW::AC1009) |
1112 | writer->writeUtf8Caps(2, varStr); |
1113 | else |
1114 | writer->writeUtf8String(2, varStr); |
1115 | else |
1116 | writer->writeString(2, ""); |
1117 | writer->writeString(9, "$PUCSORTHOVIEW"); |
1118 | if (getInt("$PUCSORTHOVIEW", &varInt)) |
1119 | writer->writeInt16(70, varInt); |
1120 | else |
1121 | writer->writeInt16(70, 0); |
1122 | writer->writeString(9, "$PUCSORGTOP"); |
1123 | if (getCoord("$PUCSORGTOP", &varCoord)) { |
1124 | writer->writeDouble(10, varCoord.x); |
1125 | writer->writeDouble(20, varCoord.y); |
1126 | writer->writeDouble(30, varCoord.z); |
1127 | } else { |
1128 | writer->writeDouble(10, 0.0); |
1129 | writer->writeDouble(20, 0.0); |
1130 | writer->writeDouble(30, 0.0); |
1131 | } |
1132 | writer->writeString(9, "$PUCSORGBOTTOM"); |
1133 | if (getCoord("$PUCSORGBOTTOM", &varCoord)) { |
1134 | writer->writeDouble(10, varCoord.x); |
1135 | writer->writeDouble(20, varCoord.y); |
1136 | writer->writeDouble(30, varCoord.z); |
1137 | } else { |
1138 | writer->writeDouble(10, 0.0); |
1139 | writer->writeDouble(20, 0.0); |
1140 | writer->writeDouble(30, 0.0); |
1141 | } |
1142 | writer->writeString(9, "$PUCSORGLEFT"); |
1143 | if (getCoord("$PUCSORGLEFT", &varCoord)) { |
1144 | writer->writeDouble(10, varCoord.x); |
1145 | writer->writeDouble(20, varCoord.y); |
1146 | writer->writeDouble(30, varCoord.z); |
1147 | } else { |
1148 | writer->writeDouble(10, 0.0); |
1149 | writer->writeDouble(20, 0.0); |
1150 | writer->writeDouble(30, 0.0); |
1151 | } |
1152 | writer->writeString(9, "$PUCSORGRIGHT"); |
1153 | if (getCoord("$PUCSORGRIGHT", &varCoord)) { |
1154 | writer->writeDouble(10, varCoord.x); |
1155 | writer->writeDouble(20, varCoord.y); |
1156 | writer->writeDouble(30, varCoord.z); |
1157 | } else { |
1158 | writer->writeDouble(10, 0.0); |
1159 | writer->writeDouble(20, 0.0); |
1160 | writer->writeDouble(30, 0.0); |
1161 | } |
1162 | writer->writeString(9, "$PUCSORGFRONT"); |
1163 | if (getCoord("$PUCSORGFRONT", &varCoord)) { |
1164 | writer->writeDouble(10, varCoord.x); |
1165 | writer->writeDouble(20, varCoord.y); |
1166 | writer->writeDouble(30, varCoord.z); |
1167 | } else { |
1168 | writer->writeDouble(10, 0.0); |
1169 | writer->writeDouble(20, 0.0); |
1170 | writer->writeDouble(30, 0.0); |
1171 | } |
1172 | writer->writeString(9, "$PUCSORGBACK"); |
1173 | if (getCoord("$PUCSORGBACK", &varCoord)) { |
1174 | writer->writeDouble(10, varCoord.x); |
1175 | writer->writeDouble(20, varCoord.y); |
1176 | writer->writeDouble(30, varCoord.z); |
1177 | } else { |
1178 | writer->writeDouble(10, 0.0); |
1179 | writer->writeDouble(20, 0.0); |
1180 | writer->writeDouble(30, 0.0); |
1181 | } |
1182 | } //end post r12 PUCS vars |
1183 | |
1184 | writer->writeString(9, "$USERI1"); |
1185 | if (getInt("$USERI1", &varInt)) |
1186 | writer->writeInt16(70, varInt); |
1187 | else |
1188 | writer->writeInt16(70, 0); |
1189 | writer->writeString(9, "$USERI2"); |
1190 | if (getInt("$USERI2", &varInt)) |
1191 | writer->writeInt16(70, varInt); |
1192 | else |
1193 | writer->writeInt16(70, 0); |
1194 | writer->writeString(9, "$USERI3"); |
1195 | if (getInt("$USERI3", &varInt)) |
1196 | writer->writeInt16(70, varInt); |
1197 | else |
1198 | writer->writeInt16(70, 0); |
1199 | writer->writeString(9, "$USERI4"); |
1200 | if (getInt("$USERI4", &varInt)) |
1201 | writer->writeInt16(70, varInt); |
1202 | else |
1203 | writer->writeInt16(70, 0); |
1204 | writer->writeString(9, "$USERI5"); |
1205 | if (getInt("$USERI5", &varInt)) |
1206 | writer->writeInt16(70, varInt); |
1207 | else |
1208 | writer->writeInt16(70, 0); |
1209 | writer->writeString(9, "$USERR1"); |
1210 | if (getDouble("$USERR1", &varDouble)) |
1211 | writer->writeDouble(40, varDouble); |
1212 | else |
1213 | writer->writeDouble(40, 0.0); |
1214 | writer->writeString(9, "$USERR2"); |
1215 | if (getDouble("$USERR2", &varDouble)) |
1216 | writer->writeDouble(40, varDouble); |
1217 | else |
1218 | writer->writeDouble(40, 0.0); |
1219 | writer->writeString(9, "$USERR3"); |
1220 | if (getDouble("$USERR3", &varDouble)) |
1221 | writer->writeDouble(40, varDouble); |
1222 | else |
1223 | writer->writeDouble(40, 0.0); |
1224 | writer->writeString(9, "$USERR4"); |
1225 | if (getDouble("$USERR4", &varDouble)) |
1226 | writer->writeDouble(40, varDouble); |
1227 | else |
1228 | writer->writeDouble(40, 0.0); |
1229 | writer->writeString(9, "$USERR5"); |
1230 | if (getDouble("$USERR5", &varDouble)) |
1231 | writer->writeDouble(40, varDouble); |
1232 | else |
1233 | writer->writeDouble(40, 0.0); |
1234 | writer->writeString(9, "$WORLDVIEW"); |
1235 | if (getInt("$WORLDVIEW", &varInt)) |
1236 | writer->writeInt16(70, varInt); |
1237 | else |
1238 | writer->writeInt16(70, 1); |
1239 | writer->writeString(9, "$SHADEDGE"); |
1240 | if (getInt("$SHADEDGE", &varInt)) |
1241 | writer->writeInt16(70, varInt); |
1242 | else |
1243 | writer->writeInt16(70, 3); |
1244 | writer->writeString(9, "$SHADEDIF"); |
1245 | if (getInt("$SHADEDIF", &varInt)) |
1246 | writer->writeInt16(70, varInt); |
1247 | else |
1248 | writer->writeInt16(70, 70); |
1249 | writer->writeString(9, "$TILEMODE"); |
1250 | if (getInt("$TILEMODE", &varInt)) |
1251 | writer->writeInt16(70, varInt); |
1252 | else |
1253 | writer->writeInt16(70, 1); |
1254 | writer->writeString(9, "$MAXACTVP"); |
1255 | if (getInt("$MAXACTVP", &varInt)) |
1256 | writer->writeInt16(70, varInt); |
1257 | else |
1258 | writer->writeInt16(70, 64); |
1259 | if (ver > DRW::AC1009) { //begin post r12 PUCS vars |
1260 | writer->writeString(9, "$PINSBASE"); |
1261 | if (getCoord("$PINSBASE", &varCoord)) { |
1262 | writer->writeDouble(10, varCoord.x); |
1263 | writer->writeDouble(20, varCoord.y); |
1264 | writer->writeDouble(30, varCoord.z); |
1265 | } else { |
1266 | writer->writeDouble(10, 0.0); |
1267 | writer->writeDouble(20, 0.0); |
1268 | writer->writeDouble(30, 0.0); |
1269 | } |
1270 | } |
1271 | writer->writeString(9, "$PLIMCHECK"); |
1272 | if (getInt("$PLIMCHECK", &varInt)) |
1273 | writer->writeInt16(70, varInt); |
1274 | else |
1275 | writer->writeInt16(70, 0); |
1276 | writer->writeString(9, "$PEXTMIN"); |
1277 | if (getCoord("$PEXTMIN", &varCoord)) { |
1278 | writer->writeDouble(10, varCoord.x); |
1279 | writer->writeDouble(20, varCoord.y); |
1280 | writer->writeDouble(30, varCoord.z); |
1281 | } else { |
1282 | writer->writeDouble(10, 0.0); |
1283 | writer->writeDouble(20, 0.0); |
1284 | writer->writeDouble(30, 0.0); |
1285 | } |
1286 | writer->writeString(9, "$PEXTMAX"); |
1287 | if (getCoord("$PEXTMAX", &varCoord)) { |
1288 | writer->writeDouble(10, varCoord.x); |
1289 | writer->writeDouble(20, varCoord.y); |
1290 | writer->writeDouble(30, varCoord.z); |
1291 | } else { |
1292 | writer->writeDouble(10, 0.0); |
1293 | writer->writeDouble(20, 0.0); |
1294 | writer->writeDouble(30, 0.0); |
1295 | } |
1296 | |
1297 | /* RLZ: moved to active VPORT, but can write in header if present*/ |
1298 | if (getInt("$GRIDMODE", &varInt)) { |
1299 | writer->writeString(9, "$GRIDMODE"); |
1300 | writer->writeInt16(70, varInt); |
1301 | } |
1302 | if (getInt("$SNAPSTYLE", &varInt)) { |
1303 | writer->writeString(9, "$SNAPSTYLE"); |
1304 | writer->writeInt16(70, varInt); |
1305 | } |
1306 | if (getCoord("$GRIDUNIT", &varCoord)) { |
1307 | writer->writeString(9, "$GRIDUNIT"); |
1308 | writer->writeDouble(10, varCoord.x); |
1309 | writer->writeDouble(20, varCoord.y); |
1310 | } |
1311 | if (getCoord("$VIEWCTR", &varCoord)) { |
1312 | writer->writeString(9, "$VIEWCTR"); |
1313 | writer->writeDouble(10, varCoord.x); |
1314 | writer->writeDouble(20, varCoord.y); |
1315 | } |
1316 | /* RLZ: moved to active VPORT, but can write in header if present*/ |
1317 | |
1318 | writer->writeString(9, "$PLIMMIN"); |
1319 | if (getCoord("$PLIMMIN", &varCoord)) { |
1320 | writer->writeDouble(10, varCoord.x); |
1321 | writer->writeDouble(20, varCoord.y); |
1322 | } else { |
1323 | writer->writeDouble(10, 0.0); |
1324 | writer->writeDouble(20, 0.0); |
1325 | } |
1326 | writer->writeString(9, "$PLIMMAX"); |
1327 | if (getCoord("$PLIMMAX", &varCoord)) { |
1328 | writer->writeDouble(10, varCoord.x); |
1329 | writer->writeDouble(20, varCoord.y); |
1330 | } else { |
1331 | writer->writeDouble(10, 297.0); |
1332 | writer->writeDouble(20, 210.0); |
1333 | } |
1334 | writer->writeString(9, "$UNITMODE"); |
1335 | if (getInt("$UNITMODE", &varInt)) |
1336 | writer->writeInt16(70, varInt); |
1337 | else |
1338 | writer->writeInt16(70, 0); |
1339 | writer->writeString(9, "$VISRETAIN"); |
1340 | if (getInt("$VISRETAIN", &varInt)) |
1341 | writer->writeInt16(70, varInt); |
1342 | else |
1343 | writer->writeInt16(70, 1); |
1344 | writer->writeString(9, "$PLINEGEN"); |
1345 | if (getInt("$PLINEGEN", &varInt)) |
1346 | writer->writeInt16(70, varInt); |
1347 | else |
1348 | writer->writeInt16(70, 0); |
1349 | writer->writeString(9, "$PSLTSCALE"); |
1350 | if (getInt("$PSLTSCALE", &varInt)) |
1351 | writer->writeInt16(70, varInt); |
1352 | else |
1353 | writer->writeInt16(70, 1); |
1354 | if (ver > DRW::AC1009){//start port r12 vars |
1355 | writer->writeString(9, "$TREEDEPTH"); |
1356 | if (getInt("$TREEDEPTH", &varInt)) |
1357 | writer->writeInt16(70, varInt); |
1358 | else |
1359 | writer->writeInt16(70, 3020); |
1360 | writer->writeString(9, "$CMLSTYLE"); |
1361 | if (getStr("$CMLSTYLE", &varStr)) |
1362 | if (ver == DRW::AC1009) |
1363 | writer->writeUtf8Caps(2, varStr); |
1364 | else |
1365 | writer->writeUtf8String(2, varStr); |
1366 | else |
1367 | writer->writeString(2, "Standard"); |
1368 | writer->writeString(9, "$CMLJUST"); |
1369 | if (getInt("$CMLJUST", &varInt)) |
1370 | writer->writeInt16(70, varInt); |
1371 | else |
1372 | writer->writeInt16(70, 0); |
1373 | writer->writeString(9, "$CMLSCALE"); |
1374 | if (getDouble("$CMLSCALE", &varDouble)) |
1375 | writer->writeDouble(40, varDouble); |
1376 | else |
1377 | writer->writeDouble(40, 20.0); |
1378 | writer->writeString(9, "$PROXYGRAPHICS"); |
1379 | if (getInt("$PROXYGRAPHICS", &varInt)) |
1380 | writer->writeInt16(70, varInt); |
1381 | else |
1382 | writer->writeInt16(70, 1); |
1383 | int insunits {Units::None}; |
1384 | getInt("$INSUNITS", &insunits); // get $INSUNITS now to evaluate $MEASUREMENT |
1385 | getInt("$MEASUREMENT", &varInt); // just remove the variable from list |
1386 | writer->writeString(9, "$MEASUREMENT"); |
1387 | writer->writeInt16(70, measurement( insunits)); |
1388 | writer->writeString(9, "$CELWEIGHT"); |
1389 | if (getInt("$CELWEIGHT", &varInt)) |
1390 | writer->writeInt16(370, varInt); |
1391 | else |
1392 | writer->writeInt16(370, -1); |
1393 | writer->writeString(9, "$ENDCAPS"); |
1394 | if (getInt("$ENDCAPS", &varInt)) |
1395 | writer->writeInt16(280, varInt); |
1396 | else |
1397 | writer->writeInt16(280, 0); |
1398 | writer->writeString(9, "$JOINSTYLE"); |
1399 | if (getInt("$JOINSTYLE", &varInt)) |
1400 | writer->writeInt16(280, varInt); |
1401 | else |
1402 | writer->writeInt16(280, 0); |
1403 | writer->writeString(9, "$LWDISPLAY"); //RLZ bool flag, verify in bin version |
1404 | if (getInt("$LWDISPLAY", &varInt)) |
1405 | writer->writeInt16(290, varInt); |
1406 | else |
1407 | writer->writeInt16(290, 0); |
1408 | if (ver > DRW::AC1014) { |
1409 | writer->writeString(9, "$INSUNITS"); |
1410 | writer->writeInt16(70, insunits); // already fetched above for $MEASUREMENT |
1411 | } |
1412 | writer->writeString(9, "$HYPERLINKBASE"); |
1413 | if (getStr("$HYPERLINKBASE", &varStr)) |
1414 | if (ver == DRW::AC1009) |
1415 | writer->writeUtf8Caps(1, varStr); |
1416 | else |
1417 | writer->writeUtf8String(1, varStr); |
1418 | else |
1419 | writer->writeString(1, ""); |
1420 | writer->writeString(9, "$STYLESHEET"); |
1421 | if (getStr("$STYLESHEET", &varStr)) |
1422 | if (ver == DRW::AC1009) |
1423 | writer->writeUtf8Caps(1, varStr); |
1424 | else |
1425 | writer->writeUtf8String(1, varStr); |
1426 | else |
1427 | writer->writeString(1, ""); |
1428 | writer->writeString(9, "$XEDIT"); //RLZ bool flag, verify in bin version |
1429 | if (getInt("$XEDIT", &varInt)) |
1430 | writer->writeInt16(290, varInt); |
1431 | else |
1432 | writer->writeInt16(290, 1); |
1433 | writer->writeString(9, "$CEPSNTYPE"); |
1434 | if (getInt("$CEPSNTYPE", &varInt)) |
1435 | writer->writeInt16(380, varInt); |
1436 | else |
1437 | writer->writeInt16(380, 0); |
1438 | writer->writeString(9, "$PSTYLEMODE"); //RLZ bool flag, verify in bin version |
1439 | if (getInt("$PSTYLEMODE", &varInt)) |
1440 | writer->writeInt16(290, varInt); |
1441 | else |
1442 | writer->writeInt16(290, 1); |
1443 | //RLZ: here $FINGERPRINTGUID and $VERSIONGUID, do not add? |
1444 | writer->writeString(9, "$EXTNAMES"); //RLZ bool flag, verify in bin version |
1445 | if (getInt("$EXTNAMES", &varInt)) |
1446 | writer->writeInt16(290, varInt); |
1447 | else |
1448 | writer->writeInt16(290, 1); |
1449 | writer->writeString(9, "$PSVPSCALE"); |
1450 | if (getDouble("$PSVPSCALE", &varDouble)) |
1451 | writer->writeDouble(40, varDouble); |
1452 | else |
1453 | writer->writeDouble(40, 0.0); |
1454 | writer->writeString(9, "$OLESTARTUP"); //RLZ bool flag, verify in bin version |
1455 | if (getInt("$OLESTARTUP", &varInt)) |
1456 | writer->writeInt16(290, varInt); |
1457 | else |
1458 | writer->writeInt16(290, 0); |
1459 | } |
1460 | if (ver > DRW::AC1015) {// and post v2004 vars |
1461 | writer->writeString(9, "$SORTENTS"); |
1462 | if (getInt("$SORTENTS", &varInt)) |
1463 | writer->writeInt16(280, varInt); |
1464 | else |
1465 | writer->writeInt16(280, 127); |
1466 | writer->writeString(9, "$INDEXCTL"); |
1467 | if (getInt("$INDEXCTL", &varInt)) |
1468 | writer->writeInt16(280, varInt); |
1469 | else |
1470 | writer->writeInt16(280, 0); |
1471 | writer->writeString(9, "$HIDETEXT"); |
1472 | if (getInt("$HIDETEXT", &varInt)) |
1473 | writer->writeInt16(280, varInt); |
1474 | else |
1475 | writer->writeInt16(280, 1); |
1476 | writer->writeString(9, "$XCLIPFRAME"); //RLZ bool flag, verify in bin version |
1477 | if (ver > DRW::AC1021) { |
1478 | if (getInt("$XCLIPFRAME", &varInt)) |
1479 | writer->writeInt16(280, varInt); |
1480 | else |
1481 | writer->writeInt16(280, 0); |
1482 | } else { |
1483 | if (getInt("$XCLIPFRAME", &varInt)) |
1484 | writer->writeInt16(290, varInt); |
1485 | else |
1486 | writer->writeInt16(290, 0); |
1487 | } |
1488 | writer->writeString(9, "$HALOGAP"); |
1489 | if (getInt("$HALOGAP", &varInt)) |
1490 | writer->writeInt16(280, varInt); |
1491 | else |
1492 | writer->writeInt16(280, 0); |
1493 | writer->writeString(9, "$OBSCOLOR"); |
1494 | if (getInt("$OBSCOLOR", &varInt)) |
1495 | writer->writeInt16(70, varInt); |
1496 | else |
1497 | writer->writeInt16(70, 257); |
1498 | writer->writeString(9, "$OBSLTYPE"); |
1499 | if (getInt("$OBSLTYPE", &varInt)) |
1500 | writer->writeInt16(280, varInt); |
1501 | else |
1502 | writer->writeInt16(280, 0); |
1503 | writer->writeString(9, "$INTERSECTIONDISPLAY"); |
1504 | if (getInt("$INTERSECTIONDISPLAY", &varInt)) |
1505 | writer->writeInt16(280, varInt); |
1506 | else |
1507 | writer->writeInt16(280, 0); |
1508 | writer->writeString(9, "$INTERSECTIONCOLOR"); |
1509 | if (getInt("$INTERSECTIONCOLOR", &varInt)) |
1510 | writer->writeInt16(70, varInt); |
1511 | else |
1512 | writer->writeInt16(70, 257); |
1513 | writer->writeString(9, "$DIMASSOC"); |
1514 | if (getInt("$DIMASSOC", &varInt)) |
1515 | writer->writeInt16(280, varInt); |
1516 | else |
1517 | writer->writeInt16(280, 1); |
1518 | writer->writeString(9, "$PROJECTNAME"); |
1519 | if (getStr("$PROJECTNAME", &varStr)) |
1520 | writer->writeUtf8String(1, varStr); |
1521 | else |
1522 | writer->writeString(1, ""); |
1523 | } |
1524 | if (ver > DRW::AC1018) {// and post v2007 vars |
1525 | writer->writeString(9, "$CAMERADISPLAY"); //RLZ bool flag, verify in bin version |
1526 | if (getInt("$CAMERADISPLAY", &varInt)) |
1527 | writer->writeInt16(290, varInt); |
1528 | else |
1529 | writer->writeInt16(290, 0); |
1530 | writer->writeString(9, "$LENSLENGTH"); |
1531 | if (getDouble("$LENSLENGTH", &varDouble)) |
1532 | writer->writeDouble(40, varDouble); |
1533 | else |
1534 | writer->writeDouble(40, 50.0); |
1535 | writer->writeString(9, "$CAMERAHEIGHT"); |
1536 | if (getDouble("$CAMERAHEIGHT", &varDouble)) |
1537 | writer->writeDouble(40, varDouble); |
1538 | else |
1539 | writer->writeDouble(40, 0.0); |
1540 | writer->writeString(9, "$STEPSPERSEC"); |
1541 | if (getDouble("$STEPSPERSEC", &varDouble)) |
1542 | writer->writeDouble(40, varDouble); |
1543 | else |
1544 | writer->writeDouble(40, 2.0); |
1545 | writer->writeString(9, "$STEPSIZE"); |
1546 | if (getDouble("$STEPSIZE", &varDouble)) |
1547 | writer->writeDouble(40, varDouble); |
1548 | else |
1549 | writer->writeDouble(40, 50.0); |
1550 | writer->writeString(9, "$3DDWFPREC"); |
1551 | if (getDouble("$3DDWFPREC", &varDouble)) |
1552 | writer->writeDouble(40, varDouble); |
1553 | else |
1554 | writer->writeDouble(40, 2.0); |
1555 | writer->writeString(9, "$PSOLWIDTH"); |
1556 | if (getDouble("$PSOLWIDTH", &varDouble)) |
1557 | writer->writeDouble(40, varDouble); |
1558 | else |
1559 | writer->writeDouble(40, 5.0); |
1560 | writer->writeString(9, "$PSOLHEIGHT"); |
1561 | if (getDouble("$PSOLHEIGHT", &varDouble)) |
1562 | writer->writeDouble(40, varDouble); |
1563 | else |
1564 | writer->writeDouble(40, 80.0); |
1565 | writer->writeString(9, "$LOFTANG1"); |
1566 | if (getDouble("$LOFTANG1", &varDouble)) |
1567 | writer->writeDouble(40, varDouble); |
1568 | else |
1569 | writer->writeDouble(40, M_PI_21.57079632679489661923); |
1570 | writer->writeString(9, "$LOFTANG2"); |
1571 | if (getDouble("$LOFTANG2", &varDouble)) |
1572 | writer->writeDouble(40, varDouble); |
1573 | else |
1574 | writer->writeDouble(40, M_PI_21.57079632679489661923); |
1575 | writer->writeString(9, "$LOFTMAG1"); |
1576 | if (getDouble("$LOFTMAG1", &varDouble)) |
1577 | writer->writeDouble(40, varDouble); |
1578 | else |
1579 | writer->writeDouble(40, 0.0); |
1580 | writer->writeString(9, "$LOFTMAG2"); |
1581 | if (getDouble("$LOFTMAG2", &varDouble)) |
1582 | writer->writeDouble(40, varDouble); |
1583 | else |
1584 | writer->writeDouble(40, 0.0); |
1585 | writer->writeString(9, "$LOFTPARAM"); |
1586 | if (getInt("$LOFTPARAM", &varInt)) |
1587 | writer->writeInt16(70, varInt); |
1588 | else |
1589 | writer->writeInt16(70, 7); |
1590 | writer->writeString(9, "$LOFTNORMALS"); |
1591 | if (getInt("$LOFTNORMALS", &varInt)) |
1592 | writer->writeInt16(280, varInt); |
1593 | else |
1594 | writer->writeInt16(280, 1); |
1595 | writer->writeString(9, "$LATITUDE"); |
1596 | if (getDouble("$LATITUDE", &varDouble)) |
1597 | writer->writeDouble(40, varDouble); |
1598 | else |
1599 | writer->writeDouble(40, 1.0); |
1600 | writer->writeString(9, "$LONGITUDE"); |
1601 | if (getDouble("$LONGITUDE", &varDouble)) |
1602 | writer->writeDouble(40, varDouble); |
1603 | else |
1604 | writer->writeDouble(40, 1.0); |
1605 | writer->writeString(9, "$NORTHDIRECTION"); |
1606 | if (getDouble("$LONGITUDE", &varDouble)) |
1607 | writer->writeDouble(40, varDouble); |
1608 | else |
1609 | writer->writeDouble(40, 0.0); |
1610 | writer->writeString(9, "$TIMEZONE"); |
1611 | if (getInt("$TIMEZONE", &varInt)) |
1612 | writer->writeInt16(70, varInt); |
1613 | else |
1614 | writer->writeInt16(70, -8000); |
1615 | writer->writeString(9, "$LIGHTGLYPHDISPLAY"); |
1616 | if (getInt("$LIGHTGLYPHDISPLAY", &varInt)) |
1617 | writer->writeInt16(280, varInt); |
1618 | else |
1619 | writer->writeInt16(280, 1); |
1620 | writer->writeString(9, "$TILEMODELIGHTSYNCH"); |
1621 | if (getInt("$TILEMODELIGHTSYNCH", &varInt)) |
1622 | writer->writeInt16(280, varInt); |
1623 | else |
1624 | writer->writeInt16(280, 1); |
1625 | //$CMATERIAL is a handle |
1626 | writer->writeString(9, "$SOLIDHIST"); |
1627 | if (getInt("$SOLIDHIST", &varInt)) |
1628 | writer->writeInt16(280, varInt); |
1629 | else |
1630 | writer->writeInt16(280, 1); |
1631 | writer->writeString(9, "$SHOWHIST"); |
1632 | if (getInt("$SHOWHIST", &varInt)) |
1633 | writer->writeInt16(280, varInt); |
1634 | else |
1635 | writer->writeInt16(280, 1); |
1636 | writer->writeString(9, "$DWFFRAME"); |
1637 | if (getInt("$DWFFRAME", &varInt)) |
1638 | writer->writeInt16(280, varInt); |
1639 | else |
1640 | writer->writeInt16(280, 2); |
1641 | writer->writeString(9, "$DGNFRAME"); |
1642 | if (getInt("$DGNFRAME", &varInt)) |
1643 | writer->writeInt16(280, varInt); |
1644 | else |
1645 | writer->writeInt16(280, 0); |
1646 | writer->writeString(9, "$REALWORLDSCALE"); //RLZ bool flag, verify in bin version |
1647 | if (getInt("$REALWORLDSCALE", &varInt)) |
1648 | writer->writeInt16(290, varInt); |
1649 | else |
1650 | writer->writeInt16(290, 1); |
1651 | writer->writeString(9, "$INTERFERECOLOR"); |
1652 | if (getInt("$INTERFERECOLOR", &varInt)) |
1653 | writer->writeInt16(62, varInt); |
1654 | else |
1655 | writer->writeInt16(62, 1); |
1656 | //$INTERFEREOBJVS is a handle |
1657 | //$INTERFEREVPVS is a handle |
1658 | writer->writeString(9, "$CSHADOW"); |
1659 | if (getInt("$CSHADOW", &varInt)) |
1660 | writer->writeInt16(280, varInt); |
1661 | else |
1662 | writer->writeInt16(280, 0); |
1663 | writer->writeString(9, "$SHADOWPLANELOCATION"); |
1664 | if (getDouble("$SHADOWPLANELOCATION", &varDouble)) |
1665 | writer->writeDouble(40, varDouble); |
1666 | else |
1667 | writer->writeDouble(40, 0.0); |
1668 | } |
1669 | |
1670 | #ifdef DRW_DBG |
1671 | for ( auto it=vars.begin() ; it != vars.end(); ++it ){ |
1672 | DRW_DBG((*it).first)DRW_dbg::getInstance()->print((*it).first); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1673 | } |
1674 | #endif |
1675 | } |
1676 | |
1677 | void DRW_Header::addDouble(std::string key, double value, int code){ |
1678 | curr = new DRW_Variant(code, value); |
1679 | vars[key] =curr; |
1680 | } |
1681 | |
1682 | void DRW_Header::addInt(std::string key, int value, int code){ |
1683 | curr = new DRW_Variant(code, value); |
1684 | vars[key] =curr; |
1685 | } |
1686 | |
1687 | void DRW_Header::addStr(std::string key, std::string value, int code){ |
1688 | curr = new DRW_Variant(code, value); |
1689 | vars[key] =curr; |
1690 | } |
1691 | |
1692 | void DRW_Header::addCoord(std::string key, DRW_Coord value, int code){ |
1693 | curr = new DRW_Variant(code, value); |
1694 | vars[key] =curr; |
1695 | } |
1696 | |
1697 | bool DRW_Header::getDouble(std::string key, double *varDouble){ |
1698 | bool result = false; |
1699 | auto it=vars.find( key); |
1700 | if (it != vars.end()) { |
1701 | DRW_Variant *var = (*it).second; |
1702 | if (var->type() == DRW_Variant::DOUBLE) { |
1703 | *varDouble = var->content.d; |
1704 | result = true; |
1705 | } |
1706 | delete var; |
1707 | vars.erase (it); |
1708 | } |
1709 | return result; |
1710 | } |
1711 | |
1712 | bool DRW_Header::getInt(std::string key, int *varInt){ |
1713 | bool result = false; |
1714 | auto it=vars.find( key); |
1715 | if (it != vars.end()) { |
1716 | DRW_Variant *var = (*it).second; |
1717 | if (var->type() == DRW_Variant::INTEGER) { |
1718 | *varInt = var->content.i; |
1719 | result = true; |
1720 | } |
1721 | delete var; |
1722 | vars.erase (it); |
1723 | } |
1724 | return result; |
1725 | } |
1726 | |
1727 | bool DRW_Header::getStr(std::string key, std::string *varStr){ |
1728 | bool result = false; |
1729 | auto it=vars.find( key); |
1730 | if (it != vars.end()) { |
1731 | DRW_Variant *var = (*it).second; |
1732 | if (var->type() == DRW_Variant::STRING) { |
1733 | *varStr = *var->content.s; |
1734 | result = true; |
1735 | } |
1736 | delete var; |
1737 | vars.erase (it); |
1738 | } |
1739 | return result; |
1740 | } |
1741 | |
1742 | bool DRW_Header::getCoord(std::string key, DRW_Coord *varCoord){ |
1743 | bool result = false; |
1744 | auto it=vars.find( key); |
1745 | if (it != vars.end()) { |
1746 | DRW_Variant *var = (*it).second; |
1747 | if (var->type() == DRW_Variant::COORD) { |
1748 | *varCoord = *var->content.v; |
1749 | result = true; |
1750 | } |
1751 | delete var; |
1752 | vars.erase (it); |
1753 | } |
1754 | return result; |
1755 | } |
1756 | |
1757 | bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 maintenanceVersion){ |
1758 | bool result = true; |
1759 | duint32 size = buf->getRawLong32(); |
1760 | duint32 bitSize = 0; |
1761 | duint32 endBitPos = 160; //start bit: 16 sentinel + 4 size |
1762 | DRW_DBG("\nbyte size of data: ")DRW_dbg::getInstance()->print("\nbyte size of data: "); DRW_DBG(size)DRW_dbg::getInstance()->print(size); |
1763 | if ((DRW::AC1024 <= version && 3 < maintenanceVersion) |
1764 | || DRW::AC1032 <= version) { //2010+ |
1765 | duint32 hSize = buf->getRawLong32(); |
1766 | endBitPos += 32; //start bit: + 4 height size |
1767 | DRW_DBG("\n2010+ & MV> 3, height 32b: ")DRW_dbg::getInstance()->print("\n2010+ & MV> 3, height 32b: " ); DRW_DBG(hSize)DRW_dbg::getInstance()->print(hSize); |
1768 | } |
1769 | //RLZ TODO add $ACADVER var & $DWGCODEPAGE & $MEASUREMENT |
1770 | //RLZ TODO EN 2000 falta $CELWEIGHT, $ENDCAPS, $EXTNAMES $JOINSTYLE $LWDISPLAY $PSTYLEMODE $TDUCREATE $TDUUPDATE $XEDIT |
1771 | |
1772 | //bit size of data needed to locate start of string stream in 2007+ |
1773 | //and mark the start of handle stream |
1774 | //header is one object reads data and continue read strings ??? |
1775 | if (version > DRW::AC1018) {//2007+ |
1776 | bitSize = buf->getRawLong32(); |
1777 | DRW_DBG("\nsize in bits: ")DRW_dbg::getInstance()->print("\nsize in bits: "); DRW_DBG(bitSize)DRW_dbg::getInstance()->print(bitSize); |
1778 | endBitPos += bitSize; |
1779 | hBbuf->setPosition(endBitPos >>3); |
1780 | hBbuf->setBitPos(endBitPos&7); |
1781 | } |
1782 | |
1783 | if (version > DRW::AC1024) {//2013+ |
1784 | duint64 requiredVersions = buf->getBitLongLong(); |
1785 | DRW_DBG("\nREQUIREDVERSIONS var: ")DRW_dbg::getInstance()->print("\nREQUIREDVERSIONS var: "); DRW_DBG(requiredVersions)DRW_dbg::getInstance()->print(requiredVersions); |
1786 | } |
1787 | DRW_DBG("\nUnknown1: ")DRW_dbg::getInstance()->print("\nUnknown1: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
1788 | DRW_DBG("\nUnknown2: ")DRW_dbg::getInstance()->print("\nUnknown2: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
1789 | DRW_DBG("\nUnknown3: ")DRW_dbg::getInstance()->print("\nUnknown3: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
1790 | DRW_DBG("\nUnknown4: ")DRW_dbg::getInstance()->print("\nUnknown4: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
1791 | if (version < DRW::AC1021) {//2007- |
1792 | DRW_DBG("\nUnknown text1: ")DRW_dbg::getInstance()->print("\nUnknown text1: "); DRW_DBG(buf->getCP8Text())DRW_dbg::getInstance()->print(buf->getCP8Text()); |
1793 | DRW_DBG("\nUnknown text2: ")DRW_dbg::getInstance()->print("\nUnknown text2: "); DRW_DBG(buf->getCP8Text())DRW_dbg::getInstance()->print(buf->getCP8Text()); |
1794 | DRW_DBG("\nUnknown text3: ")DRW_dbg::getInstance()->print("\nUnknown text3: "); DRW_DBG(buf->getCP8Text())DRW_dbg::getInstance()->print(buf->getCP8Text()); |
1795 | DRW_DBG("\nUnknown text4: ")DRW_dbg::getInstance()->print("\nUnknown text4: "); DRW_DBG(buf->getCP8Text())DRW_dbg::getInstance()->print(buf->getCP8Text()); |
1796 | } |
1797 | DRW_DBG("\nUnknown long1 (24L): ")DRW_dbg::getInstance()->print("\nUnknown long1 (24L): "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1798 | DRW_DBG("\nUnknown long2 (0L): ")DRW_dbg::getInstance()->print("\nUnknown long2 (0L): "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1799 | if (version < DRW::AC1015) {//pre 2000 |
1800 | DRW_DBG("\nUnknown short (0): ")DRW_dbg::getInstance()->print("\nUnknown short (0): "); DRW_DBG(buf->getBitShort())DRW_dbg::getInstance()->print(buf->getBitShort()); |
1801 | } |
1802 | if (version < DRW::AC1018) {//pre 2004 |
1803 | dwgHandle hcv = hBbuf->getHandle(); |
1804 | DRW_DBG("\nhandle of current view: ")DRW_dbg::getInstance()->print("\nhandle of current view: " ); DRW_DBGHL(hcv.code, hcv.size, hcv.ref)DRW_dbg::getInstance()->printHL(hcv.code, hcv.size ,hcv.ref ); |
1805 | } |
1806 | vars["DIMASO"]=new DRW_Variant(70, buf->getBit()); |
1807 | vars["DIMSHO"]=new DRW_Variant(70, buf->getBit()); |
1808 | if (version < DRW::AC1015) {//pre 2000 |
1809 | vars["DIMSAV"]=new DRW_Variant(70, buf->getBit()); |
1810 | } |
1811 | vars["PLINEGEN"]=new DRW_Variant(70, buf->getBit()); |
1812 | vars["ORTHOMODE"]=new DRW_Variant(70, buf->getBit()); |
1813 | vars["REGENMODE"]=new DRW_Variant(70, buf->getBit()); |
1814 | vars["FILLMODE"]=new DRW_Variant(70, buf->getBit()); |
1815 | vars["QTEXTMODE"]=new DRW_Variant(70, buf->getBit()); |
1816 | vars["PSLTSCALE"]=new DRW_Variant(70, buf->getBit()); |
1817 | vars["LIMCHECK"]=new DRW_Variant(70, buf->getBit()); |
1818 | if (version < DRW::AC1015) {//pre 2000 |
1819 | vars["BLIPMODE"]=new DRW_Variant(70, buf->getBit()); |
1820 | } |
1821 | if (version > DRW::AC1015) {//2004+ |
1822 | DRW_DBG("\nUndocumented: ")DRW_dbg::getInstance()->print("\nUndocumented: "); DRW_DBG(buf->getBit())DRW_dbg::getInstance()->print(buf->getBit()); |
1823 | } |
1824 | vars["USRTIMER"]=new DRW_Variant(70, buf->getBit()); |
1825 | vars["SKPOLY"]=new DRW_Variant(70, buf->getBit()); |
1826 | vars["ANGDIR"]=new DRW_Variant(70, buf->getBit()); |
1827 | vars["SPLFRAME"]=new DRW_Variant(70, buf->getBit()); |
1828 | if (version < DRW::AC1015) {//pre 2000 |
1829 | vars["ATTREQ"]=new DRW_Variant(70, buf->getBit()); |
1830 | vars["ATTDIA"]=new DRW_Variant(70, buf->getBit()); |
1831 | } |
1832 | vars["MIRRTEXT"]=new DRW_Variant(70, buf->getBit()); |
1833 | vars["WORLDVIEW"]=new DRW_Variant(70, buf->getBit()); |
1834 | if (version < DRW::AC1015) {//pre 2000 |
1835 | vars["WIREFRAME"]=new DRW_Variant(70, buf->getBit()); |
1836 | } |
1837 | vars["TILEMODE"]=new DRW_Variant(70, buf->getBit()); |
1838 | vars["PLIMCHECK"]=new DRW_Variant(70, buf->getBit()); |
1839 | vars["VISRETAIN"]=new DRW_Variant(70, buf->getBit()); |
1840 | if (version < DRW::AC1015) {//pre 2000 |
1841 | vars["DELOBJ"]=new DRW_Variant(70, buf->getBit()); |
1842 | } |
1843 | vars["DISPSILH"]=new DRW_Variant(70, buf->getBit()); |
1844 | vars["PELLIPSE"]=new DRW_Variant(70, buf->getBit()); |
1845 | vars["PROXIGRAPHICS"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit?? |
1846 | if (version < DRW::AC1015) {//pre 2000 |
1847 | vars["DRAGMODE"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit?? |
1848 | } |
1849 | vars["TREEDEPTH"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit?? |
1850 | vars["LUNITS"]=new DRW_Variant(70, buf->getBitShort()); |
1851 | vars["LUPREC"]=new DRW_Variant(70, buf->getBitShort()); |
1852 | vars["AUNITS"]=new DRW_Variant(70, buf->getBitShort()); |
1853 | vars["AUPREC"]=new DRW_Variant(70, buf->getBitShort()); |
1854 | if (version < DRW::AC1015) {//pre 2000 |
1855 | vars["OSMODE"]=new DRW_Variant(70, buf->getBitShort()); |
1856 | } |
1857 | vars["ATTMODE"]=new DRW_Variant(70, buf->getBitShort()); |
1858 | if (version < DRW::AC1015) {//pre 2000 |
1859 | vars["COORDS"]=new DRW_Variant(70, buf->getBitShort()); |
1860 | } |
1861 | vars["PDMODE"]=new DRW_Variant(70, buf->getBitShort()); |
1862 | if (version < DRW::AC1015) {//pre 2000 |
1863 | vars["PICKSTYLE"]=new DRW_Variant(70, buf->getBitShort()); |
1864 | } |
1865 | if (version > DRW::AC1015) {//2004+ |
1866 | DRW_DBG("\nUnknown long 1: ")DRW_dbg::getInstance()->print("\nUnknown long 1: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1867 | DRW_DBG("\nUnknown long 2: ")DRW_dbg::getInstance()->print("\nUnknown long 2: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1868 | DRW_DBG("\nUnknown long 3: ")DRW_dbg::getInstance()->print("\nUnknown long 3: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1869 | } |
1870 | vars["USERI1"]=new DRW_Variant(70, buf->getBitShort()); |
1871 | vars["USERI2"]=new DRW_Variant(70, buf->getBitShort()); |
1872 | vars["USERI3"]=new DRW_Variant(70, buf->getBitShort()); |
1873 | vars["USERI4"]=new DRW_Variant(70, buf->getBitShort()); |
1874 | vars["USERI5"]=new DRW_Variant(70, buf->getBitShort()); |
1875 | vars["SPLINESEGS"]=new DRW_Variant(70, buf->getBitShort()); |
1876 | vars["SURFU"]=new DRW_Variant(70, buf->getBitShort()); |
1877 | vars["SURFV"]=new DRW_Variant(70, buf->getBitShort()); |
1878 | vars["SURFTYPE"]=new DRW_Variant(70, buf->getBitShort()); |
1879 | vars["SURFTAB1"]=new DRW_Variant(70, buf->getBitShort()); |
1880 | vars["SURFTAB2"]=new DRW_Variant(70, buf->getBitShort()); |
1881 | vars["SPLINETYPE"]=new DRW_Variant(70, buf->getBitShort()); |
1882 | vars["SHADEDGE"]=new DRW_Variant(70, buf->getBitShort()); |
1883 | vars["SHADEDIF"]=new DRW_Variant(70, buf->getBitShort()); |
1884 | vars["UNITMODE"]=new DRW_Variant(70, buf->getBitShort()); |
1885 | vars["MAXACTVP"]=new DRW_Variant(70, buf->getBitShort()); |
1886 | vars["ISOLINES"]=new DRW_Variant(70, buf->getBitShort());////////////////// |
1887 | vars["CMLJUST"]=new DRW_Variant(70, buf->getBitShort()); |
1888 | vars["TEXTQLTY"]=new DRW_Variant(70, buf->getBitShort());///////////////////// |
1889 | vars["LTSCALE"]=new DRW_Variant(40, buf->getBitDouble()); |
1890 | vars["TEXTSIZE"]=new DRW_Variant(40, buf->getBitDouble()); |
1891 | vars["TRACEWID"]=new DRW_Variant(40, buf->getBitDouble()); |
1892 | vars["SKETCHINC"]=new DRW_Variant(40, buf->getBitDouble()); |
1893 | vars["FILLETRAD"]=new DRW_Variant(40, buf->getBitDouble()); |
1894 | vars["THICKNESS"]=new DRW_Variant(40, buf->getBitDouble()); |
1895 | vars["ANGBASE"]=new DRW_Variant(50, buf->getBitDouble()); |
1896 | vars["PDSIZE"]=new DRW_Variant(40, buf->getBitDouble()); |
1897 | vars["PLINEWID"]=new DRW_Variant(40, buf->getBitDouble()); |
1898 | vars["USERR1"]=new DRW_Variant(40, buf->getBitDouble()); |
1899 | vars["USERR2"]=new DRW_Variant(40, buf->getBitDouble()); |
1900 | vars["USERR3"]=new DRW_Variant(40, buf->getBitDouble()); |
1901 | vars["USERR4"]=new DRW_Variant(40, buf->getBitDouble()); |
1902 | vars["USERR5"]=new DRW_Variant(40, buf->getBitDouble()); |
1903 | vars["CHAMFERA"]=new DRW_Variant(40, buf->getBitDouble()); |
1904 | vars["CHAMFERB"]=new DRW_Variant(40, buf->getBitDouble()); |
1905 | vars["CHAMFERC"]=new DRW_Variant(40, buf->getBitDouble()); |
1906 | vars["CHAMFERD"]=new DRW_Variant(40, buf->getBitDouble()); |
1907 | vars["FACETRES"]=new DRW_Variant(40, buf->getBitDouble());///////////////////////// |
1908 | vars["CMLSCALE"]=new DRW_Variant(40, buf->getBitDouble()); |
1909 | vars["CELTSCALE"]=new DRW_Variant(40, buf->getBitDouble()); |
1910 | if (version < DRW::AC1021) {//2004- |
1911 | vars["MENU"]=new DRW_Variant(1, buf->getCP8Text()); |
1912 | } |
1913 | ddouble64 msec, day; |
1914 | day = buf->getBitLong(); |
1915 | msec = buf->getBitLong(); |
1916 | while (msec > 0) |
1917 | msec /=10; |
1918 | vars["TDCREATE"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec |
1919 | // vars["TDCREATE"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1920 | // vars["TDCREATE"]=new DRW_Variant(40, buf->getBitLong()); |
1921 | day = buf->getBitLong(); |
1922 | msec = buf->getBitLong(); |
1923 | while (msec > 0) |
1924 | msec /=10; |
1925 | vars["TDUPDATE"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec |
1926 | // vars["TDUPDATE"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1927 | // vars["TDUPDATE"]=new DRW_Variant(40, buf->getBitLong()); |
1928 | if (version > DRW::AC1015) {//2004+ |
1929 | DRW_DBG("\nUnknown long 4: ")DRW_dbg::getInstance()->print("\nUnknown long 4: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1930 | DRW_DBG("\nUnknown long 5: ")DRW_dbg::getInstance()->print("\nUnknown long 5: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1931 | DRW_DBG("\nUnknown long 6: ")DRW_dbg::getInstance()->print("\nUnknown long 6: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
1932 | } |
1933 | day = buf->getBitLong(); |
1934 | msec = buf->getBitLong(); |
1935 | while (msec > 0) |
1936 | msec /=10; |
1937 | vars["TDINDWG"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec |
1938 | // vars["TDINDWG"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1939 | // vars["TDINDWG"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1940 | day = buf->getBitLong(); |
1941 | msec = buf->getBitLong(); |
1942 | while (msec > 0) |
1943 | msec /=10; |
1944 | vars["TDUSRTIMER"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec |
1945 | // vars["TDUSRTIMER"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1946 | // vars["TDUSRTIMER"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec |
1947 | vars["CECOLOR"]=new DRW_Variant(62, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color |
1948 | dwgHandle HANDSEED = buf->getHandle();//always present in data stream |
1949 | DRW_DBG("\nHANDSEED: ")DRW_dbg::getInstance()->print("\nHANDSEED: "); DRW_DBGHL(HANDSEED.code, HANDSEED.size, HANDSEED.ref)DRW_dbg::getInstance()->printHL(HANDSEED.code, HANDSEED.size ,HANDSEED.ref); |
1950 | dwgHandle CLAYER = hBbuf->getHandle(); |
1951 | DRW_DBG("\nCLAYER: ")DRW_dbg::getInstance()->print("\nCLAYER: "); DRW_DBGHL(CLAYER.code, CLAYER.size, CLAYER.ref)DRW_dbg::getInstance()->printHL(CLAYER.code, CLAYER.size , CLAYER.ref); |
1952 | dwgHandle TEXTSTYLE = hBbuf->getHandle(); |
1953 | DRW_DBG("\nTEXTSTYLE: ")DRW_dbg::getInstance()->print("\nTEXTSTYLE: "); DRW_DBGHL(TEXTSTYLE.code, TEXTSTYLE.size, TEXTSTYLE.ref)DRW_dbg::getInstance()->printHL(TEXTSTYLE.code, TEXTSTYLE. size ,TEXTSTYLE.ref); |
1954 | dwgHandle CELTYPE = hBbuf->getHandle(); |
1955 | DRW_DBG("\nCELTYPE: ")DRW_dbg::getInstance()->print("\nCELTYPE: "); DRW_DBGHL(CELTYPE.code, CELTYPE.size, CELTYPE.ref)DRW_dbg::getInstance()->printHL(CELTYPE.code, CELTYPE.size ,CELTYPE.ref); |
1956 | if (version > DRW::AC1018) {//2007+ |
1957 | dwgHandle CMATERIAL = hBbuf->getHandle(); |
1958 | DRW_DBG("\nCMATERIAL: ")DRW_dbg::getInstance()->print("\nCMATERIAL: "); DRW_DBGHL(CMATERIAL.code, CMATERIAL.size, CMATERIAL.ref)DRW_dbg::getInstance()->printHL(CMATERIAL.code, CMATERIAL. size ,CMATERIAL.ref); |
1959 | } |
1960 | dwgHandle DIMSTYLE = hBbuf->getHandle(); |
1961 | DRW_DBG("\nDIMSTYLE: ")DRW_dbg::getInstance()->print("\nDIMSTYLE: "); DRW_DBGHL(DIMSTYLE.code, DIMSTYLE.size, DIMSTYLE.ref)DRW_dbg::getInstance()->printHL(DIMSTYLE.code, DIMSTYLE.size ,DIMSTYLE.ref); |
1962 | dwgHandle CMLSTYLE = hBbuf->getHandle(); |
1963 | DRW_DBG("\nCMLSTYLE: ")DRW_dbg::getInstance()->print("\nCMLSTYLE: "); DRW_DBGHL(CMLSTYLE.code, CMLSTYLE.size, CMLSTYLE.ref)DRW_dbg::getInstance()->printHL(CMLSTYLE.code, CMLSTYLE.size ,CMLSTYLE.ref); |
1964 | if (version > DRW::AC1014) {//2000+ |
1965 | vars["PSVPSCALE"]=new DRW_Variant(40, buf->getBitDouble()); |
1966 | } |
1967 | vars["PINSBASE"]=new DRW_Variant(10, buf->get3BitDouble()); |
1968 | vars["PEXTMIN"]=new DRW_Variant(10, buf->get3BitDouble()); |
1969 | vars["PEXTMAX"]=new DRW_Variant(10, buf->get3BitDouble()); |
1970 | vars["PLIMMIN"]=new DRW_Variant(10, buf->get2RawDouble()); |
1971 | vars["PLIMMAX"]=new DRW_Variant(10, buf->get2RawDouble()); |
1972 | vars["PELEVATION"]=new DRW_Variant(40, buf->getBitDouble()); |
1973 | vars["PUCSORG"]=new DRW_Variant(10, buf->get3BitDouble()); |
1974 | vars["PUCSXDIR"]=new DRW_Variant(10, buf->get3BitDouble()); |
1975 | vars["PUCSYDIR"]=new DRW_Variant(10, buf->get3BitDouble()); |
1976 | dwgHandle PUCSNAME = hBbuf->getHandle(); |
1977 | DRW_DBG("\nPUCSNAME: ")DRW_dbg::getInstance()->print("\nPUCSNAME: "); DRW_DBGHL(PUCSNAME.code, PUCSNAME.size, PUCSNAME.ref)DRW_dbg::getInstance()->printHL(PUCSNAME.code, PUCSNAME.size ,PUCSNAME.ref); |
1978 | if (version > DRW::AC1014) {//2000+ |
1979 | dwgHandle PUCSORTHOREF = hBbuf->getHandle(); |
1980 | DRW_DBG("\nPUCSORTHOREF: ")DRW_dbg::getInstance()->print("\nPUCSORTHOREF: "); DRW_DBGHL(PUCSORTHOREF.code, PUCSORTHOREF.size, PUCSORTHOREF.ref)DRW_dbg::getInstance()->printHL(PUCSORTHOREF.code, PUCSORTHOREF .size ,PUCSORTHOREF.ref); |
1981 | vars["PUCSORTHOVIEW"]=new DRW_Variant(70, buf->getBitShort()); |
1982 | dwgHandle PUCSBASE = hBbuf->getHandle(); |
1983 | DRW_DBG("\nPUCSBASE: ")DRW_dbg::getInstance()->print("\nPUCSBASE: "); DRW_DBGHL(PUCSBASE.code, PUCSBASE.size, PUCSBASE.ref)DRW_dbg::getInstance()->printHL(PUCSBASE.code, PUCSBASE.size ,PUCSBASE.ref); |
1984 | vars["PUCSORGTOP"]=new DRW_Variant(10, buf->get3BitDouble()); |
1985 | vars["PUCSORGBOTTOM"]=new DRW_Variant(10, buf->get3BitDouble()); |
1986 | vars["PUCSORGLEFT"]=new DRW_Variant(10, buf->get3BitDouble()); |
1987 | vars["PUCSORGRIGHT"]=new DRW_Variant(10, buf->get3BitDouble()); |
1988 | vars["PUCSORGFRONT"]=new DRW_Variant(10, buf->get3BitDouble()); |
1989 | vars["PUCSORGBACK"]=new DRW_Variant(10, buf->get3BitDouble()); |
1990 | } |
1991 | vars["INSBASE"]=new DRW_Variant(10, buf->get3BitDouble()); |
1992 | vars["EXTMIN"]=new DRW_Variant(10, buf->get3BitDouble()); |
1993 | vars["EXTMAX"]=new DRW_Variant(10, buf->get3BitDouble()); |
1994 | vars["LIMMIN"]=new DRW_Variant(10, buf->get2RawDouble()); |
1995 | vars["LIMMAX"]=new DRW_Variant(10, buf->get2RawDouble()); |
1996 | vars["ELEVATION"]=new DRW_Variant(40, buf->getBitDouble()); |
1997 | vars["UCSORG"]=new DRW_Variant(10, buf->get3BitDouble()); |
1998 | vars["UCSXDIR"]=new DRW_Variant(10, buf->get3BitDouble()); |
1999 | vars["UCSYDIR"]=new DRW_Variant(10, buf->get3BitDouble()); |
2000 | dwgHandle UCSNAME = hBbuf->getHandle(); |
2001 | DRW_DBG("\nUCSNAME: ")DRW_dbg::getInstance()->print("\nUCSNAME: "); DRW_DBGHL(UCSNAME.code, UCSNAME.size, UCSNAME.ref)DRW_dbg::getInstance()->printHL(UCSNAME.code, UCSNAME.size ,UCSNAME.ref); |
2002 | if (version > DRW::AC1014) {//2000+ |
2003 | dwgHandle UCSORTHOREF = hBbuf->getHandle(); |
2004 | DRW_DBG("\nUCSORTHOREF: ")DRW_dbg::getInstance()->print("\nUCSORTHOREF: "); DRW_DBGHL(UCSORTHOREF.code, UCSORTHOREF.size, UCSORTHOREF.ref)DRW_dbg::getInstance()->printHL(UCSORTHOREF.code, UCSORTHOREF .size ,UCSORTHOREF.ref); |
2005 | vars["UCSORTHOVIEW"]=new DRW_Variant(70, buf->getBitShort()); |
2006 | dwgHandle UCSBASE = hBbuf->getHandle(); |
2007 | DRW_DBG("\nUCSBASE: ")DRW_dbg::getInstance()->print("\nUCSBASE: "); DRW_DBGHL(UCSBASE.code, UCSBASE.size, UCSBASE.ref)DRW_dbg::getInstance()->printHL(UCSBASE.code, UCSBASE.size ,UCSBASE.ref); |
2008 | vars["UCSORGTOP"]=new DRW_Variant(10, buf->get3BitDouble()); |
2009 | vars["UCSORGBOTTOM"]=new DRW_Variant(10, buf->get3BitDouble()); |
2010 | vars["UCSORGLEFT"]=new DRW_Variant(10, buf->get3BitDouble()); |
2011 | vars["UCSORGRIGHT"]=new DRW_Variant(10, buf->get3BitDouble()); |
2012 | vars["UCSORGFRONT"]=new DRW_Variant(10, buf->get3BitDouble()); |
2013 | vars["UCSORGBACK"]=new DRW_Variant(10, buf->get3BitDouble()); |
2014 | if (version < DRW::AC1021) {//2004- |
2015 | vars["DIMPOST"]=new DRW_Variant(1, buf->getCP8Text()); |
2016 | vars["DIMAPOST"]=new DRW_Variant(1, buf->getCP8Text()); |
2017 | } |
2018 | } |
2019 | if (version < DRW::AC1015) {//r14- |
2020 | vars["DIMTOL"]=new DRW_Variant(70, buf->getBit()); |
2021 | vars["DIMLIM"]=new DRW_Variant(70, buf->getBit()); |
2022 | vars["DIMTIH"]=new DRW_Variant(70, buf->getBit()); |
2023 | vars["DIMTOH"]=new DRW_Variant(70, buf->getBit()); |
2024 | vars["DIMSE1"]=new DRW_Variant(70, buf->getBit()); |
2025 | vars["DIMSE2"]=new DRW_Variant(70, buf->getBit()); |
2026 | vars["DIMALT"]=new DRW_Variant(70, buf->getBit()); |
2027 | vars["DIMTOFL"]=new DRW_Variant(70, buf->getBit()); |
2028 | vars["DIMSAH"]=new DRW_Variant(70, buf->getBit()); |
2029 | vars["DIMTIX"]=new DRW_Variant(70, buf->getBit()); |
2030 | vars["DIMSOXD"]=new DRW_Variant(70, buf->getBit()); |
2031 | vars["DIMALTD"]=new DRW_Variant(70, buf->getRawChar8()); |
2032 | vars["DIMZIN"]=new DRW_Variant(70, buf->getRawChar8()); |
2033 | vars["DIMSD1"]=new DRW_Variant(70, buf->getBit()); |
2034 | vars["DIMSD2"]=new DRW_Variant(70, buf->getBit()); |
2035 | vars["DIMTOLJ"]=new DRW_Variant(70, buf->getRawChar8()); |
2036 | vars["DIMJUST"]=new DRW_Variant(70, buf->getRawChar8()); |
2037 | vars["DIMFIT"]=new DRW_Variant(70, buf->getRawChar8());/////////// |
2038 | vars["DIMUPT"]=new DRW_Variant(70, buf->getBit()); |
2039 | vars["DIMTZIN"]=new DRW_Variant(70, buf->getRawChar8()); |
2040 | vars["DIMALTZ"]=new DRW_Variant(70, buf->getRawChar8()); |
2041 | vars["DIMALTTZ"]=new DRW_Variant(70, buf->getRawChar8()); |
2042 | vars["DIMTAD"]=new DRW_Variant(70, buf->getRawChar8()); |
2043 | vars["DIMUNIT"]=new DRW_Variant(70, buf->getBitShort());/////////// |
2044 | vars["DIMAUNIT"]=new DRW_Variant(70, buf->getBitShort()); |
2045 | vars["DIMDEC"]=new DRW_Variant(70, buf->getBitShort()); |
2046 | vars["DIMTDEC"]=new DRW_Variant(70, buf->getBitShort()); |
2047 | vars["DIMALTU"]=new DRW_Variant(70, buf->getBitShort()); |
2048 | vars["DIMALTTD"]=new DRW_Variant(70, buf->getBitShort()); |
2049 | dwgHandle DIMTXSTY = hBbuf->getHandle(); |
2050 | DRW_DBG("\nDIMTXSTY: ")DRW_dbg::getInstance()->print("\nDIMTXSTY: "); DRW_DBGHL(DIMTXSTY.code, DIMTXSTY.size, DIMTXSTY.ref)DRW_dbg::getInstance()->printHL(DIMTXSTY.code, DIMTXSTY.size ,DIMTXSTY.ref); |
2051 | } |
2052 | vars["DIMSCALE"]=new DRW_Variant(40, buf->getBitDouble()); |
2053 | vars["DIMASZ"]=new DRW_Variant(40, buf->getBitDouble()); |
2054 | vars["DIMEXO"]=new DRW_Variant(40, buf->getBitDouble()); |
2055 | vars["DIMDLI"]=new DRW_Variant(40, buf->getBitDouble()); |
2056 | vars["DIMEXE"]=new DRW_Variant(40, buf->getBitDouble()); |
2057 | vars["DIMRND"]=new DRW_Variant(40, buf->getBitDouble()); |
2058 | vars["DIMDLE"]=new DRW_Variant(40, buf->getBitDouble()); |
2059 | vars["DIMTP"]=new DRW_Variant(40, buf->getBitDouble()); |
2060 | vars["DIMTM"]=new DRW_Variant(40, buf->getBitDouble()); |
2061 | if (version > DRW::AC1018) {//2007+ |
2062 | vars["DIMFXL"]=new DRW_Variant(40, buf->getBitDouble());////////////////// |
2063 | vars["DIMJOGANG"]=new DRW_Variant(40, buf->getBitDouble());/////////////// |
2064 | vars["DIMTFILL"]=new DRW_Variant(70, buf->getBitShort()); |
2065 | vars["DIMTFILLCLR"]=new DRW_Variant(62, buf->getCmColor(version)); |
2066 | } |
2067 | if (version > DRW::AC1014) {//2000+ |
2068 | vars["DIMTOL"]=new DRW_Variant(70, buf->getBit()); |
2069 | vars["DIMLIM"]=new DRW_Variant(70, buf->getBit()); |
2070 | vars["DIMTIH"]=new DRW_Variant(70, buf->getBit()); |
2071 | vars["DIMTOH"]=new DRW_Variant(70, buf->getBit()); |
2072 | vars["DIMSE1"]=new DRW_Variant(70, buf->getBit()); |
2073 | vars["DIMSE2"]=new DRW_Variant(70, buf->getBit()); |
2074 | vars["DIMTAD"]=new DRW_Variant(70, buf->getBitShort()); |
2075 | vars["DIMZIN"]=new DRW_Variant(70, buf->getBitShort()); |
2076 | vars["DIMAZIN"]=new DRW_Variant(70, buf->getBitShort()); |
2077 | } |
2078 | if (version > DRW::AC1018) {//2007+ |
2079 | vars["DIMARCSYM"]=new DRW_Variant(70, buf->getBitShort()); |
2080 | } |
2081 | vars["DIMTXT"]=new DRW_Variant(40, buf->getBitDouble()); |
2082 | vars["DIMCEN"]=new DRW_Variant(40, buf->getBitDouble()); |
2083 | vars["DIMTSZ"]=new DRW_Variant(40, buf->getBitDouble()); |
2084 | vars["DIMALTF"]=new DRW_Variant(40, buf->getBitDouble()); |
2085 | vars["DIMLFAC"]=new DRW_Variant(40, buf->getBitDouble()); |
2086 | vars["DIMTVP"]=new DRW_Variant(40, buf->getBitDouble()); |
2087 | vars["DIMTFAC"]=new DRW_Variant(40, buf->getBitDouble()); |
2088 | vars["DIMGAP"]=new DRW_Variant(40, buf->getBitDouble()); |
2089 | if (version < DRW::AC1015) {//r14- |
2090 | vars["DIMPOST"]=new DRW_Variant(1, buf->getCP8Text()); |
2091 | vars["DIMAPOST"]=new DRW_Variant(1, buf->getCP8Text()); |
2092 | vars["DIMBLK"]=new DRW_Variant(1, buf->getCP8Text()); |
2093 | vars["DIMBLK1"]=new DRW_Variant(1, buf->getCP8Text()); |
2094 | vars["DIMBLK2"]=new DRW_Variant(1, buf->getCP8Text()); |
2095 | } |
2096 | if (version > DRW::AC1014) {//2000+ |
2097 | vars["DIMALTRND"]=new DRW_Variant(40, buf->getBitDouble()); |
2098 | vars["DIMALT"]=new DRW_Variant(70, buf->getBit()); |
2099 | vars["DIMALTD"]=new DRW_Variant(70, buf->getBitShort()); |
2100 | vars["DIMTOFL"]=new DRW_Variant(70, buf->getBit()); |
2101 | vars["DIMSAH"]=new DRW_Variant(70, buf->getBit()); |
2102 | vars["DIMTIX"]=new DRW_Variant(70, buf->getBit()); |
2103 | vars["DIMSOXD"]=new DRW_Variant(70, buf->getBit()); |
2104 | } |
2105 | vars["DIMCLRD"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color |
2106 | vars["DIMCLRE"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color |
2107 | vars["DIMCLRT"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color |
2108 | if (version > DRW::AC1014) {//2000+ |
2109 | vars["DIAMDEC"]=new DRW_Variant(70, buf->getBitShort()); |
2110 | vars["DIMDEC"]=new DRW_Variant(70, buf->getBitShort()); |
2111 | vars["DIMTDEC"]=new DRW_Variant(70, buf->getBitShort()); |
2112 | vars["DIMALTU"]=new DRW_Variant(70, buf->getBitShort()); |
2113 | vars["DIMALTTD"]=new DRW_Variant(70, buf->getBitShort()); |
2114 | vars["DIMAUNIT"]=new DRW_Variant(70, buf->getBitShort()); |
2115 | vars["DIMFAC"]=new DRW_Variant(70, buf->getBitShort());///////////////// DIMFAC O DIMFRAC |
2116 | vars["DIMLUNIT"]=new DRW_Variant(70, buf->getBitShort()); |
2117 | vars["DIMDSEP"]=new DRW_Variant(70, buf->getBitShort()); |
2118 | vars["DIMTMOVE"]=new DRW_Variant(70, buf->getBitShort()); |
2119 | vars["DIMJUST"]=new DRW_Variant(70, buf->getBitShort()); |
2120 | vars["DIMSD1"]=new DRW_Variant(70, buf->getBit()); |
2121 | vars["DIMSD2"]=new DRW_Variant(70, buf->getBit()); |
2122 | vars["DIMTOLJ"]=new DRW_Variant(70, buf->getBitShort()); |
2123 | vars["DIMTZIN"]=new DRW_Variant(70, buf->getBitShort()); |
2124 | vars["DIMALTZ"]=new DRW_Variant(70, buf->getBitShort()); |
2125 | vars["DIMALTTZ"]=new DRW_Variant(70, buf->getBitShort()); |
2126 | vars["DIMUPT"]=new DRW_Variant(70, buf->getBit()); |
2127 | vars["DIMATFIT"]=new DRW_Variant(70, buf->getBitShort()); |
2128 | } |
2129 | if (version > DRW::AC1018) {//2007+ |
2130 | vars["DIMFXLON"]=new DRW_Variant(70, buf->getBit());//////////////// |
2131 | } |
2132 | if (version > DRW::AC1021) {//2010+ |
2133 | vars["DIMTXTDIRECTION"]=new DRW_Variant(70, buf->getBit());//////////////// |
2134 | vars["DIMALTMZF"]=new DRW_Variant(40, buf->getBitDouble());//////////////// |
2135 | vars["DIMMZF"]=new DRW_Variant(40, buf->getBitDouble());//////////////// |
2136 | } |
2137 | if (version > DRW::AC1014) {//2000+ |
2138 | dwgHandle DIMTXSTY = hBbuf->getHandle(); |
2139 | DRW_DBG("\nDIMTXSTY: ")DRW_dbg::getInstance()->print("\nDIMTXSTY: "); DRW_DBGHL(DIMTXSTY.code, DIMTXSTY.size, DIMTXSTY.ref)DRW_dbg::getInstance()->printHL(DIMTXSTY.code, DIMTXSTY.size ,DIMTXSTY.ref); |
2140 | dwgHandle DIMLDRBLK = hBbuf->getHandle(); |
2141 | DRW_DBG("\nDIMLDRBLK: ")DRW_dbg::getInstance()->print("\nDIMLDRBLK: "); DRW_DBGHL(DIMLDRBLK.code, DIMLDRBLK.size, DIMLDRBLK.ref)DRW_dbg::getInstance()->printHL(DIMLDRBLK.code, DIMLDRBLK. size ,DIMLDRBLK.ref); |
2142 | dwgHandle DIMBLK = hBbuf->getHandle(); |
2143 | DRW_DBG("\nDIMBLK: ")DRW_dbg::getInstance()->print("\nDIMBLK: "); DRW_DBGHL(DIMBLK.code, DIMBLK.size, DIMBLK.ref)DRW_dbg::getInstance()->printHL(DIMBLK.code, DIMBLK.size , DIMBLK.ref); |
2144 | dwgHandle DIMBLK1 = hBbuf->getHandle(); |
2145 | DRW_DBG("\nDIMBLK1: ")DRW_dbg::getInstance()->print("\nDIMBLK1: "); DRW_DBGHL(DIMBLK1.code, DIMBLK1.size, DIMBLK1.ref)DRW_dbg::getInstance()->printHL(DIMBLK1.code, DIMBLK1.size ,DIMBLK1.ref); |
2146 | dwgHandle DIMBLK2 = hBbuf->getHandle(); |
2147 | DRW_DBG("\nDIMBLK2: ")DRW_dbg::getInstance()->print("\nDIMBLK2: "); DRW_DBGHL(DIMBLK2.code, DIMBLK2.size, DIMBLK2.ref)DRW_dbg::getInstance()->printHL(DIMBLK2.code, DIMBLK2.size ,DIMBLK2.ref); |
2148 | } |
2149 | if (version > DRW::AC1018) {//2007+ |
2150 | dwgHandle DIMLTYPE = hBbuf->getHandle(); |
2151 | DRW_DBG("\nDIMLTYPE: ")DRW_dbg::getInstance()->print("\nDIMLTYPE: "); DRW_DBGHL(DIMLTYPE.code, DIMLTYPE.size, DIMLTYPE.ref)DRW_dbg::getInstance()->printHL(DIMLTYPE.code, DIMLTYPE.size ,DIMLTYPE.ref); |
2152 | dwgHandle DIMLTEX1 = hBbuf->getHandle(); |
2153 | DRW_DBG("\nDIMLTEX1: ")DRW_dbg::getInstance()->print("\nDIMLTEX1: "); DRW_DBGHL(DIMLTEX1.code, DIMLTEX1.size, DIMLTEX1.ref)DRW_dbg::getInstance()->printHL(DIMLTEX1.code, DIMLTEX1.size ,DIMLTEX1.ref); |
2154 | dwgHandle DIMLTEX2 = hBbuf->getHandle(); |
2155 | DRW_DBG("\nDIMLTEX2: ")DRW_dbg::getInstance()->print("\nDIMLTEX2: "); DRW_DBGHL(DIMLTEX2.code, DIMLTEX2.size, DIMLTEX2.ref)DRW_dbg::getInstance()->printHL(DIMLTEX2.code, DIMLTEX2.size ,DIMLTEX2.ref); |
2156 | } |
2157 | if (version > DRW::AC1014) {//2000+ |
2158 | vars["DIMLWD"]=new DRW_Variant(70, buf->getBitShort()); |
2159 | vars["DIMLWE"]=new DRW_Variant(70, buf->getBitShort()); |
2160 | } |
2161 | dwgHandle CONTROL = hBbuf->getHandle(); |
2162 | DRW_DBG("\nBLOCK CONTROL: ")DRW_dbg::getInstance()->print("\nBLOCK CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2163 | blockCtrl = CONTROL.ref; |
2164 | CONTROL = hBbuf->getHandle(); |
2165 | DRW_DBG("\nLAYER CONTROL: ")DRW_dbg::getInstance()->print("\nLAYER CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2166 | layerCtrl = CONTROL.ref; |
2167 | CONTROL = hBbuf->getHandle(); |
2168 | DRW_DBG("\nSTYLE CONTROL: ")DRW_dbg::getInstance()->print("\nSTYLE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2169 | styleCtrl = CONTROL.ref; |
2170 | CONTROL = hBbuf->getHandle(); |
2171 | DRW_DBG("\nLINETYPE CONTROL: ")DRW_dbg::getInstance()->print("\nLINETYPE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2172 | linetypeCtrl = CONTROL.ref; |
2173 | CONTROL = hBbuf->getHandle(); |
2174 | DRW_DBG("\nVIEW CONTROL: ")DRW_dbg::getInstance()->print("\nVIEW CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2175 | viewCtrl = CONTROL.ref; |
2176 | CONTROL = hBbuf->getHandle(); |
2177 | DRW_DBG("\nUCS CONTROL: ")DRW_dbg::getInstance()->print("\nUCS CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2178 | ucsCtrl = CONTROL.ref; |
2179 | CONTROL = hBbuf->getHandle(); |
2180 | DRW_DBG("\nVPORT CONTROL: ")DRW_dbg::getInstance()->print("\nVPORT CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2181 | vportCtrl = CONTROL.ref; |
2182 | CONTROL = hBbuf->getHandle(); |
2183 | DRW_DBG("\nAPPID CONTROL: ")DRW_dbg::getInstance()->print("\nAPPID CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2184 | appidCtrl = CONTROL.ref; |
2185 | CONTROL = hBbuf->getHandle(); |
2186 | DRW_DBG("\nDIMSTYLE CONTROL: ")DRW_dbg::getInstance()->print("\nDIMSTYLE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2187 | dimstyleCtrl = CONTROL.ref; |
2188 | if (version < DRW::AC1018) {//r2000- |
2189 | CONTROL = hBbuf->getHandle(); |
2190 | DRW_DBG("\nVIEWPORT ENTITY HEADER CONTROL: ")DRW_dbg::getInstance()->print("\nVIEWPORT ENTITY HEADER CONTROL: " ); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2191 | vpEntHeaderCtrl = CONTROL.ref; //RLZ: only in R13-R15 ???? |
2192 | } |
2193 | CONTROL = hBbuf->getHandle(); |
2194 | DRW_DBG("\nDICT ACAD_GROUP: ")DRW_dbg::getInstance()->print("\nDICT ACAD_GROUP: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2195 | CONTROL = hBbuf->getHandle(); |
2196 | DRW_DBG("\nDICT ACAD_MLINESTYLE: ")DRW_dbg::getInstance()->print("\nDICT ACAD_MLINESTYLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2197 | CONTROL = hBbuf->getHandle(); |
2198 | DRW_DBG("\nDICT NAMED OBJS: ")DRW_dbg::getInstance()->print("\nDICT NAMED OBJS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2199 | |
2200 | if (version > DRW::AC1014) {//2000+ |
2201 | vars["TSTACKALIGN"]=new DRW_Variant(70, buf->getBitShort()); |
2202 | vars["TSTACKSIZE"]=new DRW_Variant(70, buf->getBitShort()); |
2203 | if (version < DRW::AC1021) {//2004- |
2204 | vars["HYPERLINKBASE"]=new DRW_Variant(1, buf->getCP8Text()); |
2205 | vars["STYLESHEET"]=new DRW_Variant(1, buf->getCP8Text()); |
2206 | } |
2207 | CONTROL = hBbuf->getHandle(); |
2208 | DRW_DBG("\nDICT LAYOUTS: ")DRW_dbg::getInstance()->print("\nDICT LAYOUTS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2209 | CONTROL = hBbuf->getHandle(); |
2210 | DRW_DBG("\nDICT PLOTSETTINGS: ")DRW_dbg::getInstance()->print("\nDICT PLOTSETTINGS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2211 | CONTROL = hBbuf->getHandle(); |
2212 | DRW_DBG("\nDICT PLOTSTYLES: ")DRW_dbg::getInstance()->print("\nDICT PLOTSTYLES: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2213 | } |
2214 | if (version > DRW::AC1015) {//2004+ |
2215 | CONTROL = hBbuf->getHandle(); |
2216 | DRW_DBG("\nDICT MATERIALS: ")DRW_dbg::getInstance()->print("\nDICT MATERIALS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2217 | CONTROL = hBbuf->getHandle(); |
2218 | DRW_DBG("\nDICT COLORS: ")DRW_dbg::getInstance()->print("\nDICT COLORS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2219 | } |
2220 | if (version > DRW::AC1018) {//2007+ |
2221 | CONTROL = hBbuf->getHandle(); |
2222 | DRW_DBG("\nDICT VISUALSTYLE: ")DRW_dbg::getInstance()->print("\nDICT VISUALSTYLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2223 | } |
2224 | if (version > DRW::AC1024) {//2013+ |
2225 | CONTROL = hBbuf->getHandle(); |
2226 | DRW_DBG("\nUNKNOWN HANDLE: ")DRW_dbg::getInstance()->print("\nUNKNOWN HANDLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2227 | } |
2228 | if (version > DRW::AC1014) {//2000+ |
2229 | DRW_DBG("\nFlags: ")DRW_dbg::getInstance()->print("\nFlags: "); DRW_DBGH(buf->getBitLong())DRW_dbg::getInstance()->printH(buf->getBitLong());//RLZ TODO change to 8 vars |
2230 | vars["INSUNITS"]=new DRW_Variant(70, buf->getBitShort()); |
2231 | duint16 cepsntype = buf->getBitShort(); |
2232 | vars["CEPSNTYPE"]=new DRW_Variant(70, cepsntype); |
2233 | if (cepsntype == 3){ |
2234 | CONTROL = hBbuf->getHandle(); |
2235 | DRW_DBG("\nCPSNID HANDLE: ")DRW_dbg::getInstance()->print("\nCPSNID HANDLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2236 | } |
2237 | if (version < DRW::AC1021) {//2004- |
2238 | vars["FINGERPRINTGUID"]=new DRW_Variant(1, buf->getCP8Text()); |
2239 | vars["VERSIONGUID"]=new DRW_Variant(1, buf->getCP8Text()); |
2240 | } |
2241 | } |
2242 | if (version > DRW::AC1015) {//2004+ |
2243 | vars["SORTENTS"]=new DRW_Variant(70, buf->getRawChar8()); |
2244 | vars["INDEXCTL"]=new DRW_Variant(70, buf->getRawChar8()); |
2245 | vars["HIDETEXT"]=new DRW_Variant(70, buf->getRawChar8()); |
2246 | vars["XCLIPFRAME"]=new DRW_Variant(70, buf->getRawChar8()); |
2247 | vars["DIMASSOC"]=new DRW_Variant(70, buf->getRawChar8()); |
2248 | vars["HALOGAP"]=new DRW_Variant(70, buf->getRawChar8()); |
2249 | vars["OBSCUREDCOLOR"]=new DRW_Variant(70, buf->getBitShort()); |
2250 | vars["INTERSECTIONCOLOR"]=new DRW_Variant(70, buf->getBitShort()); |
2251 | vars["OBSCUREDLTYPE"]=new DRW_Variant(70, buf->getRawChar8()); |
2252 | vars["INTERSECTIONDISPLAY"]=new DRW_Variant(70, buf->getRawChar8()); |
2253 | if (version < DRW::AC1021) {//2004- |
2254 | vars["PROJECTNAME"]=new DRW_Variant(1, buf->getCP8Text()); |
2255 | } |
2256 | } |
2257 | CONTROL = hBbuf->getHandle(); |
2258 | DRW_DBG("\nBLOCK PAPER_SPACE: ")DRW_dbg::getInstance()->print("\nBLOCK PAPER_SPACE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2259 | CONTROL = hBbuf->getHandle(); |
2260 | DRW_DBG("\nBLOCK MODEL_SPACE: ")DRW_dbg::getInstance()->print("\nBLOCK MODEL_SPACE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2261 | CONTROL = hBbuf->getHandle(); |
2262 | DRW_DBG("\nLTYPE BYLAYER: ")DRW_dbg::getInstance()->print("\nLTYPE BYLAYER: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2263 | CONTROL = hBbuf->getHandle(); |
2264 | DRW_DBG("\nLTYPE BYBLOCK: ")DRW_dbg::getInstance()->print("\nLTYPE BYBLOCK: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2265 | CONTROL = hBbuf->getHandle(); |
2266 | DRW_DBG("\nLTYPE CONTINUOUS: ")DRW_dbg::getInstance()->print("\nLTYPE CONTINUOUS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2267 | if (version > DRW::AC1018) {//2007+ |
2268 | vars["CAMERADISPLAY"]=new DRW_Variant(70, buf->getBit()); |
2269 | DRW_DBG("\nUnknown 2007+ long1: ")DRW_dbg::getInstance()->print("\nUnknown 2007+ long1: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
2270 | DRW_DBG("\nUnknown 2007+ long2: ")DRW_dbg::getInstance()->print("\nUnknown 2007+ long2: "); DRW_DBG(buf->getBitLong())DRW_dbg::getInstance()->print(buf->getBitLong()); |
2271 | DRW_DBG("\nUnknown 2007+ double2: ")DRW_dbg::getInstance()->print("\nUnknown 2007+ double2: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
2272 | vars["STEPSPERSEC"]=new DRW_Variant(40, buf->getBitDouble()); |
2273 | vars["STEPSIZE"]=new DRW_Variant(40, buf->getBitDouble()); |
2274 | vars["3DDWFPREC"]=new DRW_Variant(40, buf->getBitDouble()); |
2275 | vars["LENSLENGTH"]=new DRW_Variant(40, buf->getBitDouble()); |
2276 | vars["CAMERAHEIGHT"]=new DRW_Variant(40, buf->getBitDouble()); |
2277 | vars["SOLIDHIST"]=new DRW_Variant(70, buf->getRawChar8()); |
2278 | vars["SHOWHIST"]=new DRW_Variant(70, buf->getRawChar8()); |
2279 | vars["PSOLWIDTH"]=new DRW_Variant(40, buf->getBitDouble()); |
2280 | vars["PSOLHEIGHT"]=new DRW_Variant(40, buf->getBitDouble()); |
2281 | vars["LOFTANG1"]=new DRW_Variant(40, buf->getBitDouble()); |
2282 | vars["LOFTANG2"]=new DRW_Variant(40, buf->getBitDouble()); |
2283 | vars["LOFTMAG1"]=new DRW_Variant(40, buf->getBitDouble()); |
2284 | vars["LOFTMAG2"]=new DRW_Variant(40, buf->getBitDouble()); |
2285 | vars["LOFTPARAM"]=new DRW_Variant(70, buf->getBitShort()); |
2286 | vars["LOFTNORMALS"]=new DRW_Variant(40, buf->getRawChar8()); |
2287 | vars["LATITUDE"]=new DRW_Variant(40, buf->getBitDouble()); |
2288 | vars["LONGITUDE"]=new DRW_Variant(40, buf->getBitDouble()); |
2289 | vars["NORTHDIRECTION"]=new DRW_Variant(40, buf->getBitDouble()); |
2290 | vars["TIMEZONE"]=new DRW_Variant(70, buf->getBitLong()); |
2291 | vars["LIGHTGLYPHDISPLAY"]=new DRW_Variant(70, buf->getRawChar8()); |
2292 | vars["TILEMODELIGHTSYNCH"]=new DRW_Variant(70, buf->getRawChar8()); |
2293 | vars["DWFFRAME"]=new DRW_Variant(70, buf->getRawChar8()); |
2294 | vars["DGNFRAME"]=new DRW_Variant(70, buf->getRawChar8()); |
2295 | DRW_DBG("\nUnknown 2007+ BIT: ")DRW_dbg::getInstance()->print("\nUnknown 2007+ BIT: "); DRW_DBG(buf->getBit())DRW_dbg::getInstance()->print(buf->getBit()); |
2296 | vars["INTERFERECOLOR"]=new DRW_Variant(70, buf->getCmColor(version)); |
2297 | CONTROL = hBbuf->getHandle(); |
2298 | DRW_DBG("\nINTERFEREOBJVS: ")DRW_dbg::getInstance()->print("\nINTERFEREOBJVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2299 | CONTROL = hBbuf->getHandle(); |
2300 | DRW_DBG("\nINTERFEREVPVS: ")DRW_dbg::getInstance()->print("\nINTERFEREVPVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2301 | CONTROL = hBbuf->getHandle(); |
2302 | DRW_DBG("\nDRAGVS: ")DRW_dbg::getInstance()->print("\nDRAGVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref)DRW_dbg::getInstance()->printHL(CONTROL.code, CONTROL.size ,CONTROL.ref); |
2303 | vars["CSHADOW"]=new DRW_Variant(70, buf->getRawChar8()); |
2304 | DRW_DBG("\nUnknown 2007+ double2: ")DRW_dbg::getInstance()->print("\nUnknown 2007+ double2: "); DRW_DBG(buf->getBitDouble())DRW_dbg::getInstance()->print(buf->getBitDouble()); |
2305 | } |
2306 | if (version > DRW::AC1012) {//R14+ |
2307 | DRW_DBG("\nUnknown R14+ short1: ")DRW_dbg::getInstance()->print("\nUnknown R14+ short1: "); DRW_DBG(buf->getBitShort())DRW_dbg::getInstance()->print(buf->getBitShort()); |
2308 | DRW_DBG("\nUnknown R14+ short2: ")DRW_dbg::getInstance()->print("\nUnknown R14+ short2: "); DRW_DBG(buf->getBitShort())DRW_dbg::getInstance()->print(buf->getBitShort()); |
2309 | DRW_DBG("\nUnknown R14+ short3: ")DRW_dbg::getInstance()->print("\nUnknown R14+ short3: "); DRW_DBG(buf->getBitShort())DRW_dbg::getInstance()->print(buf->getBitShort()); |
2310 | DRW_DBG("\nUnknown R14+ short4: ")DRW_dbg::getInstance()->print("\nUnknown R14+ short4: "); DRW_DBG(buf->getBitShort())DRW_dbg::getInstance()->print(buf->getBitShort()); |
2311 | } |
2312 | |
2313 | DRW_DBG("\nbuf position: ")DRW_dbg::getInstance()->print("\nbuf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2314 | DRW_DBG(" buf bit position: ")DRW_dbg::getInstance()->print(" buf bit position: "); DRW_DBG(buf->getBitPos())DRW_dbg::getInstance()->print(buf->getBitPos()); |
2315 | |
2316 | |
2317 | /**** RLZ: disabled, pending to read all data ***/ |
2318 | //Start reading string stream for 2007 and further |
2319 | if (version > DRW::AC1018) {//2007+ |
2320 | duint32 strStartPos = endBitPos -1; |
2321 | buf->setPosition(strStartPos >>3); |
2322 | buf->setBitPos(strStartPos&7); |
2323 | if (buf->getBit() == 1){ |
2324 | strStartPos -= 16; |
2325 | buf->setPosition(strStartPos >>3); |
2326 | buf->setBitPos(strStartPos&7); |
2327 | duint32 strDataSize = buf->getRawShort16(); |
2328 | if (strDataSize & 0x8000) { |
2329 | strStartPos -= 16;//decrement 16 bits |
2330 | strDataSize &= 0x7FFF; //strip 0x8000; |
2331 | buf->setPosition(strStartPos >> 3); |
2332 | buf->setBitPos(strStartPos & 7); |
2333 | duint32 hiSize = buf->getRawShort16(); |
2334 | strDataSize |= (hiSize << 15); |
2335 | } |
2336 | strStartPos -= strDataSize; |
2337 | buf->setPosition(strStartPos >> 3); |
2338 | buf->setBitPos(strStartPos & 7); |
2339 | |
2340 | DRW_DBG("\nstring buf position: ")DRW_dbg::getInstance()->print("\nstring buf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2341 | DRW_DBG("\nstring buf bit position: ")DRW_dbg::getInstance()->print("\nstring buf bit position: " ); DRW_DBG(buf->getBitPos())DRW_dbg::getInstance()->print(buf->getBitPos()); |
2342 | } |
2343 | DRW_DBG("\nUnknown text1: ")DRW_dbg::getInstance()->print("\nUnknown text1: "); DRW_DBG(buf->getUCSText(false))DRW_dbg::getInstance()->print(buf->getUCSText(false)); |
2344 | DRW_DBG("\nUnknown text2: ")DRW_dbg::getInstance()->print("\nUnknown text2: "); DRW_DBG(buf->getUCSText(false))DRW_dbg::getInstance()->print(buf->getUCSText(false)); |
2345 | DRW_DBG("\nUnknown text3: ")DRW_dbg::getInstance()->print("\nUnknown text3: "); DRW_DBG(buf->getUCSText(false))DRW_dbg::getInstance()->print(buf->getUCSText(false)); |
2346 | DRW_DBG("\nUnknown text4: ")DRW_dbg::getInstance()->print("\nUnknown text4: "); DRW_DBG(buf->getUCSText(false))DRW_dbg::getInstance()->print(buf->getUCSText(false)); |
2347 | vars["MENU"]=new DRW_Variant(1, buf->getUCSText(false)); |
2348 | vars["DIMPOST"]=new DRW_Variant(1, buf->getUCSText(false)); |
2349 | vars["DIMAPOST"]=new DRW_Variant(1, buf->getUCSText(false)); |
2350 | if (version > DRW::AC1021) {//2010+ |
2351 | vars["DIMALTMZS"]=new DRW_Variant(70, buf->getUCSText(false));//RLZ: pending to verify////////////// |
2352 | vars["DIMMZS"]=new DRW_Variant(70, buf->getUCSText(false));//RLZ: pending to verify////////////// |
2353 | } |
2354 | vars["HYPERLINKBASE"]=new DRW_Variant(1, buf->getUCSText(false)); |
2355 | vars["STYLESHEET"]=new DRW_Variant(1, buf->getUCSText(false)); |
2356 | vars["FINGERPRINTGUID"]=new DRW_Variant(1, buf->getUCSText(false)); |
2357 | DRW_DBG("\nstring buf position: ")DRW_dbg::getInstance()->print("\nstring buf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2358 | DRW_DBG(" string buf bit position: ")DRW_dbg::getInstance()->print(" string buf bit position: " ); DRW_DBG(buf->getBitPos())DRW_dbg::getInstance()->print(buf->getBitPos()); |
2359 | vars["VERSIONGUID"]=new DRW_Variant(1, buf->getUCSText(false)); |
2360 | DRW_DBG("\nstring buf position: ")DRW_dbg::getInstance()->print("\nstring buf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2361 | DRW_DBG(" string buf bit position: ")DRW_dbg::getInstance()->print(" string buf bit position: " ); DRW_DBG(buf->getBitPos())DRW_dbg::getInstance()->print(buf->getBitPos()); |
2362 | vars["PROJECTNAME"]=new DRW_Variant(1, buf->getUCSText(false)); |
2363 | } |
2364 | /*** ****/ |
2365 | DRW_DBG("\nstring buf position: ")DRW_dbg::getInstance()->print("\nstring buf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2366 | DRW_DBG(" string buf bit position: ")DRW_dbg::getInstance()->print(" string buf bit position: " ); DRW_DBG(buf->getBitPos())DRW_dbg::getInstance()->print(buf->getBitPos()); |
2367 | |
2368 | if (DRW_DBGGLDRW_dbg::getInstance()->getLevel() == DRW_dbg::Level::Debug){ |
2369 | for (auto it=vars.begin(); it!=vars.end(); ++it){ |
2370 | DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); DRW_DBG(it->first)DRW_dbg::getInstance()->print(it->first); DRW_DBG(": ")DRW_dbg::getInstance()->print(": "); |
2371 | switch (it->second->type()){ |
2372 | case DRW_Variant::INTEGER: |
2373 | DRW_DBG(it->second->content.i)DRW_dbg::getInstance()->print(it->second->content.i); |
2374 | break; |
2375 | case DRW_Variant::DOUBLE: |
2376 | DRW_DBG(it->second->content.d)DRW_dbg::getInstance()->print(it->second->content.d); |
2377 | break; |
2378 | case DRW_Variant::STRING: |
2379 | DRW_DBG(it->second->content.s->c_str())DRW_dbg::getInstance()->print(it->second->content.s-> c_str()); |
2380 | break; |
2381 | case DRW_Variant::COORD: |
2382 | DRW_DBG("x= ")DRW_dbg::getInstance()->print("x= "); DRW_DBG(it->second->content.v->x)DRW_dbg::getInstance()->print(it->second->content.v-> x); |
2383 | DRW_DBG(", y= ")DRW_dbg::getInstance()->print(", y= "); DRW_DBG(it->second->content.v->y)DRW_dbg::getInstance()->print(it->second->content.v-> y); |
2384 | DRW_DBG(", z= ")DRW_dbg::getInstance()->print(", z= "); DRW_DBG(it->second->content.v->z)DRW_dbg::getInstance()->print(it->second->content.v-> z); |
2385 | break; |
2386 | default: |
2387 | break; |
2388 | } |
2389 | DRW_DBG(" code: ")DRW_dbg::getInstance()->print(" code: ");DRW_DBG(it->second->code())DRW_dbg::getInstance()->print(it->second->code()); |
2390 | } |
2391 | } |
2392 | |
2393 | buf->setPosition(size+16+4); //read size +16 start sentinel + 4 size |
2394 | if ((DRW::AC1024 <= version && 3 < maintenanceVersion) |
2395 | || DRW::AC1032 <= version) { //2010+ |
2396 | buf->getRawLong32();//advance 4 bytes (hisize) |
2397 | } |
2398 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2399 | DRW_DBG("\nHeader CRC: ")DRW_dbg::getInstance()->print("\nHeader CRC: "); DRW_DBGH(buf->getRawShort16())DRW_dbg::getInstance()->printH(buf->getRawShort16()); |
2400 | DRW_DBG("\nbuf position: ")DRW_dbg::getInstance()->print("\nbuf position: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2401 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2402 | for (int i=0; i<16;i++) { |
2403 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2404 | } |
2405 | |
2406 | //temporary code to show header end sentinel |
2407 | duint64 sz= buf->size()-1; |
Value stored to 'sz' during its initialization is never read | |
2408 | if (version < DRW::AC1018) {//pre 2004 |
2409 | sz= buf->size()-16; |
2410 | buf->setPosition(sz); |
2411 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2412 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2413 | for (int i=0; i<16;i++) { |
2414 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2415 | } |
2416 | } else if (version == DRW::AC1018) {//2004 |
2417 | // sz= buf->size()-132; |
2418 | // buf->setPosition(sz); |
2419 | buf->moveBitPos(-128); |
2420 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2421 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2422 | for (int i=0; i<16;i++) { |
2423 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2424 | } |
2425 | } else if (version == DRW::AC1021) {//2007 |
2426 | sz= buf->size()-16; |
2427 | buf->setPosition(sz); |
2428 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2429 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2430 | for (int i=0; i<16;i++) { |
2431 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2432 | } |
2433 | } else if (version == DRW::AC1024) {//2010 |
2434 | // sz= buf->size()-93; |
2435 | // buf->setPosition(sz); |
2436 | buf->moveBitPos(-128); |
2437 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2438 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2439 | for (int i=0; i<16;i++) { |
2440 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2441 | } |
2442 | } else if (version == DRW::AC1027) {//2013 |
2443 | // sz= buf->size()-76; |
2444 | // buf->setPosition(sz); |
2445 | buf->moveBitPos(-128); |
2446 | DRW_DBG("\nsetting position to: ")DRW_dbg::getInstance()->print("\nsetting position to: "); DRW_DBG(buf->getPosition())DRW_dbg::getInstance()->print(buf->getPosition()); |
2447 | DRW_DBG("\ndwg header end sentinel= ")DRW_dbg::getInstance()->print("\ndwg header end sentinel= " ); |
2448 | for (int i=0; i<16;i++) { |
2449 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
2450 | } |
2451 | } |
2452 | |
2453 | return result; |
2454 | } |
2455 | |
2456 | int DRW_Header::measurement(const int unit) { |
2457 | switch (unit) { |
2458 | case Units::Inch: |
2459 | case Units::Foot: |
2460 | case Units::Mile: |
2461 | case Units::Microinch: |
2462 | case Units::Mil: |
2463 | case Units::Yard: |
2464 | return Units::English; |
2465 | |
2466 | default: |
2467 | break; |
2468 | } |
2469 | |
2470 | return Units::Metric; |
2471 | } |
File: | intern/dwgreader.cpp |
Warning: | line 685, column 21 Value stored to 'bs' is never read |
Press '?' + to see keyboard shortcuts
+ + +Keyboard shortcuts:
+1 | /****************************************************************************** |
2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** |
3 | ** ** |
4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** |
5 | ** ** |
6 | ** This library is free software, licensed under the terms of the GNU ** |
7 | ** General Public License as published by the Free Software Foundation, ** |
8 | ** either version 2 of the License, or (at your option) any later version. ** |
9 | ** You should have received a copy of the GNU General Public License ** |
10 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. ** |
11 | ******************************************************************************/ |
12 | |
13 | #include <cstdlib> |
14 | #include <iostream> |
15 | #include <fstream> |
16 | #include <string> |
17 | #include <sstream> |
18 | #include "dwgreader.h" |
19 | #include "drw_textcodec.h" |
20 | #include "drw_dbg.h" |
21 | |
22 | namespace { |
23 | //helper function to cleanup pointers in Look Up Tables |
24 | template<typename T> |
25 | void mapCleanUp(std::unordered_map<duint32, T*>& table) |
26 | { |
27 | for (auto& item: table) |
28 | delete item.second; |
29 | } |
30 | } |
31 | |
32 | dwgReader::~dwgReader() { |
33 | mapCleanUp(ltypemap); |
34 | mapCleanUp(layermap); |
35 | mapCleanUp(blockmap); |
36 | mapCleanUp(stylemap); |
37 | mapCleanUp(dimstylemap); |
38 | mapCleanUp(vportmap); |
39 | mapCleanUp(classesmap); |
40 | mapCleanUp(blockRecordmap); |
41 | mapCleanUp(appIdmap); |
42 | } |
43 | |
44 | void dwgReader::parseAttribs(DRW_Entity* e) { |
45 | if (nullptr == e) { |
46 | return; |
47 | } |
48 | |
49 | duint32 ltref =e->lTypeH.ref; |
50 | duint32 lyref =e->layerH.ref; |
51 | auto lt_it = ltypemap.find(ltref); |
52 | if (lt_it != ltypemap.end()) { |
53 | e->lineType = (lt_it->second)->name; |
54 | } |
55 | auto ly_it = layermap.find(lyref); |
56 | if (ly_it != layermap.end()) { |
57 | e->layer = (ly_it->second)->name; |
58 | } |
59 | } |
60 | |
61 | std::string dwgReader::findTableName(DRW::TTYPE table, dint32 handle){ |
62 | std::string name; |
63 | switch (table){ |
64 | case DRW::STYLE:{ |
65 | auto st_it = stylemap.find(handle); |
66 | if (st_it != stylemap.end()) |
67 | name = (st_it->second)->name; |
68 | break;} |
69 | case DRW::DIMSTYLE:{ |
70 | auto ds_it = dimstylemap.find(handle); |
71 | if (ds_it != dimstylemap.end()) |
72 | name = (ds_it->second)->name; |
73 | break;} |
74 | case DRW::BLOCK_RECORD:{ //use DRW_Block because name are more correct |
75 | // auto bk_it = blockmap.find(handle); |
76 | // if (bk_it != blockmap.end()) |
77 | auto bk_it = blockRecordmap.find(handle); |
78 | if (bk_it != blockRecordmap.end()) |
79 | name = (bk_it->second)->name; |
80 | break;} |
81 | /* case DRW::VPORT:{ |
82 | auto vp_it = vportmap.find(handle); |
83 | if (vp_it != vportmap.end()) |
84 | name = (vp_it->second)->name; |
85 | break;}*/ |
86 | case DRW::LAYER:{ |
87 | auto ly_it = layermap.find(handle); |
88 | if (ly_it != layermap.end()) |
89 | name = (ly_it->second)->name; |
90 | break;} |
91 | case DRW::LTYPE:{ |
92 | auto lt_it = ltypemap.find(handle); |
93 | if (lt_it != ltypemap.end()) |
94 | name = (lt_it->second)->name; |
95 | break;} |
96 | default: |
97 | break; |
98 | } |
99 | return name; |
100 | } |
101 | |
102 | bool dwgReader::readDwgHeader(DRW_Header& hdr, dwgBuffer *buf, dwgBuffer *hBuf){ |
103 | bool ret = hdr.parseDwg(version, buf, hBuf, maintenanceVersion); |
104 | //RLZ: copy objectControl handles |
105 | return ret; |
106 | } |
107 | |
108 | //RLZ: TODO add check instead print |
109 | bool dwgReader::checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start){ |
110 | DRW_UNUSED(start)(void)start; |
111 | for (int i=0; i<16;i++) { |
112 | DRW_DBGH(buf->getRawChar8())DRW_dbg::getInstance()->printH(buf->getRawChar8()); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); |
113 | } |
114 | return true; |
115 | } |
116 | |
117 | /*********** objects map ************************/ |
118 | /** Note: object map are split in sections with max size 2035? |
119 | * heach section are 2 bytes size + data bytes + 2 bytes crc |
120 | * size value are data bytes + 2 and to calculate crc are used |
121 | * 2 bytes size + data bytes |
122 | * last section are 2 bytes size + 2 bytes crc (size value always 2) |
123 | **/ |
124 | bool dwgReader::readDwgHandles(dwgBuffer *dbuf, duint64 offset, duint64 size) { |
125 | DRW_DBG("\ndwgReader::readDwgHandles\n")DRW_dbg::getInstance()->print("\ndwgReader::readDwgHandles\n" ); |
126 | if (!dbuf->setPosition(offset)) |
127 | return false; |
128 | |
129 | duint32 maxPos = offset + size; |
130 | DRW_DBG("\nSection HANDLES offset= ")DRW_dbg::getInstance()->print("\nSection HANDLES offset= " ); DRW_DBG(offset)DRW_dbg::getInstance()->print(offset); |
131 | DRW_DBG("\nSection HANDLES size= ")DRW_dbg::getInstance()->print("\nSection HANDLES size= "); DRW_DBG(size)DRW_dbg::getInstance()->print(size); |
132 | DRW_DBG("\nSection HANDLES maxPos= ")DRW_dbg::getInstance()->print("\nSection HANDLES maxPos= " ); DRW_DBG(maxPos)DRW_dbg::getInstance()->print(maxPos); |
133 | |
134 | int startPos = offset; |
135 | |
136 | std::vector<duint8> tmpByteStr; |
137 | while (maxPos > dbuf->getPosition()) { |
138 | DRW_DBG("\nstart handles section buf->curPosition()= ")DRW_dbg::getInstance()->print("\nstart handles section buf->curPosition()= " ); DRW_DBG(dbuf->getPosition())DRW_dbg::getInstance()->print(dbuf->getPosition()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
139 | duint16 size = dbuf->getBERawShort16(); |
140 | DRW_DBG("object map section size= ")DRW_dbg::getInstance()->print("object map section size= "); DRW_DBG(size)DRW_dbg::getInstance()->print(size); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
141 | dbuf->setPosition(startPos); |
142 | tmpByteStr.resize(size); |
143 | dbuf->getBytes(tmpByteStr.data(), size); |
144 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
145 | if (size != 2){ |
146 | buff.setPosition(2); |
147 | int lastHandle = 0; |
148 | int lastLoc = 0; |
149 | //read data |
150 | while(buff.getPosition()< size){ |
151 | lastHandle += buff.getUModularChar(); |
152 | DRW_DBG("object map lastHandle= ")DRW_dbg::getInstance()->print("object map lastHandle= "); DRW_DBGH(lastHandle)DRW_dbg::getInstance()->printH(lastHandle); |
153 | lastLoc += buff.getModularChar(); |
154 | DRW_DBG(" lastLoc= ")DRW_dbg::getInstance()->print(" lastLoc= "); DRW_DBG(lastLoc)DRW_dbg::getInstance()->print(lastLoc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
155 | ObjectMap[lastHandle]= objHandle(0, lastHandle, lastLoc); |
156 | } |
157 | } |
158 | //verify crc |
159 | duint16 crcCalc = buff.crc8(0xc0c1,0,size); |
160 | duint16 crcRead = dbuf->getBERawShort16(); |
161 | DRW_DBG("object map section crc8 read= ")DRW_dbg::getInstance()->print("object map section crc8 read= " ); DRW_DBG(crcRead)DRW_dbg::getInstance()->print(crcRead); |
162 | DRW_DBG("\nobject map section crc8 calculated= ")DRW_dbg::getInstance()->print("\nobject map section crc8 calculated= " ); DRW_DBG(crcCalc)DRW_dbg::getInstance()->print(crcCalc); |
163 | DRW_DBG("\nobject section buf->curPosition()= ")DRW_dbg::getInstance()->print("\nobject section buf->curPosition()= " ); DRW_DBG(dbuf->getPosition())DRW_dbg::getInstance()->print(dbuf->getPosition()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
164 | startPos = dbuf->getPosition(); |
165 | } |
166 | |
167 | bool ret = dbuf->isGood(); |
168 | return ret; |
169 | } |
170 | |
171 | /*********** objects ************************/ |
172 | /** |
173 | * Reads all the object referenced in the object map section of the DWG file |
174 | * (using their object file offsets) |
175 | */ |
176 | bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) { |
177 | DRW_DBG("\ndwgReader::readDwgTables start\n")DRW_dbg::getInstance()->print("\ndwgReader::readDwgTables start\n" ); |
178 | bool ret = true; |
179 | bool ret2 = true; |
180 | objHandle oc; |
181 | dint16 oType; |
182 | duint32 bs = 0; //bit size of handle stream 2010+ |
183 | std::vector<duint8> tmpByteStr; |
184 | |
185 | //parse linetypes, start with linetype Control |
186 | auto mit = ObjectMap.find(hdr.linetypeCtrl); |
187 | if (mit==ObjectMap.end()) { |
188 | DRW_DBG("\nWARNING: LineType control not found\n")DRW_dbg::getInstance()->print("\nWARNING: LineType control not found\n" ); |
189 | ret = false; |
190 | } else { |
191 | DRW_DBG("\n**********Parsing LineType control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing LineType control*******\n" ); |
192 | oc = mit->second; |
193 | ObjectMap.erase(mit); |
194 | DRW_ObjControl ltControl; |
195 | dbuf->setPosition(oc.loc); |
196 | int csize = dbuf->getModularShort(); |
197 | if (version > DRW::AC1021) //2010+ |
198 | bs = dbuf->getUModularChar(); |
199 | else |
200 | bs = 0; |
201 | tmpByteStr.resize(csize); |
202 | dbuf->getBytes(tmpByteStr.data(), csize); |
203 | dwgBuffer cbuff(tmpByteStr.data(), csize, &decoder); |
204 | //verify if object are correct |
205 | oType = cbuff.getObjType(version); |
206 | if (oType != 0x38) { |
207 | DRW_DBG("\nWARNING: Not LineType control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not LineType control object, found oType " ); |
208 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x38\n")DRW_dbg::getInstance()->print(" instead 0x38\n"); |
209 | ret = false; |
210 | } else { //reset position |
211 | cbuff.resetPosition(); |
212 | ret2 = ltControl.parseDwg(version, &cbuff, bs); |
213 | if(ret) |
214 | ret = ret2; |
215 | } |
216 | for (auto it = ltControl.handlesList.begin(); it != ltControl.handlesList.end(); ++it) { |
217 | mit = ObjectMap.find(*it); |
218 | if (mit==ObjectMap.end()) { |
219 | DRW_DBG("\nWARNING: LineType not found\n")DRW_dbg::getInstance()->print("\nWARNING: LineType not found\n" ); |
220 | ret = false; |
221 | } else { |
222 | oc = mit->second; |
223 | ObjectMap.erase(mit); |
224 | DRW_DBG("\nLineType Handle= ")DRW_dbg::getInstance()->print("\nLineType Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" loc.: ")DRW_dbg::getInstance()->print(" loc.: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
225 | DRW_LType *lt = new DRW_LType(); |
226 | dbuf->setPosition(oc.loc); |
227 | int lsize = dbuf->getModularShort(); |
228 | DRW_DBG("LineType size in bytes= ")DRW_dbg::getInstance()->print("LineType size in bytes= "); DRW_DBG(lsize)DRW_dbg::getInstance()->print(lsize); |
229 | if (version > DRW::AC1021) //2010+ |
230 | bs = dbuf->getUModularChar(); |
231 | else |
232 | bs = 0; |
233 | tmpByteStr.resize(lsize); |
234 | dbuf->getBytes(tmpByteStr.data(), lsize); |
235 | dwgBuffer lbuff(tmpByteStr.data(), lsize, &decoder); |
236 | ret2 = lt->parseDwg(version, &lbuff, bs); |
237 | ltypemap[lt->handle] = lt; |
238 | if(ret) |
239 | ret = ret2; |
240 | } |
241 | } |
242 | } |
243 | |
244 | //parse layers, start with layer Control |
245 | mit = ObjectMap.find(hdr.layerCtrl); |
246 | if (mit==ObjectMap.end()) { |
247 | DRW_DBG("\nWARNING: Layer control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Layer control not found\n" ); |
248 | ret = false; |
249 | } else { |
250 | DRW_DBG("\n**********Parsing Layer control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Layer control*******\n" ); |
251 | oc = mit->second; |
252 | ObjectMap.erase(mit); |
253 | DRW_ObjControl layControl; |
254 | dbuf->setPosition(oc.loc); |
255 | int size = dbuf->getModularShort(); |
256 | if (version > DRW::AC1021) //2010+ |
257 | bs = dbuf->getUModularChar(); |
258 | else |
259 | bs = 0; |
260 | tmpByteStr.resize(size); |
261 | dbuf->getBytes(tmpByteStr.data(), size); |
262 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
263 | //verify if object are correct |
264 | oType = buff.getObjType(version); |
265 | if (oType != 0x32) { |
266 | DRW_DBG("\nWARNING: Not Layer control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Layer control object, found oType " ); |
267 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x32\n")DRW_dbg::getInstance()->print(" instead 0x32\n"); |
268 | ret = false; |
269 | } else { //reset position |
270 | buff.resetPosition(); |
271 | ret2 = layControl.parseDwg(version, &buff, bs); |
272 | if(ret) |
273 | ret = ret2; |
274 | } |
275 | for (auto it = layControl.handlesList.begin(); it != layControl.handlesList.end(); ++it) { |
276 | mit = ObjectMap.find(*it); |
277 | if (mit==ObjectMap.end()) { |
278 | DRW_DBG("\nWARNING: Layer not found\n")DRW_dbg::getInstance()->print("\nWARNING: Layer not found\n" ); |
279 | ret = false; |
280 | } else { |
281 | oc = mit->second; |
282 | ObjectMap.erase(mit); |
283 | DRW_DBG("Layer Handle= ")DRW_dbg::getInstance()->print("Layer Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
284 | DRW_Layer *la = new DRW_Layer(); |
285 | dbuf->setPosition(oc.loc); |
286 | int size = dbuf->getModularShort(); |
287 | if (version > DRW::AC1021) //2010+ |
288 | bs = dbuf->getUModularChar(); |
289 | else |
290 | bs = 0; |
291 | tmpByteStr.resize(size); |
292 | dbuf->getBytes(tmpByteStr.data(), size); |
293 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
294 | ret2 = la->parseDwg(version, &buff, bs); |
295 | layermap[la->handle] = la; |
296 | if(ret) |
297 | ret = ret2; |
298 | } |
299 | } |
300 | } |
301 | |
302 | //set linetype in layer |
303 | for (auto it=layermap.begin(); it!=layermap.end(); ++it) { |
304 | DRW_Layer *ly = it->second; |
305 | duint32 ref =ly->lTypeH.ref; |
306 | auto lt_it = ltypemap.find(ref); |
307 | if (lt_it != ltypemap.end()){ |
308 | ly->lineType = (lt_it->second)->name; |
309 | } |
310 | } |
311 | |
312 | //parse text styles, start with style Control |
313 | mit = ObjectMap.find(hdr.styleCtrl); |
314 | if (mit==ObjectMap.end()) { |
315 | DRW_DBG("\nWARNING: Style control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Style control not found\n" ); |
316 | ret = false; |
317 | } else { |
318 | DRW_DBG("\n**********Parsing Style control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Style control*******\n" ); |
319 | oc = mit->second; |
320 | ObjectMap.erase(mit); |
321 | DRW_ObjControl styControl; |
322 | dbuf->setPosition(oc.loc); |
323 | int size = dbuf->getModularShort(); |
324 | if (version > DRW::AC1021) //2010+ |
325 | bs = dbuf->getUModularChar(); |
326 | else |
327 | bs = 0; |
328 | tmpByteStr.resize(size); |
329 | dbuf->getBytes(tmpByteStr.data(), size); |
330 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
331 | //verify if object are correct |
332 | oType = buff.getObjType(version); |
333 | if (oType != 0x34) { |
334 | DRW_DBG("\nWARNING: Not Text Style control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Text Style control object, found oType " ); |
335 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x34\n")DRW_dbg::getInstance()->print(" instead 0x34\n"); |
336 | ret = false; |
337 | } else { //reset position |
338 | buff.resetPosition(); |
339 | ret2 = styControl.parseDwg(version, &buff, bs); |
340 | if(ret) |
341 | ret = ret2; |
342 | } |
343 | for (auto it = styControl.handlesList.begin(); it != styControl.handlesList.end(); ++it) { |
344 | mit = ObjectMap.find(*it); |
345 | if (mit==ObjectMap.end()) { |
346 | DRW_DBG("\nWARNING: Style not found\n")DRW_dbg::getInstance()->print("\nWARNING: Style not found\n" ); |
347 | ret = false; |
348 | } else { |
349 | oc = mit->second; |
350 | ObjectMap.erase(mit); |
351 | DRW_DBG("Style Handle= ")DRW_dbg::getInstance()->print("Style Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
352 | DRW_Textstyle *sty = new DRW_Textstyle(); |
353 | dbuf->setPosition(oc.loc); |
354 | int size = dbuf->getModularShort(); |
355 | if (version > DRW::AC1021) //2010+ |
356 | bs = dbuf->getUModularChar(); |
357 | else |
358 | bs = 0; |
359 | tmpByteStr.resize(size); |
360 | dbuf->getBytes(tmpByteStr.data(), size); |
361 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
362 | ret2 = sty->parseDwg(version, &buff, bs); |
363 | stylemap[sty->handle] = sty; |
364 | if(ret) |
365 | ret = ret2; |
366 | } |
367 | } |
368 | } |
369 | |
370 | //parse dim styles, start with dimstyle Control |
371 | mit = ObjectMap.find(hdr.dimstyleCtrl); |
372 | if (mit==ObjectMap.end()) { |
373 | DRW_DBG("\nWARNING: Dimension Style control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Dimension Style control not found\n" ); |
374 | ret = false; |
375 | } else { |
376 | DRW_DBG("\n**********Parsing Dimension Style control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Dimension Style control*******\n" ); |
377 | oc = mit->second; |
378 | ObjectMap.erase(mit); |
379 | DRW_ObjControl dimstyControl; |
380 | dbuf->setPosition(oc.loc); |
381 | duint32 size = dbuf->getModularShort(); |
382 | if (version > DRW::AC1021) //2010+ |
383 | bs = dbuf->getUModularChar(); |
384 | else |
385 | bs = 0; |
386 | tmpByteStr.resize(size); |
387 | dbuf->getBytes(tmpByteStr.data(), size); |
388 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
389 | //verify if object are correct |
390 | oType = buff.getObjType(version); |
391 | if (oType != 0x44) { |
392 | DRW_DBG("\nWARNING: Not Dim Style control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Dim Style control object, found oType " ); |
393 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x44\n")DRW_dbg::getInstance()->print(" instead 0x44\n"); |
394 | ret = false; |
395 | } else { //reset position |
396 | buff.resetPosition(); |
397 | ret2 = dimstyControl.parseDwg(version, &buff, bs); |
398 | if(ret) |
399 | ret = ret2; |
400 | } |
401 | for (auto it = dimstyControl.handlesList.begin(); it != dimstyControl.handlesList.end(); ++it) { |
402 | mit = ObjectMap.find(*it); |
403 | if (mit==ObjectMap.end()) { |
404 | DRW_DBG("\nWARNING: Dimension Style not found\n")DRW_dbg::getInstance()->print("\nWARNING: Dimension Style not found\n" ); |
405 | ret = false; |
406 | } else { |
407 | oc = mit->second; |
408 | ObjectMap.erase(mit); |
409 | DRW_DBG("Dimstyle Handle= ")DRW_dbg::getInstance()->print("Dimstyle Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
410 | DRW_Dimstyle *sty = new DRW_Dimstyle(); |
411 | dbuf->setPosition(oc.loc); |
412 | int size = dbuf->getModularShort(); |
413 | if (version > DRW::AC1021) //2010+ |
414 | bs = dbuf->getUModularChar(); |
415 | else |
416 | bs = 0; |
417 | tmpByteStr.resize(size); |
418 | dbuf->getBytes(tmpByteStr.data(), size); |
419 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
420 | ret2 = sty->parseDwg(version, &buff, bs); |
421 | dimstylemap[sty->handle] = sty; |
422 | if(ret) |
423 | ret = ret2; |
424 | } |
425 | } |
426 | } |
427 | |
428 | //parse vports, start with vports Control |
429 | mit = ObjectMap.find(hdr.vportCtrl); |
430 | if (mit==ObjectMap.end()) { |
431 | DRW_DBG("\nWARNING: vports control not found\n")DRW_dbg::getInstance()->print("\nWARNING: vports control not found\n" ); |
432 | ret = false; |
433 | } else { |
434 | DRW_DBG("\n**********Parsing vports control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing vports control*******\n" ); |
435 | oc = mit->second; |
436 | ObjectMap.erase(mit); |
437 | DRW_ObjControl vportControl; |
438 | dbuf->setPosition(oc.loc); |
439 | int size = dbuf->getModularShort(); |
440 | if (version > DRW::AC1021) //2010+ |
441 | bs = dbuf->getUModularChar(); |
442 | else |
443 | bs = 0; |
444 | tmpByteStr.resize(size); |
445 | dbuf->getBytes(tmpByteStr.data(), size); |
446 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
447 | //verify if object are correct |
448 | oType = buff.getObjType(version); |
449 | if (oType != 0x40) { |
450 | DRW_DBG("\nWARNING: Not VPorts control object, found oType: ")DRW_dbg::getInstance()->print("\nWARNING: Not VPorts control object, found oType: " ); |
451 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x40\n")DRW_dbg::getInstance()->print(" instead 0x40\n"); |
452 | ret = false; |
453 | } else { //reset position |
454 | buff.resetPosition(); |
455 | ret2 = vportControl.parseDwg(version, &buff, bs); |
456 | if(ret) |
457 | ret = ret2; |
458 | } |
459 | for (auto it = vportControl.handlesList.begin(); it != vportControl.handlesList.end(); ++it) { |
460 | mit = ObjectMap.find(*it); |
461 | if (mit==ObjectMap.end()) { |
462 | DRW_DBG("\nWARNING: vport not found\n")DRW_dbg::getInstance()->print("\nWARNING: vport not found\n" ); |
463 | ret = false; |
464 | } else { |
465 | oc = mit->second; |
466 | ObjectMap.erase(mit); |
467 | DRW_DBG("Vport Handle= ")DRW_dbg::getInstance()->print("Vport Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
468 | DRW_Vport *vp = new DRW_Vport(); |
469 | dbuf->setPosition(oc.loc); |
470 | int size = dbuf->getModularShort(); |
471 | if (version > DRW::AC1021) //2010+ |
472 | bs = dbuf->getUModularChar(); |
473 | else |
474 | bs = 0; |
475 | tmpByteStr.resize(size); |
476 | dbuf->getBytes(tmpByteStr.data(), size); |
477 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
478 | ret2 = vp->parseDwg(version, &buff, bs); |
479 | vportmap[vp->handle] = vp; |
480 | if(ret) |
481 | ret = ret2; |
482 | } |
483 | } |
484 | } |
485 | |
486 | //parse Block_records , start with Block_record Control |
487 | mit = ObjectMap.find(hdr.blockCtrl); |
488 | if (mit==ObjectMap.end()) { |
489 | DRW_DBG("\nWARNING: Block_record control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Block_record control not found\n" ); |
490 | ret = false; |
491 | } else { |
492 | DRW_DBG("\n**********Parsing Block_record control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Block_record control*******\n" ); |
493 | oc = mit->second; |
494 | ObjectMap.erase(mit); |
495 | DRW_ObjControl blockControl; |
496 | dbuf->setPosition(oc.loc); |
497 | int csize = dbuf->getModularShort(); |
498 | if (version > DRW::AC1021) //2010+ |
499 | bs = dbuf->getUModularChar(); |
500 | else |
501 | bs = 0; |
502 | tmpByteStr.resize(csize); |
503 | dbuf->getBytes(tmpByteStr.data(), csize); |
504 | dwgBuffer buff(tmpByteStr.data(), csize, &decoder); |
505 | //verify if object are correct |
506 | oType = buff.getObjType(version); |
507 | if (oType != 0x30) { |
508 | DRW_DBG("\nWARNING: Not Block Record control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Block Record control object, found oType " ); |
509 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x30\n")DRW_dbg::getInstance()->print(" instead 0x30\n"); |
510 | ret = false; |
511 | } else { //reset position |
512 | buff.resetPosition(); |
513 | ret2 = blockControl.parseDwg(version, &buff, bs); |
514 | if(ret) |
515 | ret = ret2; |
516 | } |
517 | for (auto it = blockControl.handlesList.begin(); it != blockControl.handlesList.end(); ++it) { |
518 | mit = ObjectMap.find(*it); |
519 | if (mit==ObjectMap.end()) { |
520 | DRW_DBG("\nWARNING: block record not found\n")DRW_dbg::getInstance()->print("\nWARNING: block record not found\n" ); |
521 | ret = false; |
522 | } else { |
523 | oc = mit->second; |
524 | ObjectMap.erase(mit); |
525 | DRW_DBG("block record Handle= ")DRW_dbg::getInstance()->print("block record Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
526 | DRW_Block_Record *br = new DRW_Block_Record(); |
527 | dbuf->setPosition(oc.loc); |
528 | int size = dbuf->getModularShort(); |
529 | if (version > DRW::AC1021) //2010+ |
530 | bs = dbuf->getUModularChar(); |
531 | else |
532 | bs = 0; |
533 | tmpByteStr.resize(size); |
534 | dbuf->getBytes(tmpByteStr.data(), size); |
535 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
536 | ret2 = br->parseDwg(version, &buff, bs); |
537 | blockRecordmap[br->handle] = br; |
538 | if(ret) |
539 | ret = ret2; |
540 | } |
541 | } |
542 | } |
543 | |
544 | //parse appId , start with appId Control |
545 | mit = ObjectMap.find(hdr.appidCtrl); |
546 | if (mit==ObjectMap.end()) { |
547 | DRW_DBG("\nWARNING: AppId control not found\n")DRW_dbg::getInstance()->print("\nWARNING: AppId control not found\n" ); |
548 | ret = false; |
549 | } else { |
550 | DRW_DBG("\n**********Parsing AppId control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing AppId control*******\n" ); |
551 | oc = mit->second; |
552 | ObjectMap.erase(mit); |
553 | DRW_DBG("AppId Control Obj Handle= ")DRW_dbg::getInstance()->print("AppId Control Obj Handle= " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
554 | DRW_ObjControl appIdControl; |
555 | dbuf->setPosition(oc.loc); |
556 | int size = dbuf->getModularShort(); |
557 | if (version > DRW::AC1021) //2010+ |
558 | bs = dbuf->getUModularChar(); |
559 | else |
560 | bs = 0; |
561 | tmpByteStr.resize(size); |
562 | dbuf->getBytes(tmpByteStr.data(), size); |
563 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
564 | //verify if object are correct |
565 | oType = buff.getObjType(version); |
566 | if (oType != 0x42) { |
567 | DRW_DBG("\nWARNING: Not AppId control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not AppId control object, found oType " ); |
568 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x42\n")DRW_dbg::getInstance()->print(" instead 0x42\n"); |
569 | ret = false; |
570 | } else { //reset position |
571 | buff.resetPosition(); |
572 | ret2 = appIdControl.parseDwg(version, &buff, bs); |
573 | if(ret) |
574 | ret = ret2; |
575 | } |
576 | for (auto it = appIdControl.handlesList.begin(); it != appIdControl.handlesList.end(); ++it) { |
577 | mit = ObjectMap.find(*it); |
578 | if (mit==ObjectMap.end()) { |
579 | DRW_DBG("\nWARNING: AppId not found\n")DRW_dbg::getInstance()->print("\nWARNING: AppId not found\n" ); |
580 | ret = false; |
581 | } else { |
582 | oc = mit->second; |
583 | ObjectMap.erase(mit); |
584 | DRW_DBG("AppId Handle= ")DRW_dbg::getInstance()->print("AppId Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
585 | DRW_AppId *ai = new DRW_AppId(); |
586 | dbuf->setPosition(oc.loc); |
587 | int size = dbuf->getModularShort(); |
588 | if (version > DRW::AC1021) //2010+ |
589 | bs = dbuf->getUModularChar(); |
590 | else |
591 | bs = 0; |
592 | tmpByteStr.resize(size); |
593 | dbuf->getBytes(tmpByteStr.data(), size); |
594 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
595 | ret2 = ai->parseDwg(version, &buff, bs); |
596 | appIdmap[ai->handle] = ai; |
597 | if(ret) |
598 | ret = ret2; |
599 | } |
600 | } |
601 | } |
602 | |
603 | //RLZ: parse remaining object controls, TODO: implement all |
604 | if (DRW_DBGGLDRW_dbg::getInstance()->getLevel() == DRW_dbg::Level::Debug){ |
605 | mit = ObjectMap.find(hdr.viewCtrl); |
606 | if (mit==ObjectMap.end()) { |
607 | DRW_DBG("\nWARNING: View control not found\n")DRW_dbg::getInstance()->print("\nWARNING: View control not found\n" ); |
608 | ret = false; |
609 | } else { |
610 | DRW_DBG("\n**********Parsing View control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing View control*******\n" ); |
611 | oc = mit->second; |
612 | ObjectMap.erase(mit); |
613 | DRW_DBG("View Control Obj Handle= ")DRW_dbg::getInstance()->print("View Control Obj Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
614 | DRW_ObjControl viewControl; |
615 | dbuf->setPosition(oc.loc); |
616 | int size = dbuf->getModularShort(); |
617 | if (version > DRW::AC1021) //2010+ |
618 | bs = dbuf->getUModularChar(); |
619 | else |
620 | bs = 0; |
621 | tmpByteStr.resize(size); |
622 | dbuf->getBytes(tmpByteStr.data(), size); |
623 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
624 | //verify if object are correct |
625 | oType = buff.getObjType(version); |
626 | if (oType != 0x3C) { |
627 | DRW_DBG("\nWARNING: Not View control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not View control object, found oType " ); |
628 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x3C\n")DRW_dbg::getInstance()->print(" instead 0x3C\n"); |
629 | ret = false; |
630 | } else { //reset position |
631 | buff.resetPosition(); |
632 | ret2 = viewControl.parseDwg(version, &buff, bs); |
633 | if(ret) |
634 | ret = ret2; |
635 | } |
636 | } |
637 | |
638 | mit = ObjectMap.find(hdr.ucsCtrl); |
639 | if (mit==ObjectMap.end()) { |
640 | DRW_DBG("\nWARNING: Ucs control not found\n")DRW_dbg::getInstance()->print("\nWARNING: Ucs control not found\n" ); |
641 | ret = false; |
642 | } else { |
643 | oc = mit->second; |
644 | ObjectMap.erase(mit); |
645 | DRW_DBG("\n**********Parsing Ucs control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing Ucs control*******\n" ); |
646 | DRW_DBG("Ucs Control Obj Handle= ")DRW_dbg::getInstance()->print("Ucs Control Obj Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
647 | DRW_ObjControl ucsControl; |
648 | dbuf->setPosition(oc.loc); |
649 | int size = dbuf->getModularShort(); |
650 | if (version > DRW::AC1021) //2010+ |
651 | bs = dbuf->getUModularChar(); |
652 | else |
653 | bs = 0; |
654 | tmpByteStr.resize(size); |
655 | dbuf->getBytes(tmpByteStr.data(), size); |
656 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
657 | //verify if object are correct |
658 | oType = buff.getObjType(version); |
659 | if (oType != 0x3E) { |
660 | DRW_DBG("\nWARNING: Not Ucs control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not Ucs control object, found oType " ); |
661 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x3E\n")DRW_dbg::getInstance()->print(" instead 0x3E\n"); |
662 | ret = false; |
663 | } else { //reset position |
664 | buff.resetPosition(); |
665 | ret2 = ucsControl.parseDwg(version, &buff, bs); |
666 | if(ret) |
667 | ret = ret2; |
668 | } |
669 | } |
670 | |
671 | if (version < DRW::AC1018) {//r2000- |
672 | mit = ObjectMap.find(hdr.vpEntHeaderCtrl); |
673 | if (mit==ObjectMap.end()) { |
674 | DRW_DBG("\nWARNING: vpEntHeader control not found\n")DRW_dbg::getInstance()->print("\nWARNING: vpEntHeader control not found\n" ); |
675 | ret = false; |
676 | } else { |
677 | DRW_DBG("\n**********Parsing vpEntHeader control*******\n")DRW_dbg::getInstance()->print("\n**********Parsing vpEntHeader control*******\n" ); |
678 | oc = mit->second; |
679 | ObjectMap.erase(mit); |
680 | DRW_DBG("vpEntHeader Control Obj Handle= ")DRW_dbg::getInstance()->print("vpEntHeader Control Obj Handle= " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
681 | DRW_ObjControl vpEntHeaderCtrl; |
682 | dbuf->setPosition(oc.loc); |
683 | int size = dbuf->getModularShort(); |
684 | if (version > DRW::AC1021) //2010+ |
685 | bs = dbuf->getUModularChar(); |
Value stored to 'bs' is never read | |
686 | else |
687 | bs = 0; |
688 | tmpByteStr.resize(size); |
689 | dbuf->getBytes(tmpByteStr.data(), size); |
690 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
691 | //verify if object are correct |
692 | oType = buff.getObjType(version); |
693 | if (oType != 0x46) { |
694 | DRW_DBG("\nWARNING: Not vpEntHeader control object, found oType ")DRW_dbg::getInstance()->print("\nWARNING: Not vpEntHeader control object, found oType " ); |
695 | DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG(" instead 0x46\n")DRW_dbg::getInstance()->print(" instead 0x46\n"); |
696 | ret = false; |
697 | } else { //reset position |
698 | buff.resetPosition(); |
699 | /* RLZ: writeme ret2 = vpEntHeader.parseDwg(version, &buff, bs); |
700 | if(ret) |
701 | ret = ret2;*/ |
702 | } |
703 | } |
704 | } |
705 | } |
706 | |
707 | return ret; |
708 | } |
709 | |
710 | bool dwgReader::readDwgBlocks(DRW_Interface& intfa, dwgBuffer *dbuf){ |
711 | bool ret = true; |
712 | bool ret2 = true; |
713 | duint32 bs =0; |
714 | DRW_DBG("\nobject map total size= ")DRW_dbg::getInstance()->print("\nobject map total size= "); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
715 | |
716 | for (auto it=blockRecordmap.begin(); it != blockRecordmap.end(); ++it){ |
717 | DRW_Block_Record* bkr= it->second; |
718 | DRW_DBG("\nParsing Block, record handle= ")DRW_dbg::getInstance()->print("\nParsing Block, record handle= " ); DRW_DBGH(it->first)DRW_dbg::getInstance()->printH(it->first); DRW_DBG(" Name= ")DRW_dbg::getInstance()->print(" Name= "); DRW_DBG(bkr->name)DRW_dbg::getInstance()->print(bkr->name); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
719 | DRW_DBG("\nFinding Block, handle= ")DRW_dbg::getInstance()->print("\nFinding Block, handle= "); DRW_DBGH(bkr->block)DRW_dbg::getInstance()->printH(bkr->block); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
720 | auto mit = ObjectMap.find(bkr->block); |
721 | if (mit==ObjectMap.end()) { |
722 | DRW_DBG("\nWARNING: block entity not found\n")DRW_dbg::getInstance()->print("\nWARNING: block entity not found\n" ); |
723 | ret = false; |
724 | continue; |
725 | } |
726 | objHandle oc = mit->second; |
727 | ObjectMap.erase(mit); |
728 | DRW_DBG("Block Handle= ")DRW_dbg::getInstance()->print("Block Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" Location: ")DRW_dbg::getInstance()->print(" Location: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
729 | if ( !(dbuf->setPosition(oc.loc)) ){ |
730 | DRW_DBG("Bad Location reading blocks\n")DRW_dbg::getInstance()->print("Bad Location reading blocks\n" ); |
731 | ret = false; |
732 | continue; |
733 | } |
734 | int size = dbuf->getModularShort(); |
735 | if (version > DRW::AC1021) //2010+ |
736 | bs = dbuf->getUModularChar(); |
737 | else |
738 | bs = 0; |
739 | |
740 | std::vector<duint8> tmpByteStr(size); |
741 | dbuf->getBytes(tmpByteStr.data(), size); |
742 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
743 | DRW_Block bk; |
744 | ret2 = bk.parseDwg(version, &buff, bs); |
745 | ret = ret && ret2; |
746 | parseAttribs(&bk); |
747 | //complete block entity with block record data |
748 | bk.basePoint = bkr->basePoint; |
749 | bk.flags = bkr->flags; |
750 | intfa.addBlock(bk); |
751 | //and update block record name |
752 | bkr->name = bk.name; |
753 | |
754 | /**read & send block entities**/ |
755 | // in dwg code 330 are not set like dxf in ModelSpace & PaperSpace, set it (RLZ: only tested in 2000) |
756 | if (bk.parentHandle == DRW::NoHandle) { |
757 | // in dwg code 330 are not set like dxf in ModelSpace & PaperSpace, set it |
758 | bk.parentHandle= bkr->handle; |
759 | //and do not send block entities like dxf |
760 | } else { |
761 | if (version < DRW::AC1018) { //pre 2004 |
762 | duint32 nextH = bkr->firstEH; |
763 | while (nextH != 0){ |
764 | mit = ObjectMap.find(nextH); |
765 | if (mit==ObjectMap.end()) { |
766 | nextH = 0;//end while if entity not found |
767 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
768 | ret = false; |
769 | continue; |
770 | } else {//foud entity reads it |
771 | oc = mit->second; |
772 | ObjectMap.erase(mit); |
773 | ret2 = readDwgEntity(dbuf, oc, intfa); |
774 | ret = ret && ret2; |
775 | } |
776 | if (nextH == bkr->lastEH) |
777 | nextH = 0; //redundant, but prevent read errors |
778 | else |
779 | nextH = nextEntLink; |
780 | } |
781 | } else {//2004+ |
782 | for (std::vector<duint32>::iterator it = bkr->entMap.begin() ; it != bkr->entMap.end(); ++it){ |
783 | duint32 nextH = *it; |
784 | mit = ObjectMap.find(nextH); |
785 | if (mit==ObjectMap.end()) { |
786 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
787 | ret = false; |
788 | continue; |
789 | } else {//foud entity reads it |
790 | oc = mit->second; |
791 | ObjectMap.erase(mit); |
792 | DRW_DBG("\nBlocks, parsing entity: ")DRW_dbg::getInstance()->print("\nBlocks, parsing entity: " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(", pos: ")DRW_dbg::getInstance()->print(", pos: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
793 | ret2 = readDwgEntity(dbuf, oc, intfa); |
794 | ret = ret && ret2; |
795 | } |
796 | } |
797 | }//end 2004+ |
798 | } |
799 | |
800 | //end block entity, really needed to parse a dummy entity?? |
801 | mit = ObjectMap.find(bkr->endBlock); |
802 | if (mit==ObjectMap.end()) { |
803 | DRW_DBG("\nWARNING: end block entity not found\n")DRW_dbg::getInstance()->print("\nWARNING: end block entity not found\n" ); |
804 | ret = false; |
805 | continue; |
806 | } |
807 | oc = mit->second; |
808 | ObjectMap.erase(mit); |
809 | DRW_DBG("End block Handle= ")DRW_dbg::getInstance()->print("End block Handle= "); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(" Location: ")DRW_dbg::getInstance()->print(" Location: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
810 | dbuf->setPosition(oc.loc); |
811 | size = dbuf->getModularShort(); |
812 | if (version > DRW::AC1021) //2010+ |
813 | bs = dbuf->getUModularChar(); |
814 | else |
815 | bs = 0; |
816 | tmpByteStr.resize(size); |
817 | dbuf->getBytes(tmpByteStr.data(), size); |
818 | dwgBuffer buff1(tmpByteStr.data(), size, &decoder); |
819 | DRW_Block end; |
820 | end.isEnd = true; |
821 | ret2 = end.parseDwg(version, &buff1, bs); |
822 | ret = ret && ret2; |
823 | if (bk.parentHandle == DRW::NoHandle) bk.parentHandle= bkr->handle; |
824 | parseAttribs(&end); |
825 | intfa.endBlock(); |
826 | } |
827 | |
828 | return ret; |
829 | } |
830 | |
831 | bool dwgReader::readPlineVertex(DRW_Polyline& pline, dwgBuffer *dbuf){ |
832 | bool ret = true; |
833 | bool ret2 = true; |
834 | objHandle oc; |
835 | duint32 bs = 0; |
836 | |
837 | if (version < DRW::AC1018) { //pre 2004 |
838 | duint32 nextH = pline.firstEH; |
839 | while (nextH != 0){ |
840 | auto mit = ObjectMap.find(nextH); |
841 | if (mit==ObjectMap.end()) { |
842 | nextH = 0;//end while if entity not found |
843 | DRW_DBG("\nWARNING: pline vertex not found\n")DRW_dbg::getInstance()->print("\nWARNING: pline vertex not found\n" ); |
844 | ret = false; |
845 | continue; |
846 | } else {//foud entity reads it |
847 | oc = mit->second; |
848 | ObjectMap.erase(mit); |
849 | DRW_Vertex vt; |
850 | dbuf->setPosition(oc.loc); |
851 | //RLZ: verify if pos is ok |
852 | int size = dbuf->getModularShort(); |
853 | if (version > DRW::AC1021) {//2010+ |
854 | bs = dbuf->getUModularChar(); |
855 | } |
856 | std::vector<duint8> tmpByteStr(size); |
857 | dbuf->getBytes(tmpByteStr.data(), size); |
858 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
859 | dint16 oType = buff.getObjType(version); |
860 | buff.resetPosition(); |
861 | DRW_DBG(" object type= ")DRW_dbg::getInstance()->print(" object type= "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
862 | ret2 = vt.parseDwg(version, &buff, bs, pline.basePoint.z); |
863 | pline.addVertex(vt); |
864 | nextEntLink = vt.nextEntLink; \ |
865 | prevEntLink = vt.prevEntLink; |
866 | ret = ret && ret2; |
867 | } |
868 | if (nextH == pline.lastEH) |
869 | nextH = 0; //redundant, but prevent read errors |
870 | else |
871 | nextH = nextEntLink; |
872 | } |
873 | } else {//2004+ |
874 | for (std::list<duint32>::iterator it = pline.hadlesList.begin() ; it != pline.hadlesList.end(); ++it){ |
875 | duint32 nextH = *it; |
876 | auto mit = ObjectMap.find(nextH); |
877 | if (mit==ObjectMap.end()) { |
878 | DRW_DBG("\nWARNING: Entity of block not found\n")DRW_dbg::getInstance()->print("\nWARNING: Entity of block not found\n" ); |
879 | ret = false; |
880 | continue; |
881 | } else {//foud entity reads it |
882 | oc = mit->second; |
883 | ObjectMap.erase(mit); |
884 | DRW_DBG("\nPline vertex, parsing entity: ")DRW_dbg::getInstance()->print("\nPline vertex, parsing entity: " ); DRW_DBGH(oc.handle)DRW_dbg::getInstance()->printH(oc.handle); DRW_DBG(", pos: ")DRW_dbg::getInstance()->print(", pos: "); DRW_DBG(oc.loc)DRW_dbg::getInstance()->print(oc.loc); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
885 | DRW_Vertex vt; |
886 | dbuf->setPosition(oc.loc); |
887 | //RLZ: verify if pos is ok |
888 | int size = dbuf->getModularShort(); |
889 | if (version > DRW::AC1021) {//2010+ |
890 | bs = dbuf->getUModularChar(); |
891 | } |
892 | std::vector<duint8> tmpByteStr(size); |
893 | dbuf->getBytes(tmpByteStr.data(), size); |
894 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
895 | dint16 oType = buff.getObjType(version); |
896 | buff.resetPosition(); |
897 | DRW_DBG(" object type= ")DRW_dbg::getInstance()->print(" object type= "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
898 | ret2 = vt.parseDwg(version, &buff, bs, pline.basePoint.z); |
899 | pline.addVertex(vt); |
900 | nextEntLink = vt.nextEntLink; \ |
901 | prevEntLink = vt.prevEntLink; |
902 | ret = ret && ret2; |
903 | } |
904 | } |
905 | }//end 2004+ |
906 | DRW_DBG("\nRemoved SEQEND entity: ")DRW_dbg::getInstance()->print("\nRemoved SEQEND entity: "); DRW_DBGH(pline.seqEndH.ref)DRW_dbg::getInstance()->printH(pline.seqEndH.ref);DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
907 | ObjectMap.erase(pline.seqEndH.ref); |
908 | |
909 | return ret; |
910 | } |
911 | |
912 | bool dwgReader::readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf){ |
913 | bool ret = true; |
914 | |
915 | DRW_DBG("\nobject map total size= ")DRW_dbg::getInstance()->print("\nobject map total size= "); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
916 | auto itB=ObjectMap.begin(); |
917 | auto itE=ObjectMap.end(); |
918 | while (itB != itE) { |
919 | if (ret) { |
920 | // once readDwgEntity() failed, just clear the ObjectMap |
921 | ret = readDwgEntity( dbuf, itB->second, intfa); |
922 | } |
923 | ObjectMap.erase( itB); |
924 | itB = ObjectMap.begin(); |
925 | } |
926 | return ret; |
927 | } |
928 | |
929 | /** |
930 | * Reads a dwg drawing entity (dwg object entity) given its offset in the file |
931 | */ |
932 | bool dwgReader::readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa){ |
933 | bool ret = true; |
934 | duint32 bs = 0; |
935 | |
936 | nextEntLink = prevEntLink = 0;// set to 0 to skip unimplemented entities |
937 | dbuf->setPosition(obj.loc); |
938 | //verify if position is ok: |
939 | if (!dbuf->isGood()){ |
940 | DRW_DBG(" Warning: readDwgEntity, bad location\n")DRW_dbg::getInstance()->print(" Warning: readDwgEntity, bad location\n" ); |
941 | return false; |
942 | } |
943 | int size = dbuf->getModularShort(); |
944 | if (version > DRW::AC1021) {//2010+ |
945 | bs = dbuf->getUModularChar(); |
946 | } |
947 | std::vector<duint8> tmpByteStr(size); |
948 | dbuf->getBytes(tmpByteStr.data(), size); |
949 | //verify if getBytes is ok: |
950 | if (!dbuf->isGood()) { |
951 | DRW_DBG(" Warning: readDwgEntity, bad size\n")DRW_dbg::getInstance()->print(" Warning: readDwgEntity, bad size\n" ); |
952 | return false; |
953 | } |
954 | dwgBuffer buff(tmpByteStr.data(), size, &decoder); |
955 | dint16 oType = buff.getObjType(version); |
956 | buff.resetPosition(); |
957 | |
958 | if (oType > 499){ |
959 | auto it = classesmap.find(oType); |
960 | if (it == classesmap.end()){//fail, not found in classes set error |
961 | DRW_DBG("Class ")DRW_dbg::getInstance()->print("Class "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("not found, handle: ")DRW_dbg::getInstance()->print("not found, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
962 | return false; |
963 | } else { |
964 | DRW_Class *cl = it->second; |
965 | if (cl->dwgType != 0) |
966 | oType = cl->dwgType; |
967 | } |
968 | } |
969 | |
970 | obj.type = oType; |
971 | switch (oType) { |
972 | case 17: { |
973 | DRW_Arc e; |
974 | if (entryParse( e, buff, bs, ret)) { |
975 | intfa.addArc(e); |
976 | } |
977 | break; } |
978 | case 18: { |
979 | DRW_Circle e; |
980 | if (entryParse( e, buff, bs, ret)) { |
981 | intfa.addCircle(e); |
982 | } |
983 | break; } |
984 | case 19:{ |
985 | DRW_Line e; |
986 | if (entryParse( e, buff, bs, ret)) { |
987 | intfa.addLine(e); |
988 | } |
989 | break;} |
990 | case 27: { |
991 | DRW_Point e; |
992 | if (entryParse( e, buff, bs, ret)) { |
993 | intfa.addPoint(e); |
994 | } |
995 | break; } |
996 | case 35: { |
997 | DRW_Ellipse e; |
998 | if (entryParse( e, buff, bs, ret)) { |
999 | intfa.addEllipse(e); |
1000 | } |
1001 | break; } |
1002 | case 7: |
1003 | case 8: {//minsert = 8 |
1004 | DRW_Insert e; |
1005 | if (entryParse( e, buff, bs, ret)) { |
1006 | e.name = findTableName(DRW::BLOCK_RECORD, |
1007 | e.blockRecH.ref);//RLZ: find as block or blockrecord (ps & ps0) |
1008 | intfa.addInsert(e); |
1009 | } |
1010 | break; } |
1011 | case 77: { |
1012 | DRW_LWPolyline e; |
1013 | if (entryParse( e, buff, bs, ret)) { |
1014 | intfa.addLWPolyline(e); |
1015 | } |
1016 | break; } |
1017 | case 1: { |
1018 | DRW_Text e; |
1019 | if (entryParse( e, buff, bs, ret)) { |
1020 | e.style = findTableName(DRW::STYLE, e.styleH.ref); |
1021 | intfa.addText(e); |
1022 | } |
1023 | break; } |
1024 | case 44: { |
1025 | DRW_MText e; |
1026 | if (entryParse( e, buff, bs, ret)) { |
1027 | e.style = findTableName(DRW::STYLE, e.styleH.ref); |
1028 | intfa.addMText(e); |
1029 | } |
1030 | break; } |
1031 | case 28: { |
1032 | DRW_3Dface e; |
1033 | if (entryParse( e, buff, bs, ret)) { |
1034 | intfa.add3dFace(e); |
1035 | } |
1036 | break; } |
1037 | case 20: { |
1038 | DRW_DimOrdinate e; |
1039 | if (entryParse( e, buff, bs, ret)) { |
1040 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1041 | intfa.addDimOrdinate(&e); |
1042 | } |
1043 | break; } |
1044 | case 21: { |
1045 | DRW_DimLinear e; |
1046 | if (entryParse( e, buff, bs, ret)) { |
1047 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1048 | intfa.addDimLinear(&e); |
1049 | } |
1050 | break; } |
1051 | case 22: { |
1052 | DRW_DimAligned e; |
1053 | if (entryParse( e, buff, bs, ret)) { |
1054 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1055 | intfa.addDimAlign(&e); |
1056 | } |
1057 | break; } |
1058 | case 23: { |
1059 | DRW_DimAngular3p e; |
1060 | if (entryParse( e, buff, bs, ret)) { |
1061 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1062 | intfa.addDimAngular3P(&e); |
1063 | } |
1064 | break; } |
1065 | case 24: { |
1066 | DRW_DimAngular e; |
1067 | if (entryParse( e, buff, bs, ret)) { |
1068 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1069 | intfa.addDimAngular(&e); |
1070 | } |
1071 | break; } |
1072 | case 25: { |
1073 | DRW_DimRadial e; |
1074 | if (entryParse( e, buff, bs, ret)) { |
1075 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1076 | intfa.addDimRadial(&e); |
1077 | } |
1078 | break; } |
1079 | case 26: { |
1080 | DRW_DimDiametric e; |
1081 | if (entryParse( e, buff, bs, ret)) { |
1082 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1083 | intfa.addDimDiametric(&e); |
1084 | } |
1085 | break; } |
1086 | case 45: { |
1087 | DRW_Leader e; |
1088 | if (entryParse( e, buff, bs, ret)) { |
1089 | e.style = findTableName(DRW::DIMSTYLE, e.dimStyleH.ref); |
1090 | intfa.addLeader(&e); |
1091 | } |
1092 | break; } |
1093 | case 31: { |
1094 | DRW_Solid e; |
1095 | if (entryParse( e, buff, bs, ret)) { |
1096 | intfa.addSolid(e); |
1097 | } |
1098 | break; } |
1099 | case 78: { |
1100 | DRW_Hatch e; |
1101 | if (entryParse( e, buff, bs, ret)) { |
1102 | intfa.addHatch(&e); |
1103 | } |
1104 | break; } |
1105 | case 32: { |
1106 | DRW_Trace e; |
1107 | if (entryParse( e, buff, bs, ret)) { |
1108 | intfa.addTrace(e); |
1109 | } |
1110 | break; } |
1111 | case 34: { |
1112 | DRW_Viewport e; |
1113 | if (entryParse( e, buff, bs, ret)) { |
1114 | intfa.addViewport(e); |
1115 | } |
1116 | break; } |
1117 | case 36: { |
1118 | DRW_Spline e; |
1119 | if (entryParse( e, buff, bs, ret)) { |
1120 | intfa.addSpline(&e); |
1121 | } |
1122 | break; } |
1123 | case 40: { |
1124 | DRW_Ray e; |
1125 | if (entryParse( e, buff, bs, ret)) { |
1126 | intfa.addRay(e); |
1127 | } |
1128 | break; } |
1129 | case 15: // pline 2D |
1130 | case 16: // pline 3D |
1131 | case 29: { // pline PFACE |
1132 | DRW_Polyline e; |
1133 | if (entryParse( e, buff, bs, ret)) { |
1134 | readPlineVertex(e, dbuf); |
1135 | intfa.addPolyline(e); |
1136 | } |
1137 | break; } |
1138 | // case 30: { |
1139 | // DRW_Polyline e;// MESH (not pline) |
1140 | // ENTRY_PARSE(e) |
1141 | // intfa.addRay(e); |
1142 | // break; } |
1143 | case 41: { |
1144 | DRW_Xline e; |
1145 | if (entryParse( e, buff, bs, ret)) { |
1146 | intfa.addXline(e); |
1147 | } |
1148 | break; } |
1149 | case 101: { |
1150 | DRW_Image e; |
1151 | if (entryParse( e, buff, bs, ret)) { |
1152 | intfa.addImage(&e); |
1153 | } |
1154 | break; } |
1155 | |
1156 | default: |
1157 | //not supported or are object add to remaining map |
1158 | objObjectMap[obj.handle]= obj; |
1159 | break; |
1160 | } |
1161 | if (!ret){ |
1162 | DRW_DBG("Warning: Entity type ")DRW_dbg::getInstance()->print("Warning: Entity type "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("has failed, handle: ")DRW_dbg::getInstance()->print("has failed, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1163 | } |
1164 | |
1165 | return ret; |
1166 | } |
1167 | |
1168 | bool dwgReader::readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf){ |
1169 | bool ret = true; |
1170 | |
1171 | duint32 i=0; |
1172 | DRW_DBG("\nentities map total size= ")DRW_dbg::getInstance()->print("\nentities map total size= " ); DRW_DBG(ObjectMap.size())DRW_dbg::getInstance()->print(ObjectMap.size()); |
1173 | DRW_DBG("\nobjects map total size= ")DRW_dbg::getInstance()->print("\nobjects map total size= " ); DRW_DBG(objObjectMap.size())DRW_dbg::getInstance()->print(objObjectMap.size()); |
1174 | auto itB=objObjectMap.begin(); |
1175 | auto itE=objObjectMap.end(); |
1176 | while (itB != itE){ |
1177 | if (ret) { |
1178 | // once readDwgObject() failed, just clear the ObjectMap |
1179 | ret = readDwgObject(dbuf, itB->second, intfa); |
1180 | } |
1181 | objObjectMap.erase(itB); |
1182 | itB=objObjectMap.begin(); |
1183 | } |
1184 | if (DRW_DBGGLDRW_dbg::getInstance()->getLevel() == DRW_dbg::Level::Debug) { |
1185 | for (auto it=remainingMap.begin(); it != remainingMap.end(); ++it){ |
1186 | DRW_DBG("\nnum.# ")DRW_dbg::getInstance()->print("\nnum.# "); DRW_DBG(i++)DRW_dbg::getInstance()->print(i++); DRW_DBG(" Remaining object Handle, loc, type= ")DRW_dbg::getInstance()->print(" Remaining object Handle, loc, type= " ); DRW_DBG(it->first)DRW_dbg::getInstance()->print(it->first); |
1187 | DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(it->second.loc)DRW_dbg::getInstance()->print(it->second.loc); DRW_DBG(" ")DRW_dbg::getInstance()->print(" "); DRW_DBG(it->second.type)DRW_dbg::getInstance()->print(it->second.type); |
1188 | } |
1189 | DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1190 | } |
1191 | return ret; |
1192 | } |
1193 | |
1194 | /** |
1195 | * Reads a dwg drawing object (dwg object object) given its offset in the file |
1196 | */ |
1197 | bool dwgReader::readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa){ |
1198 | bool ret = true; |
1199 | duint32 bs = 0; |
1200 | |
1201 | dbuf->setPosition(obj.loc); |
1202 | //verify if position is ok: |
1203 | if (!dbuf->isGood()){ |
1204 | DRW_DBG(" Warning: readDwgObject, bad location\n")DRW_dbg::getInstance()->print(" Warning: readDwgObject, bad location\n" ); |
1205 | return false; |
1206 | } |
1207 | int size = dbuf->getModularShort(); |
1208 | if (version > DRW::AC1021) {//2010+ |
1209 | bs = dbuf->getUModularChar(); |
1210 | } |
1211 | duint8 *tmpByteStr = new duint8[size]; |
1212 | dbuf->getBytes(tmpByteStr, size); |
1213 | //verify if getBytes is ok: |
1214 | if (!dbuf->isGood()){ |
1215 | DRW_DBG(" Warning: readDwgObject, bad size\n")DRW_dbg::getInstance()->print(" Warning: readDwgObject, bad size\n" ); |
1216 | delete[]tmpByteStr; |
1217 | return false; |
1218 | } |
1219 | dwgBuffer buff(tmpByteStr, size, &decoder); |
1220 | //oType are set parsing entities |
1221 | dint16 oType = obj.type; |
1222 | |
1223 | switch (oType){ |
1224 | case 102: { |
1225 | DRW_ImageDef e; |
1226 | ret = e.parseDwg(version, &buff, bs); |
1227 | intfa.linkImage(&e); |
1228 | break; } |
1229 | default: |
1230 | //not supported object or entity add to remaining map for debug |
1231 | remainingMap[obj.handle]= obj; |
1232 | break; |
1233 | } |
1234 | if (!ret){ |
1235 | DRW_DBG("Warning: Object type ")DRW_dbg::getInstance()->print("Warning: Object type "); DRW_DBG(oType)DRW_dbg::getInstance()->print(oType);DRW_DBG("has failed, handle: ")DRW_dbg::getInstance()->print("has failed, handle: "); DRW_DBG(obj.handle)DRW_dbg::getInstance()->print(obj.handle); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1236 | } |
1237 | delete[]tmpByteStr; |
1238 | return ret; |
1239 | } |
1240 | |
1241 | |
1242 | |
1243 | bool DRW_ObjControl::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ |
1244 | int unkData=0; |
1245 | bool ret = DRW_TableEntry::parseDwg(version, buf, nullptr, bs); |
1246 | DRW_DBG("\n***************************** parsing object control entry *********************************************\n")DRW_dbg::getInstance()->print("\n***************************** parsing object control entry *********************************************\n" ); |
1247 | if (!ret) |
1248 | return ret; |
1249 | //last parsed is: XDic Missing Flag 2004+ |
1250 | int numEntries = buf->getBitLong(); |
1251 | DRW_DBG(" num entries: ")DRW_dbg::getInstance()->print(" num entries: "); DRW_DBG(numEntries)DRW_dbg::getInstance()->print(numEntries); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1252 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1253 | |
1254 | // if (oType == 68 && version== DRW::AC1015){//V2000 dimstyle seems have one unknown byte hard handle counter?? |
1255 | if (oType == 68 && version > DRW::AC1014){//dimstyle seems have one unknown byte hard handle counter?? |
1256 | unkData = buf->getRawChar8(); |
1257 | DRW_DBG(" unknown v2000 byte: ")DRW_dbg::getInstance()->print(" unknown v2000 byte: "); DRW_DBG( unkData)DRW_dbg::getInstance()->print(unkData); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1258 | } |
1259 | if (version > DRW::AC1018){//from v2007+ have a bit for strings follows (ObjControl do not have) |
1260 | int stringBit = buf->getBit(); |
1261 | DRW_DBG(" string bit for v2007+: ")DRW_dbg::getInstance()->print(" string bit for v2007+: "); DRW_DBG( stringBit)DRW_dbg::getInstance()->print(stringBit); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1262 | } |
1263 | |
1264 | dwgHandle objectH = buf->getHandle(); |
1265 | DRW_DBG(" NULL Handle: ")DRW_dbg::getInstance()->print(" NULL Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1266 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1267 | |
1268 | // if (oType == 56 && version== DRW::AC1015){//linetype in 2004 seems not have XDicObjH or NULL handle |
1269 | if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle |
1270 | dwgHandle XDicObjH = buf->getHandle(); |
1271 | DRW_DBG(" XDicObj control Handle: ")DRW_dbg::getInstance()->print(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref)DRW_dbg::getInstance()->printHL(XDicObjH.code, XDicObjH.size ,XDicObjH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1272 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1273 | } |
1274 | //add 2 for modelspace, paperspace blocks & bylayer, byblock linetypes |
1275 | numEntries = ((oType == 48) || (oType == 56)) ? (numEntries +2) : numEntries; |
1276 | |
1277 | for (int i =0; i< numEntries; i++){ |
1278 | objectH = buf->getOffsetHandle(handle); |
1279 | if (objectH.ref != 0) //in vports R14 I found some NULL handles |
1280 | handlesList.push_back (objectH.ref); |
1281 | DRW_DBG(" objectH Handle: ")DRW_dbg::getInstance()->print(" objectH Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1282 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1283 | } |
1284 | |
1285 | for (int i =0; i< unkData; i++){ |
1286 | objectH = buf->getOffsetHandle(handle); |
1287 | DRW_DBG(" unknown Handle: ")DRW_dbg::getInstance()->print(" unknown Handle: "); DRW_DBGHL(objectH.code, objectH.size, objectH.ref)DRW_dbg::getInstance()->printHL(objectH.code, objectH.size ,objectH.ref); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1288 | DRW_DBG("Remaining bytes: ")DRW_dbg::getInstance()->print("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes())DRW_dbg::getInstance()->print(buf->numRemainingBytes()); DRW_DBG("\n")DRW_dbg::getInstance()->print("\n"); |
1289 | } |
1290 | return buf->isGood(); |
1291 | } |
1292 |