Revision 666

View differences:

tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/IDwgExtrusionable.java
1
/*
2
 * Created on 09-ene-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: IDwgExtrusionable.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.3.2.2  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.3  2007/02/15 20:35:13  azabala
52
* comments
53
*
54
* Revision 1.2  2007/02/15 15:32:51  azabala
55
* added comments
56
*
57
* Revision 1.1  2007/01/12 19:29:58  azabala
58
* first version in cvs
59
*
60
*
61
*/
62
package org.gvsig.dwg.lib;
63
/**
64
 * All dwg drawing entities that need to compute
65
 * an extrussion before draw them must implement
66
 * this interface.
67
 * 
68
 * This "extrusion" transforms coordinates from the 
69
 * "Object Coordinate System" (OCS) to the
70
 * "World Coordinate System" (WCS).
71
 * 
72
 *  For some entities, the OCS is equivalent to the 
73
 *  WCS and all points are expressed in World coordinates. 
74

  
75
		Entities 						Notes
76

  
77
		3D entities such as 			These entities do not lie in a 
78
		line, point, 3dface,			particular plane. All points are  
79
		3D polyline,					expressed in world coordinates.  
80
		3D vertex, 3D mesh, 			Of these entities, only lines and points can be extruded. 
81
		3D mesh vertex
82
	
83

  
84

  
85

  
86
		2D entities such as circle, arc, 		These entities are planar in nature. 
87
		solid, trace, text, attrib, attdef, 	All points are expressed in object coordinates. 
88
		shape, insert, 2D polyline, 2D vertex, 	All of these entities can be extruded. 
89
		lwpolyline, hatch, image
90
	
91

  
92
 * 
93
 * 
94
 * */
95
public interface IDwgExtrusionable {
96
	public void applyExtrussion();
97
}
98

  
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/DwgObjectFactory.java
1
/*
2
 * Created on 27-dic-2006
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
 *
46
 * $Id: DwgObjectFactory.java 28969 2009-05-25 13:23:12Z jmvivo $
47
 * $Log$
48
 * Revision 1.14.2.2  2007-03-21 19:49:16  azabala
49
 * implementation of dwg 12, 13, 14.
50
 *
51
 * Revision 1.18  2007/03/20 19:55:27  azabala
52
 * source code cleaning
53
 *
54
 * Revision 1.17  2007/03/06 19:39:38  azabala
55
 * Changes to adapt dwg 12 to general architecture
56
 *
57
 * Revision 1.16  2007/03/02 20:31:22  azabala
58
 * *** empty log message ***
59
 *
60
 * Revision 1.15  2007/03/01 19:59:46  azabala
61
 * source code cleaning
62
 *
63
 * Revision 1.14  2007/02/22 20:45:51  azabala
64
 * changes to add dwg 12 entities creation
65
 *
66
 * Revision 1.13  2007/02/14 09:20:32  fdiaz
67
 * Eliminado un comentario y habilitado de nuevo el else del final del metodo create.
68
 *
69
 * Revision 1.12  2007/02/08 20:27:06  azabala
70
 * solved bug with lwpolylines
71
 *
72
 * Revision 1.11  2007/02/08 10:27:35  azabala
73
 * if the type is unknown it returns NULL
74
 *
75
 * Revision 1.10  2007/02/06 20:17:29  azabala
76
 * *** empty log message ***
77
 *
78
 * Revision 1.9  2007/02/02 12:39:52  azabala
79
 * Added new dwg entities
80
 *
81
 * Revision 1.8  2007/02/01 20:00:27  azabala
82
 * *** empty log message ***
83
 *
84
 * Revision 1.7  2007/01/31 18:20:58  fdiaz
85
 * A�adido un return null al final de metodo create por si no entra en ninguna de las condiciones.
86
 *
87
 * Revision 1.6  2007/01/31 10:01:11  fdiaz
88
 * A�adido el DwgDictionary.
89
 *
90
 * Revision 1.5  2007/01/30 19:40:23  azabala
91
 * *** empty log message ***
92
 *
93
 * Revision 1.4  2007/01/30 12:37:18  azabala
94
 * *** empty log message ***
95
 *
96
 * Revision 1.3  2007/01/24 20:14:31  azabala
97
 * implementation of reader of V14
98
 *
99
 * Revision 1.2  2007/01/12 19:35:00  azabala
100
 * *** empty log message ***
101
 *
102
 * Revision 1.1  2007/01/09 15:39:15  azabala
103
 * *** empty log message ***
104
 *
105
 *
106
 */
107
package org.gvsig.dwg.lib;
108

  
109
import org.gvsig.dwg.lib.objects.DwgArc;
110
import org.gvsig.dwg.lib.objects.DwgAttdef;
111
import org.gvsig.dwg.lib.objects.DwgAttrib;
112
import org.gvsig.dwg.lib.objects.DwgBlock;
113
import org.gvsig.dwg.lib.objects.DwgBlockControl;
114
import org.gvsig.dwg.lib.objects.DwgBlockHeader;
115
import org.gvsig.dwg.lib.objects.DwgCircle;
116
import org.gvsig.dwg.lib.objects.DwgDictionary;
117
import org.gvsig.dwg.lib.objects.DwgDictionaryVar;
118
import org.gvsig.dwg.lib.objects.DwgDimOrd;
119
import org.gvsig.dwg.lib.objects.DwgEllipse;
120
import org.gvsig.dwg.lib.objects.DwgEndblk;
121
import org.gvsig.dwg.lib.objects.DwgFace3D;
122
import org.gvsig.dwg.lib.objects.DwgHatch;
123
import org.gvsig.dwg.lib.objects.DwgIdBuffer;
124
import org.gvsig.dwg.lib.objects.DwgImage;
125
import org.gvsig.dwg.lib.objects.DwgImageDef;
126
import org.gvsig.dwg.lib.objects.DwgImageDefReactor;
127
import org.gvsig.dwg.lib.objects.DwgInsert;
128
import org.gvsig.dwg.lib.objects.DwgLayer;
129
import org.gvsig.dwg.lib.objects.DwgLayerControl;
130
import org.gvsig.dwg.lib.objects.DwgLayerIndex;
131
import org.gvsig.dwg.lib.objects.DwgLine;
132
import org.gvsig.dwg.lib.objects.DwgLwPolyline;
133
import org.gvsig.dwg.lib.objects.DwgMText;
134
import org.gvsig.dwg.lib.objects.DwgMeshPolyline;
135
import org.gvsig.dwg.lib.objects.DwgOle2Frame;
136
import org.gvsig.dwg.lib.objects.DwgPFacePolyline;
137
import org.gvsig.dwg.lib.objects.DwgPoint;
138
import org.gvsig.dwg.lib.objects.DwgPolyline2D;
139
import org.gvsig.dwg.lib.objects.DwgPolyline3D;
140
import org.gvsig.dwg.lib.objects.DwgRasterVariables;
141
import org.gvsig.dwg.lib.objects.DwgSeqend;
142
import org.gvsig.dwg.lib.objects.DwgSolid;
143
import org.gvsig.dwg.lib.objects.DwgSortEntStable;
144
import org.gvsig.dwg.lib.objects.DwgSpatialFilter;
145
import org.gvsig.dwg.lib.objects.DwgSpatialIndex;
146
import org.gvsig.dwg.lib.objects.DwgSpline;
147
import org.gvsig.dwg.lib.objects.DwgText;
148
import org.gvsig.dwg.lib.objects.DwgVertex2D;
149
import org.gvsig.dwg.lib.objects.DwgVertex3D;
150
import org.gvsig.dwg.lib.objects.DwgVertexMesh;
151
import org.gvsig.dwg.lib.objects.DwgVertexPFace;
152
import org.gvsig.dwg.lib.objects.DwgVertexPFaceFace;
153
import org.gvsig.dwg.lib.objects.DwgXRecord;
154

  
155

  
156
/**
157
 * Factory that creates dwg entities from its code (int value).
158
 * 
159
 * Some DWG entities dont have a fixed "type code". Instead, their type
160
 * is specified in the CLASSES section of the dwg file.
161
 * 
162
 * 
163
 * 
164
 * It's a singleton
165
 *  
166
 */
