Revision 9986

View differences:

trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/DwgObjectFactory.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.4  2007-01-30 12:37:18  azabala
48
 * Revision 1.5  2007-01-30 19:40:23  azabala
49 49
 * *** empty log message ***
50 50
 *
51
 * Revision 1.4  2007/01/30 12:37:18  azabala
52
 * *** empty log message ***
53
 *
51 54
 * Revision 1.3  2007/01/24 20:14:31  azabala
52 55
 * implementation of reader of V14
53 56
 *
......
68 71
import com.iver.cit.jdwglib.dwg.objects.DwgBlockControl;
69 72
import com.iver.cit.jdwglib.dwg.objects.DwgBlockHeader;
70 73
import com.iver.cit.jdwglib.dwg.objects.DwgCircle;
74
import com.iver.cit.jdwglib.dwg.objects.DwgDictionaryVar;
71 75
import com.iver.cit.jdwglib.dwg.objects.DwgEllipse;
72 76
import com.iver.cit.jdwglib.dwg.objects.DwgEndblk;
77
import com.iver.cit.jdwglib.dwg.objects.DwgHatch;
73 78
import com.iver.cit.jdwglib.dwg.objects.DwgInsert;
74 79
import com.iver.cit.jdwglib.dwg.objects.DwgLayer;
75 80
import com.iver.cit.jdwglib.dwg.objects.DwgLayerControl;
......
290 295
		obj.setType(type);
291 296
		return obj;
292 297
	}
293

  
298
	
299
	public DwgObject create(String dxfName, int index){
300
		if(dxfName.equalsIgnoreCase("DICTIONARYVAR"))
301
			return new DwgDictionaryVar(index);
302
		else if(dxfName.equalsIgnoreCase("HATCH"))
303
			return new DwgHatch(index);
304
	}
305
/*
306
 'DICTIONARYVAR' : dictionaryvar_reader,
307
    'HATCH' : hatch_reader,
308
    'IDBUFFER' : idbuffer_reader,
309
    'IMAGE' : image_reader,
310
    'IMAGEDEF' : imagedef_reader,
311
    'IMAGEDEFREACTOR' : imagedefreactor_reader,
312
    'LAYER_INDEX' : layer_index_reader,
313
    'LWPLINE' : lwpline_reader,
314
#     'OLE2FRAME' : ole2frame_reader,
315
    'RASTERVARIABLES' : rastervariables_reader,
316
    'SORTENTSTABLE' : sortentstable_reader,
317
    'SPATIAL_FILTER' : spatial_filter_reader,
318
    'SPATIAL_INDEX' : spatial_index_reader,
319
    'XRECORD' : xrecord_reader 
320
 * */
294 321
}
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/DwgFileV14Reader.java
1660 1660
		    List extData = (List)val.get(1);
1661 1661
		    obj.setExtendedData(extData);
1662 1662
		    
1663
		/* TODO        
1664
		    if _type < len(_objflags):
1665
	            _gflag, _reader = _objflags[_type]
1666
	            
1667
	        _bitpos, _objbsize = dwgutil.get_raw_long(_data, _bitpos)
1668
	        # print "object data size in bits: %d" % _objbsize
1669
	        # print "bitpos: %d" % _bitpos
1670
	        if _reader is not None:
1671
	            _reader(_ent, _data, _bitpos)
1672
	        elif _type in _vmap:
1673
	            _stype = _vmap[_type]
1674
	            # print "type: %d => %s" % (_type, _stype)
1675
	            if _stype == 'HATCH': # where is the data kept?
1676
	                _bitpos, _val = dwgutil.test_bit(_data, _bitpos)
1677
	                # print "graphic flag: " + str(_val)
1678
	            if _stype in _vobjmap:
1679
	                _vobjmap[_stype](_ent, _data, _bitpos)
1680
	        else:
1681
	            # print "unhandled object type: %d" % _type
1682
	            pass
1683
	        _objlist.append(_ent)
1684
		    */
1685
		    
1686
		    
1663
		    //Graphics data 
1687 1664
		    boolean gflag = false;
1688 1665
	    	gflag = obj.isGraphicsFlag();   	
1689 1666
	    	if (gflag) {
......
1702 1679
			    }
1703 1680
		    }//if gflag
1704 1681
	    	
1705
			readSpecificObject(obj, intData, bitPos);
1682
	    	
1683
	    	//size in bits
1684
	    	val = DwgUtil.getRawLong(intData, bitPos);
1685
	    	bitPos = ((Integer)val.get(0)).intValue();
