Revision 1050
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.218/org.gvsig.dxf.lib/src/main/java/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 |
|
50 |
* m�todos necesarios para acceder a la informaci�n almacenada en su |
|
51 |
* interior. |
|
52 |
* |
|
53 |
* @author jmorell |
|
54 |
*/ |
|
55 |
public class DxfFile extends GeoFile { |
|
56 |
|
|
57 |
public static Logger logger = LoggerFactory.getLogger(DxfFile.class); |
|
58 |
|
|
59 |
private boolean cadFlag = true; |
|
60 |
|
|
61 |
long lineNr = 0; |
|
62 |
|
|
63 |
String buf = null; |
|
64 |
|
|
65 |
BufferedReader fi; |
|
66 |
long l = 0; |
|
67 |
int count = 0; |
|
68 |
DxfGroup grp = null; |
|
69 |
|
|
70 |
EntityFactory entityMaker = null; |
|
71 |
VarSettings headerManager; |
|
72 |
private boolean dxf3DFlag; |
|
73 |
|
|
74 |
/** |
|
75 |
* Crea los objetos en el Modelo correspondiente. |
|
76 |
* |
|
77 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
78 |
*/ |
|
79 |
public interface EntityFactory extends Projected { |
|
80 |
|
|
81 |
/** |
|
82 |
* Permite saber si se est�n a�adiendo elementos a un bloque |
|
83 |
* |
|
84 |
* @param booleano que indica si se est�n a�adiendo elementos a un |
|
85 |
* bloque |
|
86 |
*/ |
|
87 |
public void setAddingToBlock(boolean a); |
|
88 |
|
|
89 |
/** |
|
90 |
* Crea una nueva capa partiendo de la informaci�n almacenada en el |
|
91 |
* DXF |
|
92 |
* |
|
93 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
94 |
* nueva capa |
|
95 |
* @throws Exception |
|
96 |
*/ |
|
97 |
public void createLayer(DxfGroupVector v) throws Exception; |
|
98 |
|
|
99 |
/** |
|
100 |
* Crea una nueva polil�nea partiendo de la informaci�n almacenada |
|
101 |
* en el DXF |
|
102 |
* |
|
103 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
104 |
* nueva polil�nea |
|
105 |
* @throws Exception |
|
106 |
*/ |
|
107 |
public void createPolyline(DxfGroupVector v) throws Exception; |
|
108 |
|
|
109 |
/** |
|
110 |
* A�ade un v�rtice a la polil�nea que se est� creando |
|
111 |
* |
|
112 |
* @param DxfGroupVector con la informaci�n necesaria para la |
|
113 |
* adici�n del v�rtice |
|
114 |
* @throws Exception |
|
115 |
*/ |
|
116 |
public void addVertex(DxfGroupVector v) throws Exception; |
|
117 |
|
|
118 |
/** |
|
119 |
* Fin de secuencia |
|
120 |
* |
|
121 |
* @throws Exception |
|
122 |
*/ |
|
123 |
public void endSeq() throws Exception; |
|
124 |
|
|
125 |
/** |
|
126 |
* Crea una nueva LwPolyline partiendo de la informaci�n almacenada en |
|
127 |
* el DXF |
|
128 |
* |
|
129 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
130 |
* nueva polil�nea |
|
131 |
* @throws Exception |
|
132 |
*/ |
|
133 |
public void createLwPolyline(DxfGroupVector v) throws Exception; |
|
134 |
|
|
135 |
/** |
|
136 |
* Crea una nueva l�nea partiendo de la informaci�n almacenada en el |
|
137 |
* DXF |
|
138 |
* |
|
139 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
140 |
* nueva l�nea |
|
141 |
* @throws Exception |
|
142 |
*/ |
|
143 |
public void createLine(DxfGroupVector v) throws Exception; |
|
144 |
|
|
145 |
/** |
|
146 |
* Crea un nuevo texto partiendo de la informaci�n almacenada en el |
|
147 |
* DXF |
|
148 |
* |
|
149 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
150 |
* nuevo texto |
|
151 |
* @throws Exception |
|
152 |
*/ |
|
153 |
public void createText(DxfGroupVector v) throws Exception; |
|
154 |
|
|
155 |
/** |
|
156 |
* Crea un nuevo MText partiendo de la informaci�n almacenada en el |
|
157 |
* DXF |
|
158 |
* |
|
159 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
160 |
* nuevo MText |
|
161 |
* @throws Exception |
|
162 |
*/ |
|
163 |
public void createMText(DxfGroupVector v) throws Exception; |
|
164 |
|
|
165 |
/** |
|
166 |
* Crea un nuevo punto partiendo de la informaci�n almacenada en el |
|
167 |
* DXF |
|
168 |
* |
|
169 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
170 |
* nuevo punto |
|
171 |
* @throws Exception |
|
172 |
*/ |
|
173 |
public void createPoint(DxfGroupVector v) throws Exception; |
|
174 |
|
|
175 |
/** |
|
176 |
* Crea un nuevo c�rculo partiendo de la informaci�n almacenada en |
|
177 |
* el DXF |
|
178 |
* |
|
179 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
180 |
* nuevo c�rculo |
|
181 |
* @throws Exception |
|
182 |
*/ |
|
183 |
public void createCircle(DxfGroupVector v) throws Exception; |
|
184 |
|
|
185 |
/** |
|
186 |
* Crea una nueva elipse partiendo de la informaci�n almacenada en el |
|
187 |
* DXF |
|
188 |
* |
|
189 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
190 |
* nueva elipse |
|
191 |
* @throws Exception |
|
192 |
*/ |
|
193 |
public void createEllipse(DxfGroupVector v) throws Exception; |
|
194 |
|
|
195 |
/** |
|
196 |
* Crea un nuevo arco partiendo de la informaci�n almacenada en el DXF |
|
197 |
* |
|
198 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
199 |
* nuevo arco |
|
200 |
* @throws Exception |
|
201 |
*/ |
|
202 |
public void createArc(DxfGroupVector v) throws Exception; |
|
203 |
|
|
204 |
/** |
|
205 |
* Crea un nuevo punto de inserci�n partiendo de la informaci�n |
|
206 |
* almacenada en el DXF |
|
207 |
* |
|
208 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
209 |
* nuevo punto de inserci�n |
|
210 |
* @throws Exception |
|
211 |
*/ |
|
212 |
public void createInsert(DxfGroupVector v) throws Exception; |
|
213 |
|
|
214 |
/** |
|
215 |
* Crea un nuevo s�lido 2D partiendo de la informaci�n almacenada en |
|
216 |
* el DXF |
|
217 |
* |
|
218 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
219 |
* nuevo s�lido |
|
220 |
* @throws Exception |
|
221 |
*/ |
|
222 |
public void createSolid(DxfGroupVector v) throws Exception; |
|
223 |
|
|
224 |
/** |
|
225 |
* Crea un nuevo Spline partiendo de la informaci�n almacenada en el |
|
226 |
* DXF |
|
227 |
* |
|
228 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
229 |
* nuevo Spline |
|
230 |
* @throws Exception |
|
231 |
*/ |
|
232 |
public void createSpline(DxfGroupVector v) throws Exception; |
|
233 |
|
|
234 |
/** |
|
235 |
* Construye la definici�n de un nuevo atributo partiendo de la |
|
236 |
* informaci�n almacenada en el DXF |
|
237 |
* |
|
238 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
239 |
* definici�n del nuevo atributo |
|
240 |
* @throws Exception |
|
241 |
*/ |
|
242 |
public void createAttdef(DxfGroupVector v) throws Exception; |
|
243 |
|
|
244 |
/** |
|
245 |
* Crea un nuevo atributo partiendo de la informaci�n almacenada en el |
|
246 |
* DXF |
|
247 |
* |
|
248 |
* @param DxfGroupVector con informaci�n para la creaci�n del nuevo |
|
249 |
* atributo |
|
250 |
* @throws Exception |
|
251 |
*/ |
|
252 |
public void createAttrib(DxfGroupVector v) throws Exception; |
|
253 |
|
|
254 |
/** |
|
255 |
* Crea un bloque |
|
256 |
* |
|
257 |
* @param DxfGroupVector con informaci�n para la creaci�n del nuevo |
|
258 |
* elemento |
|
259 |
* @throws Exception |
|
260 |
*/ |
|
261 |
public void createBlock(DxfGroupVector v) throws Exception; |
|
262 |
|
|
263 |
/** |
|
264 |
* Fin de la definici�n de un bloqe |
|
265 |
* |
|
266 |
* @param DxfGroupVector con informaci�n referente al final de un |
|
267 |
* bloque |
|
268 |
* @throws Exception |
|
269 |
*/ |
|
270 |
public void endBlk(DxfGroupVector v) throws Exception; |
|
271 |
|
|
272 |
/** |
|
273 |
* Gestiona los bloques que no se han tratado en la primera vuelta |
|
274 |
*/ |
|
275 |
void testBlocks(); |
|
276 |
|
|
277 |
/** |
|
278 |
* Devuelve el extent |
|
279 |
* |
|
280 |
* @return el extent |
|
281 |
*/ |
|
282 |
public Extent getExtent(); |
|
283 |
|
|
284 |
/** |
|
285 |
* Devuelve la lista de bloques |
|
286 |
* |
|
287 |
* @return la lista de bloques |
|
288 |
*/ |
|
289 |
public Vector getBlkList(); |
|
290 |
|
|
291 |
/** |
|
292 |
* Permite la gesti�n de los atributos almacenados en unn DXF |
|
293 |
* |
|
294 |
* @return un Vector con la lista de atributos |
|
295 |
*/ |
|
296 |
public Vector getAttributes(); |
|
297 |
|
|
298 |
/** |
|
299 |
* Borra los atributos repetidos |
|
300 |
*/ |
|
301 |
public void depureAttributes(); |
|
302 |
|
|
303 |
/** |
|
304 |
* Devuelve los objetos almacenados en el DXF |
|
305 |
* |
|
306 |
* @return IObjList con los objetos procedentes del DXF |
|
307 |
*/ |
|
308 |
public IObjList getObjects(); |
|
309 |
|
|
310 |
/** |
|
311 |
* Permite saber si se trata de un fichero DXF en 2D o en 3D |
|
312 |
* |
|
313 |
* @return booleano que indica si se trata de un fichero DXF 3D |
|
314 |
*/ |
|
315 |
public boolean isDxf3DFile(); |
|
316 |
}; |
|
317 |
|
|
318 |
/** |
|
319 |
* Establece el estado de las variables propias de un DXF que est�n |
|
320 |
* definidas en la secci�n HEADER. Por ejemplo, la versi�n del DXF. |
|
321 |
* |
|
322 |
* @author jmorell (jose.morell@gmail.com) |
|
323 |
* @version 15-dic-2004 |
|
324 |
*/ |
|
325 |
public interface VarSettings { |
|
326 |
|
|
327 |
/** |
|
328 |
* Establece la versi�n de Autocad en la que fue generado el DXF. |
|
329 |
* |
|
330 |
* @param informaci�n de base |
|
331 |
* @throws Exception |
|
332 |
*/ |
|
333 |
public void setAcadVersion(DxfGroupVector v) throws Exception; |
|
334 |
|
|
335 |
/** |
|
336 |
* Devuelve la versi�n de Autocad en la que fue generado el DXF. |
|
337 |
* |
|
338 |
* @return |
|
339 |
*/ |
|
340 |
public String getAcadVersion(); |
|
341 |
|
|
342 |
/** |
|
343 |
* Devuelve el estado de las variables propias de un DXF |
|
344 |
* |
|
345 |
* @return |
|
346 |
*/ |
|
347 |
public DxfHeaderVariables getDxfHeaderVars(); |
|
348 |
|
|
349 |
public boolean isWritedDxf3D(); |
|
350 |
|
|
351 |
public void loadMinZFromHeader(double d); |
|
352 |
|
|
353 |
public void loadMaxZFromHeader(double d); |
|
354 |
}; |
|
355 |
|
|
356 |
/** |
|
357 |
* Constructor de la clase |
|
358 |
* |
|
359 |
* @param proj, la proyecci�n cartogr�fica |
|
360 |
* @param name, el path absoluto hasta el fichero DXF |
|
361 |
* @param maker, el interface que permite la construcci�n de las entidades |
|
362 |
* procedentes del DXF |
|
363 |
*/ |
|
364 |
public DxfFile(IProjection proj, String name, EntityFactory maker) { |
|
365 |
super(proj, name); |
|
366 |
entityMaker = maker; |
|
367 |
headerManager = new DxfHeaderManager(); |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* Constructor de la clase que adem�s incorpora la capacidad de leer una |
|
372 |
* porci�n del HEADER |
|
373 |
* |
|
374 |
* @param proj, la proyecci�n cartogr�fica |
|
375 |
* @param name, el path absoluto hasta el fichero DXF |
|
376 |
* @param maker, el interface que permite la construcci�n de las entidades |
|
377 |
* procedentes del DXF |
|
378 |
* @param dxfVars, el interface que permite la lectura del HEADER de un DXF |
|
379 |
*/ |
|
380 |
public DxfFile(IProjection proj, String name, EntityFactory maker, VarSettings dxfVars) { |
|
381 |
super(proj, name); |
|
382 |
entityMaker = maker; |
|
383 |
headerManager = dxfVars; |
|
384 |
} |
|
385 |
|
|
386 |
/** |
|
387 |
* Carga un fichero en formato DXF |
|
388 |
* |
|
389 |
* @throws Exception |
|
390 |
*/ |
|
391 |
public GeoFile load() throws Exception { |
|
392 |
logger.debug("Dxf: Cargando " + name + " ..."); |
|
393 |
if (ZipFileFolder.isUrl(name)) { |
|
394 |
ZipFileFolder zFolder = new ZipFileFolder(name); |
|
395 |
InputStream is = zFolder.getInputStream(name); |
|
396 |
return load(new InputStreamReader(is)); |
|
397 |
} else { |
|
398 |
return load(new FileReader(name)); |
|
399 |
} |
|
400 |
|
|
401 |
} |
|
402 |
|
|
403 |
/** |
|
404 |
* Carga un fichero en formato DXF tomando un Reader como par�metro |
|
405 |
* |
|
406 |
* @param fr, Reader que se le pasa como par�metro |
|
407 |
* @return devuelve un objeto GeoFile, padre de DxfFile |
|
408 |
* @throws Exception |
|
409 |
* @throws Exception |
|
410 |
*/ |
|
411 |
public GeoFile load(Reader fr) throws Exception { |
|
412 |
logger.debug("Dxf: Cargando '" + name + "' ..."); |
|
413 |
fi = new BufferedReader(fr); |
|
414 |
while ((grp = readGrp()) != null) { |
|
415 |
l += 2; |
|
416 |
|
|
417 |
if (grp.equals(0, "EOF")) { |
|
418 |
break; |
|
419 |
} |
|
420 |
if (grp.equals(0, "SECTION")) { |
|
421 |
readSection(); |
|
422 |
} |
|
423 |
} |
|
424 |
fi.close(); |
|
425 |
extent.add(entityMaker.getExtent()); |
|
426 |
logger.debug("Dxf: '" + name + "' cargado. (" + l + " l�neas)."); |
|
427 |
this.lineNr = l; |
|
428 |
return this; |
|
429 |
} |
|
430 |
|
|
431 |
/** |
|
432 |
* El fichero DXF se divide en grupos. Este m�todo permite leer cada grupo |
|
433 |
* individualmente |
|
434 |
* |
|
435 |
* @return devuelve la informaci�n del DXF en forma de objetos de la clase |
|
436 |
* DxfGroup |
|
437 |
* @throws NumberFormatException |
|
438 |
* @throws IOException |
|
439 |
*/ |
|
440 |
private DxfGroup readGrp() throws NumberFormatException, IOException { |
|
441 |
DxfGroup g = DxfGroup.read(fi); |
|
442 |
if (g != null) { |
|
443 |
l += 2; |
|
444 |
} |
|
445 |
/*if (g.code == 8) |
|
446 |
if (((String) g.data).length() < 1) { |
|
447 |
logger.error("a que un layer no puede ser ''?"); |
|
448 |
System.exit(1); |
|
449 |
}*/ |
|
450 |
return g; |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* El fichero DXF se divide en varias secciones. Este m�todo se encarga de |
|
455 |
* leer cada una de ellas |
|
456 |
* |
|
457 |
* @throws NumberFormatException |
|
458 |
* @throws Exception |
|
459 |
*/ |
|
460 |
private void readSection() throws NumberFormatException, Exception { |
|
461 |
while (true) { |
|
462 |
grp = readGrp(); |
|
463 |
logger.debug("-1:" + grp); |
|
464 |
if (grp.code == 2) { |
|
465 |
if (((String) grp.data).compareTo("HEADER") == 0) { |
|
466 |
readHeader(); |
|
467 |
} else if (((String) grp.data).compareTo("CLASSES") == 0) { |
|
468 |
readAnySection(); |
|
469 |
} else if (((String) grp.data).compareTo("TABLES") == 0) { |
|
470 |
readTables(); |
|
471 |
} else if (((String) grp.data).compareTo("BLOCKS") == 0) { |
|
472 |
readBlocks(); |
|
473 |
} else if (((String) grp.data).compareTo("ENTITIES") == 0) { |
|
474 |
readEntities(); |
|
475 |
} else if (((String) grp.data).compareTo("OBJECTS") == 0) { |
|
476 |
readAnySection(); |
|
477 |
} else { |
|
478 |
logger.debug("DxfRead: Seccion " + grp.data); |
|
479 |
readAnySection(); |
|
480 |
} |
|
481 |
} else { |
|
482 |
logger.debug("Dxf: Codigo/Seccion desconocidos" + grp); |
|
483 |
} |
|
484 |
if (grp.equals(0, "EOF")) { |
|
485 |
break; |
|
486 |
} |
|
487 |
if (grp.equals(0, "ENDSEC")) { |
|
488 |
break; |
|
489 |
} |
|
490 |
} |
|
491 |
} |
|
492 |
|
|
493 |
/** |
|
494 |
* Habilita la lectura de la secci�n de TABLES |
|
495 |
* |
|
496 |
* @throws NumberFormatException |
|
497 |
* @throws Exception |
|
498 |
*/ |
|
499 |
private void readTables() throws NumberFormatException, Exception { |
|
500 |
logger.debug("Dxf: Seccion TABLAS, linea " + l + "grp =" + grp); |
|
501 |
int layerCnt = 0; |
|
502 |
String tableAct = "NONAME"; |
|
503 |
|
|
504 |
Hashtable tables = new Hashtable(); |
|
505 |
Vector table = new Vector(); |
|
506 |
DxfGroupVector v = new DxfGroupVector(); |
|
507 |
|
|
508 |
grp = readGrp(); |
|
509 |
// logger.debug("0:"+grp); |
|
510 |
while (true) { |
|
511 |
if (grp.code == 0) { |
|
512 |
String data = (String) grp.getData(); |
|
513 |
if (data.compareTo("ENDSEC") == 0 || data.compareTo("EOF") == 0) { |
|
514 |
break; |
|
515 |
} else if (data.compareTo("ENDTAB") == 0) { |
|
516 |
tables.put(tableAct, table); |
|
517 |
table = new Vector(); |
|
518 |
grp = readGrp(); |
|
519 |
// logger.debug("1:"+grp); |
|
520 |
|
|
521 |
/**/ if (tableAct.compareTo("LAYER") == 0 && v.size() > 0) { |
|
522 |
entityMaker.createLayer(v); |
|
523 |
logger.debug("Dxf: Layer " + v.getDataAsString(2)); |
|
524 |
layerCnt++; |
|
525 |
v.clear(); |
|
526 |
}/**/ |
|
527 |
|
|
528 |
continue; |
|
529 |
} else { |
|
530 |
if (table.size() == 1) { |
|
531 |
tableAct = v.getDataAsString(2); |
|
532 |
logger.debug("Dxf: Tabla " + tableAct); |
|
533 |
} else if (tableAct.compareTo("LAYER") == 0 && v.size() > 0) { |
|
534 |
entityMaker.createLayer(v); |
|
535 |
logger.debug("Dxf: Layer " + v.getDataAsString(2)); |
|
536 |
layerCnt++; |
|
537 |
} |
|
538 |
|
|
539 |
v.clear(); |
|
540 |
v.add(grp); |
|
541 |
} |
|
542 |
while (true) { |
|
543 |
grp = readGrp(); |
|
544 |
// logger.debug("2:"+grp); |
|
545 |
if (grp.code == 0) { |
|
546 |
break; |
|
547 |
} |
|
548 |
v.add(grp); |
|
549 |
} |
|
550 |
table.add(v); |
|
551 |
} else { |
|
552 |
logger.debug("Dxf: Error de secuencia"); |
|
553 |
grp = readGrp(); |
|
554 |
//logger.debug("3:"+grp); |
|
555 |
} |
|
556 |
} |
|
557 |
logger.debug("Dxf: Seccion TABLAS: " + layerCnt + " Capas. "); |
|
558 |
} |
|
559 |
|
|
560 |
/** |
|
561 |
* M�todo de lectura de secci�n por defecto. Se utiliza mientras se |
|
562 |
* realiza la implementaci�n correspondiente |
|
563 |
* |
|
564 |
* @throws NumberFormatException |
|
565 |
* @throws IOException |
|
566 |
*/ |
|
567 |
private void readAnySection() throws NumberFormatException, IOException { |
|
568 |
logger.debug("Dxf: Seccion '" + ((String) grp.getData()) + "', linea " + l); |
|
569 |
while (true) { |
|
570 |
grp = readGrp(); |
|
571 |
if (grp.equals(0, "ENDSEC")) { |
|
572 |
break; |
|
573 |
} else if (grp.equals(0, "EOF")) { |
|
574 |
break; |
|
575 |
} |
|
576 |
} |
|
577 |
} |
|
578 |
|
|
579 |
/** |
|
580 |
* Primera aproximaci�n a la implementaci�n de la lectura del HEADER. En |
|
581 |
* principio interesa que se lea la versi�n del DXF. Para implementar esta |
|
582 |
* parte del lector se ha optado por incluir el m�todo setAcadVersion en |
|
583 |
* el interface EntityFactory. A lo mejor conviene implementar un nuevo |
|
584 |
* interface VarSettings. |
|
585 |
* |
|
586 |
* @throws NumberFormatException |
|
587 |
* @throws Exception |
|
588 |
*/ |
|
589 |
private void readHeader() throws NumberFormatException, Exception { |
|
590 |
logger.debug("Dxf: Seccion HEADER, linea " + l); |
|
591 |
int variableCnt = 0; |
|
592 |
int cntVeces = 0; |
|
593 |
DxfGroupVector v = new DxfGroupVector(); |
|
594 |
grp = readGrp(); |
|
595 |
while (true) { |
|
596 |
if (grp.equals(0, "EOF")) { |
|
597 |
break; |
|
598 |
} else if (grp.code == 9 || grp.code == 0) { |
|
599 |
if (v.size() > 0) { |
|
600 |
String lastVariable = (String) ((DxfGroup) v.get(0)).data; |
|
601 |
//logger.debug(lastVariable); |
|
602 |
if (lastVariable.compareTo("$ACADVER") == 0) { |
|
603 |
//logger.debug("Aqui llega."); |
|
604 |
headerManager.setAcadVersion(v); |
|
605 |
} else if (lastVariable.compareTo("$EXTMIN") == 0) { |
|
606 |
if (v.hasCode(30)) { |
|
607 |
headerManager.loadMinZFromHeader((Double)v.getData(30)); |
|
608 |
} |
|
609 |
} else if (lastVariable.compareTo("$EXTMAX") == 0) { |
|
610 |
if (v.hasCode(30)) { |
|
611 |
headerManager.loadMaxZFromHeader((Double)v.getData(30)); |
|
612 |
} |
|
613 |
} else if (lastVariable.compareTo("ENDSEC") == 0) { |
|
614 |
//logger.debug("Llega al ENDSEC."); |
|
615 |
break; |
|
616 |
} /*else |
|
617 |
logger.debug("Dxf: Variable "+lastVariable+" desconocida.");*/ |
|
618 |
|
|
619 |
} |
|
620 |
v.clear(); |
|
621 |
v.add(grp); |
|
622 |
while (true) { |
|
623 |
grp = readGrp(); |
|
624 |
if (grp.code == 9 || grp.code == 0) { |
|
625 |
break; |
|
626 |
} |
|
627 |
v.add(grp); |
|
628 |
} |
|
629 |
variableCnt++; |
|
630 |
} |
|
631 |
cntVeces++; |
|
632 |
} |
|
633 |
logger.debug("Dxf: Seccion HEADER, " + variableCnt + " variables, " + cntVeces + " veces."); |
|
634 |
//logger.debug("Seccion HEADER, linea "+ l+ " (SALGO)"); |
|
635 |
logger.debug("readHeader: ACAD Version: " + headerManager.getDxfHeaderVars().getAcadVersion()); |
|
636 |
} |
|
637 |
|
|
638 |
/** |
|
639 |
* Permite leer la secci�n ENTITIES del DXF, donde se encuentran las |
|
640 |
* entidades geom�tricas del DXF que no aparecen dentro de ning�n bloque |
|
641 |
* |
|
642 |
* @throws NumberFormatException |
|
643 |
* @throws Exception |
|
644 |
*/ |
|
645 |
private void readEntities() throws NumberFormatException, Exception { |
|
646 |
logger.debug("Dxf: Seccion ENTITIES, linea " + l); |
|
647 |
int entityCnt = 0; |
|
648 |
int cntVeces = 0; |
|
649 |
DxfGroupVector v = new DxfGroupVector(); |
|
650 |
grp = readGrp(); |
|
651 |
while (true) { |
|
652 |
if (grp.equals(0, "EOF")) { |
|
653 |
break; |
|
654 |
} else if (grp.code == 0) { |
|
655 |
if (v.size() > 0) { |
|
656 |
String lastEntity = (String) ((DxfGroup) v.get(0)).data; |
|
657 |
if (lastEntity.compareTo("POLYLINE") == 0) { |
|
658 |
entityMaker.createPolyline(v); |
|
659 |
} else if (lastEntity.compareTo("VERTEX") == 0) { |
|
660 |
entityMaker.addVertex(v); |
|
661 |
} else if (lastEntity.compareTo("SEQEND") == 0) { |
|
662 |
entityMaker.endSeq(); |
|
663 |
} else if (lastEntity.compareTo("LWPOLYLINE") == 0) { |
|
664 |
entityMaker.createLwPolyline(v); |
|
665 |
} else if (lastEntity.compareTo("LINE") == 0) { |
|
666 |
entityMaker.createLine(v); |
|
667 |
} else if (lastEntity.compareTo("TEXT") == 0) { |
|
668 |
entityMaker.createText(v); |
|
669 |
} else if (lastEntity.compareTo("MTEXT") == 0) { |
|
670 |
entityMaker.createMText(v); |
|
671 |
} else if (lastEntity.compareTo("POINT") == 0) { |
|
672 |
entityMaker.createPoint(v); |
|
673 |
} else if (lastEntity.compareTo("CIRCLE") == 0) { |
|
674 |
entityMaker.createCircle(v); |
|
675 |
} else if (lastEntity.compareTo("ELLIPSE") == 0) { |
|
676 |
entityMaker.createEllipse(v); |
|
677 |
} else if (lastEntity.compareTo("ARC") == 0) { |
|
678 |
entityMaker.createArc(v); |
|
679 |
} else if (lastEntity.compareTo("INSERT") == 0) { |
|
680 |
entityMaker.createInsert(v); |
|
681 |
} else if (lastEntity.compareTo("SOLID") == 0) { |
|
682 |
entityMaker.createSolid(v); |
|
683 |
} else if (lastEntity.compareTo("SPLINE") == 0) { |
|
684 |
entityMaker.createSpline(v); |
|
685 |
} else if (lastEntity.compareTo("ATTRIB") == 0) { |
|
686 |
entityMaker.createAttrib(v); |
|
687 |
} else if (lastEntity.compareTo("ENDSEC") == 0) { |
|
688 |
break; |
|
689 |
} else { |
|
690 |
logger.debug("Dxf: Entidad " + lastEntity + " desconocida."); |
|
691 |
} |
|
692 |
} |
|
693 |
v.clear(); |
|
694 |
v.add(grp); |
|
695 |
while (true) { |
|
696 |
grp = readGrp(); |
|
697 |
if (grp.code == 0) { |
|
698 |
break; |
|
699 |
} |
|
700 |
v.add(grp); |
|
701 |
} |
|
702 |
entityCnt++; |
|
703 |
} |
|
704 |
cntVeces++; |
|
705 |
} |
|
706 |
logger.debug("Dxf: Seccion ENTITIES, " + entityCnt + " entidades, " + cntVeces + " veces."); |
|
707 |
//logger.debug("Seccion ENTITIES, linea "+ l+ " (SALGO)"); |
|
708 |
} |
|
709 |
|
|
710 |
/** |
|
711 |
* Permite la secci�n BLOCKS del DXF, donde se encuentran las definiciones |
|
712 |
* de los bloques que componen el DXF |
|
713 |
* |
|
714 |
* @throws NumberFormatException |
|
715 |
* @throws Exception |
|
716 |
*/ |
|
717 |
private void readBlocks() throws NumberFormatException, Exception { |
|
718 |
logger.debug("Dxf: Seccion BLOCKS, linea " + l); |
|
719 |
int blkCnt = 0; |
|
720 |
int cntVeces = 0; |
|
721 |
DxfGroupVector v = new DxfGroupVector(); |
|
722 |
grp = readGrp(); |
|
723 |
while (true) { |
|
724 |
if (grp.equals(0, "EOF")) { |
|
725 |
break; |
|
726 |
} else if (grp.code == 0) { |
|
727 |
if (v.size() > 0) { |
|
728 |
String lastEntity = (String) ((DxfGroup) v.get(0)).data; |
|
729 |
if (lastEntity.compareTo("BLOCK") == 0) { |
|
730 |
//logger.debug("readBlocks(): Empezamos a leer un bloque"); |
|
731 |
entityMaker.createBlock(v); |
|
732 |
} else if (lastEntity.compareTo("POLYLINE") == 0) { |
|
733 |
//logger.debug("readBlocks(): A�adimos una polilinea al bloque"); |
|
734 |
entityMaker.createPolyline(v); |
|
735 |
} else if (lastEntity.compareTo("VERTEX") == 0) { |
|
736 |
//logger.debug("readBlocks(): A�adimos un vertice a la polilinea"); |
|
737 |
entityMaker.addVertex(v); |
|
738 |
} else if (lastEntity.compareTo("SEQEND") == 0) { |
|
739 |
//logger.debug("readBlocks(): Cerramos una polilinea"); |
|
740 |
entityMaker.endSeq(); |
|
741 |
} else if (lastEntity.compareTo("LWPOLYLINE") == 0) { |
|
742 |
//logger.debug("readBlocks(): A�adimos una lwpolilinea al bloque"); |
|
743 |
entityMaker.createLwPolyline(v); |
|
744 |
} else if (lastEntity.compareTo("LINE") == 0) { |
|
745 |
//logger.debug("readBlocks(): A�adimos una linea al bloque"); |
|
746 |
entityMaker.createLine(v); |
|
747 |
} else if (lastEntity.compareTo("TEXT") == 0) { |
|
748 |
//logger.debug("readBlocks(): A�adimos un texto al bloque"); |
|
749 |
entityMaker.createText(v); |
|
750 |
} else if (lastEntity.compareTo("MTEXT") == 0) { |
|
751 |
//logger.debug("readBlocks(): A�adimos un m-texto al bloque"); |
|
752 |
entityMaker.createMText(v); |
|
753 |
} else if (lastEntity.compareTo("POINT") == 0) { |
|
754 |
//logger.debug("readBlocks(): A�adimos un punto al bloque"); |
|
755 |
entityMaker.createPoint(v); |
|
756 |
} else if (lastEntity.compareTo("CIRCLE") == 0) { |
|
757 |
//logger.debug("readBlocks(): A�adimos un circulo al bloque"); |
|
758 |
entityMaker.createCircle(v); |
|
759 |
} else if (lastEntity.compareTo("ARC") == 0) { |
|
760 |
//logger.debug("readBlocks(): A�adimos un arco al bloque"); |
|
761 |
entityMaker.createArc(v); |
|
762 |
} else if (lastEntity.compareTo("INSERT") == 0) { |
|
763 |
//logger.debug("readBlocks(): A�adimos un insert al bloque"); |
|
764 |
entityMaker.createInsert(v); |
|
765 |
} else if (lastEntity.compareTo("SOLID") == 0) { |
|
766 |
//logger.debug("readBlocks(): A�adimos un solido al bloque"); |
|
767 |
entityMaker.createSolid(v); |
|
768 |
} else if (lastEntity.compareTo("SPLINE") == 0) { |
|
769 |
entityMaker.createSpline(v); |
|
770 |
} else if (lastEntity.compareTo("ATTDEF") == 0) { |
|
771 |
entityMaker.createAttdef(v); |
|
772 |
} else if (lastEntity.compareTo("ENDBLK") == 0) { |
|
773 |
//logger.debug("readBlocks(): Cerramos un bloque"+v); |
|
774 |
entityMaker.endBlk(v); |
|
775 |
} else if (lastEntity.compareTo("ENDSEC") == 0) { |
|
776 |
break; |
|
777 |
} else { |
|
778 |
logger.debug("Dxf: Entidad de bloque " + lastEntity + " desconocida."); |
|
779 |
} |
|
780 |
} |
|
781 |
v.clear(); |
|
782 |
v.add(grp); |
|
783 |
while (true) { |
|
784 |
grp = readGrp(); |
|
785 |
if (grp.code == 0) { |
|
786 |
break; |
|
787 |
} |
|
788 |
v.add(grp); |
|
789 |
} |
|
790 |
blkCnt++; |
|
791 |
} |
|
792 |
cntVeces++; |
|
793 |
} |
|
794 |
|
|
795 |
entityMaker.testBlocks(); |
|
796 |
// Cuando termina de leer la secci�n de bloques se asegura de que todos los campos |
|
797 |
// son distintos. |
|
798 |
//logger.debug("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size()); |
|
799 |
entityMaker.depureAttributes(); |
|
800 |
//logger.debug("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size()); |
|
801 |
logger.debug("Dxf: Seccion BLOCKS, " + blkCnt + " elementos de bloque. " + cntVeces + " veces."); |
|
802 |
} |
|
803 |
|
|
804 |
/** |
|
805 |
* Devuelve los objetos geom�tricos obtenidos de un DXF |
|
806 |
*/ |
|
807 |
public IObjList getObjects() { |
|
808 |
return this.entityMaker.getObjects(); |
|
809 |
} |
|
810 |
|
|
811 |
/** |
|
812 |
* jmorell: M�todo que permite salvar capas al formato DXF2000. Este |
|
813 |
* m�todo ha sido actualizado en el proceso de implementaci�n del piloto |
|
814 |
* de CAD. En este piloto deb�a existir soporte para elipses, y este es |
|
815 |
* uno de los motivos que nos llevan a implementar ahora para DXF2000, |
|
816 |
* puesto que el DXF R12 no soporta elipses. |
|
817 |
* |
|
818 |
* @param fName |
|
819 |
* @throws IOException |
|
820 |
*/ |
|
821 |
public void save(String fName) throws IOException { |
|
822 |
logger.debug("save: fName = " + fName); |
|
823 |
long t2, t1; |
|
824 |
t1 = getTime(); |
|
825 |
fName = DataSource.normalize(fName); |
|
826 |
FileWriter fw = new FileWriter(fName); |
|
827 |
// COMMENTAIRES DU TRADUCTEUR |
|
828 |
// fw.write(DxfGroup.toString(999, Integer.toString(features.size()) + " features")); |
|
829 |
fw.write(DxfGroup.toString(999, "TRANSLATION BY geo.cresques.io.DxfFile")); |
|
830 |
fw.write(DxfGroup.toString(999, "DATE : " + (new Date()).toString())); |
|
831 |
writeHeader(fw); |
|
832 |
writeTables(fw); |
|
833 |
writeBlocks(fw); |
|
834 |
writeEntities(fw); |
|
835 |
writeObjects(fw); |
|
836 |
fw.write(DxfGroup.toString(0, "EOF")); |
|
837 |
fw.flush(); |
|
838 |
fw.close(); |
|
839 |
t2 = getTime(); |
|
840 |
logger.debug("DxfFile.save(): Tiempo salvando: " + (t2 - t1) / 1000 + " seg."); |
|
841 |
} |
|
842 |
|
|
843 |
/** |
|
844 |
* Escritor de la cabecera de un DXF. jmorell: Actualizaci�n del escritor |
|
845 |
* de DXF de R12 a 2000. |
|
846 |
* |
|
847 |
* @param fw, un FileWriter para escribir ficheros |
|
848 |
* @throws IOException |
|
849 |
*/ |
|
850 |
public void writeHeader(FileWriter fw) throws IOException { |
|
851 |
fw.write(DxfGroup.toString(0, "SECTION")); |
|
852 |
fw.write(DxfGroup.toString(2, "HEADER")); |
|
853 |
fw.write(DxfGroup.toString(9, "$ACADVER")); |
|
854 |
//fw.write(DxfGroup.toString(1, "AC1009")); // DXF R12 |
|
855 |
fw.write(DxfGroup.toString(1, "AC1015")); // DXF 2000 |
|
856 |
fw.write(DxfGroup.toString(9, "$INSBASE")); |
|
857 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
858 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
859 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
860 |
fw.write(DxfGroup.toString(9, "$EXTMIN")); |
|
861 |
fw.write(DxfGroup.toString(10, extent.minX(), 6)); |
|
862 |
fw.write(DxfGroup.toString(20, extent.minY(), 6)); |
|
863 |
if (dxf3DFlag) { |
|
864 |
fw.write(DxfGroup.toString(30, extent.minX(), 6)); |
|
865 |
} else { |
|
866 |
fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
867 |
} |
|
868 |
fw.write(DxfGroup.toString(9, "$EXTMAX")); |
|
869 |
fw.write(DxfGroup.toString(10, extent.maxX(), 6)); |
|
870 |
fw.write(DxfGroup.toString(20, extent.maxY(), 6)); |
|
871 |
if (dxf3DFlag) { |
|
872 |
fw.write(DxfGroup.toString(30, extent.maxX(), 6)); |
|
873 |
} else { |
|
874 |
fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
875 |
} |
|
876 |
fw.write(DxfGroup.toString(9, "$LIMMIN")); |
|
877 |
fw.write(DxfGroup.toString(10, extent.minX(), 6)); |
|
878 |
fw.write(DxfGroup.toString(20, extent.minY(), 6)); |
|
879 |
fw.write(DxfGroup.toString(9, "$LIMMAX")); |
|
880 |
fw.write(DxfGroup.toString(10, extent.maxX(), 6)); |
|
881 |
fw.write(DxfGroup.toString(20, extent.maxY(), 6)); |
|
882 |
fw.write(DxfGroup.toString(9, "$ORTHOMODE") + DxfGroup.toString(70, 0)); |
|
883 |
fw.write(DxfGroup.toString(9, "$REGENMODE") + DxfGroup.toString(70, 1)); |
|
884 |
fw.write(DxfGroup.toString(9, "$FILLMODE") + DxfGroup.toString(70, 1)); |
|
885 |
fw.write(DxfGroup.toString(9, "$QTEXTMODE") + DxfGroup.toString(70, 0)); |
|
886 |
fw.write(DxfGroup.toString(9, "$MIRRTEXT") + DxfGroup.toString(70, 1)); |
|
887 |
fw.write(DxfGroup.toString(9, "$DRAGMODE") + DxfGroup.toString(70, 2)); |
|
888 |
fw.write(DxfGroup.toString(9, "$LTSCALE") + DxfGroup.toString(40, 1.0, 1)); |
|
889 |
fw.write(DxfGroup.toString(9, "$OSMODE") + DxfGroup.toString(70, 0)); |
|
890 |
fw.write(DxfGroup.toString(9, "$ATTMODE") + DxfGroup.toString(70, 1)); |
|
891 |
fw.write(DxfGroup.toString(9, "$TEXTSIZE") + DxfGroup.toString(40, 0.2, 1)); |
|
892 |
fw.write(DxfGroup.toString(9, "$TRACEWID") + DxfGroup.toString(40, 0.05, 2)); |
|
893 |
fw.write(DxfGroup.toString(9, "$TEXTSTYLE") + DxfGroup.toString(7, "STANDARD")); |
|
894 |
fw.write(DxfGroup.toString(9, "$CLAYER") + DxfGroup.toString(8, "0")); |
|
895 |
fw.write(DxfGroup.toString(9, "$CELTYPE") + DxfGroup.toString(6, "CONTINUOUS")); |
|
896 |
fw.write(DxfGroup.toString(9, "$CECOLOR") + DxfGroup.toString(62, 256)); |
|
897 |
fw.write(DxfGroup.toString(9, "$DIMSCALE") + DxfGroup.toString(40, 1.0, 1)); |
|
898 |
fw.write(DxfGroup.toString(9, "$DIMASZ") + DxfGroup.toString(40, 0.18, 2)); |
|
899 |
fw.write(DxfGroup.toString(9, "$DIMEXO") + DxfGroup.toString(40, 0.0625, 4)); |
|
900 |
fw.write(DxfGroup.toString(9, "$DIMDLI") + DxfGroup.toString(40, 0.38, 2)); |
|
901 |
fw.write(DxfGroup.toString(9, "$DIMRND") + DxfGroup.toString(40, 0.0, 1)); |
|
902 |
fw.write(DxfGroup.toString(9, "$DIMDLE") + DxfGroup.toString(40, 0.0, 1)); |
|
903 |
fw.write(DxfGroup.toString(9, "$DIMEXE") + DxfGroup.toString(40, 0.18, 2)); |
|
904 |
fw.write(DxfGroup.toString(9, "$DIMTP") + DxfGroup.toString(40, 0.0, 1)); |
|
905 |
fw.write(DxfGroup.toString(9, "$DIMTM") + DxfGroup.toString(40, 0.0, 1)); |
|
906 |
fw.write(DxfGroup.toString(9, "$DIMTXT") + DxfGroup.toString(40, 0.18, 2)); |
|
907 |
fw.write(DxfGroup.toString(9, "$DIMCEN") + DxfGroup.toString(40, 0.09, 2)); |
|
908 |
fw.write(DxfGroup.toString(9, "$DIMTSZ") + DxfGroup.toString(40, 0.0, 1)); |
|
909 |
fw.write(DxfGroup.toString(9, "$DIMTOL") + DxfGroup.toString(70, 0)); |
|
910 |
fw.write(DxfGroup.toString(9, "$DIMLIM") + DxfGroup.toString(70, 0)); |
|
911 |
fw.write(DxfGroup.toString(9, "$DIMTIH") + DxfGroup.toString(70, 1)); |
|
912 |
fw.write(DxfGroup.toString(9, "$DIMTOH") + DxfGroup.toString(70, 1)); |
|
913 |
fw.write(DxfGroup.toString(9, "$DIMSE1") + DxfGroup.toString(70, 0)); |
|
914 |
fw.write(DxfGroup.toString(9, "$DIMSE2") + DxfGroup.toString(70, 0)); |
|
915 |
fw.write(DxfGroup.toString(9, "$DIMTAD") + DxfGroup.toString(70, 0)); |
|
916 |
fw.write(DxfGroup.toString(9, "$DIMZIN") + DxfGroup.toString(70, 0)); |
|
917 |
fw.write(DxfGroup.toString(9, "$DIMBLK") + DxfGroup.toString(1, "")); |
|
918 |
fw.write(DxfGroup.toString(9, "$DIMASO") + DxfGroup.toString(70, 1)); |
|
919 |
fw.write(DxfGroup.toString(9, "$DIMSHO") + DxfGroup.toString(70, 1)); |
|
920 |
fw.write(DxfGroup.toString(9, "$DIMPOST") + DxfGroup.toString(1, "")); |
|
921 |
fw.write(DxfGroup.toString(9, "$DIMAPOST") + DxfGroup.toString(1, "")); |
|
922 |
fw.write(DxfGroup.toString(9, "$DIMALT") + DxfGroup.toString(70, 0)); |
|
923 |
fw.write(DxfGroup.toString(9, "$DIMALTD") + DxfGroup.toString(70, 2)); |
|
924 |
fw.write(DxfGroup.toString(9, "$DIMALTF") + DxfGroup.toString(40, 25.4, 1)); |
|
925 |
fw.write(DxfGroup.toString(9, "$DIMLFAC") + DxfGroup.toString(40, 1.0, 1)); |
|
926 |
fw.write(DxfGroup.toString(9, "$DIMTOFL") + DxfGroup.toString(70, 0)); |
|
927 |
fw.write(DxfGroup.toString(9, "$DIMTVP") + DxfGroup.toString(40, 0.0, 1)); |
|
928 |
fw.write(DxfGroup.toString(9, "$DIMTIX") + DxfGroup.toString(70, 0)); |
|
929 |
fw.write(DxfGroup.toString(9, "$DIMSOXD") + DxfGroup.toString(70, 0)); |
|
930 |
fw.write(DxfGroup.toString(9, "$DIMSAH") + DxfGroup.toString(70, 0)); |
|
931 |
fw.write(DxfGroup.toString(9, "$DIMBLK1") + DxfGroup.toString(1, "")); |
|
932 |
fw.write(DxfGroup.toString(9, "$DIMBLK2") + DxfGroup.toString(1, "")); |
|
933 |
fw.write(DxfGroup.toString(9, "$DIMSTYLE") + DxfGroup.toString(2, "STANDARD")); |
|
934 |
fw.write(DxfGroup.toString(9, "$DIMCLRD") + DxfGroup.toString(70, 0)); |
|
935 |
fw.write(DxfGroup.toString(9, "$DIMCLRE") + DxfGroup.toString(70, 0)); |
|
936 |
fw.write(DxfGroup.toString(9, "$DIMCLRT") + DxfGroup.toString(70, 0)); |
|
937 |
fw.write(DxfGroup.toString(9, "$DIMTFAC") + DxfGroup.toString(40, 1.0, 1)); |
|
938 |
fw.write(DxfGroup.toString(9, "$DIMGAP") + DxfGroup.toString(40, 0.09, 2)); |
|
939 |
fw.write(DxfGroup.toString(9, "$LUNITS") + DxfGroup.toString(70, 2)); |
|
940 |
fw.write(DxfGroup.toString(9, "$LUPREC") + DxfGroup.toString(70, 4)); |
|
941 |
fw.write(DxfGroup.toString(9, "$AXISMODE") + DxfGroup.toString(70, 0)); |
|
942 |
fw.write(DxfGroup.toString(9, "$AXISUNIT")); |
|
943 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
944 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
945 |
fw.write(DxfGroup.toString(9, "$SKETCHINC") + DxfGroup.toString(40, 0.1, 1)); |
|
946 |
fw.write(DxfGroup.toString(9, "$FILLETRAD") + DxfGroup.toString(40, 0.0, 1)); |
|
947 |
fw.write(DxfGroup.toString(9, "$AUNITS") + DxfGroup.toString(70, 0)); |
|
948 |
fw.write(DxfGroup.toString(9, "$AUPREC") + DxfGroup.toString(70, 0)); |
|
949 |
fw.write(DxfGroup.toString(9, "$MENU") + DxfGroup.toString(1, "acad")); |
|
950 |
fw.write(DxfGroup.toString(9, "$ELEVATION") + DxfGroup.toString(40, 0.0, 1)); |
|
951 |
fw.write(DxfGroup.toString(9, "$PELEVATION") + DxfGroup.toString(40, 0.0, 1)); |
|
952 |
fw.write(DxfGroup.toString(9, "$THICKNESS") + DxfGroup.toString(40, 0.0, 1)); |
|
953 |
fw.write(DxfGroup.toString(9, "$LIMCHECK") + DxfGroup.toString(70, 0)); |
|
954 |
fw.write(DxfGroup.toString(9, "$BLIPMODE") + DxfGroup.toString(70, 1)); |
|
955 |
fw.write(DxfGroup.toString(9, "$CHAMFERA") + DxfGroup.toString(40, 0.0, 1)); |
|
956 |
fw.write(DxfGroup.toString(9, "$CHAMFERB") + DxfGroup.toString(40, 0.0, 1)); |
|
957 |
fw.write(DxfGroup.toString(9, "$SKPOLY") + DxfGroup.toString(70, 0)); |
|
958 |
fw.write(DxfGroup.toString(9, "$TDCREATE") + DxfGroup.toString(40, 2453116.436828704, 9)); |
|
959 |
fw.write(DxfGroup.toString(9, "$TDUPDATE") + DxfGroup.toString(40, 2453116.436828704, 9)); |
|
960 |
fw.write(DxfGroup.toString(9, "$TDINDWG") + DxfGroup.toString(40, 0.0000000000, 10)); |
|
961 |
fw.write(DxfGroup.toString(9, "$TDUSRTIMER") + DxfGroup.toString(40, 0.0000000000, 10)); |
|
962 |
fw.write(DxfGroup.toString(9, "$USRTIMER") + DxfGroup.toString(70, 1)); |
|
963 |
fw.write(DxfGroup.toString(9, "$ANGBASE") + DxfGroup.toString(50, 0.0, 1)); |
|
964 |
fw.write(DxfGroup.toString(9, "$ANGDIR") + DxfGroup.toString(70, 0)); |
|
965 |
fw.write(DxfGroup.toString(9, "$PDMODE") + DxfGroup.toString(70, 0)); |
|
966 |
fw.write(DxfGroup.toString(9, "$PDSIZE") + DxfGroup.toString(40, 0.0, 1)); |
|
967 |
fw.write(DxfGroup.toString(9, "$PLINEWID") + DxfGroup.toString(40, 0.0, 1)); |
|
968 |
fw.write(DxfGroup.toString(9, "$COORDS") + DxfGroup.toString(70, 0)); |
|
969 |
fw.write(DxfGroup.toString(9, "$SPLFRAME") + DxfGroup.toString(70, 0)); |
|
970 |
fw.write(DxfGroup.toString(9, "$SPLINETYPE") + DxfGroup.toString(70, 6)); |
|
971 |
fw.write(DxfGroup.toString(9, "$SPLINESEGS") + DxfGroup.toString(70, 10)); |
|
972 |
fw.write(DxfGroup.toString(9, "$ATTDIA") + DxfGroup.toString(70, 0)); |
|
973 |
fw.write(DxfGroup.toString(9, "$ATTREQ") + DxfGroup.toString(70, 1)); |
|
974 |
fw.write(DxfGroup.toString(9, "$HANDLING") + DxfGroup.toString(70, 1)); |
|
975 |
fw.write(DxfGroup.toString(9, "$HANDSEED") + DxfGroup.toString(5, "394B")); |
|
976 |
fw.write(DxfGroup.toString(9, "$SURFTAB1") + DxfGroup.toString(70, 6)); |
|
977 |
fw.write(DxfGroup.toString(9, "$SURFTAB2") + DxfGroup.toString(70, 6)); |
|
978 |
fw.write(DxfGroup.toString(9, "$SURFTYPE") + DxfGroup.toString(70, 6)); |
|
979 |
fw.write(DxfGroup.toString(9, "$SURFU") + DxfGroup.toString(70, 6)); |
|
980 |
fw.write(DxfGroup.toString(9, "$SURFV") + DxfGroup.toString(70, 6)); |
|
981 |
fw.write(DxfGroup.toString(9, "$UCSNAME") + DxfGroup.toString(2, "")); |
|
982 |
fw.write(DxfGroup.toString(9, "$UCSORG")); |
|
983 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
984 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
985 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
986 |
fw.write(DxfGroup.toString(9, "$UCSXDIR")); |
|
987 |
fw.write(DxfGroup.toString(10, 1.0, 1)); |
|
988 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
989 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
990 |
fw.write(DxfGroup.toString(9, "$UCSYDIR")); |
|
991 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
992 |
fw.write(DxfGroup.toString(20, 1.0, 1)); |
|
993 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
994 |
fw.write(DxfGroup.toString(9, "$PUCSNAME") + DxfGroup.toString(2, "")); |
|
995 |
fw.write(DxfGroup.toString(9, "$PUCSORG")); |
|
996 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
997 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
998 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
999 |
fw.write(DxfGroup.toString(9, "$PUCSXDIR")); |
|
1000 |
fw.write(DxfGroup.toString(10, 1.0, 1)); |
|
1001 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
1002 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
1003 |
fw.write(DxfGroup.toString(9, "$PUCSYDIR")); |
|
1004 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
1005 |
fw.write(DxfGroup.toString(20, 1.0, 1)); |
|
1006 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
1007 |
fw.write(DxfGroup.toString(9, "$USERI1") + DxfGroup.toString(70, 0)); |
|
1008 |
fw.write(DxfGroup.toString(9, "$USERI2") + DxfGroup.toString(70, 0)); |
|
1009 |
fw.write(DxfGroup.toString(9, "$USERI3") + DxfGroup.toString(70, 0)); |
|
1010 |
fw.write(DxfGroup.toString(9, "$USERI4") + DxfGroup.toString(70, 0)); |
|
1011 |
fw.write(DxfGroup.toString(9, "$USERI5") + DxfGroup.toString(70, 0)); |
|
1012 |
fw.write(DxfGroup.toString(9, "$USERR1") + DxfGroup.toString(40, 0.0, 1)); |
|
1013 |
fw.write(DxfGroup.toString(9, "$USERR2") + DxfGroup.toString(40, 0.0, 1)); |
|
1014 |
fw.write(DxfGroup.toString(9, "$USERR3") + DxfGroup.toString(40, 0.0, 1)); |
|
1015 |
fw.write(DxfGroup.toString(9, "$USERR4") + DxfGroup.toString(40, 0.0, 1)); |
|
1016 |
fw.write(DxfGroup.toString(9, "$USERR5") + DxfGroup.toString(40, 0.0, 1)); |
|
1017 |
fw.write(DxfGroup.toString(9, "$WORLDVIEW") + DxfGroup.toString(70, 1)); |
|
1018 |
fw.write(DxfGroup.toString(9, "$SHADEDGE") + DxfGroup.toString(70, 3)); |
|
1019 |
fw.write(DxfGroup.toString(9, "$SHADEDIF") + DxfGroup.toString(70, 70)); |
|
1020 |
fw.write(DxfGroup.toString(9, "$TILEMODE") + DxfGroup.toString(70, 1)); |
|
1021 |
fw.write(DxfGroup.toString(9, "$MAXACTVP") + DxfGroup.toString(70, 16)); |
|
1022 |
fw.write(DxfGroup.toString(9, "$PINSBASE")); |
|
1023 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
1024 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
1025 |
fw.write(DxfGroup.toString(30, 0.0, 1)); |
|
1026 |
fw.write(DxfGroup.toString(9, "$PLIMCHECK") + DxfGroup.toString(70, 0)); |
|
1027 |
fw.write(DxfGroup.toString(9, "$PEXTMIN")); |
|
1028 |
fw.write(DxfGroup.toString(10, "-1.000000E+20")); |
|
1029 |
fw.write(DxfGroup.toString(20, "-1.000000E+20")); |
|
1030 |
fw.write(DxfGroup.toString(30, "-1.000000E+20")); |
|
1031 |
fw.write(DxfGroup.toString(9, "$PEXTMAX")); |
|
1032 |
fw.write(DxfGroup.toString(10, "-1.000000E+20")); |
|
1033 |
fw.write(DxfGroup.toString(20, "-1.000000E+20")); |
|
1034 |
fw.write(DxfGroup.toString(30, "-1.000000E+20")); |
|
1035 |
fw.write(DxfGroup.toString(9, "$PLIMMIN")); |
|
1036 |
fw.write(DxfGroup.toString(10, 0.0, 1)); |
|
1037 |
fw.write(DxfGroup.toString(20, 0.0, 1)); |
|
1038 |
fw.write(DxfGroup.toString(9, "$PLIMMAX")); |
|
1039 |
fw.write(DxfGroup.toString(10, 12.0, 1)); |
|
1040 |
fw.write(DxfGroup.toString(20, 9.0, 1)); |
|
1041 |
fw.write(DxfGroup.toString(9, "$UNITMODE") + DxfGroup.toString(70, 0)); |
|
1042 |
fw.write(DxfGroup.toString(9, "$VISRETAIN") + DxfGroup.toString(70, 0)); |
|
1043 |
fw.write(DxfGroup.toString(9, "$PLINEGEN") + DxfGroup.toString(70, 1)); |
|
1044 |
fw.write(DxfGroup.toString(9, "$PSLTSCALE") + DxfGroup.toString(70, 0)); |
|
1045 |
fw.write(DxfGroup.toString(9, "$TREEDEPTH") + DxfGroup.toString(70, 3020)); |
|
1046 |
fw.write(DxfGroup.toString(9, "$DWGCODEPAGE") + DxfGroup.toString(3, "ansi_1252")); |
|
1047 |
/* |
|
1048 |
fw.write(DxfGroup.toString(9, "$ELEVATION")); |
|
1049 |
fw.write(DxfGroup.toString(40, 0.0, 3)); |
|
1050 |
fw.write(DxfGroup.toString(9, "$LIMCHECK")); |
|
1051 |
fw.write(DxfGroup.toString(70, 1)); |
|
1052 |
fw.write(DxfGroup.toString(9, "$LUNITS")); |
|
1053 |
fw.write(DxfGroup.toString(70, 2)); |
|
1054 |
fw.write(DxfGroup.toString(9, "$LUPREC")); |
|
1055 |
fw.write(DxfGroup.toString(70, 2));*/ |
|
1056 |
fw.write(DxfGroup.toString(0, "ENDSEC")); |
|
1057 |
} |
|
1058 |
|
|
1059 |
/** |
|
1060 |
* Escritor de la secci�n TABLES de un DXF. |
|
1061 |
* |
|
1062 |
* @param fw, FileWriter |
|
1063 |
* @throws IOException |
|
1064 |
*/ |
|
1065 |
public void writeTables(FileWriter fw) throws IOException { |
|
1066 |
fw.write(DxfGroup.toString(0, "SECTION")); |
|
1067 |
fw.write(DxfGroup.toString(2, "TABLES")); |
|
1068 |
// esta tampoco. |
|
1069 |
writeVPortTable(fw); |
|
1070 |
writeLTypeTable(fw); |
|
1071 |
writeLayerTable(fw); |
|
1072 |
writeStyleTable(fw); |
|
1073 |
// estas no son las provocan el pete. |
|
1074 |
writeViewTable(fw); |
|
1075 |
writeUCSTable(fw); |
|
1076 |
// esta provoca el pete. Y si no se pone las tablas aparecen |
|
1077 |
// incompletas y acad no abre el fichero ... |
|
1078 |
writeAppidTable(fw); |
|
1079 |
writeDimStyleTable(fw); |
|
1080 |
// esta no provoca pete. |
|
1081 |
writeBlockRecordTable(fw); |
|
1082 |
fw.write(DxfGroup.toString(0, "ENDSEC")); |
|
1083 |
} |
|
1084 |
|
|
1085 |
/** |
|
1086 |
* Escritor de la tabla VPORT. |
|
1087 |
* |
|
1088 |
* @param fw |
|
1089 |
* @throws IOException |
|
1090 |
*/ |
|
1091 |
public void writeVPortTable(FileWriter fw) throws IOException { |
|
1092 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1093 |
fw.write(DxfGroup.toString(2, "VPORT")); |
|
1094 |
fw.write(DxfGroup.toString(5, 8)); |
|
1095 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1096 |
fw.write(DxfGroup.toString(70, 0)); |
|
1097 |
/*fw.write(DxfGroup.toString(70, 1)); |
|
1098 |
fw.write(DxfGroup.toString(0, "VPORT")); |
|
1099 |
fw.write(DxfGroup.toString(5, 30)); |
|
1100 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1101 |
fw.write(DxfGroup.toString(100, "AcDbViewportTableRecord")); |
|
1102 |
fw.write(DxfGroup.toString(2, "*Active")); |
|
1103 |
fw.write(DxfGroup.toString(70, 0)); |
|
1104 |
fw.write(DxfGroup.toString(10, 0.0, 4)); |
|
1105 |
fw.write(DxfGroup.toString(20, 0.0, 4)); |
|
1106 |
fw.write(DxfGroup.toString(11, 1.0, 4)); |
|
1107 |
fw.write(DxfGroup.toString(21, 1.0, 4)); |
|
1108 |
fw.write(DxfGroup.toString(12, 286.30555555555549, 10)); |
|
1109 |
fw.write(DxfGroup.toString(22, 148.5, 4)); |
|
1110 |
fw.write(DxfGroup.toString(13, 0.0, 4)); |
|
1111 |
fw.write(DxfGroup.toString(23, 0.0, 4)); |
|
1112 |
fw.write(DxfGroup.toString(14, 10.0, 4)); |
|
1113 |
fw.write(DxfGroup.toString(24, 10.0, 4)); |
|
1114 |
fw.write(DxfGroup.toString(15, 10.0, 4)); |
|
1115 |
fw.write(DxfGroup.toString(25, 10.0, 4)); |
|
1116 |
fw.write(DxfGroup.toString(16, 0.0, 4)); |
|
1117 |
fw.write(DxfGroup.toString(26, 0.0, 4)); |
|
1118 |
fw.write(DxfGroup.toString(36, 1.0, 4)); |
|
1119 |
fw.write(DxfGroup.toString(17, 0.0, 4)); |
|
1120 |
fw.write(DxfGroup.toString(27, 0.0, 4)); |
|
1121 |
fw.write(DxfGroup.toString(37, 0.0, 4)); |
|
1122 |
fw.write(DxfGroup.toString(40, 297.0, 4)); |
|
1123 |
fw.write(DxfGroup.toString(41, 1.92798353909465, 10)); |
|
1124 |
fw.write(DxfGroup.toString(42, 50.0, 4)); |
|
1125 |
fw.write(DxfGroup.toString(43, 0.0, 4)); |
|
1126 |
fw.write(DxfGroup.toString(44, 0.0, 4)); |
|
1127 |
fw.write(DxfGroup.toString(50, 0.0, 4)); |
|
1128 |
fw.write(DxfGroup.toString(51, 0.0, 4)); |
|
1129 |
fw.write(DxfGroup.toString(71, 0)); |
|
1130 |
fw.write(DxfGroup.toString(72, 100)); |
|
1131 |
fw.write(DxfGroup.toString(73, 1)); |
|
1132 |
fw.write(DxfGroup.toString(74, 3)); |
|
1133 |
fw.write(DxfGroup.toString(75, 1)); |
|
1134 |
fw.write(DxfGroup.toString(76, 1)); |
|
1135 |
fw.write(DxfGroup.toString(77, 0)); |
|
1136 |
fw.write(DxfGroup.toString(78, 0)); |
|
1137 |
fw.write(DxfGroup.toString(281, 0)); |
|
1138 |
fw.write(DxfGroup.toString(65, 1)); |
|
1139 |
fw.write(DxfGroup.toString(110, 0.0, 4)); |
|
1140 |
fw.write(DxfGroup.toString(120, 0.0, 4)); |
|
1141 |
fw.write(DxfGroup.toString(130, 0.0, 4)); |
|
1142 |
fw.write(DxfGroup.toString(111, 1.0, 4)); |
|
1143 |
fw.write(DxfGroup.toString(121, 0.0, 4)); |
|
1144 |
fw.write(DxfGroup.toString(131, 0.0, 4)); |
|
1145 |
fw.write(DxfGroup.toString(112, 0.0, 4)); |
|
1146 |
fw.write(DxfGroup.toString(122, 1.0, 4)); |
|
1147 |
fw.write(DxfGroup.toString(132, 0.0, 4)); |
|
1148 |
fw.write(DxfGroup.toString(79, 0)); |
|
1149 |
fw.write(DxfGroup.toString(146, 0.0, 4));*/ |
|
1150 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1151 |
} |
|
1152 |
|
|
1153 |
/** |
|
1154 |
* Escritor de la tabla LTYPE. |
|
1155 |
* |
|
1156 |
* @param fw |
|
1157 |
* @throws IOException |
|
1158 |
*/ |
|
1159 |
public void writeLTypeTable(FileWriter fw) throws IOException { |
|
1160 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1161 |
fw.write(DxfGroup.toString(2, "LTYPE")); |
|
1162 |
fw.write(DxfGroup.toString(5, 5)); |
|
1163 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1164 |
fw.write(DxfGroup.toString(70, 1)); |
|
1165 |
// Aqui hay que crear un objeto DxfLType como el DxfLayer tambi�n basado en |
|
1166 |
// el lector de DXF de Mich. |
|
1167 |
/*DxfTABLE_LTYPE_ITEM ltype = |
|
1168 |
new DxfTABLE_LTYPE_ITEM("CONTINUE", 0, "", 65, 0f, new float[0]); |
|
1169 |
fw.write(ltype.toString());*/ |
|
1170 |
fw.write(DxfGroup.toString(0, "LTYPE")); |
|
1171 |
fw.write(DxfGroup.toString(5, 14)); |
|
1172 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1173 |
fw.write(DxfGroup.toString(100, "AcDbLinetypeTableRecord")); |
|
1174 |
fw.write(DxfGroup.toString(2, "ByBlock")); |
|
1175 |
fw.write(DxfGroup.toString(70, 0)); |
|
1176 |
fw.write(DxfGroup.toString(3, "")); |
|
1177 |
fw.write(DxfGroup.toString(72, 65)); |
|
1178 |
fw.write(DxfGroup.toString(73, 0)); |
|
1179 |
fw.write(DxfGroup.toString(40, 0.0, 4)); |
|
1180 |
fw.write(DxfGroup.toString(0, "LTYPE")); |
|
1181 |
fw.write(DxfGroup.toString(5, 15)); |
|
1182 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1183 |
fw.write(DxfGroup.toString(100, "AcDbLinetypeTableRecord")); |
|
1184 |
fw.write(DxfGroup.toString(2, "ByLayer")); |
|
1185 |
fw.write(DxfGroup.toString(70, 0)); |
|
1186 |
fw.write(DxfGroup.toString(3, "")); |
|
1187 |
fw.write(DxfGroup.toString(72, 65)); |
|
1188 |
fw.write(DxfGroup.toString(73, 0)); |
|
1189 |
fw.write(DxfGroup.toString(40, 0.0, 4)); |
|
1190 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1191 |
} |
|
1192 |
|
|
1193 |
/** |
|
1194 |
* Escritor de la tabla LAYER. |
|
1195 |
* |
|
1196 |
* @param fw |
|
1197 |
* @throws IOException |
|
1198 |
*/ |
|
1199 |
public void writeLayerTable(FileWriter fw) throws IOException { |
|
1200 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1201 |
fw.write(DxfGroup.toString(2, "LAYER")); |
|
1202 |
fw.write(DxfGroup.toString(5, 2)); |
|
1203 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1204 |
fw.write(DxfGroup.toString(70, 1)); |
|
1205 |
//layer = new DxfLayer(layerName, 0, 131, "CONTINUOUS"); |
|
1206 |
//fw.write(layer.toString()); |
|
1207 |
//fw.write(((DxfEntityMaker) entityMaker).getLayers().toDxfString()); |
|
1208 |
fw.write(DxfGroup.toString(0, "LAYER")); |
|
1209 |
fw.write(DxfGroup.toString(5, 10)); |
|
1210 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1211 |
fw.write(DxfGroup.toString(100, "AcDbLayerTableRecord")); |
|
1212 |
fw.write(DxfGroup.toString(2, "0")); |
|
1213 |
fw.write(DxfGroup.toString(70, 0)); |
|
1214 |
fw.write(DxfGroup.toString(62, 7)); |
|
1215 |
fw.write(DxfGroup.toString(6, "CONTINUOUS")); |
|
1216 |
fw.write(DxfGroup.toString(390, "F")); |
|
1217 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1218 |
} |
|
1219 |
|
|
1220 |
/** |
|
1221 |
* Escritor de la tabla STYLE. |
|
1222 |
* |
|
1223 |
* @param fw |
|
1224 |
* @throws IOException |
|
1225 |
*/ |
|
1226 |
public void writeStyleTable(FileWriter fw) throws IOException { |
|
1227 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1228 |
fw.write(DxfGroup.toString(2, "STYLE")); |
|
1229 |
fw.write(DxfGroup.toString(5, 3)); |
|
1230 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1231 |
fw.write(DxfGroup.toString(70, 0)); |
|
1232 |
/*fw.write(DxfGroup.toString(70, 1)); |
|
1233 |
DxfTABLE_STYLE_ITEM style = |
|
1234 |
new DxfTABLE_STYLE_ITEM("STANDARD", 0, 0f, 1f, 0f, 0, 1.0f, "xxx.txt", "yyy.txt"); |
|
1235 |
fw.write(style.toString());*/ |
|
1236 |
fw.write(DxfGroup.toString(0, "STYLE")); |
|
1237 |
fw.write(DxfGroup.toString(5, 11)); |
|
1238 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1239 |
fw.write(DxfGroup.toString(100, "AcDbTextStyleTableRecord")); |
|
1240 |
fw.write(DxfGroup.toString(2, "Standard")); |
|
1241 |
fw.write(DxfGroup.toString(70, 0)); |
|
1242 |
fw.write(DxfGroup.toString(71, 0)); |
|
1243 |
fw.write(DxfGroup.toString(40, 0.0, 4)); |
|
1244 |
fw.write(DxfGroup.toString(41, 1.0, 4)); |
|
1245 |
fw.write(DxfGroup.toString(42, 2.5, 4)); |
|
1246 |
fw.write(DxfGroup.toString(50, 0.0, 4)); |
|
1247 |
fw.write(DxfGroup.toString(3, "txt")); |
|
1248 |
fw.write(DxfGroup.toString(4, "")); |
|
1249 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1250 |
} |
|
1251 |
|
|
1252 |
/** |
|
1253 |
* Escritor de la tabla VIEW. |
|
1254 |
* |
|
1255 |
* @param fw |
|
1256 |
* @throws IOException |
|
1257 |
*/ |
|
1258 |
public void writeViewTable(FileWriter fw) throws IOException { |
|
1259 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1260 |
fw.write(DxfGroup.toString(2, "VIEW")); |
|
1261 |
fw.write(DxfGroup.toString(5, 6)); |
|
1262 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1263 |
fw.write(DxfGroup.toString(70, 0)); |
|
1264 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1265 |
} |
|
1266 |
|
|
1267 |
/** |
|
1268 |
* Escritor de la tabla UCS. |
|
1269 |
* |
|
1270 |
* @param fw |
|
1271 |
* @throws IOException |
|
1272 |
*/ |
|
1273 |
public void writeUCSTable(FileWriter fw) throws IOException { |
|
1274 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1275 |
fw.write(DxfGroup.toString(2, "UCS")); |
|
1276 |
fw.write(DxfGroup.toString(5, 7)); |
|
1277 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1278 |
fw.write(DxfGroup.toString(70, 0)); |
|
1279 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1280 |
} |
|
1281 |
|
|
1282 |
/** |
|
1283 |
* Escritor de la tabla APPID. |
|
1284 |
* |
|
1285 |
* @param fw |
|
1286 |
* @throws IOException |
|
1287 |
*/ |
|
1288 |
public void writeAppidTable(FileWriter fw) throws IOException { |
|
1289 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1290 |
fw.write(DxfGroup.toString(2, "APPID")); |
|
1291 |
fw.write(DxfGroup.toString(5, 9)); |
|
1292 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1293 |
fw.write(DxfGroup.toString(70, 1)); |
|
1294 |
fw.write(DxfGroup.toString(0, "APPID")); |
|
1295 |
fw.write(DxfGroup.toString(5, 12)); |
|
1296 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1297 |
fw.write(DxfGroup.toString(100, "AcDbRegAppTableRecord")); |
|
1298 |
fw.write(DxfGroup.toString(2, "ACAD")); |
|
1299 |
fw.write(DxfGroup.toString(70, 1)); |
|
1300 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1301 |
} |
|
1302 |
|
|
1303 |
/** |
|
1304 |
* Escritor de la tabla DIMSTYLE. |
|
1305 |
* |
|
1306 |
* @param fw |
|
1307 |
* @throws IOException |
|
1308 |
*/ |
|
1309 |
public void writeDimStyleTable(FileWriter fw) throws IOException { |
|
1310 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1311 |
fw.write(DxfGroup.toString(2, "DIMSTYLE")); |
|
1312 |
fw.write(DxfGroup.toString(5, "A")); |
|
1313 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1314 |
fw.write(DxfGroup.toString(70, 0)); |
|
1315 |
fw.write(DxfGroup.toString(100, "AcDbDimStyleTable")); |
|
1316 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1317 |
} |
|
1318 |
|
|
1319 |
/** |
|
1320 |
* Escritor de la tabla BLOCK_RECORD. |
|
1321 |
* |
|
1322 |
* @param fw |
|
1323 |
* @throws IOException |
|
1324 |
*/ |
|
1325 |
public void writeBlockRecordTable(FileWriter fw) throws IOException { |
|
1326 |
fw.write(DxfGroup.toString(0, "TABLE")); |
|
1327 |
fw.write(DxfGroup.toString(2, "BLOCK_RECORD")); |
|
1328 |
fw.write(DxfGroup.toString(5, 1)); |
|
1329 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTable")); |
|
1330 |
fw.write(DxfGroup.toString(70, 1)); |
|
1331 |
fw.write(DxfGroup.toString(0, "BLOCK_RECORD")); |
|
1332 |
fw.write(DxfGroup.toString(5, "1F")); |
|
1333 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1334 |
fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord")); |
|
1335 |
fw.write(DxfGroup.toString(2, "*Model_Space")); |
|
1336 |
fw.write(DxfGroup.toString(340, "22")); |
|
1337 |
fw.write(DxfGroup.toString(0, "BLOCK_RECORD")); |
|
1338 |
fw.write(DxfGroup.toString(5, "1B")); |
|
1339 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1340 |
fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord")); |
|
1341 |
fw.write(DxfGroup.toString(2, "*Paper_Space")); |
|
1342 |
fw.write(DxfGroup.toString(340, "1E")); |
|
1343 |
fw.write(DxfGroup.toString(0, "BLOCK_RECORD")); |
|
1344 |
fw.write(DxfGroup.toString(5, "23")); |
|
1345 |
fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
|
1346 |
fw.write(DxfGroup.toString(100, "AcDbBlockTableRecord")); |
|
1347 |
fw.write(DxfGroup.toString(2, "*Paper_Space0")); |
|
1348 |
fw.write(DxfGroup.toString(340, "26")); |
|
1349 |
fw.write(DxfGroup.toString(0, "ENDTAB")); |
|
1350 |
} |
|
1351 |
|
|
1352 |
/** |
|
1353 |
* Escritor de la secci�n de bloques por defecto de un DXF2000. |
|
1354 |
* |
|
1355 |
* @param fw |
|
1356 |
* @throws IOException |
|
1357 |
*/ |
|
1358 |
public void writeBlocks(FileWriter fw) throws IOException { |
|
1359 |
fw.write(DxfGroup.toString(0, "SECTION")); |
|
1360 |
fw.write(DxfGroup.toString(2, "BLOCKS")); |
|
1361 |
fw.write(DxfGroup.toString(0, "BLOCK")); |
|
1362 |
fw.write(DxfGroup.toString(5, "20")); |
|
1363 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1364 |
fw.write(DxfGroup.toString(8, "0")); |
|
1365 |
fw.write(DxfGroup.toString(100, "AcDbBlockBegin")); |
|
1366 |
fw.write(DxfGroup.toString(2, "*Model_Space")); |
|
1367 |
fw.write(DxfGroup.toString(70, 0)); |
|
1368 |
fw.write(DxfGroup.toString(10, 0.0, 4)); |
|
1369 |
fw.write(DxfGroup.toString(20, 0.0, 4)); |
|
1370 |
fw.write(DxfGroup.toString(30, 0.0, 4)); |
|
1371 |
fw.write(DxfGroup.toString(3, "*Model_Space")); |
|
1372 |
fw.write(DxfGroup.toString(1, "")); |
|
1373 |
fw.write(DxfGroup.toString(0, "ENDBLK")); |
|
1374 |
fw.write(DxfGroup.toString(5, "21")); |
|
1375 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1376 |
fw.write(DxfGroup.toString(8, "0")); |
|
1377 |
fw.write(DxfGroup.toString(100, "AcDbBlockEnd")); |
|
1378 |
fw.write(DxfGroup.toString(0, "BLOCK")); |
|
1379 |
fw.write(DxfGroup.toString(5, "1C")); |
|
1380 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1381 |
fw.write(DxfGroup.toString(67, 1)); |
|
1382 |
fw.write(DxfGroup.toString(8, "0")); |
|
1383 |
fw.write(DxfGroup.toString(100, "AcDbBlockBegin")); |
|
1384 |
fw.write(DxfGroup.toString(2, "*Paper_Space")); |
|
1385 |
fw.write(DxfGroup.toString(70, 0)); |
|
1386 |
fw.write(DxfGroup.toString(10, 0.0, 4)); |
|
1387 |
fw.write(DxfGroup.toString(20, 0.0, 4)); |
|
1388 |
fw.write(DxfGroup.toString(30, 0.0, 4)); |
|
1389 |
fw.write(DxfGroup.toString(3, "*Paper_Space")); |
|
1390 |
fw.write(DxfGroup.toString(1, "")); |
|
1391 |
fw.write(DxfGroup.toString(0, "ENDBLK")); |
|
1392 |
fw.write(DxfGroup.toString(5, "1D")); |
|
1393 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1394 |
fw.write(DxfGroup.toString(67, 1)); |
|
1395 |
fw.write(DxfGroup.toString(8, "0")); |
|
1396 |
fw.write(DxfGroup.toString(100, "AcDbBlockEnd")); |
|
1397 |
fw.write(DxfGroup.toString(0, "BLOCK")); |
|
1398 |
fw.write(DxfGroup.toString(5, "24")); |
|
1399 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1400 |
fw.write(DxfGroup.toString(8, "0")); |
|
1401 |
fw.write(DxfGroup.toString(100, "AcDbBlockBegin")); |
|
1402 |
fw.write(DxfGroup.toString(2, "*Paper_Space0")); |
|
1403 |
fw.write(DxfGroup.toString(70, 0)); |
|
1404 |
fw.write(DxfGroup.toString(10, 0.0, 4)); |
|
1405 |
fw.write(DxfGroup.toString(20, 0.0, 4)); |
|
1406 |
fw.write(DxfGroup.toString(30, 0.0, 4)); |
|
1407 |
fw.write(DxfGroup.toString(3, "*Paper_Space0")); |
|
1408 |
fw.write(DxfGroup.toString(1, "")); |
|
1409 |
fw.write(DxfGroup.toString(0, "ENDBLK")); |
|
1410 |
fw.write(DxfGroup.toString(5, "25")); |
|
1411 |
fw.write(DxfGroup.toString(100, "AcDbEntity")); |
|
1412 |
fw.write(DxfGroup.toString(8, "0")); |
|
1413 |
fw.write(DxfGroup.toString(100, "AcDbBlockEnd")); |
|
1414 |
fw.write(DxfGroup.toString(0, "ENDSEC")); |
|
1415 |
} |
|
1416 |
|
|
1417 |
/** |
|
1418 |
* Escritor de la secci�n ENTITIES de entidades. |
|
1419 |
* |
|
1420 |
* @param fw |
|
1421 |
* @throws IOException |
|
1422 |
*/ |
|
1423 |
public void writeEntities(FileWriter fw) throws IOException { |
|
1424 |
// ECRITURE DES FEATURES |
|
1425 |
fw.write(DxfGroup.toString(0, "SECTION")); |
|
1426 |
fw.write(DxfGroup.toString(2, "ENTITIES")); |
|
1427 |
if (cadFlag) { |
|
1428 |
fw.write(((DxfEntityMaker) entityMaker).getEntities().toDxfString()); |
|
1429 |
} else { |
|
1430 |
//fw.write(((DxfFeatureMaker) entityMaker).getObjects().toDxfString()); |
|
1431 |
} |
|
1432 |
fw.write(DxfGroup.toString(0, "ENDSEC")); |
|
1433 |
} |
|
1434 |
|
|
1435 |
/** |
|
1436 |
* 050224, jmorell: Escritura de la secci�n OBJECTS seg�n QCAD. Writes a |
|
1437 |
* objects section. This section is needed in VER_R13. Note that this method |
|
1438 |
* currently only writes a faked OBJECTS section to make the file readable |
|
1439 |
* by Aut*cad. |
|
1440 |
*/ |
|
1441 |
public void writeObjects(FileWriter fw) throws IOException { |
|
1442 |
//int dicId, dicId2, dicId3, dicId4, dicId5; |
|
1443 |
//int dicId5; |
|
1444 |
|
|
1445 |
fw.write(DxfGroup.toString(0, "SECTION")); |
|
1446 |
fw.write(DxfGroup.toString(2, "OBJECTS")); |
|
1447 |
fw.write(DxfGroup.toString(0, "DICTIONARY")); |
|
1448 |
//fw.write(DxfGroup.toString(5, 0xC); // C |
|
1449 |
fw.write(DxfGroup.toString(5, "C")); |
|
1450 |
//fw.write(DxfGroup.toString(330, 0); |
|
1451 |
fw.write(DxfGroup.toString(100, "AcDbDictionary")); |
|
1452 |
fw.write(DxfGroup.toString(280, 0)); |
|
1453 |
fw.write(DxfGroup.toString(281, 1)); |
|
1454 |
fw.write(DxfGroup.toString(3, "ACAD_GROUP")); |
|
1455 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()); // D |
|
1456 |
fw.write(DxfGroup.toString(350, "D")); // D |
|
1457 |
fw.write(DxfGroup.toString(3, "ACAD_LAYOUT")); |
|
1458 |
fw.write(DxfGroup.toString(350, "1A")); |
|
1459 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()+0); // 1A |
|
1460 |
fw.write(DxfGroup.toString(3, "ACAD_MLINESTYLE")); |
|
1461 |
fw.write(DxfGroup.toString(350, "17")); |
|
1462 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()+1); // 17 |
|
1463 |
fw.write(DxfGroup.toString(3, "ACAD_PLOTSETTINGS")); |
|
1464 |
fw.write(DxfGroup.toString(350, "19")); |
|
1465 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()+2); // 19 |
|
1466 |
fw.write(DxfGroup.toString(3, "ACAD_PLOTSTYLENAME")); |
|
1467 |
fw.write(DxfGroup.toString(350, "E")); |
|
1468 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()+3); // E |
|
1469 |
fw.write(DxfGroup.toString(3, "AcDbVariableDictionary")); |
|
1470 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle())); // 2C |
|
1471 |
fw.write(DxfGroup.toString(350, "2C")); // 2C |
|
1472 |
fw.write(DxfGroup.toString(0, "DICTIONARY")); |
|
1473 |
fw.write(DxfGroup.toString(5, "D")); |
|
1474 |
//dw.handle(); // D |
|
1475 |
//fw.write(DxfGroup.toString(330, 0xC); |
|
1476 |
fw.write(DxfGroup.toString(100, "AcDbDictionary")); |
|
1477 |
fw.write(DxfGroup.toString(280, 0)); |
|
1478 |
fw.write(DxfGroup.toString(281, 1)); |
|
1479 |
fw.write(DxfGroup.toString(0, "ACDBDICTIONARYWDFLT")); |
|
1480 |
fw.write(DxfGroup.toString(5, "E")); |
|
1481 |
//dicId4 = dw.handle(); // E |
|
1482 |
//fw.write(DxfGroup.toString(330, 0xC); // C |
|
1483 |
fw.write(DxfGroup.toString(100, "AcDbDictionary")); |
|
1484 |
fw.write(DxfGroup.toString(281, 1)); |
|
1485 |
fw.write(DxfGroup.toString(3, "Normal")); |
|
1486 |
fw.write(DxfGroup.toString(350, "F")); |
|
1487 |
//fw.write(DxfGroup.toString(350, dw.getNextHandle()+5); // F |
|
1488 |
fw.write(DxfGroup.toString(100, "AcDbDictionaryWithDefault")); |
|
1489 |
fw.write(DxfGroup.toString(340, "F")); |
|
1490 |
//fw.write(DxfGroup.toString(340, dw.getNextHandle()+5); // F |
|
1491 |
fw.write(DxfGroup.toString(0, "ACDBPLACEHOLDER")); |
|
1492 |
fw.write(DxfGroup.toString(5, "F")); |
|
1493 |
//dw.handle(); // F |
|
1494 |
//fw.write(DxfGroup.toString(330, dicId4); // E |
|
1495 |
fw.write(DxfGroup.toString(0, "DICTIONARY")); |
|
1496 |
//dicId3 = dw.handle(); // 17 |
Also available in: Unified diff