167
public class DwgObjectFactory {
168

  
169
	private static DwgObjectFactory _instance = new DwgObjectFactory();
170

  
171
	private DwgObjectFactory() {
172
	}
173
	
174
	/*
175
	 * Constants to represent polyline2d, polyline3d,
176
	 * vertex2d and vertex3d.
177
	 * */
178
//	public static final byte POLYLINE2D = 40;
179
//	public static final byte POLYLINE3D = 41;
180
//	public static final byte VERTEX2D = 50;
181
//	public static final byte VERTEX3D = 51;
182

  
183
	public static final DwgObjectFactory getInstance() {
184
		return _instance;
185
	}
186

  
187
	
188
	/**
189
	 * Creates a Dwg object instance from its type.
190
	 * 
191
	 * This method is used for DWG 13, 14, 2000 and 2004 files.
192
	 * 
193
	 * */
194
	public DwgObject create(int type, int index) {
195
		DwgObject obj = null;
196

  
197
		 if (type == 0x1) {
198
			obj = new DwgText(index);
199
			obj.setGraphicsFlag(true);
200
		} else if (type == 0x2) {
201
			obj = new DwgAttrib(index);
202
			obj.setGraphicsFlag(true);
203
		} else if (type == 0x3) {
204
			obj = new DwgAttdef(index);
205
			obj.setGraphicsFlag(true);
206
		} else if (type == 0x4) {
207
			obj = new DwgBlock(index);
208
			obj.setGraphicsFlag(true);
209
		} else if (type == 0x5) {
210
			obj = new DwgEndblk(index);
211
			obj.setGraphicsFlag(true);
212
		} else if (type == 0x6) {
213
			obj = new DwgSeqend(index);
214
			obj.setGraphicsFlag(true);
215
		} else if (type == 0x7) {
216
			obj = new DwgInsert(index);
217
			obj.setGraphicsFlag(true);
218
		} else if (type == 0x0A) {
219
			obj = new DwgVertex2D(index);
220
			obj.setGraphicsFlag(true);
221
		} else if (type == 0x0B) {
222
			obj = new DwgVertex3D(index);
223
			obj.setGraphicsFlag(true);
224
		} else if (type == 0x0C) {
225
			obj = new DwgVertexMesh(index);
226
			obj.setGraphicsFlag(true);
227
		} else if (type == 0x0D) {
228
			obj = new DwgVertexPFace(index);
229
			obj.setGraphicsFlag(true);
230
		} else if (type == 0x0E) {
231
			obj = new DwgVertexPFaceFace(index);
232
			obj.setGraphicsFlag(true);
233
		} else if (type == 0x0F) {
234
			obj = new DwgPolyline2D(index);
235
			obj.setGraphicsFlag(true);
236
		} else if (type == 0x10) {
237
			obj = new DwgPolyline3D(index);
238
			obj.setGraphicsFlag(true);
239
		} else if (type == 0x11) {
240
			obj = new DwgArc(index);
241
			obj.setGraphicsFlag(true);
242
		} else if (type == 0x12) {
243
			obj = new DwgCircle(index);
244
			obj.setGraphicsFlag(true);
245
		} else if (type == 0x13) {
246
			obj = new DwgLine(index);
247
			obj.setGraphicsFlag(true);
248
		}  else if (type == 0x1B) {
249
			obj = new DwgPoint(index);
250
			obj.setGraphicsFlag(true);
251
		} else if (type == 0x1D) {
252
			obj = new DwgPFacePolyline(index);
253
			obj.setGraphicsFlag(true);
254
		} else if (type == 0x1E) {
255
			obj = new DwgMeshPolyline(index);
256
			obj.setGraphicsFlag(true);
257
		} else if (type == 0x23) {
258
			obj = new DwgEllipse(index);
259
			obj.setGraphicsFlag(true);
260
		} else if (type == 0x24) {
261
			obj = new DwgSpline(index);
262
			obj.setGraphicsFlag(true);
263
		} else if (type == 0x2A) {
264
			obj = new DwgDictionary(index);
265
			obj.setGraphicsFlag(false);
266
		} else if (type == 0x2C) {
267
			obj = new DwgMText(index);
268
			obj.setGraphicsFlag(true);
269
		} else if (type == 0x30) {
270
			obj = new DwgBlockControl(index);
271
			obj.setGraphicsFlag(false);
272
		} else if (type == 0x31) {
273
			obj = new DwgBlockHeader(index);
274
			obj.setGraphicsFlag(false);
275
		} else if (type == 0x32) {
276
			obj = new DwgLayerControl(index);
277
			obj.setGraphicsFlag(false);
278
		} else if (type == 0x33) {
279
			obj = new DwgLayer(index);
280
			obj.setGraphicsFlag(false);
281
		} else if (type == 0x4D) {
282
			obj = new DwgLwPolyline(index);
283
			obj.setGraphicsFlag(true);
284
		} else if (type == 0x1F) {
285
			obj = new DwgSolid(index);
286
			obj.setGraphicsFlag(true);
287
		} 
288
		
289
//		else if (type == 0x15) {
290
//			obj = new DwgLinearDimension(index);
291
//			obj.setGraphicsFlag(true);
292
//		} 
293
		/*
294
		 * Segun los foros de OpenDWG:
295
		 * OLE2FRAME - 74 -> 0X4A
296
		   LWPOLYLINE - 77 -> 0X4D 
297
		   HATCH - 78 -> 0X4E
298
		 * 
299
		 * 
300
		 * */
301
		
302
		
303
		/*
304
		else if (type == 0x4A){
305
			obj = new DwgOle2Frame(index);
306
			obj.setGraphicsFlag(false);
307
		}
308
		
309
		
310
		else if (type == 0x4E){
311
			obj = new DwgHatch(index);
312
			obj.setGraphicsFlag(true);
313
		}
314
		
315
		else if (type == 0x4E) {
316
			obj = new DwgLwPolyline(index);
317
			obj.setGraphicsFlag(true);
318
		} else if (type == 0x4F) {
319
			obj = new DwgLwPolyline(index);
320
			obj.setGraphicsFlag(true);
321
		} else if (type == 0x50) {
322
			obj = new DwgLwPolyline(index);
323
			obj.setGraphicsFlag(true);
324
		} else if (type == 0x51) {
325
			obj = new DwgLwPolyline(index);
326
			obj.setGraphicsFlag(true);
327
		} else if (type == 0x52) {
328
			obj = new DwgLwPolyline(index);
329
			obj.setGraphicsFlag(true);
330
		} else if (type == 0x53) {
331
			obj = new DwgLwPolyline(index);
332
			obj.setGraphicsFlag(true);
333
		} 
334
		*/
335
		
336
		else {
337
//			obj = new DwgObject(index);
338
			return null;
339
		}
340
		obj.setType(type);
341
		return obj;
342
	}
343

  
344
	/**
345
	 * Creates a DwgObject from its DXF name.
346
	 * 
347
	 * This method is used to create entities without a fixed dwg code type
348
	 * (entities whose type is > 500)
349
	 * 
350
	 * This method is used for DWG 13, 14 and 2000 files.
351
	 *  
352
	 */
353
	public DwgObject create(String dxfName, int index) {
354
		//TODO De todas estas ver cuales son graficas,
355
		//para poner su graphicsFlag a true
356
		//ESTO MEJOR VA A SER CADA CLASE QUIEN LO HAGA, EN VEZ
357
		//DE LA FACTORIA
358
		
359
//		if (dxfName.equalsIgnoreCase("DICTIONARYVAR"))
360
//			return new DwgDictionaryVar(index);
361
//		else if (dxfName.equalsIgnoreCase("HATCH"))
362
//			return new DwgHatch(index);
363
//		else if (dxfName.equalsIgnoreCase("IDBUFFER"))
364
//			return new DwgIdBuffer(index);
365
//		else if (dxfName.equalsIgnoreCase("IMAGE"))
366
//			return new DwgImage(index);
367
//		else if (dxfName.equalsIgnoreCase("IMAGEDEF"))
368
//			return new DwgImageDef(index);
369
//		else if (dxfName.equalsIgnoreCase("IMAGEDEFREACTOR"))
370
//			return new DwgImageDefReactor(index);
371
//		else if (dxfName.equalsIgnoreCase("LAYER_INDEX"))
372
//			return new DwgLayerIndex(index);
373
//		else 
374
		if (dxfName.equalsIgnoreCase("LWPOLYLINE")){
375
			DwgLwPolyline solution = new DwgLwPolyline(index);
376
			solution.setGraphicsFlag(true);
377
			return solution;
378
		}
379
//		else if (dxfName.equalsIgnoreCase("OLE2FRAME"))
380
//			return new DwgOle2Frame(index);
381
//		else if (dxfName.equalsIgnoreCase("RASTERVARIABLES"))
382
//			return new DwgRasterVariables(index);
383
//		else if (dxfName.equalsIgnoreCase("SORTENTSTABLE"))
384
//			return new DwgSortEntStable(index);
385
//		else if (dxfName.equalsIgnoreCase("SPATIALFILTER"))
386
//			return new DwgSpatialFilter(index);
387
//		else if (dxfName.equalsIgnoreCase("SPATIALINDEX"))
388
//			return new DwgSpatialIndex(index);
389
//		else if (dxfName.equalsIgnoreCase("XRECORD"))
390
//			return new DwgXRecord(index);
391
		return null;
392
	}
393
	
394
	/**
395
	 * Creates a DWG object for DWG 12 files.
396
	 *  
397
	 * */
398
	public DwgObject create(byte kind, int index){
399
		switch(kind){
400
		case 1:
401
			return new DwgLine(index);
402
		case 2:
403
			return new DwgPoint(index);
404
		case 3:
405
			return new DwgCircle(index);
406
//		case 4://un dxf shape es un fichero externo que define una forma
407
			//(un tipo rudimentario de svg)
408
//			return new DwgShape()
409
		case 7:
410
			return new DwgText(index);
411
		case 8:
412
			return new DwgArc(index);
413
//		case 9: //It is a 3D quad
414
//			return new DwgTrace(index);
415
			
416
		case 11:
417
			return new DwgSolid(index);
418
		case 12:
419
			return new DwgBlockHeader(index);
420
		case 13:
421
			return new DwgEndblk(index);
422
		case 14:
423
			return new DwgInsert(index);
424
		case 15:
425
			return new DwgAttdef(index);
426
		case 16:
427
			return new DwgAttrib(index);	
428
		case 17://no estoy seguro de q esto sea SbEnd
429
			return new DwgSeqend(index);
430
		case 19://polyline is a particular case. Creation responsability is of Reader
431
			return null;
432
		case 20://vertex like polyline
433
			return null;
434
		case 22:
435
			return new DwgFace3D(index);
436
		case 23: //esto es Dim ??
437
			return new DwgDimOrd(index);
438
//		case 25://no implementado
439
//			return new DwgVPort(index);
440
			default:
441
				return null;
442
		}
443
	}
444
}
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgAttdefReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.awt.geom.Point2D;
8
import java.util.ArrayList;
9

  
10
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
11
import org.gvsig.dwg.lib.DwgHandleReference;
12
import org.gvsig.dwg.lib.DwgObject;
13
import org.gvsig.dwg.lib.DwgUtil;
14
import org.gvsig.dwg.lib.objects.DwgAttdef;
15

  
16

  
17
/**
18
 * @author alzabord
19
 *
20
 * TODO To change the template for this generated type comment go to
21
 * Window - Preferences - Java - Code Style - Code Templates
22
 */
