Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfEntityMaker.java @ 57

History | View | Annotate | Download (19.1 KB)

1
package org.cresques.px.dxf;
2

    
3
import java.awt.geom.Point2D;
4
import java.util.Vector;
5
import org.cresques.geo.Point3D;
6
import org.cresques.geo.Projected;
7
import org.cresques.geo.Projection;
8
import org.cresques.geo.ReProjection;
9
import org.cresques.io.DxfFile;
10
import org.cresques.io.DxfGroup;
11
import org.cresques.io.DxfGroupVector;
12
import org.cresques.px.Extent;
13
import org.cresques.px.PxObj;
14

    
15
public class DxfEntityMaker implements DxfFile.EntityFactory, Projected {
16
        Projection proj = null;
17
        DxfEntity lastEntity = null;
18
        DxfEntityList entities = null;
19
        Vector blkList = null;
20
        DxfBlock blk = null;
21
        DxfTable layers = null;
22
        double bulge = 0.0;
23

    
24
    double xtruX=0.0, xtruY=0.0, xtruZ=1.0;
25
    
26
    int polylineFlag = 0;
27
    Point2D firstPt = new Point2D.Double();
28
    
29
    boolean addingToBlock = false;
30
    int i = 0;
31
        
32
        public DxfEntityMaker (Projection proj) {
33
                this.proj = proj;
34
                layers = new DxfTable();
35
                entities = new DxfEntityList(proj);
36
                blkList = new Vector();
37
        }
38
        
39
        public PxObj getObjects() { return entities; }
40
        public Extent getExtent() { return entities.getExtent(); }
41

    
42
        public void setAddingToBlock(boolean a) { addingToBlock = a; }
43
        
44
        public void createLayer(DxfGroupVector grp) throws Exception {
45
                DxfLayer layer = new DxfLayer(grp.getDataAsString(2), grp.getDataAsInt(62));
46
                layer.lType = grp.getDataAsString(6);
47
                layer.setFlags(grp.getDataAsInt(70));
48
                // compruebo flags
49
                if ((layer.flags & 0x01) == 0x01) {
50
                        layer.frozen = true;
51
                }
52
                if ((layer.flags & 0x02) == 0x02) {
53
                        layer.frozen = true;
54
                }
55
                layers.add(layer);
56
        }
57
        
58
        public void createPolyline(DxfGroupVector grp) throws Exception {
59
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
60
                DxfPolyline entity = new DxfPolyline(proj, layer);
61
                
62
                double x = 0.0, y = 0.0, z = 0.0;
63
                double thickness = 0;
64
                
65
                if (grp.hasCode(10))
66
                        x = grp.getDataAsDouble(10);
67
                if (grp.hasCode(20))
68
                        y = grp.getDataAsDouble(20);
69
                if (grp.hasCode(30))
70
                        z = grp.getDataAsDouble(30);
71
                /*if (grp.hasCode(39))
72
                        System.out.println("Leer el thickness provoca un error");
73
                        thickness = grp.getDataAsDouble(39);*/
74
                if (grp.hasCode(62)) {
75
                        entity.dxfColor = grp.getDataAsInt(62);
76
                }
77
                if (grp.hasCode(70)) {
78
                        entity.flags = grp.getDataAsInt(70);                        
79
                }
80
                if (grp.hasCode(210))
81
                        xtruX = grp.getDataAsDouble(210);
82
                if (grp.hasCode(220))
83
                        xtruY = grp.getDataAsDouble(220);
84
                if (grp.hasCode(230))
85
                        xtruZ = grp.getDataAsDouble(230);
86
                if ((entity.flags & 0x01) == 0x01) {
87
                        entity.closed = true;
88
                }
89
                lastEntity = entity;
90
        }
91
        public void endSeq() throws Exception {
92
                DxfPolyline polyline = (DxfPolyline)lastEntity;
93
                if (polyline.closed) {
94
                        ((DxfPolyline) lastEntity).add(firstPt);
95
                        if (!(bulge==0)) {
96
                                int cnt = ((DxfPolyline) lastEntity).pts.size();
97
                                Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge);
98
                                ((DxfPolyline) lastEntity).pts.remove(cnt-1);
99
                                for (int i=0; i<arc.size(); i++) {
100
                                        Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
101
                                        ((DxfPolyline) lastEntity).add(pt);
102
                                        if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt;
103
                                }
104
                                bulge = 0.0;
105
                        }
106
                }
107
                if (addingToBlock == false) {
108
                        entities.add(lastEntity);
109
                } else {
110
                        System.out.println("createPolyline: A?adimos una polilinea al bloque " + i);
111
                        blk.add(lastEntity);
112
                }
113
                lastEntity = null;
114
                xtruX = 0.0;
115
                xtruY = 0.0;
116
                xtruZ = 1.0;
117
                bulge = 0.0;
118
        }
