Revision 39306

View differences:

tags/v2_0_0_Build_2059/libraries/libDXF/src/org/gvsig/dxf/io/DxfFile.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.gvsig.dxf.io;
25

  
26
import java.io.BufferedReader;
27
import java.io.FileReader;
28
import java.io.FileWriter;
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.io.InputStreamReader;
32
import java.io.Reader;
33
import java.util.Date;
34
import java.util.Hashtable;
35
import java.util.Vector;
36

  
37
import org.cresques.cts.ICoordTrans;
38
import org.cresques.cts.IProjection;
39
import org.cresques.geo.Projected;
40
import org.cresques.px.Extent;
41
import org.gvsig.dxf.px.IObjList;
42
import org.gvsig.dxf.px.dxf.DxfEntityMaker;
43
import org.gvsig.dxf.px.dxf.DxfHeaderManager;
44
import org.gvsig.dxf.px.dxf.DxfHeaderVariables;
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47

  
48
/**
49
 * Clase que representa un fichero en formato DXF. Contiene los interfaces y m�todos
50
 * necesarios para acceder a la informaci�n almacenada en su interior.
51
 *
52
 * @author jmorell
53
 */
54
public class DxfFile extends GeoFile {
55

  
56
	public static Logger logger = LoggerFactory.getLogger(DxfFile.class);
57
	
58
	private boolean cadFlag = true;
59
	
60
	long lineNr = 0;
61

  
62
	String buf = null;
63

  
64
	BufferedReader fi;
65
	long l = 0;
66
	int count = 0;
67
	DxfGroup grp = null;
68

  
69
	EntityFactory entityMaker = null;
70
	VarSettings headerManager;
71
    private boolean dxf3DFlag;
72

  
73
	/**
74
	 * Crea los objetos en el Modelo correspondiente.
75
	 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
76
	 */
77
	public interface EntityFactory extends Projected {
78

  
79
		/**
80
         * Permite saber si se est�n a�adiendo elementos a un bloque
81
         * @param booleano que indica si se est�n a�adiendo elementos a un bloque
82
		 */
83
        public void setAddingToBlock(boolean a);
84

  
85
        /**
86
         * Crea una nueva capa partiendo de la informaci�n almacenada en el DXF
87
         * @param DxfGroupVector con informaci�n para la construcci�n de la nueva capa
88
         * @throws Exception
89
         */
90
		public void createLayer(DxfGroupVector v) throws Exception ;
91

  
92
        /**
93
         * Crea una nueva polil�nea partiendo de la informaci�n almacenada en el DXF
94
         * @param DxfGroupVector con informaci�n para la construcci�n de la nueva polil�nea
95
         * @throws Exception
96
         */
97
		public void createPolyline(DxfGroupVector v) throws Exception ;
98

  
99
        /**
100
         * A�ade un v�rtice a la polil�nea que se est� creando
101
         * @param DxfGroupVector con la informaci�n necesaria para la adici�n del v�rtice
102
         * @throws Exception
103
         */
104
		public void addVertex(DxfGroupVector v) throws Exception ;
105

  
106
        /**
107
         * Fin de secuencia
108
         * @throws Exception
109
         */
110
        public void endSeq() throws Exception ;
111

  
112
        /**
113
         * Crea una nueva LwPolyline partiendo de la informaci�n almacenada en el DXF
114
         * @param DxfGroupVector con informaci�n para la construcci�n de la nueva polil�nea
115
         * @throws Exception
116
         */
117
		public void createLwPolyline(DxfGroupVector v) throws Exception ;
118

  
119
        /**
120
         * Crea una nueva l�nea partiendo de la informaci�n almacenada en el DXF
121
         * @param DxfGroupVector con informaci�n para la construcci�n de la nueva l�nea
122
         * @throws Exception
123
         */
124
        public void createLine(DxfGroupVector v) throws Exception ;
125

  
126
        /**
127
         * Crea un nuevo texto partiendo de la informaci�n almacenada en el DXF
128
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo texto
129
         * @throws Exception
130
         */
131
        public void createText(DxfGroupVector v) throws Exception ;
132

  
133
        /**
134
         * Crea un nuevo MText partiendo de la informaci�n almacenada en el DXF
135
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo MText
136
         * @throws Exception
137
         */
138
        public void createMText(DxfGroupVector v) throws Exception ;
139

  
140
        /**
141
         * Crea un nuevo punto partiendo de la informaci�n almacenada en el DXF
142
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo punto
143
         * @throws Exception
144
         */
145
        public void createPoint(DxfGroupVector v) throws Exception ;
146

  
147
        /**
148
         * Crea un nuevo c�rculo partiendo de la informaci�n almacenada en el DXF
149
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo c�rculo
150
         * @throws Exception
151
         */
152
        public void createCircle(DxfGroupVector v) throws Exception ;
153

  
154
        /**
155
         * Crea una nueva elipse partiendo de la informaci�n almacenada en el DXF
156
         * @param DxfGroupVector con informaci�n para la construcci�n de la nueva elipse
157
         * @throws Exception
158
         */
159
        public void createEllipse(DxfGroupVector v) throws Exception ;
160

  
161
        /**
162
         * Crea un nuevo arco partiendo de la informaci�n almacenada en el DXF
163
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo arco
164
         * @throws Exception
165
         */
166
        public void createArc(DxfGroupVector v) throws Exception ;
167

  
168
        /**
169
         * Crea un nuevo punto de inserci�n partiendo de la informaci�n almacenada en el DXF
170
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo punto de inserci�n
171
         * @throws Exception
172
         */
173
        public void createInsert(DxfGroupVector v) throws Exception ;
174

  
175
        /**
176
         * Crea un nuevo s�lido 2D partiendo de la informaci�n almacenada en el DXF
177
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo s�lido
178
         * @throws Exception
179
         */
180
        public void createSolid(DxfGroupVector v) throws Exception ;
181

  
182
        /**
183
         * Crea un nuevo Spline partiendo de la informaci�n almacenada en el DXF
184
         * @param DxfGroupVector con informaci�n para la construcci�n del nuevo Spline
185
         * @throws Exception
186
         */
187
        public void createSpline(DxfGroupVector v) throws Exception ;
188

  
189
        /**
190
         * Construye la definici�n de un nuevo atributo partiendo de la informaci�n almacenada en el DXF
191
         * @param DxfGroupVector con informaci�n para la construcci�n de la definici�n del nuevo atributo
192
         * @throws Exception
193
         */
194
        public void createAttdef(DxfGroupVector v) throws Exception ;
195

  
196
        /**
197
         * Crea un nuevo atributo partiendo de la informaci�n almacenada en el DXF
198
         * @param DxfGroupVector con informaci�n para la creaci�n del nuevo atributo
199
         * @throws Exception
200
         */
201
        public void createAttrib(DxfGroupVector v) throws Exception ;
202

  
203
        /**
204
         * Crea un bloque
205
         * @param DxfGroupVector con informaci�n para la creaci�n del nuevo elemento
206
         * @throws Exception
207
         */
208
        public void createBlock(DxfGroupVector v) throws Exception ;
209

  
210
        /**
211
         * Fin de la definici�n de un bloqe
212
         * @param DxfGroupVector con informaci�n referente al final de un bloque
213
         * @throws Exception
214
         */
215
        public void endBlk(DxfGroupVector v) throws Exception ;
216

  
217
        /**
218
         * Gestiona los bloques que no se han tratado en la primera vuelta
219
         */
220
        void testBlocks();
221

  
222
        /**
223
         * Devuelve el extent
224
         * @return el extent
225
         */
226
        public Extent getExtent();
227

  
228
        /**
229
         * Devuelve la lista de bloques
230
         * @return la lista de bloques
231
         */
232
        public Vector getBlkList();
233

  
234
		/**
235
         * Permite la gesti�n de los atributos almacenados en unn DXF
236
         * @return un Vector con la lista de atributos
237
		 */
238
        public Vector getAttributes();
239

  
240
        /**
241
         * Borra los atributos repetidos
242
         */
243
        public void depureAttributes();
244

  
245
        /**
246
         * Devuelve los objetos almacenados en el DXF
247
         * @return IObjList con los objetos procedentes del DXF
248
         */
249
        public IObjList getObjects();
250

  
251
        /**
252
         * Permite saber si se trata de un fichero DXF en 2D o en 3D
253
         * @return booleano que indica si se trata de un fichero DXF 3D
254
         */
255
        public boolean isDxf3DFile();
256
	};
257

  
258
	/**
259
	 * Establece el estado de las variables propias de un DXF que est�n definidas
260
	 * en la secci�n HEADER. Por ejemplo, la versi�n del DXF.
261
	 * @author jmorell (jose.morell@gmail.com)
262
	 * @version 15-dic-2004
263
	 */
264
	public interface VarSettings {
265

  
266
		/**
267
		 * Establece la versi�n de Autocad en la que fue generado el DXF.
268
		 * @param informaci�n de base
269
		 * @throws Exception
270
		 */
271
		public void setAcadVersion(DxfGroupVector v) throws Exception ;
272

  
273
		/**
274
		 * Devuelve la versi�n de Autocad en la que fue generado el DXF.
275
		 * @return
276
		 */
277
		public String getAcadVersion();
278

  
279
		/**
280
		 * Devuelve el estado de las variables propias de un DXF
281
		 * @return
282
		 */
283
		public DxfHeaderVariables getDxfHeaderVars();
284
        public boolean isWritedDxf3D();
285
        public void loadMinZFromHeader(double d);
286
        public void loadMaxZFromHeader(double d);
287
	};
288

  
289
    /**
290
     * Constructor de la clase
291
     * @param proj, la proyecci�n cartogr�fica
292
     * @param name, el path absoluto hasta el fichero DXF
293
     * @param maker, el interface que permite la construcci�n de las entidades procedentes del DXF
294
     */
295
	public DxfFile(IProjection proj, String name, EntityFactory maker) {
296
		super(proj, name);
297
		entityMaker = maker;
298
		headerManager = new DxfHeaderManager();
299
	}
300

  
301
    /**
302
     * Constructor de la clase que adem�s incorpora la capacidad de leer una porci�n del HEADER
303
     * @param proj, la proyecci�n cartogr�fica
304
     * @param name, el path absoluto hasta el fichero DXF
305
     * @param maker, el interface que permite la construcci�n de las entidades procedentes del DXF
306
     * @param dxfVars, el interface que permite la lectura del HEADER de un DXF
307
     */
308
    public DxfFile(IProjection proj, String name, EntityFactory maker, VarSettings dxfVars) {
309
		super(proj, name);
310
		entityMaker = maker;
311
		headerManager = dxfVars;
312
	}
313

  
314
	/**
315
	 * Carga un fichero en formato DXF
316
	 * @throws Exception
317
	 */
318
	public GeoFile load() throws Exception {
319
		logger.debug("Dxf: Cargando " + name + " ...");
320
		if (ZipFileFolder.isUrl(name)) {
321
			ZipFileFolder zFolder = new ZipFileFolder(name);
322
			InputStream is = zFolder.getInputStream(name);
323
			return load(new InputStreamReader(is));
324
		} else
325
			return load(new FileReader(name));
326

  
327
	}
328

  
329
    /**
330
     * Carga un fichero en formato DXF tomando un Reader como par�metro
331
     * @param fr, Reader que se le pasa como par�metro
332
     * @return devuelve un objeto GeoFile, padre de DxfFile
333
     * @throws Exception
334
     * @throws Exception
335
     */
336
	public GeoFile load(Reader fr) throws Exception {
337
		logger.debug("Dxf: Cargando '"+name+"' ...");
338
		fi = new BufferedReader(fr);
339
		while ((grp = readGrp()) != null) {
340
			l+=2;
341

  
342
			if (grp.equals(0, "EOF"))		break;
343
			if (grp.equals(0, "SECTION"))
344
				readSection();
345
		}
346
		fi.close();
347
		extent.add(entityMaker.getExtent());
348
		logger.debug("Dxf: '"+name+"' cargado. ("+l+" l�neas).");
349
		this.lineNr = l;
350
		return this;
351
	}
352

  
353
    /**
354
     * El fichero DXF se divide en grupos. Este m�todo permite leer cada grupo individualmente
355
     * @return devuelve la informaci�n del DXF en forma de objetos de la clase DxfGroup
356
     * @throws NumberFormatException
357
     * @throws IOException
358
     */
359
	private DxfGroup readGrp() throws NumberFormatException, IOException {
360
		DxfGroup g = DxfGroup.read(fi);
361
		if (g != null) l += 2;
362
		/*if (g.code == 8)
363
			if (((String) g.data).length() < 1) {
364
				logger.error("a que un layer no puede ser ''?");
365
				System.exit(1);
366
			}*/
367
		return g;
368
	}
369

  
370
    /**
371
     * El fichero DXF se divide en varias secciones. Este m�todo se encarga de leer cada
372
     * una de ellas
373
     * @throws NumberFormatException
374
     * @throws Exception
375
     */
376
	private void readSection() throws NumberFormatException, Exception {
377
		while (true) {
378
			grp = readGrp(); 
379
			logger.debug("-1:"+grp);
380
			if (grp.code == 2)
381
				if (((String) grp.data).compareTo("HEADER") == 0)
382
					readHeader();
383
				else if (((String) grp.data).compareTo("CLASSES") == 0)
384
					readAnySection();
385
				else if (((String) grp.data).compareTo("TABLES") == 0)
386
					readTables();
387
				else if (((String) grp.data).compareTo("BLOCKS") == 0)
388
					readBlocks();
389
				else if (((String) grp.data).compareTo("ENTITIES") == 0)
390
					readEntities();
391
				else if (((String) grp.data).compareTo("OBJECTS") == 0)
392
					readAnySection();
393
				else {
394
					logger.debug("DxfRead: Seccion "+grp.data);
395
					readAnySection();
396
				}
397
			else
398
				logger.debug("Dxf: Codigo/Seccion desconocidos" + grp);
399
			if (grp.equals(0, "EOF")) break;
400
			if (grp.equals(0, "ENDSEC")) break;
401
		}
402
	}
403

  
404
    /**
405
     * Habilita la lectura de la secci�n de TABLES
406
     * @throws NumberFormatException
407
     * @throws Exception
408
     */
409
	private void readTables() throws NumberFormatException, Exception {
410
		logger.debug("Dxf: Seccion TABLAS, linea "+ l+ "grp ="+ grp);
411
		int layerCnt = 0;
412
		String tableAct = "NONAME";
413

  
414
		Hashtable tables = new Hashtable();
415
		Vector table = new Vector();
416
		DxfGroupVector v = new DxfGroupVector();
417

  
418
		grp = readGrp();
419
		// logger.debug("0:"+grp);
420
		while (true) {
421
			if (grp.code == 0) {
422
				String data = (String) grp.getData();
423
				if (data.compareTo("ENDSEC") == 0 || data.compareTo("EOF") == 0)
424
					break;
425
				else if (data.compareTo("ENDTAB") == 0) {
426
					tables.put(tableAct, table);
427
					table = new Vector();
428
					grp = readGrp();
429
					// logger.debug("1:"+grp);
430

  
431
					/**/if (tableAct.compareTo("LAYER") == 0 && v.size()>0) {
432
						entityMaker.createLayer(v);
433
						logger.debug("Dxf: Layer "+v.getDataAsString(2));
434
						layerCnt++;
435
						v.clear();
436
					}/**/
437
					continue;
438
				} else {
439
					if (table.size()==1) {
440
						tableAct = v.getDataAsString(2);
441
						logger.debug("Dxf: Tabla "+tableAct);
442
					} else
443
						if (tableAct.compareTo("LAYER") == 0 && v.size()>0) {
444
							entityMaker.createLayer(v);
445
							logger.debug("Dxf: Layer "+v.getDataAsString(2));
446
							layerCnt++;
447
						}
448

  
449
					v.clear();
450
					v.add(grp);
451
				}
452
				while (true) {
453
					grp = readGrp();
454
					// logger.debug("2:"+grp);
455
					if (grp.code == 0)	break;
456
					v.add(grp);
457
				}
458
				table.add(v);
459
			} else {
460
				logger.debug("Dxf: Error de secuencia");
461
				grp = readGrp(); 
462
				//logger.debug("3:"+grp);
463
			}
464
		}
465
		logger.debug("Dxf: Seccion TABLAS: " + layerCnt + " Capas. ");
466
	}
467

  
468
    /**
469
     * M�todo de lectura de secci�n por defecto. Se utiliza mientras se realiza la
470
     * implementaci�n correspondiente
471
     * @throws NumberFormatException
472
     * @throws IOException
473
     */
474
	private void readAnySection() throws NumberFormatException, IOException {
475
		logger.debug("Dxf: Seccion '"+((String) grp.getData())+"', linea "+ l);
476
		while (true) {
477
			grp = readGrp();
478
			if (grp.equals(0, "ENDSEC")) break;
479
			else if (grp.equals(0, "EOF")) break;
480
		}
481
	}
482

  
483
	/**
484
	 * Primera aproximaci�n a la implementaci�n de la lectura del HEADER. En principio
485
	 * interesa que se lea la versi�n del DXF.
486
	 * Para implementar esta parte del lector se ha optado por incluir el m�todo
487
	 * setAcadVersion en el interface EntityFactory. A lo mejor conviene implementar
488
	 * un nuevo interface VarSettings.
489
	 * @throws NumberFormatException
490
	 * @throws Exception
491
	 */
492
	private void readHeader() throws NumberFormatException, Exception {
493
		logger.debug("Dxf: Seccion HEADER, linea "+ l);
494
		int variableCnt = 0;
495
		int cntVeces = 0;
496
		DxfGroupVector v = new DxfGroupVector();
497
		grp = readGrp();
498
		while (true) {
499
			if (grp.equals(0, "EOF")) {
500
				break;
501
			}
502
			else if (grp.code==9 || grp.code==0) {
503
				if (v.size() > 0) {
504
					String lastVariable = (String) ((DxfGroup) v.get(0)).data;
505
					//logger.debug(lastVariable);
506
					if (lastVariable.compareTo("$ACADVER") == 0) {
507
						//logger.debug("Aqui llega.");
508
						headerManager.setAcadVersion(v);
509
					} else if (lastVariable.compareTo("$EXTMIN") == 0) {
510
						if(v.hasCode(3))
511
							headerManager.loadMinZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue());
512
                    } else if (lastVariable.compareTo("$EXTMAX") == 0) {
513
                    	if(v.hasCode(3))
514
                    		headerManager.loadMaxZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue());
515
                    } else if (lastVariable.compareTo("ENDSEC") == 0) {
516
                        //logger.debug("Llega al ENDSEC.");
517
                        break;
518
					} /*else
519
						logger.debug("Dxf: Variable "+lastVariable+" desconocida.");*/
520
				}
521
				v.clear();
522
				v.add(grp);
523
				while (true) {
524
					grp = readGrp();
525
					if (grp.code == 9 || grp.code==0)	break;
526
					v.add(grp);
527
				}
528
				variableCnt++;
529
			}
530
			cntVeces++;
531
		}
