root / trunk / org.gvsig.dwg / org.gvsig.dwg.lib / src / main / java / org / gvsig / dwg / lib / readers / v15 / DwgLineReader15.java @ 5
History | View | Annotate | Download (3.32 KB)
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.DwgLine; |
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 DwgLineReader15 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 DwgLine)) |
28 |
throw new RuntimeException("ArcReader 15 solo puede leer DwgLine"); |
29 |
DwgLine line = (DwgLine) dwgObj; |
30 |
int bitPos = offset;
|
31 |
bitPos = headTailReader.readObjectHeader(data, bitPos, line); |
32 |
ArrayList v = DwgUtil.testBit(data, bitPos);
|
33 |
bitPos = ((Integer)v.get(0)).intValue(); |
34 |
line.setZflag(((Boolean)v.get(1)).booleanValue()); |
35 |
v = DwgUtil.getRawDouble(data, bitPos); |
36 |
bitPos = ((Integer)v.get(0)).intValue(); |
37 |
double x1 = ((Double)v.get(1)).doubleValue(); |
38 |
v = DwgUtil.getDefaultDouble(data, bitPos, x1); |
39 |
bitPos = ((Integer)v.get(0)).intValue(); |
40 |
double x2 = ((Double)v.get(1)).doubleValue(); |
41 |
v = DwgUtil.getRawDouble(data, bitPos); |
42 |
bitPos = ((Integer)v.get(0)).intValue(); |
43 |
double y1 = ((Double)v.get(1)).doubleValue(); |
44 |
v = DwgUtil.getDefaultDouble(data, bitPos, y1); |
45 |
bitPos = ((Integer)v.get(0)).intValue(); |
46 |
double y2 = ((Double)v.get(1)).doubleValue(); |
47 |
double[] p1; |
48 |
double[] p2; |
49 |
if (!line.isZflag()) {
|
50 |
v = DwgUtil.getRawDouble(data, bitPos); |
51 |
bitPos = ((Integer)v.get(0)).intValue(); |
52 |
double z1 = ((Double)v.get(1)).doubleValue(); |
53 |
v = DwgUtil.getDefaultDouble(data, bitPos, z1); |
54 |
bitPos = ((Integer)v.get(0)).intValue(); |
55 |
double z2 = ((Double)v.get(1)).doubleValue(); |
56 |
p1 = new double[]{x1, y1, z1}; |
57 |
p2 = new double[]{x2, y2, z2}; |
58 |
} else {
|
59 |
p1 = new double[]{x1, y1, 0d}; |
60 |
p2 = new double[]{x2, y2, 0d}; |
61 |
} |
62 |
line.setP1(p1); |
63 |
line.setP2(p2); |
64 |
v = DwgUtil.testBit(data, bitPos); |
65 |
bitPos = ((Integer)v.get(0)).intValue(); |
66 |
boolean flag = ((Boolean)v.get(1)).booleanValue(); |
67 |
double val;
|
68 |
if (flag) {
|
69 |
val=0.0;
|
70 |
} else {
|
71 |
v = DwgUtil.getBitDouble(data, bitPos); |
72 |
bitPos = ((Integer)v.get(0)).intValue(); |
73 |
val = ((Double)v.get(1)).doubleValue(); |
74 |
} |
75 |
line.setThickness(val); |
76 |
v = DwgUtil.testBit(data, bitPos); |
77 |
bitPos = ((Integer)v.get(0)).intValue(); |
78 |
flag = ((Boolean)v.get(1)).booleanValue(); |
79 |
double x, y, z;
|
80 |
if (flag) {
|
81 |
x = y = 0.0;
|
82 |
z = 1.0;
|
83 |
} else {
|
84 |
v = DwgUtil.getBitDouble(data, bitPos); |
85 |
bitPos = ((Integer)v.get(0)).intValue(); |
86 |
x = ((Double)v.get(1)).doubleValue(); |
87 |
v = DwgUtil.getBitDouble(data, bitPos); |
88 |
bitPos = ((Integer)v.get(0)).intValue(); |
89 |
y = ((Double)v.get(1)).doubleValue(); |
90 |
v = DwgUtil.getBitDouble(data, bitPos); |
91 |
bitPos = ((Integer)v.get(0)).intValue(); |
92 |
z = ((Double)v.get(1)).doubleValue(); |
93 |
} |
94 |
double[] coord = new double[]{x, y, z}; |
95 |
line.setExtrusion(coord); |
96 |
bitPos = headTailReader.readObjectTailer(data, bitPos, line); |
97 |
} |
98 |
|
99 |
} |