119
        public void addVertex(DxfGroupVector grp) throws Exception {
120
                double x = 0.0, y = 0.0, z = 0.0;
121
                
122
                if (bulge == 0.0) {
123
                        x  = grp.getDataAsDouble(10);
124
                        y  = grp.getDataAsDouble(20);
125
                        if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
126
                        if (grp.hasCode(42)) {
127
                                bulge = grp.getDataAsDouble(42);
128
                        } else { bulge = 0.0; }
129
                        Point3D point_in = new Point3D(x, y, z);
130
                        Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
131
                        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
132
                        x = point_out.getX();
133
                        y = point_out.getY();
134
                        Point2D pt = proj.createPoint( x, y);
135
                        ((DxfPolyline) lastEntity).add(pt);
136
                        if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt;
137
                } else {
138
                        double bulge_aux = 0.0;
139
                        x  = grp.getDataAsDouble(10);
140
                        y  = grp.getDataAsDouble(20);
141
                        if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
142
                        if (grp.hasCode(42)) {
143
                                bulge_aux = grp.getDataAsDouble(42);
144
                        } else { bulge_aux = 0.0; }
145
                        Point3D point_in = new Point3D(x, y, z);
146
                        Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
147
                        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
148
                        x = point_out.getX();
149
                        y = point_out.getY();
150
                        Point2D pt = proj.createPoint( x, y);
151
                        ((DxfPolyline) lastEntity).add(pt);
152
                        if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt;
153
                        int cnt = ((DxfPolyline) lastEntity).pts.size();
154
                        Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge);
155
                        ((DxfPolyline) lastEntity).pts.remove(cnt-1);
156
                        for (int i=0; i<arc.size(); i++) {
157
                                pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
158
                                ((DxfPolyline) lastEntity).add(pt);
159
                                if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt;
160
                        }
161
                        bulge = bulge_aux;
162
                }
163
        }
164
        public void createLwPolyline(DxfGroupVector grp) throws Exception {
165
                double x = 0.0, y = 0.0, elev=0.0;
166
                DxfGroup g = null;
167
                
168
                if (grp.hasCode(38))
169
                        elev = grp.getDataAsDouble(38);
170
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
171
                DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
172
                for (int i=0; i<grp.size(); i++) {
173
                        g = (DxfGroup) grp.get(i);
174
                        if (g.getCode() == 10)
175
                                x = ((Float) g.getData()).doubleValue();
176
                        else if (g.getCode() == 20) {
177
                                y = ((Float) g.getData()).doubleValue();
178
                                //if (y <= 1.0) throw new Exception("Y == "+y);
179
                                entity.add( proj.createPoint( x, y ) );
180
                                x = 0.0; y = 0.0;
181
                        }
182
                }
183
                if (grp.hasCode(62))
184
                        entity.dxfColor = grp.getDataAsInt(62);
185
                if (grp.hasCode(70))
186
                        entity.flags = grp.getDataAsInt(70);
187
                if (addingToBlock == false) {
188
                        entities.add(entity);
189
                } else {
190
                        System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + i);
191
                        blk.add(entity);
192
                }
193
        }
194
        public void createLine(DxfGroupVector grp) throws Exception {
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
                }
225
                if (addingToBlock == false) {
226
                        entities.add(entity);
227
                } else {
228
                        System.out.println("createLine(): A?adimos una linea al bloque " + i);
229
                        blk.add(entity);
230
                }
231
        }
232
        public void createText(DxfGroupVector grp) throws Exception {
233
                double x = 0.0, y = 0.0, h= 0.0, rot= 0.0;
234
                DxfGroup g = null;
235
                Point2D pt1 = null, pt2 = null;
236
                String txt = null;
237
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
238

    
239
                txt = grp.getDataAsString(1);
240
                DxfText entity = new DxfText(proj, layer, txt);
241

    
242
                x = grp.getDataAsDouble(10);
243
                y = grp.getDataAsDouble(20);
244
                entity.setPt1(proj.createPoint(x, y));
245
                if (grp.hasCode(11)) {
246
                        x = grp.getDataAsDouble(11);
247
                        y = grp.getDataAsDouble(21);
248
                        entity.setPt2(proj.createPoint(x, y));
249
                }
250
                entity.h = grp.getDataAsDouble(40);
251
                if (grp.hasCode(50))
252
                        entity.rot = grp.getDataAsDouble(50);
253
                if (grp.hasCode(62))
254
                        entity.dxfColor = grp.getDataAsInt(62);
255
                if (grp.hasCode(72))
256
                        entity.align = grp.getDataAsInt(72);
257
                if (addingToBlock == false) {
258
                        entities.add(entity);
259
                } else {
260
                        System.out.println("createText(): A?adimos un text al bloque " + i);
261
                        blk.add(entity);
262
                }
263
        }
264
        public void createPoint(DxfGroupVector grp) throws Exception {
265
                double x = 0.0, y = 0.0, z = 0.0; //, h= 0.0, rot= 0.0;
266
                DxfGroup g = null;
267
                Point2D pt = null;
268
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
269

    
270
                DxfPoint entity = new DxfPoint(proj, layer);
271

    
272
                x = grp.getDataAsDouble(10);
273
                y = grp.getDataAsDouble(20);
274
                if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
275
                if (grp.hasCode(62))
276
                        entity.dxfColor = grp.getDataAsInt(62);
277
                if (grp.hasCode(210))
278
                        xtruX = grp.getDataAsDouble(210);
279
                if (grp.hasCode(220))
280
                        xtruY = grp.getDataAsInt(220);
281
                if (grp.hasCode(230))
282
                        xtruZ = grp.getDataAsInt(230);
283
                Point3D point_in = new Point3D(x, y, z);
284
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
285
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
286
                x = point_out.getX();
287
                y = point_out.getY();
288
                entity.setPt(proj.createPoint(x, y));
289
                if (addingToBlock == false) {
290
                        entities.add(entity);
291
                } else {
292
                        System.out.println("createPoint(): A?adimos un punto al bloque " + i);
293
                        blk.add(entity);
294
                }
295
        }
296
        public void createCircle(DxfGroupVector grp) throws Exception {
297
                double x = 0.0, y = 0.0, z = 0.0;
298
                double r = 0.0;
299
                DxfGroup g = null;
300
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
301

    
302
                x = grp.getDataAsDouble(10);
303
                y = grp.getDataAsDouble(20);
304
                if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
305
                if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
306
                if (grp.hasCode(210))
307
                        xtruX = grp.getDataAsDouble(210);
308
                if (grp.hasCode(220))
309
                        xtruY = grp.getDataAsDouble(220);
310
                if (grp.hasCode(230))
311
                        xtruZ = grp.getDataAsDouble(230);
312
                Point3D point_in = new Point3D(x, y, z);
313
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
314
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
315
                x = point_out.getX();
316
                y = point_out.getY();
317
                
318
                Point2D center = proj.createPoint( x, y);
319
                Point2D[] pts = new Point2D[360];
320
                int angulo = 0;
321
                for (angulo=0; angulo<360; angulo++) {
322
                        pts[angulo] = new Point2D.Double(center.getX(), center.getY());
323
                        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));
324
                        if (pts.length == 1) {
325
                                firstPt = pts[angulo];
326
                        }
327
                }
328
                DxfCircle entity = new DxfCircle(proj, layer, pts);
329
                if (grp.hasCode(62))
330
                        entity.dxfColor = grp.getDataAsInt(62);
331
                if (addingToBlock == false) {
332
                        System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
333
                        entities.add(entity);
334
                } else {
335
                        System.out.println("createCircle(): A?adimos un circulo al bloque " + i);
336
                        blk.add(entity);
337
                }
338
        }
339
        public void createArc(DxfGroupVector grp) throws Exception {
340
                double x = 0.0, y = 0.0, z = 0.0;
341
                double r = 0.0, empieza = 0.0, acaba = 0.0;
342
                DxfGroup g = null;
343
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
344

    
345
                x = grp.getDataAsDouble(10);
346
                y = grp.getDataAsDouble(20);
347
                if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
348
                if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
349
                if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50);
350
                if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51);
351
                if (grp.hasCode(210))
352
                        xtruX = grp.getDataAsDouble(210);
353
                if (grp.hasCode(220))
354
                        xtruY = grp.getDataAsDouble(220);
355
                if (grp.hasCode(230))
356
                        xtruZ = grp.getDataAsDouble(230);
357
                Point3D point_in = new Point3D(x, y, z);
358
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
359
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
360
                x = point_out.getX();
361
                y = point_out.getY();
362
                
363
                Point2D center = proj.createPoint( x, y);
364
                System.out.println("empieza = " + empieza + ", acaba = " + acaba);
365
                int iempieza = (int)empieza;
366
                int iacaba = (int)acaba;
367
                System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
368
                double angulo = 0;
369
                Point2D[] pts = null;
370
                if (empieza <= acaba) {
371
                        pts = new Point2D[(iacaba-iempieza)+2];
372
                        angulo = empieza;
373
                        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));
374
                        for (int i=1; i<=(iacaba-iempieza)+1; i++) {
375
                                angulo = (double)(iempieza+i);
376
                                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));
377
                        }
378
                        angulo = acaba;
379
                        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));
380
                } else {
381
                        pts = new Point2D[(360-iempieza)+iacaba+2];
382
                        angulo = empieza;
383
                        System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
384
                        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));
385
                        for (int i=1; i<=(360-iempieza); i++) {
386
                                angulo = (double)(iempieza+i);
387
                                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));
388
                        }
389
                        for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) {
390
                                angulo = (double)(i-(360-iempieza));
391
                                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));
392
                        }
393
                        angulo = acaba;
394
                        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));
395
                }
396
                DxfArc entity = new DxfArc(proj, layer, pts);
397
                if (grp.hasCode(62))
398
                        entity.dxfColor = grp.getDataAsInt(62);
399
                System.out.println("createArc(): A?ade un arco a la lista de entidades");
400
                if (addingToBlock == false) {
401
                        entities.add(entity);
402
                } else {
403
                        System.out.println("createArc(): A?adimos un arco al bloque " + i);
404
                        blk.add(entity);
405
                }
406
        }
407
        public void createInsert(DxfGroupVector grp) throws Exception {
408
                double x = 0.0, y = 0.0, z = 0.0;
409
                DxfGroup g = null;
410
                Point2D pt = null;
411
                String blockName = "";
412
                Point3D scaleFactor = null;
413
                double rotAngle = 0.0;
414
                
415
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
416

    
417
                DxfEntityList blocks = new DxfEntityList(proj);
418
                DxfInsert entity = new DxfInsert(proj, layer, blocks);
419

    
420
                if (grp.hasCode(2))
421
                        blockName = grp.getDataAsString(2);
422
                x = grp.getDataAsDouble(10);
423
                y = grp.getDataAsDouble(20);
424
                if (grp.hasCode(30)) z = grp.getDataAsDouble(30);
425
                if (grp.hasCode(41))
426
                        scaleFactor = new Point3D(grp.getDataAsDouble(41), 1, 1);
427
                if (grp.hasCode(42))
428
                        scaleFactor = new Point3D(scaleFactor.getX(), grp.getDataAsDouble(42), 1);
429
                if (grp.hasCode(43))
430
                        scaleFactor = new Point3D(scaleFactor.getX(), scaleFactor.getY(), grp.getDataAsDouble(43));
431
                if (grp.hasCode(50)) rotAngle = grp.getDataAsDouble(50);
432
                if (grp.hasCode(62))
433
                        entity.dxfColor = grp.getDataAsInt(62);
434
                if (grp.hasCode(210))
435
                        xtruX = grp.getDataAsDouble(210);
436
                if (grp.hasCode(220))
437
                        xtruY = grp.getDataAsDouble(220);
438
                if (grp.hasCode(230))
439
                        xtruZ = grp.getDataAsDouble(230);
440
                Point3D point_in = new Point3D(x, y, z);
441
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
442
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
443
                x = point_out.getX();
444
                y = point_out.getY();
445
                
446
                /*boolean found = false;
447
                Iterator iter = blocks.entities.iterator();
448
                DxfEntityList b = null;
449
                
450
                int numBlocks = blocks.entities.size();
451
                System.out.println(numBlocks);
452
                
453
                while (iter.hasNext()) {
454
                        b = (DxfEntityList)iter.next();
455
                        
456
                        System.out.println("NBLOCK = " + b.getAttribute("NBLOCK") + ", bname = " + blockName);
457
                        if (b.getAttribute("NBLOCK").equals(blockName)) {
458
                                Point2D c = new Point2D.Double(x,y);
459
                                DxfEntityList gc = b;
460
                                System.err.print("Rotacion = " + rotAngle);
461
                                b = DxfInsert.moveGeometryCollection( gc, c, scaleFactor, rotAngle);
462
                                entities.add(b);
463
                                
464
                                found = true;
465
                                System.out.println("ENCONTRADO");
466
                                break;
467
                        }
468
                }
469
                if (! found) {
470
                        System.out.println("NO ENCONTRADO"+ blockName);
471
                                                                
472
                        //b.setGeometry(new GeometryFactory(DPM,0).createPoint(new Coordinate(x,y,z)));
473
                        entity.setPt(proj.createPoint(x, y));
474
                        
475
                        //int aux = feature.getID();
476
                        //if (debug) System.out.println("AUXXXXXXXXXXXXXXX = " + aux);
477
                        //DxfEntity block = null;
478
                        //block = feature.getGeometry();
479
                        String marca = (String) blockName;
480
                        Double xx = new Double(x);
481
                        Double yy = new Double(y);
482
                        //Double zz = new Double(z);
483
                        Double xxscale = new Double(scaleFactor.getX());
484
                        Double yyscale = new Double(scaleFactor.getY());
485
                        Double zzscale = new Double(scaleFactor.getZ());
486
                        Double aangle = new Double(rotAngle);
487
                        Object datos[] = new Object[8];
488
                        datos[0] = marca;
489
                        datos[1] = xx;
490
                        datos[2] = yy;
491
                        //datos[3] = zz;
492
                        datos[4] = xxscale;
493
                        datos[5] = yyscale;
494
                        datos[6] = zzscale;
495
                        datos[7] = aangle;
496
                        block.setUserData(datos);
497
                entities.add(b);
498
                }*/
499

    
500
                entity.setPt(proj.createPoint(x, y));
501
                if (addingToBlock == false) {
502
                        entities.add(entity);
503
                } else {
504
                        System.out.println("createInsert(): A?adimos un insert al bloque " + i);
505
                        blk.add(entity);
506
                }
507
        }
508
        public void createSolid(DxfGroupVector grp) throws Exception {
509
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
510
        }
511
        public void createBlock(DxfGroupVector grp) throws Exception {
512
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
513
                blk = new DxfBlock(proj);
514
                
515
                Point3D basePoint = new Point3D();
516
                String blockName = "";
517
                System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + i);
518
                
519
                addingToBlock = true;
520
                System.out.println("createBlock(): A?adimos el bloque " + i + " a la lista de bloques");
521
                blkList.add(i, blk);
522
                
523
                System.out.println("createBlock(): Rellenamos la informacion del bloque " + i);
524
                if (grp.hasCode(1)) {
525
                        blockName = grp.getDataAsString(1);
526
                        blk.setBlkName(blockName);
527
                }
528
                if (grp.hasCode(2)) {
529
                        blockName = grp.getDataAsString(2);
530
                        blk.setBlkName(blockName);
531
                }
532
                if (grp.hasCode(3)) {
533
                        blockName = grp.getDataAsString(3);
534
                        blk.setBlkName(blockName);
535
                }
536
                if (grp.hasCode(10)) {
537
                        basePoint.X = grp.getDataAsDouble(10);
538
                        blk.setBasePoint(basePoint);
539
                }
540
                if (grp.hasCode(20)) {
541
                        basePoint.Y = grp.getDataAsDouble(20);
542
                        blk.setBasePoint(basePoint);
543
                }
544
                if (grp.hasCode(30)) {
545
                        basePoint.Z = grp.getDataAsDouble(30);
546
                        blk.setBasePoint(basePoint);
547
                }
548
                if (grp.hasCode(70)) {
549
                        blk.flags = grp.getDataAsInt(70);                        
550
                }
551
        }
552
        public void endBlk(DxfGroupVector grp) throws Exception {
553
                DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
554
                setAddingToBlock(false);
555
                i = i + 1;
556
        }
557

    
558
        public Projection getProjection() { return proj;}
559

    
560
        /**
561
         * Cambia de proyeccion.
562
         * 
563
         * @param rp
564
         */
565
        public void reProject(ReProjection rp) {
566
                entities.reProject(rp);
567
        }
568
        public DxfEntityList getEntities() { return entities;}
569
        public DxfTable getLayers() { return layers;}
570

    
571
}