532
		logger.debug("Dxf: Seccion HEADER, " + variableCnt + " variables, "+ cntVeces + " veces.");
533
		//logger.debug("Seccion HEADER, linea "+ l+ " (SALGO)");
534
		logger.debug("readHeader: ACAD Version: " + headerManager.getDxfHeaderVars().getAcadVersion());
535
	}
536

  
537
    /**
538
     * Permite leer la secci�n ENTITIES del DXF, donde se encuentran las entidades
539
     * geom�tricas del DXF que no aparecen dentro de ning�n bloque
540
     * @throws NumberFormatException
541
     * @throws Exception
542
     */
543
	private void readEntities() throws NumberFormatException, Exception {
544
		logger.debug("Dxf: Seccion ENTITIES, linea "+ l);
545
		int entityCnt = 0;
546
		int cntVeces = 0;
547
		DxfGroupVector v = new DxfGroupVector();
548
		grp = readGrp();
549
		while (true) {
550
			if (grp.equals(0, "EOF")) break;
551
			else if (grp.code == 0) {
552
				if (v.size() > 0) {
553
					String lastEntity = (String) ((DxfGroup) v.get(0)).data;
554
					if (lastEntity.compareTo("POLYLINE") == 0) {
555
						entityMaker.createPolyline(v);
556
					} else if (lastEntity.compareTo("VERTEX") == 0) {
557
						entityMaker.addVertex(v);
558
					} else if (lastEntity.compareTo("SEQEND") == 0) {
559
						entityMaker.endSeq();
560
					} else if (lastEntity.compareTo("LWPOLYLINE") == 0) {
561
						entityMaker.createLwPolyline(v);
562
					} else if (lastEntity.compareTo("LINE") == 0) {
563
						entityMaker.createLine(v);
564
					} else if (lastEntity.compareTo("TEXT") == 0) {
565
						entityMaker.createText(v);
566
					} else if (lastEntity.compareTo("MTEXT") == 0) {
567
						entityMaker.createMText(v);
568
					} else if (lastEntity.compareTo("POINT") == 0) {
569
						entityMaker.createPoint(v);
570
					} else if (lastEntity.compareTo("CIRCLE") == 0) {
571
						entityMaker.createCircle(v);
572
					} else if (lastEntity.compareTo("ELLIPSE") == 0) {
573
						entityMaker.createEllipse(v);
574
					} else if (lastEntity.compareTo("ARC") == 0) {
575
						entityMaker.createArc(v);
576
					} else if (lastEntity.compareTo("INSERT") == 0) {
577
						entityMaker.createInsert(v);
578
					} else if (lastEntity.compareTo("SOLID") == 0) {
579
						entityMaker.createSolid(v);
580
					} else if (lastEntity.compareTo("SPLINE") == 0) {
581
						entityMaker.createSpline(v);
582
					} else if (lastEntity.compareTo("ATTRIB") == 0) {
583
						entityMaker.createAttrib(v);
584
					} else if (lastEntity.compareTo("ENDSEC") == 0) {
585
						break;
586
					} else
587
						logger.debug("Dxf: Entidad "+lastEntity+" desconocida.");
588
				}
589
				v.clear();
590
				v.add(grp);
591
				while (true) {
592
					grp = readGrp();
593
					if (grp.code == 0)	break;
594
					v.add(grp);
595
				}
596
				entityCnt++;
597
			}
598
			cntVeces++;
599
		}
600
		logger.debug("Dxf: Seccion ENTITIES, " + entityCnt + " entidades, "+ cntVeces + " veces.");
601
		//logger.debug("Seccion ENTITIES, linea "+ l+ " (SALGO)");
602
	}
