svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfEntityMaker.java @ 43
History | View | Annotate | Download (16.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 04-may-2004
|
3 |
*/
|
4 |
|
5 |
package org.cresques.px.dxf; |
6 |
|
7 |
import java.awt.geom.Point2D; |
8 |
import java.util.Iterator; |
9 |
import java.util.Vector; |
10 |
|
11 |
import org.cresques.geo.Point3D; |
12 |
import org.cresques.geo.Projected; |
13 |
import org.cresques.geo.Projection; |
14 |
import org.cresques.geo.ReProjection; |
15 |
import org.cresques.io.DxfFile; |
16 |
import org.cresques.io.DxfGroup; |
17 |
import org.cresques.io.DxfGroupVector; |
18 |
import org.cresques.px.Extent; |
19 |
import org.cresques.px.PxObj; |
20 |
|
21 |
/**
|
22 |
* Contructor de objetos Dxf
|
23 |
*
|
24 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
25 |
*/
|
26 |
|
27 |
public class DxfEntityMaker implements DxfFile.EntityFactory, Projected { |
28 |
Projection proj = null;
|
29 |
DxfEntity lastEntity = null;
|
30 |
DxfEntityList entities = null;
|
31 |
DxfTable layers = null;
|
32 |
double bulge = 0.0; |
33 |
|
34 |
double xtruX=0.0, xtruY=0.0, xtruZ=1.0; |
35 |
//double x=Double.NaN, y=Double.NaN, z=Double.NaN;
|
36 |
|
37 |
int polylineFlag = 0; |
38 |
Point2D firstPt = new Point2D.Double(); |
39 |
|
40 |
public DxfEntityMaker (Projection proj) {
|
41 |
this.proj = proj;
|
42 |
layers = new DxfTable();
|
43 |
entities = new DxfEntityList(proj);
|
44 |
} |
45 |
|
46 |
public PxObj getObjects() { return entities; } |
47 |
public Extent getExtent() { return entities.getExtent(); } |
48 |
|
49 |
public void createLayer(DxfGroupVector grp) throws Exception { |
50 |
DxfLayer layer = new DxfLayer(grp.getDataAsString(2), grp.getDataAsInt(62)); |
51 |
layer.lType = grp.getDataAsString(6);
|
52 |
layer.setFlags(grp.getDataAsInt(70));
|
53 |
// compruebo flags
|
54 |
if ((layer.flags & 0x01) == 0x01) { |
55 |
layer.frozen = true;
|
56 |
} |
57 |
if ((layer.flags & 0x02) == 0x02) { |
58 |
layer.frozen = true;
|
59 |
} |
60 |
layers.add(layer); |
61 |
} |
62 |
|
63 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
64 |
//System.out.println("Creando la polylinea");
|
65 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
66 |
DxfPolyline entity = new DxfPolyline(proj, layer);
|
67 |
double x = 0.0, y = 0.0, z = 0.0; |
68 |
double thickness = 0; |
69 |
|
70 |
if (grp.hasCode(10)) |
71 |
x = grp.getDataAsDouble(10);
|
72 |
if (grp.hasCode(20)) |
73 |
y = grp.getDataAsDouble(20);
|
74 |
if (grp.hasCode(30)) |
75 |
z = grp.getDataAsDouble(30);
|
76 |
/*if (grp.hasCode(39))
|
77 |
System.out.println("Leer el thickness provoca un error");
|
78 |
thickness = grp.getDataAsDouble(39);*/
|
79 |
if (grp.hasCode(62)) |
80 |
entity.dxfColor = grp.getDataAsInt(62);
|
81 |
if (grp.hasCode(70)) |
82 |
entity.flags = grp.getDataAsInt(70);
|
83 |
if (grp.hasCode(210)) |
84 |
xtruX = grp.getDataAsDouble(210);
|
85 |
if (grp.hasCode(220)) |
86 |
xtruY = grp.getDataAsDouble(220);
|
87 |
if (grp.hasCode(230)) |
88 |
xtruZ = grp.getDataAsDouble(230);
|
89 |
// compruebo flags
|
90 |
if ((entity.flags & 0x01) == 0x01) { |
91 |
entity.closed = true;
|
92 |
} |
93 |
lastEntity = entity; |
94 |
} |
95 |
public void endSeq() throws Exception { |
96 |
DxfPolyline polyline = (DxfPolyline)lastEntity; |
97 |
if (polyline.closed) {
|
98 |
((DxfPolyline) lastEntity).add(firstPt); |
99 |
if (!(bulge==0)) { |
100 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
101 |
Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge); |
102 |
((DxfPolyline) lastEntity).pts.remove(cnt-1);
|
103 |
for (int i=0; i<arc.size(); i++) { |
104 |
Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
105 |
((DxfPolyline) lastEntity).add(pt); |
106 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
107 |
} |
108 |
bulge = 0.0;
|
109 |
} |
110 |
} |
111 |
entities.add(lastEntity); |
112 |
lastEntity = null;
|
113 |
xtruX = 0.0;
|
114 |
xtruY = 0.0;
|
115 |
xtruZ = 1.0;
|
116 |
bulge = 0.0;
|
117 |
} |
118 |
public void addVertex(DxfGroupVector grp) throws Exception { |
119 |
double x = 0.0, y = 0.0, z = 0.0; |
120 |
|
121 |
if (bulge == 0.0) { |
122 |
x = grp.getDataAsDouble(10);
|
123 |
y = grp.getDataAsDouble(20);
|
124 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
125 |
if (grp.hasCode(42)) { |
126 |
bulge = grp.getDataAsDouble(42);
|
127 |
} else { bulge = 0.0; } |
128 |
Point3D point_in = new Point3D(x, y, z);
|
129 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
130 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
131 |
x = point_out.getX(); |
132 |
y = point_out.getY(); |
133 |
Point2D pt = proj.createPoint( x, y);
|
134 |
((DxfPolyline) lastEntity).add(pt); |
135 |
if (((DxfPolyline)lastEntity).pts.size() == 1) { |
136 |
firstPt = pt; |
137 |
} |
138 |
} else {
|
139 |
double bulge_aux = 0.0; |
140 |
x = grp.getDataAsDouble(10);
|
141 |
y = grp.getDataAsDouble(20);
|
142 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
143 |
if (grp.hasCode(42)) { |
144 |
bulge_aux = grp.getDataAsDouble(42);
|
145 |
} else { bulge_aux = 0.0; } |
146 |
Point3D point_in = new Point3D(x, y, z);
|
147 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
148 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
149 |
x = point_out.getX(); |
150 |
y = point_out.getY(); |
151 |
Point2D pt = proj.createPoint( x, y);
|
152 |
((DxfPolyline) lastEntity).add(pt); |
153 |
if (((DxfPolyline)lastEntity).pts.size() == 1) { |
154 |
firstPt = pt; |
155 |
} |
156 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
157 |
Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge); |
158 |
((DxfPolyline) lastEntity).pts.remove(cnt-1);
|
159 |
for (int i=0; i<arc.size(); i++) { |
160 |
pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
161 |
((DxfPolyline) lastEntity).add(pt); |
162 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
163 |
} |
164 |
bulge = bulge_aux; |
165 |
} |
166 |
} |
167 |
public void createLwPolyline(DxfGroupVector grp) throws Exception { |
168 |
double x = 0.0, y = 0.0, elev=0.0; |
169 |
DxfGroup g = null;
|
170 |
|
171 |
if (grp.hasCode(38)) |
172 |
elev = grp.getDataAsDouble(38);
|
173 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
174 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
175 |
for (int i=0; i<grp.size(); i++) { |
176 |
g = (DxfGroup) grp.get(i); |
177 |
if (g.getCode() == 10) |
178 |
x = ((Float) g.getData()).doubleValue();
|
179 |
else if (g.getCode() == 20) { |
180 |
y = ((Float) g.getData()).doubleValue();
|
181 |
//if (y <= 1.0) throw new Exception("Y == "+y);
|
182 |
entity.add( proj.createPoint( x, y ) ); |
183 |
x = 0.0; y = 0.0; |
184 |
} |
185 |
} |
186 |
if (grp.hasCode(62)) |
187 |
entity.dxfColor = grp.getDataAsInt(62);
|
188 |
if (grp.hasCode(70)) |
189 |
entity.flags = grp.getDataAsInt(70);
|
190 |
entities.add(entity); |
191 |
} |
192 |
|
193 |
public void createLine(DxfGroupVector grp) throws Exception { |
194 |
System.out.println("Pasa por aqui"); |
195 |
double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0; |
196 |
DxfGroup g = null;
|
197 |
Point2D pt1 = null, pt2 = null; |
198 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
199 |
|
200 |
x = grp.getDataAsDouble(10);
|
201 |
y = grp.getDataAsDouble(20);
|
202 |
if (grp.hasCode(30)) z1 = grp.getDataAsDouble(30); |
203 |
pt1 = proj.createPoint(x, y); |
204 |
x = grp.getDataAsDouble(11);
|
205 |
y = grp.getDataAsDouble(21);
|
206 |
if (grp.hasCode(31)) z2 = grp.getDataAsDouble(31); |
207 |
pt2 = proj.createPoint(x, y); |
208 |
if (grp.hasCode(210)) |
209 |
xtruX = grp.getDataAsDouble(210);
|
210 |
if (grp.hasCode(220)) |
211 |
xtruY = grp.getDataAsInt(220);
|
212 |
if (grp.hasCode(230)) |
213 |
xtruZ = grp.getDataAsInt(230);
|
214 |
Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
215 |
Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
216 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
217 |
Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
218 |
Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
219 |
pt1.setLocation(point_out1); |
220 |
pt2.setLocation(point_out2); |
221 |
DxfLine entity = new DxfLine(proj, layer, pt1, pt2);
|
222 |
if (grp.hasCode(62)) |
223 |
entity.dxfColor = grp.getDataAsInt(62);
|
224 |
entities.add(entity); |
225 |
} |
226 |
public void createText(DxfGroupVector grp) throws Exception { |
227 |
double x = 0.0, y = 0.0, h= 0.0, rot= 0.0; |
228 |
DxfGroup g = null;
|
229 |
Point2D pt1 = null, pt2 = null; |
230 |
String txt = null; |
231 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
232 |
|
233 |
txt = grp.getDataAsString(1);
|
234 |
DxfText entity = new DxfText(proj, layer, txt);
|
235 |
|
236 |
x = grp.getDataAsDouble(10);
|
237 |
y = grp.getDataAsDouble(20);
|
238 |
entity.setPt1(proj.createPoint(x, y)); |
239 |
if (grp.hasCode(11)) { |
240 |
x = grp.getDataAsDouble(11);
|
241 |
y = grp.getDataAsDouble(21);
|
242 |
entity.setPt2(proj.createPoint(x, y)); |
243 |
} |
244 |
entity.h = grp.getDataAsDouble(40);
|
245 |
if (grp.hasCode(50)) |
246 |
entity.rot = grp.getDataAsDouble(50);
|
247 |
if (grp.hasCode(62)) |
248 |
entity.dxfColor = grp.getDataAsInt(62);
|
249 |
if (grp.hasCode(72)) |
250 |
entity.align = grp.getDataAsInt(72);
|
251 |
entities.add(entity); |
252 |
} |
253 |
public void createPoint(DxfGroupVector grp) throws Exception { |
254 |
double x = 0.0, y = 0.0, z = 0.0; //, h= 0.0, rot= 0.0; |
255 |
DxfGroup g = null;
|
256 |
Point2D pt = null; |
257 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
258 |
|
259 |
DxfPoint entity = new DxfPoint(proj, layer);
|
260 |
|
261 |
x = grp.getDataAsDouble(10);
|
262 |
y = grp.getDataAsDouble(20);
|
263 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
264 |
if (grp.hasCode(62)) |
265 |
entity.dxfColor = grp.getDataAsInt(62);
|
266 |
if (grp.hasCode(210)) |
267 |
xtruX = grp.getDataAsDouble(210);
|
268 |
if (grp.hasCode(220)) |
269 |
xtruY = grp.getDataAsInt(220);
|
270 |
if (grp.hasCode(230)) |
271 |
xtruZ = grp.getDataAsInt(230);
|
272 |
Point3D point_in = new Point3D(x, y, z);
|
273 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
274 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
275 |
x = point_out.getX(); |
276 |
y = point_out.getY(); |
277 |
entity.setPt(proj.createPoint(x, y)); |
278 |
entities.add(entity); |
279 |
} |
280 |
public void createCircle(DxfGroupVector grp) throws Exception { |
281 |
double x = 0.0, y = 0.0, z = 0.0; |
282 |
double r = 0.0; |
283 |
DxfGroup g = null;
|
284 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
285 |
|
286 |
x = grp.getDataAsDouble(10);
|
287 |
y = grp.getDataAsDouble(20);
|
288 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
289 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
290 |
if (grp.hasCode(210)) |
291 |
xtruX = grp.getDataAsDouble(210);
|
292 |
if (grp.hasCode(220)) |
293 |
xtruY = grp.getDataAsInt(220);
|
294 |
if (grp.hasCode(230)) |
295 |
xtruZ = grp.getDataAsInt(230);
|
296 |
Point3D point_in = new Point3D(x, y, z);
|
297 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
298 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
299 |
x = point_out.getX(); |
300 |
y = point_out.getY(); |
301 |
|
302 |
Point2D center = proj.createPoint( x, y);
|
303 |
Point2D[] pts = new Point2D[360]; |
304 |
int angulo = 0; |
305 |
for (angulo=0; angulo<360; angulo++) { |
306 |
pts[angulo] = new Point2D.Double(center.getX(), center.getY()); |
307 |
pts[angulo].setLocation(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
308 |
if (pts.length == 1) { |
309 |
firstPt = pts[angulo]; |
310 |
} |
311 |
} |
312 |
DxfCircle entity = new DxfCircle(proj, layer, pts);
|
313 |
if (grp.hasCode(62)) |
314 |
entity.dxfColor = grp.getDataAsInt(62);
|
315 |
System.out.println("A?ade un circulo a la lista de entidades"); |
316 |
entities.add(entity); |
317 |
} |
318 |
public void createArc(DxfGroupVector grp) throws Exception { |
319 |
double x = 0.0, y = 0.0, z = 0.0; |
320 |
double r = 0.0, empieza = 0.0, acaba = 0.0; |
321 |
DxfGroup g = null;
|
322 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
323 |
|
324 |
x = grp.getDataAsDouble(10);
|
325 |
y = grp.getDataAsDouble(20);
|
326 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
327 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
328 |
if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50); |
329 |
if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51); |
330 |
if (grp.hasCode(210)) |
331 |
xtruX = grp.getDataAsDouble(210);
|
332 |
if (grp.hasCode(220)) |
333 |
xtruY = grp.getDataAsInt(220);
|
334 |
if (grp.hasCode(230)) |
335 |
xtruZ = grp.getDataAsInt(230);
|
336 |
Point3D point_in = new Point3D(x, y, z);
|
337 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
338 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
339 |
x = point_out.getX(); |
340 |
y = point_out.getY(); |
341 |
|
342 |
Point2D center = proj.createPoint( x, y);
|
343 |
System.out.println("empieza = " + empieza + ", acaba = " + acaba); |
344 |
int iempieza = (int)empieza; |
345 |
int iacaba = (int)acaba; |
346 |
System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba); |
347 |
double angulo = 0; |
348 |
Point2D[] pts = null; |
349 |
if (empieza <= acaba) {
|
350 |
pts = new Point2D[(iacaba-iempieza)+2]; |
351 |
angulo = empieza; |
352 |
pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
353 |
for (int i=1; i<=(iacaba-iempieza)+1; i++) { |
354 |
angulo = (double)(iempieza+i);
|
355 |
pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
356 |
} |
357 |
angulo = acaba; |
358 |
pts[(iacaba-iempieza)+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
359 |
} else {
|
360 |
pts = new Point2D[(360-iempieza)+iacaba+2]; |
361 |
angulo = empieza; |
362 |
System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo); |
363 |
pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
364 |
for (int i=1; i<=(360-iempieza); i++) { |
365 |
angulo = (double)(iempieza+i);
|
366 |
pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
367 |
} |
368 |
for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) { |
369 |
angulo = (double)(i-(360-iempieza)); |
370 |
pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
371 |
} |
372 |
angulo = acaba; |
373 |
pts[(360-iempieza)+iacaba+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
374 |
} |
375 |
DxfArc entity = new DxfArc(proj, layer, pts);
|
376 |
if (grp.hasCode(62)) |
377 |
entity.dxfColor = grp.getDataAsInt(62);
|
378 |
System.out.println("A?ade un arco a la lista de entidades"); |
379 |
entities.add(entity); |
380 |
} |
381 |
public void createInsert(DxfGroupVector grp) throws Exception { |
382 |
double x = 0.0, y = 0.0, z = 0.0; |
383 |
DxfGroup g = null;
|
384 |
Point2D pt = null; |
385 |
String blockName = ""; |
386 |
Point3D scaleFactor = null;
|
387 |
double rotAngle = 0.0; |
388 |
|
389 |
DxfEntityList blocks = new DxfEntityList(proj);
|
390 |
|
391 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
392 |
|
393 |
DxfInsert entity = new DxfInsert(proj, layer, blocks);
|
394 |
|
395 |
if (grp.hasCode(2)) |
396 |
blockName = grp.getDataAsString(2);
|
397 |
x = grp.getDataAsDouble(10);
|
398 |
y = grp.getDataAsDouble(20);
|
399 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
400 |
if (grp.hasCode(41)) |
401 |
scaleFactor = new Point3D(grp.getDataAsDouble(41), 1, 1); |
402 |
if (grp.hasCode(42)) |
403 |
scaleFactor = new Point3D(scaleFactor.getX(), grp.getDataAsDouble(42), 1); |
404 |
if (grp.hasCode(43)) |
405 |
scaleFactor = new Point3D(scaleFactor.getX(), scaleFactor.getY(), grp.getDataAsDouble(43)); |
406 |
if (grp.hasCode(50)) rotAngle = grp.getDataAsDouble(50); |
407 |
if (grp.hasCode(62)) |
408 |
entity.dxfColor = grp.getDataAsInt(62);
|
409 |
if (grp.hasCode(210)) |
410 |
xtruX = grp.getDataAsDouble(210);
|
411 |
if (grp.hasCode(220)) |
412 |
xtruY = grp.getDataAsDouble(220);
|
413 |
if (grp.hasCode(230)) |
414 |
xtruZ = grp.getDataAsDouble(230);
|
415 |
Point3D point_in = new Point3D(x, y, z);
|
416 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
417 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
418 |
x = point_out.getX(); |
419 |
y = point_out.getY(); |
420 |
|
421 |
/*boolean found = false;
|
422 |
Iterator iter = blocks.entities.iterator();
|
423 |
DxfEntityList b = null;
|
424 |
|
425 |
int numBlocks = blocks.entities.size();
|
426 |
System.out.println(numBlocks);
|
427 |
|
428 |
while (iter.hasNext()) {
|
429 |
b = (DxfEntityList)iter.next();
|
430 |
|
431 |
System.out.println("NBLOCK = " + b.getAttribute("NBLOCK") + ", bname = " + blockName);
|
432 |
if (b.getAttribute("NBLOCK").equals(blockName)) {
|
433 |
Point2D c = new Point2D.Double(x,y);
|
434 |
DxfEntityList gc = b;
|
435 |
System.err.print("Rotacion = " + rotAngle);
|
436 |
b = DxfInsert.moveGeometryCollection( gc, c, scaleFactor, rotAngle);
|
437 |
entities.add(b);
|
438 |
|
439 |
found = true;
|
440 |
System.out.println("ENCONTRADO");
|
441 |
break;
|
442 |
}
|
443 |
}
|
444 |
if (! found) {
|
445 |
System.out.println("NO ENCONTRADO"+ blockName);
|
446 |
|
447 |
//b.setGeometry(new GeometryFactory(DPM,0).createPoint(new Coordinate(x,y,z)));
|
448 |
entity.setPt(proj.createPoint(x, y));
|
449 |
|
450 |
//int aux = feature.getID();
|
451 |
//if (debug) System.out.println("AUXXXXXXXXXXXXXXX = " + aux);
|
452 |
//DxfEntity block = null;
|
453 |
//block = feature.getGeometry();
|
454 |
String marca = (String) blockName;
|
455 |
Double xx = new Double(x);
|
456 |
Double yy = new Double(y);
|
457 |
//Double zz = new Double(z);
|
458 |
Double xxscale = new Double(scaleFactor.getX());
|
459 |
Double yyscale = new Double(scaleFactor.getY());
|
460 |
Double zzscale = new Double(scaleFactor.getZ());
|
461 |
Double aangle = new Double(rotAngle);
|
462 |
Object datos[] = new Object[8];
|
463 |
datos[0] = marca;
|
464 |
datos[1] = xx;
|
465 |
datos[2] = yy;
|
466 |
//datos[3] = zz;
|
467 |
datos[4] = xxscale;
|
468 |
datos[5] = yyscale;
|
469 |
datos[6] = zzscale;
|
470 |
datos[7] = aangle;
|
471 |
block.setUserData(datos);
|
472 |
entities.add(b);
|
473 |
}*/
|
474 |
|
475 |
|
476 |
entity.setPt(proj.createPoint(x, y)); |
477 |
entities.add(entity); |
478 |
} |
479 |
public void createSolid(DxfGroupVector grp) throws Exception { |
480 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
481 |
} |
482 |
|
483 |
public Projection getProjection() { return proj;} |
484 |
|
485 |
/**
|
486 |
* Cambia de proyeccion.
|
487 |
*
|
488 |
* @param rp
|
489 |
*/
|
490 |
public void reProject(ReProjection rp) { |
491 |
entities.reProject(rp); |
492 |
} |
493 |
public DxfEntityList getEntities() { return entities;} |
494 |
public DxfTable getLayers() { return layers;} |
495 |
|
496 |
} |
497 |
|
498 |
|
499 |
|