23
public class DwgAttdefReader15 extends AbstractDwg15Reader{
24

  
25
	/* (non-Javadoc)
26
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
27
	 */
28
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
29
			if(!(dwgObj instanceof DwgAttdef))
30
				throw new RuntimeException("AttdefReader 15 solo lee Attdef");
31
			DwgAttdef att = (DwgAttdef) dwgObj;
32
			int bitPos = offset;
33
			bitPos = headTailReader.readObjectHeader(data, bitPos, att);
34
			ArrayList v = DwgUtil.getRawChar(data, bitPos);
35
			bitPos = ((Integer)v.get(0)).intValue();
36
			int dflag = ((Integer)v.get(1)).intValue();
37
			att.setDataFlag(dflag);
38
			if ((dflag & 0x1)==0) {
39
				v = DwgUtil.getRawDouble(data, bitPos);
40
				bitPos = ((Integer)v.get(0)).intValue();
41
				double elev = ((Double)v.get(1)).doubleValue();
42
				att.setElevation(elev);
43
			}
44
			v = DwgUtil.getRawDouble(data, bitPos);
45
			bitPos = ((Integer)v.get(0)).intValue();
46
			double x1 = ((Double)v.get(1)).doubleValue();
47
			v = DwgUtil.getRawDouble(data, bitPos);
48
			bitPos = ((Integer)v.get(0)).intValue();
49
			double y1 = ((Double)v.get(1)).doubleValue();
50
			att.setInsertionPoint(new Point2D.Double(x1, y1));
51
			double x=0, y=0, z=0;
52
			if ((dflag & 0x2)==0) {
53
				v = DwgUtil.getDefaultDouble(data, bitPos, x1);
54
				bitPos = ((Integer)v.get(0)).intValue();
55
				x = ((Double)v.get(1)).doubleValue();
56
				v = DwgUtil.getDefaultDouble(data, bitPos, y1);
57
				bitPos = ((Integer)v.get(0)).intValue();
58
				y = ((Double)v.get(1)).doubleValue();
59
			}
60
			att.setAlignmentPoint(new Point2D.Double(x, y));
61
			v = DwgUtil.testBit(data, bitPos);
62
			bitPos = ((Integer)v.get(0)).intValue();
63
			boolean flag = ((Boolean)v.get(1)).booleanValue();
64
			if (flag) {
65
				y = 0.0;
66
				x = y;
67
				z = 1.0;
68
			} else {
69
				v = DwgUtil.getBitDouble(data, bitPos);
70
				bitPos = ((Integer)v.get(0)).intValue();
71
				x = ((Double)v.get(1)).doubleValue();
72
				v = DwgUtil.getBitDouble(data, bitPos);
73
				bitPos = ((Integer)v.get(0)).intValue();
74
				y = ((Double)v.get(1)).doubleValue();
75
				v = DwgUtil.getBitDouble(data, bitPos);
76
				bitPos = ((Integer)v.get(0)).intValue();
77
				z = ((Double)v.get(1)).doubleValue();
78
			}
79
			att.setExtrusion(new double[]{x, y, z});
80
			v = DwgUtil.testBit(data, bitPos);
81
			bitPos = ((Integer)v.get(0)).intValue();
82
			flag = ((Boolean)v.get(1)).booleanValue();
83
		    double th;
84
			if (flag) {
85
				th=0.0;
86
			} else {
87
				v = DwgUtil.getBitDouble(data, bitPos);
88
				bitPos = ((Integer)v.get(0)).intValue();
89
				th = ((Double)v.get(1)).doubleValue();
90
			}
91
			att.setThickness(th);
92
			if ((dflag & 0x4)==0) {
93
				v = DwgUtil.getRawDouble(data, bitPos);
94
				bitPos = ((Integer)v.get(0)).intValue();
95
				double oblique = ((Double)v.get(1)).doubleValue();
96
				att.setObliqueAngle(oblique);
97
			}
98
			if ((dflag & 0x8)==0) {
99
				v = DwgUtil.getRawDouble(data, bitPos);
100
				bitPos = ((Integer)v.get(0)).intValue();
101
				double rot = ((Double)v.get(1)).doubleValue();
102
				att.setRotationAngle(rot);
103
			}
104
			v = DwgUtil.getRawDouble(data, bitPos);
105
			bitPos = ((Integer)v.get(0)).intValue();
106
			double height = ((Double)v.get(1)).doubleValue();
107
			att.setHeight(height);
108
			if ((dflag & 0x10)==0) {
109
				v = DwgUtil.getRawDouble(data, bitPos);
110
				bitPos = ((Integer)v.get(0)).intValue();
111
				double width = ((Double)v.get(1)).doubleValue();
112
				att.setWidthFactor(width);
113
			}
114
			v = DwgUtil.getTextString(data, bitPos);
115
			bitPos = ((Integer)v.get(0)).intValue();
116
			String text = (String)v.get(1);
117
			att.setText(text);
118
			if ((dflag & 0x20)==0) {
119
				v = DwgUtil.getBitShort(data, bitPos);
120
				bitPos = ((Integer)v.get(0)).intValue();
121
				int gen = ((Integer)v.get(1)).intValue();
122
				att.setGeneration(gen);
123
			}
124
			if ((dflag & 0x40)==0) {
125
				v = DwgUtil.getBitShort(data, bitPos);
126
				bitPos = ((Integer)v.get(0)).intValue();
127
				int halign = ((Integer)v.get(1)).intValue();
128
				att.setHalign(halign);
129
			}
130
			if ((dflag & 0x80)==0) {
131
				v = DwgUtil.getBitShort(data, bitPos);
132
				bitPos = ((Integer)v.get(0)).intValue();
133
				int valign = ((Integer)v.get(1)).intValue();
134
				att.setValign(valign);
135
			}
136
			v = DwgUtil.getTextString(data, bitPos);
137
			bitPos = ((Integer)v.get(0)).intValue();
138
			String tag = (String)v.get(1);
139
			att.setTag(tag);
140
			v = DwgUtil.getBitShort(data, bitPos);
141
			bitPos = ((Integer)v.get(0)).intValue();
142
			int fl = ((Integer)v.get(1)).intValue();
143
			att.setFieldLength(fl);
144
			v = DwgUtil.getRawChar(data, bitPos);
145
			bitPos = ((Integer)v.get(0)).intValue();
146
			int flags = ((Integer)v.get(1)).intValue();
147
			att.setFlags(flags);
148
			v = DwgUtil.getTextString(data, bitPos);
149
			bitPos = ((Integer)v.get(0)).intValue();
150
			String prompt = (String)v.get(1);
151
			att.setPrompt(prompt);
152
			bitPos = headTailReader.readObjectTailer(data, bitPos, att);
153
			DwgHandleReference styleHandle = new DwgHandleReference();
154
			bitPos = styleHandle.read(data, bitPos);
155
			att.setStyleHandle(styleHandle);
156
		}
