svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfEntityMaker.java @ 120
History | View | Annotate | Download (42.9 KB)
1 |
package org.cresques.px.dxf; |
---|---|
2 |
|
3 |
import java.awt.geom.Point2D; |
4 |
import java.util.Vector; |
5 |
|
6 |
import org.cresques.cts.ICoordTrans; |
7 |
import org.cresques.cts.IProjection; |
8 |
import org.cresques.geo.Point3D; |
9 |
import org.cresques.geo.Projected; |
10 |
import org.cresques.io.DxfFile; |
11 |
import org.cresques.io.DxfGroup; |
12 |
import org.cresques.io.DxfGroupVector; |
13 |
import org.cresques.px.Extent; |
14 |
import org.cresques.px.IObjList; |
15 |
import org.cresques.px.PxObj; |
16 |
//import org.cresques.px.gml.Feature;
|
17 |
|
18 |
public class DxfEntityMaker implements DxfFile.EntityFactory, Projected { |
19 |
IProjection proj = null;
|
20 |
DxfEntity lastEntity = null;
|
21 |
DxfEntityList entities = null;
|
22 |
Vector blkList = null; |
23 |
DxfBlock blk = null;
|
24 |
DxfTable layers = null;
|
25 |
double bulge = 0.0; |
26 |
|
27 |
double xtruX=0.0, xtruY=0.0, xtruZ=1.0; |
28 |
|
29 |
int polylineFlag = 0; |
30 |
Point2D firstPt = new Point2D.Double(); |
31 |
|
32 |
boolean addingToBlock = false; |
33 |
int iterator = 0; |
34 |
|
35 |
public DxfEntityMaker (IProjection proj) {
|
36 |
this.proj = proj;
|
37 |
layers = new DxfTable();
|
38 |
entities = new DxfEntityList(proj);
|
39 |
blkList = new Vector(); |
40 |
} |
41 |
|
42 |
public Vector getBlkList() { return blkList; } |
43 |
|
44 |
public IObjList getObjects() { return entities; } |
45 |
public Extent getExtent() { return entities.getExtent(); } |
46 |
|
47 |
public void setAddingToBlock(boolean a) { addingToBlock = a; } |
48 |
|
49 |
public void createLayer(DxfGroupVector grp) throws Exception { |
50 |
int color = grp.getDataAsInt(62); |
51 |
DxfLayer layer = new DxfLayer(grp.getDataAsString(2), Math.abs(grp.getDataAsInt(62))); |
52 |
if (color < 0) { |
53 |
layer.isOff = true;
|
54 |
} |
55 |
layer.lType = grp.getDataAsString(6);
|
56 |
layer.setFlags(grp.getDataAsInt(70));
|
57 |
// compruebo flags
|
58 |
if ((layer.flags & 0x01) == 0x01) { |
59 |
layer.frozen = true;
|
60 |
} |
61 |
if ((layer.flags & 0x02) == 0x02) { |
62 |
layer.frozen = true;
|
63 |
} |
64 |
System.out.println("LAYER color="+layer.getColor()); |
65 |
|
66 |
layers.add(layer); |
67 |
} |
68 |
|
69 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
70 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
71 |
DxfPolyline entity = new DxfPolyline(proj, layer);
|
72 |
|
73 |
double x = 0.0, y = 0.0, z = 0.0; |
74 |
double thickness = 0; |
75 |
|
76 |
if (grp.hasCode(10)) |
77 |
x = grp.getDataAsDouble(10);
|
78 |
if (grp.hasCode(20)) |
79 |
y = grp.getDataAsDouble(20);
|
80 |
if (grp.hasCode(30)) |
81 |
z = grp.getDataAsDouble(30);
|
82 |
/*if (grp.hasCode(39))
|
83 |
System.out.println("Leer el thickness provoca un error");
|
84 |
thickness = grp.getDataAsDouble(39);*/
|
85 |
if (grp.hasCode(62)) { |
86 |
entity.dxfColor = grp.getDataAsInt(62);
|
87 |
} else {
|
88 |
//entity.dxfColor = 0;
|
89 |
} |
90 |
if (grp.hasCode(66)) { |
91 |
entity.entitiesFollow = grp.getDataAsInt(66);
|
92 |
} |
93 |
if (grp.hasCode(70)) { |
94 |
entity.flags = grp.getDataAsInt(70);
|
95 |
} |
96 |
if (grp.hasCode(210)) |
97 |
xtruX = grp.getDataAsDouble(210);
|
98 |
if (grp.hasCode(220)) |
99 |
xtruY = grp.getDataAsDouble(220);
|
100 |
if (grp.hasCode(230)) |
101 |
xtruZ = grp.getDataAsDouble(230);
|
102 |
|
103 |
if ((entity.flags & 0x01) == 0x01) { |
104 |
entity.closed = true;
|
105 |
} |
106 |
lastEntity = entity; |
107 |
} |
108 |
|
109 |
public void endSeq() throws Exception { |
110 |
DxfPolyline polyline = (DxfPolyline)lastEntity; |
111 |
if (polyline.closed) {
|
112 |
((DxfPolyline) lastEntity).add(firstPt); |
113 |
if (!(bulge==0)) { |
114 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
115 |
Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge); |
116 |
((DxfPolyline) lastEntity).pts.remove(cnt-1);
|
117 |
for (int i=0; i<arc.size(); i++) { |
118 |
Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
119 |
((DxfPolyline) lastEntity).add(pt); |
120 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
121 |
} |
122 |
bulge = 0.0;
|
123 |
} |
124 |
} |
125 |
if (addingToBlock == false) { |
126 |
//System.out.println("createPolyline: A?adimos una polilinea a la lista de entidades");
|
127 |
entities.add(lastEntity); |
128 |
} else {
|
129 |
//System.out.println("createPolyline: A?adimos una polilinea al bloque " + iterator);
|
130 |
blk.add(lastEntity); |
131 |
//System.out.println("PLINE color="+polyline.getColor());
|
132 |
} |
133 |
lastEntity = null;
|
134 |
xtruX = 0.0;
|
135 |
xtruY = 0.0;
|
136 |
xtruZ = 1.0;
|
137 |
bulge = 0.0;
|
138 |
} |
139 |
|
140 |
public void addVertex(DxfGroupVector grp) throws Exception { |
141 |
double x = 0.0, y = 0.0, z = 0.0; |
142 |
int flags = 0; |
143 |
x = grp.getDataAsDouble(10);
|
144 |
y = grp.getDataAsDouble(20);
|
145 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
146 |
if (grp.hasCode(70)) { |
147 |
flags = grp.getDataAsInt(70);
|
148 |
} |
149 |
//bulge = 0.0;
|
150 |
if (bulge == 0.0) { |
151 |
if (grp.hasCode(42)) { |
152 |
bulge = grp.getDataAsDouble(42);
|
153 |
//bulge = 0.0;
|
154 |
} else { bulge = 0.0; } |
155 |
Point3D point_in = new Point3D(x, y, z);
|
156 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
157 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
158 |
if ((flags & 0x80) == 0x80 && (flags & 0x40) == 0) { |
159 |
int [] face = {0,0,0,0}; |
160 |
face[0] = grp.getDataAsInt(71); |
161 |
face[1] = grp.getDataAsInt(72); |
162 |
face[2] = grp.getDataAsInt(73); |
163 |
face[3] = grp.getDataAsInt(74); |
164 |
((DxfPolyline) lastEntity).addFace(face); |
165 |
} else {
|
166 |
x = point_out.getX(); |
167 |
y = point_out.getY(); |
168 |
Point2D pt = proj.createPoint( x, y);
|
169 |
((DxfPolyline) lastEntity).add(pt); |
170 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
171 |
} |
172 |
} else if (bulge > 0.0) { |
173 |
double bulge_aux = 0.0; |
174 |
if (grp.hasCode(42)) { |
175 |
bulge_aux = grp.getDataAsDouble(42);
|
176 |
} else { bulge_aux = 0.0; } |
177 |
Point3D point_in = new Point3D(x, y, z);
|
178 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
179 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
180 |
x = point_out.getX(); |
181 |
y = point_out.getY(); |
182 |
Point2D pt = proj.createPoint( x, y);
|
183 |
((DxfPolyline) lastEntity).add(pt); |
184 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
185 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
186 |
Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge); |
187 |
((DxfPolyline) lastEntity).pts.remove(cnt-1);
|
188 |
for (int i=0; i<arc.size(); i++) { |
189 |
pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
190 |
((DxfPolyline) lastEntity).add(pt); |
191 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
192 |
} |
193 |
bulge = bulge_aux; |
194 |
} else { //si el bulge es menor que cero. |
195 |
double bulge_aux = 0.0; |
196 |
if (grp.hasCode(42)) { |
197 |
bulge_aux = grp.getDataAsDouble(42); // * (-1.0); |
198 |
} else { bulge_aux = 0.0; } |
199 |
Point3D point_in = new Point3D(x, y, z);
|
200 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
201 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
202 |
x = point_out.getX(); |
203 |
y = point_out.getY(); |
204 |
Point2D pt = proj.createPoint( x, y);
|
205 |
((DxfPolyline) lastEntity).add(pt); |
206 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
207 |
int cnt = ((DxfPolyline) lastEntity).pts.size();
|
208 |
Vector arc = DxfPolyline.createArc((Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-2)), (Point2D)(((DxfPolyline) lastEntity).pts.get(cnt-1)), bulge); |
209 |
((DxfPolyline) lastEntity).pts.remove(cnt-1);
|
210 |
for (int i=0; i<arc.size(); i++) { |
211 |
pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
212 |
((DxfPolyline) lastEntity).add(pt); |
213 |
if (((DxfPolyline)lastEntity).pts.size() == 1) firstPt = pt; |
214 |
} |
215 |
bulge = bulge_aux; |
216 |
} |
217 |
} |
218 |
|
219 |
public void createLwPolyline(DxfGroupVector grp) throws Exception { |
220 |
double x = 0.0, y = 0.0, elev=0.0; |
221 |
DxfGroup g = null;
|
222 |
|
223 |
if (grp.hasCode(38)) |
224 |
elev = grp.getDataAsDouble(38);
|
225 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
226 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
227 |
for (int i=0; i<grp.size(); i++) { |
228 |
g = (DxfGroup) grp.get(i); |
229 |
if (g.getCode() == 10) |
230 |
x = ((Double) g.getData()).doubleValue();
|
231 |
else if (g.getCode() == 20) { |
232 |
y = ((Double) g.getData()).doubleValue();
|
233 |
//if (y <= 1.0) throw new Exception("Y == "+y);
|
234 |
entity.add( proj.createPoint( x, y ) ); |
235 |
x = 0.0; y = 0.0; |
236 |
} |
237 |
} |
238 |
if (grp.hasCode(62)) { |
239 |
entity.dxfColor = grp.getDataAsInt(62);
|
240 |
} else {
|
241 |
//entity.dxfColor = 0;
|
242 |
} |
243 |
if (grp.hasCode(70)) |
244 |
entity.flags = grp.getDataAsInt(70);
|
245 |
if ((entity.flags & 0x01) == 0x01) { |
246 |
entity.closed = true;
|
247 |
} |
248 |
if (addingToBlock == false) { |
249 |
entities.add(entity); |
250 |
} else {
|
251 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
252 |
blk.add(entity); |
253 |
} |
254 |
} |
255 |
public void createLine(DxfGroupVector grp) throws Exception { |
256 |
double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0; |
257 |
DxfGroup g = null;
|
258 |
Point2D pt1 = null, pt2 = null; |
259 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
260 |
|
261 |
x = grp.getDataAsDouble(10);
|
262 |
y = grp.getDataAsDouble(20);
|
263 |
if (grp.hasCode(30)) z1 = grp.getDataAsDouble(30); |
264 |
pt1 = proj.createPoint(x, y); |
265 |
x = grp.getDataAsDouble(11);
|
266 |
y = grp.getDataAsDouble(21);
|
267 |
if (grp.hasCode(31)) z2 = grp.getDataAsDouble(31); |
268 |
pt2 = proj.createPoint(x, y); |
269 |
if (grp.hasCode(210)) |
270 |
xtruX = grp.getDataAsDouble(210);
|
271 |
if (grp.hasCode(220)) |
272 |
xtruY = grp.getDataAsInt(220);
|
273 |
if (grp.hasCode(230)) |
274 |
xtruZ = grp.getDataAsInt(230);
|
275 |
Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
276 |
Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
277 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
278 |
Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
279 |
Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
280 |
pt1.setLocation(point_out1); |
281 |
pt2.setLocation(point_out2); |
282 |
DxfLine entity = new DxfLine(proj, layer, pt1, pt2);
|
283 |
if (grp.hasCode(62)) { |
284 |
entity.dxfColor = grp.getDataAsInt(62);
|
285 |
} else {
|
286 |
//entity.dxfColor = 0;
|
287 |
} |
288 |
if (addingToBlock == false) { |
289 |
//System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
290 |
entities.add(entity); |
291 |
} else {
|
292 |
//System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
293 |
blk.add(entity); |
294 |
} |
295 |
} |
296 |
public void createText(DxfGroupVector grp) throws Exception { |
297 |
double x = 0.0, y = 0.0, h= 0.0, rot= 0.0; |
298 |
DxfGroup g = null;
|
299 |
Point2D pt1 = null, pt2 = null; |
300 |
String txt = null; |
301 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
302 |
|
303 |
txt = grp.getDataAsString(1);
|
304 |
DxfText entity = new DxfText(proj, layer, txt);
|
305 |
|
306 |
x = grp.getDataAsDouble(10);
|
307 |
y = grp.getDataAsDouble(20);
|
308 |
entity.setPt1(proj.createPoint(x, y)); |
309 |
if (grp.hasCode(11)) { |
310 |
x = grp.getDataAsDouble(11);
|
311 |
y = grp.getDataAsDouble(21);
|
312 |
entity.setPt2(proj.createPoint(x, y)); |
313 |
} |
314 |
entity.setHeight(grp.getDataAsDouble(40));
|
315 |
if (grp.hasCode(50)) { |
316 |
entity.setRotation(grp.getDataAsDouble(50));
|
317 |
//System.out.println("AAAAAA: entity.getRotation = " + entity.getRotation());
|
318 |
} |
319 |
if (grp.hasCode(62)) { |
320 |
entity.dxfColor = grp.getDataAsInt(62);
|
321 |
} else {
|
322 |
//entity.dxfColor = 0;
|
323 |
} |
324 |
if (grp.hasCode(72)) |
325 |
entity.align = grp.getDataAsInt(72);
|
326 |
if (addingToBlock == false) { |
327 |
entities.add(entity); |
328 |
} else {
|
329 |
//System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
330 |
blk.add(entity); |
331 |
} |
332 |
} |
333 |
public void createPoint(DxfGroupVector grp) throws Exception { |
334 |
double x = 0.0, y = 0.0, z = 0.0; //, h= 0.0, rot= 0.0; |
335 |
DxfGroup g = null;
|
336 |
Point2D pt = null; |
337 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
338 |
|
339 |
DxfPoint entity = new DxfPoint(proj, layer);
|
340 |
|
341 |
x = grp.getDataAsDouble(10);
|
342 |
y = grp.getDataAsDouble(20);
|
343 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
344 |
if (grp.hasCode(62)) { |
345 |
entity.dxfColor = grp.getDataAsInt(62);
|
346 |
} else {
|
347 |
//entity.dxfColor = 0;
|
348 |
} |
349 |
if (grp.hasCode(210)) |
350 |
xtruX = grp.getDataAsDouble(210);
|
351 |
if (grp.hasCode(220)) |
352 |
xtruY = grp.getDataAsInt(220);
|
353 |
if (grp.hasCode(230)) |
354 |
xtruZ = grp.getDataAsInt(230);
|
355 |
Point3D point_in = new Point3D(x, y, z);
|
356 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
357 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
358 |
x = point_out.getX(); |
359 |
y = point_out.getY(); |
360 |
entity.setPt(proj.createPoint(x, y)); |
361 |
if (addingToBlock == false) { |
362 |
entities.add(entity); |
363 |
} else {
|
364 |
//System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
|
365 |
blk.add(entity); |
366 |
} |
367 |
} |
368 |
public void createCircle(DxfGroupVector grp) throws Exception { |
369 |
double x = 0.0, y = 0.0, z = 0.0; |
370 |
double r = 0.0; |
371 |
DxfGroup g = null;
|
372 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
373 |
|
374 |
x = grp.getDataAsDouble(10);
|
375 |
y = grp.getDataAsDouble(20);
|
376 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
377 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
378 |
if (grp.hasCode(210)) |
379 |
xtruX = grp.getDataAsDouble(210);
|
380 |
if (grp.hasCode(220)) |
381 |
xtruY = grp.getDataAsDouble(220);
|
382 |
if (grp.hasCode(230)) |
383 |
xtruZ = grp.getDataAsDouble(230);
|
384 |
Point3D point_in = new Point3D(x, y, z);
|
385 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
386 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
387 |
x = point_out.getX(); |
388 |
y = point_out.getY(); |
389 |
|
390 |
Point2D center = proj.createPoint( x, y);
|
391 |
Point2D[] pts = new Point2D[360]; |
392 |
int angulo = 0; |
393 |
for (angulo=0; angulo<360; angulo++) { |
394 |
pts[angulo] = new Point2D.Double(center.getX(), center.getY()); |
395 |
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)); |
396 |
if (pts.length == 1) { |
397 |
firstPt = pts[angulo]; |
398 |
} |
399 |
} |
400 |
DxfCircle entity = new DxfCircle(proj, layer, pts);
|
401 |
if (grp.hasCode(62)) { |
402 |
entity.dxfColor = grp.getDataAsInt(62);
|
403 |
} else {
|
404 |
//entity.dxfColor = 0;
|
405 |
} |
406 |
if (addingToBlock == false) { |
407 |
//System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
408 |
entities.add(entity); |
409 |
} else {
|
410 |
//System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
411 |
blk.add(entity); |
412 |
} |
413 |
} |
414 |
public void createArc(DxfGroupVector grp) throws Exception { |
415 |
double x = 0.0, y = 0.0, z = 0.0; |
416 |
double r = 0.0, empieza = 0.0, acaba = 0.0; |
417 |
DxfGroup g = null;
|
418 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
419 |
|
420 |
x = grp.getDataAsDouble(10);
|
421 |
y = grp.getDataAsDouble(20);
|
422 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
423 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
424 |
if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50); |
425 |
if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51); |
426 |
if (grp.hasCode(210)) |
427 |
xtruX = grp.getDataAsDouble(210);
|
428 |
if (grp.hasCode(220)) |
429 |
xtruY = grp.getDataAsDouble(220);
|
430 |
if (grp.hasCode(230)) |
431 |
xtruZ = grp.getDataAsDouble(230);
|
432 |
Point3D point_in = new Point3D(x, y, z);
|
433 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
434 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
435 |
x = point_out.getX(); |
436 |
y = point_out.getY(); |
437 |
|
438 |
Point2D center = proj.createPoint( x, y);
|
439 |
//System.out.println("empieza = " + empieza + ", acaba = " + acaba);
|
440 |
int iempieza = (int)empieza; |
441 |
int iacaba = (int)acaba; |
442 |
//System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
|
443 |
double angulo = 0; |
444 |
Point2D[] pts = null; |
445 |
if (empieza <= acaba) {
|
446 |
pts = new Point2D[(iacaba-iempieza)+2]; |
447 |
angulo = empieza; |
448 |
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)); |
449 |
for (int i=1; i<=(iacaba-iempieza)+1; i++) { |
450 |
angulo = (double)(iempieza+i);
|
451 |
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)); |
452 |
} |
453 |
angulo = acaba; |
454 |
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)); |
455 |
} else {
|
456 |
pts = new Point2D[(360-iempieza)+iacaba+2]; |
457 |
angulo = empieza; |
458 |
//System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
|
459 |
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)); |
460 |
for (int i=1; i<=(360-iempieza); i++) { |
461 |
angulo = (double)(iempieza+i);
|
462 |
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)); |
463 |
} |
464 |
for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) { |
465 |
angulo = (double)(i-(360-iempieza)); |
466 |
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)); |
467 |
} |
468 |
angulo = acaba; |
469 |
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)); |
470 |
} |
471 |
DxfArc entity = new DxfArc(proj, layer, pts);
|
472 |
if (grp.hasCode(62)) { |
473 |
entity.dxfColor = grp.getDataAsInt(62);
|
474 |
} else {
|
475 |
//entity.dxfColor = 0;
|
476 |
} |
477 |
//System.out.println("createArc(): A?adimos un arco al bloque");
|
478 |
if (addingToBlock == false) { |
479 |
entities.add(entity); |
480 |
} else {
|
481 |
//System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
|
482 |
blk.add(entity); |
483 |
} |
484 |
} |
485 |
|
486 |
/**
|
487 |
* TODO Detectados fallos en las rotaciones de bloques. Hoja 72231.
|
488 |
* Detectado en los bloques correspondientes a campos de futbol,
|
489 |
* de tipo solid.
|
490 |
*/
|
491 |
public void createInsert(DxfGroupVector grp) throws Exception { |
492 |
double x = 0.0, y = 0.0, z = 0.0; |
493 |
DxfGroup g = null;
|
494 |
Point2D pt = new Point2D.Double(0.0, 0.0); |
495 |
Point2D scaleFactor = new Point2D.Double(1.0, 1.0); |
496 |
double rotAngle = 0.0; |
497 |
String blockName = ""; |
498 |
|
499 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
500 |
|
501 |
DxfInsert entity = new DxfInsert(proj, layer);
|
502 |
DxfPoint secondEntity = new DxfPoint(proj, layer);
|
503 |
|
504 |
if (grp.hasCode(2)) { |
505 |
blockName = grp.getDataAsString(2);
|
506 |
entity.setBlockName(blockName); |
507 |
} |
508 |
if (grp.hasCode(10)) x = grp.getDataAsDouble(10); |
509 |
if (grp.hasCode(20)) y = grp.getDataAsDouble(20); |
510 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
511 |
if (grp.hasCode(41)) { |
512 |
scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
|
513 |
entity.setScaleFactor(scaleFactor); |
514 |
} else {
|
515 |
entity.setScaleFactor(scaleFactor); |
516 |
} |
517 |
if (grp.hasCode(42)) { |
518 |
scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
|
519 |
entity.setScaleFactor(scaleFactor); |
520 |
} else {
|
521 |
entity.setScaleFactor(scaleFactor); |
522 |
} |
523 |
if (grp.hasCode(43)) { |
524 |
// TODO La coordenada z
|
525 |
} |
526 |
if (grp.hasCode(50)) { |
527 |
rotAngle = grp.getDataAsDouble(50);
|
528 |
entity.setRotAngle(rotAngle); |
529 |
} |
530 |
if (grp.hasCode(62)) { |
531 |
entity.dxfColor = grp.getDataAsInt(62);
|
532 |
} else {
|
533 |
//entity.dxfColor = 0;
|
534 |
} |
535 |
if (grp.hasCode(210)) |
536 |
xtruX = grp.getDataAsDouble(210);
|
537 |
if (grp.hasCode(220)) |
538 |
xtruY = grp.getDataAsDouble(220);
|
539 |
if (grp.hasCode(230)) |
540 |
xtruZ = grp.getDataAsDouble(230);
|
541 |
Point3D point_in = new Point3D(x, y, z);
|
542 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
543 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
544 |
x = point_out.getX(); |
545 |
y = point_out.getY(); |
546 |
|
547 |
entity.setBlkList(blkList); |
548 |
|
549 |
entity.encuentraBloque(blockName); |
550 |
|
551 |
entity.setPt(proj.createPoint(x, y)); |
552 |
secondEntity.setPt(proj.createPoint(x, y)); |
553 |
|
554 |
gestionaInsert(entity, layer); |
555 |
|
556 |
System.out.println("createInsert: entity.getBlockName = " + entity.getBlockName()); |
557 |
System.out.println("createInsert: entity.getRotAngle = " + entity.getRotAngle()); |
558 |
|
559 |
if (addingToBlock == false) { |
560 |
entities.add(secondEntity); |
561 |
} else if (addingToBlock == true && entity.blockFound == true) { |
562 |
//System.out.println("createArc(): A?adimos un insert al bloque " + iterator);
|
563 |
blk.add(entity); |
564 |
} |
565 |
} |
566 |
|
567 |
public void createSolid(DxfGroupVector grp) throws Exception { |
568 |
double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0, z3 = 0.0, z4 = 0.0; |
569 |
DxfGroup g = null;
|
570 |
//Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
|
571 |
Point2D[] pts = new Point2D[4]; |
572 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
573 |
|
574 |
x = grp.getDataAsDouble(10);
|
575 |
y = grp.getDataAsDouble(20);
|
576 |
if (grp.hasCode(30)) z1 = grp.getDataAsDouble(30); |
577 |
pts[0] = proj.createPoint(x, y);
|
578 |
x = grp.getDataAsDouble(11);
|
579 |
y = grp.getDataAsDouble(21);
|
580 |
if (grp.hasCode(31)) z2 = grp.getDataAsDouble(31); |
581 |
pts[1] = proj.createPoint(x, y);
|
582 |
x = grp.getDataAsDouble(12);
|
583 |
y = grp.getDataAsDouble(22);
|
584 |
if (grp.hasCode(32)) z3 = grp.getDataAsDouble(32); |
585 |
pts[2] = proj.createPoint(x, y);
|
586 |
x = grp.getDataAsDouble(13);
|
587 |
y = grp.getDataAsDouble(23);
|
588 |
if (grp.hasCode(33)) z2 = grp.getDataAsDouble(33); |
589 |
pts[3] = proj.createPoint(x, y);
|
590 |
if (grp.hasCode(210)) |
591 |
xtruX = grp.getDataAsDouble(210);
|
592 |
if (grp.hasCode(220)) |
593 |
xtruY = grp.getDataAsDouble(220);
|
594 |
if (grp.hasCode(230)) |
595 |
xtruZ = grp.getDataAsDouble(230);
|
596 |
Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1); |
597 |
Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2); |
598 |
Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3); |
599 |
Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4); |
600 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
601 |
Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
602 |
Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
603 |
Point2D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru);
|
604 |
Point2D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru);
|
605 |
pts[0].setLocation(point_out1);
|
606 |
pts[1].setLocation(point_out2);
|
607 |
pts[2].setLocation(point_out3);
|
608 |
pts[3].setLocation(point_out4);
|
609 |
DxfSolid entity = new DxfSolid(proj, layer, pts);
|
610 |
if (grp.hasCode(62)) { |
611 |
entity.dxfColor = grp.getDataAsInt(62);
|
612 |
} else {
|
613 |
//entity.dxfColor = 0;
|
614 |
} |
615 |
if (addingToBlock == false) { |
616 |
//System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
617 |
entities.add(entity); |
618 |
} else {
|
619 |
//System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
620 |
blk.add(entity); |
621 |
} |
622 |
} |
623 |
/**
|
624 |
* Los Splines estan implementados como LwPolylines. Se pintan las lineas
|
625 |
* entre los vertices pero no se aplica la curvatura Spline.
|
626 |
* TODO Contemplar la curvatura spline para Splines.
|
627 |
*/
|
628 |
public void createSpline(DxfGroupVector grp) throws Exception { |
629 |
double x = 0.0, y = 0.0, elev=0.0; |
630 |
DxfGroup g = null;
|
631 |
|
632 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
633 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
634 |
for (int i=0; i<grp.size(); i++) { |
635 |
g = (DxfGroup) grp.get(i); |
636 |
if (g.getCode() == 10) |
637 |
x = ((Double) g.getData()).doubleValue();
|
638 |
else if (g.getCode() == 20) { |
639 |
y = ((Double) g.getData()).doubleValue();
|
640 |
//if (y <= 1.0) throw new Exception("Y == "+y);
|
641 |
entity.add( proj.createPoint( x, y ) ); |
642 |
x = 0.0; y = 0.0; |
643 |
} |
644 |
} |
645 |
if (grp.hasCode(62)) { |
646 |
entity.dxfColor = grp.getDataAsInt(62);
|
647 |
} else {
|
648 |
//entity.dxfColor = 0;
|
649 |
} |
650 |
if (grp.hasCode(70)) |
651 |
entity.flags = grp.getDataAsInt(70);
|
652 |
if ((entity.flags & 0x01) == 0x01) { |
653 |
entity.closed = true;
|
654 |
} |
655 |
if (addingToBlock == false) { |
656 |
entities.add(entity); |
657 |
} else {
|
658 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
659 |
blk.add(entity); |
660 |
} |
661 |
} |
662 |
public void createBlock(DxfGroupVector grp) throws Exception { |
663 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
664 |
blk = new DxfBlock(proj);
|
665 |
|
666 |
Point2D basePoint = new Point2D.Double(); |
667 |
String blockName = ""; |
668 |
//System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
|
669 |
|
670 |
addingToBlock = true;
|
671 |
//System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
|
672 |
blkList.add(iterator, blk); |
673 |
|
674 |
//System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
|
675 |
if (grp.hasCode(1)) { |
676 |
blockName = grp.getDataAsString(1);
|
677 |
blk.setBlkName(blockName); |
678 |
} |
679 |
if (grp.hasCode(2)) { |
680 |
blockName = grp.getDataAsString(2);
|
681 |
blk.setBlkName(blockName); |
682 |
} |
683 |
if (grp.hasCode(3)) { |
684 |
blockName = grp.getDataAsString(3);
|
685 |
blk.setBlkName(blockName); |
686 |
} |
687 |
if (grp.hasCode(10)) { |
688 |
basePoint.setLocation(grp.getDataAsDouble(10), basePoint.getY());
|
689 |
blk.setBPoint(basePoint); |
690 |
} |
691 |
if (grp.hasCode(20)) { |
692 |
basePoint.setLocation(basePoint.getX(), grp.getDataAsDouble(20));
|
693 |
blk.setBPoint(basePoint); |
694 |
} |
695 |
if (grp.hasCode(30)) { |
696 |
// TODO Contemplar la coordenada z
|
697 |
} |
698 |
if (grp.hasCode(70)) { |
699 |
blk.flags = grp.getDataAsInt(70);
|
700 |
} |
701 |
} |
702 |
public void endBlk(DxfGroupVector grp) throws Exception { |
703 |
//DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
704 |
setAddingToBlock(false);
|
705 |
iterator = iterator + 1;
|
706 |
} |
707 |
|
708 |
public void testBlocks() { |
709 |
Vector blkList = getBlkList();
|
710 |
DxfBlock dxfBlock = null;
|
711 |
DxfEntity dxfEntity = null;
|
712 |
DxfLine dxfLine = null;
|
713 |
DxfInsert dxfInsert = null;
|
714 |
Point2D point1 = new Point2D.Double(); |
715 |
Point2D point2 = new Point2D.Double(); |
716 |
for (int i=0; i<blkList.size(); i++) { |
717 |
dxfBlock = (DxfBlock)blkList.get(i); |
718 |
int aux = dxfBlock.getBlkElements().size();
|
719 |
for (int j=0; j<aux; j++) { |
720 |
dxfEntity = (DxfEntity)dxfBlock.getBlkElements().get(j); |
721 |
if (dxfEntity instanceof DxfLine) { |
722 |
dxfLine = (DxfLine)dxfEntity; |
723 |
point1 = dxfLine.getPts()[0];
|
724 |
point2 = dxfLine.getPts()[1];
|
725 |
//System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", vertice1 = " + point1 + ", vertice2 = " + point2);
|
726 |
} else if (dxfEntity instanceof DxfInsert){ |
727 |
dxfInsert = (DxfInsert)dxfEntity; |
728 |
String nomBlock = dxfInsert.getBlockName();
|
729 |
//System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", inserta el bloque = " + nomBlock);
|
730 |
//System.out.println("compruebaBloques(): dxfInsert.pt = " + dxfInsert.getPt());
|
731 |
//System.out.println("compruebaBloques(): dxfInsert.rotAngle = " + dxfInsert.getRotAngle());
|
732 |
//System.out.println("compruebaBloques(): dxfInsert.scaleFactor = " + dxfInsert.getScaleFactor());
|
733 |
|
734 |
if (dxfInsert.getBlockFound() == false) { |
735 |
//System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock);
|
736 |
boolean aux_bool = dxfInsert.encuentraBloque(nomBlock);
|
737 |
gestionaInsert(dxfInsert, dxfInsert.getDxfLayer()); |
738 |
dxfBlock.add(dxfInsert); |
739 |
} |
740 |
|
741 |
} |
742 |
} |
743 |
} |
744 |
} |
745 |
|
746 |
/**
|
747 |
* Cambia de proyeccion.
|
748 |
*
|
749 |
* @param rp
|
750 |
*/
|
751 |
public void setProjection(IProjection proj) { this.proj = proj;} |
752 |
public IProjection getProjection() { return proj;} |
753 |
|
754 |
public void reProject(ICoordTrans rp) { |
755 |
entities.reProject(rp); |
756 |
setProjection(rp.getPDest()); |
757 |
} |
758 |
|
759 |
public DxfEntityList getEntities() { return entities;} |
760 |
public DxfTable getLayers() { return layers;} |
761 |
|
762 |
public DxfBlock getBlk() {
|
763 |
return blk;
|
764 |
} |
765 |
|
766 |
public void gestionaInsert(DxfInsert entity, DxfLayer layer) { |
767 |
DxfEntity dxfEntity = null;
|
768 |
DxfLine dxfLine = null;
|
769 |
DxfInsert dxfInsert = null;
|
770 |
DxfPolyline dxfPolyline = null;
|
771 |
DxfArc dxfArc = null;
|
772 |
DxfCircle dxfCircle = null;
|
773 |
DxfLwPolyline dxfLwPolyline = null;
|
774 |
DxfPoint dxfPoint = null;
|
775 |
DxfText dxfText = null;
|
776 |
DxfSolid dxfSolid = null;
|
777 |
for (int i=0; i<entity.block.size(); i++) { |
778 |
//System.out.println("gestionaInserts: entity.block.blkElements.size() = " + entity.block.blkElements.size());
|
779 |
dxfEntity = (DxfEntity)entity.block.get(i); |
780 |
|
781 |
Point2D point1 = new Point2D.Double(); |
782 |
Point2D point2 = new Point2D.Double(); |
783 |
Point2D point11 = new Point2D.Double(); |
784 |
Point2D point22 = new Point2D.Double(); |
785 |
if (dxfEntity instanceof DxfLine) { |
786 |
dxfLine = (DxfLine)dxfEntity; |
787 |
point1 = dxfLine.getPts()[0];
|
788 |
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()); |
789 |
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()); |
790 |
point11.setLocation(laX, laY); |
791 |
point2 = dxfLine.getPts()[1];
|
792 |
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())); |
793 |
DxfLine dxfLinee = new DxfLine(proj, layer, point11, point22);
|
794 |
if (addingToBlock == false) { |
795 |
entities.add(dxfLinee); |
796 |
} |
797 |
} else if (dxfEntity instanceof DxfInsert){ |
798 |
dxfInsert = (DxfInsert)dxfEntity; |
799 |
point1 = dxfInsert.pt; |
800 |
//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()));
|
801 |
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())); |
802 |
DxfInsert dxfInsertt = new DxfInsert(proj, layer);
|
803 |
|
804 |
dxfInsertt.pt = point11; |
805 |
|
806 |
dxfInsertt.blkList = dxfInsert.blkList; |
807 |
dxfInsertt.block = dxfInsert.block; |
808 |
dxfInsertt.blockName = dxfInsert.blockName; |
809 |
dxfInsertt.layer = dxfInsert.layer; |
810 |
dxfInsertt.proj = dxfInsert.proj; |
811 |
dxfInsertt.rotAngle = dxfInsert.rotAngle; // * entity.rotAngle;
|
812 |
|
813 |
dxfInsertt.scaleFactor = new Point2D.Double(dxfInsert.scaleFactor.getX() * entity.scaleFactor.getX(), dxfInsert.scaleFactor.getY() * entity.scaleFactor.getY()); |
814 |
|
815 |
gestionaInsert(dxfInsertt, layer); |
816 |
} else if (dxfEntity instanceof DxfPolyline) { |
817 |
dxfPolyline = (DxfPolyline)dxfEntity; |
818 |
DxfPolyline dxfPolylinee = new DxfPolyline(proj, layer);
|
819 |
if (dxfPolyline.closed) dxfPolylinee.closed = true; |
820 |
Point2D[] points = new Point2D[dxfPolyline.pts.size()]; |
821 |
Point2D[] pointss = new Point2D[dxfPolyline.pts.size()]; |
822 |
for (int j=0; j<dxfPolyline.pts.size(); j++) { |
823 |
points[j] = (Point2D)dxfPolyline.pts.get(j);
|
824 |
pointss[j] = new Point2D.Double(); |
825 |
//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()));
|
826 |
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())); |
827 |
//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()));
|
828 |
dxfPolylinee.add(pointss[j]); |
829 |
} |
830 |
if (addingToBlock == false) entities.add(dxfPolylinee); |
831 |
} else if (dxfEntity instanceof DxfArc) { |
832 |
dxfArc = (DxfArc)dxfEntity; |
833 |
Point2D[] points = new Point2D[dxfArc.pts.length]; |
834 |
Point2D[] pointss = new Point2D[dxfArc.pts.length]; |
835 |
for (int j=0; j<dxfArc.pts.length; j++) { |
836 |
points[j] = (Point2D)dxfArc.pts[j];
|
837 |
pointss[j] = new Point2D.Double(); |
838 |
//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()));
|
839 |
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())); |
840 |
//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()));
|
841 |
} |
842 |
DxfArc dxfArcc = new DxfArc(proj, layer, pointss);
|
843 |
if (addingToBlock == false) entities.add(dxfArcc); |
844 |
} else if (dxfEntity instanceof DxfCircle) { |
845 |
dxfCircle = (DxfCircle)dxfEntity; |
846 |
Point2D[] points = new Point2D[dxfCircle.pts.length]; |
847 |
Point2D[] pointss = new Point2D[dxfCircle.pts.length]; |
848 |
for (int j=0; j<dxfCircle.pts.length; j++) { |
849 |
points[j] = (Point2D)dxfCircle.pts[j];
|
850 |
pointss[j] = new Point2D.Double(); |
851 |
//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()));
|
852 |
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())); |
853 |
//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()));
|
854 |
} |
855 |
DxfCircle dxfCirclee = new DxfCircle(proj, layer, pointss);
|
856 |
if (addingToBlock == false) entities.add(dxfCirclee); |
857 |
} else if (dxfEntity instanceof DxfLwPolyline) { |
858 |
dxfLwPolyline = (DxfLwPolyline)dxfEntity; |
859 |
DxfLwPolyline dxfLwPolylinee = new DxfLwPolyline(proj, layer);
|
860 |
Point2D[] points = new Point2D[dxfLwPolyline.pts.size()]; |
861 |
Point2D[] pointss = new Point2D[dxfLwPolyline.pts.size()]; |
862 |
for (int j=0; j<dxfLwPolyline.pts.size(); j++) { |
863 |
points[j] = (Point2D)dxfLwPolyline.pts.get(j);
|
864 |
pointss[j] = new Point2D.Double(); |
865 |
//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()));
|
866 |
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())); |
867 |
//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() - (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()));
|
868 |
dxfLwPolylinee.add(pointss[j]); |
869 |
} |
870 |
if (addingToBlock == false) entities.add(dxfLwPolylinee); |
871 |
} else if (dxfEntity instanceof DxfPoint) { |
872 |
dxfPoint = (DxfPoint)dxfEntity; |
873 |
point1 = dxfPoint.pt; |
874 |
//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()));
|
875 |
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())); |
876 |
//point11.setLocation(entity.pt.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() + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
877 |
DxfPoint dxfPointt = new DxfPoint(proj, layer);
|
878 |
dxfPointt.pt = point11; |
879 |
if (addingToBlock == false) entities.add(dxfPointt); |
880 |
} else if (dxfEntity instanceof DxfText) { |
881 |
dxfText = (DxfText)dxfEntity; |
882 |
point1 = dxfText.pts[0];
|
883 |
//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()));
|
884 |
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())); |
885 |
//point11.setLocation(entity.pt.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() + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
886 |
point2 = dxfText.pts[1];
|
887 |
//point22.setLocation(entity.pt.getX() - entity.block.bPoint.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() + ((point2.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point2.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
888 |
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())); |
889 |
//point22.setLocation(entity.pt.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() + ((point2.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point2.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
|
890 |
DxfText dxfTextt = new DxfText(proj, layer, dxfText.getText());
|
891 |
dxfTextt.pts[0] = point11;
|
892 |
dxfTextt.pts[1] = point22;
|
893 |
if (addingToBlock == false) entities.add(dxfTextt); |
894 |
} else if (dxfEntity instanceof DxfSolid) { |
895 |
dxfSolid = (DxfSolid)dxfEntity; |
896 |
Point2D[] points = new Point2D[dxfSolid.pts.length]; |
897 |
Point2D[] pointss = new Point2D[dxfSolid.pts.length]; |
898 |
for (int j=0; j<dxfSolid.pts.length; j++) { |
899 |
points[j] = (Point2D)dxfSolid.pts[j];
|
900 |
pointss[j] = new Point2D.Double(); |
901 |
//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()));
|
902 |
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())); |
903 |
//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()));
|
904 |
} |
905 |
DxfSolid dxfSolidd = new DxfSolid(proj, layer, pointss);
|
906 |
Point2D aux = dxfSolidd.pts[2]; |
907 |
dxfSolidd.pts[2] = dxfSolidd.pts[3]; |
908 |
dxfSolidd.pts[3] = aux;
|
909 |
if (addingToBlock == false) entities.add(dxfSolidd); |
910 |
} else {
|
911 |
System.out.println("gestionaInserts: Encontrado elemento desconocido"); |
912 |
} |
913 |
} |
914 |
} |
915 |
|
916 |
} |