603

  
604
    /**
605
     * Permite la secci�n BLOCKS del DXF, donde se encuentran las definiciones de los
606
     * bloques que componen el DXF
607
     * @throws NumberFormatException
608
     * @throws Exception
609
     */
610
	private void readBlocks() throws NumberFormatException, Exception {
611
		logger.debug("Dxf: Seccion BLOCKS, linea "+ l);
612
		int blkCnt = 0;
613
		int cntVeces = 0;
614
		DxfGroupVector v = new DxfGroupVector();
615
		grp = readGrp();
616
		while (true) {
617
			if (grp.equals(0, "EOF")) break;
618
			else if (grp.code == 0) {
619
				if (v.size() > 0) {
620
					String lastEntity = (String) ((DxfGroup) v.get(0)).data;
621
					if (lastEntity.compareTo("BLOCK") == 0) {
622
						//logger.debug("readBlocks(): Empezamos a leer un bloque");
623
						entityMaker.createBlock(v);
624
					} else if (lastEntity.compareTo("POLYLINE") == 0) {
625
						//logger.debug("readBlocks(): A�adimos una polilinea al bloque");
626
						entityMaker.createPolyline(v);
627
					} else if (lastEntity.compareTo("VERTEX") == 0) {
628
						//logger.debug("readBlocks(): A�adimos un vertice a la polilinea");
629
						entityMaker.addVertex(v);
630
					} else if (lastEntity.compareTo("SEQEND") == 0) {
631
						//logger.debug("readBlocks(): Cerramos una polilinea");
632
						entityMaker.endSeq();
633
					} else if (lastEntity.compareTo("LWPOLYLINE") == 0) {
634
						//logger.debug("readBlocks(): A�adimos una lwpolilinea al bloque");
635
						entityMaker.createLwPolyline(v);
636
					} else if (lastEntity.compareTo("LINE") == 0) {
637
						//logger.debug("readBlocks(): A�adimos una linea al bloque");
638
						entityMaker.createLine(v);
639
					} else if (lastEntity.compareTo("TEXT") == 0) {
640
						//logger.debug("readBlocks(): A�adimos un texto al bloque");
641
						entityMaker.createText(v);
642
					} else if (lastEntity.compareTo("MTEXT") == 0) {
643
						//logger.debug("readBlocks(): A�adimos un m-texto al bloque");
644
						entityMaker.createMText(v);
645
					} else if (lastEntity.compareTo("POINT") == 0) {
646
						//logger.debug("readBlocks(): A�adimos un punto al bloque");
647
						entityMaker.createPoint(v);
648
					} else if (lastEntity.compareTo("CIRCLE") == 0) {
649
						//logger.debug("readBlocks(): A�adimos un circulo al bloque");
650
						entityMaker.createCircle(v);
651
					} else if (lastEntity.compareTo("ARC") == 0) {
652
						//logger.debug("readBlocks(): A�adimos un arco al bloque");
653
						entityMaker.createArc(v);
654
					} else if (lastEntity.compareTo("INSERT") == 0) {
655
						//logger.debug("readBlocks(): A�adimos un insert al bloque");
656
						entityMaker.createInsert(v);
657
					} else if (lastEntity.compareTo("SOLID") == 0) {
658
						//logger.debug("readBlocks(): A�adimos un solido al bloque");
659
						entityMaker.createSolid(v);
660
					} else if (lastEntity.compareTo("SPLINE") == 0) {
661
						entityMaker.createSpline(v);
662
					} else if (lastEntity.compareTo("ATTDEF") == 0) {
663
						entityMaker.createAttdef(v);
664
					} else if (lastEntity.compareTo("ENDBLK") == 0) {
665
						//logger.debug("readBlocks(): Cerramos un bloque"+v);
666
						entityMaker.endBlk(v);
667
					} else if (lastEntity.compareTo("ENDSEC") == 0) {
668
						break;
669
					} else
670
						logger.debug("Dxf: Entidad de bloque "+lastEntity+" desconocida.");
671
				}
672
				v.clear();
673
				v.add(grp);
674
				while (true) {
675
					grp = readGrp();
676
					if (grp.code == 0)	break;
677
					v.add(grp);
678
				}
679
				blkCnt++;
680
			}
681
			cntVeces++;
682
		}
683

  
684
		entityMaker.testBlocks();
685
		// Cuando termina de leer la secci�n de bloques se asegura de que todos los campos
686
		// son distintos.
687
		//logger.debug("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size());
688
		entityMaker.depureAttributes();
689
		//logger.debug("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size());
690
		logger.debug("Dxf: Seccion BLOCKS, " + blkCnt + " elementos de bloque. "+ cntVeces + " veces.");
691
	}
692

  
693
    /**
694
     * Devuelve los objetos geom�tricos obtenidos de un DXF
695
     */
696
	public IObjList getObjects() {
697
		return this.entityMaker.getObjects();
698
	}
699

  
700
	/**
701
	 * jmorell: M�todo que permite salvar capas al formato DXF2000.
702
	 * Este m�todo ha sido actualizado en el proceso de implementaci�n del piloto
703
	 * de CAD. En este piloto deb�a existir soporte para elipses, y este es uno de
704
	 * los motivos que nos llevan a implementar ahora para DXF2000, puesto que el
705
	 * DXF R12 no soporta elipses.
706
	 * @param fName
707
	 * @throws IOException
708
	 */
709
	public void save(String fName) throws IOException {
710
		logger.debug("save: fName = " + fName);
711
		long t2, t1;
712
		t1 = getTime();
713
		fName = DataSource.normalize(fName);
714
		FileWriter fw = new FileWriter(fName);
715
		// COMMENTAIRES DU TRADUCTEUR
716
//		fw.write(DxfGroup.toString(999, Integer.toString(features.size()) + " features"));
717
		fw.write(DxfGroup.toString(999, "TRANSLATION BY geo.cresques.io.DxfFile"));
718
		fw.write(DxfGroup.toString(999, "DATE : " + (new Date()).toString()));
719
		writeHeader(fw);
720
		writeTables(fw);
721
		writeBlocks(fw);
722
		writeEntities(fw);
723
		writeObjects(fw);
724
		fw.write(DxfGroup.toString(0, "EOF"));
725
		fw.flush();
726
		fw.close();
727
		t2 = getTime();
728
		logger.debug("DxfFile.save(): Tiempo salvando: " + (t2-t1)/1000 + " seg.");
729
	}
730

  
731
	/**
732
	 * Escritor de la cabecera de un DXF.
733
	 * jmorell: Actualizaci�n del escritor de DXF de R12 a 2000.
734
	 * @param fw, un FileWriter para escribir ficheros
735
	 * @throws IOException
736
	 */
737
	public void writeHeader(FileWriter fw) throws IOException {
738
		fw.write(DxfGroup.toString(0, "SECTION"));
739
		fw.write(DxfGroup.toString(2, "HEADER"));
740
		fw.write(DxfGroup.toString(9, "$ACADVER"));
741
			//fw.write(DxfGroup.toString(1, "AC1009"));			// DXF R12
742
			fw.write(DxfGroup.toString(1, "AC1015"));			// DXF 2000
743
		fw.write(DxfGroup.toString(9, "$INSBASE"));
744
			fw.write(DxfGroup.toString(10, 0.0, 1));
745
			fw.write(DxfGroup.toString(20, 0.0, 1));
746
			fw.write(DxfGroup.toString(30, 0.0, 1));
747
		fw.write(DxfGroup.toString(9, "$EXTMIN"));
748
			fw.write(DxfGroup.toString(10, extent.minX(), 6));
749
			fw.write(DxfGroup.toString(20, extent.minY(), 6));
750
			if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.minX(), 6));
751
            else fw.write(DxfGroup.toString(30, 0.0, 6));
752
		fw.write(DxfGroup.toString(9, "$EXTMAX"));
753
			fw.write(DxfGroup.toString(10, extent.maxX(), 6));
754
			fw.write(DxfGroup.toString(20, extent.maxY(), 6));
755
            if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.maxX(), 6));
756
            else fw.write(DxfGroup.toString(30, 0.0, 6));
757
		fw.write(DxfGroup.toString(9, "$LIMMIN"));