157
}
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgPFaceReader15.java
1
/*
2
 * Created on 19-mar-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DwgPFaceReader15.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.1.2.1  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.1  2007/03/20 19:57:08  azabala
52
* source code cleaning
53
*
54
*
55
*/
56
package org.gvsig.dwg.lib.readers.v15;
57

  
58
import java.util.List;
59

  
60
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
61
import org.gvsig.dwg.lib.DwgHandleReference;
62
import org.gvsig.dwg.lib.DwgObject;
63
import org.gvsig.dwg.lib.DwgUtil;
64
import org.gvsig.dwg.lib.objects.DwgPFacePolyline;
65

  
66

  
67
public class DwgPFaceReader15 extends AbstractDwg15Reader {
68
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
69
			throws RuntimeException, CorruptedDwgEntityException {
70
		
71
		if(! (dwgObj instanceof DwgPFacePolyline))
72
	    	throw new RuntimeException("ArcReader 15 solo puede leer DwgPFacePolyline");
73
		DwgPFacePolyline pface = (DwgPFacePolyline) dwgObj;
74
		int bitPos = offset;
75
		bitPos = headTailReader.readObjectHeader(data, bitPos, pface);
76
		
77
		List val = DwgUtil.getBitShort(data, bitPos);
78
		bitPos = ((Integer) val.get(0)).intValue();
79
		int vertexCount = ((Integer) val.get(1)).intValue();
80
		pface.setVertexCount(vertexCount);
81
		
82
		val = DwgUtil.getBitShort(data, bitPos);
83
		bitPos = ((Integer) val.get(0)).intValue();
84
		int faceCount = ((Integer) val.get(1)).intValue();
85
		pface.setFaceCount(faceCount);
86
		
87
		bitPos = headTailReader.readObjectTailer(data, bitPos, pface);
88
		
89
		DwgHandleReference handle = new DwgHandleReference();
90
		bitPos = handle.read(data, bitPos);
91
		pface.setFirstVertexHandle(handle);
92
		
93
		handle = new DwgHandleReference();
94
		bitPos = handle.read(data, bitPos);
95
		pface.setLastVertexHandle(handle);
96
		
97
		handle = new DwgHandleReference();
98
		bitPos = handle.read(data, bitPos);
99
		pface.setSeqendHandle(handle);
100
	}
101

  
102
}
103

  
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgAttribReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.awt.geom.Point2D;
8
import java.util.ArrayList;
9

  
10
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
11
import org.gvsig.dwg.lib.DwgHandleReference;
12
import org.gvsig.dwg.lib.DwgObject;
13
import org.gvsig.dwg.lib.DwgUtil;
14
import org.gvsig.dwg.lib.objects.DwgArc;
15
import org.gvsig.dwg.lib.objects.DwgAttrib;
16
import org.gvsig.dwg.lib.readers.IDwgFileReader;
17
import org.gvsig.dwg.lib.readers.IDwgObjectReader;
18

  
19

  
20
/**
21
 * @author alzabord
22
 * 
23
 * TODO To change the template for this generated type comment go to Window -
24
 * Preferences - Java - Code Style - Code Templates
25
 */
