svn-gvsig-desktop / tags / v1_0_2_Build_911 / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfFeatureMaker.java @ 11388
History | View | Annotate | Download (129 KB)
1 | 2809 | nacho | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | 44 | jmorell | package org.cresques.px.dxf; |
25 | |||
26 | 5404 | fjp | import java.awt.Graphics2D; |
27 | import java.awt.geom.AffineTransform; |
||
28 | import java.awt.geom.Point2D; |
||
29 | import java.util.Iterator; |
||
30 | import java.util.Vector; |
||
31 | |||
32 | 94 | luisw | import org.cresques.cts.ICoordTrans; |
33 | import org.cresques.cts.IProjection; |
||
34 | 44 | jmorell | import org.cresques.geo.Point3D; |
35 | import org.cresques.geo.Projected; |
||
36 | 91 | luisw | import org.cresques.geo.ViewPortData; |
37 | 44 | jmorell | import org.cresques.io.DxfFile; |
38 | import org.cresques.io.DxfGroup; |
||
39 | import org.cresques.io.DxfGroupVector; |
||
40 | import org.cresques.px.Extent; |
||
41 | 96 | luisw | import org.cresques.px.IObjList; |
42 | 44 | jmorell | import org.cresques.px.gml.Feature; |
43 | 73 | jmorell | import org.cresques.px.gml.FeatureCollection; |
44 | 2809 | nacho | import org.cresques.px.gml.InsPoint3D; |
45 | 44 | jmorell | import org.cresques.px.gml.LineString; |
46 | 2809 | nacho | import org.cresques.px.gml.LineString3D; |
47 | 44 | jmorell | import org.cresques.px.gml.Polygon; |
48 | 2809 | nacho | import org.cresques.px.gml.Polygon3D; |
49 | |||
50 | 44 | jmorell | |
51 | 2809 | nacho | /**
|
52 | * La clase DxfFeatureMaker facilita la creaci?n de entidades en un modelo de datos
|
||
53 | * GIS. La creaci?n se realiza partiendo de las entidades obtenidas de un fichero DXF.
|
||
54 | * @author jmorell
|
||
55 | */
|
||
56 | 44 | jmorell | public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected { |
57 | 2809 | nacho | IProjection proj = null;
|
58 | |||
59 | 3151 | jmorell | //Feature lastFeature = null;
|
60 | Feature lastFeaBordes = null;
|
||
61 | Feature lastFeaFondos = null;
|
||
62 | boolean isDoubleFeatured = false; |
||
63 | 2809 | nacho | FeatureCollection features = null;
|
64 | double bulge = 0.0; |
||
65 | double xtruX = 0.0; |
||
66 | double xtruY = 0.0; |
||
67 | double xtruZ = 1.0; |
||
68 | 44 | jmorell | int polylineFlag = 0; |
69 | 2809 | nacho | Point3D firstPt = new Point3D();
|
70 | Point3D ptAnterior = null;
|
||
71 | 57 | jmorell | boolean addingToBlock = false; |
72 | 73 | jmorell | int iterator = 0; |
73 | 2809 | nacho | FeatureCollection blk = null;
|
74 | Vector blkList = null; |
||
75 | DxfTable layers = null;
|
||
76 | private Vector faces = null; |
||
77 | private boolean hasFaces = false; |
||
78 | private int facesIterador = 1; |
||
79 | private Point2D facesFirstPoint = null; |
||
80 | private Vector attributes = null; |
||
81 | private boolean constantPolylineElevation; |
||
82 | private double lastVertexElevation; |
||
83 | private boolean dxf3DFile; |
||
84 | |||
85 | /**
|
||
86 | * Constructor de DxfFeatureMaker.
|
||
87 | * @param proj, proyecci?n cartogr?fica en la que se encontrar?n las entidades
|
||
88 | * que creemos.
|
||
89 | */
|
||
90 | public DxfFeatureMaker(IProjection proj) {
|
||
91 | this.proj = proj;
|
||
92 | layers = new DxfTable();
|
||
93 | features = new FeatureCollection(proj);
|
||
94 | blkList = new Vector(); |
||
95 | attributes = new Vector(); |
||
96 | dxf3DFile = false;
|
||
97 | } |
||
98 | 57 | jmorell | |
99 | 2809 | nacho | /* (non-Javadoc)
|
100 | * @see org.cresques.io.DxfFile.EntityFactory#setAddingToBlock(boolean)
|
||
101 | */
|
||
102 | public void setAddingToBlock(boolean a) { |
||
103 | addingToBlock = a; |
||
104 | } |
||
105 | 44 | jmorell | |
106 | 2809 | nacho | /* (non-Javadoc)
|
107 | * @see org.cresques.io.DxfFile.EntityFactory#createLayer(org.cresques.io.DxfGroupVector)
|
||
108 | */
|
||
109 | public void createLayer(DxfGroupVector v) throws Exception { |
||
110 | int color = v.getDataAsInt(62); |
||
111 | DxfLayer layer = new DxfLayer(v.getDataAsString(2), |
||
112 | Math.abs(v.getDataAsInt(62))); |
||
113 | 57 | jmorell | |
114 | 2809 | nacho | if (color < 0) { |
115 | layer.isOff = true;
|
||
116 | } |
||
117 | 128 | jmorell | |
118 | 2809 | nacho | layer.lType = v.getDataAsString(6);
|
119 | layer.setFlags(v.getDataAsInt(70));
|
||
120 | 44 | jmorell | |
121 | 2809 | nacho | // compruebo flags
|
122 | if ((layer.flags & 0x01) == 0x01) { |
||
123 | layer.frozen = true;
|
||
124 | } |
||
125 | 44 | jmorell | |
126 | 2809 | nacho | if ((layer.flags & 0x02) == 0x02) { |
127 | layer.frozen = true;
|
||
128 | } |
||
129 | 44 | jmorell | |
130 | 2809 | nacho | System.out.println("LAYER color=" + layer.getColor()); |
131 | 44 | jmorell | |
132 | 2809 | nacho | layers.add(layer); |
133 | } |
||
134 | 44 | jmorell | |
135 | 2809 | nacho | /* (non-Javadoc)
|
136 | * @see org.cresques.io.DxfFile.EntityFactory#createPolyline(org.cresques.io.DxfGroupVector)
|
||
137 | */
|
||
138 | public void createPolyline(DxfGroupVector grp) throws Exception { |
||
139 | LineString3D lineString3D = new LineString3D();
|
||
140 | Polygon3D polygon3D = new Polygon3D();
|
||
141 | 44 | jmorell | |
142 | 3151 | jmorell | //Feature feature= new Feature();
|
143 | Feature feaBordes = new Feature();
|
||
144 | Feature feaFondos = new Feature();
|
||
145 | 2809 | nacho | double x = 0.0; |
146 | double y = 0.0; |
||
147 | double z = 0.0; |
||
148 | int flags = 0; |
||
149 | constantPolylineElevation = true;
|
||
150 | 44 | jmorell | |
151 | 2809 | nacho | // 041122: Cada polyline tiene asociado un objeto faces distinto.
|
152 | faces = new Vector(); |
||
153 | 44 | jmorell | |
154 | 3151 | jmorell | //feature.setProp("dxfEntity", "Polyline");
|
155 | feaBordes.setProp("dxfEntity", "Polyline"); |
||
156 | feaFondos.setProp("dxfEntity", "Polyline"); |
||
157 | 44 | jmorell | |
158 | 2809 | nacho | if (grp.hasCode(8)) { |
159 | 3151 | jmorell | //feature.setProp("layer", grp.getDataAsString(8));
|
160 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
161 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
162 | 2809 | nacho | } |
163 | 44 | jmorell | |
164 | 2809 | nacho | if (grp.hasCode(39)) { |
165 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
166 | String string = doub.toString();
|
||
167 | 44 | jmorell | |
168 | 3151 | jmorell | //feature.setProp("thickness", string);
|
169 | feaBordes.setProp("thickness", string);
|
||
170 | feaFondos.setProp("thickness", string);
|
||
171 | 2809 | nacho | } else {
|
172 | Double doub = new Double(0.0); |
||
173 | 44 | jmorell | |
174 | 3151 | jmorell | //feature.setProp("thickness", doub.toString());
|
175 | feaBordes.setProp("thickness", doub.toString());
|
||
176 | feaFondos.setProp("thickness", doub.toString());
|
||
177 | 2809 | nacho | } |
178 | 44 | jmorell | |
179 | 2809 | nacho | if (grp.hasCode(62)) { |
180 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
181 | String string = integer.toString();
|
||
182 | 44 | jmorell | |
183 | 3151 | jmorell | //feature.setProp("color", string);
|
184 | feaBordes.setProp("color", string);
|
||
185 | feaFondos.setProp("color", string);
|
||
186 | feaBordes.setProp("colorByLayer", "false"); |
||
187 | feaFondos.setProp("colorByLayer", "false"); |
||
188 | 2809 | nacho | } else {
|
189 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
190 | int clr = layer.colorNumber;
|
||
191 | Integer integer = new Integer(clr); |
||
192 | String string = integer.toString();
|
||
193 | 44 | jmorell | |
194 | 3151 | jmorell | //feature.setProp("color", string);
|
195 | feaBordes.setProp("color", string);
|
||
196 | feaFondos.setProp("color", string);
|
||
197 | feaBordes.setProp("colorByLayer", "true"); |
||
198 | feaFondos.setProp("colorByLayer", "true"); |
||
199 | 2809 | nacho | } |
200 | 44 | jmorell | |
201 | 2809 | nacho | if (grp.hasCode(10)) { |
202 | x = grp.getDataAsDouble(10);
|
||
203 | } |
||
204 | 82 | jmorell | |
205 | 2809 | nacho | if (grp.hasCode(20)) { |
206 | y = grp.getDataAsDouble(20);
|
||
207 | } |
||
208 | |||
209 | if (grp.hasCode(30)) { |
||
210 | z = grp.getDataAsDouble(30);
|
||
211 | |||
212 | if (z != 0.0) { |
||
213 | dxf3DFile = true;
|
||
214 | } |
||
215 | |||
216 | Double doub = new Double(z); |
||
217 | String string = doub.toString();
|
||
218 | |||
219 | 3151 | jmorell | //feature.setProp("elevation", string);
|
220 | feaBordes.setProp("elevation", string);
|
||
221 | feaFondos.setProp("elevation", string);
|
||
222 | 2809 | nacho | } else {
|
223 | Double doub = new Double(0.0); |
||
224 | |||
225 | 3151 | jmorell | //feature.setProp("elevation", doub.toString());
|
226 | feaBordes.setProp("elevation", doub.toString());
|
||
227 | feaFondos.setProp("elevation", doub.toString());
|
||
228 | 2809 | nacho | } |
229 | |||
230 | if (grp.hasCode(70)) { |
||
231 | flags = grp.getDataAsInt(70);
|
||
232 | } |
||
233 | |||
234 | if (grp.hasCode(210)) { |
||
235 | xtruX = grp.getDataAsDouble(210);
|
||
236 | } |
||
237 | |||
238 | if (grp.hasCode(220)) { |
||
239 | xtruY = grp.getDataAsDouble(220);
|
||
240 | } |
||
241 | |||
242 | if (grp.hasCode(230)) { |
||
243 | xtruZ = grp.getDataAsDouble(230);
|
||
244 | } |
||
245 | |||
246 | if (((flags & 0x01) == 0x01) || ((flags & 0x40) == 0x40)) { |
||
247 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
248 | feaFondos.setGeometry(polygon3D); |
||
249 | lastFeaBordes = feaBordes; |
||
250 | lastFeaFondos = feaFondos; |
||
251 | isDoubleFeatured = true;
|
||
252 | 2809 | nacho | } else if ((flags & 0x01) == 0x00) { |
253 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
254 | lastFeaBordes = feaBordes; |
||
255 | isDoubleFeatured = false;
|
||
256 | 2809 | nacho | } else {
|
257 | System.out.println("Detectada una Polyline Flag que no corresponde"); |
||
258 | System.out.println("a una Polyline corriente, ni a una Closed Polyline"); |
||
259 | } |
||
260 | } |
||
261 | |||
262 | /* (non-Javadoc)
|
||
263 | * @see org.cresques.io.DxfFile.EntityFactory#endSeq(org.cresques.io.DxfGroupVector)
|
||
264 | */
|
||
265 | public void endSeq() throws Exception { |
||
266 | 3151 | jmorell | if (isDoubleFeatured) {
|
267 | if (lastFeaBordes.getGeometry() instanceof LineString3D) { |
||
268 | Feature feaBordes = lastFeaBordes; |
||
269 | Feature feaFondos = lastFeaFondos; |
||
270 | LineString3D lineString3D = (LineString3D) feaBordes.getGeometry(); |
||
271 | Polygon3D polygon3D = (Polygon3D) feaFondos.getGeometry(); |
||
272 | lineString3D.add(firstPt); |
||
273 | 2809 | nacho | |
274 | 3151 | jmorell | if ((bulge != 0) && |
275 | !((lineString3D.get(lineString3D.pointNr() - 2).getX() == lineString3D.get(lineString3D.pointNr() -
|
||
276 | 1)
|
||
277 | .getX()) && |
||
278 | (lineString3D.get(lineString3D.pointNr() - 2).getY() == lineString3D.get(lineString3D.pointNr() -
|
||
279 | 1)
|
||
280 | .getY()))) { |
||
281 | 2809 | nacho | // 041122: Correcci?n del bug en los bulges de FIXT3.DXF
|
282 | 3151 | jmorell | Vector arc = createArc(new Point2D.Double(lineString3D.get(lineString3D.pointNr() - |
283 | 2809 | nacho | 2)
|
284 | .getX(), |
||
285 | lineString3D.get(lineString3D.pointNr() - |
||
286 | 2)
|
||
287 | .getY()), |
||
288 | new Point2D.Double(lineString3D.get(lineString3D.pointNr() - |
||
289 | 1)
|
||
290 | .getX(), |
||
291 | lineString3D.get(lineString3D.pointNr() - |
||
292 | 1)
|
||
293 | .getY()), |
||
294 | 3151 | jmorell | bulge); |
295 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
296 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
297 | polygon3D.remove(lineString3D.pointNr() - 1);
|
||
298 | polygon3D.remove(lineString3D.pointNr() - 1);
|
||
299 | 2809 | nacho | |
300 | if (bulge > 0) { |
||
301 | for (int i = 0; i < arc.size(); i++) { |
||
302 | Point2D ptAux = new Point2D.Double(); |
||
303 | 3151 | jmorell | double z = ((Point3D) lineString3D.get(lineString3D.pointNr() -
|
304 | 2)).getZ();
|
||
305 | 2809 | nacho | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
306 | ((Point2D) arc.get(i)).getY());
|
||
307 | |||
308 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
309 | ptAux.getY(), z); |
||
310 | 3151 | jmorell | lineString3D.add(ptAux3D); |
311 | 2809 | nacho | polygon3D.add(ptAux3D); |
312 | |||
313 | 3151 | jmorell | if (lineString3D.pointNr() == 1) { |
314 | 3150 | jmorell | firstPt = ptAux3D; |
315 | } |
||
316 | 2809 | nacho | } |
317 | } else {
|
||
318 | for (int i = arc.size() - 1; i >= 0; i--) { |
||
319 | Point2D ptAux = new Point2D.Double(); |
||
320 | 3151 | jmorell | double z = ((Point3D) lineString3D.get(lineString3D.pointNr() -
|
321 | 2)).getZ();
|
||
322 | 2809 | nacho | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
323 | ((Point2D) arc.get(i)).getY());
|
||
324 | |||
325 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
326 | ptAux.getY(), z); |
||
327 | 3151 | jmorell | lineString3D.add(ptAux3D); |
328 | 2809 | nacho | polygon3D.add(ptAux3D); |
329 | |||
330 | 3151 | jmorell | if ((lineString3D.pointNr() == 1) || |
331 | (polygon3D.pointNr() == 1)) {
|
||
332 | 2809 | nacho | firstPt = ptAux3D; |
333 | } |
||
334 | } |
||
335 | } |
||
336 | |||
337 | // 041122
|
||
338 | bulge = 0.0;
|
||
339 | } |
||
340 | |||
341 | if (hasFaces) {
|
||
342 | //System.out.println("Sabe que es un poligono.");
|
||
343 | //System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
|
||
344 | LineString ls1 = new LineString();
|
||
345 | Polygon pl1 = new Polygon(); |
||
346 | LineString ls2 = new LineString();
|
||
347 | Polygon pl2 = new Polygon(); |
||
348 | LineString ls = new LineString();
|
||
349 | Polygon pl = new Polygon(); |
||
350 | int[] face; |
||
351 | int i0;
|
||
352 | int i1;
|
||
353 | Iterator iter = faces.iterator();
|
||
354 | |||
355 | while (iter.hasNext()) {
|
||
356 | face = (int[]) iter.next(); |
||
357 | i0 = face[3];
|
||
358 | |||
359 | for (int i = 0; i < 4; i++) { |
||
360 | i1 = face[i]; |
||
361 | |||
362 | if (i0 > 0) { |
||
363 | if ((facesIterador % 2) != 0) { |
||
364 | 3151 | jmorell | ls1.add((Point2D) lineString3D.get(i0 - 1)); |
365 | 2809 | nacho | pl1.add((Point2D) polygon3D.get(i0 - 1)); |
366 | } else {
|
||
367 | 3151 | jmorell | ls2.add((Point2D) lineString3D.get(i0 - 1)); |
368 | 2809 | nacho | pl2.add((Point2D) polygon3D.get(i0 - 1)); |
369 | } |
||
370 | |||
371 | facesIterador = facesIterador + 1;
|
||
372 | } |
||
373 | |||
374 | i0 = i1; |
||
375 | } |
||
376 | } |
||
377 | |||
378 | facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), |
||
379 | ls1.get(0).getY());
|
||
380 | |||
381 | for (int i = 0; i < ls1.pointNr(); i++) { |
||
382 | ls.add(ls1.get(i)); |
||
383 | pl.add(pl1.get(i)); |
||
384 | } |
||
385 | |||
386 | for (int i = ls2.pointNr() - 1; i > 0; i--) { |
||
387 | ls.add(ls2.get(i)); |
||
388 | pl.add(pl2.get(i)); |
||
389 | } |
||
390 | |||
391 | ls.add(facesFirstPoint); |
||
392 | pl.add(facesFirstPoint); |
||
393 | 3151 | jmorell | lastFeaBordes.setGeometry(ls); |
394 | lastFeaFondos.setGeometry(pl); |
||
395 | 2809 | nacho | } else {
|
396 | 3151 | jmorell | lastFeaBordes.setGeometry(lineString3D); |
397 | lastFeaFondos.setGeometry(polygon3D); |
||
398 | 2809 | nacho | } |
399 | |||
400 | // 041130: Rellena las props con los atributos.
|
||
401 | 3151 | jmorell | completeAttributes(lastFeaBordes); |
402 | completeAttributes(lastFeaFondos); |
||
403 | 2809 | nacho | |
404 | 3151 | jmorell | setPolylineElevation(lastFeaBordes, lastFeaFondos); |
405 | 2809 | nacho | |
406 | if (addingToBlock == false) { |
||
407 | 3149 | jmorell | //features.add(lastFeaBordes);
|
408 | 3151 | jmorell | features.add(lastFeaFondos); |
409 | 2809 | nacho | } else {
|
410 | 3149 | jmorell | //blk.add(lastFeaBordes);
|
411 | 3151 | jmorell | blk.add(lastFeaFondos); |
412 | 2809 | nacho | } |
413 | |||
414 | 3151 | jmorell | lastFeaBordes = null;
|
415 | lastFeaFondos = null;
|
||
416 | } else if (lastFeaBordes.getGeometry() instanceof InsPoint3D) { |
||
417 | 2809 | nacho | // Se trata de un SEQEND despues de un ATTRIB
|
418 | 3151 | jmorell | copyAttributes(lastFeaBordes); |
419 | 2809 | nacho | |
420 | 3151 | jmorell | gestionaInsert(lastFeaBordes); |
421 | 2809 | nacho | |
422 | if (addingToBlock == false) { |
||
423 | 3151 | jmorell | features.add(lastFeaFondos); |
424 | 2809 | nacho | } else {
|
425 | 3151 | jmorell | blk.add(lastFeaBordes); |
426 | 2809 | nacho | } |
427 | |||
428 | 3151 | jmorell | lastFeaBordes = null;
|
429 | lastFeaFondos = null;
|
||
430 | 2809 | nacho | } else {
|
431 | // Caso no contemplado.
|
||
432 | } |
||
433 | } else {
|
||
434 | 3151 | jmorell | if (lastFeaBordes.getGeometry() instanceof LineString3D) { |
435 | Feature feaBordes = lastFeaBordes; |
||
436 | LineString3D lineString3D = (LineString3D) feaBordes.getGeometry(); |
||
437 | 2809 | nacho | |
438 | if ((bulge != 0) && |
||
439 | !((lineString3D.get(lineString3D.pointNr() - 2).getX() == lineString3D.get(lineString3D.pointNr() -
|
||
440 | 1)
|
||
441 | .getX()) && |
||
442 | (lineString3D.get(lineString3D.pointNr() - 2).getY() == lineString3D.get(lineString3D.pointNr() -
|
||
443 | 1)
|
||
444 | .getY()))) { |
||
445 | // 041122: Correcci?n del bug en los bulges de FIXT3.DXF
|
||
446 | Vector arc = createArc(new Point2D.Double(lineString3D.get(lineString3D.pointNr() - |
||
447 | 2)
|
||
448 | .getX(), |
||
449 | lineString3D.get(lineString3D.pointNr() - |
||
450 | 2)
|
||
451 | .getY()), |
||
452 | new Point2D.Double(lineString3D.get(lineString3D.pointNr() - |
||
453 | 1)
|
||
454 | .getX(), |
||
455 | lineString3D.get(lineString3D.pointNr() - |
||
456 | 1)
|
||
457 | .getY()), |
||
458 | bulge); |
||
459 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
460 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
461 | |||
462 | if (bulge > 0) { |
||
463 | for (int i = 0; i < arc.size(); i++) { |
||
464 | Point2D ptAux = new Point2D.Double(); |
||
465 | double z = ((Point3D) lineString3D.get(lineString3D.pointNr() -
|
||
466 | 2)).getZ();
|
||
467 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
468 | ((Point2D) arc.get(i)).getY());
|
||
469 | |||
470 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
471 | ptAux.getY(), z); |
||
472 | lineString3D.add(ptAux3D); |
||
473 | |||
474 | if (lineString3D.pointNr() == 1) { |
||
475 | firstPt = ptAux3D; |
||
476 | } |
||
477 | } |
||
478 | } else {
|
||
479 | for (int i = arc.size() - 1; i >= 0; i--) { |
||
480 | Point2D ptAux = new Point2D.Double(); |
||
481 | double z = ((Point3D) lineString3D.get(lineString3D.pointNr() -
|
||
482 | 2)).getZ();
|
||
483 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
484 | ((Point2D) arc.get(i)).getY());
|
||
485 | |||
486 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
487 | ptAux.getY(), z); |
||
488 | lineString3D.add(ptAux3D); |
||
489 | |||
490 | if (lineString3D.pointNr() == 1) { |
||
491 | firstPt = ptAux3D; |
||
492 | } |
||
493 | } |
||
494 | } |
||
495 | |||
496 | // 041122
|
||
497 | bulge = 0.0;
|
||
498 | } |
||
499 | |||
500 | if (hasFaces) {
|
||
501 | //System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
|
||
502 | LineString ls1 = new LineString();
|
||
503 | LineString ls2 = new LineString();
|
||
504 | LineString ls = new LineString();
|
||
505 | int[] face; |
||
506 | int i0;
|
||
507 | int i1;
|
||
508 | Iterator iter = faces.iterator();
|
||
509 | |||
510 | while (iter.hasNext()) {
|
||
511 | face = (int[]) iter.next(); |
||
512 | i0 = face[3];
|
||
513 | |||
514 | for (int i = 0; i < 4; i++) { |
||
515 | i1 = face[i]; |
||
516 | |||
517 | if (i0 > 0) { |
||
518 | if ((facesIterador % 2) != 0) { |
||
519 | ls1.add((Point2D) lineString3D.get(i0 - 1)); |
||
520 | |||
521 | //ls.add((Point2D)lineString.get(Math.abs(i1)-1));
|
||
522 | } else {
|
||
523 | ls2.add((Point2D) lineString3D.get(i0 - 1)); |
||
524 | |||
525 | //ls.add((Point2D)lineString.get(Math.abs(i1)-1));
|
||
526 | } |
||
527 | |||
528 | facesIterador = facesIterador + 1;
|
||
529 | } |
||
530 | |||
531 | i0 = i1; |
||
532 | } |
||
533 | } |
||
534 | |||
535 | facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), |
||
536 | ls1.get(0).getY());
|
||
537 | |||
538 | for (int i = 0; i < ls1.pointNr(); i++) { |
||
539 | ls.add(ls1.get(i)); |
||
540 | } |
||
541 | |||
542 | for (int i = ls2.pointNr() - 1; i > 0; i--) { |
||
543 | ls.add(ls2.get(i)); |
||
544 | } |
||
545 | |||
546 | ls.add(facesFirstPoint); |
||
547 | 3151 | jmorell | lastFeaBordes.setGeometry(ls); |
548 | 2809 | nacho | } else {
|
549 | 3151 | jmorell | lastFeaBordes.setGeometry(lineString3D); |
550 | 2809 | nacho | } |
551 | |||
552 | // 041130: Rellena las props con los atributos.
|
||
553 | 3151 | jmorell | completeAttributes(lastFeaBordes); |
554 | 2809 | nacho | |
555 | 3151 | jmorell | setPolylineElevation(lastFeaBordes); |
556 | 2809 | nacho | |
557 | if (addingToBlock == false) { |
||
558 | 3151 | jmorell | features.add(lastFeaBordes); |
559 | 2809 | nacho | } else {
|
560 | 3151 | jmorell | blk.add(lastFeaBordes); |
561 | 2809 | nacho | } |
562 | |||
563 | 3151 | jmorell | lastFeaBordes = null;
|
564 | 2809 | nacho | } else {
|
565 | // Se trata de un SEQEND despues de un ATTRIB
|
||
566 | } |
||
567 | } |
||
568 | |||
569 | xtruX = 0.0;
|
||
570 | xtruY = 0.0;
|
||
571 | xtruZ = 1.0;
|
||
572 | bulge = 0.0;
|
||
573 | 3151 | jmorell | isDoubleFeatured = false;
|
574 | 2809 | nacho | hasFaces = false;
|
575 | facesIterador = 1;
|
||
576 | } |
||
577 | 78 | luisw | |
578 | 2809 | nacho | /**
|
579 | * Establece un valor constante para la elevaci?n de una polil?nea.
|
||
580 | * @param feaBordes, la polil?nea.
|
||
581 | */
|
||
582 | private void setPolylineElevation(Feature feaBordes) { |
||
583 | if (constantPolylineElevation) {
|
||
584 | Double doub = new Double(lastVertexElevation); |
||
585 | String string = doub.toString();
|
||
586 | feaBordes.setProp("elevation", string);
|
||
587 | } else {
|
||
588 | Double doub = new Double(0.0); |
||
589 | String string = doub.toString();
|
||
590 | feaBordes.setProp("elevation", string);
|
||
591 | } |
||
592 | } |
||
593 | |||
594 | /**
|
||
595 | * Establece un valor constante para la elevaci?n de un pol?gono.
|
||
596 | * @param feaBordes, borde del pol?gono.
|
||
597 | * @param feaFondos, fondo del pol?gono.
|
||
598 | */
|
||
599 | private void setPolylineElevation(Feature feaBordes, Feature feaFondos) { |
||
600 | if (constantPolylineElevation) {
|
||
601 | Double doub = new Double(lastVertexElevation); |
||
602 | String string = doub.toString();
|
||
603 | feaBordes.setProp("elevation", string);
|
||
604 | feaFondos.setProp("elevation", string);
|
||
605 | } else {
|
||
606 | Double doub = new Double(0.0); |
||
607 | String string = doub.toString();
|
||
608 | feaBordes.setProp("elevation", string);
|
||
609 | feaFondos.setProp("elevation", string);
|
||
610 | } |
||
611 | } |
||
612 | 44 | jmorell | |
613 | 2809 | nacho | /* (non-Javadoc)
|
614 | * @see org.cresques.io.DxfFile.EntityFactory#addVertex(org.cresques.io.DxfGroupVector)
|
||
615 | */
|
||
616 | public void addVertex(DxfGroupVector grp) throws Exception { |
||
617 | double x = 0.0; |
||
618 | double y = 0.0; |
||
619 | double z = 0.0; |
||
620 | int vFlags = 0; |
||
621 | 44 | jmorell | |
622 | 3151 | jmorell | if (isDoubleFeatured) {
|
623 | Feature feaBordes = lastFeaBordes; |
||
624 | Feature feaFondos = lastFeaFondos; |
||
625 | LineString3D lineString3D = (LineString3D) feaBordes.getGeometry(); |
||
626 | Polygon3D polygon3D = (Polygon3D) feaFondos.getGeometry(); |
||
627 | 44 | jmorell | |
628 | 2809 | nacho | if (grp.hasCode(8)) { |
629 | 3151 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
630 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
631 | 2809 | nacho | } |
632 | 62 | jmorell | |
633 | 2809 | nacho | if (grp.hasCode(70)) { |
634 | vFlags = grp.getDataAsInt(70);
|
||
635 | } |
||
636 | 66 | jmorell | |
637 | 2809 | nacho | x = grp.getDataAsDouble(10);
|
638 | y = grp.getDataAsDouble(20);
|
||
639 | z = grp.getDataAsDouble(30);
|
||
640 | 69 | jmorell | |
641 | 2809 | nacho | Point3D point_in = new Point3D(x, y, z);
|
642 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
643 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
644 | x = point_out.getX(); |
||
645 | y = point_out.getY(); |
||
646 | z = point_out.getZ(); |
||
647 | |||
648 | if (z != 0.0) { |
||
649 | dxf3DFile = true;
|
||
650 | } |
||
651 | |||
652 | 3151 | jmorell | if ((z != lastVertexElevation) && (lineString3D.pointNr() > 0)) { |
653 | 2809 | nacho | constantPolylineElevation = false;
|
654 | } |
||
655 | |||
656 | lastVertexElevation = z; |
||
657 | |||
658 | //System.out.println("addVertex(): vFlags = " + vFlags);
|
||
659 | if (((vFlags & 0x80) == 0x80) && ((vFlags & 0x40) == 0)) { |
||
660 | int[] face = { 0, 0, 0, 0 }; |
||
661 | face[0] = grp.getDataAsInt(71); |
||
662 | face[1] = grp.getDataAsInt(72); |
||
663 | face[2] = grp.getDataAsInt(73); |
||
664 | face[3] = grp.getDataAsInt(74); |
||
665 | addFace(face); |
||
666 | } else if ((vFlags & 0x10) == 0x10) { |
||
667 | // Son vertices que se trataran cuando se implementen
|
||
668 | // los splines. En principio no se hace nada con ellos.
|
||
669 | } else {
|
||
670 | Point3D pt = new Point3D(proj.createPoint(x, y).getX(),
|
||
671 | proj.createPoint(x, y).getY(), z); |
||
672 | 3151 | jmorell | lineString3D.add(pt); |
673 | 2809 | nacho | polygon3D.add(pt); |
674 | |||
675 | 3151 | jmorell | if (lineString3D.pointNr() == 1) { |
676 | firstPt = pt; |
||
677 | } |
||
678 | 2809 | nacho | |
679 | if (bulge == 0.0) { |
||
680 | if (grp.hasCode(42)) { |
||
681 | bulge = grp.getDataAsDouble(42);
|
||
682 | } else {
|
||
683 | bulge = 0.0;
|
||
684 | } |
||
685 | } else {
|
||
686 | double bulge_aux = 0.0; |
||
687 | |||
688 | if (grp.hasCode(42)) { |
||
689 | bulge_aux = grp.getDataAsDouble(42);
|
||
690 | } else {
|
||
691 | bulge_aux = 0.0;
|
||
692 | } |
||
693 | |||
694 | //int cnt = lineString.pointNr();
|
||
695 | if ((ptAnterior.getX() == pt.getX()) &&
|
||
696 | (ptAnterior.getY() == pt.getY())) { |
||
697 | // no se construye el arco
|
||
698 | } else {
|
||
699 | 3151 | jmorell | lineString3D.remove(lineString3D.pointNr() - 1);
|
700 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
701 | 2809 | nacho | polygon3D.remove(polygon3D.pointNr() - 1);
|
702 | polygon3D.remove(polygon3D.pointNr() - 1);
|
||
703 | |||
704 | Vector arc = createArc(ptAnterior, pt, bulge);
|
||
705 | |||
706 | if (bulge > 0) { |
||
707 | for (int i = 0; i < arc.size(); i++) { |
||
708 | Point2D ptAux = new Point2D.Double(); |
||
709 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
710 | ((Point2D) arc.get(i)).getY());
|
||
711 | |||
712 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
713 | ptAux.getY(), z); |
||
714 | 3151 | jmorell | lineString3D.add(ptAux3D); |
715 | 2809 | nacho | polygon3D.add(ptAux3D); |
716 | |||
717 | 3151 | jmorell | if (lineString3D.pointNr() == 1) { |
718 | firstPt = ptAux3D; |
||
719 | } |
||
720 | 2809 | nacho | } |
721 | } else {
|
||
722 | for (int i = arc.size() - 1; i >= 0; i--) { |
||
723 | Point2D ptAux = new Point2D.Double(); |
||
724 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
725 | ((Point2D) arc.get(i)).getY());
|
||
726 | |||
727 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
728 | ptAux.getY(), z); |
||
729 | 3151 | jmorell | lineString3D.add(ptAux3D); |
730 | 2809 | nacho | polygon3D.add(ptAux3D); |
731 | |||
732 | 3151 | jmorell | if ((lineString3D.pointNr() == 1) || |
733 | (polygon3D.pointNr() == 1)) {
|
||
734 | 2809 | nacho | firstPt = ptAux3D; |
735 | } |
||
736 | } |
||
737 | } |
||
738 | } |
||
739 | |||
740 | bulge = bulge_aux; |
||
741 | } |
||
742 | |||
743 | ptAnterior = pt; |
||
744 | } |
||
745 | } else {
|
||
746 | 3151 | jmorell | Feature feaBordes = lastFeaBordes; |
747 | LineString3D lineString3D = (LineString3D) feaBordes.getGeometry(); |
||
748 | 2809 | nacho | |
749 | if (grp.hasCode(8)) { |
||
750 | 3151 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
751 | 2809 | nacho | } |
752 | |||
753 | if (grp.hasCode(70)) { |
||
754 | vFlags = grp.getDataAsInt(70);
|
||
755 | } |
||
756 | |||
757 | x = grp.getDataAsDouble(10);
|
||
758 | y = grp.getDataAsDouble(20);
|
||
759 | z = grp.getDataAsDouble(30);
|
||
760 | |||
761 | Point3D point_in = new Point3D(x, y, z);
|
||
762 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
763 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
764 | x = point_out.getX(); |
||
765 | y = point_out.getY(); |
||
766 | z = point_out.getZ(); |
||
767 | |||
768 | if (z != 0.0) { |
||
769 | dxf3DFile = true;
|
||
770 | } |
||
771 | |||
772 | if ((z != lastVertexElevation) && (lineString3D.pointNr() > 0)) { |
||
773 | constantPolylineElevation = false;
|
||
774 | } |
||
775 | |||
776 | lastVertexElevation = z; |
||
777 | |||
778 | if (((vFlags & 0x80) == 0x80) && ((vFlags & 0x40) == 0)) { |
||
779 | int[] face = { 0, 0, 0, 0 }; |
||
780 | face[0] = grp.getDataAsInt(71); |
||
781 | face[1] = grp.getDataAsInt(72); |
||
782 | face[2] = grp.getDataAsInt(73); |
||
783 | face[3] = grp.getDataAsInt(74); |
||
784 | addFace(face); |
||
785 | } else if ((vFlags & 16) == 16) { |
||
786 | // no se hace nada.
|
||
787 | } else {
|
||
788 | Point3D pt = new Point3D(proj.createPoint(x, y).getX(),
|
||
789 | proj.createPoint(x, y).getY(), z); |
||
790 | lineString3D.add(pt); |
||
791 | |||
792 | //System.out.println("addVertex: pt = " + pt);
|
||
793 | if (lineString3D.pointNr() == 1) { |
||
794 | firstPt = pt; |
||
795 | |||
796 | //System.out.println("addVertex(Primer pto de la lineString, firstPt=pt): firstPt = " + firstPt);
|
||
797 | } |
||
798 | |||
799 | if (bulge == 0.0) { |
||
800 | if (grp.hasCode(42)) { |
||
801 | bulge = grp.getDataAsDouble(42);
|
||
802 | } else {
|
||
803 | bulge = 0.0;
|
||
804 | } |
||
805 | |||
806 | //System.out.println("addVertex: El vertice anterior tenia bulge=0.0");
|
||
807 | } else {
|
||
808 | //System.out.println("addVertex: El vertice anterior tiene bulge = " + bulge);
|
||
809 | double bulge_aux = 0.0; |
||
810 | |||
811 | if (grp.hasCode(42)) { |
||
812 | bulge_aux = grp.getDataAsDouble(42);
|
||
813 | } else {
|
||
814 | bulge_aux = 0.0;
|
||
815 | } |
||
816 | |||
817 | if ((ptAnterior.getX() == pt.getX()) &&
|
||
818 | (ptAnterior.getY() == pt.getY())) { |
||
819 | // no se construye el arco
|
||
820 | } else {
|
||
821 | // Borro los puntos inicio y final del arco.
|
||
822 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
823 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
824 | |||
825 | Vector arc = createArc(ptAnterior, pt, bulge);
|
||
826 | |||
827 | if (bulge > 0) { |
||
828 | for (int i = 0; i < arc.size(); i++) { |
||
829 | Point2D ptAux = new Point2D.Double(); |
||
830 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
831 | ((Point2D) arc.get(i)).getY());
|
||
832 | |||
833 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
834 | ptAux.getY(), z); |
||
835 | lineString3D.add(ptAux3D); |
||
836 | |||
837 | if (lineString3D.pointNr() == 1) { |
||
838 | firstPt = ptAux3D; |
||
839 | } |
||
840 | } |
||
841 | } else {
|
||
842 | for (int i = arc.size() - 1; i >= 0; i--) { |
||
843 | Point2D ptAux = new Point2D.Double(); |
||
844 | ptAux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
||
845 | ((Point2D) arc.get(i)).getY());
|
||
846 | |||
847 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
848 | ptAux.getY(), z); |
||
849 | lineString3D.add(ptAux3D); |
||
850 | |||
851 | if (lineString3D.pointNr() == 1) { |
||
852 | firstPt = ptAux3D; |
||
853 | } |
||
854 | } |
||
855 | } |
||
856 | } |
||
857 | |||
858 | bulge = bulge_aux; |
||
859 | } |
||
860 | |||
861 | ptAnterior = pt; |
||
862 | } |
||
863 | } |
||
864 | } |
||
865 | |||
866 | /* (non-Javadoc)
|
||
867 | * @see org.cresques.io.DxfFile.EntityFactory#createLwPolyline(org.cresques.io.DxfGroupVector)
|
||
868 | */
|
||
869 | public void createLwPolyline(DxfGroupVector grp) throws Exception { |
||
870 | double x = 0.0; |
||
871 | double y = 0.0; |
||
872 | double elev = 0.0; |
||
873 | DxfGroup g = null;
|
||
874 | LineString3D lineString3D = new LineString3D();
|
||
875 | Polygon3D polygon3D = new Polygon3D();
|
||
876 | |||
877 | //Geometry geometria;
|
||
878 | 3151 | jmorell | //Feature feature= new Feature();
|
879 | Feature feaBordes = new Feature();
|
||
880 | Feature feaFondos = new Feature();
|
||
881 | 2809 | nacho | int flags = 0; |
882 | 3188 | jmorell | //int NumberOfVertices = 0;
|
883 | 2809 | nacho | double extx = 0.0; |
884 | double exty = 0.0; |
||
885 | double extz = 1.0; |
||
886 | |||
887 | 3151 | jmorell | //feature.setProp("dxfEntity", "LwPolyline");
|
888 | feaBordes.setProp("dxfEntity", "LwPolyline"); |
||
889 | feaFondos.setProp("dxfEntity", "LwPolyline"); |
||
890 | 2809 | nacho | |
891 | 3188 | jmorell | //if (grp.hasCode(8)) {
|
892 | 3151 | jmorell | //feature.setProp("layer", grp.getDataAsString(8));
|
893 | 3188 | jmorell | // feaBordes.setProp("layer", grp.getDataAsString(8));
|
894 | //}
|
||
895 | 2809 | nacho | |
896 | 3188 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
897 | 3151 | jmorell | feaFondos.setProp("layer", grp.getDataAsString(8)); |
898 | 2809 | nacho | |
899 | if (grp.hasCode(38)) { |
||
900 | elev = grp.getDataAsDouble(38);
|
||
901 | |||
902 | if (elev != 0.0) { |
||
903 | dxf3DFile = true;
|
||
904 | } |
||
905 | |||
906 | Double doub = new Double(elev); |
||
907 | String string = doub.toString();
|
||
908 | |||
909 | 3151 | jmorell | //feature.setProp("elevation", string);
|
910 | feaBordes.setProp("elevation", string);
|
||
911 | feaFondos.setProp("elevation", string);
|
||
912 | 2809 | nacho | } else {
|
913 | Double doub = new Double(0.0); |
||
914 | |||
915 | 3151 | jmorell | //feature.setProp("elevation", doub.toString());
|
916 | feaBordes.setProp("elevation", doub.toString());
|
||
917 | feaFondos.setProp("elevation", doub.toString());
|
||
918 | 2809 | nacho | } |
919 | |||
920 | if (grp.hasCode(39)) { |
||
921 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
922 | String string = doub.toString();
|
||
923 | |||
924 | 3151 | jmorell | //feature.setProp("thickness", string);
|
925 | feaBordes.setProp("thickness", string);
|
||
926 | feaFondos.setProp("thickness", string);
|
||
927 | 2809 | nacho | } else {
|
928 | Double doub = new Double(0.0); |
||
929 | |||
930 | 3151 | jmorell | //feature.setProp("thickness", doub.toString());
|
931 | feaBordes.setProp("thickness", doub.toString());
|
||
932 | feaFondos.setProp("thickness", doub.toString());
|
||
933 | 2809 | nacho | } |
934 | |||
935 | if (grp.hasCode(62)) { |
||
936 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
937 | String string = integer.toString();
|
||
938 | |||
939 | 3151 | jmorell | //feature.setProp("color", string);
|
940 | feaBordes.setProp("color", string);
|
||
941 | feaFondos.setProp("color", string);
|
||
942 | feaBordes.setProp("colorByLayer", "false"); |
||
943 | feaFondos.setProp("colorByLayer", "false"); |
||
944 | 2809 | nacho | } else {
|
945 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
946 | int clr = layer.colorNumber;
|
||
947 | Integer integer = new Integer(clr); |
||
948 | String string = integer.toString();
|
||
949 | |||
950 | 3151 | jmorell | //feature.setProp("color", string);
|
951 | feaBordes.setProp("color", string);
|
||
952 | feaFondos.setProp("color", string);
|
||
953 | feaBordes.setProp("colorByLayer", "true"); |
||
954 | feaFondos.setProp("colorByLayer", "true"); |
||
955 | 2809 | nacho | } |
956 | |||
957 | if (grp.hasCode(70)) { |
||
958 | flags = grp.getDataAsInt(70);
|
||
959 | } |
||
960 | |||
961 | if ((flags & 0x01) == 0x01) { |
||
962 | //geometria = new Polygon();
|
||
963 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
964 | feaFondos.setGeometry(polygon3D); |
||
965 | isDoubleFeatured = true;
|
||
966 | 2809 | nacho | } else {
|
967 | //geometria = new LineString();
|
||
968 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
969 | isDoubleFeatured = false;
|
||
970 | 2809 | nacho | } |
971 | |||
972 | 3188 | jmorell | //if (grp.hasCode(90)) {
|
973 | // NumberOfVertices = grp.getDataAsInt(90);
|
||
974 | //}
|
||
975 | 2809 | nacho | |
976 | if (grp.hasCode(210)) { |
||
977 | extx = grp.getDataAsDouble(210);
|
||
978 | } |
||
979 | |||
980 | if (grp.hasCode(220)) { |
||
981 | exty = grp.getDataAsDouble(220);
|
||
982 | } |
||
983 | |||
984 | if (grp.hasCode(230)) { |
||
985 | extz = grp.getDataAsDouble(230);
|
||
986 | } |
||
987 | |||
988 | int j = 0; |
||
989 | double firstX = 0.0; |
||
990 | double firstY = 0.0; |
||
991 | boolean hasBulge = false; |
||
992 | double bulgeLwp = 0.0; |
||
993 | |||
994 | for (int i = 0; i < grp.size(); i++) { |
||
995 | g = (DxfGroup) grp.get(i); |
||
996 | |||
997 | if (g.getCode() == 10) { |
||
998 | j++; |
||
999 | x = ((Double) g.getData()).doubleValue();
|
||
1000 | } else if (g.getCode() == 20) { |
||
1001 | y = ((Double) g.getData()).doubleValue();
|
||
1002 | |||
1003 | // A?adiendo extrusion a LwPolyline ...
|
||
1004 | Point3D point_in1 = new Point3D(x, y, elev);
|
||
1005 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1006 | Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
||
1007 | x = point_out1.getX(); |
||
1008 | y = point_out1.getY(); |
||
1009 | elev = point_out1.getZ(); |
||
1010 | |||
1011 | //
|
||
1012 | if (hasBulge) {
|
||
1013 | Point2D finalPoint = new Point2D.Double(x, y); |
||
1014 | |||
1015 | if ((((LineString3D) lineString3D).get(lineString3D.pointNr() -
|
||
1016 | 1).getX() == finalPoint.getX()) &&
|
||
1017 | (((LineString3D) lineString3D).get(lineString3D.pointNr() - |
||
1018 | 1).getY() == finalPoint.getY())) {
|
||
1019 | // no se construye el arco
|
||
1020 | } else {
|
||
1021 | Vector arc = createArc(((LineString3D) lineString3D).get(lineString3D.pointNr() -
|
||
1022 | 1),
|
||
1023 | finalPoint, bulgeLwp); |
||
1024 | lineString3D.remove(lineString3D.pointNr() - 1);
|
||
1025 | |||
1026 | 3151 | jmorell | if (isDoubleFeatured) {
|
1027 | 2809 | nacho | polygon3D.remove(polygon3D.pointNr() - 1);
|
1028 | } |
||
1029 | |||
1030 | if (bulgeLwp > 0) { |
||
1031 | for (int k = 0; k < arc.size(); k++) { |
||
1032 | Point2D ptAux = new Point2D.Double(); |
||
1033 | ptAux = proj.createPoint(((Point2D) arc.get(k)).getX(),
|
||
1034 | ((Point2D) arc.get(k)).getY());
|
||
1035 | |||
1036 | //System.out.println("createLwPolyline: ptAux = " + ptAux);
|
||
1037 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
1038 | ptAux.getY(), elev); |
||
1039 | lineString3D.add(ptAux3D); |
||
1040 | |||
1041 | //if (lineString.pointNr() == 1) firstPt = ptAux;
|
||
1042 | 3151 | jmorell | if (isDoubleFeatured) {
|
1043 | 2809 | nacho | polygon3D.add(ptAux3D); |
1044 | } |
||
1045 | |||
1046 | if ((lineString3D.pointNr() == 1) || |
||
1047 | (polygon3D.pointNr() == 1)) {
|
||
1048 | firstPt = ptAux3D; |
||
1049 | } |
||
1050 | } |
||
1051 | } else {
|
||
1052 | for (int k = arc.size() - 1; k >= 0; k--) { |
||
1053 | Point2D ptAux = new Point2D.Double(); |
||
1054 | ptAux = proj.createPoint(((Point2D) arc.get(k)).getX(),
|
||
1055 | ((Point2D) arc.get(k)).getY());
|
||
1056 | |||
1057 | Point3D ptAux3D = new Point3D(ptAux.getX(),
|
||
1058 | ptAux.getY(), elev); |
||
1059 | lineString3D.add(ptAux3D); |
||
1060 | |||
1061 | 3151 | jmorell | if (isDoubleFeatured) {
|
1062 | 2809 | nacho | polygon3D.add(ptAux3D); |
1063 | } |
||
1064 | |||
1065 | if ((lineString3D.pointNr() == 1) || |
||
1066 | (polygon3D.pointNr() == 1)) {
|
||
1067 | firstPt = ptAux3D; |
||
1068 | } |
||
1069 | } |
||
1070 | } |
||
1071 | } |
||
1072 | |||
1073 | hasBulge = false;
|
||
1074 | bulgeLwp = 0.0;
|
||
1075 | } else {
|
||
1076 | //System.out.println("createLwPolyline: hasBulge siempre es false");
|
||
1077 | Point3D ptAux3D = new Point3D(proj.createPoint(x, y).getX(),
|
||
1078 | proj.createPoint(x, y).getY(), |
||
1079 | elev); |
||
1080 | lineString3D.add(ptAux3D); |
||
1081 | |||
1082 | 3151 | jmorell | if (isDoubleFeatured) {
|
1083 | 2809 | nacho | polygon3D.add(ptAux3D); |
1084 | } |
||
1085 | } |
||
1086 | |||
1087 | if (j == 1) { |
||
1088 | firstX = x; |
||
1089 | firstY = y; |
||
1090 | } |
||
1091 | |||
1092 | x = 0.0;
|
||
1093 | y = 0.0;
|
||
1094 | 3188 | jmorell | } else if (g.getCode() == 42 && ((Double)g.getData()).doubleValue()!=0.0) { // Cuando los bulges eran 0.000 se provocaban errores |
1095 | 2809 | nacho | //System.out.println("createLwPolyline: Lee el bulgeLwp");
|
1096 | hasBulge = true;
|
||
1097 | bulgeLwp = ((Double) g.getData()).doubleValue();
|
||
1098 | } |
||
1099 | } |
||
1100 | |||
1101 | 3151 | jmorell | if (isDoubleFeatured) {
|
1102 | 2809 | nacho | //geometria.add(proj.createPoint(firstX, firstY));
|
1103 | Point3D ptAux3D = new Point3D(proj.createPoint(firstX, firstY).getX(),
|
||
1104 | proj.createPoint(firstX, firstY).getY(), |
||
1105 | elev); |
||
1106 | lineString3D.add(ptAux3D); |
||
1107 | polygon3D.add(ptAux3D); |
||
1108 | } |
||
1109 | |||
1110 | 3151 | jmorell | lastFeaBordes = feaBordes; |
1111 | 2809 | nacho | |
1112 | 3151 | jmorell | if (isDoubleFeatured) {
|
1113 | lastFeaFondos = feaFondos; |
||
1114 | 2809 | nacho | } |
1115 | |||
1116 | // 041130: Rellena las props con los atributos.
|
||
1117 | 3151 | jmorell | completeAttributes(lastFeaBordes); |
1118 | completeAttributes(lastFeaFondos); |
||
1119 | 2809 | nacho | |
1120 | //features.add(feature);
|
||
1121 | if (addingToBlock == false) { |
||
1122 | 3151 | jmorell | if (isDoubleFeatured) {
|
1123 | features.add(feaFondos); |
||
1124 | } else {
|
||
1125 | features.add(feaBordes); |
||
1126 | 2809 | nacho | } |
1127 | } else {
|
||
1128 | //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
||
1129 | 3151 | jmorell | if (isDoubleFeatured) {
|
1130 | blk.add(feaFondos); |
||
1131 | } else {
|
||
1132 | blk.add(feaBordes); |
||
1133 | 2809 | nacho | } |
1134 | } |
||
1135 | |||
1136 | 3151 | jmorell | isDoubleFeatured = false;
|
1137 | 2809 | nacho | } |
1138 | |||
1139 | /* (non-Javadoc)
|
||
1140 | * @see org.cresques.io.DxfFile.EntityFactory#createLine(org.cresques.io.DxfGroupVector)
|
||
1141 | */
|
||
1142 | public void createLine(DxfGroupVector grp) throws Exception { |
||
1143 | double x = 0.0; |
||
1144 | double y = 0.0; |
||
1145 | double z1 = 0.0; |
||
1146 | double z2 = 0.0; |
||
1147 | double elev = 0.0; |
||
1148 | DxfGroup g = null;
|
||
1149 | Point2D pt1 = null; |
||
1150 | Point2D pt2 = null; |
||
1151 | LineString3D lineString3D = new LineString3D();
|
||
1152 | Feature feature = new Feature();
|
||
1153 | double extx = 0.0; |
||
1154 | double exty = 0.0; |
||
1155 | double extz = 1.0; |
||
1156 | |||
1157 | feature.setProp("dxfEntity", "Line"); |
||
1158 | |||
1159 | if (grp.hasCode(8)) { |
||
1160 | feature.setProp("layer", grp.getDataAsString(8)); |
||
1161 | } |
||
1162 | |||
1163 | if (grp.hasCode(39)) { |
||
1164 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1165 | String string = doub.toString();
|
||
1166 | feature.setProp("thickness", string);
|
||
1167 | } else {
|
||
1168 | Double doub = new Double(0.0); |
||
1169 | feature.setProp("thickness", doub.toString());
|
||
1170 | } |
||
1171 | |||
1172 | if (grp.hasCode(62)) { |
||
1173 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1174 | String string = integer.toString();
|
||
1175 | feature.setProp("color", string);
|
||
1176 | feature.setProp("colorByLayer", "false"); |
||
1177 | } else {
|
||
1178 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1179 | int clr = layer.colorNumber;
|
||
1180 | Integer integer = new Integer(clr); |
||
1181 | String string = integer.toString();
|
||
1182 | feature.setProp("color", string);
|
||
1183 | feature.setProp("colorByLayer", "true"); |
||
1184 | } |
||
1185 | |||
1186 | x = grp.getDataAsDouble(10);
|
||
1187 | y = grp.getDataAsDouble(20);
|
||
1188 | z1 = grp.getDataAsDouble(30);
|
||
1189 | |||
1190 | /*if (grp.hasCode(30)) {
|
||
1191 | z1 = grp.getDataAsDouble(30);
|
||
1192 | elev = z1;
|
||
1193 | Double doub = new Double(elev);
|
||
1194 | String string = doub.toString();
|
||
1195 | //feature.setProp("elevation", string);
|
||
1196 | }*/
|
||
1197 | pt1 = proj.createPoint(x, y); |
||
1198 | x = grp.getDataAsDouble(11);
|
||
1199 | y = grp.getDataAsDouble(21);
|
||
1200 | z2 = grp.getDataAsDouble(31);
|
||
1201 | |||
1202 | /*if (grp.hasCode(31)) {
|
||
1203 | z2 = grp.getDataAsDouble(31);
|
||
1204 | } else {
|
||
1205 | // Cuando no se especifican z para las lineas se asume que la
|
||
1206 | // z es cero.
|
||
1207 | Double doub = new Double(0.0);
|
||
1208 | //feature.setProp("elevation", doub.toString());
|
||
1209 | }*/
|
||
1210 | pt2 = proj.createPoint(x, y); |
||
1211 | |||
1212 | if (grp.hasCode(210)) { |
||
1213 | extx = grp.getDataAsDouble(210);
|
||
1214 | } |
||
1215 | |||
1216 | if (grp.hasCode(220)) { |
||
1217 | exty = grp.getDataAsDouble(220);
|
||
1218 | } |
||
1219 | |||
1220 | if (grp.hasCode(230)) { |
||
1221 | extz = grp.getDataAsDouble(230);
|
||
1222 | } |
||
1223 | |||
1224 | Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
||
1225 | Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
||
1226 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1227 | Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
||
1228 | Point3D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru); |
||
1229 | |||
1230 | if (point_out1.getZ() != 0.0) { |
||
1231 | dxf3DFile = true;
|
||
1232 | } |
||
1233 | |||
1234 | if (point_out2.getZ() != 0.0) { |
||
1235 | dxf3DFile = true;
|
||
1236 | } |
||
1237 | |||
1238 | if (point_out1.getZ() == point_out2.getZ()) {
|
||
1239 | elev = z1; |
||
1240 | |||
1241 | Double doub = new Double(elev); |
||
1242 | String string = doub.toString();
|
||
1243 | feature.setProp("elevation", string);
|
||
1244 | } else {
|
||
1245 | elev = 0.0;
|
||
1246 | |||
1247 | Double doub = new Double(elev); |
||
1248 | String string = doub.toString();
|
||
1249 | feature.setProp("elevation", string);
|
||
1250 | } |
||
1251 | |||
1252 | //pt1.setLocation(point_out1);
|
||
1253 | //pt2.setLocation(point_out2);
|
||
1254 | lineString3D.add(point_out1); |
||
1255 | lineString3D.add(point_out2); |
||
1256 | |||
1257 | feature.setGeometry(lineString3D); |
||
1258 | |||
1259 | // 041130: Rellena las props con los atributos.
|
||
1260 | completeAttributes(feature); |
||
1261 | |||
1262 | //features.add(feature);
|
||
1263 | if (addingToBlock == false) { |
||
1264 | //System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
||
1265 | features.add(feature); |
||
1266 | } else {
|
||
1267 | //System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
||
1268 | blk.add(feature); |
||
1269 | } |
||
1270 | } |
||
1271 | |||
1272 | /* (non-Javadoc)
|
||
1273 | * @see org.cresques.io.DxfFile.EntityFactory#createText(org.cresques.io.DxfGroupVector)
|
||
1274 | */
|
||
1275 | public void createText(DxfGroupVector grp) throws Exception { |
||
1276 | double x = 0.0; |
||
1277 | double y = 0.0; |
||
1278 | double z = 0.0; |
||
1279 | double h = 0.0; |
||
1280 | double rot = 0.0; |
||
1281 | DxfGroup g = null;
|
||
1282 | |||
1283 | //Point3D pt1 = null, pt2 = null;
|
||
1284 | Point3D pt = null;
|
||
1285 | org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
||
1286 | double extx = 0.0; |
||
1287 | double exty = 0.0; |
||
1288 | double extz = 1.0; |
||
1289 | |||
1290 | point.setTextPoint(true);
|
||
1291 | |||
1292 | Feature feature = new Feature();
|
||
1293 | |||
1294 | feature.setProp("dxfEntity", "Text"); |
||
1295 | |||
1296 | if (grp.hasCode(8)) { |
||
1297 | feature.setProp("layer", grp.getDataAsString(8)); |
||
1298 | } |
||
1299 | |||
1300 | if (grp.hasCode(39)) { |
||
1301 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1302 | String string = doub.toString();
|
||
1303 | feature.setProp("thickness", string);
|
||
1304 | } else {
|
||
1305 | Double doub = new Double(0.0); |
||
1306 | feature.setProp("thickness", doub.toString());
|
||
1307 | } |
||
1308 | |||
1309 | if (grp.hasCode(62)) { |
||
1310 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1311 | String string = integer.toString();
|
||
1312 | feature.setProp("color", string);
|
||
1313 | feature.setProp("colorByLayer", "false"); |
||
1314 | } else {
|
||
1315 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1316 | int clr = layer.colorNumber;
|
||
1317 | Integer integer = new Integer(clr); |
||
1318 | String string = integer.toString();
|
||
1319 | feature.setProp("color", string);
|
||
1320 | feature.setProp("colorByLayer", "true"); |
||
1321 | } |
||
1322 | |||
1323 | if (grp.hasCode(1)) { |
||
1324 | String strAux1 = grp.getDataAsString(1); |
||
1325 | strAux1 = DxfConvTexts.ConvertText(strAux1); |
||
1326 | feature.setProp("text", strAux1);
|
||
1327 | } else {
|
||
1328 | feature.setProp("text", "No Text Code"); |
||
1329 | } |
||
1330 | |||
1331 | if (grp.hasCode(40)) { |
||
1332 | Double heightD = new Double(grp.getDataAsDouble(40)); |
||
1333 | String heightS = heightD.toString();
|
||
1334 | feature.setProp("textHeight", heightS);
|
||
1335 | } else {
|
||
1336 | feature.setProp("textHeight", "20.0"); |
||
1337 | } |
||
1338 | |||
1339 | if (grp.hasCode(50)) { |
||
1340 | Double rotD = new Double(grp.getDataAsDouble(50)); |
||
1341 | String rotS = rotD.toString();
|
||
1342 | feature.setProp("textRotation", rotS);
|
||
1343 | |||
1344 | //System.out.println("rotS = " + rotS);
|
||
1345 | } else {
|
||
1346 | feature.setProp("textRotation", "0.0"); |
||
1347 | } |
||
1348 | |||
1349 | x = grp.getDataAsDouble(10);
|
||
1350 | y = grp.getDataAsDouble(20);
|
||
1351 | 9878 | fjp | if (grp.hasCode(30)) { |
1352 | z = grp.getDataAsDouble(30);
|
||
1353 | } |
||
1354 | 2809 | nacho | /*if (grp.hasCode(30)){
|
1355 | Double doub = new Double(z);
|
||
1356 | String string = doub.toString();
|
||
1357 | feature.setProp("elevation", string);
|
||
1358 | } else {
|
||
1359 | Double doub = new Double(0.0);
|
||
1360 | feature.setProp("elevation", doub.toString());
|
||
1361 | }*/
|
||
1362 | if (grp.hasCode(210)) { |
||
1363 | extx = grp.getDataAsDouble(210);
|
||
1364 | } |
||
1365 | |||
1366 | if (grp.hasCode(220)) { |
||
1367 | exty = grp.getDataAsDouble(220);
|
||
1368 | } |
||
1369 | |||
1370 | if (grp.hasCode(230)) { |
||
1371 | extz = grp.getDataAsDouble(230);
|
||
1372 | } |
||
1373 | |||
1374 | Point3D point_in = new Point3D(x, y, z);
|
||
1375 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1376 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
1377 | x = point_out.getX(); |
||
1378 | y = point_out.getY(); |
||
1379 | z = point_out.getZ(); |
||
1380 | |||
1381 | Double doub = new Double(z); |
||
1382 | feature.setProp("elevation", doub.toString());
|
||
1383 | |||
1384 | if (z != 0.0) { |
||
1385 | dxf3DFile = true;
|
||
1386 | } |
||
1387 | |||
1388 | point.add(new Point3D(x, y, z));
|
||
1389 | feature.setGeometry(point); |
||
1390 | |||
1391 | // 041130: Rellena las props con los atributos.
|
||
1392 | completeAttributes(feature); |
||
1393 | |||
1394 | //features.add(feature);
|
||
1395 | if (addingToBlock == false) { |
||
1396 | features.add(feature); |
||
1397 | } else {
|
||
1398 | //System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
||
1399 | blk.add(feature); |
||
1400 | } |
||
1401 | } |
||
1402 | |||
1403 | /* (non-Javadoc)
|
||
1404 | * @see org.cresques.io.DxfFile.EntityFactory#createMText(org.cresques.io.DxfGroupVector)
|
||
1405 | */
|
||
1406 | public void createMText(DxfGroupVector grp) throws Exception { |
||
1407 | double x = 0.0; |
||
1408 | double y = 0.0; |
||
1409 | double z = 0.0; |
||
1410 | double h = 0.0; |
||
1411 | double rot = 0.0; |
||
1412 | DxfGroup g = null;
|
||
1413 | |||
1414 | //Point2D pt1 = null, pt2 = null;
|
||
1415 | Point3D pt = null;
|
||
1416 | org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
||
1417 | double extx = 0.0; |
||
1418 | double exty = 0.0; |
||
1419 | double extz = 1.0; |
||
1420 | |||
1421 | point.setTextPoint(true);
|
||
1422 | |||
1423 | Feature feature = new Feature();
|
||
1424 | |||
1425 | feature.setProp("dxfEntity", "Text"); |
||
1426 | |||
1427 | if (grp.hasCode(8)) { |
||
1428 | feature.setProp("layer", grp.getDataAsString(8)); |
||
1429 | } |
||
1430 | |||
1431 | if (grp.hasCode(39)) { |
||
1432 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1433 | String string = doub.toString();
|
||
1434 | feature.setProp("thickness", string);
|
||
1435 | } else {
|
||
1436 | Double doub = new Double(0.0); |
||
1437 | feature.setProp("thickness", doub.toString());
|
||
1438 | } |
||
1439 | |||
1440 | if (grp.hasCode(62)) { |
||
1441 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1442 | String string = integer.toString();
|
||
1443 | feature.setProp("color", string);
|
||
1444 | feature.setProp("colorByLayer", "false"); |
||
1445 | } else {
|
||
1446 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1447 | int clr = layer.colorNumber;
|
||
1448 | Integer integer = new Integer(clr); |
||
1449 | String string = integer.toString();
|
||
1450 | feature.setProp("color", string);
|
||
1451 | feature.setProp("colorByLayer", "true"); |
||
1452 | } |
||
1453 | |||
1454 | if (grp.hasCode(1)) { |
||
1455 | String strAux1 = grp.getDataAsString(1); |
||
1456 | strAux1 = DxfConvTexts.ConvertText(strAux1); |
||
1457 | feature.setProp("text", strAux1);
|
||
1458 | } else {
|
||
1459 | feature.setProp("text", "No Text Code"); |
||
1460 | } |
||
1461 | |||
1462 | if (grp.hasCode(40)) { |
||
1463 | Double heightD = new Double(grp.getDataAsDouble(40)); |
||
1464 | String heightS = heightD.toString();
|
||
1465 | feature.setProp("textHeight", heightS);
|
||
1466 | } else {
|
||
1467 | feature.setProp("textHeight", "20.0"); |
||
1468 | } |
||
1469 | |||
1470 | if (grp.hasCode(50)) { |
||
1471 | Double rotD = new Double(grp.getDataAsDouble(50)); |
||
1472 | String rotS = rotD.toString();
|
||
1473 | feature.setProp("textRotation", rotS);
|
||
1474 | |||
1475 | //System.out.println("rotS = " + rotS);
|
||
1476 | } else {
|
||
1477 | feature.setProp("textRotation", "0.0"); |
||
1478 | } |
||
1479 | |||
1480 | if (grp.hasCode(71)) { |
||
1481 | int attachPoint = grp.getDataAsInt(71); |
||
1482 | |||
1483 | if (attachPoint == 1) { |
||
1484 | } else if (attachPoint == 2) { |
||
1485 | } else if (attachPoint == 3) { |
||
1486 | } else if (attachPoint == 4) { |
||
1487 | } else if (attachPoint == 5) { |
||
1488 | } else if (attachPoint == 6) { |
||
1489 | } else if (attachPoint == 7) { |
||
1490 | } else if (attachPoint == 8) { |
||
1491 | } else if (attachPoint == 9) { |
||
1492 | } |
||
1493 | } |
||
1494 | |||
1495 | if (grp.hasCode(72)) { |
||
1496 | int drawDirection = grp.getDataAsInt(71); |
||
1497 | |||
1498 | if (drawDirection == 1) { |
||
1499 | } else if (drawDirection == 3) { |
||
1500 | } else if (drawDirection == 5) { |
||
1501 | } |
||
1502 | } |
||
1503 | |||
1504 | if (grp.hasCode(73)) { |
||
1505 | int spacingStyle = grp.getDataAsInt(71); |
||
1506 | |||
1507 | if (spacingStyle == 1) { |
||
1508 | } else if (spacingStyle == 2) { |
||
1509 | } |
||
1510 | } |
||
1511 | |||
1512 | x = grp.getDataAsDouble(10);
|
||
1513 | y = grp.getDataAsDouble(20);
|
||
1514 | z = grp.getDataAsDouble(30);
|
||
1515 | |||
1516 | /*if (grp.hasCode(30)){
|
||
1517 | z = grp.getDataAsDouble(30);
|
||
1518 | Double doub = new Double(z);
|
||
1519 | String string = doub.toString();
|
||
1520 | feature.setProp("elevation", string);
|
||
1521 | } else {
|
||
1522 | Double doub = new Double(0.0);
|
||
1523 | feature.setProp("elevation", doub.toString());
|
||
1524 | }*/
|
||
1525 | if (grp.hasCode(210)) { |
||
1526 | extx = grp.getDataAsDouble(210);
|
||
1527 | } |
||
1528 | |||
1529 | if (grp.hasCode(220)) { |
||
1530 | exty = grp.getDataAsDouble(220);
|
||
1531 | } |
||
1532 | |||
1533 | if (grp.hasCode(230)) { |
||
1534 | extz = grp.getDataAsDouble(230);
|
||
1535 | } |
||
1536 | |||
1537 | Point3D point_in = new Point3D(x, y, z);
|
||
1538 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1539 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
1540 | x = point_out.getX(); |
||
1541 | y = point_out.getY(); |
||
1542 | z = point_out.getZ(); |
||
1543 | |||
1544 | Double doub = new Double(z); |
||
1545 | feature.setProp("elevation", doub.toString());
|
||
1546 | |||
1547 | if (z != 0.0) { |
||
1548 | dxf3DFile = true;
|
||
1549 | } |
||
1550 | |||
1551 | point.add(new Point3D(x, y, z));
|
||
1552 | feature.setGeometry(point); |
||
1553 | |||
1554 | // 041130: Rellena las props con los atributos.
|
||
1555 | completeAttributes(feature); |
||
1556 | |||
1557 | //features.add(feature);
|
||
1558 | if (addingToBlock == false) { |
||
1559 | features.add(feature); |
||
1560 | } else {
|
||
1561 | //System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
||
1562 | blk.add(feature); |
||
1563 | } |
||
1564 | } |
||
1565 | |||
1566 | /* (non-Javadoc)
|
||
1567 | * @see org.cresques.io.DxfFile.EntityFactory#createPoint(org.cresques.io.DxfGroupVector)
|
||
1568 | */
|
||
1569 | public void createPoint(DxfGroupVector grp) throws Exception { |
||
1570 | double x = 0.0; |
||
1571 | double y = 0.0; |
||
1572 | double z = 0.0; |
||
1573 | DxfGroup g = null;
|
||
1574 | Point3D pt = null;
|
||
1575 | double extx = 0.0; |
||
1576 | double exty = 0.0; |
||
1577 | double extz = 1.0; |
||
1578 | org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
||
1579 | Feature feature = new Feature();
|
||
1580 | |||
1581 | feature.setProp("dxfEntity", "Point"); |
||
1582 | |||
1583 | if (grp.hasCode(8)) { |
||
1584 | feature.setProp("layer", grp.getDataAsString(8)); |
||
1585 | } |
||
1586 | |||
1587 | if (grp.hasCode(39)) { |
||
1588 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1589 | String string = doub.toString();
|
||
1590 | feature.setProp("thickness", string);
|
||
1591 | } else {
|
||
1592 | Double doub = new Double(0.0); |
||
1593 | feature.setProp("thickness", doub.toString());
|
||
1594 | } |
||
1595 | |||
1596 | if (grp.hasCode(62)) { |
||
1597 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1598 | String string = integer.toString();
|
||
1599 | feature.setProp("color", string);
|
||
1600 | feature.setProp("colorByLayer", "false"); |
||
1601 | } else {
|
||
1602 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1603 | int clr = layer.colorNumber;
|
||
1604 | Integer integer = new Integer(clr); |
||
1605 | String string = integer.toString();
|
||
1606 | feature.setProp("color", string);
|
||
1607 | feature.setProp("colorByLayer", "true"); |
||
1608 | } |
||
1609 | |||
1610 | x = grp.getDataAsDouble(10);
|
||
1611 | y = grp.getDataAsDouble(20);
|
||
1612 | z = grp.getDataAsDouble(30);
|
||
1613 | |||
1614 | /*if (grp.hasCode(30)) {
|
||
1615 | z = grp.getDataAsDouble(30);
|
||
1616 | Double doub = new Double(z);
|
||
1617 | String string = doub.toString();
|
||
1618 | feature.setProp("elevation", string);
|
||
1619 | } else {
|
||
1620 | Double doub = new Double(0.0);
|
||
1621 | feature.setProp("elevation", doub.toString());
|
||
1622 | }*/
|
||
1623 | if (grp.hasCode(210)) { |
||
1624 | extx = grp.getDataAsDouble(210);
|
||
1625 | } |
||
1626 | |||
1627 | if (grp.hasCode(220)) { |
||
1628 | exty = grp.getDataAsDouble(220);
|
||
1629 | } |
||
1630 | |||
1631 | if (grp.hasCode(230)) { |
||
1632 | extz = grp.getDataAsDouble(230);
|
||
1633 | } |
||
1634 | |||
1635 | Point3D point_in = new Point3D(x, y, z);
|
||
1636 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1637 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
1638 | x = point_out.getX(); |
||
1639 | y = point_out.getY(); |
||
1640 | z = point_out.getZ(); |
||
1641 | |||
1642 | Double doub = new Double(z); |
||
1643 | feature.setProp("elevation", doub.toString());
|
||
1644 | |||
1645 | if (z != 0.0) { |
||
1646 | dxf3DFile = true;
|
||
1647 | } |
||
1648 | |||
1649 | point.add(new Point3D(x, y, z));
|
||
1650 | feature.setGeometry(point); |
||
1651 | |||
1652 | // 041130: Rellena las props con los atributos.
|
||
1653 | completeAttributes(feature); |
||
1654 | |||
1655 | /*for (int i=0;i<attributes.size();i++) {
|
||
1656 | String[] att = new String[2];
|
||
1657 | att = (String[])attributes.get(i);
|
||
1658 | feature.setProp(att[0],att[1]);
|
||
1659 | }*/
|
||
1660 | |||
1661 | //features.add(feature);
|
||
1662 | if (addingToBlock == false) { |
||
1663 | features.add(feature); |
||
1664 | } else {
|
||
1665 | //System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
|
||
1666 | blk.add(feature); |
||
1667 | } |
||
1668 | } |
||
1669 | |||
1670 | /* (non-Javadoc)
|
||
1671 | * @see org.cresques.io.DxfFile.EntityFactory#createCircle(org.cresques.io.DxfGroupVector)
|
||
1672 | */
|
||
1673 | public void createCircle(DxfGroupVector grp) throws Exception { |
||
1674 | double x = 0.0; |
||
1675 | double y = 0.0; |
||
1676 | double z = 0.0; |
||
1677 | double r = 0.0; |
||
1678 | Point3D firstPt = new Point3D();
|
||
1679 | DxfGroup g = null;
|
||
1680 | double extx = 0.0; |
||
1681 | double exty = 0.0; |
||
1682 | double extz = 1.0; |
||
1683 | 3151 | jmorell | LineString3D lineString3D = new LineString3D();
|
1684 | 2809 | nacho | Polygon3D polygon3D = new Polygon3D();
|
1685 | 3151 | jmorell | Feature feaBordes = new Feature();
|
1686 | Feature feaFondos = new Feature();
|
||
1687 | 2809 | nacho | |
1688 | 3151 | jmorell | feaBordes.setProp("dxfEntity", "Circle"); |
1689 | feaFondos.setProp("dxfEntity", "Circle"); |
||
1690 | 2809 | nacho | |
1691 | 3151 | jmorell | if (grp.hasCode(8)) { |
1692 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
1693 | } |
||
1694 | 2809 | nacho | |
1695 | 3151 | jmorell | feaFondos.setProp("layer", grp.getDataAsString(8)); |
1696 | 2809 | nacho | |
1697 | if (grp.hasCode(39)) { |
||
1698 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1699 | String string = doub.toString();
|
||
1700 | 3151 | jmorell | feaBordes.setProp("thickness", string);
|
1701 | feaFondos.setProp("thickness", string);
|
||
1702 | 2809 | nacho | } else {
|
1703 | Double doub = new Double(0.0); |
||
1704 | 3151 | jmorell | feaBordes.setProp("thickness", doub.toString());
|
1705 | feaFondos.setProp("thickness", doub.toString());
|
||
1706 | 2809 | nacho | } |
1707 | |||
1708 | if (grp.hasCode(62)) { |
||
1709 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1710 | String string = integer.toString();
|
||
1711 | 3151 | jmorell | feaBordes.setProp("color", string);
|
1712 | feaFondos.setProp("color", string);
|
||
1713 | feaBordes.setProp("colorByLayer", "false"); |
||
1714 | feaFondos.setProp("colorByLayer", "false"); |
||
1715 | 2809 | nacho | } else {
|
1716 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1717 | int clr = layer.colorNumber;
|
||
1718 | Integer integer = new Integer(clr); |
||
1719 | String string = integer.toString();
|
||
1720 | 3151 | jmorell | feaBordes.setProp("color", string);
|
1721 | feaFondos.setProp("color", string);
|
||
1722 | feaBordes.setProp("colorByLayer", "true"); |
||
1723 | feaFondos.setProp("colorByLayer", "true"); |
||
1724 | 2809 | nacho | } |
1725 | |||
1726 | x = grp.getDataAsDouble(10);
|
||
1727 | y = grp.getDataAsDouble(20);
|
||
1728 | 5404 | fjp | if (grp.hasCode(30)) { |
1729 | z = grp.getDataAsDouble(30);
|
||
1730 | } |
||
1731 | |||
1732 | 2809 | nacho | |
1733 | /*if (grp.hasCode(30)) {
|
||
1734 | z = grp.getDataAsDouble(30);
|
||
1735 | Double doub = new Double(z);
|
||
1736 | String string = doub.toString();
|
||
1737 | feaBordes.setProp("elevation", string);
|
||
1738 | feaFondos.setProp("elevation", string);
|
||
1739 | } else {
|
||
1740 | Double doub = new Double(0.0);
|
||
1741 | feaBordes.setProp("elevation", doub.toString());
|
||
1742 | feaFondos.setProp("elevation", doub.toString());
|
||
1743 | }*/
|
||
1744 | if (grp.hasCode(40)) { |
||
1745 | r = grp.getDataAsDouble(40);
|
||
1746 | } |
||
1747 | |||
1748 | if (grp.hasCode(210)) { |
||
1749 | extx = grp.getDataAsDouble(210);
|
||
1750 | } |
||
1751 | |||
1752 | if (grp.hasCode(220)) { |
||
1753 | exty = grp.getDataAsDouble(220);
|
||
1754 | } |
||
1755 | |||
1756 | if (grp.hasCode(230)) { |
||
1757 | extz = grp.getDataAsDouble(230);
|
||
1758 | } |
||
1759 | |||
1760 | Point3D point_in = new Point3D(x, y, z);
|
||
1761 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1762 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
1763 | x = point_out.getX(); |
||
1764 | y = point_out.getY(); |
||
1765 | z = point_out.getZ(); |
||
1766 | |||
1767 | Double doub = new Double(z); |
||
1768 | 3151 | jmorell | feaBordes.setProp("elevation", doub.toString());
|
1769 | feaFondos.setProp("elevation", doub.toString());
|
||
1770 | 2809 | nacho | |
1771 | if (z != 0.0) { |
||
1772 | dxf3DFile = true;
|
||
1773 | } |
||
1774 | |||
1775 | Point2D c = proj.createPoint(x, y);
|
||
1776 | Point3D center = new Point3D(c.getX(), c.getY(), z);
|
||
1777 | Point3D[] pts = new Point3D[360]; |
||
1778 | int angulo = 0; |
||
1779 | |||
1780 | for (angulo = 0; angulo < 360; angulo++) { |
||
1781 | pts[angulo] = new Point3D(center.getX(), center.getY(),
|
||
1782 | center.getZ()); |
||
1783 | pts[angulo] = new Point3D(pts[angulo].getX() +
|
||
1784 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1785 | pts[angulo].getY() + |
||
1786 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1787 | center.getZ()); |
||
1788 | |||
1789 | if (pts.length == 1) { |
||
1790 | firstPt = pts[angulo]; |
||
1791 | } |
||
1792 | } |
||
1793 | |||
1794 | for (int i = 0; i < pts.length; i++) { |
||
1795 | 3151 | jmorell | lineString3D.add(pts[i]); |
1796 | 2809 | nacho | polygon3D.add(pts[i]); |
1797 | } |
||
1798 | |||
1799 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
1800 | feaFondos.setGeometry(polygon3D); |
||
1801 | 2809 | nacho | |
1802 | // 041130: Rellena las props con los atributos.
|
||
1803 | 3151 | jmorell | completeAttributes(feaBordes); |
1804 | completeAttributes(feaFondos); |
||
1805 | 2809 | nacho | |
1806 | //features.add(feature);
|
||
1807 | if (addingToBlock == false) { |
||
1808 | //System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
||
1809 | 3149 | jmorell | //features.add(feaBordes);
|
1810 | 3151 | jmorell | features.add(feaFondos); |
1811 | 2809 | nacho | } else {
|
1812 | //System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
||
1813 | 3149 | jmorell | //blk.add(feaBordes);
|
1814 | 3151 | jmorell | blk.add(feaFondos); |
1815 | 2809 | nacho | } |
1816 | } |
||
1817 | |||
1818 | /* (non-Javadoc)
|
||
1819 | * @see org.cresques.io.DxfFile.EntityFactory#createArc(org.cresques.io.DxfGroupVector)
|
||
1820 | */
|
||
1821 | public void createArc(DxfGroupVector grp) throws Exception { |
||
1822 | double x = 0.0; |
||
1823 | double y = 0.0; |
||
1824 | double z = 0.0; |
||
1825 | double r = 0.0; |
||
1826 | double empieza = 0.0; |
||
1827 | double acaba = 0.0; |
||
1828 | DxfGroup g = null;
|
||
1829 | double extx = 0.0; |
||
1830 | double exty = 0.0; |
||
1831 | double extz = 1.0; |
||
1832 | LineString3D lineString3D = new LineString3D();
|
||
1833 | Feature feature = new Feature();
|
||
1834 | |||
1835 | feature.setProp("dxfEntity", "Arc"); |
||
1836 | |||
1837 | if (grp.hasCode(8)) { |
||
1838 | feature.setProp("layer", grp.getDataAsString(8)); |
||
1839 | } |
||
1840 | |||
1841 | if (grp.hasCode(39)) { |
||
1842 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1843 | String string = doub.toString();
|
||
1844 | feature.setProp("thickness", string);
|
||
1845 | } else {
|
||
1846 | Double doub = new Double(0.0); |
||
1847 | feature.setProp("thickness", doub.toString());
|
||
1848 | } |
||
1849 | |||
1850 | if (grp.hasCode(62)) { |
||
1851 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1852 | String string = integer.toString();
|
||
1853 | feature.setProp("color", string);
|
||
1854 | feature.setProp("colorByLayer", "false"); |
||
1855 | } else {
|
||
1856 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1857 | int clr = layer.colorNumber;
|
||
1858 | Integer integer = new Integer(clr); |
||
1859 | String string = integer.toString();
|
||
1860 | feature.setProp("color", string);
|
||
1861 | feature.setProp("colorByLayer", "true"); |
||
1862 | } |
||
1863 | |||
1864 | x = grp.getDataAsDouble(10);
|
||
1865 | y = grp.getDataAsDouble(20);
|
||
1866 | 5404 | fjp | if (grp.hasCode(30)) |
1867 | { |
||
1868 | z = grp.getDataAsDouble(30);
|
||
1869 | } |
||
1870 | 2809 | nacho | |
1871 | /*if (grp.hasCode(30)) {
|
||
1872 | z = grp.getDataAsDouble(30);
|
||
1873 | Double doub = new Double(z);
|
||
1874 | String string = doub.toString();
|
||
1875 | feature.setProp("elevation", string);
|
||
1876 | } else {
|
||
1877 | Double doub = new Double(0.0);
|
||
1878 | feature.setProp("elevation", doub.toString());
|
||
1879 | }*/
|
||
1880 | if (grp.hasCode(40)) { |
||
1881 | r = grp.getDataAsDouble(40);
|
||
1882 | } |
||
1883 | |||
1884 | if (grp.hasCode(50)) { |
||
1885 | empieza = grp.getDataAsDouble(50);
|
||
1886 | } |
||
1887 | |||
1888 | if (grp.hasCode(51)) { |
||
1889 | acaba = grp.getDataAsDouble(51);
|
||
1890 | } |
||
1891 | |||
1892 | if (grp.hasCode(210)) { |
||
1893 | extx = grp.getDataAsDouble(210);
|
||
1894 | } |
||
1895 | |||
1896 | if (grp.hasCode(220)) { |
||
1897 | exty = grp.getDataAsDouble(220);
|
||
1898 | } |
||
1899 | |||
1900 | if (grp.hasCode(230)) { |
||
1901 | extz = grp.getDataAsDouble(230);
|
||
1902 | } |
||
1903 | |||
1904 | Point3D point_in = new Point3D(x, y, z);
|
||
1905 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
1906 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
1907 | x = point_out.getX(); |
||
1908 | y = point_out.getY(); |
||
1909 | z = point_out.getZ(); |
||
1910 | |||
1911 | Double doub = new Double(z); |
||
1912 | feature.setProp("elevation", doub.toString());
|
||
1913 | |||
1914 | if (z != 0.0) { |
||
1915 | dxf3DFile = true;
|
||
1916 | } |
||
1917 | |||
1918 | Point2D c = proj.createPoint(x, y);
|
||
1919 | Point3D center = new Point3D(c.getX(), c.getY(), z);
|
||
1920 | |||
1921 | //System.out.println("empieza = " + empieza + ", acaba = " + acaba);
|
||
1922 | int iempieza = (int) empieza; |
||
1923 | int iacaba = (int) acaba; |
||
1924 | |||
1925 | //System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
|
||
1926 | double angulo = 0; |
||
1927 | Point3D[] pts = null; |
||
1928 | |||
1929 | if (empieza <= acaba) {
|
||
1930 | pts = new Point3D[(iacaba - iempieza) + 2]; |
||
1931 | angulo = empieza; |
||
1932 | pts[0] = new Point3D(center.getX() + |
||
1933 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1934 | center.getY() + |
||
1935 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1936 | center.getZ()); |
||
1937 | |||
1938 | for (int i = 1; i <= ((iacaba - iempieza) + 1); i++) { |
||
1939 | angulo = (double) (iempieza + i);
|
||
1940 | pts[i] = new Point3D(center.getX() +
|
||
1941 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1942 | center.getY() + |
||
1943 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1944 | center.getZ()); |
||
1945 | } |
||
1946 | |||
1947 | angulo = acaba; |
||
1948 | pts[(iacaba - iempieza) + 1] = new Point3D(center.getX() + |
||
1949 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1950 | center.getY() + |
||
1951 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1952 | center.getZ()); |
||
1953 | } else {
|
||
1954 | pts = new Point3D[(360 - iempieza) + iacaba + 2]; |
||
1955 | angulo = empieza; |
||
1956 | |||
1957 | //System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
|
||
1958 | pts[0] = new Point3D(center.getX() + |
||
1959 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1960 | center.getY() + |
||
1961 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1962 | center.getZ()); |
||
1963 | |||
1964 | for (int i = 1; i <= (360 - iempieza); i++) { |
||
1965 | angulo = (double) (iempieza + i);
|
||
1966 | pts[i] = new Point3D(center.getX() +
|
||
1967 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1968 | center.getY() + |
||
1969 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1970 | center.getZ()); |
||
1971 | } |
||
1972 | |||
1973 | for (int i = (360 - iempieza) + 1; |
||
1974 | i <= ((360 - iempieza) + iacaba); i++) {
|
||
1975 | angulo = (double) (i - (360 - iempieza)); |
||
1976 | pts[i] = new Point3D(center.getX() +
|
||
1977 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1978 | center.getY() + |
||
1979 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1980 | center.getZ()); |
||
1981 | } |
||
1982 | |||
1983 | angulo = acaba; |
||
1984 | pts[(360 - iempieza) + iacaba + 1] = new Point3D(center.getX() + |
||
1985 | (r * Math.cos((angulo * Math.PI) / (double) 180.0)), |
||
1986 | center.getY() + |
||
1987 | (r * Math.sin((angulo * Math.PI) / (double) 180.0)), |
||
1988 | center.getZ()); |
||
1989 | } |
||
1990 | |||
1991 | for (int i = 0; i < pts.length; i++) { |
||
1992 | lineString3D.add(pts[i]); |
||
1993 | } |
||
1994 | |||
1995 | feature.setGeometry(lineString3D); |
||
1996 | |||
1997 | // 041130: Rellena las props con los atributos.
|
||
1998 | completeAttributes(feature); |
||
1999 | |||
2000 | //features.add(feature);
|
||
2001 | if (addingToBlock == false) { |
||
2002 | features.add(feature); |
||
2003 | } else {
|
||
2004 | //System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
|
||
2005 | blk.add(feature); |
||
2006 | } |
||
2007 | } |
||
2008 | |||
2009 | /* (non-Javadoc)
|
||
2010 | * @see org.cresques.io.DxfFile.EntityFactory#createInsert(org.cresques.io.DxfGroupVector)
|
||
2011 | */
|
||
2012 | public void createInsert(DxfGroupVector grp) throws Exception { |
||
2013 | double x = 0.0; |
||
2014 | double y = 0.0; |
||
2015 | double z = 0.0; |
||
2016 | DxfGroup g = null;
|
||
2017 | Point3D pt = new Point3D(0.0, 0.0, 0.0); |
||
2018 | Point3D scaleFactor = new Point3D(1.0, 1.0, 1.0); |
||
2019 | double rotAngle = 0.0; |
||
2020 | String blockName = ""; |
||
2021 | double extx = 0.0; |
||
2022 | double exty = 0.0; |
||
2023 | double extz = 1.0; |
||
2024 | |||
2025 | InsPoint3D insert = new InsPoint3D();
|
||
2026 | Feature feature = new Feature();
|
||
2027 | org.cresques.px.gml.Point3D secondGeom = new org.cresques.px.gml.Point3D();
|
||
2028 | Feature secondFeat = new Feature();
|
||
2029 | int attributesFollowFlag = 0; |
||
2030 | |||
2031 | feature.setProp("dxfEntity", "Insert"); |
||
2032 | secondFeat.setProp("dxfEntity", "Insert"); |
||
2033 | |||
2034 | if (grp.hasCode(2)) { |
||
2035 | blockName = grp.getDataAsString(2);
|
||
2036 | |||
2037 | //feature.setProp("blockName", blockName);
|
||
2038 | insert.setBlockName(blockName); |
||
2039 | } |
||
2040 | |||
2041 | if (grp.hasCode(8)) { |
||
2042 | feature.setProp("layer", grp.getDataAsString(8)); |
||
2043 | secondFeat.setProp("layer", grp.getDataAsString(8)); |
||
2044 | } |
||
2045 | |||
2046 | Double doub = new Double(0.0); |
||
2047 | secondFeat.setProp("thickness", doub.toString());
|
||
2048 | |||
2049 | if (grp.hasCode(62)) { |
||
2050 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
2051 | String string = integer.toString();
|
||
2052 | feature.setProp("color", string);
|
||
2053 | secondFeat.setProp("color", string);
|
||
2054 | feature.setProp("colorByLayer", "false"); |
||
2055 | secondFeat.setProp("colorByLayer", "false"); |
||
2056 | } else {
|
||
2057 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2058 | int clr = layer.colorNumber;
|
||
2059 | Integer integer = new Integer(clr); |
||
2060 | String string = integer.toString();
|
||
2061 | feature.setProp("color", string);
|
||
2062 | secondFeat.setProp("color", string);
|
||
2063 | feature.setProp("colorByLayer", "true"); |
||
2064 | secondFeat.setProp("colorByLayer", "true"); |
||
2065 | } |
||
2066 | |||
2067 | if (grp.hasCode(66)) { |
||
2068 | attributesFollowFlag = grp.getDataAsInt(66);
|
||
2069 | } |
||
2070 | |||
2071 | x = grp.getDataAsDouble(10);
|
||
2072 | y = grp.getDataAsDouble(20);
|
||
2073 | z = grp.getDataAsDouble(30);
|
||
2074 | |||
2075 | /*if (grp.hasCode(30)) {
|
||
2076 | z = grp.getDataAsDouble(30);
|
||
2077 | Double doubz = new Double(z);
|
||
2078 | String string = doubz.toString();
|
||
2079 | feature.setProp("elevation", string);
|
||
2080 | secondFeat.setProp("elevation", string);
|
||
2081 | } else {
|
||
2082 | Double elev = new Double(z);
|
||
2083 | //feature.setProp("elevation", doub.toString());
|
||
2084 | feature.setProp("elevation", elev.toString());
|
||
2085 | secondFeat.setProp("elevation", elev.toString());
|
||
2086 | }*/
|
||
2087 | if (grp.hasCode(41)) { |
||
2088 | scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
|
||
2089 | insert.setScaleFactor(scaleFactor); |
||
2090 | } else {
|
||
2091 | insert.setScaleFactor(scaleFactor); |
||
2092 | } |
||
2093 | |||
2094 | if (grp.hasCode(42)) { |
||
2095 | scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
|
||
2096 | insert.setScaleFactor(scaleFactor); |
||
2097 | } else {
|
||
2098 | insert.setScaleFactor(scaleFactor); |
||
2099 | } |
||
2100 | |||
2101 | if (grp.hasCode(43)) { |
||
2102 | scaleFactor = new Point3D(scaleFactor.getX(), scaleFactor.getY(),
|
||
2103 | grp.getDataAsDouble(43));
|
||
2104 | insert.setScaleFactor(scaleFactor); |
||
2105 | } else {
|
||
2106 | insert.setScaleFactor(scaleFactor); |
||
2107 | } |
||
2108 | |||
2109 | if (grp.hasCode(50)) { |
||
2110 | rotAngle = grp.getDataAsDouble(50);
|
||
2111 | insert.setRotAngle(rotAngle); |
||
2112 | } |
||
2113 | |||
2114 | if (grp.hasCode(210)) { |
||
2115 | extx = grp.getDataAsDouble(210);
|
||
2116 | } |
||
2117 | |||
2118 | if (grp.hasCode(220)) { |
||
2119 | exty = grp.getDataAsDouble(220);
|
||
2120 | } |
||
2121 | |||
2122 | if (grp.hasCode(230)) { |
||
2123 | extz = grp.getDataAsDouble(230);
|
||
2124 | } |
||
2125 | |||
2126 | Point3D point_in = new Point3D(x, y, z);
|
||
2127 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
2128 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
2129 | x = point_out.getX(); |
||
2130 | y = point_out.getY(); |
||
2131 | z = point_out.getZ(); |
||
2132 | |||
2133 | Double doubz = new Double(z); |
||
2134 | feature.setProp("elevation", doubz.toString());
|
||
2135 | secondFeat.setProp("elevation", doubz.toString());
|
||
2136 | |||
2137 | if (z != 0.0) { |
||
2138 | dxf3DFile = true;
|
||
2139 | } |
||
2140 | |||
2141 | insert.setBlkList(blkList); |
||
2142 | |||
2143 | insert.encuentraBloque(blockName); |
||
2144 | |||
2145 | insert.add(new Point3D(x, y, z));
|
||
2146 | secondGeom.add(new Point3D(x, y, z));
|
||
2147 | |||
2148 | feature.setGeometry(insert); |
||
2149 | secondFeat.setGeometry(secondGeom); |
||
2150 | |||
2151 | // 041130: Rellena las props con los atributos.
|
||
2152 | completeAttributes(feature); |
||
2153 | completeAttributes(secondFeat); |
||
2154 | |||
2155 | /*for (int i=0;i<attributes.size();i++) {
|
||
2156 | String[] att = new String[2];
|
||
2157 | att = (String[])attributes.get(i);
|
||
2158 | secondFeat.setProp(att[0],att[1]);
|
||
2159 | }*/
|
||
2160 | if ((insert.getBlockFound() == true) && (attributesFollowFlag != 1)) { |
||
2161 | gestionaInsert(feature); |
||
2162 | } |
||
2163 | |||
2164 | //if (addingToBlock == false) {
|
||
2165 | //features.add(secondFeat);
|
||
2166 | //}
|
||
2167 | //if (addingToBlock == true/* && insert.getBlockFound() == true*/) {
|
||
2168 | //System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
|
||
2169 | //blk.add(feature);
|
||
2170 | //}
|
||
2171 | // 041129: A?adido para implementar los ATTRIBS.
|
||
2172 | if (attributesFollowFlag == 1) { |
||
2173 | 3151 | jmorell | isDoubleFeatured = true;
|
2174 | lastFeaBordes = feature; |
||
2175 | lastFeaFondos = secondFeat; |
||
2176 | 2809 | nacho | } else {
|
2177 | if (addingToBlock == false) { |
||
2178 | features.add(secondFeat); |
||
2179 | } |
||
2180 | |||
2181 | if (addingToBlock == true /* && insert.getBlockFound() == true*/) { |
||
2182 | //System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
|
||
2183 | blk.add(feature); |
||
2184 | } |
||
2185 | } |
||
2186 | } |
||
2187 | |||
2188 | /* (non-Javadoc)
|
||
2189 | * @see org.cresques.io.DxfFile.EntityFactory#createSolid(org.cresques.io.DxfGroupVector)
|
||
2190 | */
|
||
2191 | public void createSolid(DxfGroupVector grp) throws Exception { |
||
2192 | double x = 0.0; |
||
2193 | double y = 0.0; |
||
2194 | double z1 = 0.0; |
||
2195 | double z2 = 0.0; |
||
2196 | double z3 = 0.0; |
||
2197 | double z4 = 0.0; |
||
2198 | DxfGroup g = null;
|
||
2199 | |||
2200 | //Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
|
||
2201 | Point3D[] pts = new Point3D[4]; |
||
2202 | |||
2203 | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2204 | double extx = 0.0; |
||
2205 | double exty = 0.0; |
||
2206 | double extz = 1.0; |
||
2207 | |||
2208 | 3151 | jmorell | LineString3D lineString3D = new LineString3D();
|
2209 | 2809 | nacho | Polygon3D polygon3D = new Polygon3D();
|
2210 | 3151 | jmorell | Feature feaBordes = new Feature();
|
2211 | 2809 | nacho | Feature feaFondos = new Feature();
|
2212 | |||
2213 | //double elev = 0;
|
||
2214 | 3151 | jmorell | feaBordes.setProp("dxfEntity", "Solid"); |
2215 | 2809 | nacho | feaFondos.setProp("dxfEntity", "Solid"); |
2216 | |||
2217 | 3151 | jmorell | if (grp.hasCode(8)) { |
2218 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
2219 | } |
||
2220 | 2809 | nacho | |
2221 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
2222 | x = grp.getDataAsDouble(10);
|
||
2223 | y = grp.getDataAsDouble(20);
|
||
2224 | z1 = grp.getDataAsDouble(30);
|
||
2225 | |||
2226 | /*if (grp.hasCode(30)) {
|
||
2227 | z1 = grp.getDataAsDouble(30);
|
||
2228 | } else {
|
||
2229 | Double doub = new Double(0.0);
|
||
2230 | feaBordes.setProp("elevation", doub.toString());
|
||
2231 | feaFondos.setProp("elevation", doub.toString());
|
||
2232 | }*/
|
||
2233 | Point2D pto = proj.createPoint(x, y);
|
||
2234 | Point3D pto3D = new Point3D(pto.getX(), pto.getY(), z1);
|
||
2235 | pts[0] = pto3D;
|
||
2236 | x = grp.getDataAsDouble(11);
|
||
2237 | y = grp.getDataAsDouble(21);
|
||
2238 | z2 = grp.getDataAsDouble(31);
|
||
2239 | pto = proj.createPoint(x, y); |
||
2240 | pto3D = new Point3D(pto.getX(), pto.getY(), z2);
|
||
2241 | pts[1] = pto3D;
|
||
2242 | x = grp.getDataAsDouble(12);
|
||
2243 | y = grp.getDataAsDouble(22);
|
||
2244 | z3 = grp.getDataAsDouble(32);
|
||
2245 | pto = proj.createPoint(x, y); |
||
2246 | pto3D = new Point3D(pto.getX(), pto.getY(), z3);
|
||
2247 | pts[2] = pto3D;
|
||
2248 | |||
2249 | if (grp.hasCode(13)) { |
||
2250 | x = grp.getDataAsDouble(13);
|
||
2251 | } |
||
2252 | |||
2253 | if (grp.hasCode(23)) { |
||
2254 | y = grp.getDataAsDouble(23);
|
||
2255 | } |
||
2256 | |||
2257 | if (grp.hasCode(33)) { |
||
2258 | z4 = grp.getDataAsDouble(33);
|
||
2259 | } |
||
2260 | |||
2261 | pto = proj.createPoint(x, y); |
||
2262 | pto3D = new Point3D(pto.getX(), pto.getY(), z4);
|
||
2263 | pts[3] = pto3D;
|
||
2264 | |||
2265 | if (grp.hasCode(39)) { |
||
2266 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
2267 | String string = doub.toString();
|
||
2268 | 3151 | jmorell | feaBordes.setProp("thickness", string);
|
2269 | 2809 | nacho | feaFondos.setProp("thickness", string);
|
2270 | } else {
|
||
2271 | Double doub = new Double(0.0); |
||
2272 | 3151 | jmorell | feaBordes.setProp("thickness", doub.toString());
|
2273 | 2809 | nacho | feaFondos.setProp("thickness", doub.toString());
|
2274 | } |
||
2275 | |||
2276 | if (grp.hasCode(62)) { |
||
2277 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
2278 | String string = integer.toString();
|
||
2279 | 3151 | jmorell | feaBordes.setProp("color", string);
|
2280 | 2809 | nacho | feaFondos.setProp("color", string);
|
2281 | 3151 | jmorell | feaBordes.setProp("colorByLayer", "false"); |
2282 | 2809 | nacho | feaFondos.setProp("colorByLayer", "false"); |
2283 | } else {
|
||
2284 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2285 | int clr = layer.colorNumber;
|
||
2286 | Integer integer = new Integer(clr); |
||
2287 | String string = integer.toString();
|
||
2288 | 3151 | jmorell | feaBordes.setProp("color", string);
|
2289 | 2809 | nacho | feaFondos.setProp("color", string);
|
2290 | 3151 | jmorell | feaBordes.setProp("colorByLayer", "true"); |
2291 | 2809 | nacho | feaFondos.setProp("colorByLayer", "true"); |
2292 | } |
||
2293 | |||
2294 | if (grp.hasCode(210)) { |
||
2295 | extx = grp.getDataAsDouble(210);
|
||
2296 | } |
||
2297 | |||
2298 | if (grp.hasCode(220)) { |
||
2299 | exty = grp.getDataAsDouble(220);
|
||
2300 | } |
||
2301 | |||
2302 | if (grp.hasCode(230)) { |
||
2303 | extz = grp.getDataAsDouble(230);
|
||
2304 | } |
||
2305 | |||
2306 | Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1); |
||
2307 | Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2); |
||
2308 | Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3); |
||
2309 | Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4); |
||
2310 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
2311 | Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
||
2312 | Point3D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru); |
||
2313 | Point3D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru); |
||
2314 | Point3D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru); |
||
2315 | pts[0] = new Point3D(point_out1); |
||
2316 | pts[1] = new Point3D(point_out2); |
||
2317 | pts[2] = new Point3D(point_out3); |
||
2318 | pts[3] = new Point3D(point_out4); |
||
2319 | |||
2320 | if ((pts[0].getZ() != 0.0) || (pts[1].getZ() != 0.0) || |
||
2321 | (pts[2].getZ() != 0.0) || (pts[3].getZ() != 0.0)) { |
||
2322 | dxf3DFile = true;
|
||
2323 | } |
||
2324 | |||
2325 | 5895 | luisw2 | Point3D aux = new Point3D(pts[2]); |
2326 | pts[2] = new Point3D(pts[3]); |
||
2327 | 2809 | nacho | pts[3] = aux;
|
2328 | |||
2329 | 5895 | luisw2 | Double doub = new Double(0.0); |
2330 | 2809 | nacho | if ((pts[0].getZ() == pts[1].getZ()) && |
2331 | (pts[1].getZ() == pts[2].getZ()) && |
||
2332 | (pts[2].getZ() == pts[3].getZ())) { |
||
2333 | 5895 | luisw2 | doub = new Double(pts[0].getZ()); |
2334 | 2809 | nacho | } |
2335 | 5895 | luisw2 | String string = doub.toString();
|
2336 | feaBordes.setProp("elevation", string);
|
||
2337 | feaFondos.setProp("elevation", string);
|
||
2338 | 2809 | nacho | |
2339 | for (int i = 0; i < pts.length; i++) { |
||
2340 | 3151 | jmorell | lineString3D.add(pts[i]); |
2341 | 2809 | nacho | polygon3D.add(pts[i]); |
2342 | } |
||
2343 | |||
2344 | // Para cerrarlos.
|
||
2345 | 3151 | jmorell | lineString3D.add(pts[0]);
|
2346 | 2809 | nacho | polygon3D.add(pts[0]);
|
2347 | |||
2348 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
2349 | 2809 | nacho | feaFondos.setGeometry(polygon3D); |
2350 | |||
2351 | // 041130: Rellena las props con los atributos.
|
||
2352 | 3151 | jmorell | completeAttributes(feaBordes); |
2353 | 2809 | nacho | completeAttributes(feaFondos); |
2354 | |||
2355 | //features.add(feature);
|
||
2356 | if (addingToBlock == false) { |
||
2357 | //System.out.println("createSolid(): A?ade un solid a la lista de entidades");
|
||
2358 | 3149 | jmorell | //features.add(feaBordes);
|
2359 | 2809 | nacho | features.add(feaFondos); |
2360 | } else {
|
||
2361 | //System.out.println("createSolid(): A?adimos un circulo al bloque " + iterator);
|
||
2362 | 3149 | jmorell | //blk.add(feaBordes);
|
2363 | 2809 | nacho | blk.add(feaFondos); |
2364 | } |
||
2365 | } |
||
2366 | |||
2367 | /* (non-Javadoc)
|
||
2368 | * @see org.cresques.io.DxfFile.EntityFactory#createSpline(org.cresques.io.DxfGroupVector)
|
||
2369 | */
|
||
2370 | public void createSpline(DxfGroupVector grp) throws Exception { |
||
2371 | double x = 0.0; //elev = 0.0; |
||
2372 | double y = 0.0; //elev = 0.0; |
||
2373 | double z = 0.0; //elev = 0.0; |
||
2374 | |||
2375 | //double elev = 0.0;
|
||
2376 | DxfGroup g = null;
|
||
2377 | LineString3D lineString3D = new LineString3D();
|
||
2378 | Polygon3D polygon3D = new Polygon3D();
|
||
2379 | |||
2380 | //Geometry geometria;
|
||
2381 | 3151 | jmorell | //Feature feature= new Feature();
|
2382 | Feature feaBordes = new Feature();
|
||
2383 | Feature feaFondos = new Feature();
|
||
2384 | 2809 | nacho | int flags = 0; |
2385 | |||
2386 | 3151 | jmorell | //feature.setProp("dxfEntity", "LwPolyline");
|
2387 | feaBordes.setProp("dxfEntity", "Spline"); |
||
2388 | feaFondos.setProp("dxfEntity", "Spline"); |
||
2389 | 2809 | nacho | |
2390 | if (grp.hasCode(8)) { |
||
2391 | 3151 | jmorell | //feature.setProp("layer", grp.getDataAsString(8));
|
2392 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
2393 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
2394 | 2809 | nacho | } |
2395 | |||
2396 | if (grp.hasCode(39)) { |
||
2397 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
2398 | String string = doub.toString();
|
||
2399 | |||
2400 | 3151 | jmorell | //feature.setProp("thickness", string);
|
2401 | feaBordes.setProp("thickness", string);
|
||
2402 | feaFondos.setProp("thickness", string);
|
||
2403 | 2809 | nacho | } else {
|
2404 | Double doub = new Double(0.0); |
||
2405 | |||
2406 | 3151 | jmorell | //feature.setProp("thickness", doub.toString());
|
2407 | feaBordes.setProp("thickness", doub.toString());
|
||
2408 | feaFondos.setProp("thickness", doub.toString());
|
||
2409 | 2809 | nacho | } |
2410 | |||
2411 | if (grp.hasCode(62)) { |
||
2412 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
2413 | String string = integer.toString();
|
||
2414 | |||
2415 | 3151 | jmorell | //feature.setProp("color", string);
|
2416 | feaBordes.setProp("color", string);
|
||
2417 | feaFondos.setProp("color", string);
|
||
2418 | feaBordes.setProp("colorByLayer", "false"); |
||
2419 | feaFondos.setProp("colorByLayer", "false"); |
||
2420 | 2809 | nacho | } else {
|
2421 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2422 | int clr = layer.colorNumber;
|
||
2423 | Integer integer = new Integer(clr); |
||
2424 | String string = integer.toString();
|
||
2425 | |||
2426 | 3151 | jmorell | //feature.setProp("color", string);
|
2427 | feaBordes.setProp("color", string);
|
||
2428 | feaFondos.setProp("color", string);
|
||
2429 | feaBordes.setProp("colorByLayer", "true"); |
||
2430 | feaFondos.setProp("colorByLayer", "true"); |
||
2431 | 2809 | nacho | } |
2432 | |||
2433 | if (grp.hasCode(70)) { |
||
2434 | flags = grp.getDataAsInt(70);
|
||
2435 | } |
||
2436 | |||
2437 | if ((flags & 0x01) == 0x01) { |
||
2438 | //geometria = new Polygon();
|
||
2439 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
2440 | feaFondos.setGeometry(polygon3D); |
||
2441 | isDoubleFeatured = true;
|
||
2442 | 2809 | nacho | } else {
|
2443 | //geometria = new LineString();
|
||
2444 | 3151 | jmorell | feaBordes.setGeometry(lineString3D); |
2445 | isDoubleFeatured = false;
|
||
2446 | 2809 | nacho | } |
2447 | |||
2448 | int j = 0; |
||
2449 | double firstX = 0.0; |
||
2450 | double firstY = 0.0; |
||
2451 | double firstZ = 0.0; |
||
2452 | |||
2453 | for (int i = 0; i < grp.size(); i++) { |
||
2454 | g = (DxfGroup) grp.get(i); |
||
2455 | |||
2456 | if (g.getCode() == 10) { |
||
2457 | j++; |
||
2458 | x = ((Double) g.getData()).doubleValue();
|
||
2459 | } else if (g.getCode() == 20) { |
||
2460 | y = ((Double) g.getData()).doubleValue();
|
||
2461 | } else if (g.getCode() == 30) { |
||
2462 | z = ((Double) g.getData()).doubleValue();
|
||
2463 | |||
2464 | Point2D p = proj.createPoint(x, y);
|
||
2465 | Point3D p3d = new Point3D(p.getX(), p.getY(), z);
|
||
2466 | lineString3D.add(p3d); |
||
2467 | |||
2468 | 3151 | jmorell | if (isDoubleFeatured) {
|
2469 | 2809 | nacho | polygon3D.add(p3d); |
2470 | } |
||
2471 | |||
2472 | if (j == 1) { |
||
2473 | firstX = x; |
||
2474 | firstY = y; |
||
2475 | firstZ = z; |
||
2476 | } |
||
2477 | |||
2478 | //elev = z;
|
||
2479 | x = 0.0;
|
||
2480 | y = 0.0;
|
||
2481 | z = 0.0;
|
||
2482 | } |
||
2483 | } |
||
2484 | |||
2485 | //Double doub = new Double(elev);
|
||
2486 | //String string = doub.toString();
|
||
2487 | //feature.setProp("elevation", string);
|
||
2488 | //feaBordes.setProp("elevation", string);
|
||
2489 | //feaFondos.setProp("elevation", string);
|
||
2490 | 3151 | jmorell | if (isDoubleFeatured) {
|
2491 | 2809 | nacho | Point2D p = proj.createPoint(firstX, firstY);
|
2492 | Point3D p3d = new Point3D(p.getX(), p.getY(), z);
|
||
2493 | lineString3D.add(p3d); |
||
2494 | polygon3D.add(p3d); |
||
2495 | } |
||
2496 | |||
2497 | double zprev = 0; |
||
2498 | boolean constSplineElev = true; |
||
2499 | |||
2500 | for (int i = 0; i < lineString3D.pointNr(); i++) { |
||
2501 | z = lineString3D.getPoint3D(i).getZ(); |
||
2502 | |||
2503 | if (z != 0.0) { |
||
2504 | dxf3DFile = true;
|
||
2505 | } |
||
2506 | |||
2507 | if ((i > 0) && (z != zprev)) { |
||
2508 | constSplineElev = false;
|
||
2509 | } |
||
2510 | |||
2511 | zprev = z; |
||
2512 | } |
||
2513 | |||
2514 | if (constSplineElev) {
|
||
2515 | Double doub = new Double(lineString3D.getPoint3D(0).getZ()); |
||
2516 | String string = doub.toString();
|
||
2517 | 3151 | jmorell | feaBordes.setProp("elevation", string);
|
2518 | 2809 | nacho | |
2519 | 3151 | jmorell | if (isDoubleFeatured) {
|
2520 | feaFondos.setProp("elevation", string);
|
||
2521 | 2809 | nacho | } |
2522 | } else {
|
||
2523 | Double doub = new Double(0.0); |
||
2524 | String string = doub.toString();
|
||
2525 | 3151 | jmorell | feaBordes.setProp("elevation", string);
|
2526 | 2809 | nacho | |
2527 | 3151 | jmorell | if (isDoubleFeatured) {
|
2528 | feaFondos.setProp("elevation", string);
|
||
2529 | 2809 | nacho | } |
2530 | } |
||
2531 | |||
2532 | 3151 | jmorell | lastFeaBordes = feaBordes; |
2533 | 2809 | nacho | |
2534 | 3151 | jmorell | if (isDoubleFeatured) {
|
2535 | lastFeaFondos = feaFondos; |
||
2536 | 2809 | nacho | } |
2537 | |||
2538 | // 041130: Rellena las props con los atributos.
|
||
2539 | 3151 | jmorell | completeAttributes(feaBordes); |
2540 | completeAttributes(feaFondos); |
||
2541 | 2809 | nacho | |
2542 | //features.add(feature);
|
||
2543 | if (addingToBlock == false) { |
||
2544 | 3151 | jmorell | if (isDoubleFeatured) {
|
2545 | features.add(feaFondos); |
||
2546 | } else {
|
||
2547 | features.add(feaBordes); |
||
2548 | 2809 | nacho | } |
2549 | } else {
|
||
2550 | //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
||
2551 | 3151 | jmorell | if (isDoubleFeatured) {
|
2552 | blk.add(feaFondos); |
||
2553 | } else {
|
||
2554 | blk.add(feaBordes); |
||
2555 | 2809 | nacho | } |
2556 | } |
||
2557 | |||
2558 | 3151 | jmorell | isDoubleFeatured = false;
|
2559 | 2809 | nacho | } |
2560 | |||
2561 | /* (non-Javadoc)
|
||
2562 | * @see org.cresques.io.DxfFile.EntityFactory#createAttdef(org.cresques.io.DxfGroupVector)
|
||
2563 | */
|
||
2564 | public void createAttdef(DxfGroupVector grp) throws Exception { |
||
2565 | DxfGroup g = null;
|
||
2566 | |||
2567 | String defaultValue = ""; |
||
2568 | String tagString = ""; |
||
2569 | String textStyleName = ""; |
||
2570 | String[] attribute = new String[2]; |
||
2571 | boolean tagDefined = false; |
||
2572 | boolean defValDefined = false; |
||
2573 | |||
2574 | if (grp.hasCode(1)) { |
||
2575 | defaultValue = grp.getDataAsString(1);
|
||
2576 | attribute[1] = DxfConvTexts.ConvertText(defaultValue);
|
||
2577 | defValDefined = true;
|
||
2578 | |||
2579 | if (tagDefined) {
|
||
2580 | attributes.add(attribute); |
||
2581 | } |
||
2582 | } |
||
2583 | |||
2584 | if (grp.hasCode(2)) { |
||
2585 | tagString = grp.getDataAsString(2);
|
||
2586 | attribute[0] = DxfConvTexts.ConvertText(tagString);
|
||
2587 | tagDefined = true;
|
||
2588 | |||
2589 | if (defValDefined) {
|
||
2590 | attributes.add(attribute); |
||
2591 | } |
||
2592 | } |
||
2593 | |||
2594 | if (grp.hasCode(7)) { |
||
2595 | textStyleName = grp.getDataAsString(7);
|
||
2596 | textStyleName = DxfConvTexts.ConvertText(textStyleName); |
||
2597 | } |
||
2598 | |||
2599 | setNewAttributes(); |
||
2600 | } |
||
2601 | |||
2602 | /* (non-Javadoc)
|
||
2603 | * @see org.cresques.io.DxfFile.EntityFactory#createAttrib(org.cresques.io.DxfGroupVector)
|
||
2604 | */
|
||
2605 | public void createAttrib(DxfGroupVector grp) throws Exception { |
||
2606 | double x = 0.0; |
||
2607 | double y = 0.0; |
||
2608 | double z = 0.0; |
||
2609 | double h = 0.0; |
||
2610 | double rot = 0.0; |
||
2611 | DxfGroup g = null;
|
||
2612 | |||
2613 | //Point2D pt1 = null, pt2 = null;
|
||
2614 | Point3D pt = null;
|
||
2615 | org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
||
2616 | |||
2617 | point.setTextPoint(true);
|
||
2618 | |||
2619 | String defaultValue = ""; |
||
2620 | String tagString = ""; |
||
2621 | String textStyleName = ""; |
||
2622 | String[] att = new String[2]; |
||
2623 | boolean tagDefined = false; |
||
2624 | boolean defValDefined = false; |
||
2625 | int attributeFlags = 0; |
||
2626 | |||
2627 | double extx = 0.0; |
||
2628 | double exty = 0.0; |
||
2629 | double extz = 1.0; |
||
2630 | |||
2631 | 3151 | jmorell | Feature insFea = lastFeaBordes; |
2632 | Feature ptFea = lastFeaFondos; |
||
2633 | 2809 | nacho | |
2634 | Feature feature = new Feature();
|
||
2635 | |||
2636 | feature.setProp("dxfEntity", "Attrib"); // <-- Es un INSERT con attributes. |
||
2637 | |||
2638 | if (grp.hasCode(8)) { |
||
2639 | feature.setProp("layer", grp.getDataAsString(8)); |
||
2640 | } |
||
2641 | |||
2642 | if (grp.hasCode(39)) { |
||
2643 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
2644 | String string = doub.toString();
|
||
2645 | feature.setProp("thickness", string);
|
||
2646 | } else {
|
||
2647 | Double doub = new Double(0.0); |
||
2648 | feature.setProp("thickness", doub.toString());
|
||
2649 | } |
||
2650 | |||
2651 | if (grp.hasCode(62)) { |
||
2652 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
2653 | String string = integer.toString();
|
||
2654 | feature.setProp("color", string);
|
||
2655 | feature.setProp("colorByLayer", "false"); |
||
2656 | } else {
|
||
2657 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2658 | int clr = layer.colorNumber;
|
||
2659 | Integer integer = new Integer(clr); |
||
2660 | String string = integer.toString();
|
||
2661 | feature.setProp("color", string);
|
||
2662 | feature.setProp("colorByLayer", "true"); |
||
2663 | } |
||
2664 | |||
2665 | if (grp.hasCode(1)) { |
||
2666 | String strAux1 = grp.getDataAsString(1); |
||
2667 | strAux1 = DxfConvTexts.ConvertText(strAux1); |
||
2668 | defaultValue = strAux1; |
||
2669 | att[1] = DxfConvTexts.ConvertText(defaultValue);
|
||
2670 | defValDefined = true;
|
||
2671 | |||
2672 | if (tagDefined) {
|
||
2673 | insFea.setProp(att[0], att[1]); |
||
2674 | ptFea.setProp(att[0], att[1]); |
||
2675 | } |
||
2676 | |||
2677 | feature.setProp("text", strAux1);
|
||
2678 | } |
||
2679 | |||
2680 | if (grp.hasCode(2)) { |
||
2681 | String strAux2 = grp.getDataAsString(2); |
||
2682 | strAux2 = DxfConvTexts.ConvertText(strAux2); |
||
2683 | tagString = strAux2; |
||
2684 | att[0] = DxfConvTexts.ConvertText(tagString);
|
||
2685 | tagDefined = true;
|
||
2686 | |||
2687 | if (defValDefined) {
|
||
2688 | insFea.setProp(att[0], att[1]); |
||
2689 | ptFea.setProp(att[0], att[1]); |
||
2690 | } |
||
2691 | } |
||
2692 | |||
2693 | if (grp.hasCode(7)) { |
||
2694 | textStyleName = grp.getDataAsString(7);
|
||
2695 | textStyleName = DxfConvTexts.ConvertText(textStyleName); |
||
2696 | } |
||
2697 | |||
2698 | if (grp.hasCode(70)) { |
||
2699 | attributeFlags = grp.getDataAsInt(70);
|
||
2700 | } |
||
2701 | |||
2702 | if (grp.hasCode(40)) { |
||
2703 | Double heightD = new Double(grp.getDataAsDouble(40)); |
||
2704 | String heightS = heightD.toString();
|
||
2705 | feature.setProp("textHeight", heightS);
|
||
2706 | } else {
|
||
2707 | feature.setProp("textHeight", "20.0"); |
||
2708 | } |
||
2709 | |||
2710 | if (grp.hasCode(50)) { |
||
2711 | Double rotD = new Double(grp.getDataAsDouble(50)); |
||
2712 | String rotS = rotD.toString();
|
||
2713 | feature.setProp("textRotation", rotS);
|
||
2714 | } else {
|
||
2715 | feature.setProp("textRotation", "0.0"); |
||
2716 | } |
||
2717 | |||
2718 | x = grp.getDataAsDouble(10);
|
||
2719 | y = grp.getDataAsDouble(20);
|
||
2720 | z = grp.getDataAsDouble(30);
|
||
2721 | |||
2722 | /*if (grp.hasCode(30)){
|
||
2723 | z = grp.getDataAsDouble(30);
|
||
2724 | Double doub = new Double(z);
|
||
2725 | String string = doub.toString();
|
||
2726 | feature.setProp("elevation", string);
|
||
2727 | } else {
|
||
2728 | Double doub = new Double(0.0);
|
||
2729 | feature.setProp("elevation", doub.toString());
|
||
2730 | }*/
|
||
2731 | if (grp.hasCode(210)) { |
||
2732 | extx = grp.getDataAsDouble(210);
|
||
2733 | } |
||
2734 | |||
2735 | if (grp.hasCode(220)) { |
||
2736 | exty = grp.getDataAsDouble(220);
|
||
2737 | } |
||
2738 | |||
2739 | if (grp.hasCode(230)) { |
||
2740 | extz = grp.getDataAsDouble(230);
|
||
2741 | } |
||
2742 | |||
2743 | Point3D point_in = new Point3D(x, y, z);
|
||
2744 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
2745 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
2746 | x = point_out.getX(); |
||
2747 | y = point_out.getY(); |
||
2748 | z = point_out.getZ(); |
||
2749 | |||
2750 | Double doub = new Double(z); |
||
2751 | feature.setProp("elevation", doub.toString());
|
||
2752 | |||
2753 | if (z != 0.0) { |
||
2754 | dxf3DFile = true;
|
||
2755 | } |
||
2756 | |||
2757 | point.add(new Point3D(x, y, z));
|
||
2758 | feature.setGeometry(point); |
||
2759 | |||
2760 | // 041130: Rellena las props con los atributos.
|
||
2761 | completeAttributes(feature); |
||
2762 | |||
2763 | if (attributeFlags == 8) { |
||
2764 | if (addingToBlock == false) { |
||
2765 | features.add(feature); |
||
2766 | } else {
|
||
2767 | blk.add(feature); |
||
2768 | } |
||
2769 | } |
||
2770 | } |
||
2771 | |||
2772 | /* (non-Javadoc)
|
||
2773 | * @see org.cresques.io.DxfFile.EntityFactory#createBlock(org.cresques.io.DxfGroupVector)
|
||
2774 | */
|
||
2775 | public void createBlock(DxfGroupVector grp) throws Exception { |
||
2776 | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2777 | blk = new FeatureCollection(proj);
|
||
2778 | |||
2779 | Point3D basePoint = new Point3D();
|
||
2780 | String blockName = ""; |
||
2781 | |||
2782 | //System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
|
||
2783 | addingToBlock = true;
|
||
2784 | |||
2785 | //System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
|
||
2786 | blkList.add(iterator, blk); |
||
2787 | |||
2788 | //System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
|
||
2789 | if (grp.hasCode(8)) { |
||
2790 | blk.setProp("layer", grp.getDataAsString(8)); |
||
2791 | } |
||
2792 | |||
2793 | if (grp.hasCode(62)) { |
||
2794 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
2795 | String string = integer.toString();
|
||
2796 | blk.setProp("color", string);
|
||
2797 | blk.setProp("colorByLayer", "false"); |
||
2798 | } else {
|
||
2799 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2800 | int clr = layer.colorNumber;
|
||
2801 | Integer integer = new Integer(clr); |
||
2802 | String string = integer.toString();
|
||
2803 | blk.setProp("color", string);
|
||
2804 | blk.setProp("colorByLayer", "true"); |
||
2805 | } |
||
2806 | |||
2807 | if (grp.hasCode(1)) { |
||
2808 | blockName = grp.getDataAsString(1);
|
||
2809 | |||
2810 | //blk.setBlkName(blockName);
|
||
2811 | blk.setProp("blockName", blockName);
|
||
2812 | } |
||
2813 | |||
2814 | if (grp.hasCode(2)) { |
||
2815 | blockName = grp.getDataAsString(2);
|
||
2816 | |||
2817 | //blk.setBlkName(blockName);
|
||
2818 | blk.setProp("blockName", blockName);
|
||
2819 | } |
||
2820 | |||
2821 | if (grp.hasCode(10)) { |
||
2822 | Double basePointX = new Double(grp.getDataAsDouble(10)); |
||
2823 | basePoint.X = grp.getDataAsDouble(10);
|
||
2824 | blk.setProp("basePointX", basePointX.toString());
|
||
2825 | } |
||
2826 | |||
2827 | if (grp.hasCode(20)) { |
||
2828 | Double basePointY = new Double(grp.getDataAsDouble(20)); |
||
2829 | basePoint.Y = grp.getDataAsDouble(20);
|
||
2830 | blk.setProp("basePointY", basePointY.toString());
|
||
2831 | } |
||
2832 | |||
2833 | if (grp.hasCode(30)) { |
||
2834 | Double basePointZ = new Double(grp.getDataAsDouble(30)); |
||
2835 | basePoint.Z = grp.getDataAsDouble(30);
|
||
2836 | |||
2837 | if (basePoint.getZ() != 0.0) { |
||
2838 | dxf3DFile = true;
|
||
2839 | } |
||
2840 | |||
2841 | blk.setProp("basePointZ", basePointZ.toString());
|
||
2842 | } |
||
2843 | |||
2844 | if (grp.hasCode(70)) { |
||
2845 | //blk.flags = grp.getDataAsInt(70);
|
||
2846 | Integer blockFlags = new Integer(grp.getDataAsInt(70)); |
||
2847 | blk.setProp("blockFlags", blockFlags.toString());
|
||
2848 | |||
2849 | // 041103: Hoy por hoy esto no lo utilizamos.
|
||
2850 | } |
||
2851 | } |
||
2852 | |||
2853 | /* (non-Javadoc)
|
||
2854 | * @see org.cresques.io.DxfFile.EntityFactory#endBlk(org.cresques.io.DxfGroupVector)
|
||
2855 | */
|
||
2856 | public void endBlk(DxfGroupVector grp) throws Exception { |
||
2857 | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
2858 | setAddingToBlock(false);
|
||
2859 | iterator = iterator + 1;
|
||
2860 | } |
||
2861 | |||
2862 | /* (non-Javadoc)
|
||
2863 | * @see org.cresques.io.DxfFile.EntityFactory#testBlocks()
|
||
2864 | */
|
||
2865 | public void testBlocks() { |
||
2866 | //System.out.println("getBlkList() = " + getBlkList());
|
||
2867 | Vector blkList = getBlkList();
|
||
2868 | FeatureCollection block = null;
|
||
2869 | Feature feature = null;
|
||
2870 | InsPoint3D insert = null;
|
||
2871 | |||
2872 | for (int i = 0; i < blkList.size(); i++) { |
||
2873 | //System.out.println("compruebaBloques(): Bloque " + i +" de " + blkList.size());
|
||
2874 | block = (FeatureCollection) blkList.get(i); |
||
2875 | |||
2876 | int aux = block.size();
|
||
2877 | |||
2878 | for (int j = 0; j < aux; j++) { |
||
2879 | feature = (Feature) block.get(j); |
||
2880 | |||
2881 | //if (feature.getGeometry() instanceof InsPoint && feature.getProp("isAnInsert") == "true") {
|
||
2882 | if (feature.getGeometry() instanceof InsPoint3D) { |
||
2883 | insert = (InsPoint3D) feature.getGeometry(); |
||
2884 | |||
2885 | String nomBlock = insert.getBlockName();
|
||
2886 | |||
2887 | if (insert.getBlockFound() == false) { |
||
2888 | //System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock);
|
||
2889 | insert.encuentraBloque(nomBlock); |
||
2890 | |||
2891 | //gestionaInsert(feature);
|
||
2892 | //block.add(feature);
|
||
2893 | } |
||
2894 | } |
||
2895 | } |
||
2896 | } |
||
2897 | } |
||
2898 | |||
2899 | /**
|
||
2900 | * M?todo que permite incluir en la lista general de objetos los objetos que se
|
||
2901 | * encuentran dentro del bloque referenciado por cada InsPoint3D.
|
||
2902 | * @param feature, el punto de inserci?n.
|
||
2903 | */
|
||
2904 | private void gestionaInsert(Feature feature) { |
||
2905 | Feature feature2 = null;
|
||
2906 | org.cresques.px.gml.Point3D point = null;
|
||
2907 | LineString3D lineString3D = null;
|
||
2908 | Polygon3D polygon3D = null;
|
||
2909 | InsPoint3D insert = new InsPoint3D();
|
||
2910 | insert = (InsPoint3D) feature.getGeometry(); |
||
2911 | |||
2912 | double bPointX = 0.0; |
||
2913 | double bPointY = 0.0; |
||
2914 | double bPointZ = 0.0; |
||
2915 | |||
2916 | 9190 | fjp | if (insert.getBlockFound() != true) |
2917 | { |
||
2918 | System.err.println("BLOQUE NO ENCONTRADO !!!" + insert.getBlockName() + " " + insert.toString()); |
||
2919 | return;
|
||
2920 | } |
||
2921 | |||
2922 | 2809 | nacho | bPointX = Double.parseDouble(insert.getBlock().getProp("basePointX")); |
2923 | bPointY = Double.parseDouble(insert.getBlock().getProp("basePointY")); |
||
2924 | bPointZ = Double.parseDouble(insert.getBlock().getProp("basePointZ")); |
||
2925 | |||
2926 | //}
|
||
2927 | double sFactorX = insert.getScaleFactor().getX();
|
||
2928 | double sFactorY = insert.getScaleFactor().getY();
|
||
2929 | double sFactorZ = insert.getScaleFactor().getZ();
|
||
2930 | double rAngleGra = insert.getRotAngle();
|
||
2931 | double rAngleRad = (rAngleGra * Math.PI) / 180.0; |
||
2932 | InsPoint3D insert2 = null;
|
||
2933 | |||
2934 | for (int i = 0; i < insert.getBlock().size(); i++) { |
||
2935 | //System.out.println("gestionaInserts: insert.getBlock().features.size() = " + insert.getBlock().size());
|
||
2936 | feature2 = (Feature) insert.getBlock().get(i); |
||
2937 | |||
2938 | // Para que los elementos dentro del bloque tengan la misma layer
|
||
2939 | // y color que el insert al que corresponden.
|
||
2940 | // Segun la especificacion del formato DXF de Autodesk, la layer
|
||
2941 | // de las entities dentro de un bloque es la del bloque. La
|
||
2942 | // layer especifica para estos elementos en la defincion del
|
||
2943 | // bloque se ignora.
|
||
2944 | //System.out.println("gestionaInsert(): layer = " + feature2.getProp("layer"));
|
||
2945 | if ((feature2.getProp("colorByLayer").equals("false") || |
||
2946 | feature2.getProp("layer").equals("0")) && |
||
2947 | !feature.getProp("layer").equals("0")) { |
||
2948 | feature2.setProp("color", feature.getProp("color")); |
||
2949 | } |
||
2950 | |||
2951 | feature2.setProp("layer", feature.getProp("layer")); |
||
2952 | |||
2953 | Point3D point1 = new Point3D();
|
||
2954 | Point3D point11 = new Point3D();
|
||
2955 | Point3D pointAux = null;
|
||
2956 | |||
2957 | if (feature2.getGeometry() instanceof InsPoint3D) { |
||
2958 | //System.out.println("gestionaInsert(): Encuentra bloques dentro de bloques");
|
||
2959 | insert2 = (InsPoint3D) feature2.getGeometry(); |
||
2960 | point1 = insert2.getPoint3D(0);
|
||
2961 | |||
2962 | pointAux = new Point3D(point1.getX() - bPointX,
|
||
2963 | point1.getY() - bPointY, |
||
2964 | point1.getZ() - bPointZ); |
||
2965 | |||
2966 | double laX = insert.getPoint3D(0).getX() + |
||
2967 | (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
||
2968 | ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
||
2969 | double laY = insert.getPoint3D(0).getY() + |
||
2970 | (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
||
2971 | ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
||
2972 | double laZ = insert.getPoint3D(0).getZ() + |
||
2973 | (pointAux.getZ() * sFactorZ); |
||
2974 | point11 = new Point3D(laX, laY, laZ);
|
||
2975 | |||
2976 | InsPoint3D insert3 = new InsPoint3D();
|
||
2977 | |||
2978 | insert3.add(point11); |
||
2979 | |||
2980 | insert3.setBlkList(insert2.getBlkList()); |
||
2981 | insert3.setBlock(insert2.getBlock()); |
||
2982 | insert3.setBlockName(insert2.getBlockName()); |
||
2983 | insert3.setRotAngle(insert2.getRotAngle()); |
||
2984 | |||
2985 | Point3D newScale = new Point3D(insert2.getScaleFactor().getX() * sFactorX,
|
||
2986 | insert2.getScaleFactor().getY() * sFactorY, |
||
2987 | insert2.getScaleFactor().getZ() * sFactorZ); |
||
2988 | insert3.setScaleFactor(newScale); |
||
2989 | |||
2990 | Feature feature3 = new Feature();
|
||
2991 | feature3.setProp("layer", feature2.getProp("layer")); |
||
2992 | feature3.setProp("color", feature2.getProp("color")); |
||
2993 | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
||
2994 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
2995 | |||
2996 | //041130
|
||
2997 | for (int j = 0; j < attributes.size(); j++) { |
||
2998 | String[] att = new String[2]; |
||
2999 | att = (String[]) attributes.get(j); |
||
3000 | feature3.setProp(att[0], feature2.getProp(att[0])); |
||
3001 | } |
||
3002 | |||
3003 | feature3.setGeometry(insert3); |
||
3004 | |||
3005 | gestionaInsert(feature3); |
||
3006 | } else if (feature2.getGeometry() instanceof LineString3D) { |
||
3007 | lineString3D = (LineString3D) feature2.getGeometry(); |
||
3008 | |||
3009 | LineString3D lineString2 = new LineString3D();
|
||
3010 | Point3D[] points = new Point3D[lineString3D.pointNr()]; |
||
3011 | Point3D[] pointss = new Point3D[lineString3D.pointNr()]; |
||
3012 | |||
3013 | for (int j = 0; j < lineString3D.pointNr(); j++) { |
||
3014 | points[j] = (Point3D) lineString3D.get(j); |
||
3015 | pointss[j] = new Point3D();
|
||
3016 | |||
3017 | pointAux = new Point3D(points[j].getX() - bPointX,
|
||
3018 | points[j].getY() - bPointY, |
||
3019 | points[j].getZ() - bPointZ); |
||
3020 | |||
3021 | double laX = insert.getPoint3D(0).getX() + |
||
3022 | (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
||
3023 | ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
||
3024 | double laY = insert.getPoint3D(0).getY() + |
||
3025 | (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
||
3026 | ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
||
3027 | double laZ = insert.getPoint3D(0).getZ() + |
||
3028 | (pointAux.getZ() * sFactorZ); |
||
3029 | pointss[j] = new Point3D(laX, laY, laZ);
|
||
3030 | lineString2.add(pointss[j]); |
||
3031 | } |
||
3032 | |||
3033 | Feature feature3 = new Feature();
|
||
3034 | feature3.setProp("layer", feature2.getProp("layer")); |
||
3035 | feature3.setProp("color", feature2.getProp("color")); |
||
3036 | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
||
3037 | |||
3038 | if (feature2.getProp("elevation") != null) { |
||
3039 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
3040 | } |
||
3041 | |||
3042 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
3043 | |||
3044 | //041130
|
||
3045 | for (int j = 0; j < attributes.size(); j++) { |
||
3046 | String[] att = new String[2]; |
||
3047 | att = (String[]) attributes.get(j); |
||
3048 | |||
3049 | String str = att[0]; |
||
3050 | feature3.setProp(str, feature2.getProp(str)); |
||
3051 | } |
||
3052 | |||
3053 | feature3.setGeometry(lineString2); |
||
3054 | |||
3055 | if (addingToBlock == false) { |
||
3056 | features.add(feature3); |
||
3057 | } |
||
3058 | } else if (feature2.getGeometry() instanceof Polygon3D) { |
||
3059 | polygon3D = (Polygon3D) feature2.getGeometry(); |
||
3060 | |||
3061 | Polygon3D polygon2 = new Polygon3D();
|
||
3062 | Point3D[] points = new Point3D[polygon3D.pointNr()]; |
||
3063 | Point3D[] pointss = new Point3D[polygon3D.pointNr()]; |
||
3064 | |||
3065 | for (int j = 0; j < polygon3D.pointNr(); j++) { |
||
3066 | points[j] = (Point3D) polygon3D.get(j); |
||
3067 | pointss[j] = new Point3D();
|
||
3068 | |||
3069 | pointAux = new Point3D(points[j].getX() - bPointX,
|
||
3070 | points[j].getY() - bPointY, |
||
3071 | points[j].getZ() - bPointZ); |
||
3072 | |||
3073 | double laX = insert.getPoint3D(0).getX() + |
||
3074 | (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
||
3075 | ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
||
3076 | double laY = insert.getPoint3D(0).getY() + |
||
3077 | (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
||
3078 | ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
||
3079 | double laZ = insert.getPoint3D(0).getZ() + |
||
3080 | (pointAux.getZ() * sFactorZ); |
||
3081 | pointss[j] = new Point3D(laX, laY, laZ);
|
||
3082 | polygon2.add(pointss[j]); |
||
3083 | } |
||
3084 | |||
3085 | Feature feature3 = new Feature();
|
||
3086 | feature3.setProp("layer", feature2.getProp("layer")); |
||
3087 | feature3.setProp("color", feature2.getProp("color")); |
||
3088 | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
||
3089 | |||
3090 | if (feature2.getProp("elevation") != null) { |
||
3091 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
3092 | } |
||
3093 | |||
3094 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
3095 | |||
3096 | //041130
|
||
3097 | for (int j = 0; j < attributes.size(); j++) { |
||
3098 | String[] att = new String[2]; |
||
3099 | att = (String[]) attributes.get(j); |
||
3100 | feature3.setProp(att[0], feature2.getProp(att[0])); |
||
3101 | } |
||
3102 | |||
3103 | feature3.setGeometry(polygon2); |
||
3104 | |||
3105 | if (addingToBlock == false) { |
||
3106 | features.add(feature3); |
||
3107 | } |
||
3108 | } else if (feature2.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
||
3109 | point = (org.cresques.px.gml.Point3D) feature2.getGeometry(); |
||
3110 | point1 = point.getPoint3D(0);
|
||
3111 | |||
3112 | pointAux = new Point3D(point1.getX() - bPointX,
|
||
3113 | point1.getY() - bPointY, |
||
3114 | point1.getZ() - bPointZ); |
||
3115 | |||
3116 | double laX = insert.getPoint3D(0).getX() + |
||
3117 | (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
|
||
3118 | ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad))); |
||
3119 | double laY = insert.getPoint3D(0).getY() + |
||
3120 | (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
|
||
3121 | ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
|
||
3122 | double laZ = insert.getPoint3D(0).getZ() + |
||
3123 | (pointAux.getZ() * sFactorZ); |
||
3124 | point11 = new Point3D(laX, laY, laZ);
|
||
3125 | |||
3126 | org.cresques.px.gml.Point3D pointt = new org.cresques.px.gml.Point3D();
|
||
3127 | pointt.add(point11); |
||
3128 | |||
3129 | Feature feature3 = new Feature();
|
||
3130 | feature3.setProp("layer", feature2.getProp("layer")); |
||
3131 | feature3.setProp("color", feature2.getProp("color")); |
||
3132 | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
||
3133 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
3134 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
3135 | |||
3136 | if (point.isTextPoint()) {
|
||
3137 | feature3.setProp("text", feature2.getProp("text")); |
||
3138 | feature3.setProp("textHeight",
|
||
3139 | feature2.getProp("textHeight"));
|
||
3140 | |||
3141 | double auxR = Double.parseDouble(feature2.getProp("textRotation")); |
||
3142 | |||
3143 | //System.out.println("auxR = " + auxR);
|
||
3144 | auxR = auxR + rAngleGra; |
||
3145 | feature3.setProp("textRotation", Double.toString(auxR)); |
||
3146 | |||
3147 | //System.out.println("gestionaInsert(): feature3.getProp(textRotation) = " + feature3.getProp("textRotation"));
|
||
3148 | pointt.setTextPoint(true);
|
||
3149 | } |
||
3150 | |||
3151 | //041130
|
||
3152 | for (int j = 0; j < attributes.size(); j++) { |
||
3153 | String[] att = new String[2]; |
||
3154 | att = (String[]) attributes.get(j); |
||
3155 | feature3.setProp(att[0], feature2.getProp(att[0])); |
||
3156 | } |
||
3157 | |||
3158 | feature3.setGeometry(pointt); |
||
3159 | |||
3160 | //if (addingToBlock == false) {
|
||
3161 | features.add(feature3); |
||
3162 | |||
3163 | //}
|
||
3164 | } else {
|
||
3165 | System.out.println("gestionaInsert(): Encontrado elemento desconocido"); |
||
3166 | } |
||
3167 | } |
||
3168 | } |
||
3169 | |||
3170 | /**
|
||
3171 | * Gestiona la caracter?stica faces en las polil?neas.
|
||
3172 | * @param face
|
||
3173 | */
|
||
3174 | private void addFace(int[] face) { |
||
3175 | hasFaces = true;
|
||
3176 | |||
3177 | if (faces == null) { |
||
3178 | faces = new Vector(); |
||
3179 | } |
||
3180 | |||
3181 | faces.add(face); |
||
3182 | } |
||
3183 | |||
3184 | /* (non-Javadoc)
|
||
3185 | * @see org.cresques.io.DxfFile.EntityFactory#depureAttributes()
|
||
3186 | */
|
||
3187 | public void depureAttributes() { |
||
3188 | //String[] att = null;
|
||
3189 | |||
3190 | /*Set conjunto = new HashSet();
|
||
3191 | for (int i=0;i<attributes.size();i++) {
|
||
3192 | att = (String[])attributes.get(i);
|
||
3193 | String str = att[0];
|
||
3194 | conjunto.add(str);
|
||
3195 | }
|
||
3196 | //conjunto.addAll(attributes);
|
||
3197 | Vector atts = new Vector();
|
||
3198 | Vector atts2 = new Vector();
|
||
3199 | atts.addAll(conjunto);
|
||
3200 | for (int i=0;i<atts.size();i++) {
|
||
3201 | if (((String[])(attributes.get(i)))[0] == atts.get(i)) {
|
||
3202 | atts2.add(i, attributes.get(i));
|
||
3203 | }
|
||
3204 | }*/
|
||
3205 | String[] lastAtt = new String[2]; |
||
3206 | |||
3207 | for (int i = 0; i < attributes.size(); i++) { |
||
3208 | String[] att = (String[]) attributes.get(i); |
||
3209 | |||
3210 | for (int j = i + 1; j < attributes.size(); j++) { |
||
3211 | //System.out.println("depureAttributes(): j = " + j);
|
||
3212 | String[] st = (String[]) attributes.get(j); |
||
3213 | String st1 = att[0]; |
||
3214 | String st2 = st[0]; |
||
3215 | |||
3216 | //System.out.println("depureAttributes(): st1 = " + st1);
|
||
3217 | //System.out.println("depureAttributes(): st2 = " + st2);
|
||
3218 | if (st2.equals(st1)) {
|
||
3219 | //System.out.println("depureAttributes(): Borra el st2");
|
||
3220 | attributes.remove(j); |
||
3221 | } |
||
3222 | |||
3223 | if (i == (attributes.size() - 1)) { |
||
3224 | lastAtt = att; |
||
3225 | } |
||
3226 | } |
||
3227 | } |
||
3228 | |||
3229 | for (int i = attributes.size() - 2; i >= 0; i--) { |
||
3230 | String[] att = (String[]) attributes.get(i); |
||
3231 | String st1 = lastAtt[0]; |
||
3232 | String st2 = att[0]; |
||
3233 | |||
3234 | if (st2.equals(st1)) {
|
||
3235 | attributes.remove(i); |
||
3236 | } |
||
3237 | } |
||
3238 | |||
3239 | /*String[] attStrs = new String[attributes.size()];
|
||
3240 | Vector attribs = new Vector();
|
||
3241 | for (int i=0;i<attributes.size();i++) {
|
||
3242 | att = (String[])attributes.get(i);
|
||
3243 | attStrs[i] = att[0];
|
||
3244 | }
|
||
3245 | Set attStrsNR = new HashSet();
|
||
3246 | for (int i=0;i<attStrs.length;i++) {
|
||
3247 | attStrsNR.add(attStrs[i]);
|
||
3248 | }
|
||
3249 | String[] attStrsNRA = new String[attStrsNR.size()];
|
||
3250 | attStrsNR.toArray(attStrsNRA);
|
||
3251 | for (int i=0;i<attStrsNR.size();i++) {
|
||
3252 | att[0] = attStrsNRA[i];
|
||
3253 | attribs.add(att);
|
||
3254 | }
|
||
3255 | for (int i=0;i<attributes.size();i++) {
|
||
3256 | att = (String[])attributes.get(i);
|
||
3257 | String[] att2 = new String[2];
|
||
3258 | for (int j=0;j<attribs.size();j++) {
|
||
3259 | att2 = (String[])attribs.get(j);
|
||
3260 | if (att[0].equals(att2[0])) {
|
||
3261 | att2[1] = att[1];
|
||
3262 | }
|
||
3263 | attribs.set(j, att2);
|
||
3264 | }
|
||
3265 | }
|
||
3266 | attributes = attribs;*/
|
||
3267 | } |
||
3268 | |||
3269 | /**
|
||
3270 | * Hace los setProp para los atributos extra de las entidades.
|
||
3271 | * @param feature
|
||
3272 | */
|
||
3273 | private void completeAttributes(Feature feature) { |
||
3274 | // 041130: Rellena las props con los atributos.
|
||
3275 | for (int i = 0; i < attributes.size(); i++) { |
||
3276 | String[] att = new String[2]; |
||
3277 | att = (String[]) attributes.get(i); |
||
3278 | feature.setProp(att[0], att[1]); |
||
3279 | } |
||
3280 | } |
||
3281 | |||
3282 | /**
|
||
3283 | * Copia los atributos extra cargados en InsPoint y ya perfectamente definidos a los
|
||
3284 | * elementos del bloque al que referencia el punto de insercion.
|
||
3285 | * @param feaInsert, punto de inserci?n.
|
||
3286 | */
|
||
3287 | private void copyAttributes(Feature feaInsert) { |
||
3288 | Feature feature = null;
|
||
3289 | InsPoint3D insert = new InsPoint3D();
|
||
3290 | insert = (InsPoint3D) feaInsert.getGeometry(); |
||
3291 | |||
3292 | for (int i = 0; i < insert.getBlock().size(); i++) { |
||
3293 | feature = (Feature) insert.getBlock().get(i); |
||
3294 | |||
3295 | for (int j = 0; j < attributes.size(); j++) { |
||
3296 | String[] att = new String[2]; |
||
3297 | att = (String[]) attributes.get(j); |
||
3298 | feature.setProp(att[0], feaInsert.getProp(att[0])); |
||
3299 | } |
||
3300 | } |
||
3301 | } |
||
3302 | |||
3303 | /**
|
||
3304 | * Se ejecuta cuando se declaran nuevos atributos, es decir, tras cada ATTDEF.
|
||
3305 | * A?ade estos atributos a las features existentes.
|
||
3306 | */
|
||
3307 | private void setNewAttributes() { |
||
3308 | for (int i = 0; i < features.size(); i++) { |
||
3309 | Feature fea = new Feature();
|
||
3310 | fea = (Feature) features.get(i); |
||
3311 | completeAttributes(fea); |
||
3312 | } |
||
3313 | |||
3314 | for (int i = 0; i < blkList.size(); i++) { |
||
3315 | FeatureCollection bloque = new FeatureCollection(proj);
|
||
3316 | bloque = (FeatureCollection) blkList.get(i); |
||
3317 | |||
3318 | for (int j = 0; j < bloque.size(); j++) { |
||
3319 | Feature fea = new Feature();
|
||
3320 | fea = (Feature) bloque.get(j); |
||
3321 | completeAttributes(fea); |
||
3322 | } |
||
3323 | } |
||
3324 | } |
||
3325 | |||
3326 | /* (non-Javadoc)
|
||
3327 | * @see org.cresques.io.DxfFile.EntityFactory#getAttributes()
|
||
3328 | */
|
||
3329 | public Vector getAttributes() { |
||
3330 | return attributes;
|
||
3331 | } |
||
3332 | |||
3333 | /* (non-Javadoc)
|
||
3334 | * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
|
||
3335 | */
|
||
3336 | public Extent getExtent() {
|
||
3337 | Feature feature = new Feature();
|
||
3338 | Extent extent = new Extent();
|
||
3339 | Iterator iter = features.iterator();
|
||
3340 | |||
3341 | while (iter.hasNext()) {
|
||
3342 | feature = (Feature) iter.next(); |
||
3343 | extent.add(feature.getExtent()); |
||
3344 | } |
||
3345 | |||
3346 | return extent;
|
||
3347 | } |
||
3348 | |||
3349 | /**
|
||
3350 | * Establece la proyecci?n cartogr?fica en la que se van a crear las features.
|
||
3351 | * @param p, Proyecci?n cartogr?fica.
|
||
3352 | */
|
||
3353 | public void setProjection(IProjection p) { |
||
3354 | proj = p; |
||
3355 | } |
||
3356 | |||
3357 | /* (non-Javadoc)
|
||
3358 | * @see org.cresques.io.DxfFile.EntityFactory#reProject(org.cresques.geo.ReProjection)
|
||
3359 | */
|
||
3360 | public void reProject(ICoordTrans rp) { |
||
3361 | Feature feature = new Feature();
|
||
3362 | Extent extent = new Extent();
|
||
3363 | Iterator iter = features.iterator();
|
||
3364 | |||
3365 | while (iter.hasNext()) {
|
||
3366 | feature = (Feature) iter.next(); |
||
3367 | ((Projected) feature).reProject(rp); |
||
3368 | extent.add(feature.getExtent()); |
||
3369 | } |
||
3370 | |||
3371 | setProjection(rp.getPDest()); |
||
3372 | } |
||
3373 | |||
3374 | /* (non-Javadoc)
|
||
3375 | * @see org.cresques.geo.Projected#getProjection()
|
||
3376 | */
|
||
3377 | public IProjection getProjection() {
|
||
3378 | return proj;
|
||
3379 | } |
||
3380 | |||
3381 | /**
|
||
3382 | * Devuelve las features creadas.
|
||
3383 | * @return IObjList
|
||
3384 | */
|
||
3385 | public IObjList getObjects() {
|
||
3386 | return features;
|
||
3387 | } |
||
3388 | |||
3389 | /**
|
||
3390 | * Permite dibujar las features creadas.
|
||
3391 | */
|
||
3392 | public void draw(Graphics2D g, ViewPortData vp) { |
||
3393 | Iterator iter = features.iterator();
|
||
3394 | Extent extent; |
||
3395 | |||
3396 | while (iter.hasNext()) {
|
||
3397 | Feature feature = new Feature();
|
||
3398 | feature = (Feature) iter.next(); |
||
3399 | extent = feature.getExtent(); |
||
3400 | |||
3401 | if (vp.getExtent().minX() > extent.maxX()) {
|
||
3402 | continue;
|
||
3403 | } |
||
3404 | |||
3405 | if (vp.getExtent().minY() > extent.maxY()) {
|
||
3406 | continue;
|
||
3407 | } |
||
3408 | |||
3409 | if (vp.getExtent().maxX() < extent.minX()) {
|
||
3410 | continue;
|
||
3411 | } |
||
3412 | |||
3413 | if (vp.getExtent().maxY() < extent.minY()) {
|
||
3414 | continue;
|
||
3415 | } |
||
3416 | |||
3417 | //if (!feature.layer.frozen)
|
||
3418 | feature.draw(g, vp); |
||
3419 | } |
||
3420 | } |
||
3421 | |||
3422 | /**
|
||
3423 | * Invoca el m?todo de creaci?n de arcos para polil?neas con par?metros de
|
||
3424 | * curvatura.
|
||
3425 | * @param coord1, punto inicial del arco.
|
||
3426 | * @param coord2, punto final del arco.
|
||
3427 | * @param bulge, par?metro de curvatura.
|
||
3428 | * @return Vector con los puntos del arco.
|
||
3429 | */
|
||
3430 | public static Vector createArc(Point2D coord1, Point2D coord2, double bulge) { |
||
3431 | return new DxfCalArcs(coord1, coord2, bulge).getPoints(1); |
||
3432 | } |
||
3433 | |||
3434 | /* (non-Javadoc)
|
||
3435 | * @see org.cresques.io.DxfFile.EntityFactory#getBlkList()
|
||
3436 | */
|
||
3437 | public Vector getBlkList() { |
||
3438 | return blkList;
|
||
3439 | } |
||
3440 | |||
3441 | /* (non-Javadoc)
|
||
3442 | * @see org.cresques.io.DxfFile.EntityFactory#getDxfEntityList()
|
||
3443 | */
|
||
3444 | public DxfEntityList getDxfEntityList() {
|
||
3445 | // TODO Auto-generated method stub
|
||
3446 | return null; |
||
3447 | } |
||
3448 | |||
3449 | /* (non-Javadoc)
|
||
3450 | * @see org.cresques.io.DxfFile.EntityFactory#getBlk()
|
||
3451 | */
|
||
3452 | public DxfBlock getBlk() {
|
||
3453 | // TODO Auto-generated method stub
|
||
3454 | return null; |
||
3455 | } |
||
3456 | |||
3457 | /* (non-Javadoc)
|
||
3458 | * @see org.cresques.io.DxfFile.EntityFactory#createEllipse(org.cresques.io.DxfGroupVector)
|
||
3459 | */
|
||
3460 | 5404 | fjp | public void createEllipse(DxfGroupVector grp) throws Exception { |
3461 | double cx = 0.0; |
||
3462 | double cy = 0.0; |
||
3463 | double cz = 0.0; |
||
3464 | |||
3465 | double x_end_point_major_axis = 0.0; |
||
3466 | double y_end_point_major_axis = 0.0; |
||
3467 | double z_end_point_major_axis = 0.0; |
||
3468 | |||
3469 | double extx = 0.0; |
||
3470 | double exty = 0.0; |
||
3471 | double extz = 1.0; |
||
3472 | double ratio_minor_to_major_axis = 1.0; |
||
3473 | double start = 0.0; |
||
3474 | double end = 2* Math.PI; |
||
3475 | LineString3D lineString3D = new LineString3D();
|
||
3476 | Polygon3D polygon3D = new Polygon3D();
|
||
3477 | Feature feaBordes = new Feature();
|
||
3478 | Feature feaFondos = new Feature();
|
||
3479 | |||
3480 | feaBordes.setProp("dxfEntity", "Ellipse"); |
||
3481 | feaFondos.setProp("dxfEntity", "Ellipse"); |
||
3482 | |||
3483 | if (grp.hasCode(8)) { |
||
3484 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
3485 | } |
||
3486 | |||
3487 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
3488 | |||
3489 | if (grp.hasCode(39)) { |
||
3490 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
3491 | String string = doub.toString();
|
||
3492 | feaBordes.setProp("thickness", string);
|
||
3493 | feaFondos.setProp("thickness", string);
|
||
3494 | } else {
|
||
3495 | Double doub = new Double(0.0); |
||
3496 | feaBordes.setProp("thickness", doub.toString());
|
||
3497 | feaFondos.setProp("thickness", doub.toString());
|
||
3498 | } |
||
3499 | |||
3500 | if (grp.hasCode(62)) { |
||
3501 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
3502 | String string = integer.toString();
|
||
3503 | feaBordes.setProp("color", string);
|
||
3504 | feaFondos.setProp("color", string);
|
||
3505 | feaBordes.setProp("colorByLayer", "false"); |
||
3506 | feaFondos.setProp("colorByLayer", "false"); |
||
3507 | } else {
|
||
3508 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
3509 | int clr = layer.colorNumber;
|
||
3510 | Integer integer = new Integer(clr); |
||
3511 | String string = integer.toString();
|
||
3512 | feaBordes.setProp("color", string);
|
||
3513 | feaFondos.setProp("color", string);
|
||
3514 | feaBordes.setProp("colorByLayer", "true"); |
||
3515 | feaFondos.setProp("colorByLayer", "true"); |
||
3516 | } |
||
3517 | |||
3518 | // Center point
|
||
3519 | cx = grp.getDataAsDouble(10);
|
||
3520 | cy = grp.getDataAsDouble(20);
|
||
3521 | if (grp.hasCode(30)) { |
||
3522 | cz = grp.getDataAsDouble(30);
|
||
3523 | } |
||
3524 | |||
3525 | 5408 | fjp | // end_point_major_axis (RELATIVE to the center)
|
3526 | 5404 | fjp | x_end_point_major_axis = grp.getDataAsDouble(11);
|
3527 | y_end_point_major_axis = grp.getDataAsDouble(21);
|
||
3528 | 5408 | fjp | if (grp.hasCode(31)) { |
3529 | 5404 | fjp | z_end_point_major_axis = grp.getDataAsDouble(31);
|
3530 | } |
||
3531 | |||
3532 | // ratio minor axis to major axis
|
||
3533 | if (grp.hasCode(40)) { |
||
3534 | ratio_minor_to_major_axis = grp.getDataAsDouble(40);
|
||
3535 | } |
||
3536 | Point2D c = proj.createPoint(cx, cy);
|
||
3537 | 5408 | fjp | // Point2D end_major = proj.createPoint(x_end_point_major_axis, y_end_point_major_axis);
|
3538 | // double r_major_axis_2D = c.distance(end_major)/2.0;
|
||
3539 | double r_major_axis_2D = Math.sqrt(x_end_point_major_axis* |
||
3540 | x_end_point_major_axis + |
||
3541 | y_end_point_major_axis * y_end_point_major_axis); |
||
3542 | 5404 | fjp | double r_minor_axis_2D = r_major_axis_2D * ratio_minor_to_major_axis;
|
3543 | 5408 | fjp | double rotation_angle = Math.atan2(y_end_point_major_axis , x_end_point_major_axis); |
3544 | 5404 | fjp | |
3545 | if (grp.hasCode(210)) { |
||
3546 | extx = grp.getDataAsDouble(210);
|
||
3547 | } |
||
3548 | |||
3549 | if (grp.hasCode(220)) { |
||
3550 | exty = grp.getDataAsDouble(220);
|
||
3551 | } |
||
3552 | |||
3553 | if (grp.hasCode(230)) { |
||
3554 | extz = grp.getDataAsDouble(230);
|
||
3555 | } |
||
3556 | |||
3557 | Point3D point_in = new Point3D(cx, cy, cz);
|
||
3558 | Point3D xtru = new Point3D(extx, exty, extz);
|
||
3559 | Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
||
3560 | cx = point_out.getX(); |
||
3561 | cy = point_out.getY(); |
||
3562 | cz = point_out.getZ(); |
||
3563 | |||
3564 | Double doub = new Double(cz); |
||
3565 | feaBordes.setProp("elevation", doub.toString());
|
||
3566 | feaFondos.setProp("elevation", doub.toString());
|
||
3567 | |||
3568 | if (cz != 0.0) { |
||
3569 | dxf3DFile = true;
|
||
3570 | } |
||
3571 | |||
3572 | |||
3573 | Point3D center = new Point3D(c.getX(), c.getY(), cz);
|
||
3574 | Point3D[] pts = new Point3D[360]; |
||
3575 | int angulo = 0; |
||
3576 | |||
3577 | for (angulo = 0; angulo < 360; angulo++) { |
||
3578 | 5408 | fjp | pts[angulo] = new Point3D(center.getX() +
|
3579 | r_major_axis_2D * Math.cos(Math.toRadians(angulo)), |
||
3580 | center.getY() + |
||
3581 | r_minor_axis_2D * Math.sin(Math.toRadians(angulo)), |
||
3582 | 5404 | fjp | center.getZ()); |
3583 | |||
3584 | if (pts.length == 1) { |
||
3585 | firstPt = pts[angulo]; |
||
3586 | } |
||
3587 | } |
||
3588 | |||
3589 | AffineTransform at = new AffineTransform(); |
||
3590 | at.rotate(rotation_angle, cx, cy); |
||
3591 | for (int i = 0; i < pts.length; i++) { |
||
3592 | Point2D pAux = pts[i];
|
||
3593 | Point2D pRot = at.transform(pAux, null); |
||
3594 | lineString3D.add(pRot); |
||
3595 | polygon3D.add(pRot); |
||
3596 | } |
||
3597 | |||
3598 | feaBordes.setGeometry(lineString3D); |
||
3599 | feaFondos.setGeometry(polygon3D); |
||
3600 | |||
3601 | // 041130: Rellena las props con los atributos.
|
||
3602 | completeAttributes(feaBordes); |
||
3603 | completeAttributes(feaFondos); |
||
3604 | |||
3605 | //features.add(feature);
|
||
3606 | if (addingToBlock == false) { |
||
3607 | //System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
||
3608 | //features.add(feaBordes);
|
||
3609 | features.add(feaFondos); |
||
3610 | } else {
|
||
3611 | //System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
||
3612 | //blk.add(feaBordes);
|
||
3613 | blk.add(feaFondos); |
||
3614 | } |
||
3615 | |||
3616 | 2809 | nacho | } |
3617 | |||
3618 | /**
|
||
3619 | * @return Returns the dxf3DFile.
|
||
3620 | */
|
||
3621 | public boolean isDxf3DFile() { |
||
3622 | return dxf3DFile;
|
||
3623 | } |
||
3624 | |||
3625 | /**
|
||
3626 | * @param dxf3DFile The dxf3DFile to set.
|
||
3627 | */
|
||
3628 | public void setDxf3DFile(boolean dxf3DFile) { |
||
3629 | this.dxf3DFile = dxf3DFile;
|
||
3630 | } |
||
3631 | 44 | jmorell | } |