1686
		    int sizeInBits = ((Integer)val.get(1)).intValue();
1687
		    obj.setSizeInBits(sizeInBits);
1688
		    
1689
		    if(obj.getClass() != DwgObject.class){
1690
		    	//El objeto ha sido reconocido
1691
		    	readSpecificObject(obj, intData, bitPos);
1692
		    }else{
1693
		    	if(type > 500){
1694
		    		/*
1695
		    		 * Pag 46 de la spec: restamos 500 al tipo y nos da un ?ndice
1696
		    		 * a la tabla de clases (CLASSES section)
1697
		    		 * 
1698
		    		 * Filtro aquellos que sean mayores de 500 porque todav?a
1699
		    		 * nos quedan por implementar muchas entidades DWG (para no confundirlas)
1700
		    		 * 
1701
		    		 * */
1702
		    		int newIndex = type - 500;
1703
		    		if(newIndex < (dwgFile.getDwgClasses().size() - 1)){
1704
		    			DwgClass dwgClass = (DwgClass) dwgFile.getDwgClasses().get(index);
1705
		    			String dxfEntityName = dwgClass.getDxfName();
1706
		    			/*
1707
		    			 * A partir del nombre de la entidad, la instanciamos
1708
		    			 * y construimos un READER para ella.
1709
		    			 * 
1710
		    			 * Hay que a?adir un nuevo metodo para la factoria de DWG
1711
		    			 * para que reciba un nombre de entidad DXF
1712
		    			 * */
1713
		    		}
1714
		    	}//if type 500
1715
		    }//if DwgObject.class	
1716
		    
1717
	    
1718
		    
1719
		    
1720
	       
1721
//	        elif _type in _vmap:
1722
//	            _stype = _vmap[_type]
1723
//	          
1724
//	            if _stype == 'HATCH': # where is the data kept?
1725
//	                _bitpos, _val = dwgutil.test_bit(_data, _bitpos)
1726
//	                # print "graphic flag: " + str(_val)
1727
//	                
1728
//	            if _stype in _vobjmap:
1729
//	                _vobjmap[_stype](_ent, _data, _bitpos)
1730
//	        else:
1731
//	            # print "unhandled object type: %d" % _type
1732
//	            pass
1733
//	        _objlist.append(_ent)
1734
	    	
1735
	    	
1736
	    	/*
1737
	    	 _vobjmap = {
1738
    'DICTIONARYVAR' : dictionaryvar_reader,
1739
    'HATCH' : hatch_reader,
1740
    'IDBUFFER' : idbuffer_reader,
1741
    'IMAGE' : image_reader,
1742
    'IMAGEDEF' : imagedef_reader,
1743
    'IMAGEDEFREACTOR' : imagedefreactor_reader,
1744
    'LAYER_INDEX' : layer_index_reader,
1745
    'LWPLINE' : lwpline_reader,
1746
#     'OLE2FRAME' : ole2frame_reader,
1747
    'RASTERVARIABLES' : rastervariables_reader,
1748
    'SORTENTSTABLE' : sortentstable_reader,
1749
    'SPATIAL_FILTER' : spatial_filter_reader,
1750
    'SPATIAL_INDEX' : spatial_index_reader,
1751
    'XRECORD' : xrecord_reader
1752
    }
1753
	    	  
1754
	    	  
1755
	    	  
1756
	    	 * */
1757
	    	
1758
	    	
1759
	    	
1760
	    	
1761
			
1706 1762
		    return obj;
1763
		    