26
public class DwgAttribReader15 extends AbstractDwg15Reader {
27

  
28
	/*
29
	 * (non-Javadoc)
30
	 * 
31
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[],
32
	 *      int, com.iver.cit.jdwglib.dwg.DwgObject)
33
	 */
34
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
35

  
36
		if (!(dwgObj instanceof DwgAttrib))
37
			throw new RuntimeException("ArcReader 15 solo puede leer DwgAttrib");
38
		DwgAttrib att = (DwgAttrib) dwgObj;
39

  
40
		int bitPos = offset;
41
		bitPos = headTailReader.readObjectHeader(data, bitPos, att);
42
		ArrayList v = DwgUtil.getRawChar(data, bitPos);
43
		bitPos = ((Integer) v.get(0)).intValue();
44
		int dflag = ((Integer) v.get(1)).intValue();
45
		att.setDataFlag(dflag);
46
		if ((dflag & 0x1) == 0) {
47
			v = DwgUtil.getRawDouble(data, bitPos);
48
			bitPos = ((Integer) v.get(0)).intValue();
49
			double elev = ((Double) v.get(1)).doubleValue();
50
			att.setElevation(elev);
51
		}
52
		v = DwgUtil.getRawDouble(data, bitPos);
53
		bitPos = ((Integer) v.get(0)).intValue();
54
		double x1 = ((Double) v.get(1)).doubleValue();
55
		v = DwgUtil.getRawDouble(data, bitPos);
56
		bitPos = ((Integer) v.get(0)).intValue();
57
		double y1 = ((Double) v.get(1)).doubleValue();
58
		att.setInsertionPoint(new Point2D.Double(x1, y1));
59
		double x = 0, y = 0, z = 0;
60
		if ((dflag & 0x2) == 0) {
61
			v = DwgUtil.getDefaultDouble(data, bitPos, x1);
62
			bitPos = ((Integer) v.get(0)).intValue();
63
			x = ((Double) v.get(1)).doubleValue();
64
			v = DwgUtil.getDefaultDouble(data, bitPos, y1);
65
			bitPos = ((Integer) v.get(0)).intValue();
66
			y = ((Double) v.get(1)).doubleValue();
67
		}
68
		att.setAlignmentPoint(new Point2D.Double(x, y));
69
		v = DwgUtil.testBit(data, bitPos);
70
		bitPos = ((Integer) v.get(0)).intValue();
71
		boolean flag = ((Boolean) v.get(1)).booleanValue();
72
		if (flag) {
73
			y = 0.0;
74
			x = y;
75
			z = 1.0;
76
		} else {
77
			v = DwgUtil.getBitDouble(data, bitPos);
78
			bitPos = ((Integer) v.get(0)).intValue();
79
			x = ((Double) v.get(1)).doubleValue();
80
			v = DwgUtil.getBitDouble(data, bitPos);
81
			bitPos = ((Integer) v.get(0)).intValue();
82
			y = ((Double) v.get(1)).doubleValue();
83
			v = DwgUtil.getBitDouble(data, bitPos);
84
			bitPos = ((Integer) v.get(0)).intValue();
85
			z = ((Double) v.get(1)).doubleValue();
86
		}
87
		att.setExtrusion(new double[] { x, y, z });
88
		v = DwgUtil.testBit(data, bitPos);
89
		bitPos = ((Integer) v.get(0)).intValue();
90
		flag = ((Boolean) v.get(1)).booleanValue();
91
		double th;
92
		if (flag) {
93
			th = 0.0;
94
		} else {
95
			v = DwgUtil.getBitDouble(data, bitPos);
96
			bitPos = ((Integer) v.get(0)).intValue();
97
			th = ((Double) v.get(1)).doubleValue();
98
		}
99
		att.setThickness(th);
100
		if ((dflag & 0x4) == 0) {
101
			v = DwgUtil.getRawDouble(data, bitPos);
102
			bitPos = ((Integer) v.get(0)).intValue();
103
			double oblique = ((Double) v.get(1)).doubleValue();
104
			att.setObliqueAngle(oblique);
105
		}
106
		if ((dflag & 0x8) == 0) {
107
			v = DwgUtil.getRawDouble(data, bitPos);
108
			bitPos = ((Integer) v.get(0)).intValue();
109
			double rot = ((Double) v.get(1)).doubleValue();
110
			att.setRotationAngle(rot);
111
		}
112
		v = DwgUtil.getRawDouble(data, bitPos);
113
		bitPos = ((Integer) v.get(0)).intValue();
114
		double height = ((Double) v.get(1)).doubleValue();
115
		att.setHeight(height);
116
		if ((dflag & 0x10) == 0) {
117
			v = DwgUtil.getRawDouble(data, bitPos);
118
			bitPos = ((Integer) v.get(0)).intValue();
119
			double width = ((Double) v.get(1)).doubleValue();
120
			att.setWidthFactor(width);
121
		}
122
		v = DwgUtil.getTextString(data, bitPos);
123
		bitPos = ((Integer) v.get(0)).intValue();
124
		String text = (String) v.get(1);
125
		att.setText(text);
126
		if ((dflag & 0x20) == 0) {
127
			v = DwgUtil.getBitShort(data, bitPos);
128
			bitPos = ((Integer) v.get(0)).intValue();
129
			int gen = ((Integer) v.get(1)).intValue();
130
			att.setGeneration(gen);
131
		}
132
		if ((dflag & 0x40) == 0) {
133
			v = DwgUtil.getBitShort(data, bitPos);
134
			bitPos = ((Integer) v.get(0)).intValue();
135
			int halign = ((Integer) v.get(1)).intValue();
136
			att.setHalign(halign);
137
		}
138
		if ((dflag & 0x80) == 0) {
139
			v = DwgUtil.getBitShort(data, bitPos);
140
			bitPos = ((Integer) v.get(0)).intValue();
141
			int valign = ((Integer) v.get(1)).intValue();
142
			att.setValign(valign);
143
		}
144
		v = DwgUtil.getTextString(data, bitPos);
145
		bitPos = ((Integer) v.get(0)).intValue();
146
		String tag = (String) v.get(1);
147
		att.setTag(tag);
148
		v = DwgUtil.getBitShort(data, bitPos);
149
		bitPos = ((Integer) v.get(0)).intValue();
150
		int fl = ((Integer) v.get(1)).intValue();
151
		att.setFieldLength(fl);
152
		v = DwgUtil.getRawChar(data, bitPos);
153
		bitPos = ((Integer) v.get(0)).intValue();
154
		int flags = ((Integer) v.get(1)).intValue();
155
		att.setFlags(flags);
156
		bitPos = headTailReader.readObjectTailer(data, bitPos, att);
157
		DwgHandleReference styleHandle = new DwgHandleReference();
158
		bitPos = styleHandle.read(data, bitPos);
159
		att.setStyleHandle(styleHandle);
160
	}
161
}
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgSplineReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgSpline;
13

  
14

  
15
/**
16
 * @author alzabord
17
 *
18
 * TODO To change the template for this generated type comment go to
19
 * Window - Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgSplineReader15 extends AbstractDwg15Reader{
22

  
23
	/* (non-Javadoc)
24
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
25
	 */
26
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
27
		if(! (dwgObj instanceof DwgSpline))
28
			throw new RuntimeException("ArcReader 15 solo puede leer DwgSpline");
29
		DwgSpline spline = (DwgSpline) dwgObj;
30
		int bitPos = offset;
31
		bitPos = headTailReader.readObjectHeader(data, bitPos, spline);
32
		ArrayList v = DwgUtil.getBitShort(data, bitPos);
33
		bitPos = ((Integer)v.get(0)).intValue();
34
		int sc = ((Integer)v.get(1)).intValue();
35
		spline.setScenario(sc);
36
		v = DwgUtil.getBitShort(data, bitPos);
37
		bitPos = ((Integer)v.get(0)).intValue();
38
		int deg = ((Integer)v.get(1)).intValue();
39
		spline.setDegree(deg);
40
		int knotsNumber = 0;
41
		int controlPointsNumber = 0;
42
		int fitPointsNumber = 0;
43
		boolean weight = false;
44
		if (sc==2) {
45
			v = DwgUtil.getBitDouble(data, bitPos);
46
			bitPos = ((Integer)v.get(0)).intValue();
47
			double ft = ((Double)v.get(1)).doubleValue();
48
			spline.setFitTolerance(ft);
49
			v = DwgUtil.getBitDouble(data, bitPos);
50
			bitPos = ((Integer)v.get(0)).intValue();
51
			double x = ((Double)v.get(1)).doubleValue();
52
			v = DwgUtil.getBitDouble(data, bitPos);
53
			bitPos = ((Integer)v.get(0)).intValue();
54
			double y = ((Double)v.get(1)).doubleValue();
55
			v = DwgUtil.getBitDouble(data, bitPos);
56
			bitPos = ((Integer)v.get(0)).intValue();
57
			double z = ((Double)v.get(1)).doubleValue();
58
			double[] coord = new double[]{x, y, z};
59
			spline.setBeginTanVector(coord);
60
			v = DwgUtil.getBitDouble(data, bitPos);
61
			bitPos = ((Integer)v.get(0)).intValue();
62
			x = ((Double)v.get(1)).doubleValue();
63
			v = DwgUtil.getBitDouble(data, bitPos);
64
			bitPos = ((Integer)v.get(0)).intValue();
65
			y = ((Double)v.get(1)).doubleValue();
66
			v = DwgUtil.getBitDouble(data, bitPos);
67
			bitPos = ((Integer)v.get(0)).intValue();
68
			z = ((Double)v.get(1)).doubleValue();
69
			coord = new double[]{x, y, z};
70
			spline.setEndTanVector(coord);
71
			v = DwgUtil.getBitShort(data, bitPos);
72
			bitPos = ((Integer)v.get(0)).intValue();
73
			fitPointsNumber = ((Integer)v.get(1)).intValue();
74
		} else if (sc==1) {
75
			v = DwgUtil.testBit(data, bitPos);
76
			bitPos = ((Integer)v.get(0)).intValue();
77
			boolean rat = ((Boolean)v.get(1)).booleanValue();
78
			spline.setRational(rat);
79
			v = DwgUtil.testBit(data, bitPos);
80
			bitPos = ((Integer)v.get(0)).intValue();
81
			boolean closed = ((Boolean)v.get(1)).booleanValue();
82
			spline.setClosed(closed);
83
			v = DwgUtil.testBit(data, bitPos);
84
			bitPos = ((Integer)v.get(0)).intValue();
85
			boolean per = ((Boolean)v.get(1)).booleanValue();
86
			spline.setPeriodic(per);
87
			v = DwgUtil.getBitDouble(data, bitPos);
88
			bitPos = ((Integer)v.get(0)).intValue();
89
			double ktol = ((Double)v.get(1)).doubleValue();
90
			spline.setKnotTolerance(ktol);
91
			v = DwgUtil.getBitDouble(data, bitPos);
92
			bitPos = ((Integer)v.get(0)).intValue();
93
			double ctol = ((Double)v.get(1)).doubleValue();
94
			spline.setControlTolerance(ctol);
95
			v = DwgUtil.getBitLong(data, bitPos);
96
			bitPos = ((Integer)v.get(0)).intValue();
97
			knotsNumber = ((Integer)v.get(1)).intValue();
98
			v = DwgUtil.getBitLong(data, bitPos);
99
			bitPos = ((Integer)v.get(0)).intValue();
100
			controlPointsNumber = ((Integer)v.get(1)).intValue();
101
			v = DwgUtil.testBit(data, bitPos);
102
			bitPos = ((Integer)v.get(0)).intValue();
103
			weight = ((Boolean)v.get(1)).booleanValue();
104
		} else {
105
			System.out.println("ERROR: Escenario desconocido");
106
		}
107
		if (knotsNumber>0) {
108
			double[] knotpts = new double[knotsNumber];
109
			for (int i=0;i<knotsNumber;i++) {
110
				v = DwgUtil.getBitDouble(data, bitPos);
111
				bitPos = ((Integer)v.get(0)).intValue();
112
				knotpts[i] = ((Double)v.get(1)).doubleValue();
113
			}
114
			spline.setKnotPoints(knotpts);
115
		}
116
		if (controlPointsNumber>0) {
117
			// Si el n?mero de weights no coincide con el de ctrlpts habr? problemas ...
118
			double[][] ctrlpts = new double[controlPointsNumber][3];
119
			double[] weights = new double[controlPointsNumber];
120
			for (int i=0;i<controlPointsNumber;i++) {
121
				v = DwgUtil.getBitDouble(data, bitPos);
122
				bitPos = ((Integer)v.get(0)).intValue();
123
				double x = ((Double)v.get(1)).doubleValue();
124
				v = DwgUtil.getBitDouble(data, bitPos);
125
				bitPos = ((Integer)v.get(0)).intValue();
126
				double y = ((Double)v.get(1)).doubleValue();
127
				v = DwgUtil.getBitDouble(data, bitPos);
128
				bitPos = ((Integer)v.get(0)).intValue();
129
				double z = ((Double)v.get(1)).doubleValue();
130
				//double[] coord = new double[]{x, y, z};
131
				ctrlpts[i][0] = x;
132
				ctrlpts[i][1] = y;
133
				ctrlpts[i][2] = z;
134
				if (weight) {
135
					v = DwgUtil.getBitDouble(data, bitPos);
136
					bitPos = ((Integer)v.get(0)).intValue();
137
					weights[i] = ((Double)v.get(1)).doubleValue();
138
				}
139
			}
140
			spline.setControlPoints(ctrlpts);
141
			if (weight) {
142
				spline.setWeights(weights);
143
			}
144
		}
145
		if (fitPointsNumber>0) {
146
			double[][] fitpts = new double[fitPointsNumber][3];
147
			for (int i=0;i<fitPointsNumber;i++) {
148
				v = DwgUtil.getBitDouble(data, bitPos);
149
				bitPos = ((Integer)v.get(0)).intValue();
150
				double x = ((Double)v.get(1)).doubleValue();
151
				v = DwgUtil.getBitDouble(data, bitPos);
152
				bitPos = ((Integer)v.get(0)).intValue();
153
				double y = ((Double)v.get(1)).doubleValue();
154
				v = DwgUtil.getBitDouble(data, bitPos);
155
				bitPos = ((Integer)v.get(0)).intValue();
156
				double z = ((Double)v.get(1)).doubleValue();
157
				fitpts[i][0] = x;
158
				fitpts[i][1] = y;
159
				fitpts[i][2] = z;
160
			}
161
			spline.setFitPoints(fitpts);
162
		}
163
		bitPos = headTailReader.readObjectTailer(data, bitPos, spline);
164
	}
165

  
166

  
167
}
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgVertexPFaceFaceReader15.java
1
/*
2
 * Created on 19-mar-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DwgVertexPFaceFaceReader15.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.1.2.1  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.1  2007/03/20 19:57:08  azabala
52
* source code cleaning
53
*
54
*
55
*/
56
package org.gvsig.dwg.lib.readers.v15;
57

  
58
import java.util.List;
59

  
60
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
61
import org.gvsig.dwg.lib.DwgObject;
62
import org.gvsig.dwg.lib.DwgUtil;
63
import org.gvsig.dwg.lib.objects.DwgVertexPFaceFace;
64

  
65

  
66
public class DwgVertexPFaceFaceReader15 extends AbstractDwg15Reader {
67

  
68
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
69
			throws RuntimeException, CorruptedDwgEntityException {
70
		
71
		 if(! (dwgObj instanceof DwgVertexPFaceFace))
72
		    	throw new RuntimeException("ArcReader 15 solo puede leer DwgVertexPFaceFace");
73
		 DwgVertexPFaceFace v = (DwgVertexPFaceFace) dwgObj;
74
		 
75
		 int bitPos = offset;
76
		 
77
		 bitPos = headTailReader.readObjectHeader(data, offset, v);
78
		 
79
		 List val = DwgUtil.getBitShort(data, bitPos);
80
		 bitPos = ((Integer) val.get(0)).intValue();
81
		 int v1 = ((Integer) val.get(1)).intValue();
82
		 
83
		 val = DwgUtil.getBitShort(data, bitPos);
84
		 bitPos = ((Integer) val.get(0)).intValue();
85
		 int v2 = ((Integer) val.get(1)).intValue();
86
		 
87
		 val = DwgUtil.getBitShort(data, bitPos);
88
		 bitPos = ((Integer) val.get(0)).intValue();
89
		 int v3 = ((Integer) val.get(1)).intValue();
90
		 
91
		 val = DwgUtil.getBitShort(data, bitPos);
92
		 bitPos = ((Integer) val.get(0)).intValue();
93
		 int v4 = ((Integer) val.get(1)).intValue();
94
		 
95
		 v.setVerticesidx(new int[]{v1, v2, v3, v4});
96
		 
97
		 bitPos = headTailReader.readObjectTailer(data, bitPos, v);
98
	}
99

  
100
}
101

  
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgMeshReader15.java
1
/*
2
 * Created on 19-mar-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DwgMeshReader15.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.1.2.1  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.1  2007/03/20 19:57:08  azabala
52
* source code cleaning
53
*
54
*
55
*/
56
package org.gvsig.dwg.lib.readers.v15;
57

  
58
import java.util.List;
59

  
60
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
61
import org.gvsig.dwg.lib.DwgHandleReference;
62
import org.gvsig.dwg.lib.DwgObject;
63
import org.gvsig.dwg.lib.DwgUtil;
64
import org.gvsig.dwg.lib.objects.DwgMeshPolyline;
65

  
66

  
67
public class DwgMeshReader15 extends AbstractDwg15Reader {
68

  
69
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
70
			throws RuntimeException, CorruptedDwgEntityException {
71
		if(! (dwgObj instanceof DwgMeshPolyline))
72
	    	throw new RuntimeException("ArcReader 15 solo puede leer DwgMeshPolyline");
73
		DwgMeshPolyline m = (DwgMeshPolyline) dwgObj;
74
		int bitPos = offset;
75
		bitPos = headTailReader.readObjectHeader(data, bitPos, m);
76
		
77
		List val = DwgUtil.getBitShort(data, bitPos);
78
		bitPos = ((Integer) val.get(0)).intValue();
79
		int flags = ((Integer) val.get(1)).intValue();
80
		m.setFlags(flags);
81
		
82
		val = DwgUtil.getBitShort(data, bitPos);
83
		bitPos = ((Integer) val.get(0)).intValue();
84
		int curveType = ((Integer) val.get(1)).intValue();
85
		m.setCurveType(curveType);
86
		
87
		val = DwgUtil.getBitShort(data, bitPos);
88
		bitPos = ((Integer) val.get(0)).intValue();
89
		int mVerticies = ((Integer) val.get(1)).intValue();
90
		m.setMVerticies(mVerticies);
91
		
92
		val = DwgUtil.getBitShort(data, bitPos);
93
		bitPos = ((Integer) val.get(0)).intValue();
94
		int nVerticies = ((Integer) val.get(1)).intValue();
95
		m.setNVerticies(nVerticies);
96
		
97
		val = DwgUtil.getBitShort(data, bitPos);
98
		bitPos = ((Integer) val.get(0)).intValue();
99
		int mDensity = ((Integer) val.get(1)).intValue();
100
		m.setMDensity(mDensity);
101
		
102
		val = DwgUtil.getBitShort(data, bitPos);
103
		bitPos = ((Integer) val.get(0)).intValue();
104
		int nDensity = ((Integer) val.get(1)).intValue();
105
		m.setNDensity(nDensity);
106
		
107
		bitPos = headTailReader.readObjectTailer(data, bitPos, m);
108
		
109
		DwgHandleReference handle = new DwgHandleReference();
110
		bitPos = handle.read(data, bitPos);
111
		m.setFirstVertexHandle(handle);
112
		
113
		handle = new DwgHandleReference();
114
		bitPos = handle.read(data, bitPos);
115
		m.setLastVertexHandle(handle);
116
		
117
		handle = new DwgHandleReference();
118
		bitPos = handle.read(data, bitPos);
119
		m.setSeqendHandle(handle);
120
	}
121

  
122
}
123

  
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgEllipseReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgEllipse;
13

  
14

  
15
/**
16
 * @author alzabord
17
 *
18
 * TODO To change the template for this generated type comment go to
19
 * Window - Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgEllipseReader15 extends AbstractDwg15Reader{
22

  
23
	/* (non-Javadoc)
24
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
25
	 */
26
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
27
		if(! (dwgObj instanceof DwgEllipse))
28
			throw new RuntimeException("ArcReader 15 solo puede leer DwgEllipse");
29
		DwgEllipse ell = (DwgEllipse) dwgObj;
30
		int bitPos = offset;
31
		bitPos = headTailReader.readObjectHeader(data, bitPos, ell);
32
		ArrayList v = DwgUtil.getBitDouble(data, bitPos);
33
		bitPos = ((Integer)v.get(0)).intValue();
34
		double x = ((Double)v.get(1)).doubleValue();
35
		v = DwgUtil.getBitDouble(data, bitPos);
36
		bitPos = ((Integer)v.get(0)).intValue();
37
		double y = ((Double)v.get(1)).doubleValue();
38
		v = DwgUtil.getBitDouble(data, bitPos);
39
		bitPos = ((Integer)v.get(0)).intValue();
40
		double z = ((Double)v.get(1)).doubleValue();
41
		double[] coord = new double[]{x, y, z};
42
		ell.setCenter(coord);
43
		v = DwgUtil.getBitDouble(data, bitPos);
44
		bitPos = ((Integer)v.get(0)).intValue();
45
		x = ((Double)v.get(1)).doubleValue();
46
		v = DwgUtil.getBitDouble(data, bitPos);
47
		bitPos = ((Integer)v.get(0)).intValue();
48
		y = ((Double)v.get(1)).doubleValue();
49
		v = DwgUtil.getBitDouble(data, bitPos);
50
		bitPos = ((Integer)v.get(0)).intValue();
51
		z = ((Double)v.get(1)).doubleValue();
52
		coord = new double[]{x, y, z};
53
		ell.setSemiMajorAxisVector(coord);
54
		v = DwgUtil.getBitDouble(data, bitPos);
55
		bitPos = ((Integer)v.get(0)).intValue();
56
		x = ((Double)v.get(1)).doubleValue();
57
		v = DwgUtil.getBitDouble(data, bitPos);
58
		bitPos = ((Integer)v.get(0)).intValue();
59
		y = ((Double)v.get(1)).doubleValue();
60
		v = DwgUtil.getBitDouble(data, bitPos);
61
		bitPos = ((Integer)v.get(0)).intValue();
62
		z = ((Double)v.get(1)).doubleValue();
63
		coord = new double[]{x, y, z};
64
		ell.setExtrusion(coord);
65
		v = DwgUtil.getBitDouble(data, bitPos);
66
		bitPos = ((Integer)v.get(0)).intValue();
67
		double val = ((Double)v.get(1)).doubleValue();
68
		ell.setAxisRatio(val);
69
		v = DwgUtil.getBitDouble(data, bitPos);
70
		bitPos = ((Integer)v.get(0)).intValue();
71
		val = ((Double)v.get(1)).doubleValue();
72
		ell.setInitAngle(val);
73
		v = DwgUtil.getBitDouble(data, bitPos);
74
		bitPos = ((Integer)v.get(0)).intValue();
75
		val = ((Double)v.get(1)).doubleValue();
76
		ell.setEndAngle(val);
77
		bitPos = headTailReader.readObjectTailer(data, bitPos, ell);
78
	}
79
}
tags/org.gvsig.dwg-2.0.144/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgLwPolylineReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.awt.geom.Point2D;
8
import java.util.ArrayList;
9
import java.util.List;
10

  
11
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
12
import org.gvsig.dwg.lib.DwgObject;
13
import org.gvsig.dwg.lib.DwgUtil;
14
import org.gvsig.dwg.lib.objects.DwgLwPolyline;
15

  
16

  
17
/**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff