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