758
			fw.write(DxfGroup.toString(10, extent.minX(), 6));
759
			fw.write(DxfGroup.toString(20, extent.minY(), 6));
760
		fw.write(DxfGroup.toString(9, "$LIMMAX"));
761
			fw.write(DxfGroup.toString(10, extent.maxX(), 6));
762
			fw.write(DxfGroup.toString(20, extent.maxY(), 6));
763
		fw.write(DxfGroup.toString(9, "$ORTHOMODE")+DxfGroup.toString(70, 0));
764
		fw.write(DxfGroup.toString(9, "$REGENMODE")+DxfGroup.toString(70, 1));
765
		fw.write(DxfGroup.toString(9, "$FILLMODE")+	DxfGroup.toString(70, 1));
766
		fw.write(DxfGroup.toString(9, "$QTEXTMODE")+DxfGroup.toString(70, 0));
767
		fw.write(DxfGroup.toString(9, "$MIRRTEXT")+	DxfGroup.toString(70, 1));
768
		fw.write(DxfGroup.toString(9, "$DRAGMODE")+	DxfGroup.toString(70, 2));
769
		fw.write(DxfGroup.toString(9, "$LTSCALE")+	DxfGroup.toString(40, 1.0, 1));
770
		fw.write(DxfGroup.toString(9, "$OSMODE")+	DxfGroup.toString(70, 0));
771
		fw.write(DxfGroup.toString(9, "$ATTMODE")+	DxfGroup.toString(70, 1));
772
		fw.write(DxfGroup.toString(9, "$TEXTSIZE")+	DxfGroup.toString(40, 0.2, 1));
773
		fw.write(DxfGroup.toString(9, "$TRACEWID")+	DxfGroup.toString(40, 0.05, 2));
774
		fw.write(DxfGroup.toString(9, "$TEXTSTYLE")+	DxfGroup.toString(7, "STANDARD"));
775
		fw.write(DxfGroup.toString(9, "$CLAYER")+	DxfGroup.toString(8, "0"));
776
		fw.write(DxfGroup.toString(9, "$CELTYPE")+	DxfGroup.toString(6, "CONTINUOUS"));
777
		fw.write(DxfGroup.toString(9, "$CECOLOR")+	DxfGroup.toString(62, 256));
778
		fw.write(DxfGroup.toString(9, "$DIMSCALE")+	DxfGroup.toString(40, 1.0, 1));
779
		fw.write(DxfGroup.toString(9, "$DIMASZ")+	DxfGroup.toString(40, 0.18, 2));
780
		fw.write(DxfGroup.toString(9, "$DIMEXO")+	DxfGroup.toString(40, 0.0625, 4));
781
		fw.write(DxfGroup.toString(9, "$DIMDLI")+	DxfGroup.toString(40, 0.38, 2));
782
		fw.write(DxfGroup.toString(9, "$DIMRND")+	DxfGroup.toString(40, 0.0, 1));
783
		fw.write(DxfGroup.toString(9, "$DIMDLE")+	DxfGroup.toString(40, 0.0, 1));
784
		fw.write(DxfGroup.toString(9, "$DIMEXE")+	DxfGroup.toString(40, 0.18, 2));
785
		fw.write(DxfGroup.toString(9, "$DIMTP")+	DxfGroup.toString(40, 0.0, 1));
786
		fw.write(DxfGroup.toString(9, "$DIMTM")+	DxfGroup.toString(40, 0.0, 1));
787
		fw.write(DxfGroup.toString(9, "$DIMTXT")+	DxfGroup.toString(40, 0.18, 2));
788
		fw.write(DxfGroup.toString(9, "$DIMCEN")+	DxfGroup.toString(40, 0.09, 2));
789
		fw.write(DxfGroup.toString(9, "$DIMTSZ")+	DxfGroup.toString(40, 0.0, 1));
790
		fw.write(DxfGroup.toString(9,"$DIMTOL")+	DxfGroup.toString(70,0));
791
		fw.write(DxfGroup.toString(9,"$DIMLIM")+	DxfGroup.toString(70,0));
792
		fw.write(DxfGroup.toString(9,"$DIMTIH")+	DxfGroup.toString(70,1));
793
		fw.write(DxfGroup.toString(9,"$DIMTOH")+	DxfGroup.toString(70,1));
794
		fw.write(DxfGroup.toString(9,"$DIMSE1")+	DxfGroup.toString(70,0));
795
		fw.write(DxfGroup.toString(9,"$DIMSE2")+	DxfGroup.toString(70,0));
796
		fw.write(DxfGroup.toString(9,"$DIMTAD")+	DxfGroup.toString(70,0));
797
		fw.write(DxfGroup.toString(9,"$DIMZIN")+	DxfGroup.toString(70,0));
798
		fw.write(DxfGroup.toString(9,"$DIMBLK")+	DxfGroup.toString(1,""));
799
		fw.write(DxfGroup.toString(9,"$DIMASO")+	DxfGroup.toString(70,1));
800
		fw.write(DxfGroup.toString(9,"$DIMSHO")+	DxfGroup.toString(70,1));
801
		fw.write(DxfGroup.toString(9,"$DIMPOST")+	DxfGroup.toString(1,""));
802
		fw.write(DxfGroup.toString(9,"$DIMAPOST")+	DxfGroup.toString(1,""));
803
		fw.write(DxfGroup.toString(9,"$DIMALT")+	DxfGroup.toString(70,0));
804
		fw.write(DxfGroup.toString(9,"$DIMALTD")+	DxfGroup.toString(70,2));
805
		fw.write(DxfGroup.toString(9,"$DIMALTF")+	DxfGroup.toString(40,25.4,1));
806
		fw.write(DxfGroup.toString(9,"$DIMLFAC")+	DxfGroup.toString(40,1.0,1));
807
		fw.write(DxfGroup.toString(9,"$DIMTOFL")+	DxfGroup.toString(70,0));
808
		fw.write(DxfGroup.toString(9,"$DIMTVP")+	DxfGroup.toString(40,0.0,1));
809
		fw.write(DxfGroup.toString(9,"$DIMTIX")+	DxfGroup.toString(70,0));
810
		fw.write(DxfGroup.toString(9,"$DIMSOXD")+	DxfGroup.toString(70,0));
811
		fw.write(DxfGroup.toString(9,"$DIMSAH")+	DxfGroup.toString(70,0));
812
		fw.write(DxfGroup.toString(9,"$DIMBLK1")+	DxfGroup.toString(1,""));
813
		fw.write(DxfGroup.toString(9,"$DIMBLK2")+	DxfGroup.toString(1,""));
814
		fw.write(DxfGroup.toString(9,"$DIMSTYLE")+	DxfGroup.toString(2,"STANDARD"));
815
		fw.write(DxfGroup.toString(9,"$DIMCLRD")+	DxfGroup.toString(70,0));
816
		fw.write(DxfGroup.toString(9,"$DIMCLRE")+	DxfGroup.toString(70,0));
817
		fw.write(DxfGroup.toString(9,"$DIMCLRT")+	DxfGroup.toString(70,0));
818
		fw.write(DxfGroup.toString(9,"$DIMTFAC")+	DxfGroup.toString(40,1.0,1));
819
		fw.write(DxfGroup.toString(9,"$DIMGAP")+	DxfGroup.toString(40,0.09,2));
820
		fw.write(DxfGroup.toString(9,"$LUNITS")+	DxfGroup.toString(70,2));
821
		fw.write(DxfGroup.toString(9,"$LUPREC")+	DxfGroup.toString(70,4));
822
		fw.write(DxfGroup.toString(9,"$AXISMODE")+	DxfGroup.toString(70,0));
823
		fw.write(DxfGroup.toString(9,"$AXISUNIT"));
824
		fw.write(DxfGroup.toString(10,0.0,1));
825
		fw.write(DxfGroup.toString(20,0.0,1));
826
		fw.write(DxfGroup.toString(9,"$SKETCHINC")+	DxfGroup.toString(40,0.1,1));
827
		fw.write(DxfGroup.toString(9,"$FILLETRAD")+	DxfGroup.toString(40,0.0,1));
828
		fw.write(DxfGroup.toString(9,"$AUNITS")+	DxfGroup.toString(70,0));
829
		fw.write(DxfGroup.toString(9,"$AUPREC")+	DxfGroup.toString(70,0));
830
		fw.write(DxfGroup.toString(9,"$MENU")+		DxfGroup.toString(1,"acad"));
831
		fw.write(DxfGroup.toString(9,"$ELEVATION")+	DxfGroup.toString(40,0.0,1));
832
		fw.write(DxfGroup.toString(9,"$PELEVATION")+DxfGroup.toString(40,0.0,1));
833
		fw.write(DxfGroup.toString(9,"$THICKNESS")+	DxfGroup.toString(40,0.0,1));
834
		fw.write(DxfGroup.toString(9,"$LIMCHECK")+	DxfGroup.toString(70,0));
835
		fw.write(DxfGroup.toString(9,"$BLIPMODE")+	DxfGroup.toString(70,1));
836
		fw.write(DxfGroup.toString(9,"$CHAMFERA")+	DxfGroup.toString(40,0.0,1));
837
		fw.write(DxfGroup.toString(9,"$CHAMFERB")+	DxfGroup.toString(40,0.0,1));
838
		fw.write(DxfGroup.toString(9,"$SKPOLY")+	DxfGroup.toString(70,0));
839
		fw.write(DxfGroup.toString(9,"$TDCREATE")+	DxfGroup.toString(40,2453116.436828704,9));
840
		fw.write(DxfGroup.toString(9,"$TDUPDATE")+	DxfGroup.toString(40,2453116.436828704,9));
841
		fw.write(DxfGroup.toString(9,"$TDINDWG")+	DxfGroup.toString(40,0.0000000000,10));
842
		fw.write(DxfGroup.toString(9,"$TDUSRTIMER")+DxfGroup.toString(40,0.0000000000,10));
843
		fw.write(DxfGroup.toString(9,"$USRTIMER")+	DxfGroup.toString(70,1));
844
		fw.write(DxfGroup.toString(9,"$ANGBASE")+	DxfGroup.toString(50,0.0,1));
845
		fw.write(DxfGroup.toString(9,"$ANGDIR")+	DxfGroup.toString(70,0));
