root / trunk / org.gvsig.dwg / org.gvsig.dwg.lib / src / main / java / org / gvsig / dwg / lib / readers / v2004 / DwgPolyline2DReader2004.java @ 5
History | View | Annotate | Download (3.37 KB)
1 |
/*
|
---|---|
2 |
* Created on 25-ene-2007 by azabala
|
3 |
*
|
4 |
*/
|
5 |
package org.gvsig.dwg.lib.readers.v2004; |
6 |
|
7 |
import java.util.ArrayList; |
8 |
|
9 |
import org.gvsig.dwg.lib.CorruptedDwgEntityException; |
10 |
import org.gvsig.dwg.lib.DwgHandleReference; |
11 |
import org.gvsig.dwg.lib.DwgObject; |
12 |
import org.gvsig.dwg.lib.DwgUtil; |
13 |
import org.gvsig.dwg.lib.objects.DwgPolyline2D; |
14 |
|
15 |
|
16 |
/**
|
17 |
* @author alzabord
|
18 |
*
|
19 |
* TODO To change the template for this generated type comment go to
|
20 |
* Window - Preferences - Java - Code Style - Code Templates
|
21 |
*/
|
22 |
public class DwgPolyline2DReader2004 extends AbstractDwg2004Reader{ |
23 |
|
24 |
/* (non-Javadoc)
|
25 |
* @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
|
26 |
*/
|
27 |
public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException { |
28 |
if(! (dwgObj instanceof DwgPolyline2D)) |
29 |
throw new RuntimeException(this.getClass().getName()+" solo puede leer DwgPolyline2D"); |
30 |
DwgPolyline2D ln = (DwgPolyline2D) dwgObj; |
31 |
int bitPos = offset;
|
32 |
boolean dontRead = false; |
33 |
ArrayList v;
|
34 |
|
35 |
|
36 |
bitPos = readObjectHeader(data, bitPos, ln); |
37 |
|
38 |
v = DwgUtil.getBitShort(data, bitPos); |
39 |
bitPos = ((Integer)v.get(0)).intValue(); |
40 |
int flags = ((Integer)v.get(1)).intValue(); |
41 |
ln.setFlags(flags); |
42 |
|
43 |
v = DwgUtil.getBitShort(data, bitPos); |
44 |
bitPos = ((Integer)v.get(0)).intValue(); |
45 |
int ctype = ((Integer)v.get(1)).intValue(); |
46 |
ln.setCurveType(ctype); |
47 |
|
48 |
v = DwgUtil.getBitDouble(data, bitPos); |
49 |
bitPos = ((Integer)v.get(0)).intValue(); |
50 |
double sw = ((Double)v.get(1)).doubleValue(); |
51 |
ln.setInitWidth(sw); |
52 |
|
53 |
v = DwgUtil.getBitDouble(data, bitPos); |
54 |
bitPos = ((Integer)v.get(0)).intValue(); |
55 |
double ew = ((Double)v.get(1)).doubleValue(); |
56 |
ln.setEndWidth(ew); |
57 |
|
58 |
v = DwgUtil.testBit(data, bitPos); |
59 |
bitPos = ((Integer)v.get(0)).intValue(); |
60 |
boolean flag = ((Boolean)v.get(1)).booleanValue(); |
61 |
double th = 0.0; |
62 |
if (!flag) {
|
63 |
v = DwgUtil.getBitDouble(data, bitPos); |
64 |
bitPos = ((Integer)v.get(0)).intValue(); |
65 |
th = ((Double)v.get(1)).doubleValue(); |
66 |
} |
67 |
ln.setThickness(th); |
68 |
|
69 |
v = DwgUtil.getBitDouble(data, bitPos); |
70 |
bitPos = ((Integer)v.get(0)).intValue(); |
71 |
double elev = ((Double)v.get(1)).doubleValue(); |
72 |
ln.setElevation(elev); |
73 |
|
74 |
v = DwgUtil.testBit(data, bitPos); |
75 |
bitPos = ((Integer)v.get(0)).intValue(); |
76 |
flag = ((Boolean)v.get(1)).booleanValue(); |
77 |
double ex, ey, ez = 0.0; |
78 |
if (flag) {
|
79 |
ex = 0.0;
|
80 |
ey = 0.0;
|
81 |
ez = 1.0;
|
82 |
} else {
|
83 |
v = DwgUtil.getBitDouble(data, bitPos); |
84 |
bitPos = ((Integer)v.get(0)).intValue(); |
85 |
ex = ((Double)v.get(1)).doubleValue(); |
86 |
v = DwgUtil.getBitDouble(data, bitPos); |
87 |
bitPos = ((Integer)v.get(0)).intValue(); |
88 |
ey = ((Double)v.get(1)).doubleValue(); |
89 |
v = DwgUtil.getBitDouble(data, bitPos); |
90 |
bitPos = ((Integer)v.get(0)).intValue(); |
91 |
ez = ((Double)v.get(1)).doubleValue(); |
92 |
} |
93 |
ln.setExtrusion(new double[]{ex, ey, ez}); |
94 |
|
95 |
v = DwgUtil.getBitLong(data, bitPos); //OWNED OBJECT COUNT
|
96 |
bitPos = ((Integer)v.get(0)).intValue(); |
97 |
int OwnedObj = ((Integer)v.get(1)).intValue(); |
98 |
|
99 |
bitPos = readObjectTailer(data, bitPos, ln); |
100 |
|
101 |
DwgHandleReference hr; |
102 |
if (OwnedObj>0) { |
103 |
for (int i=0;i<OwnedObj;i++) { |
104 |
hr = new DwgHandleReference();
|
105 |
bitPos = hr.read(data, bitPos); |
106 |
ln.addVertexHandle(hr); |
107 |
} |
108 |
} |
109 |
|
110 |
hr = new DwgHandleReference();
|
111 |
bitPos = hr.read(data, bitPos); |
112 |
ln.setSeqendHandle(hr); |
113 |
ln.inserta(); |
114 |
|
115 |
} |
116 |
|
117 |
} |