1707 1764
	    } catch (Exception e) {
1708 1765
//	        logger.warn("Exception capturada. Probablemente se ha encontrado un" +
1709 1766
//	        		"objeto con type non fixed");
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/objreaders/v1314/DwgHatchReader1314.java
1
/*
2
 * Created on 30-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$
47
* $Log$
48
* Revision 1.1  2007-01-30 19:40:23  azabala
49
* *** empty log message ***
50
*
51
*
52
*/
53
package com.iver.cit.jdwglib.dwg.readers.objreaders.v1314;
54

  
55
import java.util.ArrayList;
56
import java.util.HashMap;
57
import java.util.List;
58
import java.util.Map;
59

  
60
import com.iver.cit.jdwglib.dwg.DwgObject;
61
import com.iver.cit.jdwglib.dwg.DwgUtil;
62
import com.iver.cit.jdwglib.dwg.objects.DwgHatch;
63

  
64
public class DwgHatchReader1314 extends AbstractDwg1314Reader {
65

  
66
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
67
			throws Exception {
68
		
69
		 if(! (dwgObj instanceof DwgHatch))
70
		    	throw new RuntimeException("ArcReader 14 solo puede leer DwgHatch");
71
		 DwgHatch h = (DwgHatch) dwgObj;
72
		
73
		int bitPos = offset;
74
		bitPos = headTailReader.readObjectHeader(data, offset, dwgObj);
75
		
76
		List val = DwgUtil.getBitDouble(data, bitPos);
77
		bitPos = ((Integer)val.get(0)).intValue();
78
		double zCoord = ((Double)val.get(1)).doubleValue();
79
		h.setZ(zCoord);
80
		
81
		val = DwgUtil.getBitDouble(data, bitPos);
82
		bitPos = ((Integer)val.get(0)).intValue();
83
		double xEx = ((Double)val.get(1)).doubleValue();
84
		
85
		val = DwgUtil.getBitDouble(data, bitPos);
86
		bitPos = ((Integer)val.get(0)).intValue();
87
		double yEx = ((Double)val.get(1)).doubleValue();
88
		
89
		val = DwgUtil.getBitDouble(data, bitPos);
90
		bitPos = ((Integer)val.get(0)).intValue();
91
		double zEx = ((Double)val.get(1)).doubleValue();
92
		
93
		h.setExtrusion(new double[]{xEx, yEx, zEx});
94
		
95
		val = DwgUtil.getTextString(data, bitPos);
96
		bitPos = ((Integer)val.get(0)).intValue();
97
		String txt = (String)val.get(1);
98
		h.setName(txt);
99
		
100
		val = DwgUtil.testBit(data, bitPos);
101
		bitPos = ((Integer)val.get(0)).intValue();
102
		boolean solidFill = ((Boolean)val.get(1)).booleanValue();
103
		h.setSolidFill(solidFill);
104
		
105
		val = DwgUtil.testBit(data, bitPos);
106
		bitPos = ((Integer)val.get(0)).intValue();
107
		boolean associative = ((Boolean)val.get(1)).booleanValue();
108
		h.setAssociative(associative);
109
		
110
		val = DwgUtil.getBitLong(data, bitPos);
111
		bitPos = ((Integer)val.get(0)).intValue();
112
		int numPaths =  ((Integer)val.get(1)).intValue();
113
//		TODO Esto lo pongo por analogia con las colecciones de Python
114
		//pero hay que quitarlo
115
		Map paths = new HashMap();
116
		
117
		int pathFlag = 0;
118
		int pixel = 0;
119
		int allBounds = 0;
120
		for(int i = 0; i < numPaths; i++){
121
			val = DwgUtil.getBitLong(data, bitPos);
122
			bitPos = ((Integer)val.get(0)).intValue();
123
			pathFlag = ((Integer)val.get(1)).intValue();
124
			
125
			if( (pathFlag  & 0x4) > 0){
126
				pixel++;
127
				//TODO La especificacion no dice esto (lo hace PythonCAD)
128
				//la especificacion dice pixel = DwgUtil.getBitDouble(...etc)
129
			}
130
			
131
			if( (pathFlag & 0x2) > 0){
132
				
133
				//POLYLINE PATH
134
				val = DwgUtil.testBit(data, bitPos);
135
				bitPos = ((Integer)val.get(0)).intValue();
136
				boolean hasBulges = ((Boolean)val.get(1)).booleanValue();
137
				
138
				val = DwgUtil.testBit(data, bitPos);
139
				bitPos = ((Integer)val.get(0)).intValue();
140
				boolean isClosed = ((Boolean)val.get(1)).booleanValue();
141
				
142
				
143
				val = DwgUtil.getBitLong(data, bitPos);
144
				bitPos = ((Integer)val.get(0)).intValue();
145
				int nps = ((Integer)val.get(1)).intValue();
146
				
147
				List pathSegments = new ArrayList();
148
				for (int j = 0; j < nps; j++){
149
					val = DwgUtil.getRawDouble(data, bitPos);
150
					bitPos = ((Integer)val.get(0)).intValue();
151
					double x = ((Double)val.get(1)).doubleValue();
152
					
153
					val = DwgUtil.getRawDouble(data, bitPos);
154
					bitPos = ((Integer)val.get(0)).intValue();
155
					double y = ((Double)val.get(1)).doubleValue();
156
					double bulge = 0d;
157
					if(hasBulges){
158
						val = DwgUtil.getBitDouble(data, bitPos);
159
						bitPos = ((Integer)val.get(0)).intValue();
160
						bulge = ((Double)val.get(1)).doubleValue();
161
					}
162
					pathSegments.add(new double[]{x, y, bulge});
163
				}//for
164
				paths.put("polyline", pathSegments);
165
			}else{
166
				val = DwgUtil.getBitLong(data, bitPos);
167
				bitPos = ((Integer)val.get(0)).intValue();
168
				int nps = ((Integer)val.get(1)).intValue();
169
				Map pathSegments = new HashMap();
170
				for(int j = 0; j < nps; j++){
171
					val = DwgUtil.getRawChar(data, bitPos);
172
					bitPos = ((Integer)val.get(0)).intValue();
173
					int pts = ((Integer)val.get(1)).intValue();
174
					
175
					double x, y, r, sa, ea;
176
					ArrayList list;
177
					boolean isCcw;
178
					
179
					switch(pts){
180
					case 1://LINE
181
						val = DwgUtil.getRawDouble(data, bitPos);
182
						bitPos = ((Integer)val.get(0)).intValue();
183
						double x1 = ((Double)val.get(1)).doubleValue();
184
						
185
						val = DwgUtil.getRawDouble(data, bitPos);
186
						bitPos = ((Integer)val.get(0)).intValue();
187
						double y1 = ((Double)val.get(1)).doubleValue();
188
						
189
						val = DwgUtil.getRawDouble(data, bitPos);
190
						bitPos = ((Integer)val.get(0)).intValue();
191
						double x2 = ((Double)val.get(1)).doubleValue();
192
						
193
						val = DwgUtil.getRawDouble(data, bitPos);
194
						bitPos = ((Integer)val.get(0)).intValue();
195
						double y2 = ((Double)val.get(1)).doubleValue();
196
						
197
						pathSegments.put("line", new double[]{x1, y1, x2, y2});
198
					
199
					break;
200
					
201
					case 2://CIRCULAR ARC
202
						val = DwgUtil.getRawDouble(data, bitPos);
203
						bitPos = ((Integer)val.get(0)).intValue();
204
						x = ((Double)val.get(1)).doubleValue();
205
						
206
						val = DwgUtil.getRawDouble(data, bitPos);
207
						bitPos = ((Integer)val.get(0)).intValue();
208
						y = ((Double)val.get(1)).doubleValue();
209
						
210
						val = DwgUtil.getBitDouble(data, bitPos);
211
						bitPos = ((Integer)val.get(0)).intValue();
212
						r = ((Double)val.get(1)).doubleValue();
213
						
214
						val = DwgUtil.getBitDouble(data, bitPos);
215
						bitPos = ((Integer)val.get(0)).intValue();
216
						sa = ((Double)val.get(1)).doubleValue();
217
						
218
						val = DwgUtil.getBitDouble(data, bitPos);
219
						bitPos = ((Integer)val.get(0)).intValue();
220
						ea = ((Double)val.get(1)).doubleValue();
221
						
222
						val = DwgUtil.testBit(data, bitPos);
223
						bitPos = ((Integer)val.get(0)).intValue();
224
						isCcw = ((Boolean)val.get(1)).booleanValue();
225
						//TODO Esto es una kk.
226
						//CAMBIAR POR UNA JERARQUIA DE OBJETOS SEG?N EL SEGMENTO
227
						list = new ArrayList();
228
						list.add(new Double(x));
229
						list.add(new Double(y));
230
						list.add(new Double(r));
231
						list.add(new Double(sa));
232
						list.add(new Double(ea));
233
						list.add(new Boolean(isCcw));
234
						pathSegments.put("arc", list);
235
						
236
					break;
237
					
238
					case 3://ELLIPTICAL ARC
239
						val = DwgUtil.getRawDouble(data, bitPos);
240
						bitPos = ((Integer)val.get(0)).intValue();
241
						x = ((Double)val.get(1)).doubleValue();
242
						
243
						val = DwgUtil.getRawDouble(data, bitPos);
244
						bitPos = ((Integer)val.get(0)).intValue();
245
						y = ((Double)val.get(1)).doubleValue();
246
						
247
						val = DwgUtil.getRawDouble(data, bitPos);
248
						bitPos = ((Integer)val.get(0)).intValue();
249
						double xe = ((Double)val.get(1)).doubleValue();
250
						
251
						val = DwgUtil.getRawDouble(data, bitPos);
252
						bitPos = ((Integer)val.get(0)).intValue();
253
						double ye = ((Double)val.get(1)).doubleValue();
254
						
255
						val = DwgUtil.getBitDouble(data, bitPos);
256
						bitPos = ((Integer)val.get(0)).intValue();
257
						r = ((Double)val.get(1)).doubleValue();
258
						
259
						val = DwgUtil.getBitDouble(data, bitPos);
260
						bitPos = ((Integer)val.get(0)).intValue();
261
						sa = ((Double)val.get(1)).doubleValue();
262
						
263
						val = DwgUtil.getBitDouble(data, bitPos);
264
						bitPos = ((Integer)val.get(0)).intValue();
265
						ea = ((Double)val.get(1)).doubleValue();
266
						
267
						val = DwgUtil.testBit(data, bitPos);
268
						bitPos = ((Integer)val.get(0)).intValue();
269
						isCcw = ((Boolean)val.get(1)).booleanValue();
270
						
271
						list = new ArrayList();
272
						list.add(new Double(x));
273
						list.add(new Double(y));
274
						list.add(new Double(xe));
275
						list.add(new Double(ye));
276
						list.add(new Double(r));
277
						list.add(new Double(sa));
278
						list.add(new Double(ea));
279
						list.add(new Boolean(isCcw));
280
						pathSegments.put("elliptical_arc", list);
281
					break;
282
					
283
					case 4://SPLINE ARC
284
						val = DwgUtil.getBitLong(data, bitPos);
285
						bitPos = ((Integer)val.get(0)).intValue();
286
						int deg = ((Integer)val.get(1)).intValue();
287
						
288
						val = DwgUtil.testBit(data, bitPos);
289
						bitPos = ((Integer)val.get(0)).intValue();
290
						boolean isRat = ((Boolean)val.get(1)).booleanValue();
291
						
292
						val = DwgUtil.testBit(data, bitPos);
293
						bitPos = ((Integer)val.get(0)).intValue();
294
						boolean isPer = ((Boolean)val.get(1)).booleanValue();
295
						
296
						val = DwgUtil.getBitLong(data, bitPos);
297
						bitPos = ((Integer)val.get(0)).intValue();
298
						int numKnokts = ((Integer)val.get(1)).intValue();
299
						
300
						val = DwgUtil.getBitLong(data, bitPos);
301
						bitPos = ((Integer)val.get(0)).intValue();
302
						int numCtrlPts = ((Integer)val.get(1)).intValue();
303
						 
304
						double[] knots = new double[numKnokts];
305
						for(int z = 0;  z < numKnokts; z++){
306
							val = DwgUtil.getBitDouble(data, bitPos);
307
							bitPos = ((Integer)val.get(0)).intValue();
308
							knots[z] = ((Double)val.get(1)).doubleValue();
309
						}
310
						
311
						double[][] controlPoints = new double[3][numCtrlPts];
312
						for(int z = 0; z < numCtrlPts; z++){
313
							//x
314
							val = DwgUtil.getRawDouble(data, bitPos);
315
							bitPos = ((Integer)val.get(0)).intValue();
316
							controlPoints[0][z] = ((Double)val.get(1)).doubleValue();
317
							//y
318
							val = DwgUtil.getRawDouble(data, bitPos);
319
							bitPos = ((Integer)val.get(0)).intValue();
320
							controlPoints[1][z] = ((Double)val.get(1)).doubleValue();
321
							
322
							//weight
323
							if(isRat){
324
								val = DwgUtil.getBitDouble(data, bitPos);
325
								bitPos = ((Integer)val.get(0)).intValue();
326
								controlPoints[2][z] = ((Double)val.get(1)).doubleValue();
327
							}else{
328
								controlPoints[2][z] = 0;
329
							}
330
							list = new ArrayList();
331
							list.add(new Boolean(isRat));
332
							list.add(new Boolean(isPer));
333
							list.add(knots);
334
							list.add(controlPoints);
335
							pathSegments.put("spline", list);
336
						}
337
					break;
338
					
339
					default:
340
						System.out.println("Error leyendo un segmento de hatch:codigo="+pts);
341
					break;
342
					}//switch
343
				}//for
344
				paths.put("stdpath", pathSegments);
345
			}//else
346
			
347
			val = DwgUtil.getBitLong(data, bitPos);
348
			bitPos = ((Integer)val.get(0)).intValue();
349
			int nbh = ((Integer)val.get(1)).intValue();
350
			allBounds += nbh;
351
		}//for
352
		
353
		val = DwgUtil.getBitShort(data, bitPos);
354
		bitPos = ((Integer)val.get(0)).intValue();
355
		int style = ((Integer)val.get(1)).intValue();
356
		
357
		dwgObj.setStyle(style);
358
		
359
		//TODO Continuar mas abajo
360
		
361
		/*
362
		   _bitpos, _val = dwgutil.get_bit_short(data, _bitpos)
363
    ent.setEntityData('style', _val)
364
    _bitpos, _val = dwgutil.get_bit_short(data, _bitpos)
365
    ent.setEntityData('pattern_type', _val)
366
    if not _solid_fill:
367
        _bitpos, _val = dwgutil.get_bit_double(data, _bitpos)
368
        ent.setEntityData('fill_angle', _val)
369
        _bitpos, _val = dwgutil.get_bit_double(data, _bitpos)
370
        ent.setEntityData('fill_scale_or_spacing', _val)
371
        _bitpos, _val = dwgutil.test_bit(data, _bitpos)
372
        ent.setEntityData('file_doublehatch', _val)
373
        _bitpos, _ndf = dwgutil.get_bit_short(data, _bitpos)
374
        _lines = []
375
        for _i in range(_ndf):
376
            _bitpos, _angle = dwgutil.get_bit_double(data, _bitpos)
377
            _bitpos, _x = dwgutil.get_bit_double(data, _bitpos)
378
            _bitpos, _y = dwgutil.get_bit_double(data, _bitpos)
379
            _bitpos, _xo = dwgutil.get_bit_double(data, _bitpos)
380
            _bitpos, _yo = dwgutil.get_bit_double(data, _bitpos)
381
            _bitpos, _nds = dwgutil.get_bit_short(data, _bitpos)
382
            _dashes = []
383
            for _j in range(_nds):
384
                _bitpos, _val = dwgutil.get_bit_double(data, _bitpos)
385
                ent.setEntityData('dashlength', _val)
386
            _lines.append((_angle, _x, _y, _xo, _yo, _dashes))
387
        ent.setEntityData('fill_lines', _lines)                
388
    if _pixel:
389
        _bitpos, _val = dwgutil.get_bit_double(data, _bitpos)
390
        ent.setEntityData('pixel_size', _val)
391
    _bitpos, _nsp = dwgutil.get_bit_long(data, _bitpos)
392
    if _nsp:
393
        _points = []
394
        for _i in range(_nsp):
395
            _bitpos, _x = dwgutil.get_raw_double(data, _bitpos)
396
            _bitpos, _y = dwgutil.get_raw_double(data, _bitpos)
397
            _points.append((_x, _y))
398
        ent.setEntityData('seed_points', _points)
399
    for _i in range(ent.getNumReactors()):
400
        _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
401
        ent.addReactor(_handle)
402
    _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
403
    ent.setXdicobj(_handle)
404
    _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
405
    ent.setEntityData('layer_handle', _handle)
406
    if ent.getIsLayerByLinetype() is False:
407
        _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
408
        ent.setEntityData('linetype_handle', _handle)
409
    if ent.getNoLinks() is False:
410
        _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
411
        ent.setPrevious(_handle)
412
        _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
413
        ent.setNext(_handle)
414
    _bounds = []
415
    for _i in range(_allbounds):
416
        _bitpos, _handle = dwgutil.get_handle(data, _bitpos)
417
        _bounds.append(_handle)
418
    if len(_bounds):
419
        ent.setEntityData('boundary_handles', _bounds)
420
		        */
421
	}
422

  
423
}
424

  
0 425

  
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/objreaders/v1314/AbstractDwg1314Reader.java
1
/*
2
 * Created on 30-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$
47
* $Log$
48
* Revision 1.1  2007-01-30 19:40:23  azabala
49
* *** empty log message ***
50
*
51
*
52
*/
53
package com.iver.cit.jdwglib.dwg.readers.objreaders.v1314;
54

  
55
import com.iver.cit.jdwglib.dwg.readers.DwgFileV14Reader;
56
import com.iver.cit.jdwglib.dwg.readers.IDwgFileReader;
57
import com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader;
58

  
59
public abstract class AbstractDwg1314Reader implements IDwgObjectReader {
60

  
61
	protected IDwgFileReader headTailReader;
62
	public void setFileReader(IDwgFileReader headTailReader) {
63
		if( ! (headTailReader instanceof DwgFileV14Reader))
64
			throw new RuntimeException("Tratando de leer entidad de DWG 13-14 con"+
65
					headTailReader.getClass().getName());
66
		this.headTailReader = headTailReader;
67
	}
68

  
69
}
70

  
0 71

  
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/objreaders/v1314/DwgDictionaryVarReader1314.java
1
/*
2
 * Created on 30-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$
47
* $Log$
48
* Revision 1.1  2007-01-30 19:40:23  azabala
49
* *** empty log message ***
50
*
51
*
52
*/
53
package com.iver.cit.jdwglib.dwg.readers.objreaders.v1314;
54

  
55
import java.util.List;
56

  
57
import com.iver.cit.jdwglib.dwg.DwgObject;
58
import com.iver.cit.jdwglib.dwg.DwgUtil;
59
import com.iver.cit.jdwglib.dwg.objects.DwgDictionaryVar;
60

  
61
public class DwgDictionaryVarReader1314 extends AbstractDwg1314Reader {
62

  
63
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
64
			throws Exception {
65
		
66
		 if(! (dwgObj instanceof DwgDictionaryVar))
67
		    	throw new RuntimeException("ArcReader 14 solo puede leer DwgDictionaryVar");
68
		
69
		DwgDictionaryVar dic = (DwgDictionaryVar) dwgObj;
70
		int bitPos = offset;
71
		List val = DwgUtil.getBitLong(data, bitPos);
72
		bitPos = ((Integer)val.get(0)).intValue();
73
		int numReactors = ((Integer)val.get(1)).intValue();
74
		dic.setNumReactors(numReactors);
75
		
76
		val = DwgUtil.getRawChar(data, bitPos);
77
		bitPos = ((Integer)val.get(0)).intValue();
78
		int intval = ((Integer)val.get(0)).intValue();
79
		dic.setIntVal(intval);
80
		
81
		val = DwgUtil.getTextString(data, bitPos);
82
		bitPos = ((Integer)val.get(0)).intValue();
83
		String text = ((String)val.get(1));
84
		dic.setText(text);
85
		
86
		val = DwgUtil.getHandle(data, bitPos);
87
		bitPos = ((Integer)val.get(0)).intValue();
88
		//TODO Tengo serias dudas de que los handles se puedan leer
89
		//asi (prueba para ver si nativeOrder permite prescindir de 
90
		//poner BIG_ENDIAN
91
		int intHandle = DwgUtil.handleToInt(val);
92
		dic.setParentHandle(intHandle);
93
		
94
		for(int i = 0; i < numReactors; i++){
95
			val = DwgUtil.getHandle(data, bitPos);
96
			bitPos = ((Integer)val.get(0)).intValue();
97
			//no seteamos los reactors
98
		}
99
		val = DwgUtil.getHandle(data, bitPos);
100
		bitPos = ((Integer)val.get(0)).intValue();
101
		int xdicHdl = DwgUtil.handleToInt(val);
102
		dic.setXDicObjHandle(xdicHdl);
103
	}
104

  
105
}
106

  
0 107

  
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgHatch.java
1
/*
2
 * Created on 30-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$
47
* $Log$
48
* Revision 1.1  2007-01-30 19:40:23  azabala
49
* *** empty log message ***
50
*
51
*
52
*/
53
package com.iver.cit.jdwglib.dwg.objects;
54

  
55
import com.iver.cit.jdwglib.dwg.DwgObject;
56

  
57
public class DwgHatch extends DwgObject {
58

  
59
	private double z;
60
	private double[] extrusion;
61
	private String name;
62
	private boolean solidFill;
63
	private boolean associative;
64

  
65
	public DwgHatch(int index) {
66
		super(index);
67
	}
68

  
69
	public void setZ(double coord) {
70
		this.z = coord;
71
	}
72

  
73
	public void setExtrusion(double[] ds) {
74
		this.extrusion = ds;
75
	}
76

  
77
	public void setName(String txt) {
78
		this.name = txt;
79
	}
80

  
81
	public void setSolidFill(boolean solidFill) {
82
		this.solidFill = solidFill;
83
	}
84

  
85
	public void setAssociative(boolean associative) {
86
		this.associative = associative;
87
	}
88

  
89
}
90

  
0 91

  
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgDictionaryVar.java
1
/*
2
 * Created on 30-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$
47
* $Log$
48
* Revision 1.1  2007-01-30 19:40:23  azabala
49
* *** empty log message ***
50
*
51
*
52
*/
53
package com.iver.cit.jdwglib.dwg.objects;
54

  
55
import com.iver.cit.jdwglib.dwg.DwgObject;
56

  
57
public class DwgDictionaryVar extends DwgObject {
58
	private int intval;
59
	private String text;
60
	private int parentHandle;
61

  
62
	public DwgDictionaryVar(int index) {
63
		super(index);
64
	}
65

  
66
	public void setIntVal(int intval) {
67
		this.intval = intval;
68
	}
69
	
70
	
71
	public void setText(String text) {
72
		this.text = text;
73
	}
74

  
75
	public void setParentHandle(int intHandle) {
76
		this.parentHandle = intHandle;
77
		
78
	}
79

  
80
	public int getIntval() {
81
		return intval;
82
	}
83

  
84
	public void setIntval(int intval) {
85
		this.intval = intval;
86
	}
87

  
88
	public int getParentHandle() {
89
		return parentHandle;
90
	}
91

  
92
	public String getText() {
93
		return text;
94
	}
95
}
96

  
0 97

  
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/DwgFile.java
547 547
					dwgObjectsWithoutBlocks.add(entity);
548 548
				} else if (entity instanceof DwgAttdef && !addingToBlock) {
549 549
					dwgObjectsWithoutBlocks.add(entity);
550
				} else if (entity instanceof DwgBlock) {
550
				} 
