Revision 38480

View differences:

tags/v2_0_0_Build_2049/libraries/libDXF/src/org/gvsig/dxf/geo/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/v2_0_0_Build_2049/libraries/libDXF/src/org/gvsig/dxf/geo/Polygon2D.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.geo;
25

  
26
import java.awt.Graphics2D;
27
import java.awt.geom.GeneralPath;
28
import java.awt.geom.Point2D;
29

  
30
import java.util.Iterator;
31
import java.util.Vector;
32

  
33
import org.cresques.geo.ViewPortData;
34

  
35

  
36
/**
37
 * Clase que representa un pol?gono 2D
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
39
 */
40
public class Polygon2D extends Vector {
41
    GeneralPath gp = null;
42

  
43
    public Polygon2D() {
44
        super();
45
        gp = null;
46
    }
47

  
48
    /**
49
     * A?ade un vertice al po??gono
50
     * @param pt        punto 2D que representa el vertice a?adido
51
     */
52
    public void addPoint(Point2D pt) {
53
        super.add(pt);
54
    }
55

  
56
    /**
57
     * Dibuja el pol?gono
58
     * @param g        Graphics sobre el que dibuja
59
     * @param vp        ViewPort con la vista
60
     */
61
    public void draw(Graphics2D g, ViewPortData vp) {
62
        newGP(vp);
63
        g.draw(gp);
64

  
65
        //g.draw(new Line2D.Double(pt,pt0));
66
    }
67

  
68
    /**
69
     *
70
     * @param g
71
     * @param vp
72
     */
73
    public void fill(Graphics2D g, ViewPortData vp) {
74
        newGP(vp);
75
        g.fill(gp);
76
    }
77

  
78
    /**
79
     *
80
     * @param vp
81
     */
82
    private void newGP(ViewPortData vp) {
83
        //if (gp != null) return;
84
        gp = new GeneralPath();
85

  
86
        Point2D pt0 = null;
87
        Point2D pt = null;
88
        Point2D pt1 = null;
89
        Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
90
        Iterator iter = iterator();
91

  
92
        while (iter.hasNext()) {
93
            pt1 = (Point2D) iter.next();
94
            vp.mat.transform(pt1, ptTmp);
95

  
96
            if (pt0 == null) {
97
                pt0 = ptTmp;
98
                gp.moveTo((float) ptTmp.getX(), (float) ptTmp.getY());
99
            } else {
100
                gp.lineTo((float) ptTmp.getX(), (float) ptTmp.getY());
101
            }
102
        }
103

  
104
        gp.closePath();
105
    }
106
}
0 107

  
tags/v2_0_0_Build_2049/libraries/libDXF/src/org/gvsig/dxf/geo/cover/package.html
1
<html>
2
	<body>Clases relacionadas con coverturas espaciales.
3
</body>
4
</html>
0 5

  
tags/v2_0_0_Build_2049/libraries/libDXF/src/org/gvsig/dxf/geo/cover/Hoja.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.geo.cover;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

  
29
import org.cresques.geo.Projected;
30
import org.cresques.px.Extent;
31

  
32

  
33
import java.awt.geom.Point2D;
34

  
35
import java.io.InputStream;
36
import java.io.OutputStream;
37

  
38
import java.util.Vector;
39

  
40

  
41
/**
42
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
43
 */
44
public class Hoja implements Projected {
45
    IProjection proj;
46
    String code = null;
47
    String name = null;
48
    Extent extent = null;
49
    Point2D tl;
50
    Point2D tr;
51
    Point2D bl;
52
    Point2D br;
53

  
54
    public Hoja(IProjection proj, String code, String name) {
55
        this.proj = proj;
56
        this.code = code;
57
        this.name = name;
58
        tl = tr = bl = br = null;
59
    }
60

  
61
    public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4,
62
                String name) {
63
        code = cod;
64
        tl = p1;
65
        tr = p2;
66
        bl = p3;
67
        br = p4;
68

  
69
        if (name != null) {
70
            this.name = name;
71
        }
72

  
73
        setExtent();
74
    }
