svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / readers / v2004 / DwgMeshReader2004.java @ 28969
History | View | Annotate | Download (5.19 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-mar-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: DwgMeshReader15.java,v 1.1.2.1 2007/03/21 19:49:16 azabala Exp $
|
47 |
* $Log: DwgMeshReader15.java,v $
|
48 |
* Revision 1.1.2.1 2007/03/21 19:49:16 azabala
|
49 |
* implementation of dwg 12, 13, 14.
|
50 |
*
|
51 |
* Revision 1.1 2007/03/20 19:57:08 azabala
|
52 |
* source code cleaning
|
53 |
*
|
54 |
*
|
55 |
*/
|
56 |
package org.gvsig.dwg.lib.readers.v2004; |
57 |
|
58 |
import java.util.ArrayList; |
59 |
import java.util.List; |
60 |
|
61 |
import org.gvsig.dwg.lib.CorruptedDwgEntityException; |
62 |
import org.gvsig.dwg.lib.DwgHandleReference; |
63 |
import org.gvsig.dwg.lib.DwgObject; |
64 |
import org.gvsig.dwg.lib.DwgUtil; |
65 |
import org.gvsig.dwg.lib.objects.DwgMeshPolyline; |
66 |
|
67 |
|
68 |
public class DwgMeshReader2004 extends AbstractDwg2004Reader { |
69 |
|
70 |
public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) |
71 |
throws RuntimeException, CorruptedDwgEntityException { |
72 |
if(! (dwgObj instanceof DwgMeshPolyline)) |
73 |
throw new RuntimeException("Meshr 2004 solo puede leer DwgMeshPolyline"); |
74 |
DwgMeshPolyline m = (DwgMeshPolyline) dwgObj; |
75 |
int bitPos = offset;
|
76 |
ArrayList v;
|
77 |
// boolean dontRead = false;
|
78 |
//
|
79 |
//
|
80 |
// v = DwgUtil.getRawLong(data, bitPos);
|
81 |
// bitPos = ((Integer) v.get(0)).intValue();
|
82 |
// int objBSize = ((Integer) v.get(1)).intValue();
|
83 |
// m.setSizeInBits(objBSize);
|
84 |
//
|
85 |
// DwgHandleReference entityHandle = new DwgHandleReference();
|
86 |
// entityHandle.read(data, bitPos);
|
87 |
// if(entityHandle.getCode()!=0 && entityHandle.getCounter()!=1)
|
88 |
// dontRead=true;
|
89 |
// if(!dontRead){
|
90 |
// entityHandle = new DwgHandleReference();
|
91 |
// bitPos = entityHandle.read(data, bitPos);
|
92 |
// m.setHandle(entityHandle);
|
93 |
// }
|
94 |
// if(dontRead) bitPos=bitPos + 16;
|
95 |
//
|
96 |
//
|
97 |
// v=DwgUtil.getBitShort(data, bitPos);
|
98 |
// double newBitPos=((Integer)v.get(0)).intValue();
|
99 |
// newBitPos=newBitPos-bitPos;
|
100 |
// newBitPos=Math.ceil((newBitPos/8));
|
101 |
// bitPos=(int) newBitPos;
|
102 |
//
|
103 |
//
|
104 |
// boolean gflag = false;
|
105 |
// gflag = m.isGraphicsFlag();
|
106 |
// if (gflag) {
|
107 |
// //lee un flag boolean
|
108 |
// v = DwgUtil.testBit(data, bitPos);
|
109 |
// bitPos = ((Integer) v.get(0)).intValue();
|
110 |
// boolean val = ((Boolean) v.get(1)).booleanValue();
|
111 |
// //si hay imagen asociada, se lee por completo
|
112 |
// if (val) {
|
113 |
// v = DwgUtil.getRawLong(data, bitPos);
|
114 |
// bitPos = ((Integer) v.get(0)).intValue();
|
115 |
// int size = ((Integer) v.get(1)).intValue();
|
116 |
// int bgSize = size * 8;
|
117 |
// Integer giData = (Integer) DwgUtil.getBits(data, bgSize,
|
118 |
// bitPos);
|
119 |
// m.setGraphicData(giData.intValue());
|
120 |
// bitPos = bitPos + bgSize;
|
121 |
// }
|
122 |
// }
|
123 |
//
|
124 |
|
125 |
bitPos = readObjectHeader(data, bitPos, m); |
126 |
|
127 |
List val = DwgUtil.getBitShort(data, bitPos);
|
128 |
bitPos = ((Integer) val.get(0)).intValue(); |
129 |
int flags = ((Integer) val.get(1)).intValue(); |
130 |
m.setFlags(flags); |
131 |
|
132 |
val = DwgUtil.getBitShort(data, bitPos); |
133 |
bitPos = ((Integer) val.get(0)).intValue(); |
134 |
int curveType = ((Integer) val.get(1)).intValue(); |
135 |
m.setCurveType(curveType); |
136 |
|
137 |
val = DwgUtil.getBitShort(data, bitPos); |
138 |
bitPos = ((Integer) val.get(0)).intValue(); |
139 |
int mVerticies = ((Integer) val.get(1)).intValue(); |
140 |
m.setMVerticies(mVerticies); |
141 |
|
142 |
val = DwgUtil.getBitShort(data, bitPos); |
143 |
bitPos = ((Integer) val.get(0)).intValue(); |
144 |
int nVerticies = ((Integer) val.get(1)).intValue(); |
145 |
m.setNVerticies(nVerticies); |
146 |
|
147 |
val = DwgUtil.getBitShort(data, bitPos); |
148 |
bitPos = ((Integer) val.get(0)).intValue(); |
149 |
int mDensity = ((Integer) val.get(1)).intValue(); |
150 |
m.setMDensity(mDensity); |
151 |
|
152 |
val = DwgUtil.getBitShort(data, bitPos); |
153 |
bitPos = ((Integer) val.get(0)).intValue(); |
154 |
int nDensity = ((Integer) val.get(1)).intValue(); |
155 |
m.setNDensity(nDensity); |
156 |
|
157 |
val = DwgUtil.getBitLong(data, bitPos); //OWNED OBJECT COUNT
|
158 |
bitPos = ((Integer)val.get(0)).intValue(); |
159 |
int OwnedObj = ((Integer)val.get(1)).intValue(); |
160 |
|
161 |
bitPos = readObjectTailer(data, bitPos, m); |
162 |
|
163 |
DwgHandleReference handle; |
164 |
|
165 |
if (OwnedObj>0) { |
166 |
for (int i=0;i<OwnedObj;i++) { |
167 |
handle = new DwgHandleReference();
|
168 |
bitPos = handle.read(data, bitPos); |
169 |
m.addOwnedObjectHandle(handle); |
170 |
} |
171 |
} |
172 |
|
173 |
handle = new DwgHandleReference();
|
174 |
bitPos = handle.read(data, bitPos); |
175 |
m.setSeqendHandle(handle); |
176 |
} |
177 |
|
178 |
} |
179 |
|