551
				
552
				else if (entity instanceof DwgBlock) {
551 553
					addingToBlock = true;
552
				} else if (entity instanceof DwgEndblk) {
554
				} 
555
				
556
				else if (entity instanceof DwgEndblk) {
553 557
					addingToBlock = false;
554
				} else if (entity instanceof DwgBlockHeader) {
558
				} 
559
				
560
				else if (entity instanceof DwgBlockHeader) {
555 561
					addingToBlock = true;
556
				} 
562
				}
563
				//Segun esto, un insert solo se procesa dentro de un Block (o BlockHeader)
564
				//?Puede haber INSERT fuera de BLOCK-ENDBLK?
557 565
				else if (entity instanceof DwgInsert && !addingToBlock) {
558 566
					double[] p = ((DwgInsert)entity).getInsertionPoint();
559 567
					Point2D point = new Point2D.Double(p[0], p[1]);
......
616 624
			return;
617 625
		}	
618 626
		
619
		//Busca el bloque cuyo nombre sea bname
620
//		El bloque no se usa para nada DwgBlock block = (DwgBlock) names_blocks.get(bname);
621 627
		/*
622 628
		 * Ahora localiza la primera entidad del bloque, 
623 629
		 * y a partir de ah?, a?ade
......
632 638
		 
633 639
		 int firstObjIdx = dwgObjects.indexOf(firstObj);
634 640
		 int lastObjIdx = dwgObjects.indexOf(lastObj);
635
		 if(firstObjIdx == -1 || lastObjIdx == -1){
636
			 System.out.println("Problemas en la LinkedList: 1?="+firstObjIdx+",Ultimo="+lastObjIdx);
641
		 if(firstObjIdx == -1){
642
			 System.out.println("El primer objeto del bloque "+
643
					 		blockHeader.getName()+
644
					 	" no ha sido localizado a partir del handle "+
645
					 	firstObjectHandle);
646
			 return;
647
		 }
648
		 
649
		 if(lastObjIdx == -1){
650
			 System.out.println("El ultimo objeto del bloque "+
651
					 		blockHeader.getName()+
652
					 	" no ha sido localizado a partir del handle "+
653
					 	lastObjectHandle);
637 654
			 
638
			 //TODO Si el primer elemento est? seteado, y el ultimo no,
639
			 //Probar a hacer un while(!(lastElement instanceof DwgEndBlk)
655
			 //Intentamos ver si como delimitador final de bloque aparece EndBlk
656
			 LinkedList tempDwgObj = new LinkedList();
657
			 DwgObject scannedEntity = (DwgObject) dwgObjects.get(firstObjIdx);
658
			 while(! (scannedEntity instanceof DwgEndblk)){
659
				 manageBlockEntity(scannedEntity, bPoint, 
660
						 insPoint, scale, rot, 
661
						 tempDwgObj);
662
				 firstObjIdx++;
663
				 scannedEntity = (DwgObject) dwgObjects.get(firstObjIdx);
664
				 if( (scannedEntity instanceof DwgBlock) ||
665
					(scannedEntity instanceof DwgBlockHeader)){
666
					 //No puede haber bloques anidados
667
					 //Descartar 
668
					 System.out.println("Error, aparecen bloques anidados");
669
					 return;
670
				 } 
671
			 }//while
672
			 if(tempDwgObj.size() > 0)
673
				 dwgObjectsWithoutBlocks.addAll(tempDwgObj);
674
			 return;
640 675
			 
641
			 return;
642
		 }
676
		 }//if
643 677
		 for(int i = firstObjIdx; i <= lastObjIdx; i++){
644 678
			 DwgObject obj = (DwgObject) dwgObjects.get(i);
645 679
			 manageBlockEntity(obj, bPoint, 

Also available in: Unified diff