846
		fw.write(DxfGroup.toString(9,"$PDMODE")+	DxfGroup.toString(70,0));
847
		fw.write(DxfGroup.toString(9,"$PDSIZE")+	DxfGroup.toString(40,0.0,1));
848
		fw.write(DxfGroup.toString(9,"$PLINEWID")+	DxfGroup.toString(40,0.0,1));
849
		fw.write(DxfGroup.toString(9,"$COORDS")+	DxfGroup.toString(70,0));
850
		fw.write(DxfGroup.toString(9,"$SPLFRAME")+	DxfGroup.toString(70,0));
851
		fw.write(DxfGroup.toString(9,"$SPLINETYPE")+DxfGroup.toString(70,6));
852
		fw.write(DxfGroup.toString(9,"$SPLINESEGS")+DxfGroup.toString(70,10));
853
		fw.write(DxfGroup.toString(9,"$ATTDIA")+	DxfGroup.toString(70,0));
854
		fw.write(DxfGroup.toString(9,"$ATTREQ")+	DxfGroup.toString(70,1));
855
		fw.write(DxfGroup.toString(9,"$HANDLING")+	DxfGroup.toString(70,1));
856
		fw.write(DxfGroup.toString(9,"$HANDSEED")+	DxfGroup.toString(5,"394B"));
857
		fw.write(DxfGroup.toString(9,"$SURFTAB1")+	DxfGroup.toString(70,6));
858
		fw.write(DxfGroup.toString(9,"$SURFTAB2")+	DxfGroup.toString(70,6));
859
		fw.write(DxfGroup.toString(9,"$SURFTYPE")+	DxfGroup.toString(70,6));
860
		fw.write(DxfGroup.toString(9,"$SURFU")+		DxfGroup.toString(70,6));
861
		fw.write(DxfGroup.toString(9,"$SURFV")+		DxfGroup.toString(70,6));
862
		fw.write(DxfGroup.toString(9,"$UCSNAME")+	DxfGroup.toString(2,""));
863
		fw.write(DxfGroup.toString(9,"$UCSORG"));
864
		fw.write(DxfGroup.toString(10,0.0,1));
865
		fw.write(DxfGroup.toString(20,0.0,1));
866
		fw.write(DxfGroup.toString(30,0.0,1));
867
		fw.write(DxfGroup.toString(9,"$UCSXDIR"));
868
		fw.write(DxfGroup.toString(10,1.0,1));
869
		fw.write(DxfGroup.toString(20,0.0,1));
870
		fw.write(DxfGroup.toString(30,0.0,1));
871
		fw.write(DxfGroup.toString(9,"$UCSYDIR"));
872
		fw.write(DxfGroup.toString(10,0.0,1));
873
		fw.write(DxfGroup.toString(20,1.0,1));
874
		fw.write(DxfGroup.toString(30,0.0,1));
875
		fw.write(DxfGroup.toString(9,"$PUCSNAME")+	DxfGroup.toString(2,""));
876
		fw.write(DxfGroup.toString(9,"$PUCSORG"));
877
		fw.write(DxfGroup.toString(10,0.0,1));
878
		fw.write(DxfGroup.toString(20,0.0,1));
879
		fw.write(DxfGroup.toString(30,0.0,1));
880
		fw.write(DxfGroup.toString(9,"$PUCSXDIR"));
881
		fw.write(DxfGroup.toString(10,1.0,1));
882
		fw.write(DxfGroup.toString(20,0.0,1));
883
		fw.write(DxfGroup.toString(30,0.0,1));
884
		fw.write(DxfGroup.toString(9,"$PUCSYDIR"));
885
		fw.write(DxfGroup.toString(10,0.0,1));
886
		fw.write(DxfGroup.toString(20,1.0,1));
887
		fw.write(DxfGroup.toString(30,0.0,1));
888
		fw.write(DxfGroup.toString(9,"$USERI1")+	DxfGroup.toString(70,0));
889
		fw.write(DxfGroup.toString(9,"$USERI2")+	DxfGroup.toString(70,0));
890
		fw.write(DxfGroup.toString(9,"$USERI3")+	DxfGroup.toString(70,0));
891
		fw.write(DxfGroup.toString(9,"$USERI4")+	DxfGroup.toString(70,0));
892
		fw.write(DxfGroup.toString(9,"$USERI5")+	DxfGroup.toString(70,0));
893
		fw.write(DxfGroup.toString(9,"$USERR1")+	DxfGroup.toString(40,0.0,1));
894
		fw.write(DxfGroup.toString(9,"$USERR2")+	DxfGroup.toString(40,0.0,1));
895
		fw.write(DxfGroup.toString(9,"$USERR3")+	DxfGroup.toString(40,0.0,1));
896
		fw.write(DxfGroup.toString(9,"$USERR4")+	DxfGroup.toString(40,0.0,1));
897
		fw.write(DxfGroup.toString(9,"$USERR5")+	DxfGroup.toString(40,0.0,1));
898
		fw.write(DxfGroup.toString(9,"$WORLDVIEW")+	DxfGroup.toString(70,1));
899
		fw.write(DxfGroup.toString(9,"$SHADEDGE")+	DxfGroup.toString(70,3));
900
		fw.write(DxfGroup.toString(9,"$SHADEDIF")+	DxfGroup.toString(70,70));
901
		fw.write(DxfGroup.toString(9,"$TILEMODE")+	DxfGroup.toString(70,1));
902
		fw.write(DxfGroup.toString(9,"$MAXACTVP")+	DxfGroup.toString(70,16));
903
		fw.write(DxfGroup.toString(9,"$PINSBASE"));
904
		fw.write(DxfGroup.toString(10,0.0,1));
905
		fw.write(DxfGroup.toString(20,0.0,1));
906
		fw.write(DxfGroup.toString(30,0.0,1));
907
		fw.write(DxfGroup.toString(9,"$PLIMCHECK")+	DxfGroup.toString(70,0));
908
		fw.write(DxfGroup.toString(9,"$PEXTMIN"));
909
		fw.write(DxfGroup.toString(10,"-1.000000E+20"));
910
		fw.write(DxfGroup.toString(20,"-1.000000E+20"));
911
		fw.write(DxfGroup.toString(30,"-1.000000E+20"));
912
		fw.write(DxfGroup.toString(9,"$PEXTMAX"));
913
		fw.write(DxfGroup.toString(10,"-1.000000E+20"));
914
		fw.write(DxfGroup.toString(20,"-1.000000E+20"));
915
		fw.write(DxfGroup.toString(30,"-1.000000E+20"));
916
		fw.write(DxfGroup.toString(9,"$PLIMMIN"));
917
		fw.write(DxfGroup.toString(10,0.0,1));
918
		fw.write(DxfGroup.toString(20,0.0,1));
919
		fw.write(DxfGroup.toString(9,"$PLIMMAX"));
920
		fw.write(DxfGroup.toString(10,12.0,1));
921
		fw.write(DxfGroup.toString(20,9.0,1));
922
		fw.write(DxfGroup.toString(9,"$UNITMODE")+	DxfGroup.toString(70,0));
923
		fw.write(DxfGroup.toString(9,"$VISRETAIN")+	DxfGroup.toString(70,0));
924
		fw.write(DxfGroup.toString(9,"$PLINEGEN")+	DxfGroup.toString(70,1));
925
		fw.write(DxfGroup.toString(9,"$PSLTSCALE")+	DxfGroup.toString(70,0));
926
		fw.write(DxfGroup.toString(9,"$TREEDEPTH")+	DxfGroup.toString(70,3020));
927
		fw.write(DxfGroup.toString(9,"$DWGCODEPAGE")+DxfGroup.toString(3,"ansi_1252"));
928
/*
929
		fw.write(DxfGroup.toString(9, "$ELEVATION"));
930
			fw.write(DxfGroup.toString(40, 0.0, 3));
931
		fw.write(DxfGroup.toString(9, "$LIMCHECK"));
932
			fw.write(DxfGroup.toString(70, 1));
933
		fw.write(DxfGroup.toString(9, "$LUNITS"));
934
			fw.write(DxfGroup.toString(70, 2));
935
		fw.write(DxfGroup.toString(9, "$LUPREC"));
936
			fw.write(DxfGroup.toString(70, 2));*/
937
		fw.write(DxfGroup.toString(0, "ENDSEC"));
938
	}
939

  
940
	/**
941
	 * Escritor de la secci�n TABLES de un DXF.
942
	 * @param fw, FileWriter
943
	 * @throws IOException
944
	 */
945
	public void writeTables(FileWriter fw) throws IOException {
946
		fw.write(DxfGroup.toString(0, "SECTION"));
947
		fw.write(DxfGroup.toString(2, "TABLES"));
948
		// esta tampoco.
949
		writeVPortTable(fw);
950
		writeLTypeTable(fw);
951
		writeLayerTable(fw);
952
		writeStyleTable(fw);
953
		// estas no son las provocan el pete.
954
		writeViewTable(fw);
955
		writeUCSTable(fw);
956
		// esta provoca el pete. Y si no se pone las tablas aparecen
957
		// incompletas y acad no abre el fichero ...
958
		writeAppidTable(fw);
959
		writeDimStyleTable(fw);
960
		// esta no provoca pete.
961
		writeBlockRecordTable(fw);
962
		fw.write(DxfGroup.toString(0, "ENDSEC"));
963
	}
964

  
965
	/**
966
	 * Escritor de la tabla VPORT.
967
	 * @param fw
968
	 * @throws IOException
969
	 */