75

  
76
    public Hoja(String cod, Point2D[] pt, String name) {
77
        code = cod;
78
        tl = pt[0];
79
        tr = pt[1];
80
        br = pt[2];
81
        bl = pt[3];
82

  
83
        if (name != null) {
84
            this.name = name;
85
        }
86

  
87
        setExtent();
88
    }
89

  
90
    public Hoja(String cod, Vector pt, String name) {
91
        code = cod;
92
        tl = (Point2D) pt.get(0);
93
        tr = (Point2D) pt.get(1);
94
        br = (Point2D) pt.get(2);
95
        bl = (Point2D) pt.get(3);
96

  
97
        if (name != null) {
98
            this.name = name;
99
        }
100

  
101
        setExtent();
102
    }
103

  
104
    public Hoja(String cod, Hoja h, String name) {
105
        code = cod;
106
        tl = h.tl;
107
        tr = h.tr;
108
        br = h.br;
109
        bl = h.bl;
110

  
111
        if (name != null) {
112
            this.name = name;
113
        }
114

  
115
        setExtent();
116
    }
117

  
118
    public IProjection getProjection() {
119
        return proj;
120
    }
121

  
122
    public void setProjection(IProjection p) {
123
        proj = p;
124
    }
125

  
126
    public void reProject(ICoordTrans rp) {
127
        // TODO metodo reProject pendiente de implementar
128
    }
129

  
130
    public Point2D getTL() {
131
        return tl;
132
    }
133

  
134
    public void setTL(Point2D pt) {
135
        tl = pt;
136
        extent.add(pt);
137
    }
138

  
139
    public Point2D getTR() {
140
        return tr;
141
    }
142

  
143
    public void setTR(Point2D pt) {
144
        tr = pt;
145
        extent.add(pt);
146
    }
147

  
148
    public Point2D getBL() {
149
        return bl;
150
    }
151

  
152
    public void setBL(Point2D pt) {
153
        bl = pt;
154
        extent.add(pt);
155
    }
156

  
157
    public Point2D getBR() {
158
        return br;
159
    }
160

  
161
    public void setBR(Point2D pt) {
162
        br = pt;
163
        extent.add(pt);
164
    }
165

  
166
    public Extent getExtent() {
167
        return extent;
168
    }
169

  
170
    private void setExtent() {
171
        extent = new Extent(tl, br);
172
        extent.add(tr);
173
        extent.add(bl);
174
    }
175

  
176
    public String getCode() {
177
        return code;
178
    }
179

  
180
    public String getName() {
181
        return name;
182
    }
183

  
184
    public Point2D[] getVertex() {
185
        Point2D[] v = { tl, tr, br, bl };
186

  
187
        return v;
188
    }
189

  
190
    public void toXml(OutputStream os) {
191
    }
192

  
193
    public void fromXml(InputStream is) {
194
    }
195
}
0 196

  
tags/v2_0_0_Build_2049/libraries/libDXF/src/org/gvsig/dxf/geo/Point3D.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.geo;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29
/**
30
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
31
 */
32
public class Point3D extends Point2D {
33
    public double X;
34
    public double Y;
35
    public double Z;
36

  
37
    public Point3D() {
38
        setLocation(0.0, 0.0);
39
    }
40

  
41
    public Point3D(double x, double y) {
42
        setLocation(x, y);
43
    }
44

  
45
    public Point3D(double x, double y, double z) {
46
        setLocation(x, y, z);
47
    }
48

  
49
    public Point3D(Point2D pt) {
50
        setLocation(pt.getX(), pt.getY());
51
    }
52

  
53
    public Point3D(Point3D pt) {
54
        setLocation(pt.getX(), pt.getY(), pt.getZ());
55
    }
56

  
57
    public double getX() {
58
        return X;
59
    }
60

  
61
    public double getY() {
62
        return Y;
63
    }
64

  
65
    public double getZ() {
66
        return Z;
67
    }
68

  
69
    public void setLocation(double x, double y) {
70
        X = x;
71
        Y = y;
72
        Z = 0D;
73
    }
74

  
75
    public void setLocation(double x, double y, double z) {
76
        X = x;
77
        Y = y;
78
        Z = z;
79
    }
80

  
81
    public String toString() {
82
        return "(" + getX() + "," + getY() + ")";
83
    }
84
}
0 85

  
tags/v2_0_0_Build_2049/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"));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff