Revision 23458

View differences:

branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/util/FMapUtil.java
42 42
//	}
43 43

  
44 44
	private static  GeneralPathX getGeneralPathX(List pts){
45
		if(pts == null || pts.size()==0){
46
			return null;
47
		}
48

  
49
		Object firstVertex = pts.get(0);
50

  
51
		if(firstVertex == null){
52
			return null;
53
		}
45 54
		GeneralPathX genPathX = new GeneralPathX();
46 55

  
47
		Object firstVertex = pts.get(0);
48 56
		double[] coordinate = null;
49 57
		if(firstVertex instanceof double[])
50 58
			coordinate = (double[])firstVertex;
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/DwgFileV14Reader.java
1 1
/* jdwglib. Java Library for reading Dwg files.
2
 * 
2
 *
3 3
 * Author: Jose Morell Rama (jose.morell@gmail.com).
4 4
 * Port from the Pythoncad Dwg library by Art Haas.
5 5
 *
......
22 22
 * For more information, contact:
23 23
 *
24 24
 * Jose Morell (jose.morell@gmail.com)
25
 * 
25
 *
26 26
 * or
27 27
 *
28 28
 * IVER TI S.A.
......
54 54

  
55 55
/**
56 56
 * The DwgFileV14Reader reads the DWG version 14 format
57
 * 
57
 *
58 58
 * @author jmorell
59 59
 */
60 60
public class DwgFileV14Reader implements IDwgFileReader {
......
69 69

  
70 70
	/**
71 71
	 * Reads the DWG version 15 format
72
	 * 
72
	 *
73 73
	 * @param dwgFile
74 74
	 *            Represents the DWG file that we want to read
75 75
	 * @throws IOException
......
93 93

  
94 94
	/**
95 95
	 * It reads all HEADER section of a DWG 13-14 file.
96
	 * 
96
	 *
97 97
	 * This method must be called only for debug purposes because we dont the
98 98
	 * meaning (or the practical application) of the fields readed with it
99
	 * 
99
	 *
100 100
	 * TODO Pasarlo a la clase abstracta comun que se haga de las versiones 15,
101 101
	 * 13-14 (la cabecera es la misma practicamente)
102
	 * 
103
	 *  
102
	 *
103
	 *
104 104
	 */
105 105
	protected void readHeaders() {
106 106

  
107 107
		int offset = dwgFile.getDwgSectionOffset("HEADERS");
108 108
		bb.position(offset);
109 109

  
110
		//1? leemos el sentinnel inicial
110
		//1 leemos el sentinnel inicial
111 111
		bb.order(ByteOrder.nativeOrder());
112 112
		byte[] sentinel = new byte[16];
113 113
		bb.get(sentinel);
......
145 145
		if (sentinel[15] != 0x5f)
146 146
			logger.warn("sentinel[15] != 0x5f");
147 147

  
148
		//2? seguidamente leemos los datos
148
		//2 seguidamente leemos los datos
149 149
		bb.order(ByteOrder.LITTLE_ENDIAN);
150 150
		int size = bb.getInt();
151 151

  
......
155 155

  
156 156
		int[] intData = DwgUtil.toIntArray(data);
157 157

  
158
		//3? a continuacion el CRC de la seccion HEADER
158
		//3 a continuacion el CRC de la seccion HEADER
159 159
		bb.order(ByteOrder.LITTLE_ENDIAN);
160 160
		short crc = bb.getShort();
161 161

  
......
701 701
			bitPos = ((Integer) val.get(0)).intValue();
702 702
			dwgFile.setHeader("PSPACE_ELEVATION", val.get(1));
703 703

  
704
			double[] spaces6 = new double[6];
704
			double[] spaces6 = new double[3];
705 705
			val = DwgUtil.getBitDouble(intData, bitPos);
706 706
			bitPos = ((Integer) val.get(0)).intValue();
707 707
			spaces6[0] = ((Double) val.get(1)).doubleValue();
......
713 713
			spaces6[2] = ((Double) val.get(1)).doubleValue();
714 714
			dwgFile.setHeader("PSPACE_UCSORG", spaces6);
715 715

  
716
			double[] spaces7 = new double[6];
716
			double[] spaces7 = new double[3];
717 717
			val = DwgUtil.getBitDouble(intData, bitPos);
718 718
			bitPos = ((Integer) val.get(0)).intValue();
719 719
			spaces7[0] = ((Double) val.get(1)).doubleValue();
......
725 725
			spaces7[2] = ((Double) val.get(1)).doubleValue();
726 726
			dwgFile.setHeader("PSPACE_UCSXDIR", spaces7);
727 727

  
728
			double[] spaces8 = new double[6];
728
			double[] spaces8 = new double[3];
729 729
			val = DwgUtil.getBitDouble(intData, bitPos);
730 730
			bitPos = ((Integer) val.get(0)).intValue();
731 731
			spaces8[0] = ((Double) val.get(1)).doubleValue();
......
742 742
			intHandle = DwgUtil.handleToInt(val);
743 743
			dwgFile.setHeader("PSPACE_UCSNAME", new Integer(intHandle));
744 744

  
745
			double[] spaces9 = new double[6];
745
			double[] spaces9 = new double[3];
746 746
			val = DwgUtil.getBitDouble(intData, bitPos);
747 747
			bitPos = ((Integer) val.get(0)).intValue();
748 748
			spaces9[0] = ((Double) val.get(1)).doubleValue();
......
754 754
			spaces9[2] = ((Double) val.get(1)).doubleValue();
755 755
			dwgFile.setHeader("MSPACE_INSBASE", spaces9);
756 756

  
757
			double[] spaces10 = new double[6];
757
			double[] spaces10 = new double[3];
758 758
			val = DwgUtil.getBitDouble(intData, bitPos);
759 759
			bitPos = ((Integer) val.get(0)).intValue();
760 760
			spaces10[0] = ((Double) val.get(1)).doubleValue();
......
1169 1169

  
1170 1170
	/**
1171 1171
	 * It read the SECTIONS from the header of the DWG file
1172
	 * 
1172
	 *
1173 1173
	 * TODO Mover esto a una clase abstracta Reader, pues es similar para DWG 15
1174 1174
	 * (o hacer que esta herede de DWG 15)
1175
	 * 
1176
	 * 
1177
	 *  
1175
	 *
1176
	 *
1177
	 *
1178 1178
	 */
1179 1179
	protected void readDwgSectionOffsets() {
1180 1180
		//6 primeros bytes: version de autocad
1181 1181

  
1182 1182
		//7 siguientes bytes: 6 ceros y un 1 (0000001)
1183
		//No obstante, la especificaci?n Python dice que los bytes que lee
1183
		//No obstante, la especificacin Python dice que los bytes que lee
1184 1184
		//con _buf.fromfile(handle, 7) son bytes de la maquina. REVISAR
1185 1185

  
1186 1186
		/*
......
1211 1211
			logger.warn("chunk[6] != 0");
1212 1212

  
1213 1213
		/*
1214
		 *  
1214
		 *
1215 1215
		 */
1216 1216

  
1217
		//Siempre que en python una lectura se haga as? '<'+loquesea
1217
		//Siempre que en python una lectura se haga as '<'+loquesea
1218 1218
		//hay que poner little_endian. Si no, se dejan los de la maquina
1219 1219
		// (y si aparece > se pone big endian)
1220 1220
		bb.order(ByteOrder.LITTLE_ENDIAN);
......
1364 1364
	protected void readDwgClasses() throws Exception {
1365 1365
		int offset = dwgFile.getDwgSectionOffset("CLASSES");
1366 1366
		bb.position(offset);
1367
		//1? leemos el sentinnel inicial
1367
		//1 leemos el sentinnel inicial
1368 1368
		bb.order(ByteOrder.nativeOrder());
1369 1369
		byte[] sentinel = new byte[16];
1370 1370
		bb.get(sentinel);
......
1503 1503

  
1504 1504
	/**
1505 1505
	 * Return a dwg object from its index in the dwg file
1506
	 * 
1506
	 *
1507 1507
	 * @param index
1508 1508
	 *            of the requested dwg object in the dwg file
1509
	 *  
1509
	 *
1510 1510
	 */
1511 1511
	public DwgObject getDwgObjectByIndex(int index) {
1512 1512
		DwgObjectOffset doo = (DwgObjectOffset) dwgFile.getDwgObjectOffsets()
1513 1513
				.get(index);
1514 1514
		return readDwgObject(doo.getOffset(), index);
1515 1515
	}
1516
	
1516

  
1517 1517
	void dumpEntity(int[] intData){
1518 1518
		String outtxt= "int[] data = new int[]{";
1519 1519
		for(int z = 0; z < intData.length -1; z++){
......
1525 1525

  
1526 1526
	/**
1527 1527
	 * Reads a dwg drawing entity (dwg object) given its offset in the file
1528
	 * 
1528
	 *
1529 1529
	 * @param offset
1530 1530
	 *            offset of the dwg object in the file
1531 1531
	 * @param index
......
1558 1558
								dxfEntityName, index);
1559 1559
						if (obj == null) {
1560 1560
							logger.info(dxfEntityName
1561
									+ " todavia no est? implementado");
1561
									+ " todavia no est implementado");
1562 1562
							return null;
1563 1563
						}//if
1564 1564
					}//if newIndex
......
1620 1620
	}
1621 1621

  
1622 1622
	/*
1623
	 * TODO Esto est? pesimamente dise?ado. Cada objeto DwgObject debe tener un
1623
	 * TODO Esto est� pesimamente dise�ado. Cada objeto DwgObject debe tener un
1624 1624
	 * metodo readSpecificObject(data,bitPos)
1625
	 *  
1625
	 *
1626 1626
	 */
1627 1627
	protected void readSpecificObject(DwgObject obj, int[] data, int bitPos)
1628 1628
			throws Exception {
......
1643 1643
	 */
1644 1644
	List readExtendedData(int[] data, int bitPos) throws Exception {
1645 1645
		List solution = new ArrayList();
1646
		//TODO Ver si el array est? bien, o hay que cambiarlo por un
1646
		//TODO Ver si el array est bien, o hay que cambiarlo por un
1647 1647
		// stringbuffer
1648 1648
		List extendedData = new ArrayList();
1649 1649
		int size;
......
1793 1793

  
1794 1794
	/*
1795 1795
	 * (non-Javadoc)
1796
	 * 
1796
	 *
1797 1797
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgFileReader#readObjectHeader(int[],
1798 1798
	 *      int, com.iver.cit.jdwglib.dwg.DwgObject)
1799 1799
	 */
......
1807 1807
		bitPos = ((Integer) val.get(0)).intValue();
1808 1808
		int rnum = ((Integer) val.get(1)).intValue();
1809 1809
		dwgObject.setNumReactors(rnum);
1810
		
1811 1810

  
1811

  
1812 1812
		val = DwgUtil.testBit(data, bitPos);
1813 1813
		bitPos = ((Integer) val.get(0)).intValue();
1814 1814
		boolean isLyrByLineType = ((Boolean) val.get(1)).booleanValue();
......
1837 1837
	}
1838 1838

  
1839 1839
	/*
1840
	 * 
1840
	 *
1841 1841
	 * (non-Javadoc)
1842
	 * 
1842
	 *
1843 1843
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgFileReader#readObjectTailer(int[],
1844 1844
	 *      int, com.iver.cit.jdwglib.dwg.DwgObject)
1845 1845
	 */
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPFacePolyline.java
74 74
import java.util.Map;
75 75

  
76 76
import org.apache.log4j.Logger;
77

  
78 77
import org.gvsig.fmap.geom.Geometry;
79
import org.gvsig.fmap.geom.GeometryFactory;
80
import org.gvsig.fmap.geom.GeometryManager;
81 78
import org.gvsig.fmap.geom.aggregate.MultiSurface2D;
82
import org.gvsig.fmap.geom.primitive.Surface;
83 79
import org.gvsig.fmap.geom.primitive.Surface2D;
84 80

  
85 81
import com.iver.cit.jdwglib.dwg.DwgFile;
......
89 85
import com.iver.cit.jdwglib.dwg.IDwgBlockMember;
90 86
import com.iver.cit.jdwglib.dwg.IDwgPolyline;
91 87
import com.iver.cit.jdwglib.dwg.IDwgVertex;
92
import com.iver.cit.jdwglib.dwg.readers.objreaders.v2004.AbstractDwg2004Reader;
93 88
import com.iver.cit.jdwglib.util.FMapUtil;
94 89

  
95 90
/**
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgCircle.java
171 171
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
172 172
		double[] c = getCenter();
173 173
		Point2D center = new Point2D.Double(c[0], c[1]);
174
		double radius = getRadius();
174
		//FIXME: ¿qué hacer cuando llega un radio negativo?
175
		//	De momento, tomamos el valor absoluto del radio, pero
176
		//	¿habría que modificar de alguna manera los angulos?
177
		double radius = Math.abs(getRadius());
175 178
		if (is3DFile) {
176 179

  
177 180
			return gFactory.createArc2DZ(center, radius, c[2], 0, Math.PI * 2);
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgArc.java
174 174
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
175 175

  
176 176
		double[] center = getCenter();
177
		double radius = getRadius();
177
		//FIXME: ¿qué hacer cuando llega un radio negativo?
178
		//	De momento, tomamos el valor absoluto del radio, pero
179
		//	¿habría que modificar de alguna manera los angulos?
180
		double radius = Math.abs(getRadius());
178 181
		double angSt = getInitAngle();
179 182
		double angEnd = getEndAngle();
180 183
		double angExt = UtilFunctions.angleDistance(angSt, angEnd);
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline2D.java
511 511
						gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(),
512 512
								new Double(((Point2D)vertice).getY()).floatValue());
513 513
					}
514
				}
514
				} else {
515 515

  
516
				if(vertice instanceof double[]){
517
					gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
518
				} else if (vertice instanceof Point2D){
519
					gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(),
520
							new Double(((Point2D)vertice).getY()).floatValue());
516
					if(vertice instanceof double[]){
517
						gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
518
					} else if (vertice instanceof Point2D){
519
						gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(),
520
								new Double(((Point2D)vertice).getY()).floatValue());
521
					}
521 522
				}
522 523
			}
523 524
			if (is3DFile) {
branches/v2_0_0_prep/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline3D.java
401 401
						gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(),
402 402
								new Double(((Point2D)vertice).getY()).floatValue());
403 403
					}
404
				} else {
405
					if(vertice instanceof double[]){
406
						gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
407
					} else if (vertice instanceof Point2D){
408
						gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(),
409
								new Double(((Point2D)vertice).getY()).floatValue());
410
					}
404 411
				}
405
				if(vertice instanceof double[]){
406
					gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
407
				} else if (vertice instanceof Point2D){
408
					gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(),
409
							new Double(((Point2D)vertice).getY()).floatValue());
410
				}
411 412
			}
412 413
			if (is3DFile) {
413 414
				return gFactory.createPolyline3D(gp,getPZ());

Also available in: Unified diff