970
	public void writeVPortTable(FileWriter fw) throws IOException {
971
		fw.write(DxfGroup.toString(0, "TABLE"));
972
		fw.write(DxfGroup.toString(2, "VPORT"));
973
		fw.write(DxfGroup.toString(5, 8));
974
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
975
		fw.write(DxfGroup.toString(70, 0));
976
		/*fw.write(DxfGroup.toString(70, 1));
977
		fw.write(DxfGroup.toString(0, "VPORT"));
978
		fw.write(DxfGroup.toString(5, 30));
979
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
980
		fw.write(DxfGroup.toString(100, "AcDbViewportTableRecord"));
981
		fw.write(DxfGroup.toString(2, "*Active"));
982
		fw.write(DxfGroup.toString(70, 0));
983
		fw.write(DxfGroup.toString(10, 0.0, 4));
984
		fw.write(DxfGroup.toString(20, 0.0, 4));
985
		fw.write(DxfGroup.toString(11, 1.0, 4));
986
		fw.write(DxfGroup.toString(21, 1.0, 4));
987
		fw.write(DxfGroup.toString(12, 286.30555555555549, 10));
988
		fw.write(DxfGroup.toString(22, 148.5, 4));
989
		fw.write(DxfGroup.toString(13, 0.0, 4));
990
		fw.write(DxfGroup.toString(23, 0.0, 4));
991
		fw.write(DxfGroup.toString(14, 10.0, 4));
992
		fw.write(DxfGroup.toString(24, 10.0, 4));
993
		fw.write(DxfGroup.toString(15, 10.0, 4));
994
		fw.write(DxfGroup.toString(25, 10.0, 4));
995
		fw.write(DxfGroup.toString(16, 0.0, 4));
996
		fw.write(DxfGroup.toString(26, 0.0, 4));
997
		fw.write(DxfGroup.toString(36, 1.0, 4));
998
		fw.write(DxfGroup.toString(17, 0.0, 4));
999
		fw.write(DxfGroup.toString(27, 0.0, 4));
1000
		fw.write(DxfGroup.toString(37, 0.0, 4));
1001
		fw.write(DxfGroup.toString(40, 297.0, 4));
1002
		fw.write(DxfGroup.toString(41, 1.92798353909465, 10));
1003
		fw.write(DxfGroup.toString(42, 50.0, 4));
1004
		fw.write(DxfGroup.toString(43, 0.0, 4));
1005
		fw.write(DxfGroup.toString(44, 0.0, 4));
1006
		fw.write(DxfGroup.toString(50, 0.0, 4));
1007
		fw.write(DxfGroup.toString(51, 0.0, 4));
1008
		fw.write(DxfGroup.toString(71, 0));
1009
		fw.write(DxfGroup.toString(72, 100));
1010
		fw.write(DxfGroup.toString(73, 1));
1011
		fw.write(DxfGroup.toString(74, 3));
1012
		fw.write(DxfGroup.toString(75, 1));
1013
		fw.write(DxfGroup.toString(76, 1));
1014
		fw.write(DxfGroup.toString(77, 0));
1015
		fw.write(DxfGroup.toString(78, 0));
1016
		fw.write(DxfGroup.toString(281, 0));
1017
		fw.write(DxfGroup.toString(65, 1));
1018
		fw.write(DxfGroup.toString(110, 0.0, 4));
1019
		fw.write(DxfGroup.toString(120, 0.0, 4));
1020
		fw.write(DxfGroup.toString(130, 0.0, 4));
1021
		fw.write(DxfGroup.toString(111, 1.0, 4));
1022
		fw.write(DxfGroup.toString(121, 0.0, 4));
1023
		fw.write(DxfGroup.toString(131, 0.0, 4));
1024
		fw.write(DxfGroup.toString(112, 0.0, 4));
1025
		fw.write(DxfGroup.toString(122, 1.0, 4));
1026
		fw.write(DxfGroup.toString(132, 0.0, 4));
1027
		fw.write(DxfGroup.toString(79, 0));
1028
		fw.write(DxfGroup.toString(146, 0.0, 4));*/
1029
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1030
	}
1031

  
1032
	/**
1033
	 * Escritor de la tabla LTYPE.
1034
	 * @param fw
1035
	 * @throws IOException
1036
	 */
1037
	public void writeLTypeTable(FileWriter fw) throws IOException {
1038
		fw.write(DxfGroup.toString(0, "TABLE"));
1039
		fw.write(DxfGroup.toString(2, "LTYPE"));
1040
		fw.write(DxfGroup.toString(5, 5));
1041
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1042
		fw.write(DxfGroup.toString(70, 1));
1043
		// Aqui hay que crear un objeto DxfLType como el DxfLayer tambi�n basado en
1044
		// el lector de DXF de Mich.
1045
		/*DxfTABLE_LTYPE_ITEM ltype =
1046
			new DxfTABLE_LTYPE_ITEM("CONTINUE", 0, "", 65, 0f, new float[0]);
1047
		fw.write(ltype.toString());*/
1048
		fw.write(DxfGroup.toString(0, "LTYPE"));
1049
		fw.write(DxfGroup.toString(5, 14));
1050
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1051
		fw.write(DxfGroup.toString(100, "AcDbLinetypeTableRecord"));
1052
		fw.write(DxfGroup.toString(2, "ByBlock"));
1053
		fw.write(DxfGroup.toString(70, 0));
1054
		fw.write(DxfGroup.toString(3, ""));
1055
		fw.write(DxfGroup.toString(72, 65));
1056
		fw.write(DxfGroup.toString(73, 0));
1057
		fw.write(DxfGroup.toString(40, 0.0, 4));
1058
		fw.write(DxfGroup.toString(0, "LTYPE"));
1059
		fw.write(DxfGroup.toString(5, 15));
1060
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1061
		fw.write(DxfGroup.toString(100, "AcDbLinetypeTableRecord"));
1062
		fw.write(DxfGroup.toString(2, "ByLayer"));
1063
		fw.write(DxfGroup.toString(70, 0));
1064
		fw.write(DxfGroup.toString(3, ""));
1065
		fw.write(DxfGroup.toString(72, 65));
1066
		fw.write(DxfGroup.toString(73, 0));
1067
		fw.write(DxfGroup.toString(40, 0.0, 4));
1068
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1069
	}
1070

  
1071
	/**
1072
	 * Escritor de la tabla LAYER.
1073
	 * @param fw
1074
	 * @throws IOException
1075
	 */
1076
	public void writeLayerTable(FileWriter fw) throws IOException {
1077
		fw.write(DxfGroup.toString(0, "TABLE"));
1078
		fw.write(DxfGroup.toString(2, "LAYER"));
1079
		fw.write(DxfGroup.toString(5, 2));
1080
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1081
		fw.write(DxfGroup.toString(70, 1));
1082
		//layer = new DxfLayer(layerName, 0, 131, "CONTINUOUS");
1083
		//fw.write(layer.toString());
1084
		//fw.write(((DxfEntityMaker) entityMaker).getLayers().toDxfString());
1085
		fw.write(DxfGroup.toString(0, "LAYER"));
1086
		fw.write(DxfGroup.toString(5, 10));
1087
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1088
		fw.write(DxfGroup.toString(100, "AcDbLayerTableRecord"));
1089
		fw.write(DxfGroup.toString(2, "0"));
1090
		fw.write(DxfGroup.toString(70, 0));
1091
		fw.write(DxfGroup.toString(62, 7));
1092
		fw.write(DxfGroup.toString(6, "CONTINUOUS"));
1093
		fw.write(DxfGroup.toString(390, "F"));
1094
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1095
	}
1096

  
1097
	/**
1098
	 * Escritor de la tabla STYLE.
1099
	 * @param fw
1100
	 * @throws IOException
1101
	 */
1102
	public void writeStyleTable(FileWriter fw) throws IOException {
1103
		fw.write(DxfGroup.toString(0, "TABLE"));
1104
		fw.write(DxfGroup.toString(2, "STYLE"));
1105
		fw.write(DxfGroup.toString(5, 3));
1106
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1107
		fw.write(DxfGroup.toString(70, 0));
1108
		/*fw.write(DxfGroup.toString(70, 1));
1109
		DxfTABLE_STYLE_ITEM style =
1110
			new DxfTABLE_STYLE_ITEM("STANDARD", 0, 0f, 1f, 0f, 0, 1.0f, "xxx.txt", "yyy.txt");
1111
		fw.write(style.toString());*/
1112
		fw.write(DxfGroup.toString(0, "STYLE"));
1113
		fw.write(DxfGroup.toString(5, 11));
1114
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1115
		fw.write(DxfGroup.toString(100, "AcDbTextStyleTableRecord"));
1116
		fw.write(DxfGroup.toString(2, "Standard"));
1117
		fw.write(DxfGroup.toString(70, 0));
1118
		fw.write(DxfGroup.toString(71, 0));
1119
		fw.write(DxfGroup.toString(40, 0.0, 4));
1120
		fw.write(DxfGroup.toString(41, 1.0, 4));
1121
		fw.write(DxfGroup.toString(42, 2.5, 4));
1122
		fw.write(DxfGroup.toString(50, 0.0, 4));
1123
		fw.write(DxfGroup.toString(3, "txt"));
1124
		fw.write(DxfGroup.toString(4, ""));
1125
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1126
	}
1127

  
1128
	/**
1129
	 * Escritor de la tabla VIEW.
1130
	 * @param fw
1131
	 * @throws IOException
1132
	 */
1133
	public void writeViewTable(FileWriter fw) throws IOException {
1134
		fw.write(DxfGroup.toString(0, "TABLE"));
1135
		fw.write(DxfGroup.toString(2, "VIEW"));
1136
		fw.write(DxfGroup.toString(5, 6));
1137
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1138
		fw.write(DxfGroup.toString(70, 0));
1139
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1140
	}
1141

  
1142
	/**
1143
	 * Escritor de la tabla UCS.
1144
	 * @param fw
1145
	 * @throws IOException
1146
	 */
1147
	public void writeUCSTable(FileWriter fw) throws IOException {
1148
		fw.write(DxfGroup.toString(0, "TABLE"));
1149
		fw.write(DxfGroup.toString(2, "UCS"));
1150
		fw.write(DxfGroup.toString(5, 7));
1151
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1152
		fw.write(DxfGroup.toString(70, 0));
1153
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1154
	}
1155

  
1156
	/**
1157
	 * Escritor de la tabla APPID.
1158
	 * @param fw
1159
	 * @throws IOException
1160
	 */
1161
	public void writeAppidTable(FileWriter fw) throws IOException {
1162
		fw.write(DxfGroup.toString(0, "TABLE"));
1163
		fw.write(DxfGroup.toString(2, "APPID"));
1164
		fw.write(DxfGroup.toString(5, 9));
1165
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1166
		fw.write(DxfGroup.toString(70, 1));
1167
		fw.write(DxfGroup.toString(0, "APPID"));
1168
		fw.write(DxfGroup.toString(5, 12));
1169
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1170
		fw.write(DxfGroup.toString(100, "AcDbRegAppTableRecord"));
1171
		fw.write(DxfGroup.toString(2, "ACAD"));
1172
		fw.write(DxfGroup.toString(70, 1));
1173
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1174
	}
