Revision 28969

View differences:

branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/readers/DwgFileV15Reader.java
1
/* jdwglib. Java Library for reading Dwg files.
2
 *
3
 * Author: Jose Morell Rama (jose.morell@gmail.com).
4
 * Port from the Pythoncad Dwg library by Art Haas.
5
 *
6
 * Copyright (C) 2005 Jose Morell, IVER TI S.A. and Generalitat Valenciana
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 * Jose Morell (jose.morell@gmail.com)
25
 *
26
 * or
27
 *
28
 * IVER TI S.A.
29
 *  C/Salamanca, 50
30
 *  46005 Valencia
31
 *  Spain
32
 *  +34 963163400
33
 *  dac@iver.es
34
 */
35
package org.gvsig.dwg.lib.readers;
36

  
37
import java.io.IOException;
38
import java.nio.ByteBuffer;
39
import java.nio.ByteOrder;
40
import java.util.ArrayList;
41
import java.util.List;
42

  
43
import org.gvsig.dwg.lib.ByteUtils;
44
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
45
import org.gvsig.dwg.lib.DwgClass;
46
import org.gvsig.dwg.lib.DwgFile;
47
import org.gvsig.dwg.lib.DwgHandleReference;
48
import org.gvsig.dwg.lib.DwgObject;
49
import org.gvsig.dwg.lib.DwgObjectFactory;
50
import org.gvsig.dwg.lib.DwgObjectOffset;
51
import org.gvsig.dwg.lib.DwgUtil;
52
import org.gvsig.dwg.lib.util.HexUtil;
53
import org.slf4j.Logger;
54
import org.slf4j.LoggerFactory;
55

  
56

  
57

  
58
/**
59
 * The DwgFileV15Reader reads the DWG version 15 format
60
 *
61
 * @author jmorell
62
 */
