File: | 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 |