1175

  
1176
	/**
1177
	 * Escritor de la tabla DIMSTYLE.
1178
	 * @param fw
1179
	 * @throws IOException
1180
	 */
1181
	public void writeDimStyleTable(FileWriter fw) throws IOException {
1182
		fw.write(DxfGroup.toString(0, "TABLE"));
1183
		fw.write(DxfGroup.toString(2, "DIMSTYLE"));
1184
		fw.write(DxfGroup.toString(5, "A"));
1185
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1186
		fw.write(DxfGroup.toString(70, 0));
1187
		fw.write(DxfGroup.toString(100, "AcDbDimStyleTable"));
1188
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1189
	}
1190

  
1191
	/**
1192
	 * Escritor de la tabla BLOCK_RECORD.
1193
	 * @param fw
1194
	 * @throws IOException
1195
	 */
1196
	public void writeBlockRecordTable(FileWriter fw) throws IOException {
1197
		fw.write(DxfGroup.toString(0, "TABLE"));
1198
		fw.write(DxfGroup.toString(2, "BLOCK_RECORD"));
1199
		fw.write(DxfGroup.toString(5, 1));
1200
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1201
		fw.write(DxfGroup.toString(70, 1));
1202
		fw.write(DxfGroup.toString(0, "BLOCK_RECORD"));
1203
		fw.write(DxfGroup.toString(5, "1F"));
1204
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1205
		fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord"));
1206
		fw.write(DxfGroup.toString(2, "*Model_Space"));
1207
		fw.write(DxfGroup.toString(340, "22"));
1208
		fw.write(DxfGroup.toString(0, "BLOCK_RECORD"));
1209
		fw.write(DxfGroup.toString(5, "1B"));
1210
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1211
		fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord"));
1212
		fw.write(DxfGroup.toString(2, "*Paper_Space"));
1213
		fw.write(DxfGroup.toString(340, "1E"));
1214
		fw.write(DxfGroup.toString(0, "BLOCK_RECORD"));
1215
		fw.write(DxfGroup.toString(5, "23"));
1216
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1217
		fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord"));
1218
		fw.write(DxfGroup.toString(2, "*Paper_Space0"));
1219
		fw.write(DxfGroup.toString(340, "26"));
1220
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1221
	}
1222

  
1223
	/**
1224
	 * Escritor de la secci�n de bloques por defecto de un DXF2000.
1225
	 * @param fw
1226
	 * @throws IOException
1227
	 */
1228
	public void writeBlocks(FileWriter fw) throws IOException {
1229
		fw.write(DxfGroup.toString(0, "SECTION"));
1230
		fw.write(DxfGroup.toString(2, "BLOCKS"));
1231
		fw.write(DxfGroup.toString(0, "BLOCK"));
1232
		fw.write(DxfGroup.toString(5, "20"));
1233
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1234
		fw.write(DxfGroup.toString(8, "0"));
1235
		fw.write(DxfGroup.toString(100, "AcDbBlockBegin"));
1236
		fw.write(DxfGroup.toString(2, "*Model_Space"));
1237
		fw.write(DxfGroup.toString(70, 0));
1238
		fw.write(DxfGroup.toString(10, 0.0, 4));
1239
		fw.write(DxfGroup.toString(20, 0.0, 4));
1240
		fw.write(DxfGroup.toString(30, 0.0, 4));
1241
		fw.write(DxfGroup.toString(3, "*Model_Space"));
1242
		fw.write(DxfGroup.toString(1, ""));
1243
		fw.write(DxfGroup.toString(0, "ENDBLK"));
1244
		fw.write(DxfGroup.toString(5, "21"));
1245
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1246
		fw.write(DxfGroup.toString(8, "0"));
1247
		fw.write(DxfGroup.toString(100, "AcDbBlockEnd"));
1248
		fw.write(DxfGroup.toString(0, "BLOCK"));
1249
		fw.write(DxfGroup.toString(5, "1C"));
1250
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1251
		fw.write(DxfGroup.toString(67, 1));
1252
		fw.write(DxfGroup.toString(8, "0"));
1253
		fw.write(DxfGroup.toString(100, "AcDbBlockBegin"));
1254
		fw.write(DxfGroup.toString(2, "*Paper_Space"));
1255
		fw.write(DxfGroup.toString(70, 0));
1256
		fw.write(DxfGroup.toString(10, 0.0, 4));
1257
		fw.write(DxfGroup.toString(20, 0.0, 4));
1258
		fw.write(DxfGroup.toString(30, 0.0, 4));
1259
		fw.write(DxfGroup.toString(3, "*Paper_Space"));
1260
		fw.write(DxfGroup.toString(1, ""));
1261
		fw.write(DxfGroup.toString(0, "ENDBLK"));
1262
		fw.write(DxfGroup.toString(5, "1D"));
1263
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1264
		fw.write(DxfGroup.toString(67, 1));
1265
		fw.write(DxfGroup.toString(8, "0"));
1266
		fw.write(DxfGroup.toString(100, "AcDbBlockEnd"));
1267
		fw.write(DxfGroup.toString(0, "BLOCK"));
1268
		fw.write(DxfGroup.toString(5, "24"));
1269
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1270
		fw.write(DxfGroup.toString(8, "0"));
1271
		fw.write(DxfGroup.toString(100, "AcDbBlockBegin"));
1272
		fw.write(DxfGroup.toString(2, "*Paper_Space0"));
1273
		fw.write(DxfGroup.toString(70, 0));
1274
		fw.write(DxfGroup.toString(10, 0.0, 4));
1275
		fw.write(DxfGroup.toString(20, 0.0, 4));
1276
		fw.write(DxfGroup.toString(30, 0.0, 4));
1277
		fw.write(DxfGroup.toString(3, "*Paper_Space0"));
1278
		fw.write(DxfGroup.toString(1, ""));
1279
		fw.write(DxfGroup.toString(0, "ENDBLK"));
1280
		fw.write(DxfGroup.toString(5, "25"));
1281
		fw.write(DxfGroup.toString(100, "AcDbEntity"));
1282
		fw.write(DxfGroup.toString(8, "0"));
1283
		fw.write(DxfGroup.toString(100, "AcDbBlockEnd"));
1284
		fw.write(DxfGroup.toString(0, "ENDSEC"));
1285
	}
1286

  
1287
	/**
1288
	 * Escritor de la secci�n ENTITIES de entidades.
1289
	 * @param fw
1290
	 * @throws IOException
1291
	 */
1292
	public void writeEntities(FileWriter fw) throws IOException {
1293
		// ECRITURE DES FEATURES
1294
		fw.write(DxfGroup.toString(0, "SECTION"));
1295
		fw.write(DxfGroup.toString(2, "ENTITIES"));
1296
		if (cadFlag) {
1297
			fw.write(((DxfEntityMaker) entityMaker).getEntities().toDxfString());
1298
		} else {
1299
			//fw.write(((DxfFeatureMaker) entityMaker).getObjects().toDxfString());
1300
		}
1301
		fw.write(DxfGroup.toString(0, "ENDSEC"));
1302
	}
1303

  
1304
	/**
1305
	 * 050224, jmorell: Escritura de la secci�n OBJECTS seg�n QCAD.
1306
	 * Writes a objects section. This section is needed in VER_R13.
1307
	 * Note that this method currently only writes a faked OBJECTS section
1308
	 * to make the file readable by Aut*cad.
1309
	 */
1310
	public void writeObjects(FileWriter fw) throws IOException {
1311
	    //int dicId, dicId2, dicId3, dicId4, dicId5;
1312
	    //int dicId5;
1313

  
1314
	    fw.write(DxfGroup.toString(  0, "SECTION"));
1315
	    fw.write(DxfGroup.toString(  2, "OBJECTS"));
1316
	    fw.write(DxfGroup.toString(  0, "DICTIONARY"));
1317
	    //fw.write(DxfGroup.toString(5, 0xC);                            // C
1318
	    fw.write(DxfGroup.toString(  5, "C"));
1319
	    //fw.write(DxfGroup.toString(330, 0);
1320
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1321
	    fw.write(DxfGroup.toString(280, 0));
1322
	    fw.write(DxfGroup.toString(281, 1));
1323
	    fw.write(DxfGroup.toString(  3, "ACAD_GROUP"));
1324
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle());          // D
1325
	    fw.write(DxfGroup.toString(350, "D"));          // D
1326
	    fw.write(DxfGroup.toString(  3, "ACAD_LAYOUT"));
1327
	    fw.write(DxfGroup.toString(350, "1A"));
1328
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+0);        // 1A
1329
	    fw.write(DxfGroup.toString(  3, "ACAD_MLINESTYLE"));
1330
	    fw.write(DxfGroup.toString(350, "17"));
1331
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+1);        // 17
1332
	    fw.write(DxfGroup.toString(  3, "ACAD_PLOTSETTINGS"));
1333
	    fw.write(DxfGroup.toString(350, "19"));
1334
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+2);        // 19
1335
	    fw.write(DxfGroup.toString(  3, "ACAD_PLOTSTYLENAME"));
1336
	    fw.write(DxfGroup.toString(350, "E"));
1337
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+3);        // E
1338
	    fw.write(DxfGroup.toString(  3, "AcDbVariableDictionary"));
1339
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()));        // 2C
1340
	    fw.write(DxfGroup.toString(350, "2C"));        // 2C
1341
	    fw.write(DxfGroup.toString(  0, "DICTIONARY"));
1342
	    fw.write(DxfGroup.toString(5, "D"));
1343
	    //dw.handle();                                    // D
1344
	    //fw.write(DxfGroup.toString(330, 0xC);
1345
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1346
	    fw.write(DxfGroup.toString(280, 0));
1347
	    fw.write(DxfGroup.toString(281, 1));
1348
	    fw.write(DxfGroup.toString(  0, "ACDBDICTIONARYWDFLT"));
1349
	    fw.write(DxfGroup.toString(5, "E"));
1350
	    //dicId4 = dw.handle();                           // E
1351
	    //fw.write(DxfGroup.toString(330, 0xC);                       // C
1352
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1353
	    fw.write(DxfGroup.toString(281, 1));
1354
	    fw.write(DxfGroup.toString(  3, "Normal"));
1355
	    fw.write(DxfGroup.toString(350, "F"));
1356
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+5);        // F
1357
	    fw.write(DxfGroup.toString(100, "AcDbDictionaryWithDefault"));
1358
	    fw.write(DxfGroup.toString(340, "F"));
1359
	    //fw.write(DxfGroup.toString(340, dw.getNextHandle()+5);        // F
1360
	    fw.write(DxfGroup.toString(  0, "ACDBPLACEHOLDER"));
1361
	    fw.write(DxfGroup.toString(5, "F"));
1362
	    //dw.handle();                                    // F
1363
	    //fw.write(DxfGroup.toString(330, dicId4);                      // E
1364
	    fw.write(DxfGroup.toString(  0, "DICTIONARY"));
1365
	    //dicId3 = dw.handle();                           // 17
1366
	    fw.write(DxfGroup.toString(5, "17"));
1367
	    //fw.write(DxfGroup.toString(330, 0xC);                       // C
1368
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1369
	    fw.write(DxfGroup.toString(280, 0));
1370
	    fw.write(DxfGroup.toString(281, 1));
1371
	    fw.write(DxfGroup.toString(  3, "Standard"));
1372
	    fw.write(DxfGroup.toString(350, "18"));
1373
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+5);        // 18
1374
	    fw.write(DxfGroup.toString(  0, "MLINESTYLE"));
1375
	    fw.write(DxfGroup.toString(5, "18"));
1376
	    //dw.handle();                                    // 18
1377
	    //fw.write(DxfGroup.toString(330, dicId3);                      // 17
1378
	    fw.write(DxfGroup.toString(100, "AcDbMlineStyle"));
1379
	    fw.write(DxfGroup.toString(  2, "STANDARD"));
1380
	    fw.write(DxfGroup.toString( 70, 0));
1381
	    fw.write(DxfGroup.toString(  3, ""));
1382
	    fw.write(DxfGroup.toString( 62, 256));
1383
	    //dw.dxfReal( 51, 90.0);
1384
	    fw.write(DxfGroup.toString( 51, 90.0, 4));
1385
	    fw.write(DxfGroup.toString( 52, 90.0, 4));
1386
	    fw.write(DxfGroup.toString( 71, 2));
1387
	    fw.write(DxfGroup.toString( 49, 0.5, 4));
1388
	    fw.write(DxfGroup.toString( 62, 256));
1389
	    fw.write(DxfGroup.toString(  6, "BYLAYER"));
1390
	    fw.write(DxfGroup.toString( 49, -0.5, 4));
1391
	    fw.write(DxfGroup.toString( 62, 256));
1392
	    fw.write(DxfGroup.toString(  6, "BYLAYER"));
1393
	    fw.write(DxfGroup.toString(  0, "DICTIONARY"));
1394
	    fw.write(DxfGroup.toString(5, "19"));
1395
	    //dw.handle();                           // 17
1396
	    //fw.write(DxfGroup.toString(330, 0xC);                       // C
1397
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1398
	    fw.write(DxfGroup.toString(280, 0));
1399
	    fw.write(DxfGroup.toString(281, 1));
1400
	    fw.write(DxfGroup.toString(  0, "DICTIONARY"));
1401
	    //dicId2 = dw.handle();                           // 1A
1402
	    fw.write(DxfGroup.toString(5, "1A"));
1403
	    //fw.write(DxfGroup.toString(330, 0xC);
1404
	    fw.write(DxfGroup.toString(100, "AcDbDictionary"));
1405
	    fw.write(DxfGroup.toString(281, 1));
1406
	    fw.write(DxfGroup.toString(  3, "Layout1"));
1407
	    fw.write(DxfGroup.toString(350, "1E"));
1408
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+2);        // 1E
1409
	    fw.write(DxfGroup.toString(  3, "Layout2"));
1410
	    fw.write(DxfGroup.toString(350, "26"));
1411
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+4);        // 26
1412
	    fw.write(DxfGroup.toString(  3, "Model"));
1413
	    fw.write(DxfGroup.toString(350, "22"));
1414
	    //fw.write(DxfGroup.toString(350, dw.getNextHandle()+5);        // 22
1415

  
1416
	    fw.write(DxfGroup.toString(  0, "LAYOUT"));
1417
	    fw.write(DxfGroup.toString(5, "1E"));
1418
	    //dw.handle();                                    // 1E
1419
	    //fw.write(DxfGroup.toString(330, dicId2);                      // 1A
1420
	    fw.write(DxfGroup.toString(100, "AcDbPlotSettings"));
1421
	    fw.write(DxfGroup.toString(  1, ""));
1422
	    fw.write(DxfGroup.toString(  2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3"));
1423
	    fw.write(DxfGroup.toString(  4, ""));
1424
	    fw.write(DxfGroup.toString(  6, ""));
1425
	    fw.write(DxfGroup.toString( 40, 0.0, 4));
1426
	    fw.write(DxfGroup.toString( 41, 0.0, 4));
1427
	    fw.write(DxfGroup.toString( 42, 0.0, 4));
1428
	    fw.write(DxfGroup.toString( 43, 0.0, 4));
1429
	    fw.write(DxfGroup.toString( 44, 0.0, 4));
1430
	    fw.write(DxfGroup.toString( 45, 0.0, 4));
1431
	    fw.write(DxfGroup.toString( 46, 0.0, 4));
1432
	    fw.write(DxfGroup.toString( 47, 0.0, 4));
1433
	    fw.write(DxfGroup.toString( 48, 0.0, 4));
1434
	    fw.write(DxfGroup.toString( 49, 0.0, 4));
1435
	    fw.write(DxfGroup.toString(140, 0.0, 4));
1436
	    fw.write(DxfGroup.toString(141, 0.0, 4));
1437
	    fw.write(DxfGroup.toString(142, 1.0, 4));
1438
	    fw.write(DxfGroup.toString(143, 1.0, 4));
1439
	    fw.write(DxfGroup.toString( 70, 688));
1440
	    fw.write(DxfGroup.toString( 72, 0));
1441
	    fw.write(DxfGroup.toString( 73, 0));
1442
	    fw.write(DxfGroup.toString( 74, 5));
1443
	    fw.write(DxfGroup.toString(  7, ""));
1444
	    fw.write(DxfGroup.toString( 75, 16));
1445
	    fw.write(DxfGroup.toString(147, 1.0, 4));
1446
	    fw.write(DxfGroup.toString(148, 0.0, 4));
1447
	    fw.write(DxfGroup.toString(149, 0.0, 4));
1448
	    fw.write(DxfGroup.toString(100, "AcDbLayout"));
1449
	    fw.write(DxfGroup.toString(  1, "Layout1"));
1450
	    fw.write(DxfGroup.toString( 70, 1));
1451
	    fw.write(DxfGroup.toString( 71, 1));
1452
	    fw.write(DxfGroup.toString( 10, 0.0, 4));
1453
	    fw.write(DxfGroup.toString( 20, 0.0, 4));
1454
	    fw.write(DxfGroup.toString( 11, 420.0, 4));
1455
	    fw.write(DxfGroup.toString( 21, 297.0, 4));
1456
	    fw.write(DxfGroup.toString( 12, 0.0, 4));
1457
	    fw.write(DxfGroup.toString( 22, 0.0, 4));
1458
	    fw.write(DxfGroup.toString( 32, 0.0, 4));
1459
	    fw.write(DxfGroup.toString( 14, 1.000000000000000E+20, 4));
1460
	    fw.write(DxfGroup.toString( 24, 1.000000000000000E+20, 4));
1461
	    fw.write(DxfGroup.toString( 34, 1.000000000000000E+20, 4));
1462
	    fw.write(DxfGroup.toString( 15, -1.000000000000000E+20, 4));
1463
	    fw.write(DxfGroup.toString( 25, -1.000000000000000E+20, 4));
1464
	    fw.write(DxfGroup.toString( 35, -1.000000000000000E+20, 4));
1465
	    fw.write(DxfGroup.toString(146, 0.0, 4));
1466
	    fw.write(DxfGroup.toString( 13, 0.0, 4));
1467
	    fw.write(DxfGroup.toString( 23, 0.0, 4));
1468
	    fw.write(DxfGroup.toString( 33, 0.0, 4));
1469
	    fw.write(DxfGroup.toString( 16, 1.0, 4));
1470
	    fw.write(DxfGroup.toString( 26, 0.0, 4));
1471
	    fw.write(DxfGroup.toString( 36, 0.0, 4));
1472
	    fw.write(DxfGroup.toString( 17, 0.0, 4));
1473
	    fw.write(DxfGroup.toString( 27, 1.0, 4));
1474
	    fw.write(DxfGroup.toString( 37, 0.0, 4));
1475
	    fw.write(DxfGroup.toString( 76, 0));
1476
	    //fw.write(DxfGroup.toString(330, dw.getPaperSpaceHandle());    // 1B
1477
	    fw.write(DxfGroup.toString(330, "1B"));
1478
	    fw.write(DxfGroup.toString(  0, "LAYOUT"));
1479
	    fw.write(DxfGroup.toString(5, "22"));
1480
	    //dw.handle();                                    // 22
1481
	    //fw.write(DxfGroup.toString(330, dicId2);                      // 1A
1482
	    fw.write(DxfGroup.toString(100, "AcDbPlotSettings"));
1483
	    fw.write(DxfGroup.toString(  1, ""));
1484
	    fw.write(DxfGroup.toString(  2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3"));
1485
	    fw.write(DxfGroup.toString(  4, ""));
1486
	    fw.write(DxfGroup.toString(  6, ""));
1487
	    fw.write(DxfGroup.toString( 40, 0.0, 4));
1488
	    fw.write(DxfGroup.toString( 41, 0.0, 4));
1489
	    fw.write(DxfGroup.toString( 42, 0.0, 4));
1490
	    fw.write(DxfGroup.toString( 43, 0.0, 4));
1491
	    fw.write(DxfGroup.toString( 44, 0.0, 4));
1492
	    fw.write(DxfGroup.toString( 45, 0.0, 4));
1493
	    fw.write(DxfGroup.toString( 46, 0.0, 4));
1494
	    fw.write(DxfGroup.toString( 47, 0.0, 4));
1495
	    fw.write(DxfGroup.toString( 48, 0.0, 4));
1496
	    fw.write(DxfGroup.toString( 49, 0.0, 4));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff