root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfEntityMaker.java @ 2669
History | View | Annotate | Download (83.5 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.px.dxf; |
25 |
|
26 |
import org.cresques.cts.ICoordTrans; |
27 |
import org.cresques.cts.IProjection; |
28 |
|
29 |
import org.cresques.geo.Point3D; |
30 |
import org.cresques.geo.Projected; |
31 |
|
32 |
import org.cresques.io.DxfFile; |
33 |
import org.cresques.io.DxfGroup; |
34 |
import org.cresques.io.DxfGroupVector; |
35 |
|
36 |
import org.cresques.px.Extent; |
37 |
import org.cresques.px.IObjList; |
38 |
|
39 |
import java.awt.geom.Point2D; |
40 |
|
41 |
import java.util.Vector; |
42 |
|
43 |
|
44 |
/**
|
45 |
* jmorell: Implementaci?n de la creaci?n de entidades DXF2000.
|
46 |
*/
|
47 |
/**
|
48 |
* @author nacho
|
49 |
*
|
50 |
* TODO To change the template for this generated type comment go to
|
51 |
* Window - Preferences - Java - Code Style - Code Templates
|
52 |
*/
|
53 |
public class DxfEntityMaker implements DxfFile.EntityFactory, Projected { |
54 |
IProjection proj = null;
|
55 |
DxfEntity lastEntity = null;
|
56 |
DxfEntityList entities = null;
|
57 |
Vector blkList = null; |
58 |
DxfBlock blk = null;
|
59 |
DxfTable layers = null;
|
60 |
double bulge = 0.0; |
61 |
double xtruX = 0.0; |
62 |
double xtruY = 0.0; |
63 |
double xtruZ = 1.0; |
64 |
int polylineFlag = 0; |
65 |
Point2D firstPt = new Point2D.Double(); |
66 |
boolean addingToBlock = false; |
67 |
int iterator = 0; |
68 |
|
69 |
// jmorell, 050406: implementaci?n inicial de los ATTRIBS para el piloto ...
|
70 |
private Vector attributes = null; |
71 |
|
72 |
public DxfEntityMaker(IProjection proj) {
|
73 |
this.proj = proj;
|
74 |
layers = new DxfTable();
|
75 |
entities = new DxfEntityList(proj);
|
76 |
blkList = new Vector(); |
77 |
|
78 |
// jmorell, 050406: implementaci?n inicial de los ATTRIBS para el piloto ...
|
79 |
attributes = new Vector(); |
80 |
} |
81 |
|
82 |
public Vector getBlkList() { |
83 |
return blkList;
|
84 |
} |
85 |
|
86 |
public IObjList getObjects() {
|
87 |
return entities;
|
88 |
} |
89 |
|
90 |
public Extent getExtent() {
|
91 |
return entities.getExtent();
|
92 |
} |
93 |
|
94 |
public void setAddingToBlock(boolean a) { |
95 |
addingToBlock = a; |
96 |
} |
97 |
|
98 |
public void createLayer(DxfGroupVector grp) throws Exception { |
99 |
int color = grp.getDataAsInt(62); |
100 |
DxfLayer layer = new DxfLayer(grp.getDataAsString(2), |
101 |
Math.abs(grp.getDataAsInt(62))); |
102 |
|
103 |
if (color < 0) { |
104 |
layer.isOff = true;
|
105 |
} |
106 |
|
107 |
layer.lType = grp.getDataAsString(6);
|
108 |
layer.setFlags(grp.getDataAsInt(70));
|
109 |
|
110 |
// compruebo flags
|
111 |
if ((layer.flags & 0x01) == 0x01) { |
112 |
layer.frozen = true;
|
113 |
} |
114 |
|
115 |
if ((layer.flags & 0x02) == 0x02) { |
116 |
layer.frozen = true;
|
117 |
} |
118 |
|
119 |
System.out.println("LAYER color=" + layer.getColor()); |
120 |
|
121 |
layers.add(layer); |
122 |
} |
123 |
|
124 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
125 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
126 |
DxfPolyline entity = new DxfPolyline(proj, layer);
|
127 |
|
128 |
if (grp.hasCode(5)) { |
129 |
String hexS = grp.getDataAsString(5); |
130 |
Integer hexI = Integer.decode("0x" + hexS); |
131 |
int hexi = hexI.intValue();
|
132 |
entity.setHandle(hexi); |
133 |
} else {
|
134 |
entity.setHandle(entities.size() + 40);
|
135 |
} |
136 |
|
137 |
double x = 0.0; |
138 |
double y = 0.0; |
139 |
double z = 0.0; |
140 |
double thickness = 0; |
141 |
|
142 |
if (grp.hasCode(10)) { |
143 |
x = grp.getDataAsDouble(10);
|
144 |
} |
145 |
|
146 |
if (grp.hasCode(20)) { |
147 |
y = grp.getDataAsDouble(20);
|
148 |
} |
149 |
|
150 |
if (grp.hasCode(30)) { |
151 |
z = grp.getDataAsDouble(30);
|
152 |
} |
153 |
|
154 |
/*if (grp.hasCode(39))
|
155 |
System.out.println("Leer el thickness provoca un error");
|
156 |
thickness = grp.getDataAsDouble(39);*/
|
157 |
if (grp.hasCode(62)) { |
158 |
entity.dxfColor = grp.getDataAsInt(62);
|
159 |
} else {
|
160 |
//entity.dxfColor = 0;
|
161 |
} |
162 |
|
163 |
if (grp.hasCode(66)) { |
164 |
entity.entitiesFollow = grp.getDataAsInt(66);
|
165 |
} |
166 |
|
167 |
if (grp.hasCode(70)) { |
168 |
entity.flags = grp.getDataAsInt(70);
|
169 |
} |
170 |
|
171 |
if (grp.hasCode(210)) { |
172 |
xtruX = grp.getDataAsDouble(210);
|
173 |
} |
174 |
|
175 |
if (grp.hasCode(220)) { |
176 |
xtruY = grp.getDataAsDouble(220);
|
177 |
} |
178 |
|
179 |
if (grp.hasCode(230)) { |
180 |
xtruZ = grp.getDataAsDouble(230);
|
181 |
} |
182 |
|
183 |
if ((entity.flags & 0x01) == 0x01) { |
184 |
entity.closed = true;
|
185 |
} |
186 |
|
187 |
lastEntity = entity; |
188 |
} |
189 |
|
190 |
public void endSeq() throws Exception { |
191 |
if (lastEntity instanceof DxfPolyline) { |
192 |
DxfPolyline polyline = (DxfPolyline) lastEntity; |
193 |
|
194 |
if (polyline.closed) {
|
195 |
((DxfPolyline) lastEntity).add(firstPt); |
196 |
|
197 |
if (bulge > 0) { |
198 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
199 |
|
200 |
if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
201 |
2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
202 |
1))).getX()) &&
|
203 |
(((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
204 |
2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
205 |
1))).getY())) {
|
206 |
// no se construye el arco
|
207 |
} else {
|
208 |
Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
209 |
2)),
|
210 |
(Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
211 |
1)),
|
212 |
bulge); |
213 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1);
|
214 |
|
215 |
for (int i = 0; i < arc.size(); i++) { |
216 |
Point2D pt = proj.createPoint(((Point2D) arc.get(i)).getX(), |
217 |
((Point2D) arc.get(i)).getY());
|
218 |
((DxfPolyline) lastEntity).add(pt); |
219 |
|
220 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
221 |
firstPt = pt; |
222 |
} |
223 |
} |
224 |
} |
225 |
|
226 |
bulge = 0.0;
|
227 |
} else if (bulge < 0) { |
228 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
229 |
|
230 |
if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
231 |
2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
232 |
1))).getX()) &&
|
233 |
(((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
234 |
2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
235 |
1))).getY())) {
|
236 |
// no se construye el arco
|
237 |
} else {
|
238 |
Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
239 |
2)),
|
240 |
(Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
241 |
1)),
|
242 |
bulge); |
243 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1);
|
244 |
|
245 |
for (int i = arc.size() - 1; i >= 0; i--) { |
246 |
Point2D pt = proj.createPoint(((Point2D) arc.get(i)).getX(), |
247 |
((Point2D) arc.get(i)).getY());
|
248 |
((DxfPolyline) lastEntity).add(pt); |
249 |
|
250 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
251 |
firstPt = pt; |
252 |
} |
253 |
} |
254 |
} |
255 |
|
256 |
bulge = 0.0;
|
257 |
} |
258 |
} |
259 |
|
260 |
// 050315, jmorell: Para leer Polylines estas tb deben tener vector de bulges.
|
261 |
for (int i = 0; i < ((DxfPolyline) lastEntity).pts.size(); i++) { |
262 |
// jmorell, 050405: intentando leer DxfPolylines con bulges para el
|
263 |
// piloto ...
|
264 |
//polyline.addBulge(new Double(0));
|
265 |
((DxfPolyline) lastEntity).addBulge(new Double(0)); |
266 |
} |
267 |
|
268 |
//System.out.println("DxfEntityMaker.endSeq(): ((DxfPolyline)lastEntity).getBulges().size() = " + ((DxfPolyline)lastEntity).getBulges().size());
|
269 |
//((DxfPolyline)lastEntity).addBulge(new Double(bulge));
|
270 |
//lastEntity.setHandle(entities.size()+40);
|
271 |
if (addingToBlock == false) { |
272 |
//System.out.println("createPolyline: A?adimos una polilinea a la lista de entidades");
|
273 |
entities.add(lastEntity); |
274 |
} else {
|
275 |
//System.out.println("createPolyline: A?adimos una polilinea al bloque " + iterator);
|
276 |
blk.add(lastEntity); |
277 |
|
278 |
//System.out.println("PLINE color="+polyline.getColor());
|
279 |
} |
280 |
|
281 |
lastEntity = null;
|
282 |
} else if (lastEntity instanceof DxfInsert) { |
283 |
// Se trata de un SEQEND despues de un ATTRIB
|
284 |
gestionaInsert((DxfInsert) lastEntity, lastEntity.getLayer()); |
285 |
|
286 |
if (addingToBlock == false) { |
287 |
entities.add(lastEntity); |
288 |
} else {
|
289 |
blk.add(lastEntity); |
290 |
} |
291 |
|
292 |
lastEntity = null;
|
293 |
} else {
|
294 |
// Caso no contemplado
|
295 |
} |
296 |
|
297 |
xtruX = 0.0;
|
298 |
xtruY = 0.0;
|
299 |
xtruZ = 1.0;
|
300 |
bulge = 0.0;
|
301 |
} |
302 |
|
303 |
public void addVertex(DxfGroupVector grp) throws Exception { |
304 |
double x = 0.0; |
305 |
double y = 0.0; |
306 |
double z = 0.0; |
307 |
int flags = 0; |
308 |
x = grp.getDataAsDouble(10);
|
309 |
y = grp.getDataAsDouble(20);
|
310 |
|
311 |
if (grp.hasCode(30)) { |
312 |
z = grp.getDataAsDouble(30);
|
313 |
} |
314 |
|
315 |
if (grp.hasCode(70)) { |
316 |
flags = grp.getDataAsInt(70);
|
317 |
} |
318 |
|
319 |
//bulge = 0.0;
|
320 |
if (bulge == 0.0) { |
321 |
if (grp.hasCode(42)) { |
322 |
bulge = grp.getDataAsDouble(42);
|
323 |
|
324 |
//bulge = 0.0;
|
325 |
} else {
|
326 |
bulge = 0.0;
|
327 |
} |
328 |
|
329 |
Point3D point_in = new Point3D(x, y, z);
|
330 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
331 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
332 |
|
333 |
if (((flags & 0x80) == 0x80) && ((flags & 0x40) == 0)) { |
334 |
int[] face = { 0, 0, 0, 0 }; |
335 |
face[0] = grp.getDataAsInt(71); |
336 |
face[1] = grp.getDataAsInt(72); |
337 |
face[2] = grp.getDataAsInt(73); |
338 |
face[3] = grp.getDataAsInt(74); |
339 |
((DxfPolyline) lastEntity).addFace(face); |
340 |
} else {
|
341 |
x = point_out.getX(); |
342 |
y = point_out.getY(); |
343 |
|
344 |
Point2D pt = proj.createPoint(x, y);
|
345 |
((DxfPolyline) lastEntity).add(pt); |
346 |
|
347 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
348 |
firstPt = pt; |
349 |
} |
350 |
} |
351 |
} else if (bulge > 0.0) { |
352 |
double bulge_aux = 0.0; |
353 |
|
354 |
if (grp.hasCode(42)) { |
355 |
bulge_aux = grp.getDataAsDouble(42);
|
356 |
} else {
|
357 |
bulge_aux = 0.0;
|
358 |
} |
359 |
|
360 |
Point3D point_in = new Point3D(x, y, z);
|
361 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
362 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
363 |
x = point_out.getX(); |
364 |
y = point_out.getY(); |
365 |
|
366 |
Point2D pt = proj.createPoint(x, y);
|
367 |
((DxfPolyline) lastEntity).add(pt); |
368 |
|
369 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
370 |
firstPt = pt; |
371 |
} |
372 |
|
373 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
374 |
|
375 |
if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
376 |
1))).getX()) &&
|
377 |
(((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
378 |
1))).getY())) {
|
379 |
// no se construye el arco
|
380 |
} else {
|
381 |
Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
382 |
2)),
|
383 |
(Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
384 |
1)),
|
385 |
bulge); |
386 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1);
|
387 |
|
388 |
for (int i = 0; i < arc.size(); i++) { |
389 |
pt = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
390 |
((Point2D) arc.get(i)).getY());
|
391 |
((DxfPolyline) lastEntity).add(pt); |
392 |
|
393 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
394 |
firstPt = pt; |
395 |
} |
396 |
} |
397 |
} |
398 |
|
399 |
bulge = bulge_aux; |
400 |
} else { //si el bulge es menor que cero. |
401 |
|
402 |
double bulge_aux = 0.0; |
403 |
|
404 |
if (grp.hasCode(42)) { |
405 |
bulge_aux = grp.getDataAsDouble(42); // * (-1.0); |
406 |
} else {
|
407 |
bulge_aux = 0.0;
|
408 |
} |
409 |
|
410 |
Point3D point_in = new Point3D(x, y, z);
|
411 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
412 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
413 |
x = point_out.getX(); |
414 |
y = point_out.getY(); |
415 |
|
416 |
Point2D pt = proj.createPoint(x, y);
|
417 |
((DxfPolyline) lastEntity).add(pt); |
418 |
|
419 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
420 |
firstPt = pt; |
421 |
} |
422 |
|
423 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
424 |
|
425 |
if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
426 |
1))).getX()) &&
|
427 |
(((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
428 |
1))).getY())) {
|
429 |
// no se construye el arco
|
430 |
} else {
|
431 |
Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - |
432 |
2)),
|
433 |
(Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
|
434 |
1)),
|
435 |
bulge); |
436 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1);
|
437 |
|
438 |
for (int i = arc.size() - 1; i >= 0; i--) { |
439 |
pt = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
440 |
((Point2D) arc.get(i)).getY());
|
441 |
((DxfPolyline) lastEntity).add(pt); |
442 |
|
443 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
444 |
firstPt = pt; |
445 |
} |
446 |
} |
447 |
} |
448 |
|
449 |
bulge = bulge_aux; |
450 |
} |
451 |
|
452 |
/*if (grp.hasCode(5)) {
|
453 |
String hexS = grp.getDataAsString(5);
|
454 |
Integer hexI = Integer.decode("0x" + hexS);
|
455 |
int hexi = hexI.intValue();
|
456 |
lastEntity.setHandle(hexi);
|
457 |
} else {
|
458 |
lastEntity.setHandle(entities.size()+40);
|
459 |
}*/
|
460 |
} |
461 |
|
462 |
public void createLwPolyline(DxfGroupVector grp) throws Exception { |
463 |
double x = 0.0; |
464 |
double y = 0.0; |
465 |
double elev = 0.0; |
466 |
DxfGroup g = null;
|
467 |
double extx = 0.0; |
468 |
double exty = 0.0; |
469 |
double extz = 1.0; |
470 |
|
471 |
if (grp.hasCode(38)) { |
472 |
elev = grp.getDataAsDouble(38);
|
473 |
} |
474 |
|
475 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
476 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
477 |
|
478 |
if (grp.hasCode(5)) { |
479 |
String hexS = grp.getDataAsString(5); |
480 |
Integer hexI = Integer.decode("0x" + hexS); |
481 |
int hexi = hexI.intValue();
|
482 |
entity.setHandle(hexi); |
483 |
} else {
|
484 |
entity.setHandle(entities.size() + 40);
|
485 |
} |
486 |
|
487 |
if (grp.hasCode(210)) { |
488 |
extx = grp.getDataAsDouble(210);
|
489 |
} |
490 |
|
491 |
if (grp.hasCode(220)) { |
492 |
exty = grp.getDataAsDouble(220);
|
493 |
} |
494 |
|
495 |
if (grp.hasCode(230)) { |
496 |
extz = grp.getDataAsDouble(230);
|
497 |
} |
498 |
|
499 |
double bulge = 0; |
500 |
boolean isNewCoord = false; |
501 |
|
502 |
for (int i = 0; i < grp.size(); i++) { |
503 |
bulge = 0;
|
504 |
isNewCoord = false;
|
505 |
g = (DxfGroup) grp.get(i); |
506 |
|
507 |
if (g.getCode() == 10) { |
508 |
x = ((Double) g.getData()).doubleValue();
|
509 |
} else if (g.getCode() == 20) { |
510 |
y = ((Double) g.getData()).doubleValue();
|
511 |
|
512 |
// A?adiendo extrusion a LwPolyline ...
|
513 |
Point3D point_in1 = new Point3D(x, y, elev);
|
514 |
Point3D xtru = new Point3D(extx, exty, extz);
|
515 |
Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
516 |
x = point_out1.getX(); |
517 |
y = point_out1.getY(); |
518 |
elev = point_out1.getZ(); |
519 |
|
520 |
//
|
521 |
//if (y <= 1.0) throw new Exception("Y == "+y);
|
522 |
entity.add(proj.createPoint(x, y)); |
523 |
entity.addBulge(new Double(0)); |
524 |
x = 0.0;
|
525 |
y = 0.0;
|
526 |
isNewCoord = true;
|
527 |
} else if (g.getCode() == 42) { |
528 |
//entity.addBulge((Double)g.getData());
|
529 |
entity.getBulges().remove(entity.getBulges().size() - 1);
|
530 |
entity.getBulges().add((Double) g.getData());
|
531 |
bulge = ((Double) g.getData()).doubleValue();
|
532 |
} |
533 |
|
534 |
/*if (bulge == 0 && isNewCoord) {
|
535 |
entity.addBulge(new Double(0));
|
536 |
}*/
|
537 |
} |
538 |
|
539 |
//System.out.println("entity.getPts().size() = " + entity.getPts().size());
|
540 |
//System.out.println("entity.getBulges().size() = " + entity.getBulges().size());
|
541 |
if (grp.hasCode(62)) { |
542 |
entity.dxfColor = grp.getDataAsInt(62);
|
543 |
} else {
|
544 |
//entity.dxfColor = 0;
|
545 |
} |
546 |
|
547 |
if (grp.hasCode(70)) { |
548 |
entity.flags = grp.getDataAsInt(70);
|
549 |
|
550 |
//System.out.println("entity.flags = " + entity.flags);
|
551 |
} |
552 |
|
553 |
if ((entity.flags & 0x01) == 0x01) { |
554 |
entity.closed = true;
|
555 |
} |
556 |
|
557 |
if (addingToBlock == false) { |
558 |
entities.add(entity); |
559 |
} else {
|
560 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
561 |
blk.add(entity); |
562 |
} |
563 |
} |
564 |
|
565 |
public void createLine(DxfGroupVector grp) throws Exception { |
566 |
double x = 0.0; |
567 |
double y = 0.0; |
568 |
double z1 = 0.0; |
569 |
double z2 = 0.0; |
570 |
DxfGroup g = null;
|
571 |
Point2D pt1 = null; |
572 |
Point2D pt2 = null; |
573 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
574 |
double extx = 0.0; |
575 |
double exty = 0.0; |
576 |
double extz = 1.0; |
577 |
|
578 |
x = grp.getDataAsDouble(10);
|
579 |
y = grp.getDataAsDouble(20);
|
580 |
|
581 |
if (grp.hasCode(30)) { |
582 |
z1 = grp.getDataAsDouble(30);
|
583 |
} |
584 |
|
585 |
pt1 = proj.createPoint(x, y); |
586 |
x = grp.getDataAsDouble(11);
|
587 |
y = grp.getDataAsDouble(21);
|
588 |
|
589 |
if (grp.hasCode(31)) { |
590 |
z2 = grp.getDataAsDouble(31);
|
591 |
} |
592 |
|
593 |
pt2 = proj.createPoint(x, y); |
594 |
|
595 |
if (grp.hasCode(210)) { |
596 |
extx = grp.getDataAsDouble(210);
|
597 |
} |
598 |
|
599 |
if (grp.hasCode(220)) { |
600 |
exty = grp.getDataAsInt(220);
|
601 |
} |
602 |
|
603 |
if (grp.hasCode(230)) { |
604 |
extz = grp.getDataAsInt(230);
|
605 |
} |
606 |
|
607 |
Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
608 |
Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
609 |
Point3D xtru = new Point3D(extx, exty, extz);
|
610 |
Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
611 |
Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
612 |
pt1.setLocation(point_out1); |
613 |
pt2.setLocation(point_out2); |
614 |
|
615 |
DxfLine entity = new DxfLine(proj, layer, pt1, pt2);
|
616 |
|
617 |
if (grp.hasCode(5)) { |
618 |
String hexS = grp.getDataAsString(5); |
619 |
Integer hexI = Integer.decode("0x" + hexS); |
620 |
int hexi = hexI.intValue();
|
621 |
entity.setHandle(hexi); |
622 |
} else {
|
623 |
entity.setHandle(entities.size() + 40);
|
624 |
} |
625 |
|
626 |
if (grp.hasCode(62)) { |
627 |
entity.dxfColor = grp.getDataAsInt(62);
|
628 |
} else {
|
629 |
//entity.dxfColor = 0;
|
630 |
} |
631 |
|
632 |
if (addingToBlock == false) { |
633 |
//System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
634 |
entities.add(entity); |
635 |
} else {
|
636 |
//System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
637 |
blk.add(entity); |
638 |
} |
639 |
} |
640 |
|
641 |
public void createText(DxfGroupVector grp) throws Exception { |
642 |
double x = 0.0; |
643 |
double y = 0.0; |
644 |
double z = 0.0; |
645 |
double h = 0.0; |
646 |
double rot = 0.0; |
647 |
DxfGroup g = null;
|
648 |
|
649 |
//OJO! El segundo punto es opcional ...
|
650 |
Point2D pt1 = null; |
651 |
|
652 |
//OJO! El segundo punto es opcional ...
|
653 |
Point2D pt2 = null; |
654 |
String txt = null; |
655 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
656 |
|
657 |
txt = grp.getDataAsString(1);
|
658 |
|
659 |
DxfText entity = new DxfText(proj, layer, txt);
|
660 |
double extx = 0.0; |
661 |
double exty = 0.0; |
662 |
double extz = 1.0; |
663 |
|
664 |
x = grp.getDataAsDouble(10);
|
665 |
y = grp.getDataAsDouble(20);
|
666 |
z = grp.getDataAsDouble(30);
|
667 |
|
668 |
if (grp.hasCode(210)) { |
669 |
extx = grp.getDataAsDouble(210);
|
670 |
} |
671 |
|
672 |
if (grp.hasCode(220)) { |
673 |
exty = grp.getDataAsDouble(220);
|
674 |
} |
675 |
|
676 |
if (grp.hasCode(230)) { |
677 |
extz = grp.getDataAsDouble(230);
|
678 |
} |
679 |
|
680 |
Point3D point_in = new Point3D(x, y, z);
|
681 |
Point3D xtru = new Point3D(extx, exty, extz);
|
682 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
683 |
x = point_out.getX(); |
684 |
y = point_out.getY(); |
685 |
z = point_out.getZ(); |
686 |
|
687 |
entity.setPt(proj.createPoint(x, y)); |
688 |
|
689 |
//entity.setPt1(proj.createPoint(x, y));
|
690 |
if (grp.hasCode(11)) { |
691 |
entity.setTwoPointsFlag(true);
|
692 |
entity.setPt1(proj.createPoint(entity.getPt().getX(), |
693 |
entity.getPt().getY())); |
694 |
x = grp.getDataAsDouble(11);
|
695 |
y = grp.getDataAsDouble(21);
|
696 |
z = grp.getDataAsDouble(31);
|
697 |
|
698 |
point_in = new Point3D(x, y, z);
|
699 |
point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
700 |
x = point_out.getX(); |
701 |
y = point_out.getY(); |
702 |
z = point_out.getZ(); |
703 |
|
704 |
entity.setPt2(proj.createPoint(x, y)); |
705 |
} |
706 |
|
707 |
entity.setHeight(grp.getDataAsDouble(40));
|
708 |
|
709 |
if (grp.hasCode(50)) { |
710 |
entity.setRotation(grp.getDataAsDouble(50));
|
711 |
|
712 |
//System.out.println("AAAAAA: entity.getRotation = " + entity.getRotation());
|
713 |
} |
714 |
|
715 |
if (grp.hasCode(62)) { |
716 |
entity.dxfColor = grp.getDataAsInt(62);
|
717 |
} else {
|
718 |
//entity.dxfColor = 0;
|
719 |
} |
720 |
|
721 |
if (grp.hasCode(72)) { |
722 |
entity.align = grp.getDataAsInt(72);
|
723 |
} |
724 |
|
725 |
if (addingToBlock == false) { |
726 |
entities.add(entity); |
727 |
} else {
|
728 |
//System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
729 |
blk.add(entity); |
730 |
} |
731 |
} |
732 |
|
733 |
/* (non-Javadoc)
|
734 |
* @see org.cresques.io.DxfFile.EntityFactory#createMText(org.cresques.io.DxfGroupVector)
|
735 |
*/
|
736 |
public void createMText(DxfGroupVector v) throws Exception { |
737 |
// TODO Auto-generated method stub
|
738 |
} |
739 |
|
740 |
public void createPoint(DxfGroupVector grp) throws Exception { |
741 |
double x = 0.0; //, h= 0.0, rot= 0.0; |
742 |
double y = 0.0; //, h= 0.0, rot= 0.0; |
743 |
double z = 0.0; //, h= 0.0, rot= 0.0; |
744 |
DxfGroup g = null;
|
745 |
Point2D pt = null; |
746 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
747 |
double extx = 0.0; |
748 |
double exty = 0.0; |
749 |
double extz = 1.0; |
750 |
|
751 |
DxfPoint entity = new DxfPoint(proj, layer);
|
752 |
|
753 |
if (grp.hasCode(5)) { |
754 |
String hexS = grp.getDataAsString(5); |
755 |
Integer hexI = Integer.decode("0x" + hexS); |
756 |
int hexi = hexI.intValue();
|
757 |
entity.setHandle(hexi); |
758 |
} else {
|
759 |
entity.setHandle(entities.size() + 40);
|
760 |
} |
761 |
|
762 |
x = grp.getDataAsDouble(10);
|
763 |
y = grp.getDataAsDouble(20);
|
764 |
|
765 |
if (grp.hasCode(30)) { |
766 |
z = grp.getDataAsDouble(30);
|
767 |
} |
768 |
|
769 |
if (grp.hasCode(62)) { |
770 |
entity.dxfColor = grp.getDataAsInt(62);
|
771 |
} else {
|
772 |
//entity.dxfColor = 0;
|
773 |
} |
774 |
|
775 |
if (grp.hasCode(210)) { |
776 |
extx = grp.getDataAsDouble(210);
|
777 |
} |
778 |
|
779 |
if (grp.hasCode(220)) { |
780 |
exty = grp.getDataAsInt(220);
|
781 |
} |
782 |
|
783 |
if (grp.hasCode(230)) { |
784 |
extz = grp.getDataAsInt(230);
|
785 |
} |
786 |
|
787 |
Point3D point_in = new Point3D(x, y, z);
|
788 |
Point3D xtru = new Point3D(extx, exty, extz);
|
789 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
790 |
x = point_out.getX(); |
791 |
y = point_out.getY(); |
792 |
entity.setPt(proj.createPoint(x, y)); |
793 |
|
794 |
if (addingToBlock == false) { |
795 |
entities.add(entity); |
796 |
} else {
|
797 |
//System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
|
798 |
blk.add(entity); |
799 |
} |
800 |
} |
801 |
|
802 |
public void createCircle(DxfGroupVector grp) throws Exception { |
803 |
//System.out.println("Encontramos un Circle.");
|
804 |
double x = 0.0; |
805 |
|
806 |
//System.out.println("Encontramos un Circle.");
|
807 |
double y = 0.0; |
808 |
|
809 |
//System.out.println("Encontramos un Circle.");
|
810 |
double z = 0.0; |
811 |
double r = 0.0; |
812 |
DxfGroup g = null;
|
813 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
814 |
double extx = 0.0; |
815 |
double exty = 0.0; |
816 |
double extz = 1.0; |
817 |
|
818 |
x = grp.getDataAsDouble(10);
|
819 |
y = grp.getDataAsDouble(20);
|
820 |
|
821 |
if (grp.hasCode(30)) { |
822 |
z = grp.getDataAsDouble(30);
|
823 |
} |
824 |
|
825 |
if (grp.hasCode(40)) { |
826 |
r = grp.getDataAsDouble(40);
|
827 |
} |
828 |
|
829 |
if (grp.hasCode(210)) { |
830 |
extx = grp.getDataAsDouble(210);
|
831 |
} |
832 |
|
833 |
if (grp.hasCode(220)) { |
834 |
exty = grp.getDataAsDouble(220);
|
835 |
} |
836 |
|
837 |
if (grp.hasCode(230)) { |
838 |
extz = grp.getDataAsDouble(230);
|
839 |
} |
840 |
|
841 |
Point3D point_in = new Point3D(x, y, z);
|
842 |
Point3D xtru = new Point3D(extx, exty, extz);
|
843 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
844 |
x = point_out.getX(); |
845 |
y = point_out.getY(); |
846 |
|
847 |
Point2D center = proj.createPoint(x, y);
|
848 |
Point2D[] pts = new Point2D[360]; |
849 |
int angulo = 0; |
850 |
|
851 |
for (angulo = 0; angulo < 360; angulo++) { |
852 |
pts[angulo] = new Point2D.Double(center.getX(), center.getY()); |
853 |
pts[angulo].setLocation(pts[angulo].getX() + |
854 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
855 |
pts[angulo].getY() + |
856 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0))); |
857 |
|
858 |
if (pts.length == 1) { |
859 |
firstPt = pts[angulo]; |
860 |
} |
861 |
} |
862 |
|
863 |
DxfCircle entity = new DxfCircle(proj, layer, pts);
|
864 |
|
865 |
if (grp.hasCode(5)) { |
866 |
String hexS = grp.getDataAsString(5); |
867 |
Integer hexI = Integer.decode("0x" + hexS); |
868 |
int hexi = hexI.intValue();
|
869 |
entity.setHandle(hexi); |
870 |
} else {
|
871 |
entity.setHandle(entities.size() + 40);
|
872 |
} |
873 |
|
874 |
entity.setCenter(new Point2D.Double(x, y)); |
875 |
|
876 |
//System.out.println("Y le metemos el centro.");
|
877 |
entity.setRadius(r); |
878 |
|
879 |
if (grp.hasCode(62)) { |
880 |
entity.dxfColor = grp.getDataAsInt(62);
|
881 |
} else {
|
882 |
//entity.dxfColor = 0;
|
883 |
} |
884 |
|
885 |
if (addingToBlock == false) { |
886 |
//System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
887 |
entities.add(entity); |
888 |
} else {
|
889 |
//System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
890 |
blk.add(entity); |
891 |
} |
892 |
} |
893 |
|
894 |
public void createEllipse(DxfGroupVector grp) throws Exception { |
895 |
double incX = 0.0; |
896 |
double incY = 0.0; |
897 |
double incZ = 0.0; |
898 |
double xc = 0.0; |
899 |
double yc = 0.0; |
900 |
double zc = 0.0; |
901 |
double mMAxisRatio = 0.0; |
902 |
DxfGroup g = null;
|
903 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
904 |
double extx = 0.0; |
905 |
double exty = 0.0; |
906 |
double extz = 1.0; |
907 |
|
908 |
xc = grp.getDataAsDouble(10);
|
909 |
yc = grp.getDataAsDouble(20);
|
910 |
|
911 |
if (grp.hasCode(30)) { |
912 |
zc = grp.getDataAsDouble(30);
|
913 |
} |
914 |
|
915 |
if (grp.hasCode(210)) { |
916 |
extx = grp.getDataAsDouble(210);
|
917 |
} |
918 |
|
919 |
if (grp.hasCode(220)) { |
920 |
exty = grp.getDataAsDouble(220);
|
921 |
} |
922 |
|
923 |
if (grp.hasCode(230)) { |
924 |
extz = grp.getDataAsDouble(230);
|
925 |
} |
926 |
|
927 |
Point3D point_in = new Point3D(xc, yc, zc);
|
928 |
Point3D xtru = new Point3D(extx, exty, extz);
|
929 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
930 |
xc = point_out.getX(); |
931 |
yc = point_out.getY(); |
932 |
zc = point_out.getZ(); |
933 |
|
934 |
incX = grp.getDataAsDouble(11);
|
935 |
incY = grp.getDataAsDouble(21);
|
936 |
|
937 |
if (grp.hasCode(31)) { |
938 |
incZ = grp.getDataAsDouble(31);
|
939 |
} |
940 |
|
941 |
if (grp.hasCode(40)) { |
942 |
mMAxisRatio = grp.getDataAsDouble(40);
|
943 |
} |
944 |
|
945 |
Point2D pt2 = new Point2D.Double(xc + incX, yc + incY); |
946 |
Point2D pt1 = new Point2D.Double(xc - incX, yc - incY); |
947 |
double majorAxisLength = pt1.distance(pt2);
|
948 |
double minorAxisLength = majorAxisLength * mMAxisRatio;
|
949 |
|
950 |
DxfEllipse entity = new DxfEllipse(proj, layer, pt1, pt2,
|
951 |
minorAxisLength); |
952 |
|
953 |
if (grp.hasCode(5)) { |
954 |
String hexS = grp.getDataAsString(5); |
955 |
Integer hexI = Integer.decode("0x" + hexS); |
956 |
int hexi = hexI.intValue();
|
957 |
entity.setHandle(hexi); |
958 |
} else {
|
959 |
entity.setHandle(entities.size() + 40);
|
960 |
} |
961 |
|
962 |
if (grp.hasCode(62)) { |
963 |
entity.dxfColor = grp.getDataAsInt(62);
|
964 |
} else {
|
965 |
//entity.dxfColor = 0;
|
966 |
} |
967 |
|
968 |
if (addingToBlock == false) { |
969 |
//System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
970 |
entities.add(entity); |
971 |
} else {
|
972 |
//System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
973 |
blk.add(entity); |
974 |
} |
975 |
} |
976 |
|
977 |
public void createArc(DxfGroupVector grp) throws Exception { |
978 |
double x = 0.0; |
979 |
double y = 0.0; |
980 |
double z = 0.0; |
981 |
double r = 0.0; |
982 |
double empieza = 0.0; |
983 |
double acaba = 0.0; |
984 |
DxfGroup g = null;
|
985 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
986 |
double extx = 0.0; |
987 |
double exty = 0.0; |
988 |
double extz = 1.0; |
989 |
|
990 |
x = grp.getDataAsDouble(10);
|
991 |
y = grp.getDataAsDouble(20);
|
992 |
|
993 |
if (grp.hasCode(30)) { |
994 |
z = grp.getDataAsDouble(30);
|
995 |
} |
996 |
|
997 |
if (grp.hasCode(40)) { |
998 |
r = grp.getDataAsDouble(40);
|
999 |
} |
1000 |
|
1001 |
if (grp.hasCode(50)) { |
1002 |
empieza = grp.getDataAsDouble(50);
|
1003 |
} |
1004 |
|
1005 |
if (grp.hasCode(51)) { |
1006 |
acaba = grp.getDataAsDouble(51);
|
1007 |
} |
1008 |
|
1009 |
if (grp.hasCode(210)) { |
1010 |
extx = grp.getDataAsDouble(210);
|
1011 |
} |
1012 |
|
1013 |
if (grp.hasCode(220)) { |
1014 |
exty = grp.getDataAsDouble(220);
|
1015 |
} |
1016 |
|
1017 |
if (grp.hasCode(230)) { |
1018 |
extz = grp.getDataAsDouble(230);
|
1019 |
} |
1020 |
|
1021 |
Point3D point_in = new Point3D(x, y, z);
|
1022 |
Point3D xtru = new Point3D(extx, exty, extz);
|
1023 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
1024 |
x = point_out.getX(); |
1025 |
y = point_out.getY(); |
1026 |
|
1027 |
Point2D center = proj.createPoint(x, y);
|
1028 |
|
1029 |
//System.out.println("empieza = " + empieza + ", acaba = " + acaba);
|
1030 |
int iempieza = (int) empieza; |
1031 |
int iacaba = (int) acaba; |
1032 |
|
1033 |
//System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
|
1034 |
double angulo = 0; |
1035 |
Point2D[] pts = null; |
1036 |
|
1037 |
if (empieza <= acaba) {
|
1038 |
pts = new Point2D[(iacaba - iempieza) + 2]; |
1039 |
angulo = empieza; |
1040 |
pts[0] = new Point2D.Double(center.getX() + |
1041 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1042 |
center.getY() + |
1043 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1044 |
|
1045 |
for (int i = 1; i <= ((iacaba - iempieza) + 1); i++) { |
1046 |
angulo = (double) (iempieza + i);
|
1047 |
pts[i] = new Point2D.Double(center.getX() + |
1048 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1049 |
center.getY() + |
1050 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1051 |
} |
1052 |
|
1053 |
angulo = acaba; |
1054 |
pts[(iacaba - iempieza) + 1] = new Point2D.Double(center.getX() + |
1055 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1056 |
center.getY() + |
1057 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1058 |
} else {
|
1059 |
pts = new Point2D[(360 - iempieza) + iacaba + 2]; |
1060 |
angulo = empieza; |
1061 |
|
1062 |
//System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
|
1063 |
pts[0] = new Point2D.Double(center.getX() + |
1064 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1065 |
center.getY() + |
1066 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1067 |
|
1068 |
for (int i = 1; i <= (360 - iempieza); i++) { |
1069 |
angulo = (double) (iempieza + i);
|
1070 |
pts[i] = new Point2D.Double(center.getX() + |
1071 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1072 |
center.getY() + |
1073 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1074 |
} |
1075 |
|
1076 |
for (int i = (360 - iempieza) + 1; |
1077 |
i <= ((360 - iempieza) + iacaba); i++) {
|
1078 |
angulo = (double) (i - (360 - iempieza)); |
1079 |
pts[i] = new Point2D.Double(center.getX() + |
1080 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1081 |
center.getY() + |
1082 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1083 |
} |
1084 |
|
1085 |
angulo = acaba; |
1086 |
pts[(360 - iempieza) + iacaba + 1] = new Point2D.Double(center.getX() + |
1087 |
(r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
1088 |
center.getY() + |
1089 |
(r * Math.sin((angulo * Math.PI) / (double) 180.0))); |
1090 |
} |
1091 |
|
1092 |
DxfArc entity = new DxfArc(proj, layer, pts);
|
1093 |
|
1094 |
if (grp.hasCode(5)) { |
1095 |
String hexS = grp.getDataAsString(5); |
1096 |
Integer hexI = Integer.decode("0x" + hexS); |
1097 |
int hexi = hexI.intValue();
|
1098 |
entity.setHandle(hexi); |
1099 |
} else {
|
1100 |
entity.setHandle(entities.size() + 40);
|
1101 |
} |
1102 |
|
1103 |
// 050223, jmorell: Establecimiento de los par?metros del arco.
|
1104 |
//System.out.println("DxfEntityMaker.createArc(): pts.length = " + pts.length);
|
1105 |
entity.setCentralPoint(pts[(pts.length) / 2]);
|
1106 |
|
1107 |
//System.out.println("DxfEntityMaker.createArc(): (pts.length)/2 = " + (pts.length/2));
|
1108 |
entity.setInit(pts[0]);
|
1109 |
entity.setEnd(pts[pts.length - 1]);
|
1110 |
|
1111 |
//System.out.println("DxfEntityMaker.createArc(): (pts.length)-1 = " + (pts.length-1));
|
1112 |
entity.setCenter(center); |
1113 |
entity.setRadius(r); |
1114 |
entity.setInitAngle(empieza); |
1115 |
|
1116 |
//System.out.println("DxfEntityMaker.createArc(): empieza = " + empieza);
|
1117 |
entity.setEndAngle(acaba); |
1118 |
|
1119 |
//System.out.println("DxfEntityMaker.createArc(): acaba = " + acaba);
|
1120 |
if (grp.hasCode(62)) { |
1121 |
entity.dxfColor = grp.getDataAsInt(62);
|
1122 |
} else {
|
1123 |
//entity.dxfColor = 0;
|
1124 |
} |
1125 |
|
1126 |
//System.out.println("createArc(): A?adimos un arco al bloque");
|
1127 |
if (addingToBlock == false) { |
1128 |
entities.add(entity); |
1129 |
} else {
|
1130 |
//System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
|
1131 |
blk.add(entity); |
1132 |
} |
1133 |
} |
1134 |
|
1135 |
/**
|
1136 |
* TODO Detectados fallos en las rotaciones de bloques. Hoja 72231.
|
1137 |
* Detectado en los bloques correspondientes a campos de futbol,
|
1138 |
* de tipo solid.
|
1139 |
*/
|
1140 |
public void createInsert(DxfGroupVector grp) throws Exception { |
1141 |
double x = 0.0; |
1142 |
double y = 0.0; |
1143 |
double z = 0.0; |
1144 |
DxfGroup g = null;
|
1145 |
Point2D pt = new Point2D.Double(0.0, 0.0); |
1146 |
Point2D scaleFactor = new Point2D.Double(1.0, 1.0); |
1147 |
double rotAngle = 0.0; |
1148 |
String blockName = ""; |
1149 |
double extx = 0.0; |
1150 |
double exty = 0.0; |
1151 |
double extz = 1.0; |
1152 |
|
1153 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1154 |
|
1155 |
DxfInsert entity = new DxfInsert(proj, layer);
|
1156 |
DxfPoint secondEntity = new DxfPoint(proj, layer);
|
1157 |
|
1158 |
// jmorell, 050406: implementaci?n inicial de los ATTRIBS para el piloto ...
|
1159 |
int attributesFollowFlag = 0; |
1160 |
|
1161 |
if (grp.hasCode(2)) { |
1162 |
blockName = grp.getDataAsString(2);
|
1163 |
entity.setBlockName(blockName); |
1164 |
} |
1165 |
|
1166 |
if (grp.hasCode(10)) { |
1167 |
x = grp.getDataAsDouble(10);
|
1168 |
} |
1169 |
|
1170 |
if (grp.hasCode(20)) { |
1171 |
y = grp.getDataAsDouble(20);
|
1172 |
} |
1173 |
|
1174 |
if (grp.hasCode(30)) { |
1175 |
z = grp.getDataAsDouble(30);
|
1176 |
} |
1177 |
|
1178 |
if (grp.hasCode(41)) { |
1179 |
scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
|
1180 |
entity.setScaleFactor(scaleFactor); |
1181 |
} else {
|
1182 |
entity.setScaleFactor(scaleFactor); |
1183 |
} |
1184 |
|
1185 |
if (grp.hasCode(42)) { |
1186 |
scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
|
1187 |
entity.setScaleFactor(scaleFactor); |
1188 |
} else {
|
1189 |
entity.setScaleFactor(scaleFactor); |
1190 |
} |
1191 |
|
1192 |
if (grp.hasCode(43)) { |
1193 |
// TODO La coordenada z
|
1194 |
} |
1195 |
|
1196 |
if (grp.hasCode(50)) { |
1197 |
rotAngle = grp.getDataAsDouble(50);
|
1198 |
entity.setRotAngle(rotAngle); |
1199 |
} |
1200 |
|
1201 |
if (grp.hasCode(62)) { |
1202 |
entity.dxfColor = grp.getDataAsInt(62);
|
1203 |
} else {
|
1204 |
//entity.dxfColor = 0;
|
1205 |
} |
1206 |
|
1207 |
if (grp.hasCode(66)) { |
1208 |
attributesFollowFlag = grp.getDataAsInt(66);
|
1209 |
|
1210 |
//System.out.println("createInsert: attributesFollowFlag = " + attributesFollowFlag);
|
1211 |
} |
1212 |
|
1213 |
if (grp.hasCode(210)) { |
1214 |
extx = grp.getDataAsDouble(210);
|
1215 |
} |
1216 |
|
1217 |
if (grp.hasCode(220)) { |
1218 |
exty = grp.getDataAsDouble(220);
|
1219 |
} |
1220 |
|
1221 |
if (grp.hasCode(230)) { |
1222 |
extz = grp.getDataAsDouble(230);
|
1223 |
} |
1224 |
|
1225 |
Point3D point_in = new Point3D(x, y, z);
|
1226 |
Point3D xtru = new Point3D(extx, exty, extz);
|
1227 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
1228 |
x = point_out.getX(); |
1229 |
y = point_out.getY(); |
1230 |
|
1231 |
entity.setBlkList(blkList); |
1232 |
|
1233 |
entity.encuentraBloque(blockName); |
1234 |
|
1235 |
entity.setPt(proj.createPoint(x, y)); |
1236 |
secondEntity.setPt(proj.createPoint(x, y)); |
1237 |
|
1238 |
if ((entity.getBlockFound() == true) && (attributesFollowFlag != 1)) { |
1239 |
gestionaInsert(entity, layer); |
1240 |
} |
1241 |
|
1242 |
//System.out.println("createInsert: entity.getBlockName = " + entity.getBlockName());
|
1243 |
//System.out.println("createInsert: entity.getRotAngle = " + entity.getRotAngle());
|
1244 |
if (attributesFollowFlag == 1) { |
1245 |
//System.out.println("createInsert: Coloca como lastEntity el insert");
|
1246 |
lastEntity = entity; |
1247 |
} else {
|
1248 |
if (addingToBlock == false) { |
1249 |
entities.add(secondEntity); |
1250 |
} else if ((addingToBlock == true) && (entity.blockFound == true)) { |
1251 |
//System.out.println("createArc(): A?adimos un insert al bloque " + iterator);
|
1252 |
blk.add(entity); |
1253 |
} |
1254 |
} |
1255 |
} |
1256 |
|
1257 |
public void createSolid(DxfGroupVector grp) throws Exception { |
1258 |
double x = 0.0; |
1259 |
double y = 0.0; |
1260 |
double z1 = 0.0; |
1261 |
double z2 = 0.0; |
1262 |
double z3 = 0.0; |
1263 |
double z4 = 0.0; |
1264 |
DxfGroup g = null;
|
1265 |
|
1266 |
//Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
|
1267 |
Point2D[] pts = new Point2D[4]; |
1268 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1269 |
double extx = 0.0; |
1270 |
double exty = 0.0; |
1271 |
double extz = 1.0; |
1272 |
|
1273 |
x = grp.getDataAsDouble(10);
|
1274 |
y = grp.getDataAsDouble(20);
|
1275 |
|
1276 |
if (grp.hasCode(30)) { |
1277 |
z1 = grp.getDataAsDouble(30);
|
1278 |
} |
1279 |
|
1280 |
pts[0] = proj.createPoint(x, y);
|
1281 |
x = grp.getDataAsDouble(11);
|
1282 |
y = grp.getDataAsDouble(21);
|
1283 |
|
1284 |
if (grp.hasCode(31)) { |
1285 |
z2 = grp.getDataAsDouble(31);
|
1286 |
} |
1287 |
|
1288 |
pts[1] = proj.createPoint(x, y);
|
1289 |
x = grp.getDataAsDouble(12);
|
1290 |
y = grp.getDataAsDouble(22);
|
1291 |
|
1292 |
if (grp.hasCode(32)) { |
1293 |
z3 = grp.getDataAsDouble(32);
|
1294 |
} |
1295 |
|
1296 |
pts[2] = proj.createPoint(x, y);
|
1297 |
x = grp.getDataAsDouble(13);
|
1298 |
y = grp.getDataAsDouble(23);
|
1299 |
|
1300 |
if (grp.hasCode(33)) { |
1301 |
z2 = grp.getDataAsDouble(33);
|
1302 |
} |
1303 |
|
1304 |
pts[3] = proj.createPoint(x, y);
|
1305 |
|
1306 |
if (grp.hasCode(210)) { |
1307 |
extx = grp.getDataAsDouble(210);
|
1308 |
} |
1309 |
|
1310 |
if (grp.hasCode(220)) { |
1311 |
exty = grp.getDataAsDouble(220);
|
1312 |
} |
1313 |
|
1314 |
if (grp.hasCode(230)) { |
1315 |
extz = grp.getDataAsDouble(230);
|
1316 |
} |
1317 |
|
1318 |
Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1); |
1319 |
Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2); |
1320 |
Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3); |
1321 |
Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4); |
1322 |
Point3D xtru = new Point3D(extx, exty, extz);
|
1323 |
Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
1324 |
Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
1325 |
Point2D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru);
|
1326 |
Point2D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru);
|
1327 |
pts[0].setLocation(point_out1);
|
1328 |
pts[1].setLocation(point_out2);
|
1329 |
pts[2].setLocation(point_out3);
|
1330 |
pts[3].setLocation(point_out4);
|
1331 |
|
1332 |
DxfSolid entity = new DxfSolid(proj, layer, pts);
|
1333 |
|
1334 |
if (grp.hasCode(62)) { |
1335 |
entity.dxfColor = grp.getDataAsInt(62);
|
1336 |
} else {
|
1337 |
//entity.dxfColor = 0;
|
1338 |
} |
1339 |
|
1340 |
if (addingToBlock == false) { |
1341 |
//System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
1342 |
entities.add(entity); |
1343 |
} else {
|
1344 |
//System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
1345 |
blk.add(entity); |
1346 |
} |
1347 |
} |
1348 |
|
1349 |
/**
|
1350 |
* Los Splines estan implementados como LwPolylines. Se pintan las lineas
|
1351 |
* entre los vertices pero no se aplica la curvatura Spline.
|
1352 |
* TODO Contemplar la curvatura spline para Splines.
|
1353 |
*/
|
1354 |
public void createSpline(DxfGroupVector grp) throws Exception { |
1355 |
double x = 0.0; |
1356 |
double y = 0.0; |
1357 |
double elev = 0.0; |
1358 |
DxfGroup g = null;
|
1359 |
|
1360 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1361 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
1362 |
|
1363 |
for (int i = 0; i < grp.size(); i++) { |
1364 |
g = (DxfGroup) grp.get(i); |
1365 |
|
1366 |
if (g.getCode() == 10) { |
1367 |
x = ((Double) g.getData()).doubleValue();
|
1368 |
} else if (g.getCode() == 20) { |
1369 |
y = ((Double) g.getData()).doubleValue();
|
1370 |
|
1371 |
//if (y <= 1.0) throw new Exception("Y == "+y);
|
1372 |
entity.add(proj.createPoint(x, y)); |
1373 |
x = 0.0;
|
1374 |
y = 0.0;
|
1375 |
} |
1376 |
} |
1377 |
|
1378 |
if (grp.hasCode(62)) { |
1379 |
entity.dxfColor = grp.getDataAsInt(62);
|
1380 |
} else {
|
1381 |
//entity.dxfColor = 0;
|
1382 |
} |
1383 |
|
1384 |
if (grp.hasCode(70)) { |
1385 |
entity.flags = grp.getDataAsInt(70);
|
1386 |
} |
1387 |
|
1388 |
if ((entity.flags & 0x01) == 0x01) { |
1389 |
entity.closed = true;
|
1390 |
} |
1391 |
|
1392 |
if (addingToBlock == false) { |
1393 |
entities.add(entity); |
1394 |
} else {
|
1395 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
1396 |
blk.add(entity); |
1397 |
} |
1398 |
} |
1399 |
|
1400 |
public void createBlock(DxfGroupVector grp) throws Exception { |
1401 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1402 |
blk = new DxfBlock(proj);
|
1403 |
|
1404 |
Point2D basePoint = new Point2D.Double(); |
1405 |
String blockName = ""; |
1406 |
|
1407 |
//System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
|
1408 |
addingToBlock = true;
|
1409 |
|
1410 |
//System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
|
1411 |
blkList.add(iterator, blk); |
1412 |
|
1413 |
//System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
|
1414 |
if (grp.hasCode(1)) { |
1415 |
blockName = grp.getDataAsString(1);
|
1416 |
blk.setBlkName(blockName); |
1417 |
} |
1418 |
|
1419 |
if (grp.hasCode(2)) { |
1420 |
blockName = grp.getDataAsString(2);
|
1421 |
blk.setBlkName(blockName); |
1422 |
} |
1423 |
|
1424 |
if (grp.hasCode(3)) { |
1425 |
blockName = grp.getDataAsString(3);
|
1426 |
blk.setBlkName(blockName); |
1427 |
} |
1428 |
|
1429 |
if (grp.hasCode(10)) { |
1430 |
basePoint = new Point2D.Double(grp.getDataAsDouble(10), |
1431 |
basePoint.getY()); |
1432 |
blk.setBPoint(basePoint); |
1433 |
} |
1434 |
|
1435 |
if (grp.hasCode(20)) { |
1436 |
basePoint = new Point2D.Double(basePoint.getX(), |
1437 |
grp.getDataAsDouble(20));
|
1438 |
blk.setBPoint(basePoint); |
1439 |
} |
1440 |
|
1441 |
if (grp.hasCode(30)) { |
1442 |
// TODO Contemplar la coordenada z
|
1443 |
} |
1444 |
|
1445 |
if (grp.hasCode(70)) { |
1446 |
blk.flags = grp.getDataAsInt(70);
|
1447 |
} |
1448 |
} |
1449 |
|
1450 |
public void endBlk(DxfGroupVector grp) throws Exception { |
1451 |
//DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1452 |
setAddingToBlock(false);
|
1453 |
iterator = iterator + 1;
|
1454 |
} |
1455 |
|
1456 |
public void testBlocks() { |
1457 |
Vector blkList = getBlkList();
|
1458 |
DxfBlock dxfBlock = null;
|
1459 |
DxfEntity dxfEntity = null;
|
1460 |
DxfLine dxfLine = null;
|
1461 |
DxfInsert dxfInsert = null;
|
1462 |
Point2D point1 = new Point2D.Double(); |
1463 |
Point2D point2 = new Point2D.Double(); |
1464 |
|
1465 |
for (int i = 0; i < blkList.size(); i++) { |
1466 |
dxfBlock = (DxfBlock) blkList.get(i); |
1467 |
|
1468 |
int aux = dxfBlock.getBlkElements().size();
|
1469 |
|
1470 |
for (int j = 0; j < aux; j++) { |
1471 |
dxfEntity = (DxfEntity) dxfBlock.getBlkElements().get(j); |
1472 |
|
1473 |
if (dxfEntity instanceof DxfLine) { |
1474 |
dxfLine = (DxfLine) dxfEntity; |
1475 |
point1 = dxfLine.getPts()[0];
|
1476 |
point2 = dxfLine.getPts()[1];
|
1477 |
|
1478 |
//System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", vertice1 = " + point1 + ", vertice2 = " + point2);
|
1479 |
} else if (dxfEntity instanceof DxfInsert) { |
1480 |
dxfInsert = (DxfInsert) dxfEntity; |
1481 |
|
1482 |
String nomBlock = dxfInsert.getBlockName();
|
1483 |
|
1484 |
//System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", inserta el bloque = " + nomBlock);
|
1485 |
//System.out.println("compruebaBloques(): dxfInsert.pt = " + dxfInsert.getPt());
|
1486 |
//System.out.println("compruebaBloques(): dxfInsert.rotAngle = " + dxfInsert.getRotAngle());
|
1487 |
//System.out.println("compruebaBloques(): dxfInsert.scaleFactor = " + dxfInsert.getScaleFactor());
|
1488 |
if (dxfInsert.getBlockFound() == false) { |
1489 |
//System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock);
|
1490 |
boolean aux_bool = dxfInsert.encuentraBloque(nomBlock);
|
1491 |
gestionaInsert(dxfInsert, dxfInsert.getDxfLayer()); |
1492 |
dxfBlock.add(dxfInsert); |
1493 |
} |
1494 |
} |
1495 |
} |
1496 |
} |
1497 |
} |
1498 |
|
1499 |
public void setProjection(IProjection proj) { |
1500 |
this.proj = proj;
|
1501 |
} |
1502 |
|
1503 |
public IProjection getProjection() {
|
1504 |
return proj;
|
1505 |
} |
1506 |
|
1507 |
public void reProject(ICoordTrans rp) { |
1508 |
entities.reProject(rp); |
1509 |
setProjection(rp.getPDest()); |
1510 |
} |
1511 |
|
1512 |
public DxfEntityList getEntities() {
|
1513 |
return entities;
|
1514 |
} |
1515 |
|
1516 |
public DxfTable getLayers() {
|
1517 |
return layers;
|
1518 |
} |
1519 |
|
1520 |
public DxfBlock getBlk() {
|
1521 |
return blk;
|
1522 |
} |
1523 |
|
1524 |
public void gestionaInsert(DxfInsert entity, DxfLayer layer) { |
1525 |
DxfEntity dxfEntity = null;
|
1526 |
DxfLine dxfLine = null;
|
1527 |
DxfInsert dxfInsert = null;
|
1528 |
DxfPolyline dxfPolyline = null;
|
1529 |
DxfArc dxfArc = null;
|
1530 |
DxfCircle dxfCircle = null;
|
1531 |
DxfLwPolyline dxfLwPolyline = null;
|
1532 |
DxfPoint dxfPoint = null;
|
1533 |
DxfText dxfText = null;
|
1534 |
DxfSolid dxfSolid = null;
|
1535 |
|
1536 |
// jmorell, 050406: intentando corregir cosas que salen fuera de sitio ...
|
1537 |
double bPointX = 0.0; |
1538 |
double bPointY = 0.0; |
1539 |
|
1540 |
//if (entity.getBlockFound() == true) {
|
1541 |
bPointX = entity.block.bPoint.getX(); |
1542 |
bPointY = entity.block.bPoint.getY(); |
1543 |
|
1544 |
//}
|
1545 |
double sFactorX = entity.getScaleFactor().getX();
|
1546 |
double sFactorY = entity.getScaleFactor().getY();
|
1547 |
double rAngleGra = entity.getRotAngle();
|
1548 |
double rAngleRad = (rAngleGra * Math.PI) / 180.0; |
1549 |
|
1550 |
for (int i = 0; i < entity.block.size(); i++) { |
1551 |
//System.out.println("gestionaInserts: entity.block.blkElements.size() = " + entity.block.blkElements.size());
|
1552 |
dxfEntity = (DxfEntity) entity.block.get(i); |
1553 |
|
1554 |
Point2D point1 = new Point2D.Double(); |
1555 |
Point2D point2 = new Point2D.Double(); |
1556 |
Point2D point11 = new Point2D.Double(); |
1557 |
Point2D point22 = new Point2D.Double(); |
1558 |
Point2D pointAux = null; |
1559 |
|
1560 |
if (dxfEntity instanceof DxfLine) { |
1561 |
dxfLine = (DxfLine) dxfEntity; |
1562 |
point1 = dxfLine.getPts()[0];
|
1563 |
|
1564 |
//double laX = entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX());
|
1565 |
//double laY = entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY());
|
1566 |
pointAux = new Point2D.Double(point1.getX() - bPointX, |
1567 |
point1.getY() - bPointY); |
1568 |
|
1569 |
double laX = entity.pt.getX() +
|
1570 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1571 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1572 |
double laY = entity.pt.getY() +
|
1573 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1574 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1575 |
point11.setLocation(laX, laY); |
1576 |
point2 = dxfLine.getPts()[1];
|
1577 |
pointAux = new Point2D.Double(point2.getX() - bPointX, |
1578 |
point2.getY() - bPointY); |
1579 |
laX = entity.pt.getX() + |
1580 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1581 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1582 |
laY = entity.pt.getY() + |
1583 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1584 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1585 |
point22.setLocation(laX, laY); |
1586 |
|
1587 |
DxfLine dxfLinee = new DxfLine(proj, layer, point11, point22);
|
1588 |
|
1589 |
if (addingToBlock == false) { |
1590 |
entities.add(dxfLinee); |
1591 |
} |
1592 |
} else if (dxfEntity instanceof DxfInsert) { |
1593 |
dxfInsert = (DxfInsert) dxfEntity; |
1594 |
point1 = dxfInsert.pt; |
1595 |
pointAux = new Point2D.Double(point1.getX() - bPointX, |
1596 |
point1.getY() - bPointY); |
1597 |
|
1598 |
//point11.setLocation(entity.pt.getX() - entity.block.bPoint.getX() + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - entity.block.bPoint.getY() + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1599 |
//point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1600 |
double laX = entity.pt.getX() +
|
1601 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1602 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1603 |
double laY = entity.pt.getY() +
|
1604 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1605 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1606 |
point11.setLocation(laX, laY); |
1607 |
|
1608 |
DxfInsert dxfInsertt = new DxfInsert(proj, layer);
|
1609 |
|
1610 |
dxfInsertt.pt = point11; |
1611 |
|
1612 |
dxfInsertt.blkList = dxfInsert.blkList; |
1613 |
dxfInsertt.block = dxfInsert.block; |
1614 |
dxfInsertt.blockName = dxfInsert.blockName; |
1615 |
dxfInsertt.rotAngle = dxfInsert.rotAngle; |
1616 |
dxfInsertt.layer = dxfInsert.layer; |
1617 |
dxfInsertt.proj = dxfInsert.proj; |
1618 |
|
1619 |
Point2D newScale = new Point2D.Double(dxfInsert.getScaleFactor() |
1620 |
.getX() * sFactorX, |
1621 |
dxfInsert.getScaleFactor() |
1622 |
.getY() * sFactorY); |
1623 |
dxfInsertt.setScaleFactor(newScale); |
1624 |
|
1625 |
//dxfInsertt.scaleFactor = new Point2D.Double(dxfInsert.scaleFactor.getX() * entity.scaleFactor.getX(), dxfInsert.scaleFactor.getY() * entity.scaleFactor.getY());
|
1626 |
gestionaInsert(dxfInsertt, layer); |
1627 |
} else if (dxfEntity instanceof DxfPolyline) { |
1628 |
dxfPolyline = (DxfPolyline) dxfEntity; |
1629 |
|
1630 |
DxfPolyline dxfPolylinee = new DxfPolyline(proj, layer);
|
1631 |
|
1632 |
if (dxfPolyline.closed) {
|
1633 |
dxfPolylinee.closed = true;
|
1634 |
} |
1635 |
|
1636 |
Point2D[] points = new Point2D[dxfPolyline.pts.size()]; |
1637 |
Point2D[] pointss = new Point2D[dxfPolyline.pts.size()]; |
1638 |
|
1639 |
for (int j = 0; j < dxfPolyline.pts.size(); j++) { |
1640 |
points[j] = (Point2D) dxfPolyline.pts.get(j);
|
1641 |
pointss[j] = new Point2D.Double(); |
1642 |
|
1643 |
//pointss[j].setLocation(entity.pt.getX() - entity.block.bPoint.getX() + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - entity.block.bPoint.getY() + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1644 |
//pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1645 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, |
1646 |
points[j].getY() - bPointY); |
1647 |
|
1648 |
double laX = entity.pt.getX() +
|
1649 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1650 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1651 |
double laY = entity.pt.getY() +
|
1652 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1653 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1654 |
pointss[j].setLocation(laX, laY); |
1655 |
|
1656 |
//pointss[j].setLocation(entity.pt.getX() + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1657 |
dxfPolylinee.add(pointss[j]); |
1658 |
|
1659 |
// jmorell, 050405: Bulges en Dxfpolyline para el piloto
|
1660 |
dxfPolylinee.addBulge((Double) dxfPolyline.getBulges().get(j));
|
1661 |
} |
1662 |
|
1663 |
if (addingToBlock == false) { |
1664 |
entities.add(dxfPolylinee); |
1665 |
} |
1666 |
} else if (dxfEntity instanceof DxfArc) { |
1667 |
dxfArc = (DxfArc) dxfEntity; |
1668 |
|
1669 |
Point2D[] points = new Point2D[dxfArc.pts.length]; |
1670 |
Point2D[] pointss = new Point2D[dxfArc.pts.length]; |
1671 |
|
1672 |
for (int j = 0; j < dxfArc.pts.length; j++) { |
1673 |
points[j] = (Point2D) dxfArc.pts[j];
|
1674 |
pointss[j] = new Point2D.Double(); |
1675 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, |
1676 |
points[j].getY() - bPointY); |
1677 |
|
1678 |
double laX = entity.pt.getX() +
|
1679 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1680 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1681 |
double laY = entity.pt.getY() +
|
1682 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1683 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1684 |
pointss[j].setLocation(laX, laY); |
1685 |
|
1686 |
//pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1687 |
} |
1688 |
|
1689 |
DxfArc dxfArcc = new DxfArc(proj, layer, pointss);
|
1690 |
|
1691 |
// 050315, jmorell: Para que no se pierdan las propiedades en el
|
1692 |
// caso de objetos dentro de bloques.
|
1693 |
pointAux = new Point2D.Double(dxfArc.getCentralPoint().getX() - |
1694 |
bPointX, |
1695 |
dxfArc.getCentralPoint().getY() - |
1696 |
bPointY); |
1697 |
|
1698 |
double laX = entity.pt.getX() +
|
1699 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1700 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1701 |
double laY = entity.pt.getY() +
|
1702 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1703 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1704 |
pointAux.setLocation(laX, laY); |
1705 |
dxfArcc.setCentralPoint(pointAux); |
1706 |
pointAux = new Point2D.Double(dxfArc.getInit().getX() - |
1707 |
bPointX, |
1708 |
dxfArc.getInit().getY() - |
1709 |
bPointY); |
1710 |
laX = entity.pt.getX() + |
1711 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1712 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1713 |
laY = entity.pt.getY() + |
1714 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1715 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1716 |
pointAux.setLocation(laX, laY); |
1717 |
dxfArcc.setInit(pointAux); |
1718 |
pointAux = new Point2D.Double(dxfArc.getEnd().getX() - bPointX, |
1719 |
dxfArc.getEnd().getY() - bPointY); |
1720 |
laX = entity.pt.getX() + |
1721 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1722 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1723 |
laY = entity.pt.getY() + |
1724 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1725 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1726 |
pointAux.setLocation(laX, laY); |
1727 |
dxfArcc.setEnd(pointAux); |
1728 |
pointAux = new Point2D.Double(dxfArc.getCenter().getX() - |
1729 |
bPointX, |
1730 |
dxfArc.getCenter().getY() - |
1731 |
bPointY); |
1732 |
laX = entity.pt.getX() + |
1733 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1734 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1735 |
laY = entity.pt.getY() + |
1736 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1737 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1738 |
pointAux.setLocation(laX, laY); |
1739 |
dxfArcc.setCenter(pointAux); |
1740 |
dxfArcc.setRadius(dxfArc.getRadius() * sFactorX); |
1741 |
|
1742 |
// TODO ?Como afectan las rotaciones del insert al init y el end angle?
|
1743 |
dxfArcc.setInitAngle(dxfArc.getInitAngle()); |
1744 |
dxfArcc.setEndAngle(dxfArc.getEndAngle()); |
1745 |
|
1746 |
if (addingToBlock == false) { |
1747 |
entities.add(dxfArcc); |
1748 |
} |
1749 |
} else if (dxfEntity instanceof DxfCircle) { |
1750 |
dxfCircle = (DxfCircle) dxfEntity; |
1751 |
|
1752 |
Point2D[] points = new Point2D[dxfCircle.pts.length]; |
1753 |
Point2D[] pointss = new Point2D[dxfCircle.pts.length]; |
1754 |
|
1755 |
for (int j = 0; j < dxfCircle.pts.length; j++) { |
1756 |
points[j] = (Point2D) dxfCircle.pts[j];
|
1757 |
pointss[j] = new Point2D.Double(); |
1758 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, |
1759 |
points[j].getY() - bPointY); |
1760 |
|
1761 |
double laX = entity.pt.getX() +
|
1762 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1763 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1764 |
double laY = entity.pt.getY() +
|
1765 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1766 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1767 |
pointss[j].setLocation(laX, laY); |
1768 |
|
1769 |
//pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1770 |
} |
1771 |
|
1772 |
DxfCircle dxfCirclee = new DxfCircle(proj, layer, pointss);
|
1773 |
|
1774 |
// 050315, jmorell: Para que no se pierdan las propiedades en el
|
1775 |
// caso de objetos dentro de bloques.
|
1776 |
pointAux = new Point2D.Double(dxfCircle.getCenter().getX() - |
1777 |
bPointX, |
1778 |
dxfCircle.getCenter().getY() - |
1779 |
bPointY); |
1780 |
|
1781 |
double laX = entity.pt.getX() +
|
1782 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1783 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1784 |
double laY = entity.pt.getY() +
|
1785 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1786 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1787 |
pointAux.setLocation(laX, laY); |
1788 |
dxfCirclee.setCenter(pointAux); |
1789 |
|
1790 |
// Escala en X = escala en Y ...
|
1791 |
dxfCirclee.setRadius(dxfCircle.getRadius() * sFactorX); |
1792 |
|
1793 |
if (addingToBlock == false) { |
1794 |
entities.add(dxfCirclee); |
1795 |
} |
1796 |
} else if (dxfEntity instanceof DxfLwPolyline) { |
1797 |
dxfLwPolyline = (DxfLwPolyline) dxfEntity; |
1798 |
|
1799 |
DxfLwPolyline dxfLwPolylinee = new DxfLwPolyline(proj, layer);
|
1800 |
Point2D[] points = new Point2D[dxfLwPolyline.pts.size()]; |
1801 |
Point2D[] pointss = new Point2D[dxfLwPolyline.pts.size()]; |
1802 |
|
1803 |
for (int j = 0; j < dxfLwPolyline.pts.size(); j++) { |
1804 |
points[j] = (Point2D) dxfLwPolyline.pts.get(j);
|
1805 |
pointss[j] = new Point2D.Double(); |
1806 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, |
1807 |
points[j].getY() - bPointY); |
1808 |
|
1809 |
double laX = entity.pt.getX() +
|
1810 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1811 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1812 |
double laY = entity.pt.getY() +
|
1813 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1814 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1815 |
pointss[j].setLocation(laX, laY); |
1816 |
|
1817 |
//pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1818 |
dxfLwPolylinee.add(pointss[j]); |
1819 |
|
1820 |
// jmorell, 050405: Bulges en Dxfpolyline para el piloto
|
1821 |
dxfLwPolylinee.addBulge((Double) dxfPolyline.getBulges()
|
1822 |
.get(j)); |
1823 |
} |
1824 |
|
1825 |
if (addingToBlock == false) { |
1826 |
entities.add(dxfLwPolylinee); |
1827 |
} |
1828 |
} else if (dxfEntity instanceof DxfPoint) { |
1829 |
dxfPoint = (DxfPoint) dxfEntity; |
1830 |
point1 = dxfPoint.getPt(); |
1831 |
pointAux = new Point2D.Double(point1.getX() - bPointX, |
1832 |
point1.getY() - bPointY); |
1833 |
|
1834 |
double laX = entity.pt.getX() +
|
1835 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1836 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1837 |
double laY = entity.pt.getY() +
|
1838 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1839 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1840 |
point11.setLocation(laX, laY); |
1841 |
|
1842 |
//point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1843 |
DxfPoint dxfPointt = new DxfPoint(proj, layer);
|
1844 |
|
1845 |
//dxfPointt.pt = point11;
|
1846 |
dxfPointt.setPt(point11); |
1847 |
|
1848 |
if (addingToBlock == false) { |
1849 |
entities.add(dxfPointt); |
1850 |
} |
1851 |
} else if (dxfEntity instanceof DxfText) { |
1852 |
dxfText = (DxfText) dxfEntity; |
1853 |
|
1854 |
if (dxfText.getTwoPointsFlag()) {
|
1855 |
point1 = dxfText.pts[0];
|
1856 |
pointAux = new Point2D.Double(point1.getX() - bPointX, |
1857 |
point1.getY() - bPointY); |
1858 |
|
1859 |
double laX = entity.pt.getX() +
|
1860 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1861 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1862 |
double laY = entity.pt.getY() +
|
1863 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1864 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1865 |
point11.setLocation(laX, laY); |
1866 |
|
1867 |
//point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1868 |
point2 = dxfText.pts[1];
|
1869 |
pointAux = new Point2D.Double(point2.getX() - bPointX, |
1870 |
point2.getY() - bPointY); |
1871 |
laX = entity.pt.getX() + |
1872 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1873 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1874 |
laY = entity.pt.getY() + |
1875 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1876 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1877 |
point22.setLocation(laX, laY); |
1878 |
|
1879 |
//point22.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point2.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point2.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point2.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point2.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1880 |
DxfText dxfTextt = new DxfText(proj, layer,
|
1881 |
dxfText.getText()); |
1882 |
dxfTextt.pts[0] = point11;
|
1883 |
dxfTextt.pts[1] = point22;
|
1884 |
|
1885 |
if (addingToBlock == false) { |
1886 |
entities.add(dxfTextt); |
1887 |
} |
1888 |
} else {
|
1889 |
point1 = dxfText.getPt(); |
1890 |
pointAux = new Point2D.Double(point1.getX() - bPointX, |
1891 |
point1.getY() - bPointY); |
1892 |
|
1893 |
double laX = entity.pt.getX() +
|
1894 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1895 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1896 |
double laY = entity.pt.getY() +
|
1897 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1898 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1899 |
point11.setLocation(laX, laY); |
1900 |
|
1901 |
//point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1902 |
DxfText dxfTextt = new DxfText(proj, layer,
|
1903 |
dxfText.getText()); |
1904 |
dxfTextt.setPt(point11); |
1905 |
|
1906 |
if (addingToBlock == false) { |
1907 |
entities.add(dxfTextt); |
1908 |
} |
1909 |
} |
1910 |
} else if (dxfEntity instanceof DxfSolid) { |
1911 |
dxfSolid = (DxfSolid) dxfEntity; |
1912 |
|
1913 |
Point2D[] points = new Point2D[dxfSolid.pts.length]; |
1914 |
Point2D[] pointss = new Point2D[dxfSolid.pts.length]; |
1915 |
|
1916 |
for (int j = 0; j < dxfSolid.pts.length; j++) { |
1917 |
points[j] = (Point2D) dxfSolid.pts[j];
|
1918 |
pointss[j] = new Point2D.Double(); |
1919 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, |
1920 |
points[j].getY() - bPointY); |
1921 |
|
1922 |
double laX = entity.pt.getX() +
|
1923 |
(((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
1924 |
((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
1925 |
double laY = entity.pt.getY() +
|
1926 |
(((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
1927 |
((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
1928 |
pointss[j].setLocation(laX, laY); |
1929 |
|
1930 |
//pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
1931 |
} |
1932 |
|
1933 |
DxfSolid dxfSolidd = new DxfSolid(proj, layer, pointss);
|
1934 |
Point2D aux = dxfSolidd.pts[2]; |
1935 |
dxfSolidd.pts[2] = dxfSolidd.pts[3]; |
1936 |
dxfSolidd.pts[3] = aux;
|
1937 |
|
1938 |
if (addingToBlock == false) { |
1939 |
entities.add(dxfSolidd); |
1940 |
} |
1941 |
} else {
|
1942 |
System.out.println("gestionaInserts: Encontrado elemento desconocido"); |
1943 |
} |
1944 |
} |
1945 |
} |
1946 |
|
1947 |
public void createAttdef(DxfGroupVector grp) throws Exception { |
1948 |
DxfGroup g = null;
|
1949 |
|
1950 |
String defaultValue = ""; |
1951 |
String tagString = ""; |
1952 |
String textStyleName = ""; |
1953 |
String[] attribute = new String[2]; |
1954 |
boolean tagDefined = false; |
1955 |
boolean defValDefined = false; |
1956 |
|
1957 |
if (grp.hasCode(1)) { |
1958 |
defaultValue = grp.getDataAsString(1);
|
1959 |
attribute[1] = DxfConvTexts.ConvertText(defaultValue);
|
1960 |
defValDefined = true;
|
1961 |
|
1962 |
if (tagDefined) {
|
1963 |
attributes.add(attribute); |
1964 |
} |
1965 |
} |
1966 |
|
1967 |
if (grp.hasCode(2)) { |
1968 |
tagString = grp.getDataAsString(2);
|
1969 |
attribute[0] = DxfConvTexts.ConvertText(tagString);
|
1970 |
tagDefined = true;
|
1971 |
|
1972 |
if (defValDefined) {
|
1973 |
attributes.add(attribute); |
1974 |
} |
1975 |
} |
1976 |
|
1977 |
if (grp.hasCode(7)) { |
1978 |
textStyleName = grp.getDataAsString(7);
|
1979 |
textStyleName = DxfConvTexts.ConvertText(textStyleName); |
1980 |
} |
1981 |
|
1982 |
// TODO setNewAttributes();
|
1983 |
} |
1984 |
|
1985 |
public void createAttrib(DxfGroupVector grp) throws Exception { |
1986 |
double x = 0.0; |
1987 |
double y = 0.0; |
1988 |
double z = 0.0; |
1989 |
double h = 0.0; |
1990 |
double rot = 0.0; |
1991 |
DxfGroup g = null;
|
1992 |
Point2D pt = null; |
1993 |
|
1994 |
String defaultValue = ""; |
1995 |
String tagString = ""; |
1996 |
String textStyleName = ""; |
1997 |
String[] att = new String[2]; |
1998 |
boolean tagDefined = false; |
1999 |
boolean defValDefined = false; |
2000 |
int attributeFlags = 0; |
2001 |
double extx = 0.0; |
2002 |
double exty = 0.0; |
2003 |
double extz = 1.0; |
2004 |
|
2005 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
2006 |
DxfAttrib entity = new DxfAttrib(proj, layer);
|
2007 |
|
2008 |
if (grp.hasCode(1)) { |
2009 |
String strAux1 = grp.getDataAsString(1); |
2010 |
strAux1 = DxfConvTexts.ConvertText(strAux1); |
2011 |
defaultValue = strAux1; |
2012 |
att[1] = DxfConvTexts.ConvertText(defaultValue);
|
2013 |
defValDefined = true;
|
2014 |
|
2015 |
/*if (tagDefined) {
|
2016 |
insFea.setProp(att[0], att[1]);
|
2017 |
ptFea.setProp(att[0], att[1]);
|
2018 |
}
|
2019 |
feature.setProp("text", strAux1);*/
|
2020 |
} |
2021 |
|
2022 |
if (grp.hasCode(2)) { |
2023 |
String strAux2 = grp.getDataAsString(2); |
2024 |
strAux2 = DxfConvTexts.ConvertText(strAux2); |
2025 |
tagString = strAux2; |
2026 |
att[0] = DxfConvTexts.ConvertText(tagString);
|
2027 |
tagDefined = true;
|
2028 |
|
2029 |
/*if (defValDefined) {
|
2030 |
insFea.setProp(att[0], att[1]);
|
2031 |
ptFea.setProp(att[0], att[1]);
|
2032 |
}*/
|
2033 |
} |
2034 |
|
2035 |
if (grp.hasCode(7)) { |
2036 |
textStyleName = grp.getDataAsString(7);
|
2037 |
textStyleName = DxfConvTexts.ConvertText(textStyleName); |
2038 |
} |
2039 |
|
2040 |
x = grp.getDataAsDouble(10);
|
2041 |
y = grp.getDataAsDouble(20);
|
2042 |
z = grp.getDataAsDouble(30);
|
2043 |
|
2044 |
if (grp.hasCode(210)) { |
2045 |
extx = grp.getDataAsDouble(210);
|
2046 |
} |
2047 |
|
2048 |
if (grp.hasCode(220)) { |
2049 |
exty = grp.getDataAsDouble(220);
|
2050 |
} |
2051 |
|
2052 |
if (grp.hasCode(230)) { |
2053 |
extz = grp.getDataAsDouble(230);
|
2054 |
} |
2055 |
|
2056 |
Point3D point_in = new Point3D(x, y, z);
|
2057 |
Point3D xtru = new Point3D(extx, exty, extz);
|
2058 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
2059 |
x = point_out.getX(); |
2060 |
y = point_out.getY(); |
2061 |
z = point_out.getZ(); |
2062 |
entity.setPt(proj.createPoint(x, y)); |
2063 |
|
2064 |
if (grp.hasCode(40)) { |
2065 |
Double heightD = new Double(grp.getDataAsDouble(40)); |
2066 |
String heightS = heightD.toString();
|
2067 |
|
2068 |
//feature.setProp("textHeight", heightS);
|
2069 |
} else {
|
2070 |
//feature.setProp("textHeight", "20.0");
|
2071 |
} |
2072 |
|
2073 |
if (grp.hasCode(50)) { |
2074 |
Double rotD = new Double(grp.getDataAsDouble(50)); |
2075 |
String rotS = rotD.toString();
|
2076 |
|
2077 |
//feature.setProp("textRotation", rotS);
|
2078 |
} else {
|
2079 |
//feature.setProp("textRotation", "0.0");
|
2080 |
} |
2081 |
|
2082 |
if (grp.hasCode(62)) { |
2083 |
entity.dxfColor = grp.getDataAsInt(62);
|
2084 |
} else {
|
2085 |
//entity.dxfColor = 0;
|
2086 |
} |
2087 |
|
2088 |
if (grp.hasCode(70)) { |
2089 |
attributeFlags = grp.getDataAsInt(70);
|
2090 |
} |
2091 |
|
2092 |
if (attributeFlags == 8) { |
2093 |
if (addingToBlock == false) { |
2094 |
entities.add(entity); |
2095 |
} else {
|
2096 |
blk.add(entity); |
2097 |
} |
2098 |
} |
2099 |
} |
2100 |
|
2101 |
public Vector getAttributes() { |
2102 |
return attributes;
|
2103 |
} |
2104 |
|
2105 |
/* (non-Javadoc)
|
2106 |
* @see org.cresques.io.DxfFile.EntityFactory#depureAttributes()
|
2107 |
*/
|
2108 |
public void depureAttributes() { |
2109 |
// TODO Auto-generated method stub
|
2110 |
} |
2111 |
|
2112 |
/* (non-Javadoc)
|
2113 |
* @see org.cresques.io.DxfFile.EntityFactory#isDxf3DFile()
|
2114 |
*/
|
2115 |
public boolean isDxf3DFile() { |
2116 |
// TODO Auto-generated method stub
|
2117 |
return false; |
2118 |
} |
2119 |
} |