63
public class DwgFileV15Reader implements IDwgFileReader {
64
	protected DwgFile dwgFile;
65

  
66
	protected ByteBuffer bb;
67
	
68
	private static Logger logger = LoggerFactory.getLogger(DwgFileV15Reader.class
69
			.getName());
70
	
71

  
72

  
73
	/**
74
	 * Reads the DWG version 15 format
75
	 *
76
	 * @param dwgFile
77
	 *            Represents the DWG file that we want to read
78
	 * @throws IOException
79
	 *             When DWG file path is wrong
80
	 */
81
	public void read(DwgFile dwgFile, ByteBuffer bb) throws IOException {
82
		this.dwgFile = dwgFile;
83
		this.bb = bb;
84
		try {
85
			readDwgSectionOffsets();
86
			readHeaders();
87
			readDwgClasses();
88
			readDwgObjectOffsets();
89
			readDwgObjects();
90
			//checkSuperentities();
91
		} catch (Exception e) {
92
			e.printStackTrace();
93
			logger.error(e.getMessage());
94
		}
95

  
96
	}
97

  
98
	/*
99
	 *TODO: Eliminar esto cuando terminemos con el testeo
100
	 */
101
	protected void checkSuperentities(){
102
		logger.info("***** CHEQUEANDO LAS SUPERENTIDADES *****");
103
		List objects = dwgFile.getDwgObjects();
104
		DwgObject obj;
105
		DwgObject superEnt;
106
		boolean buscado=false;
107
		boolean perdidos=false;
108
		int j=0;
109
		for (int i=0; i<objects.size(); i++){
110
			obj = (DwgObject)objects.get(i);
111
			if (obj.hasSubEntityHandle()){
112
				buscado = true;
113
				superEnt = dwgFile.getDwgSuperEntity(obj);
114
				if (superEnt == null){
115
					j++;
116
				}
117
			}
118
		}
119
		if(j!=0) {
120
			logger.warn("+++++ SE HAN PERDIDO LAS SUPERENTIDADES DE "+ j+" OBJETOS +++++");
121
		}
122
		logger.info("***** FIN DEL CHEQUEO DE LAS SUPERENTIDADES *****");
123

  
124
	}
125

  
126

  
127
	/**
128
	 * It read the SECTIONS from the header of the DWG file
129
	 */
130
	protected void readDwgSectionOffsets() {
131
		bb.position(19);
132
		bb.order(ByteOrder.LITTLE_ENDIAN);
133
		short codePage = bb.getShort();
134
		int count = bb.getInt();
135
		for (int i = 0; i < count; i++) {
136
			byte rec = bb.get();
137
			int seek = bb.getInt();
138
			int size = bb.getInt();
139
			if (rec == 0) {
140
				dwgFile.addDwgSectionOffset("HEADERS", seek, size);
141
			} else if (rec == 1) {
142
				dwgFile.addDwgSectionOffset("CLASSES", seek, size);
143
			} else if (rec == 2) {
144
				dwgFile.addDwgSectionOffset("OBJECTS", seek, size);
145
			} else if (rec == 3) {
146
				dwgFile.addDwgSectionOffset("UNKNOWN", seek, size);
147
			} else if (rec == 4) {
148
				dwgFile.addDwgSectionOffset("R14DATA", seek, size);
149
			} else if (rec == 5) {
150
				dwgFile.addDwgSectionOffset("R14REC5", seek, size);
151
			} else {
152
				//				System.out.println("ERROR: C�digo de n�mero de registro
153
				// no soportado: " + rec);
154
			}
155
		}
156
	}
157

  
158
	/**
159
	 * OpenDWG spec says: This section -object map- is a table which gives the
160
	 * location of each object in the DWG file. This table is broken into
161
	 * sections. It is basically a list of handle/file loc pairs. It could be
162
	 * readed with this pseudocode:
163
	 *
164
	 * Set lastHandle to all 0 and last loc to 0L. Repeat until section size ==
165
	 * 2 section size = read short (in bigendian order) Repeat until out of data
166
	 * for this section offset of this handle form last handle as modular char
167
	 * offset of location in file from last location as modular char End repeat
168
	 * End repeat
169
	 *
170
	 */
171
	protected void readDwgObjectOffsets() throws Exception {
172
		int offset = dwgFile.getDwgSectionOffset("OBJECTS");
173
		bb.position(offset);
174
		while (true) {
175
			bb.order(ByteOrder.BIG_ENDIAN);
176
			/*
177
			 * We read the size of the next section. If size == 2, break (it is
178
			 * the last empty -except crc- section)
179
			 */
180
			short size = bb.getShort();
181
			if (size == 2)
182
				break;
183
			bb.order(ByteOrder.LITTLE_ENDIAN);
184
			byte[] dataBytes = new byte[size];
185
			bb.get(dataBytes);
186
			int[] data = DwgUtil.bytesToMachineBytes(dataBytes);
187
			int lastHandle = 0;
188
			int lastLoc = 0;
189
			int bitPos = 0;
190
			int bitMax = (size - 2) * 8;
191
			while (bitPos < bitMax) {
192
				ArrayList v = DwgUtil.getModularChar(data, bitPos);
193
				bitPos = ((Integer) v.get(0)).intValue();
194
				lastHandle = lastHandle + ((Integer) v.get(1)).intValue();
195
				v = DwgUtil.getModularChar(data, bitPos);
196
				bitPos = ((Integer) v.get(0)).intValue();
197
				lastLoc = lastLoc + ((Integer) v.get(1)).intValue();
198
				dwgFile.addDwgObjectOffset(lastHandle, lastLoc);
199
			}//while
200
		}//while
201
	}
202

  
203

  
204
	protected void readDwgClasses() throws Exception {
205
		int offset = dwgFile.getDwgSectionOffset("CLASSES");
206
		bb.position(offset);
207
		//1� leemos el sentinnel inicial
208
		bb.order(ByteOrder.nativeOrder());
209
		byte[] sentinel = new byte[16];
210
		bb.get(sentinel);
211
		if (sentinel[0] != 0x8d)
212
			logger.warn("sentinel[0] != 0x8d");
213
		if (sentinel[1] != 0xa1)
214
			logger.warn("sentinel[1] != 0xa1");
215
		if (sentinel[2] != 0xc4)
216
			logger.warn("sentinel[2] != 0xc4");
217
		if (sentinel[3] != 0xb8)
218
			logger.warn("sentinel[3] != 0xb8");
219
		if (sentinel[4] != 0xc4)
220
			logger.warn("sentinel[4] != 0xc4");
221
		if (sentinel[5] != 0xa9)
222
			logger.warn("sentinel[5] != 0xa9");
223
		if (sentinel[6] != 0xf8)
224
			logger.warn("sentinel[6] != 0xf8");
225
		if (sentinel[7] != 0xc5)
226
			logger.warn("sentinel[7] != 0xc5");
227
		if (sentinel[8] != 0xc0)
228
			logger.warn("sentinel[8] != 0xc0");
229
		if (sentinel[9] != 0xdc)
230
			logger.warn("sentinel[9] != 0xdc");
231
		if (sentinel[10] != 0xf4)
232
			logger.warn("sentinel[10] != 0xf4");
233
		if (sentinel[11] != 0x5f)
234
			logger.warn("sentinel[11] != 0x5f");
235
		if (sentinel[12] != 0xe7)
236
			logger.warn("sentinel[12] != 0xe7");
237
		if (sentinel[13] != 0xcf)
238
			logger.warn("sentinel[13] != 0xcf");
239
		if (sentinel[14] != 0xb6)
240
			logger.warn("sentinel[14] != 0xb6");
241
		if (sentinel[15] != 0x8a)
242
			logger.warn("sentinel[15] != 0x8a");
243

  
244
		bb.order(ByteOrder.LITTLE_ENDIAN);
245
		int size = bb.getInt();
246
		byte[] data = new byte[size];
247
		bb.get(data);
248
		int[] intData = DwgUtil.toIntArray(data);
249
		short crc = bb.getShort();
250

  
251
		int maxBit = size * 8;
252
		int bitPos = 0;
253
		List val = null;
254
		while ((bitPos + 8) < maxBit) {
255
			val = DwgUtil.getBitShort(intData, bitPos);
256
			bitPos = ((Integer) val.get(0)).intValue();
257
			int classNum = ((Integer) val.get(1)).intValue();
258

  
259
			val = DwgUtil.getBitShort(intData, bitPos);
260
			bitPos = ((Integer) val.get(0)).intValue();
261
			int version = ((Integer) val.get(1)).intValue();
262

  
263
			val = DwgUtil.getTextString(intData, bitPos);
264
			bitPos = ((Integer) val.get(0)).intValue();
265
			String appName = (String) val.get(1);
266

  
267
			val = DwgUtil.getTextString(intData, bitPos);
268
			bitPos = ((Integer) val.get(0)).intValue();
269
			String cPlusPlusName = (String) val.get(1);
270

  
271
			val = DwgUtil.getTextString(intData, bitPos);
272
			bitPos = ((Integer) val.get(0)).intValue();
273
			String dxfName = (String) val.get(1);
274

  
275
			val = DwgUtil.testBit(intData, bitPos);
276
			bitPos = ((Integer) val.get(0)).intValue();
277
			boolean isZombie = ((Boolean) val.get(1)).booleanValue();
278

  
279
			val = DwgUtil.getBitShort(intData, bitPos);
280
			bitPos = ((Integer) val.get(0)).intValue();
281
			int id = ((Integer) val.get(1)).intValue();
282

  
283
			DwgClass dwgClass = new DwgClass(classNum, version, appName,
284
					cPlusPlusName, dxfName, isZombie, id);
285
			dwgFile.addDwgClass(dwgClass);
286

  
287
		}//while
288
		//		Por ultimo, el sentinnel final
289
		bb.order(ByteOrder.nativeOrder());
290
		byte[] lastSentinnel = new byte[16];
291
		bb.get(lastSentinnel);
292
		if (lastSentinnel[0] != 0x72)
293
			logger.warn("lastSentinnel[0] != 0x72");
294
		if (lastSentinnel[1] != 0x5e)
295
			logger.warn("lastSentinnel[1] != 0x5e");
296
		if (lastSentinnel[2] != 0x3b)
297
			logger.warn("lastSentinnel[2] != 0x3b");
298
		if (lastSentinnel[3] != 0x47)
299
			logger.warn("lastSentinnel[3] != 0x47");
300
		if (lastSentinnel[4] != 0x3b)
301
			logger.warn("lastSentinnel[4] != 0x3b");
302
		if (lastSentinnel[5] != 0x56)
303
			logger.warn("lastSentinnel[5] != 0x56");
304
		if (lastSentinnel[6] != 0x07)
305
			logger.warn("lastSentinnel[6] != 0x07");
306
		if (lastSentinnel[7] != 0x3a)
307
			logger.warn("lastSentinnel[7] != 0x3a");
308
		if (lastSentinnel[8] != 0x3f)
309
			logger.warn("lastSentinnel[8] != 0x3f");
310
		if (lastSentinnel[9] != 0x23)
311
			logger.warn("lastSentinnel[9] != 0x23");
312
		if (lastSentinnel[10] != 0x0b)
313
			logger.warn("lastSentinnel[10] != 0x0b");
314
		if (lastSentinnel[11] != 0xa0)
315
			logger.warn("lastSentinnel[11] != 0xa0");
316
		if (lastSentinnel[12] != 0x18)
317
			logger.warn("lastSentinnel[12] != 0x18");
318
		if (lastSentinnel[13] != 0x30)
319
			logger.warn("lastSentinnel[13] != 0x30");
320
		if (lastSentinnel[14] != 0x49)
321
			logger.warn("lastSentinnel[14] != 0x49");
322
		if (lastSentinnel[15] != 0x75)
323
			logger.warn("lastSentinnel[15] != 0x75");
324
	}
325

  
326
	protected void readDwgClasses2() throws Exception {
327
		int offset = dwgFile.getDwgSectionOffset("CLASSES");
328
		// Por ahora nos saltamos los 16 bytes de control
329
		bb.position(offset + 16);
330
		bb.order(ByteOrder.LITTLE_ENDIAN);
331
		int size = bb.getInt();
332
		byte[] dataBytes = new byte[size];
333
		for (int i = 0; i < dataBytes.length; i++) {
334
			dataBytes[i] = bb.get();
335
		}
336
		int[] data = DwgUtil.bytesToMachineBytes(dataBytes);
337
		for (int i = 0; i < data.length; i++) {
338
			data[i] = (byte) ByteUtils.getUnsigned((byte) data[i]);
339
		}
340
		bb.position(bb.position() + 2 + 16);
341
		int maxbit = size * 8;
342
		int bitPos = 0;
343
		while ((bitPos + 8) < maxbit) {
344
			ArrayList v = DwgUtil.getBitShort(data, bitPos);
345
			bitPos = ((Integer) v.get(0)).intValue();
346
			v = DwgUtil.getBitShort(data, bitPos);
347
			bitPos = ((Integer) v.get(0)).intValue();
348
			v = DwgUtil.getTextString(data, bitPos);
349
			bitPos = ((Integer) v.get(0)).intValue();
350
			v = DwgUtil.getTextString(data, bitPos);
351
			bitPos = ((Integer) v.get(0)).intValue();
352
			v = DwgUtil.getTextString(data, bitPos);
353
			bitPos = ((Integer) v.get(0)).intValue();
354
			v = DwgUtil.testBit(data, bitPos);
355
			bitPos = ((Integer) v.get(0)).intValue();
356
			v = DwgUtil.getBitShort(data, bitPos);
357
			bitPos = ((Integer) v.get(0)).intValue();
358
		}
359
	}
360

  
361
	/**
362
	 * Reads all the object referenced in the object map section of the DWG file
363
	 * (using their object file obsets)
364
	 */
365
	protected void readDwgObjects() {
366
		for (int i = 0; i < dwgFile.getDwgObjectOffsets().size(); i++) {
367
				 try{
368
					DwgObjectOffset doo = (DwgObjectOffset) dwgFile
369
							.getDwgObjectOffsets().get(i);
370

  
371
					DwgObject obj = readDwgObject(doo.getOffset(), i);
372
					/*
373
					 * azabala: las entidades DWG no implementadas no nos aportan nada
374
					 * (aunque la sigo leyendo por si aparecen problemas de puntero de
375
					 * fichero) No considero por tanto los DwgObject if (obj != null) {
376
					 * dwgFile.addDwgObject(obj); }
377
					 *
378
					 * paco: propongo reconsiderar esto. Si no cargamos todos los objetos
379
					 * podemos tener problemas con las subentities.
380
					 */
381
					if (obj != null && obj.getClass() != DwgObject.class) {
382
						dwgFile.addDwgObject(obj);
383
					}
384
				}catch(Exception e){
385
					logger.error(e.getMessage());
386
					continue;
387
				}
388
			}//for
389

  
390
	}
391

  
392

  
393

  
394
	/**
395
	 * Reads the header of an object in a DWG file Version 15
396
	 *
397
	 * @param data
398
	 *            Array of unsigned bytes obtained from the DWG binary file
399
	 * @param offset
400
	 *            The current bit offset where the value begins
401
	 * @return int New offset
402
	 */
403
	public int readObjectHeader(int[] data, int offset, DwgObject dwgObject) {
404
		int bitPos = offset;
405
		Integer mode = (Integer) DwgUtil.getBits(data, 2, bitPos);
406
		bitPos = bitPos + 2;
407
		dwgObject.setMode(mode.intValue());
408

  
409
		/*
410
		ArrayList v = DwgUtil.getBitLong(data, bitPos);
411
		bitPos = ((Integer) v.get(0)).intValue();
412
		int rnum = ((Integer) v.get(1)).intValue();
413
		dwgObject.setNumReactors(rnum);
414
		*/
415
		ArrayList v = DwgUtil.getBitShort(data, bitPos);
416
		bitPos = ((Integer) v.get(0)).intValue();
417
		int rnum = ((Integer) v.get(1)).intValue();
418
		dwgObject.setNumReactors(rnum);
419

  
420
		v = DwgUtil.testBit(data, bitPos);
421
		bitPos = ((Integer) v.get(0)).intValue();
422
		boolean nolinks = ((Boolean) v.get(1)).booleanValue();
423
		dwgObject.setNoLinks(nolinks);
424

  
425
		v = DwgUtil.getBitShort(data, bitPos);
426
		bitPos = ((Integer) v.get(0)).intValue();
427
		int color = ((Integer) v.get(1)).intValue();
428
		dwgObject.setColor(color);
429

  
430
		v = DwgUtil.getBitDouble(data, bitPos);
431
		bitPos = ((Integer) v.get(0)).intValue();
432
		float ltscale = ((Double) v.get(1)).floatValue();
433

  
434
		Integer ltflag = (Integer) DwgUtil.getBits(data, 2, bitPos);
435
		bitPos = bitPos + 2;
436

  
437
		Integer psflag = (Integer) DwgUtil.getBits(data, 2, bitPos);
438
		bitPos = bitPos + 2;
439

  
440
		v = DwgUtil.getBitShort(data, bitPos);
441
		bitPos = ((Integer) v.get(0)).intValue();
442
		int invis = ((Integer) v.get(1)).intValue();
443

  
444
		v = DwgUtil.getRawChar(data, bitPos);
445
		bitPos = ((Integer) v.get(0)).intValue();
446
		int weight = ((Integer) v.get(1)).intValue();
447

  
448
		return bitPos;
449
	}
450

  
451
	/**
452
	 * Reads the tail of an object in a DWG file Version 15
453
	 *
454
	 * @param data
455
	 *            Array of bytes obtained from the DWG binary file
456
	 * @param offset
457
	 *            Offset for this array of bytes
458
	 * @return int New offset
459
	 * @throws CorruptedDwgEntityException
460
	 * @throws RuntimeException
461
	 */
462
	public int readObjectTailer(int[] data, int offset, DwgObject dwgObject) throws RuntimeException, CorruptedDwgEntityException {
463
		int bitPos = offset;
464
		/*
465
		 * Subentity ref handle. Esto se aplica sobre VERTEX, ATTRIB, SEQEND
466
		 */
467
		if (dwgObject.getMode() == 0x0) {
468
			DwgHandleReference subEntityHandle = new DwgHandleReference();
469
			bitPos = subEntityHandle.read(data, bitPos);
470
			dwgObject.setSubEntityHandle(subEntityHandle);
471
		}
472

  
473
		/*
474
		 * Reactors handles TODO No se est�n usando para setear nada en
475
		 * DwgObject
476
		 */
477
		DwgHandleReference reactorHandle;
478
		for (int i = 0; i < dwgObject.getNumReactors(); i++) {
479
			reactorHandle = new DwgHandleReference();
480
			bitPos = reactorHandle.read(data, bitPos);
481
			dwgObject.addReactorHandle(reactorHandle);
482
		}
483

  
484
		/*
485
		 * XDICOBJHANDLE
486
		 */
487
		DwgHandleReference xDicObjHandle = new DwgHandleReference();
488
		bitPos = xDicObjHandle.read(data, bitPos);
489
		dwgObject.setXDicObjHandle(xDicObjHandle);
490

  
491
		/*
492
		 * Layer Handle code
493
		 */
494

  
495
		DwgHandleReference handle = new DwgHandleReference();
496
		bitPos = handle.read(data, bitPos);
497
		dwgObject.setLayerHandle(handle);
498

  
499
		if (!dwgObject.isNoLinks()) {
500

  
501
			DwgHandleReference previousHandle = new DwgHandleReference();
502
			bitPos = previousHandle.read(data, bitPos);
503
			dwgObject.setPreviousHandle(previousHandle);
504

  
505
			DwgHandleReference nextHandle = new DwgHandleReference();
506
			bitPos = nextHandle.read(data, bitPos);
507
			dwgObject.setNextHandle(nextHandle);
508

  
509
		}
510

  
511
		if (dwgObject.getLinetypeFlags() == 0x3) {
512
			DwgHandleReference lineTypeHandle = new DwgHandleReference();
513
			bitPos = lineTypeHandle.read(data, bitPos);
514
			dwgObject.setLineTypeHandle(lineTypeHandle);
515

  
516
		}
517

  
518
		if (dwgObject.getPlotstyleFlags() == 0x3) {
519
			DwgHandleReference plotStyleHandle = new DwgHandleReference();
520
			bitPos = plotStyleHandle.read(data, bitPos);
521
			dwgObject.setPlotStyleHandle(plotStyleHandle);
522

  
523
		}
524
		return bitPos;
525
	}
526

  
527
	/**
528
	 * Return a dwg object from its index in the dwg file
529
	 *
530
	 * @param index
531
	 *            of the requested dwg object in the dwg file
532
	 *
533
	 */
534
	public DwgObject getDwgObjectByIndex(int index) {
535
		DwgObjectOffset doo = (DwgObjectOffset) dwgFile.getDwgObjectOffsets()
536
				.get(index);
537
		return readDwgObject(doo.getOffset(), index);
538
	}
539

  
540

  
541
	/**
542
	 * Reads a dwg drawing entity (dwg object) given its offset in the file
543
	 */
544

  
545
	protected DwgObject readDwgObject(int offset, int index) {
546
		DwgObject obj = null;
547
		try {
548
			bb.position(offset);
549
			int size = DwgUtil.getModularShort(bb);
550

  
551
			bb.order(ByteOrder.LITTLE_ENDIAN);
552
			byte[] dataBytes = new byte[size];
553
			String[] dataMachValString = new String[size];
554
			int[] data = new int[size];
555
			for (int i = 0; i < size; i++) {
556
				dataBytes[i] = bb.get();
557
				dataMachValString[i] = HexUtil
558
						.bytesToHex(new byte[] { dataBytes[i] });
559
				Integer dataMachValShort = Integer.decode("0x"
560
						+ dataMachValString[i]);
561
				data[i] = dataMachValShort.byteValue();
562
				data[i] = ByteUtils.getUnsigned((byte) data[i]);
563
			}
564

  
565
			int bitPos = 0;
566
			ArrayList v = DwgUtil.getBitShort(data, bitPos);
567
			bitPos = ((Integer) v.get(0)).intValue();
568
			int type = ((Integer) v.get(1)).intValue();
569
			obj = DwgObjectFactory.getInstance().create(type, index);
570
			if (obj == null) {
571
				if (type >= 500) {
572
					int newIndex = type - 500;
573
					if (newIndex < (dwgFile.getDwgClasses().size() - 1)) {
574
						DwgClass dwgClass = (DwgClass) dwgFile.getDwgClasses()
575
								.get(newIndex);
576
						String dxfEntityName = dwgClass.getDxfName();
577
						obj = DwgObjectFactory.getInstance().create(
578
								dxfEntityName, index);
579
						if (obj == null) {
580
							logger.info(dxfEntityName
581
									+ " todavia no est� implementado");
582
							return null;
583
						}//if
584
					}//if newIndex
585
					else{
586
						return null;
587
					}
588
				}else {
589
					logger.info("Encontrado tipo " + type);
590
					return null;
591
				}
592
			}//if obj == null
593

  
594

  
595
			v = DwgUtil.getRawLong(data, bitPos);
596
			bitPos = ((Integer) v.get(0)).intValue();
597
			int objBSize = ((Integer) v.get(1)).intValue();
598
			obj.setSizeInBits(objBSize);
599

  
600
			DwgHandleReference entityHandle = new DwgHandleReference();
601
			bitPos = entityHandle.read(data, bitPos);
602
			obj.setHandle(entityHandle);
603

  
604
			v = DwgUtil.readExtendedData(data, bitPos);
605
			bitPos = ((Integer) v.get(0)).intValue();
606
			ArrayList extData = (ArrayList) v.get(1);
607
			obj.setExtendedData(extData);
608

  
609
			boolean gflag = false;
610
			gflag = obj.isGraphicsFlag();
611
			if (gflag) {
612
				//lee un flag boolean
613
				v = DwgUtil.testBit(data, bitPos);
614
				bitPos = ((Integer) v.get(0)).intValue();
615
				boolean val = ((Boolean) v.get(1)).booleanValue();
616
				//si hay imagen asociada, se lee por completo
617
				if (val) {
618
					v = DwgUtil.getRawLong(data, bitPos);
619
					bitPos = ((Integer) v.get(0)).intValue();
620
					size = ((Integer) v.get(1)).intValue();
621
					int bgSize = size * 8;
622
					Integer giData = (Integer) DwgUtil.getBits(data, bgSize,
623
							bitPos);
624
					obj.setGraphicData(giData.intValue());
625
					bitPos = bitPos + bgSize;
626
				}
627
			}
628
				if(obj.getClass() != DwgObject.class)
629
					readSpecificObject(obj, data, bitPos);
630
		} catch (RuntimeException e) {
631
			e.printStackTrace();
632
		} catch (CorruptedDwgEntityException e) {
633
			// TODO Auto-generated catch block
634
			e.printStackTrace();
635
			return null;
636
		}
637
		return obj;
638
	}
639

  
640
	/*
641
	 * TODO Esto está pesimamente diseñado. Cada objeto DwgObject debe tener un
642
	 * metodo readSpecificObject(data,bitPos)
643
	 *
644
	 */
645
	protected void readSpecificObject(DwgObject obj, int[] data, int bitPos)
646
			throws RuntimeException, CorruptedDwgEntityException {
647
			DwgObjectReaderPool pool = DwgObjectReaderPool.getInstance();
648
			IDwgObjectReader reader = pool.get(obj, "15");
649
			if(reader != null){
650
				reader.setFileReader(this);
651
				reader.readSpecificObj(data, bitPos, obj);
652
			}else{
653
				logger.warn("No se ha implementado la lectura de "+obj.getClass().getName()+", code="+obj.getType());
654
			}
655
	}
656

  
657

  
658
	//TODO PROBAR, ESTA COPIADO A PELO DE DWG13-14. SI VALE, LLEVAR A UNA
659
	//CLASE ABSTRACTA
660
	protected void readHeaders() {
661

  
662
		int offset = dwgFile.getDwgSectionOffset("HEADERS");
663
		bb.position(offset);
664

  
665
		//1� leemos el sentinnel inicial
666
		bb.order(ByteOrder.nativeOrder());
667
		byte[] sentinel = new byte[16];
668
		bb.get(sentinel);
669

  
670
		if (sentinel[0] != 0xcf)
671
			logger.warn("sentinel[0] != 0xcf");
672
		if (sentinel[1] != 0x7b)
673
			logger.warn("sentinel[1] != 0x7b");
674
		if (sentinel[2] != 0x1f)
675
			logger.warn("sentinel[2] != 0x1f");
676
		if (sentinel[3] != 0x23)
677
			logger.warn("sentinel[3] != 0x23");
678
		if (sentinel[4] != 0xfd)
679
			logger.warn("sentinel[4] != 0xfd");
680
		if (sentinel[5] != 0xde)
681
			logger.warn("sentinel[5] != 0xde");
682
		if (sentinel[6] != 0x38)
683
			logger.warn("sentinel[6] != 0x38");
684
		if (sentinel[7] != 0xa9)
685
			logger.warn("sentinel[7] != 0xa9");
686
		if (sentinel[8] != 0x5f)
687
			logger.warn("sentinel[8] != 0x5f");
688
		if (sentinel[9] != 0x7c)
689
			logger.warn("sentinel[9] != 0x7c");
690
		if (sentinel[10] != 0x68)
691
			logger.warn("sentinel[10] != 0x68");
692
		if (sentinel[11] != 0xb8)
693
			logger.warn("sentinel[11] != 0xb8");
694
		if (sentinel[12] != 0x4e)
695
			logger.warn("sentinel[12] != 0x4e");
696
		if (sentinel[13] != 0x6d)
697
			logger.warn("sentinel[13] != 0x6d");
698
		if (sentinel[14] != 0x33)
699
			logger.warn("sentinel[14] != 0x33");
700
		if (sentinel[15] != 0x5f)
701
			logger.warn("sentinel[15] != 0x5f");
702

  
703
		//2� seguidamente leemos los datos
704
		bb.order(ByteOrder.LITTLE_ENDIAN);
705
		int size = bb.getInt();
706

  
707
		bb.order(ByteOrder.nativeOrder());
708
		byte[] data = new byte[size];
709
		bb.get(data);
710

  
711
		int[] intData = DwgUtil.toIntArray(data);
712

  
713
		//3� a continuacion el CRC de la seccion HEADER
714
		bb.order(ByteOrder.LITTLE_ENDIAN);
715
		short crc = bb.getShort();
716

  
717
		//Por ultimo, el sentinnel final
718
		bb.order(ByteOrder.nativeOrder());
719
		byte[] lastSentinnel = new byte[16];
720
		bb.get(lastSentinnel);
721
		if (lastSentinnel[0] != 0x30)
722
			logger.warn("lastSentinnel[0] != 0x30");
723
		if (lastSentinnel[1] != 0x84)
724
			logger.warn("lastSentinnel[1] != 0x84");
725
		if (lastSentinnel[2] != 0xe0)
726
			logger.warn("lastSentinnel[2] != 0xe0");
727
		if (lastSentinnel[3] != 0xdc)
728
			logger.warn("lastSentinnel[3] != 0xdc");
729
		if (lastSentinnel[4] != 0x02)
730
			logger.warn("lastSentinnel[4] != 0x02");
731
		if (lastSentinnel[5] != 0x21)
732
			logger.warn("lastSentinnel[5] != 0x21");
733
		if (lastSentinnel[6] != 0xc7)
734
			logger.warn("lastSentinnel[6] != 0xc7");
735
		if (lastSentinnel[7] != 0x56)
736
			logger.warn("lastSentinnel[7] != 0x56");
737
		if (lastSentinnel[8] != 0xa0)
738
			logger.warn("lastSentinnel[8] != 0xa0");
739
		if (lastSentinnel[9] != 0x83)
740
			logger.warn("lastSentinnel[9] != 0x83");
741
		if (lastSentinnel[10] != 0x97)
742
			logger.warn("lastSentinnel[10] != 0x97");
743
		if (lastSentinnel[11] != 0x47)
744
			logger.warn("lastSentinnel[11] != 0x47");
745
		if (lastSentinnel[12] != 0xb1)
746
			logger.warn("lastSentinnel[12] != 0xb1");
747
		if (lastSentinnel[13] != 0x92)
748
			logger.warn("lastSentinnel[13] != 0x92");
749
		if (lastSentinnel[14] != 0xcc)
750
			logger.warn("lastSentinnel[14] != 0xcc");
751
		if (lastSentinnel[15] != 0xa0)
752
			logger.warn("lastSentinnel[15] != 0xa0");
753

  
754
		//Ahora interpretamos los datos en bruto
755
		int bitPos = 0;
756
		try {
757
			List val = DwgUtil.getBitDouble(intData, bitPos);
758
			bitPos = ((Integer) val.get(0)).intValue();
759
			dwgFile.setHeader("VAL1", val.get(1));
760

  
761
			val = DwgUtil.getBitDouble(intData, bitPos);
762
			bitPos = ((Integer) val.get(0)).intValue();
763
			dwgFile.setHeader("VAL2", val.get(1));
764

  
765
			val = DwgUtil.getBitDouble(intData, bitPos);
766
			bitPos = ((Integer) val.get(0)).intValue();
767
			dwgFile.setHeader("VAL3", val.get(1));
768

  
769
			val = DwgUtil.getBitDouble(intData, bitPos);
770
			bitPos = ((Integer) val.get(0)).intValue();
771
			dwgFile.setHeader("VAL4", val.get(1));
772

  
773
			val = DwgUtil.getTextString(intData, bitPos);
774
			bitPos = ((Integer) val.get(0)).intValue();
775
			dwgFile.setHeader("STRING1", val.get(1));
776

  
777
			val = DwgUtil.getTextString(intData, bitPos);
778
			bitPos = ((Integer) val.get(0)).intValue();
779
			dwgFile.setHeader("STRING2", val.get(1));
780

  
781
			val = DwgUtil.getTextString(intData, bitPos);
782
			bitPos = ((Integer) val.get(0)).intValue();
783
			dwgFile.setHeader("STRING3", val.get(1));
784

  
785
			val = DwgUtil.getTextString(intData, bitPos);
786
			bitPos = ((Integer) val.get(0)).intValue();
787
			dwgFile.setHeader("STRING4", val.get(1));
788

  
789
			val = DwgUtil.getBitLong(intData, bitPos);
790
			bitPos = ((Integer) val.get(0)).intValue();
791
			dwgFile.setHeader("LONG1", val.get(1));
792

  
793
			val = DwgUtil.getBitLong(intData, bitPos);
794
			bitPos = ((Integer) val.get(0)).intValue();
795
			dwgFile.setHeader("LONG2", val.get(1));
796

  
797
//			val = DwgUtil.getBitShort(intData, bitPos);
798
//			bitPos = ((Integer) val.get(0)).intValue();
799
//			dwgFile.setHeader("SHORT1", val.get(1));
800

  
801
			//TODO REFACTORIZAR ESTO PARA USAR DWGHANDLEREFERENCE
802

  
803
			//TODO Los handle se leen asi??
804
			val = DwgUtil.getHandle(intData, bitPos);
805
			bitPos = ((Integer) val.get(0)).intValue();
806
			dwgFile.setHeader("HANDLE1", val.get(1));
807

  
808
			val = DwgUtil.testBit(intData, bitPos);
809
			bitPos = ((Integer) val.get(0)).intValue();
810
			dwgFile.setHeader("DIMASO", val.get(1));
811

  
812
			val = DwgUtil.testBit(intData, bitPos);
813
			bitPos = ((Integer) val.get(0)).intValue();
814
			dwgFile.setHeader("DIMSHO", val.get(1));
815

  
816
//			val = DwgUtil.testBit(intData, bitPos);
817
//			bitPos = ((Integer) val.get(0)).intValue();
818
//			dwgFile.setHeader("DIMSAV", val.get(1));
819

  
820
			val = DwgUtil.testBit(intData, bitPos);
821
			bitPos = ((Integer) val.get(0)).intValue();
822
			dwgFile.setHeader("PLINEGEN", val.get(1));
823

  
824
			val = DwgUtil.testBit(intData, bitPos);
825
			bitPos = ((Integer) val.get(0)).intValue();
826
			dwgFile.setHeader("ORTHOMODE", val.get(1));
827

  
828
			val = DwgUtil.testBit(intData, bitPos);
829
			bitPos = ((Integer) val.get(0)).intValue();
830
			dwgFile.setHeader("REGENMODE", val.get(1));
831

  
832
			val = DwgUtil.testBit(intData, bitPos);
833
			bitPos = ((Integer) val.get(0)).intValue();
834
			dwgFile.setHeader("FILLMODE", val.get(1));
835

  
836
			val = DwgUtil.testBit(intData, bitPos);
837
			bitPos = ((Integer) val.get(0)).intValue();
838
			dwgFile.setHeader("QTEXTMODE", val.get(1));
839

  
840
			val = DwgUtil.testBit(intData, bitPos);
841
			bitPos = ((Integer) val.get(0)).intValue();
842
			dwgFile.setHeader("PSLTSCALE", val.get(1));
843

  
844
			val = DwgUtil.testBit(intData, bitPos);
845
			bitPos = ((Integer) val.get(0)).intValue();
846
			dwgFile.setHeader("LIMCHECK", val.get(1));
847

  
848
//			val = DwgUtil.testBit(intData, bitPos);
849
//			bitPos = ((Integer) val.get(0)).intValue();
850
//			dwgFile.setHeader("BLIPMODE", val.get(1));
851

  
852
			val = DwgUtil.testBit(intData, bitPos);
853
			bitPos = ((Integer) val.get(0)).intValue();
854
			dwgFile.setHeader("USER_TIMER", val.get(1));
855

  
856
			val = DwgUtil.testBit(intData, bitPos);
857
			bitPos = ((Integer) val.get(0)).intValue();
858
			dwgFile.setHeader("SKPOLY", val.get(1));
859

  
860
			val = DwgUtil.testBit(intData, bitPos);
861
			bitPos = ((Integer) val.get(0)).intValue();
862
			dwgFile.setHeader("ANGDIR", val.get(1));
863

  
864
			val = DwgUtil.testBit(intData, bitPos);
865
			bitPos = ((Integer) val.get(0)).intValue();
866
			dwgFile.setHeader("SPLFRAME", val.get(1));
867

  
868
//			val = DwgUtil.testBit(intData, bitPos);
869
//			bitPos = ((Integer) val.get(0)).intValue();
870
//			dwgFile.setHeader("ATTREQ", val.get(1));
871
//
872
//			val = DwgUtil.testBit(intData, bitPos);
873
//			bitPos = ((Integer) val.get(0)).intValue();
874
//			dwgFile.setHeader("ATTDIA", val.get(1));
875

  
876
			val = DwgUtil.testBit(intData, bitPos);
877
			bitPos = ((Integer) val.get(0)).intValue();
878
			dwgFile.setHeader("MIRRTEXT", val.get(1));
879

  
880
			val = DwgUtil.testBit(intData, bitPos);
881
			bitPos = ((Integer) val.get(0)).intValue();
882
			dwgFile.setHeader("WORLDVIEW", val.get(1));
883

  
884
//			val = DwgUtil.testBit(intData, bitPos);
885
//			bitPos = ((Integer) val.get(0)).intValue();
886
//			dwgFile.setHeader("WIREFRAME", val.get(1));
887

  
888
			val = DwgUtil.testBit(intData, bitPos);
889
			bitPos = ((Integer) val.get(0)).intValue();
890
			dwgFile.setHeader("TILEMODE", val.get(1));
891

  
892
			val = DwgUtil.testBit(intData, bitPos);
893
			bitPos = ((Integer) val.get(0)).intValue();
894
			dwgFile.setHeader("PLIMCHECK", val.get(1));
895

  
896
			val = DwgUtil.testBit(intData, bitPos);
897
			bitPos = ((Integer) val.get(0)).intValue();
898
			dwgFile.setHeader("VISRETAIN", val.get(1));
899

  
900
//			val = DwgUtil.testBit(intData, bitPos);
901
//			bitPos = ((Integer) val.get(0)).intValue();
902
//			dwgFile.setHeader("DELOBJ", val.get(1));
903

  
904
			val = DwgUtil.testBit(intData, bitPos);
905
			bitPos = ((Integer) val.get(0)).intValue();
906
			dwgFile.setHeader("DISPSILH", val.get(1));
907

  
908
			val = DwgUtil.testBit(intData, bitPos);
909
			bitPos = ((Integer) val.get(0)).intValue();
910
			dwgFile.setHeader("PELLISE", val.get(1));
911

  
912
			val = DwgUtil.getBitShort(intData, bitPos);
913
			bitPos = ((Integer) val.get(0)).intValue();
914
//			if (dwgFile.getDwgVersion() == "R14")
915
			dwgFile.setHeader("PROXYGRAPH", val.get(1));
916
//			else
917
//				dwgFile.setHeader("SAVEIMAGES", val.get(1));
918

  
919
//			val = DwgUtil.getBitShort(intData, bitPos);
920
//			bitPos = ((Integer) val.get(0)).intValue();
921
//			dwgFile.setHeader("DRAGMODE", val.get(1));
922

  
923
			val = DwgUtil.getBitShort(intData, bitPos);
924
			bitPos = ((Integer) val.get(0)).intValue();
925
			dwgFile.setHeader("TREEDEPTH", val.get(1));
926

  
927
			val = DwgUtil.getBitShort(intData, bitPos);
928
			bitPos = ((Integer) val.get(0)).intValue();
929
			dwgFile.setHeader("LUNITS", val.get(1));
930

  
931
			val = DwgUtil.getBitShort(intData, bitPos);
932
			bitPos = ((Integer) val.get(0)).intValue();
933
			dwgFile.setHeader("LUPREC", val.get(1));
934

  
935
			val = DwgUtil.getBitShort(intData, bitPos);
936
			bitPos = ((Integer) val.get(0)).intValue();
937
			dwgFile.setHeader("AUNITS", val.get(1));
938

  
939
			val = DwgUtil.getBitShort(intData, bitPos);
940
			bitPos = ((Integer) val.get(0)).intValue();
941
			dwgFile.setHeader("AUPREC", val.get(1));
942

  
943
//			val = DwgUtil.getBitShort(intData, bitPos);
944
//			bitPos = ((Integer) val.get(0)).intValue();
945
//			dwgFile.setHeader("OSMODE", val.get(1));
946

  
947
			val = DwgUtil.getBitShort(intData, bitPos);
948
			bitPos = ((Integer) val.get(0)).intValue();
949
			dwgFile.setHeader("ATTMODE", val.get(1));
950

  
951
//			val = DwgUtil.getBitShort(intData, bitPos);
952
//			bitPos = ((Integer) val.get(0)).intValue();
953
//			dwgFile.setHeader("COORDS", val.get(1));
954

  
955
			val = DwgUtil.getBitShort(intData, bitPos);
956
			bitPos = ((Integer) val.get(0)).intValue();
957
			dwgFile.setHeader("PDMODE", val.get(1));
958

  
959
//			val = DwgUtil.getBitShort(intData, bitPos);
960
//			bitPos = ((Integer) val.get(0)).intValue();
961
//			dwgFile.setHeader("PICKSTYLE", val.get(1));
962

  
963
			val = DwgUtil.getBitShort(intData, bitPos);
964
			bitPos = ((Integer) val.get(0)).intValue();
965
			dwgFile.setHeader("USERI1", val.get(1));
966

  
967
			val = DwgUtil.getBitShort(intData, bitPos);
968
			bitPos = ((Integer) val.get(0)).intValue();
969
			dwgFile.setHeader("USERI2", val.get(1));
970

  
971
			val = DwgUtil.getBitShort(intData, bitPos);
972
			bitPos = ((Integer) val.get(0)).intValue();
973
			dwgFile.setHeader("USERI3", val.get(1));
974

  
975
			val = DwgUtil.getBitShort(intData, bitPos);
976
			bitPos = ((Integer) val.get(0)).intValue();
977
			dwgFile.setHeader("USERI4", val.get(1));
978

  
979
			val = DwgUtil.getBitShort(intData, bitPos);
980
			bitPos = ((Integer) val.get(0)).intValue();
981
			dwgFile.setHeader("USERI5", val.get(1));
982

  
983
			val = DwgUtil.getBitShort(intData, bitPos);
984
			bitPos = ((Integer) val.get(0)).intValue();
985
			dwgFile.setHeader("SPLINESEGS", val.get(1));
986

  
987
			val = DwgUtil.getBitShort(intData, bitPos);
988
			bitPos = ((Integer) val.get(0)).intValue();
989
			dwgFile.setHeader("SURFU", val.get(1));
990

  
991
			val = DwgUtil.getBitShort(intData, bitPos);
992
			bitPos = ((Integer) val.get(0)).intValue();
993
			dwgFile.setHeader("SURFV", val.get(1));
994

  
995
			val = DwgUtil.getBitShort(intData, bitPos);
996
			bitPos = ((Integer) val.get(0)).intValue();
997
			dwgFile.setHeader("SURFTYPE", val.get(1));
998

  
999
			val = DwgUtil.getBitShort(intData, bitPos);
1000
			bitPos = ((Integer) val.get(0)).intValue();
1001
			dwgFile.setHeader("SURFTAB1", val.get(1));
1002

  
1003
			val = DwgUtil.getBitShort(intData, bitPos);
1004
			bitPos = ((Integer) val.get(0)).intValue();
1005
			dwgFile.setHeader("SURFTAB2", val.get(1));
1006

  
1007
			val = DwgUtil.getBitShort(intData, bitPos);
1008
			bitPos = ((Integer) val.get(0)).intValue();
1009
			dwgFile.setHeader("SPLINETYPE", val.get(1));
1010

  
1011
			val = DwgUtil.getBitShort(intData, bitPos);
1012
			bitPos = ((Integer) val.get(0)).intValue();
1013
			dwgFile.setHeader("SHADEDGE", val.get(1));
1014

  
1015
			val = DwgUtil.getBitShort(intData, bitPos);
1016
			bitPos = ((Integer) val.get(0)).intValue();
1017
			dwgFile.setHeader("SHADEDIF", val.get(1));
1018

  
1019
			val = DwgUtil.getBitShort(intData, bitPos);
1020
			bitPos = ((Integer) val.get(0)).intValue();
1021
			dwgFile.setHeader("UNITMODE", val.get(1));
1022

  
1023
			val = DwgUtil.getBitShort(intData, bitPos);
1024
			bitPos = ((Integer) val.get(0)).intValue();
1025
			dwgFile.setHeader("MAXACTVP", val.get(1));
1026

  
1027
			val = DwgUtil.getBitShort(intData, bitPos);
1028
			bitPos = ((Integer) val.get(0)).intValue();
1029
			dwgFile.setHeader("ISOLINES", val.get(1));
1030

  
1031
			val = DwgUtil.getBitShort(intData, bitPos);
1032
			bitPos = ((Integer) val.get(0)).intValue();
1033
			dwgFile.setHeader("CMLJUST", val.get(1));
1034

  
1035
			val = DwgUtil.getBitShort(intData, bitPos);
1036
			bitPos = ((Integer) val.get(0)).intValue();
1037
			dwgFile.setHeader("TEXTQLTY", val.get(1));
1038

  
1039
			val = DwgUtil.getBitDouble(intData, bitPos);
1040
			bitPos = ((Integer) val.get(0)).intValue();
1041
			dwgFile.setHeader("LTSCALE", val.get(1));
1042

  
1043
			val = DwgUtil.getBitDouble(intData, bitPos);
1044
			bitPos = ((Integer) val.get(0)).intValue();
1045
			dwgFile.setHeader("TEXTSIZE", val.get(1));
1046

  
1047
			val = DwgUtil.getBitDouble(intData, bitPos);
1048
			bitPos = ((Integer) val.get(0)).intValue();
1049
			dwgFile.setHeader("TRACEWID", val.get(1));
1050

  
1051
			val = DwgUtil.getBitDouble(intData, bitPos);
1052
			bitPos = ((Integer) val.get(0)).intValue();
1053
			dwgFile.setHeader("SKETCHINC", val.get(1));
1054

  
1055
			val = DwgUtil.getBitDouble(intData, bitPos);
1056
			bitPos = ((Integer) val.get(0)).intValue();
1057
			dwgFile.setHeader("FILLETRAD", val.get(1));
1058

  
1059
			val = DwgUtil.getBitDouble(intData, bitPos);
1060
			bitPos = ((Integer) val.get(0)).intValue();
1061
			dwgFile.setHeader("THICKNESS", val.get(1));
1062

  
1063
			val = DwgUtil.getBitDouble(intData, bitPos);
1064
			bitPos = ((Integer) val.get(0)).intValue();
1065
			dwgFile.setHeader("ANGBASE", val.get(1));
1066

  
1067
			val = DwgUtil.getBitDouble(intData, bitPos);
1068
			bitPos = ((Integer) val.get(0)).intValue();
1069
			dwgFile.setHeader("PDSIZE", val.get(1));
1070

  
1071
			val = DwgUtil.getBitDouble(intData, bitPos);
1072
			bitPos = ((Integer) val.get(0)).intValue();
1073
			dwgFile.setHeader("PLINEWID", val.get(1));
1074

  
1075
			val = DwgUtil.getBitDouble(intData, bitPos);
1076
			bitPos = ((Integer) val.get(0)).intValue();
1077
			dwgFile.setHeader("USERR1", val.get(1));
1078

  
1079
			val = DwgUtil.getBitDouble(intData, bitPos);
1080
			bitPos = ((Integer) val.get(0)).intValue();
1081
			dwgFile.setHeader("USERR2", val.get(1));
1082

  
1083
			val = DwgUtil.getBitDouble(intData, bitPos);
1084
			bitPos = ((Integer) val.get(0)).intValue();
1085
			dwgFile.setHeader("USERR3", val.get(1));
1086

  
1087
			val = DwgUtil.getBitDouble(intData, bitPos);
1088
			bitPos = ((Integer) val.get(0)).intValue();
1089
			dwgFile.setHeader("USERR4", val.get(1));
1090

  
1091
			val = DwgUtil.getBitDouble(intData, bitPos);
1092
			bitPos = ((Integer) val.get(0)).intValue();
1093
			dwgFile.setHeader("USERR5", val.get(1));
1094

  
1095
			val = DwgUtil.getBitDouble(intData, bitPos);
1096
			bitPos = ((Integer) val.get(0)).intValue();
1097
			dwgFile.setHeader("CHAMFERA", val.get(1));
1098

  
1099
			val = DwgUtil.getBitDouble(intData, bitPos);
1100
			bitPos = ((Integer) val.get(0)).intValue();
1101
			dwgFile.setHeader("CHAMFERB", val.get(1));
1102

  
1103
			val = DwgUtil.getBitDouble(intData, bitPos);
1104
			bitPos = ((Integer) val.get(0)).intValue();
1105
			dwgFile.setHeader("CHAMFERC", val.get(1));
1106

  
1107
			val = DwgUtil.getBitDouble(intData, bitPos);
1108
			bitPos = ((Integer) val.get(0)).intValue();
1109
			dwgFile.setHeader("CHAMFERD", val.get(1));
1110

  
1111
			val = DwgUtil.getBitDouble(intData, bitPos);
1112
			bitPos = ((Integer) val.get(0)).intValue();
1113
			dwgFile.setHeader("FACETRES", val.get(1));
1114

  
1115
			val = DwgUtil.getBitDouble(intData, bitPos);
1116
			bitPos = ((Integer) val.get(0)).intValue();
1117
			dwgFile.setHeader("CMLSCALE", val.get(1));
1118

  
1119
			val = DwgUtil.getBitDouble(intData, bitPos);
1120
			bitPos = ((Integer) val.get(0)).intValue();
1121
			dwgFile.setHeader("CELTSCALE", val.get(1));
1122

  
1123
			val = DwgUtil.getTextString(intData, bitPos);
1124
			bitPos = ((Integer) val.get(0)).intValue();
1125
			dwgFile.setHeader("MENUNAME", val.get(1));
1126

  
1127
			int[] tdcreate = new int[2];
1128
			val = DwgUtil.getBitLong(intData, bitPos);
1129
			bitPos = ((Integer) val.get(0)).intValue();
1130
			tdcreate[0] = ((Integer) val.get(1)).intValue();
1131

  
1132
			val = DwgUtil.getBitLong(intData, bitPos);
1133
			bitPos = ((Integer) val.get(0)).intValue();
1134
			tdcreate[1] = ((Integer) val.get(1)).intValue();
1135
			dwgFile.setHeader("TDCREATE", tdcreate);
1136

  
1137
			int[] tdupdate = new int[2];
1138
			val = DwgUtil.getBitLong(intData, bitPos);
1139
			bitPos = ((Integer) val.get(0)).intValue();
1140
			tdupdate[0] = ((Integer) val.get(1)).intValue();
1141

  
1142
			val = DwgUtil.getBitLong(intData, bitPos);
1143
			bitPos = ((Integer) val.get(0)).intValue();
1144
			tdupdate[1] = ((Integer) val.get(1)).intValue();
1145
			dwgFile.setHeader("TDUPDATE", tdupdate);
1146

  
1147
			int[] tdindwg = new int[2];
1148
			val = DwgUtil.getBitLong(intData, bitPos);
1149
			bitPos = ((Integer) val.get(0)).intValue();
1150
			tdindwg[0] = ((Integer) val.get(1)).intValue();
1151

  
1152
			val = DwgUtil.getBitLong(intData, bitPos);
1153
			bitPos = ((Integer) val.get(0)).intValue();
1154
			tdindwg[1] = ((Integer) val.get(1)).intValue();
1155
			dwgFile.setHeader("TDINDWG", tdindwg);
1156

  
1157
			int[] tdusrtime = new int[2];
1158
			val = DwgUtil.getBitLong(intData, bitPos);
1159
			bitPos = ((Integer) val.get(0)).intValue();
1160
			tdusrtime[0] = ((Integer) val.get(1)).intValue();
1161
			val = DwgUtil.getBitLong(intData, bitPos);
1162
			bitPos = ((Integer) val.get(0)).intValue();
1163
			tdusrtime[1] = ((Integer) val.get(1)).intValue();
1164
			dwgFile.setHeader("TDUSRTIME", tdusrtime);
1165

  
1166
			val = DwgUtil.getBitShort(intData, bitPos);
1167
			bitPos = ((Integer) val.get(0)).intValue();
1168
			dwgFile.setHeader("CECOLOR", val.get(1));
1169

  
1170
			val = DwgUtil.getHandle(intData, bitPos);
1171
			bitPos = ((Integer) val.get(0)).intValue();
1172
			int intHandle = DwgUtil.handleToInt(val);
1173
			dwgFile.setHeader("HANDSEED", new Integer(intHandle));
1174

  
1175
			//creo que CLAYER marca la capa actualmente seleccionada en el menu
1176
			// de
1177
			// autocad
1178

  
1179
			val = DwgUtil.getHandle(intData, bitPos);
1180
			bitPos = ((Integer) val.get(0)).intValue();
1181
			intHandle = DwgUtil.handleToInt(val);
1182
			dwgFile.setHeader("CLAYER", new Integer(intHandle));
1183

  
1184
			val = DwgUtil.getHandle(intData, bitPos);
1185
			bitPos = ((Integer) val.get(0)).intValue();
1186
			intHandle = DwgUtil.handleToInt(val);
1187
			dwgFile.setHeader("TEXSTYLE", new Integer(intHandle));
1188

  
1189
			val = DwgUtil.getHandle(intData, bitPos);
1190
			bitPos = ((Integer) val.get(0)).intValue();
1191
			intHandle = DwgUtil.handleToInt(val);
1192
			dwgFile.setHeader("CELLTYPE", new Integer(intHandle));
1193

  
1194
			val = DwgUtil.getHandle(intData, bitPos);
1195
			bitPos = ((Integer) val.get(0)).intValue();
1196
			intHandle = DwgUtil.handleToInt(val);
1197
			dwgFile.setHeader("DIMSTYLE", new Integer(intHandle));
1198

  
1199
			val = DwgUtil.getHandle(intData, bitPos);
1200
			bitPos = ((Integer) val.get(0)).intValue();
1201
			intHandle = DwgUtil.handleToInt(val);
1202
			dwgFile.setHeader("CMLSTYLE", new Integer(intHandle));
1203

  
1204
			//this property is exclusive of DWG 2000
1205
			val = DwgUtil.getBitDouble(intData, bitPos);
1206
			bitPos = ((Integer) val.get(0)).intValue();
1207
			dwgFile.setHeader("PSVPSCALE", val.get(1));
1208

  
1209

  
1210
			double[] spaces1 = new double[3];
1211
			val = DwgUtil.getBitDouble(intData, bitPos);
1212
			bitPos = ((Integer) val.get(0)).intValue();
1213
			spaces1[0] = ((Double) val.get(1)).doubleValue();
1214
			val = DwgUtil.getBitDouble(intData, bitPos);
1215
			bitPos = ((Integer) val.get(0)).intValue();
1216
			spaces1[1] = ((Double) val.get(1)).doubleValue();
1217
			val = DwgUtil.getBitDouble(intData, bitPos);
1218
			bitPos = ((Integer) val.get(0)).intValue();
1219
			spaces1[2] = ((Double) val.get(1)).doubleValue();
1220
			dwgFile.setHeader("PSPACE_INSBASE", spaces1);
1221

  
1222
			double[] spaces2 = new double[3];
1223
			val = DwgUtil.getBitDouble(intData, bitPos);
1224
			bitPos = ((Integer) val.get(0)).intValue();
1225
			spaces2[0] = ((Double) val.get(1)).doubleValue();
1226
			val = DwgUtil.getBitDouble(intData, bitPos);
1227
			bitPos = ((Integer) val.get(0)).intValue();
1228
			spaces2[1] = ((Double) val.get(1)).doubleValue();
1229
			val = DwgUtil.getBitDouble(intData, bitPos);
1230
			bitPos = ((Integer) val.get(0)).intValue();
1231
			spaces2[2] = ((Double) val.get(1)).doubleValue();
1232
			dwgFile.setHeader("PSPACE_EXTMIN", spaces2);
1233

  
1234
			double[] spaces3 = new double[3];
1235
			val = DwgUtil.getBitDouble(intData, bitPos);
1236
			bitPos = ((Integer) val.get(0)).intValue();
1237
			spaces3[0] = ((Double) val.get(1)).doubleValue();
1238
			val = DwgUtil.getBitDouble(intData, bitPos);
1239
			bitPos = ((Integer) val.get(0)).intValue();
1240
			spaces3[1] = ((Double) val.get(1)).doubleValue();
1241
			val = DwgUtil.getBitDouble(intData, bitPos);
1242
			bitPos = ((Integer) val.get(0)).intValue();
1243
			spaces3[2] = ((Double) val.get(1)).doubleValue();
1244
			dwgFile.setHeader("PSPACE_EXTMAX", spaces2);
1245

  
1246
			double[] spaces4 = new double[2];
1247
			val = DwgUtil.getRawDouble(intData, bitPos);
1248
			bitPos = ((Integer) val.get(0)).intValue();
1249
			spaces4[0] = ((Double) val.get(1)).doubleValue();
1250
			val = DwgUtil.getRawDouble(intData, bitPos);
1251
			bitPos = ((Integer) val.get(0)).intValue();
1252
			spaces4[1] = ((Double) val.get(1)).doubleValue();
1253
			dwgFile.setHeader("PSPACE_LIMMIN", spaces4);
1254

  
1255
			double[] spaces5 = new double[2];
1256
			val = DwgUtil.getRawDouble(intData, bitPos);
1257
			bitPos = ((Integer) val.get(0)).intValue();
1258
			spaces5[0] = ((Double) val.get(1)).doubleValue();
1259
			val = DwgUtil.getRawDouble(intData, bitPos);
1260
			bitPos = ((Integer) val.get(0)).intValue();
1261
			spaces5[1] = ((Double) val.get(1)).doubleValue();
1262
			dwgFile.setHeader("PSPACE_LIMMAX", spaces5);
1263

  
1264
			val = DwgUtil.getBitDouble(intData, bitPos);
1265
			bitPos = ((Integer) val.get(0)).intValue();
1266
			dwgFile.setHeader("PSPACE_ELEVATION", val.get(1));
1267

  
1268
			double[] spaces6 = new double[6];
1269
			val = DwgUtil.getBitDouble(intData, bitPos);
1270
			bitPos = ((Integer) val.get(0)).intValue();
1271
			spaces6[0] = ((Double) val.get(1)).doubleValue();
1272
			val = DwgUtil.getBitDouble(intData, bitPos);
1273
			bitPos = ((Integer) val.get(0)).intValue();
1274
			spaces6[1] = ((Double) val.get(1)).doubleValue();
1275
			val = DwgUtil.getBitDouble(intData, bitPos);
1276
			bitPos = ((Integer) val.get(0)).intValue();
1277
			spaces6[2] = ((Double) val.get(1)).doubleValue();
1278
			dwgFile.setHeader("PSPACE_UCSORG", spaces6);
1279

  
1280
			double[] spaces7 = new double[6];
1281
			val = DwgUtil.getBitDouble(intData, bitPos);
1282
			bitPos = ((Integer) val.get(0)).intValue();
1283
			spaces7[0] = ((Double) val.get(1)).doubleValue();
1284
			val = DwgUtil.getBitDouble(intData, bitPos);
1285
			bitPos = ((Integer) val.get(0)).intValue();
1286
			spaces7[1] = ((Double) val.get(1)).doubleValue();
1287
			val = DwgUtil.getBitDouble(intData, bitPos);
1288
			bitPos = ((Integer) val.get(0)).intValue();
1289
			spaces7[2] = ((Double) val.get(1)).doubleValue();
1290
			dwgFile.setHeader("PSPACE_UCSXDIR", spaces7);
1291

  
1292
			double[] spaces8 = new double[6];
1293
			val = DwgUtil.getBitDouble(intData, bitPos);
1294
			bitPos = ((Integer) val.get(0)).intValue();
1295
			spaces8[0] = ((Double) val.get(1)).doubleValue();
1296
			val = DwgUtil.getBitDouble(intData, bitPos);
1297
			bitPos = ((Integer) val.get(0)).intValue();
1298
			spaces8[1] = ((Double) val.get(1)).doubleValue();
1299
			val = DwgUtil.getBitDouble(intData, bitPos);
1300
			bitPos = ((Integer) val.get(0)).intValue();
1301
			spaces8[2] = ((Double) val.get(1)).doubleValue();
1302
			dwgFile.setHeader("PSPACE_UCSYDIR", spaces8);
1303

  
1304
			val = DwgUtil.getHandle(intData, bitPos);
1305
			bitPos = ((Integer) val.get(0)).intValue();
1306
			intHandle = DwgUtil.handleToInt(val);
1307
			dwgFile.setHeader("PSPACE_UCSNAME", new Integer(intHandle));
1308

  
1309
			///DWG 2000 ONLY
1310

  
1311
			val = DwgUtil.getHandle(intData, bitPos);
1312
			bitPos = ((Integer) val.get(0)).intValue();
1313
			intHandle = DwgUtil.handleToInt(val);
1314
			dwgFile.setHeader("PUCSBASE", new Integer(intHandle));
1315

  
1316
			val = DwgUtil.getBitShort(intData, bitPos);
1317
			bitPos = ((Integer) val.get(0)).intValue();
1318
			dwgFile.setHeader("PUCSORTHOVIEW", val.get(1));
1319

  
1320
			val = DwgUtil.getHandle(intData, bitPos);
1321
			bitPos = ((Integer) val.get(0)).intValue();
1322
			intHandle = DwgUtil.handleToInt(val);
1323
			dwgFile.setHeader("PUCSORTHOREF", new Integer(intHandle));
1324

  
1325
			double[] pucsorgtop = new double[3];
1326
			val = DwgUtil.getBitDouble(intData, bitPos);
1327
			bitPos = ((Integer) val.get(0)).intValue();
1328
			pucsorgtop[0] = ((Double) val.get(1)).doubleValue();
1329
			val = DwgUtil.getBitDouble(intData, bitPos);
1330
			bitPos = ((Integer) val.get(0)).intValue();
1331
			pucsorgtop[1] = ((Double) val.get(1)).doubleValue();
1332
			val = DwgUtil.getBitDouble(intData, bitPos);
1333
			bitPos = ((Integer) val.get(0)).intValue();
1334
			pucsorgtop[2] = ((Double) val.get(1)).doubleValue();
1335
			dwgFile.setHeader("PUCSORGTOP", pucsorgtop);
1336

  
1337
			double[] pucsorgbottom = new double[3];
1338
			val = DwgUtil.getBitDouble(intData, bitPos);
1339
			bitPos = ((Integer) val.get(0)).intValue();
1340
			pucsorgbottom[0] = ((Double) val.get(1)).doubleValue();
1341
			val = DwgUtil.getBitDouble(intData, bitPos);
1342
			bitPos = ((Integer) val.get(0)).intValue();
1343
			pucsorgbottom[1] = ((Double) val.get(1)).doubleValue();
1344
			val = DwgUtil.getBitDouble(intData, bitPos);
1345
			bitPos = ((Integer) val.get(0)).intValue();
1346
			pucsorgbottom[2] = ((Double) val.get(1)).doubleValue();
1347
			dwgFile.setHeader("PUCSORGBOTTOM", pucsorgbottom);
1348

  
1349
			double[] pucsorgleft = new double[3];
1350
			val = DwgUtil.getBitDouble(intData, bitPos);
1351
			bitPos = ((Integer) val.get(0)).intValue();
1352
			pucsorgleft[0] = ((Double) val.get(1)).doubleValue();
1353
			val = DwgUtil.getBitDouble(intData, bitPos);
1354
			bitPos = ((Integer) val.get(0)).intValue();
1355
			pucsorgleft[1] = ((Double) val.get(1)).doubleValue();
1356
			val = DwgUtil.getBitDouble(intData, bitPos);
1357
			bitPos = ((Integer) val.get(0)).intValue();
1358
			pucsorgleft[2] = ((Double) val.get(1)).doubleValue();
1359
			dwgFile.setHeader("PUCSORGLEFT", pucsorgleft);
1360

  
1361
			double[] pucsorgright = new double[3];
1362
			val = DwgUtil.getBitDouble(intData, bitPos);
1363
			bitPos = ((Integer) val.get(0)).intValue();
1364
			pucsorgright[0] = ((Double) val.get(1)).doubleValue();
1365
			val = DwgUtil.getBitDouble(intData, bitPos);
1366
			bitPos = ((Integer) val.get(0)).intValue();
1367
			pucsorgright[1] = ((Double) val.get(1)).doubleValue();
1368
			val = DwgUtil.getBitDouble(intData, bitPos);
1369
			bitPos = ((Integer) val.get(0)).intValue();
1370
			pucsorgright[2] = ((Double) val.get(1)).doubleValue();
1371
			dwgFile.setHeader("PUCSORGRIGHT", pucsorgright);
1372

  
1373
			double[] pucsorgfront = new double[3];
1374
			val = DwgUtil.getBitDouble(intData, bitPos);
1375
			bitPos = ((Integer) val.get(0)).intValue();
1376
			pucsorgfront[0] = ((Double) val.get(1)).doubleValue();
1377
			val = DwgUtil.getBitDouble(intData, bitPos);
1378
			bitPos = ((Integer) val.get(0)).intValue();
1379
			pucsorgfront[1] = ((Double) val.get(1)).doubleValue();
1380
			val = DwgUtil.getBitDouble(intData, bitPos);
1381
			bitPos = ((Integer) val.get(0)).intValue();
1382
			pucsorgfront[2] = ((Double) val.get(1)).doubleValue();
1383
			dwgFile.setHeader("PUCSORGFRONT", pucsorgfront);
1384

  
1385
			double[] pucsorgback = new double[3];
1386
			val = DwgUtil.getBitDouble(intData, bitPos);
1387
			bitPos = ((Integer) val.get(0)).intValue();
1388
			pucsorgback[0] = ((Double) val.get(1)).doubleValue();
1389
			val = DwgUtil.getBitDouble(intData, bitPos);
1390
			bitPos = ((Integer) val.get(0)).intValue();
1391
			pucsorgback[1] = ((Double) val.get(1)).doubleValue();
1392
			val = DwgUtil.getBitDouble(intData, bitPos);
1393
			bitPos = ((Integer) val.get(0)).intValue();
1394
			pucsorgback[2] = ((Double) val.get(1)).doubleValue();
1395
			dwgFile.setHeader("PUCSORGBACK", pucsorgback);
1396

  
1397

  
1398
			//COMMON
1399
			double[] spaces9 = new double[6];
1400
			val = DwgUtil.getBitDouble(intData, bitPos);
1401
			bitPos = ((Integer) val.get(0)).intValue();
1402
			spaces9[0] = ((Double) val.get(1)).doubleValue();
1403
			val = DwgUtil.getBitDouble(intData, bitPos);
1404
			bitPos = ((Integer) val.get(0)).intValue();
1405
			spaces9[1] = ((Double) val.get(1)).doubleValue();
1406
			val = DwgUtil.getBitDouble(intData, bitPos);
1407
			bitPos = ((Integer) val.get(0)).intValue();
1408
			spaces9[2] = ((Double) val.get(1)).doubleValue();
1409
			dwgFile.setHeader("MSPACE_INSBASE", spaces9);
1410

  
1411
			double[] spaces10 = new double[6];
1412
			val = DwgUtil.getBitDouble(intData, bitPos);
1413
			bitPos = ((Integer) val.get(0)).intValue();
1414
			spaces10[0] = ((Double) val.get(1)).doubleValue();
1415
			val = DwgUtil.getBitDouble(intData, bitPos);
1416
			bitPos = ((Integer) val.get(0)).intValue();
1417
			spaces10[1] = ((Double) val.get(1)).doubleValue();
1418
			val = DwgUtil.getBitDouble(intData, bitPos);
1419
			bitPos = ((Integer) val.get(0)).intValue();
1420
			spaces10[2] = ((Double) val.get(1)).doubleValue();
1421
			dwgFile.setHeader("MSPACE_EXTMIN", spaces10);
1422

  
1423
			double[] spaces11 = new double[3];
1424
			val = DwgUtil.getBitDouble(intData, bitPos);
1425
			bitPos = ((Integer) val.get(0)).intValue();
1426
			spaces11[0] = ((Double) val.get(1)).doubleValue();
1427
			val = DwgUtil.getBitDouble(intData, bitPos);
1428
			bitPos = ((Integer) val.get(0)).intValue();
1429
			spaces11[1] = ((Double) val.get(1)).doubleValue();
1430
			val = DwgUtil.getBitDouble(intData, bitPos);
1431
			bitPos = ((Integer) val.get(0)).intValue();
1432
			spaces11[2] = ((Double) val.get(1)).doubleValue();
1433
			dwgFile.setHeader("MSPACE_EXTMAX", spaces11);
1434

  
1435
			double[] spaces12 = new double[2];
1436
			val = DwgUtil.getRawDouble(intData, bitPos);
1437
			bitPos = ((Integer) val.get(0)).intValue();
1438
			spaces12[0] = ((Double) val.get(1)).doubleValue();
1439
			val = DwgUtil.getRawDouble(intData, bitPos);
1440
			bitPos = ((Integer) val.get(0)).intValue();
1441
			spaces12[1] = ((Double) val.get(1)).doubleValue();
1442
			dwgFile.setHeader("MSPACE_LIMMIN", spaces12);
1443

  
1444
			double[] spaces13 = new double[2];
1445
			val = DwgUtil.getRawDouble(intData, bitPos);
1446
			bitPos = ((Integer) val.get(0)).intValue();
1447
			spaces13[0] = ((Double) val.get(1)).doubleValue();
1448
			val = DwgUtil.getRawDouble(intData, bitPos);
1449
			bitPos = ((Integer) val.get(0)).intValue();
1450
			spaces13[1] = ((Double) val.get(1)).doubleValue();
1451
			dwgFile.setHeader("MSPACE_LIMMAX", spaces13);
1452

  
1453
			val = DwgUtil.getBitDouble(intData, bitPos);
1454
			bitPos = ((Integer) val.get(0)).intValue();
1455
			dwgFile.setHeader("MSPACE_ELEVATION", (Double) val.get(1));
1456

  
1457
			double[] spaces14 = new double[3];
1458
			val = DwgUtil.getBitDouble(intData, bitPos);
1459
			bitPos = ((Integer) val.get(0)).intValue();
1460
			spaces14[0] = ((Double) val.get(1)).doubleValue();
1461
			val = DwgUtil.getBitDouble(intData, bitPos);
1462
			bitPos = ((Integer) val.get(0)).intValue();
1463
			spaces14[1] = ((Double) val.get(1)).doubleValue();
1464
			val = DwgUtil.getBitDouble(intData, bitPos);
1465
			bitPos = ((Integer) val.get(0)).intValue();
1466
			spaces14[2] = ((Double) val.get(1)).doubleValue();
1467
			dwgFile.setHeader("MSPACE_UCSORG", spaces14);
1468

  
1469
			double[] spaces15 = new double[3];
1470
			val = DwgUtil.getBitDouble(intData, bitPos);
1471
			bitPos = ((Integer) val.get(0)).intValue();
1472
			spaces15[0] = ((Double) val.get(1)).doubleValue();
1473
			val = DwgUtil.getBitDouble(intData, bitPos);
1474
			bitPos = ((Integer) val.get(0)).intValue();
1475
			spaces15[1] = ((Double) val.get(1)).doubleValue();
1476
			val = DwgUtil.getBitDouble(intData, bitPos);
1477
			bitPos = ((Integer) val.get(0)).intValue();
1478
			spaces15[2] = ((Double) val.get(1)).doubleValue();
1479
			dwgFile.setHeader("MSPACE_UCSXDIR", spaces15);
1480

  
1481
			double[] spaces16 = new double[3];
1482
			val = DwgUtil.getBitDouble(intData, bitPos);
1483
			bitPos = ((Integer) val.get(0)).intValue();
1484
			spaces16[0] = ((Double) val.get(1)).doubleValue();
1485
			val = DwgUtil.getBitDouble(intData, bitPos);
1486
			bitPos = ((Integer) val.get(0)).intValue();
1487
			spaces16[1] = ((Double) val.get(1)).doubleValue();
1488
			val = DwgUtil.getBitDouble(intData, bitPos);
1489
			bitPos = ((Integer) val.get(0)).intValue();
1490
			spaces16[2] = ((Double) val.get(1)).doubleValue();
1491
			dwgFile.setHeader("MSPACE_UCSYDIR", spaces16);
1492

  
1493
			val = DwgUtil.getHandle(intData, bitPos);
1494
			bitPos = ((Integer) val.get(0)).intValue();
1495
			intHandle = DwgUtil.handleToInt(val);
1496
			dwgFile.setHeader("MSPACE_UCSNAME", new Integer(intHandle));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff