root / trunk / org.gvsig.dwg / org.gvsig.dwg.lib / src / main / java / org / gvsig / dwg / lib / readers / v15 / DwgBlockHeaderReader15.java @ 5
History | View | Annotate | Download (5.54 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.DwgHandleReference; |
11 |
import org.gvsig.dwg.lib.DwgObject; |
12 |
import org.gvsig.dwg.lib.DwgUtil; |
13 |
import org.gvsig.dwg.lib.objects.DwgBlockHeader; |
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 DwgBlockHeaderReader15 extends AbstractDwg15Reader{ |
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 DwgBlockHeader)) |
29 |
throw new RuntimeException("DwgBlockHeaderReader15 solo puede leer DwgBlockControl"); |
30 |
DwgBlockHeader hdr = (DwgBlockHeader) dwgObj; |
31 |
int bitPos = offset;
|
32 |
ArrayList v = DwgUtil.getBitLong(data, bitPos);
|
33 |
bitPos = ((Integer)v.get(0)).intValue(); |
34 |
int numReactors = ((Integer)v.get(1)).intValue(); |
35 |
hdr.setNumReactors(numReactors); |
36 |
|
37 |
v = DwgUtil.getTextString(data, bitPos); |
38 |
bitPos = ((Integer)v.get(0)).intValue(); |
39 |
String name = (String)v.get(1); |
40 |
hdr.setName(name); |
41 |
|
42 |
v = DwgUtil.testBit(data, bitPos); |
43 |
bitPos = ((Integer)v.get(0)).intValue(); |
44 |
boolean flag = ((Boolean)v.get(1)).booleanValue(); |
45 |
hdr.setFlag64(flag); |
46 |
|
47 |
v = DwgUtil.getBitShort(data, bitPos); |
48 |
bitPos = ((Integer)v.get(0)).intValue(); |
49 |
int xrefplus1 = ((Integer)v.get(1)).intValue(); |
50 |
hdr.setXRefPlus(xrefplus1); |
51 |
|
52 |
v = DwgUtil.testBit(data, bitPos); |
53 |
bitPos = ((Integer)v.get(0)).intValue(); |
54 |
boolean xdep = ((Boolean)v.get(1)).booleanValue(); |
55 |
hdr.setXdep(xdep); |
56 |
|
57 |
v = DwgUtil.testBit(data, bitPos); |
58 |
bitPos = ((Integer)v.get(0)).intValue(); |
59 |
boolean anon = ((Boolean)v.get(1)).booleanValue(); |
60 |
hdr.setAnonymous(anon); |
61 |
|
62 |
v = DwgUtil.testBit(data, bitPos); |
63 |
bitPos = ((Integer)v.get(0)).intValue(); |
64 |
boolean hasatts = ((Boolean)v.get(1)).booleanValue(); |
65 |
hdr.setHasAttrs(hasatts); |
66 |
|
67 |
v = DwgUtil.testBit(data, bitPos); |
68 |
bitPos = ((Integer)v.get(0)).intValue(); |
69 |
boolean bxref = ((Boolean)v.get(1)).booleanValue(); |
70 |
hdr.setBlkIsXRef(bxref); |
71 |
|
72 |
v = DwgUtil.testBit(data, bitPos); |
73 |
bitPos = ((Integer)v.get(0)).intValue(); |
74 |
boolean xover = ((Boolean)v.get(1)).booleanValue(); |
75 |
hdr.setXRefOverLaid(xover); |
76 |
|
77 |
v = DwgUtil.testBit(data, bitPos); |
78 |
bitPos = ((Integer)v.get(0)).intValue(); |
79 |
boolean loaded = ((Boolean)v.get(1)).booleanValue(); |
80 |
hdr.setLoaded(loaded); |
81 |
|
82 |
v = DwgUtil.getBitDouble(data, bitPos); |
83 |
bitPos = ((Integer)v.get(0)).intValue(); |
84 |
double bx = ((Double)v.get(1)).doubleValue(); |
85 |
|
86 |
v = DwgUtil.getBitDouble(data, bitPos); |
87 |
bitPos = ((Integer)v.get(0)).intValue(); |
88 |
double by = ((Double)v.get(1)).doubleValue(); |
89 |
|
90 |
v = DwgUtil.getBitDouble(data, bitPos); |
91 |
bitPos = ((Integer)v.get(0)).intValue(); |
92 |
double bz = ((Double)v.get(1)).doubleValue(); |
93 |
double[] coord = new double[]{bx, by, bz}; |
94 |
hdr.setBasePoint(coord); |
95 |
|
96 |
v = DwgUtil.getTextString(data, bitPos); |
97 |
bitPos = ((Integer)v.get(0)).intValue(); |
98 |
String pname = (String)v.get(1); |
99 |
hdr.setXRefPName(pname); |
100 |
int icount = 0; |
101 |
while (true) { |
102 |
v = DwgUtil.getRawChar(data, bitPos); |
103 |
bitPos = ((Integer)v.get(0)).intValue(); |
104 |
int val = ((Integer)v.get(1)).intValue(); |
105 |
if (val==0) { |
106 |
break;
|
107 |
} |
108 |
icount++; |
109 |
} |
110 |
|
111 |
v = DwgUtil.getTextString(data, bitPos); |
112 |
bitPos = ((Integer)v.get(0)).intValue(); |
113 |
String desc = (String)v.get(1); |
114 |
hdr.setBlockDescription(desc); |
115 |
v = DwgUtil.getBitLong(data, bitPos); |
116 |
bitPos = ((Integer)v.get(0)).intValue(); |
117 |
int pdsize = ((Integer)v.get(1)).intValue(); |
118 |
if (pdsize>0) { |
119 |
int count = pdsize + icount;
|
120 |
//int pdata = ((Integer)DwgUtil.getBits(data, count, bitPos)).intValue();
|
121 |
//previewData = pdata;
|
122 |
bitPos = bitPos + count; |
123 |
} |
124 |
|
125 |
DwgHandleReference blkCtrlHdl = new DwgHandleReference();
|
126 |
bitPos = blkCtrlHdl.read(data, bitPos); |
127 |
hdr.setBlockControlHandle(blkCtrlHdl); |
128 |
|
129 |
for (int i=0;i<numReactors;i++) { |
130 |
DwgHandleReference reactor = new DwgHandleReference();
|
131 |
bitPos = reactor.read(data, bitPos); |
132 |
|
133 |
} |
134 |
|
135 |
DwgHandleReference xdicObjHdl = new DwgHandleReference();
|
136 |
bitPos = xdicObjHdl.read(data, bitPos); |
137 |
hdr.setXDicObjHandle(xdicObjHdl); |
138 |
|
139 |
DwgHandleReference handle = new DwgHandleReference();
|
140 |
bitPos = handle.read(data, bitPos); |
141 |
hdr.setNullHandle(handle); |
142 |
|
143 |
handle = new DwgHandleReference();
|
144 |
bitPos = handle.read(data, bitPos); |
145 |
hdr.setBlockEntityHandle(handle); |
146 |
|
147 |
if ((!bxref) && (!xover)) {
|
148 |
handle = new DwgHandleReference();
|
149 |
bitPos = handle.read(data, bitPos); |
150 |
hdr.setFirstEntityHandle(handle); |
151 |
|
152 |
handle = new DwgHandleReference();
|
153 |
bitPos = handle.read(data, bitPos); |
154 |
hdr.setLastEntityHandle(handle); |
155 |
}//si el bloque es una referencia externa, es un fichero entero
|
156 |
//(no ninguna entidad del fichero actual)
|
157 |
|
158 |
handle = new DwgHandleReference();
|
159 |
bitPos = handle.read(data, bitPos); |
160 |
hdr.setEndBlkEntityHandle(handle); |
161 |
|
162 |
if(icount > 0){ |
163 |
DwgHandleReference[] insertHandles = new |
164 |
DwgHandleReference[icount]; |
165 |
for(int i = 0; i < icount; i++){ |
166 |
insertHandles[i] = new DwgHandleReference();
|
167 |
bitPos = insertHandles[i].read(data, bitPos); |
168 |
} |
169 |
hdr.setInsertHandles(insertHandles); |
170 |
} |
171 |
|
172 |
handle = new DwgHandleReference();
|
173 |
bitPos = handle.read(data, bitPos); |
174 |
hdr.setLayoutHandle(handle); |
175 |
} |
176 |
} |