root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfFeatureMaker.java @ 2326
History | View | Annotate | Download (86 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.px.dxf; |
25 |
|
26 |
import java.awt.Graphics2D; |
27 |
import java.awt.geom.Point2D; |
28 |
import java.util.Iterator; |
29 |
import java.util.Vector; |
30 |
|
31 |
import org.cresques.cts.ICoordTrans; |
32 |
import org.cresques.cts.IProjection; |
33 |
import org.cresques.geo.Point3D; |
34 |
import org.cresques.geo.Projected; |
35 |
import org.cresques.geo.ViewPortData; |
36 |
import org.cresques.io.DxfFile; |
37 |
import org.cresques.io.DxfGroup; |
38 |
import org.cresques.io.DxfGroupVector; |
39 |
import org.cresques.px.Extent; |
40 |
import org.cresques.px.IObjList; |
41 |
import org.cresques.px.gml.Feature; |
42 |
import org.cresques.px.gml.FeatureCollection; |
43 |
import org.cresques.px.gml.InsPoint3D; |
44 |
import org.cresques.px.gml.LineString; |
45 |
import org.cresques.px.gml.LineString3D; |
46 |
import org.cresques.px.gml.Polygon; |
47 |
import org.cresques.px.gml.Polygon3D; |
48 |
|
49 |
/**
|
50 |
* Implementaci?n de la creaci?n de features de un DXF2000.
|
51 |
*/
|
52 |
public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected { |
53 |
IProjection proj = null;
|
54 |
//Feature lastFeature = null;
|
55 |
Feature lastFeaBordes = null;
|
56 |
Feature lastFeaFondos = null;
|
57 |
boolean isDoubleFeatured = false; |
58 |
FeatureCollection features = null;
|
59 |
double bulge = 0.0; |
60 |
double xtruX=0.0, xtruY=0.0, xtruZ=1.0; |
61 |
int polylineFlag = 0; |
62 |
Point3D firstPt = new Point3D();
|
63 |
Point3D ptAnterior = null;
|
64 |
|
65 |
boolean addingToBlock = false; |
66 |
int iterator = 0; |
67 |
FeatureCollection blk = null;
|
68 |
Vector blkList = null; |
69 |
DxfTable layers = null;
|
70 |
|
71 |
private Vector faces = null; |
72 |
private boolean hasFaces = false; |
73 |
private int facesIterador = 1; |
74 |
private Point2D facesFirstPoint = null; |
75 |
|
76 |
private Vector attributes = null; |
77 |
private boolean constantPolylineElevation; |
78 |
private double lastVertexElevation; |
79 |
private boolean dxf3DFile; |
80 |
|
81 |
public DxfFeatureMaker(IProjection proj) {
|
82 |
this.proj = proj;
|
83 |
layers = new DxfTable();
|
84 |
features = new FeatureCollection(proj);
|
85 |
blkList = new Vector(); |
86 |
attributes = new Vector(); |
87 |
dxf3DFile = false;
|
88 |
} |
89 |
|
90 |
public void setAddingToBlock(boolean a) { addingToBlock = a; } |
91 |
|
92 |
public void createLayer(DxfGroupVector v) throws Exception { |
93 |
int color = v.getDataAsInt(62); |
94 |
DxfLayer layer = new DxfLayer(v.getDataAsString(2), Math.abs(v.getDataAsInt(62))); |
95 |
if (color < 0) { |
96 |
layer.isOff = true;
|
97 |
} |
98 |
layer.lType = v.getDataAsString(6);
|
99 |
layer.setFlags(v.getDataAsInt(70));
|
100 |
// compruebo flags
|
101 |
if ((layer.flags & 0x01) == 0x01) { |
102 |
layer.frozen = true;
|
103 |
} |
104 |
if ((layer.flags & 0x02) == 0x02) { |
105 |
layer.frozen = true;
|
106 |
} |
107 |
System.out.println("LAYER color="+layer.getColor()); |
108 |
|
109 |
layers.add(layer); |
110 |
} |
111 |
|
112 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
113 |
LineString3D lineString3D = new LineString3D();
|
114 |
Polygon3D polygon3D = new Polygon3D();
|
115 |
//Feature feature= new Feature();
|
116 |
Feature feaBordes= new Feature();
|
117 |
Feature feaFondos= new Feature();
|
118 |
double x = 0.0, y = 0.0, z = 0.0; |
119 |
int flags = 0; |
120 |
constantPolylineElevation = true;
|
121 |
|
122 |
// 041122: Cada polyline tiene asociado un objeto faces distinto.
|
123 |
faces = new Vector(); |
124 |
|
125 |
//feature.setProp("dxfEntity", "Polyline");
|
126 |
feaBordes.setProp("dxfEntity", "Polyline"); |
127 |
feaFondos.setProp("dxfEntity", "Polyline"); |
128 |
if (grp.hasCode(8)) { |
129 |
//feature.setProp("layer", grp.getDataAsString(8));
|
130 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
131 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
132 |
} |
133 |
if (grp.hasCode(39)) { |
134 |
Double doub = new Double(grp.getDataAsDouble(39)); |
135 |
String string = doub.toString();
|
136 |
//feature.setProp("thickness", string);
|
137 |
feaBordes.setProp("thickness", string);
|
138 |
feaFondos.setProp("thickness", string);
|
139 |
} else {
|
140 |
Double doub = new Double(0.0); |
141 |
//feature.setProp("thickness", doub.toString());
|
142 |
feaBordes.setProp("thickness", doub.toString());
|
143 |
feaFondos.setProp("thickness", doub.toString());
|
144 |
} |
145 |
if (grp.hasCode(62)) { |
146 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
147 |
String string = integer.toString();
|
148 |
//feature.setProp("color", string);
|
149 |
feaBordes.setProp("color", string);
|
150 |
feaFondos.setProp("color", string);
|
151 |
feaBordes.setProp("colorByLayer", "false"); |
152 |
feaFondos.setProp("colorByLayer", "false"); |
153 |
} else {
|
154 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
155 |
int clr = layer.colorNumber;
|
156 |
Integer integer = new Integer(clr); |
157 |
String string = integer.toString();
|
158 |
//feature.setProp("color", string);
|
159 |
feaBordes.setProp("color", string);
|
160 |
feaFondos.setProp("color", string);
|
161 |
feaBordes.setProp("colorByLayer", "true"); |
162 |
feaFondos.setProp("colorByLayer", "true"); |
163 |
} |
164 |
if (grp.hasCode(10)) |
165 |
x = grp.getDataAsDouble(10);
|
166 |
if (grp.hasCode(20)) |
167 |
y = grp.getDataAsDouble(20);
|
168 |
if (grp.hasCode(30)) { |
169 |
z = grp.getDataAsDouble(30);
|
170 |
if (z!=0.0) dxf3DFile = true; |
171 |
Double doub = new Double(z); |
172 |
String string = doub.toString();
|
173 |
//feature.setProp("elevation", string);
|
174 |
feaBordes.setProp("elevation", string);
|
175 |
feaFondos.setProp("elevation", string);
|
176 |
} else {
|
177 |
Double doub = new Double(0.0); |
178 |
//feature.setProp("elevation", doub.toString());
|
179 |
feaBordes.setProp("elevation", doub.toString());
|
180 |
feaFondos.setProp("elevation", doub.toString());
|
181 |
} |
182 |
if (grp.hasCode(70)) |
183 |
flags = grp.getDataAsInt(70);
|
184 |
if (grp.hasCode(210)) |
185 |
xtruX = grp.getDataAsDouble(210);
|
186 |
if (grp.hasCode(220)) |
187 |
xtruY = grp.getDataAsDouble(220);
|
188 |
if (grp.hasCode(230)) |
189 |
xtruZ = grp.getDataAsDouble(230);
|
190 |
if ((flags & 0x01) == 0x01 || (flags & 0x40) == 0x40) { |
191 |
feaBordes.setGeometry(lineString3D); |
192 |
feaFondos.setGeometry(polygon3D); |
193 |
lastFeaBordes = feaBordes; |
194 |
lastFeaFondos = feaFondos; |
195 |
isDoubleFeatured = true;
|
196 |
} else if ((flags & 0x01) == 0x00) { |
197 |
feaBordes.setGeometry(lineString3D); |
198 |
lastFeaBordes = feaBordes; |
199 |
isDoubleFeatured = false;
|
200 |
} else {
|
201 |
System.out.println("Detectada una Polyline Flag que no corresponde"); |
202 |
System.out.println("a una Polyline corriente, ni a una Closed Polyline"); |
203 |
} |
204 |
} |
205 |
|
206 |
public void endSeq() throws Exception { |
207 |
if (isDoubleFeatured) {
|
208 |
if (lastFeaBordes.getGeometry() instanceof LineString3D) { |
209 |
Feature feaBordes = lastFeaBordes; |
210 |
Feature feaFondos = lastFeaFondos; |
211 |
LineString3D lineString3D = (LineString3D)feaBordes.getGeometry(); |
212 |
Polygon3D polygon3D = (Polygon3D)feaFondos.getGeometry(); |
213 |
lineString3D.add(firstPt); |
214 |
if (bulge!=0 && !(lineString3D.get(lineString3D.pointNr()-2).getX()==lineString3D.get(lineString3D.pointNr()-1).getX()) && lineString3D.get(lineString3D.pointNr()-2).getY()==lineString3D.get(lineString3D.pointNr()-1).getY()) { |
215 |
// 041122: Correcci?n del bug en los bulges de FIXT3.DXF
|
216 |
Vector arc = createArc(new Point2D.Double(lineString3D.get(lineString3D.pointNr()-2).getX(), lineString3D.get(lineString3D.pointNr()-2).getY()), new Point2D.Double(lineString3D.get(lineString3D.pointNr()-1).getX(), lineString3D.get(lineString3D.pointNr()-1).getY()), bulge); |
217 |
lineString3D.remove(lineString3D.pointNr()-1);
|
218 |
lineString3D.remove(lineString3D.pointNr()-1);
|
219 |
polygon3D.remove(lineString3D.pointNr()-1);
|
220 |
polygon3D.remove(lineString3D.pointNr()-1);
|
221 |
if (bulge>0) { |
222 |
for (int i=0; i<arc.size(); i++) { |
223 |
Point2D ptAux = new Point2D.Double(); |
224 |
double z = ((Point3D)lineString3D.get(lineString3D.pointNr()-2)).getZ(); |
225 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
226 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
227 |
lineString3D.add(ptAux3D); |
228 |
polygon3D.add(ptAux3D); |
229 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
230 |
} |
231 |
} else {
|
232 |
for (int i=arc.size()-1; i>=0; i--) { |
233 |
Point2D ptAux = new Point2D.Double(); |
234 |
double z = ((Point3D)lineString3D.get(lineString3D.pointNr()-2)).getZ(); |
235 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
236 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
237 |
lineString3D.add(ptAux3D); |
238 |
polygon3D.add(ptAux3D); |
239 |
if (lineString3D.pointNr() == 1 || polygon3D.pointNr() == 1) firstPt = ptAux3D; |
240 |
} |
241 |
} |
242 |
// 041122
|
243 |
bulge = 0.0;
|
244 |
} |
245 |
|
246 |
if (hasFaces) {
|
247 |
//System.out.println("Sabe que es un poligono.");
|
248 |
//System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
|
249 |
LineString ls1 = new LineString();
|
250 |
Polygon pl1 = new Polygon(); |
251 |
LineString ls2 = new LineString();
|
252 |
Polygon pl2 = new Polygon(); |
253 |
LineString ls = new LineString();
|
254 |
Polygon pl = new Polygon(); |
255 |
int [] face; |
256 |
int i0, i1;
|
257 |
Iterator iter = faces.iterator();
|
258 |
while (iter.hasNext()) {
|
259 |
face = (int []) iter.next(); |
260 |
i0 = face[3];
|
261 |
for (int i=0; i<4; i++) { |
262 |
i1 = face[i]; |
263 |
if (i0 > 0) { |
264 |
if ((facesIterador%2)!=0) { |
265 |
ls1.add((Point2D)lineString3D.get(i0-1)); |
266 |
pl1.add((Point2D)polygon3D.get(i0-1)); |
267 |
} else {
|
268 |
ls2.add((Point2D)lineString3D.get(i0-1)); |
269 |
pl2.add((Point2D)polygon3D.get(i0-1)); |
270 |
} |
271 |
facesIterador = facesIterador + 1;
|
272 |
} |
273 |
i0 = i1; |
274 |
} |
275 |
} |
276 |
facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY()); |
277 |
for (int i=0;i<ls1.pointNr();i++) { |
278 |
ls.add(ls1.get(i)); |
279 |
pl.add(pl1.get(i)); |
280 |
} |
281 |
for (int i=ls2.pointNr()-1;i>0;i--) { |
282 |
ls.add(ls2.get(i)); |
283 |
pl.add(pl2.get(i)); |
284 |
} |
285 |
ls.add(facesFirstPoint); |
286 |
pl.add(facesFirstPoint); |
287 |
lastFeaBordes.setGeometry(ls); |
288 |
lastFeaFondos.setGeometry(pl); |
289 |
} else {
|
290 |
lastFeaBordes.setGeometry(lineString3D); |
291 |
lastFeaFondos.setGeometry(polygon3D); |
292 |
} |
293 |
|
294 |
// 041130: Rellena las props con los atributos.
|
295 |
completeAttributes(lastFeaBordes); |
296 |
completeAttributes(lastFeaFondos); |
297 |
|
298 |
setPolylineElevation(lastFeaBordes, lastFeaFondos); |
299 |
|
300 |
if (addingToBlock == false) { |
301 |
features.add(lastFeaBordes); |
302 |
features.add(lastFeaFondos); |
303 |
} else {
|
304 |
blk.add(lastFeaBordes); |
305 |
blk.add(lastFeaFondos); |
306 |
} |
307 |
lastFeaBordes = null;
|
308 |
lastFeaFondos = null;
|
309 |
} else if (lastFeaBordes.getGeometry() instanceof InsPoint3D) { |
310 |
// Se trata de un SEQEND despues de un ATTRIB
|
311 |
copyAttributes(lastFeaBordes); |
312 |
|
313 |
gestionaInsert(lastFeaBordes); |
314 |
|
315 |
if (addingToBlock == false) { |
316 |
features.add(lastFeaFondos); |
317 |
} else {
|
318 |
blk.add(lastFeaBordes); |
319 |
} |
320 |
lastFeaBordes = null;
|
321 |
lastFeaFondos = null;
|
322 |
} else {
|
323 |
// Caso no contemplado.
|
324 |
} |
325 |
} else {
|
326 |
if (lastFeaBordes.getGeometry() instanceof LineString3D) { |
327 |
Feature feaBordes = lastFeaBordes; |
328 |
LineString3D lineString3D = (LineString3D)feaBordes.getGeometry(); |
329 |
if (bulge!=0 && !(lineString3D.get(lineString3D.pointNr()-2).getX()==lineString3D.get(lineString3D.pointNr()-1).getX()) && lineString3D.get(lineString3D.pointNr()-2).getY()==lineString3D.get(lineString3D.pointNr()-1).getY()) { |
330 |
// 041122: Correcci?n del bug en los bulges de FIXT3.DXF
|
331 |
Vector arc = createArc(new Point2D.Double(lineString3D.get(lineString3D.pointNr()-2).getX(), lineString3D.get(lineString3D.pointNr()-2).getY()), new Point2D.Double(lineString3D.get(lineString3D.pointNr()-1).getX(), lineString3D.get(lineString3D.pointNr()-1).getY()), bulge); |
332 |
lineString3D.remove(lineString3D.pointNr()-1);
|
333 |
lineString3D.remove(lineString3D.pointNr()-1);
|
334 |
if (bulge>0) { |
335 |
for (int i=0; i<arc.size(); i++) { |
336 |
Point2D ptAux = new Point2D.Double(); |
337 |
double z = ((Point3D)lineString3D.get(lineString3D.pointNr()-2)).getZ(); |
338 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
339 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
340 |
lineString3D.add(ptAux3D); |
341 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
342 |
} |
343 |
} else {
|
344 |
for (int i=arc.size()-1; i>=0; i--) { |
345 |
Point2D ptAux = new Point2D.Double(); |
346 |
double z = ((Point3D)lineString3D.get(lineString3D.pointNr()-2)).getZ(); |
347 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
348 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
349 |
lineString3D.add(ptAux3D); |
350 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
351 |
} |
352 |
} |
353 |
// 041122
|
354 |
bulge = 0.0;
|
355 |
} |
356 |
|
357 |
if (hasFaces) {
|
358 |
//System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ lineString.pointNr());
|
359 |
LineString ls1 = new LineString();
|
360 |
LineString ls2 = new LineString();
|
361 |
LineString ls = new LineString();
|
362 |
int [] face; |
363 |
int i0, i1;
|
364 |
Iterator iter = faces.iterator();
|
365 |
while (iter.hasNext()) {
|
366 |
face = (int []) iter.next(); |
367 |
i0 = face[3];
|
368 |
for (int i=0; i<4; i++) { |
369 |
i1 = face[i]; |
370 |
if (i0 > 0) { |
371 |
if ((facesIterador%2)!=0) { |
372 |
ls1.add((Point2D)lineString3D.get(i0-1)); |
373 |
//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
|
374 |
} else {
|
375 |
ls2.add((Point2D)lineString3D.get(i0-1)); |
376 |
//ls.add((Point2D)lineString.get(Math.abs(i1)-1));
|
377 |
} |
378 |
facesIterador = facesIterador + 1;
|
379 |
} |
380 |
i0 = i1; |
381 |
} |
382 |
} |
383 |
facesFirstPoint = new Point2D.Double(ls1.get(0).getX(), ls1.get(0).getY()); |
384 |
for (int i=0;i<ls1.pointNr();i++) { |
385 |
ls.add(ls1.get(i)); |
386 |
} |
387 |
for (int i=ls2.pointNr()-1;i>0;i--) { |
388 |
ls.add(ls2.get(i)); |
389 |
} |
390 |
ls.add(facesFirstPoint); |
391 |
lastFeaBordes.setGeometry(ls); |
392 |
} else {
|
393 |
lastFeaBordes.setGeometry(lineString3D); |
394 |
} |
395 |
|
396 |
// 041130: Rellena las props con los atributos.
|
397 |
completeAttributes(lastFeaBordes); |
398 |
|
399 |
setPolylineElevation(lastFeaBordes); |
400 |
|
401 |
if (addingToBlock == false) { |
402 |
features.add(lastFeaBordes); |
403 |
} else {
|
404 |
blk.add(lastFeaBordes); |
405 |
} |
406 |
lastFeaBordes = null;
|
407 |
} else {
|
408 |
// Se trata de un SEQEND despues de un ATTRIB
|
409 |
} |
410 |
} |
411 |
xtruX = 0.0;
|
412 |
xtruY = 0.0;
|
413 |
xtruZ = 1.0;
|
414 |
bulge = 0.0;
|
415 |
isDoubleFeatured = false;
|
416 |
hasFaces = false;
|
417 |
facesIterador = 1;
|
418 |
} |
419 |
private void setPolylineElevation(Feature feaBordes) { |
420 |
if (constantPolylineElevation) {
|
421 |
Double doub = new Double(lastVertexElevation); |
422 |
String string = doub.toString();
|
423 |
feaBordes.setProp("elevation", string);
|
424 |
} else {
|
425 |
Double doub = new Double(0.0); |
426 |
String string = doub.toString();
|
427 |
feaBordes.setProp("elevation", string);
|
428 |
} |
429 |
} |
430 |
private void setPolylineElevation(Feature feaBordes, Feature feaFondos) { |
431 |
if (constantPolylineElevation) {
|
432 |
Double doub = new Double(lastVertexElevation); |
433 |
String string = doub.toString();
|
434 |
feaBordes.setProp("elevation", string);
|
435 |
feaFondos.setProp("elevation", string);
|
436 |
} else {
|
437 |
Double doub = new Double(0.0); |
438 |
String string = doub.toString();
|
439 |
feaBordes.setProp("elevation", string);
|
440 |
feaFondos.setProp("elevation", string);
|
441 |
} |
442 |
} |
443 |
public void addVertex(DxfGroupVector grp) throws Exception { |
444 |
double x = 0.0, y = 0.0, z = 0.0; |
445 |
int vFlags = 0; |
446 |
if (isDoubleFeatured) {
|
447 |
Feature feaBordes = lastFeaBordes; |
448 |
Feature feaFondos = lastFeaFondos; |
449 |
LineString3D lineString3D = (LineString3D)feaBordes.getGeometry(); |
450 |
Polygon3D polygon3D = (Polygon3D)feaFondos.getGeometry(); |
451 |
if (grp.hasCode(8)) { |
452 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
453 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
454 |
} |
455 |
if (grp.hasCode(70)) { |
456 |
vFlags = grp.getDataAsInt(70);
|
457 |
} |
458 |
x = grp.getDataAsDouble(10);
|
459 |
y = grp.getDataAsDouble(20);
|
460 |
z = grp.getDataAsDouble(30);
|
461 |
Point3D point_in = new Point3D(x, y, z);
|
462 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
463 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
464 |
x = point_out.getX(); |
465 |
y = point_out.getY(); |
466 |
z = point_out.getZ(); |
467 |
if (z!=0.0) dxf3DFile = true; |
468 |
if (z!=lastVertexElevation && lineString3D.pointNr()>0) constantPolylineElevation = false; |
469 |
lastVertexElevation = z; |
470 |
//System.out.println("addVertex(): vFlags = " + vFlags);
|
471 |
if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) { |
472 |
int [] face = {0,0,0,0}; |
473 |
face[0] = grp.getDataAsInt(71); |
474 |
face[1] = grp.getDataAsInt(72); |
475 |
face[2] = grp.getDataAsInt(73); |
476 |
face[3] = grp.getDataAsInt(74); |
477 |
addFace(face); |
478 |
} else if ((vFlags & 0x10) == 0x10) { |
479 |
// Son vertices que se trataran cuando se implementen
|
480 |
// los splines. En principio no se hace nada con ellos.
|
481 |
} else {
|
482 |
Point3D pt = new Point3D(proj.createPoint( x, y).getX(), proj.createPoint( x, y).getY(), z);
|
483 |
lineString3D.add(pt); |
484 |
polygon3D.add(pt); |
485 |
if (lineString3D.pointNr() == 1) { |
486 |
firstPt = pt; |
487 |
} |
488 |
if (bulge == 0.0) { |
489 |
if (grp.hasCode(42)) { |
490 |
bulge = grp.getDataAsDouble(42);
|
491 |
} else { bulge = 0.0; } |
492 |
} else {
|
493 |
double bulge_aux = 0.0; |
494 |
if (grp.hasCode(42)) { |
495 |
bulge_aux = grp.getDataAsDouble(42);
|
496 |
} else { bulge_aux = 0.0; } |
497 |
//int cnt = lineString.pointNr();
|
498 |
if (ptAnterior.getX()==pt.getX() && ptAnterior.getY()==pt.getY()) {
|
499 |
// no se construye el arco
|
500 |
} else {
|
501 |
lineString3D.remove(lineString3D.pointNr()-1);
|
502 |
lineString3D.remove(lineString3D.pointNr()-1);
|
503 |
polygon3D.remove(polygon3D.pointNr()-1);
|
504 |
polygon3D.remove(polygon3D.pointNr()-1);
|
505 |
Vector arc = createArc(ptAnterior, pt, bulge);
|
506 |
if (bulge>0) { |
507 |
for (int i=0; i<arc.size(); i++) { |
508 |
Point2D ptAux = new Point2D.Double(); |
509 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
510 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
511 |
lineString3D.add(ptAux3D); |
512 |
polygon3D.add(ptAux3D); |
513 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
514 |
} |
515 |
} else {
|
516 |
for (int i=arc.size()-1; i>=0; i--) { |
517 |
Point2D ptAux = new Point2D.Double(); |
518 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
519 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
520 |
lineString3D.add(ptAux3D); |
521 |
polygon3D.add(ptAux3D); |
522 |
if (lineString3D.pointNr() == 1 || polygon3D.pointNr() == 1) firstPt = ptAux3D; |
523 |
} |
524 |
} |
525 |
} |
526 |
bulge = bulge_aux; |
527 |
} |
528 |
ptAnterior = pt; |
529 |
} |
530 |
} else {
|
531 |
Feature feaBordes = lastFeaBordes; |
532 |
LineString3D lineString3D = (LineString3D)feaBordes.getGeometry(); |
533 |
if (grp.hasCode(8)) |
534 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
535 |
if (grp.hasCode(70)) { |
536 |
vFlags = grp.getDataAsInt(70);
|
537 |
} |
538 |
x = grp.getDataAsDouble(10);
|
539 |
y = grp.getDataAsDouble(20);
|
540 |
z = grp.getDataAsDouble(30);
|
541 |
Point3D point_in = new Point3D(x, y, z);
|
542 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
543 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
544 |
x = point_out.getX(); |
545 |
y = point_out.getY(); |
546 |
z = point_out.getZ(); |
547 |
if (z!=0.0) dxf3DFile = true; |
548 |
if (z!=lastVertexElevation && lineString3D.pointNr()>0) constantPolylineElevation = false; |
549 |
lastVertexElevation = z; |
550 |
if ((vFlags & 0x80) == 0x80 && (vFlags & 0x40) == 0) { |
551 |
int [] face = {0,0,0,0}; |
552 |
face[0] = grp.getDataAsInt(71); |
553 |
face[1] = grp.getDataAsInt(72); |
554 |
face[2] = grp.getDataAsInt(73); |
555 |
face[3] = grp.getDataAsInt(74); |
556 |
addFace(face); |
557 |
} else if ((vFlags & 16) == 16) { |
558 |
// no se hace nada.
|
559 |
} else {
|
560 |
Point3D pt = new Point3D(proj.createPoint( x, y).getX(), proj.createPoint( x, y).getY(), z);
|
561 |
lineString3D.add(pt); |
562 |
//System.out.println("addVertex: pt = " + pt);
|
563 |
if (lineString3D.pointNr() == 1) { |
564 |
firstPt = pt; |
565 |
//System.out.println("addVertex(Primer pto de la lineString, firstPt=pt): firstPt = " + firstPt);
|
566 |
} |
567 |
if (bulge == 0.0) { |
568 |
if (grp.hasCode(42)) { |
569 |
bulge = grp.getDataAsDouble(42);
|
570 |
} else { bulge = 0.0; } |
571 |
//System.out.println("addVertex: El vertice anterior tenia bulge=0.0");
|
572 |
} else {
|
573 |
//System.out.println("addVertex: El vertice anterior tiene bulge = " + bulge);
|
574 |
double bulge_aux = 0.0; |
575 |
if (grp.hasCode(42)) { |
576 |
bulge_aux = grp.getDataAsDouble(42);
|
577 |
} else { bulge_aux = 0.0; } |
578 |
if (ptAnterior.getX()==pt.getX() && ptAnterior.getY()==pt.getY()) {
|
579 |
// no se construye el arco
|
580 |
} else {
|
581 |
// Borro los puntos inicio y final del arco.
|
582 |
lineString3D.remove(lineString3D.pointNr()-1);
|
583 |
lineString3D.remove(lineString3D.pointNr()-1);
|
584 |
Vector arc = createArc(ptAnterior, pt, bulge);
|
585 |
if (bulge>0) { |
586 |
for (int i=0; i<arc.size(); i++) { |
587 |
Point2D ptAux = new Point2D.Double(); |
588 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
589 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
590 |
lineString3D.add(ptAux3D); |
591 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
592 |
} |
593 |
} else {
|
594 |
for (int i=arc.size()-1; i>=0; i--) { |
595 |
Point2D ptAux = new Point2D.Double(); |
596 |
ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
597 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), z);
|
598 |
lineString3D.add(ptAux3D); |
599 |
if (lineString3D.pointNr() == 1) firstPt = ptAux3D; |
600 |
} |
601 |
} |
602 |
} |
603 |
bulge = bulge_aux; |
604 |
} |
605 |
ptAnterior = pt; |
606 |
} |
607 |
} |
608 |
} |
609 |
|
610 |
public void createLwPolyline(DxfGroupVector grp) throws Exception { |
611 |
double x = 0.0, y = 0.0; |
612 |
double elev = 0.0; |
613 |
DxfGroup g = null;
|
614 |
LineString3D lineString3D = new LineString3D();
|
615 |
Polygon3D polygon3D = new Polygon3D();
|
616 |
//Geometry geometria;
|
617 |
//Feature feature= new Feature();
|
618 |
Feature feaBordes= new Feature();
|
619 |
Feature feaFondos= new Feature();
|
620 |
int flags = 0; |
621 |
int NumberOfVertices = 0; |
622 |
|
623 |
//feature.setProp("dxfEntity", "LwPolyline");
|
624 |
feaBordes.setProp("dxfEntity", "LwPolyline"); |
625 |
feaFondos.setProp("dxfEntity", "LwPolyline"); |
626 |
if (grp.hasCode(8)) |
627 |
//feature.setProp("layer", grp.getDataAsString(8));
|
628 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
629 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
630 |
if (grp.hasCode(38)) { |
631 |
elev = grp.getDataAsDouble(38);
|
632 |
if (elev!=0.0) dxf3DFile = true; |
633 |
Double doub = new Double(elev); |
634 |
String string = doub.toString();
|
635 |
//feature.setProp("elevation", string);
|
636 |
feaBordes.setProp("elevation", string);
|
637 |
feaFondos.setProp("elevation", string);
|
638 |
} else {
|
639 |
Double doub = new Double(0.0); |
640 |
//feature.setProp("elevation", doub.toString());
|
641 |
feaBordes.setProp("elevation", doub.toString());
|
642 |
feaFondos.setProp("elevation", doub.toString());
|
643 |
} |
644 |
if (grp.hasCode(39)) { |
645 |
Double doub = new Double(grp.getDataAsDouble(39)); |
646 |
String string = doub.toString();
|
647 |
//feature.setProp("thickness", string);
|
648 |
feaBordes.setProp("thickness", string);
|
649 |
feaFondos.setProp("thickness", string);
|
650 |
} else {
|
651 |
Double doub = new Double(0.0); |
652 |
//feature.setProp("thickness", doub.toString());
|
653 |
feaBordes.setProp("thickness", doub.toString());
|
654 |
feaFondos.setProp("thickness", doub.toString());
|
655 |
} |
656 |
if (grp.hasCode(62)) { |
657 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
658 |
String string = integer.toString();
|
659 |
//feature.setProp("color", string);
|
660 |
feaBordes.setProp("color", string);
|
661 |
feaFondos.setProp("color", string);
|
662 |
feaBordes.setProp("colorByLayer", "false"); |
663 |
feaFondos.setProp("colorByLayer", "false"); |
664 |
} else {
|
665 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
666 |
int clr = layer.colorNumber;
|
667 |
Integer integer = new Integer(clr); |
668 |
String string = integer.toString();
|
669 |
//feature.setProp("color", string);
|
670 |
feaBordes.setProp("color", string);
|
671 |
feaFondos.setProp("color", string);
|
672 |
feaBordes.setProp("colorByLayer", "true"); |
673 |
feaFondos.setProp("colorByLayer", "true"); |
674 |
} |
675 |
if (grp.hasCode(70)) |
676 |
flags = grp.getDataAsInt(70);
|
677 |
if ((flags & 0x01) == 0x01) { |
678 |
//geometria = new Polygon();
|
679 |
feaBordes.setGeometry(lineString3D); |
680 |
feaFondos.setGeometry(polygon3D); |
681 |
isDoubleFeatured = true;
|
682 |
} else {
|
683 |
//geometria = new LineString();
|
684 |
feaBordes.setGeometry(lineString3D); |
685 |
isDoubleFeatured = false;
|
686 |
} |
687 |
if (grp.hasCode(90)) |
688 |
NumberOfVertices = grp.getDataAsInt(90);
|
689 |
|
690 |
int j = 0; |
691 |
double firstX = 0.0; |
692 |
double firstY = 0.0; |
693 |
boolean hasBulge = false; |
694 |
double bulgeLwp = 0.0; |
695 |
for (int i=0; i<grp.size(); i++) { |
696 |
g = (DxfGroup) grp.get(i); |
697 |
if (g.getCode() == 10) { |
698 |
j++; |
699 |
x = ((Double) g.getData()).doubleValue();
|
700 |
} else if (g.getCode() == 20) { |
701 |
y = ((Double) g.getData()).doubleValue();
|
702 |
if (hasBulge) {
|
703 |
Point2D finalPoint = new Point2D.Double(x, y); |
704 |
if (((LineString3D)lineString3D).get(lineString3D.pointNr()-1).getX()==finalPoint.getX() && ((LineString3D)lineString3D).get(lineString3D.pointNr()-1).getY()==finalPoint.getY()) { |
705 |
// no se construye el arco
|
706 |
} else {
|
707 |
Vector arc = createArc(((LineString3D)lineString3D).get(lineString3D.pointNr()-1), finalPoint, bulgeLwp); |
708 |
lineString3D.remove(lineString3D.pointNr()-1);
|
709 |
if (isDoubleFeatured) polygon3D.remove(polygon3D.pointNr()-1); |
710 |
if (bulgeLwp>0) { |
711 |
for (int k=0; k<arc.size(); k++) { |
712 |
Point2D ptAux = new Point2D.Double(); |
713 |
ptAux = proj.createPoint(((Point2D)arc.get(k)).getX(), ((Point2D)arc.get(k)).getY()); |
714 |
//System.out.println("createLwPolyline: ptAux = " + ptAux);
|
715 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), elev);
|
716 |
lineString3D.add(ptAux3D); |
717 |
//if (lineString.pointNr() == 1) firstPt = ptAux;
|
718 |
if (isDoubleFeatured) polygon3D.add(ptAux3D);
|
719 |
if (lineString3D.pointNr() == 1 || polygon3D.pointNr() == 1) firstPt = ptAux3D; |
720 |
} |
721 |
} else {
|
722 |
for (int k=arc.size()-1; k>=0; k--) { |
723 |
Point2D ptAux = new Point2D.Double(); |
724 |
ptAux = proj.createPoint(((Point2D)arc.get(k)).getX(), ((Point2D)arc.get(k)).getY()); |
725 |
Point3D ptAux3D = new Point3D(ptAux.getX(), ptAux.getY(), elev);
|
726 |
lineString3D.add(ptAux3D); |
727 |
if (isDoubleFeatured) polygon3D.add(ptAux3D);
|
728 |
if (lineString3D.pointNr() == 1 || polygon3D.pointNr() == 1) firstPt = ptAux3D; |
729 |
} |
730 |
} |
731 |
} |
732 |
hasBulge = false;
|
733 |
bulgeLwp = 0.0;
|
734 |
} else {
|
735 |
//System.out.println("createLwPolyline: hasBulge siempre es false");
|
736 |
Point3D ptAux3D = new Point3D(proj.createPoint( x, y ).getX(), proj.createPoint( x, y ).getY(), elev);
|
737 |
lineString3D.add(ptAux3D); |
738 |
if (isDoubleFeatured) polygon3D.add(ptAux3D);
|
739 |
} |
740 |
if (j == 1) { |
741 |
firstX = x; |
742 |
firstY = y; |
743 |
} |
744 |
x = 0.0; y = 0.0; |
745 |
} else if (g.getCode() == 42) { |
746 |
//System.out.println("createLwPolyline: Lee el bulgeLwp");
|
747 |
hasBulge = true;
|
748 |
bulgeLwp = ((Double) g.getData()).doubleValue();
|
749 |
} |
750 |
|
751 |
} |
752 |
if (isDoubleFeatured) {
|
753 |
//geometria.add(proj.createPoint(firstX, firstY));
|
754 |
Point3D ptAux3D = new Point3D(proj.createPoint(firstX, firstY).getX(), proj.createPoint(firstX, firstY).getY(), elev);
|
755 |
lineString3D.add(ptAux3D); |
756 |
polygon3D.add(ptAux3D); |
757 |
} |
758 |
|
759 |
lastFeaBordes = feaBordes; |
760 |
if (isDoubleFeatured) lastFeaFondos = feaFondos;
|
761 |
|
762 |
// 041130: Rellena las props con los atributos.
|
763 |
completeAttributes(lastFeaBordes); |
764 |
completeAttributes(lastFeaFondos); |
765 |
|
766 |
//features.add(feature);
|
767 |
if (addingToBlock == false) { |
768 |
features.add(feaBordes); |
769 |
if (isDoubleFeatured) features.add(feaFondos);
|
770 |
} else {
|
771 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
772 |
blk.add(feaBordes); |
773 |
if (isDoubleFeatured) blk.add(feaFondos);
|
774 |
} |
775 |
isDoubleFeatured = false;
|
776 |
} |
777 |
|
778 |
public void createLine(DxfGroupVector grp) throws Exception { |
779 |
double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0; |
780 |
double elev = 0.0; |
781 |
DxfGroup g = null;
|
782 |
Point2D pt1 = null, pt2 = null; |
783 |
LineString3D lineString3D = new LineString3D();
|
784 |
Feature feature = new Feature();
|
785 |
|
786 |
feature.setProp("dxfEntity", "Line"); |
787 |
if (grp.hasCode(8)) |
788 |
feature.setProp("layer", grp.getDataAsString(8)); |
789 |
if (grp.hasCode(39)) { |
790 |
Double doub = new Double(grp.getDataAsDouble(39)); |
791 |
String string = doub.toString();
|
792 |
feature.setProp("thickness", string);
|
793 |
} else {
|
794 |
Double doub = new Double(0.0); |
795 |
feature.setProp("thickness", doub.toString());
|
796 |
} |
797 |
if (grp.hasCode(62)) { |
798 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
799 |
String string = integer.toString();
|
800 |
feature.setProp("color", string);
|
801 |
feature.setProp("colorByLayer", "false"); |
802 |
} else {
|
803 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
804 |
int clr = layer.colorNumber;
|
805 |
Integer integer = new Integer(clr); |
806 |
String string = integer.toString();
|
807 |
feature.setProp("color", string);
|
808 |
feature.setProp("colorByLayer", "true"); |
809 |
} |
810 |
x = grp.getDataAsDouble(10);
|
811 |
y = grp.getDataAsDouble(20);
|
812 |
z1 = grp.getDataAsDouble(30);
|
813 |
/*if (grp.hasCode(30)) {
|
814 |
z1 = grp.getDataAsDouble(30);
|
815 |
elev = z1;
|
816 |
Double doub = new Double(elev);
|
817 |
String string = doub.toString();
|
818 |
//feature.setProp("elevation", string);
|
819 |
}*/
|
820 |
pt1 = proj.createPoint(x, y); |
821 |
x = grp.getDataAsDouble(11);
|
822 |
y = grp.getDataAsDouble(21);
|
823 |
z2 = grp.getDataAsDouble(31);
|
824 |
/*if (grp.hasCode(31)) {
|
825 |
z2 = grp.getDataAsDouble(31);
|
826 |
} else {
|
827 |
// Cuando no se especifican z para las lineas se asume que la
|
828 |
// z es cero.
|
829 |
Double doub = new Double(0.0);
|
830 |
//feature.setProp("elevation", doub.toString());
|
831 |
}*/
|
832 |
pt2 = proj.createPoint(x, y); |
833 |
if (grp.hasCode(210)) |
834 |
xtruX = grp.getDataAsDouble(210);
|
835 |
if (grp.hasCode(220)) |
836 |
xtruY = grp.getDataAsDouble(220);
|
837 |
if (grp.hasCode(230)) |
838 |
xtruZ = grp.getDataAsDouble(230);
|
839 |
Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
840 |
Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
841 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
842 |
Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
843 |
Point3D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru); |
844 |
if (point_out1.getZ()!=0.0) dxf3DFile = true; |
845 |
if (point_out2.getZ()!=0.0) dxf3DFile = true; |
846 |
|
847 |
if (point_out1.getZ()==point_out2.getZ()) {
|
848 |
elev = z1; |
849 |
Double doub = new Double(elev); |
850 |
String string = doub.toString();
|
851 |
feature.setProp("elevation", string);
|
852 |
} else {
|
853 |
elev = 0.0;
|
854 |
Double doub = new Double(elev); |
855 |
String string = doub.toString();
|
856 |
feature.setProp("elevation", string);
|
857 |
} |
858 |
|
859 |
//pt1.setLocation(point_out1);
|
860 |
//pt2.setLocation(point_out2);
|
861 |
lineString3D.add(point_out1); |
862 |
lineString3D.add(point_out2); |
863 |
|
864 |
feature.setGeometry(lineString3D); |
865 |
|
866 |
// 041130: Rellena las props con los atributos.
|
867 |
completeAttributes(feature); |
868 |
|
869 |
//features.add(feature);
|
870 |
if (addingToBlock == false) { |
871 |
//System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
872 |
features.add(feature); |
873 |
} else {
|
874 |
//System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
875 |
blk.add(feature); |
876 |
} |
877 |
} |
878 |
|
879 |
/* (non-Javadoc)
|
880 |
* @see org.cresques.io.DxfFile.EntityFactory#createText(org.cresques.io.DxfGroupVector)
|
881 |
*/
|
882 |
public void createText(DxfGroupVector grp) throws Exception { |
883 |
double x = 0.0, y = 0.0, z = 0.0, h= 0.0, rot= 0.0; |
884 |
DxfGroup g = null;
|
885 |
//Point3D pt1 = null, pt2 = null;
|
886 |
Point3D pt = null;
|
887 |
org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
888 |
|
889 |
point.setTextPoint(true);
|
890 |
|
891 |
Feature feature = new Feature();
|
892 |
|
893 |
feature.setProp("dxfEntity", "Text"); |
894 |
if (grp.hasCode(8)) |
895 |
feature.setProp("layer", grp.getDataAsString(8)); |
896 |
if (grp.hasCode(39)) { |
897 |
Double doub = new Double(grp.getDataAsDouble(39)); |
898 |
String string = doub.toString();
|
899 |
feature.setProp("thickness", string);
|
900 |
} else {
|
901 |
Double doub = new Double(0.0); |
902 |
feature.setProp("thickness", doub.toString());
|
903 |
} |
904 |
if (grp.hasCode(62)) { |
905 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
906 |
String string = integer.toString();
|
907 |
feature.setProp("color", string);
|
908 |
feature.setProp("colorByLayer", "false"); |
909 |
} else {
|
910 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
911 |
int clr = layer.colorNumber;
|
912 |
Integer integer = new Integer(clr); |
913 |
String string = integer.toString();
|
914 |
feature.setProp("color", string);
|
915 |
feature.setProp("colorByLayer", "true"); |
916 |
} |
917 |
if (grp.hasCode(1)) { |
918 |
String strAux1 = grp.getDataAsString(1); |
919 |
strAux1 = DxfConvTexts.ConvertText(strAux1); |
920 |
feature.setProp("text", strAux1);
|
921 |
} else {
|
922 |
feature.setProp("text", "No Text Code"); |
923 |
} |
924 |
if (grp.hasCode(40)) { |
925 |
Double heightD = new Double(grp.getDataAsDouble(40)); |
926 |
String heightS = heightD.toString();
|
927 |
feature.setProp("textHeight", heightS);
|
928 |
} else {
|
929 |
feature.setProp("textHeight", "20.0"); |
930 |
} |
931 |
if (grp.hasCode(50)) { |
932 |
Double rotD = new Double(grp.getDataAsDouble(50)); |
933 |
String rotS = rotD.toString();
|
934 |
feature.setProp("textRotation", rotS);
|
935 |
//System.out.println("rotS = " + rotS);
|
936 |
} else {
|
937 |
feature.setProp("textRotation", "0.0"); |
938 |
} |
939 |
x = grp.getDataAsDouble(10);
|
940 |
y = grp.getDataAsDouble(20);
|
941 |
z = grp.getDataAsDouble(30);
|
942 |
/*if (grp.hasCode(30)){
|
943 |
Double doub = new Double(z);
|
944 |
String string = doub.toString();
|
945 |
feature.setProp("elevation", string);
|
946 |
} else {
|
947 |
Double doub = new Double(0.0);
|
948 |
feature.setProp("elevation", doub.toString());
|
949 |
}*/
|
950 |
if (grp.hasCode(210)) |
951 |
xtruX = grp.getDataAsDouble(210);
|
952 |
if (grp.hasCode(220)) |
953 |
xtruY = grp.getDataAsDouble(220);
|
954 |
if (grp.hasCode(230)) |
955 |
xtruZ = grp.getDataAsDouble(230);
|
956 |
Point3D point_in = new Point3D(x, y, z);
|
957 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
958 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
959 |
x = point_out.getX(); |
960 |
y = point_out.getY(); |
961 |
z = point_out.getZ(); |
962 |
Double doub = new Double(z); |
963 |
feature.setProp("elevation", doub.toString());
|
964 |
if (z!=0.0) dxf3DFile = true; |
965 |
point.add(new Point3D(x, y, z));
|
966 |
feature.setGeometry(point); |
967 |
|
968 |
// 041130: Rellena las props con los atributos.
|
969 |
completeAttributes(feature); |
970 |
|
971 |
//features.add(feature);
|
972 |
if (addingToBlock == false) { |
973 |
features.add(feature); |
974 |
} else {
|
975 |
//System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
976 |
blk.add(feature); |
977 |
} |
978 |
} |
979 |
|
980 |
public void createMText(DxfGroupVector grp) throws Exception { |
981 |
double x = 0.0, y = 0.0, z = 0.0, h= 0.0, rot= 0.0; |
982 |
DxfGroup g = null;
|
983 |
//Point2D pt1 = null, pt2 = null;
|
984 |
Point3D pt = null;
|
985 |
org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
986 |
|
987 |
point.setTextPoint(true);
|
988 |
|
989 |
Feature feature = new Feature();
|
990 |
|
991 |
feature.setProp("dxfEntity", "Text"); |
992 |
if (grp.hasCode(8)) |
993 |
feature.setProp("layer", grp.getDataAsString(8)); |
994 |
if (grp.hasCode(39)) { |
995 |
Double doub = new Double(grp.getDataAsDouble(39)); |
996 |
String string = doub.toString();
|
997 |
feature.setProp("thickness", string);
|
998 |
} else {
|
999 |
Double doub = new Double(0.0); |
1000 |
feature.setProp("thickness", doub.toString());
|
1001 |
} |
1002 |
if (grp.hasCode(62)) { |
1003 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1004 |
String string = integer.toString();
|
1005 |
feature.setProp("color", string);
|
1006 |
feature.setProp("colorByLayer", "false"); |
1007 |
} else {
|
1008 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1009 |
int clr = layer.colorNumber;
|
1010 |
Integer integer = new Integer(clr); |
1011 |
String string = integer.toString();
|
1012 |
feature.setProp("color", string);
|
1013 |
feature.setProp("colorByLayer", "true"); |
1014 |
} |
1015 |
if (grp.hasCode(1)) { |
1016 |
String strAux1 = grp.getDataAsString(1); |
1017 |
strAux1 = DxfConvTexts.ConvertText(strAux1); |
1018 |
feature.setProp("text", strAux1);
|
1019 |
} else {
|
1020 |
feature.setProp("text", "No Text Code"); |
1021 |
} |
1022 |
if (grp.hasCode(40)) { |
1023 |
Double heightD = new Double(grp.getDataAsDouble(40)); |
1024 |
String heightS = heightD.toString();
|
1025 |
feature.setProp("textHeight", heightS);
|
1026 |
} else {
|
1027 |
feature.setProp("textHeight", "20.0"); |
1028 |
} |
1029 |
if (grp.hasCode(50)) { |
1030 |
Double rotD = new Double(grp.getDataAsDouble(50)); |
1031 |
String rotS = rotD.toString();
|
1032 |
feature.setProp("textRotation", rotS);
|
1033 |
//System.out.println("rotS = " + rotS);
|
1034 |
} else {
|
1035 |
feature.setProp("textRotation", "0.0"); |
1036 |
} |
1037 |
if (grp.hasCode(71)) { |
1038 |
int attachPoint = grp.getDataAsInt(71); |
1039 |
if (attachPoint == 1) { |
1040 |
} else if (attachPoint == 2) { |
1041 |
} else if (attachPoint == 3) { |
1042 |
} else if (attachPoint == 4) { |
1043 |
} else if (attachPoint == 5) { |
1044 |
} else if (attachPoint == 6) { |
1045 |
} else if (attachPoint == 7) { |
1046 |
} else if (attachPoint == 8) { |
1047 |
} else if (attachPoint == 9) { |
1048 |
} |
1049 |
} |
1050 |
if (grp.hasCode(72)) { |
1051 |
int drawDirection = grp.getDataAsInt(71); |
1052 |
if (drawDirection == 1) { |
1053 |
} else if (drawDirection == 3) { |
1054 |
} else if (drawDirection == 5) { |
1055 |
} |
1056 |
} |
1057 |
if (grp.hasCode(73)) { |
1058 |
int spacingStyle = grp.getDataAsInt(71); |
1059 |
if (spacingStyle == 1) { |
1060 |
} else if (spacingStyle == 2) { |
1061 |
} |
1062 |
} |
1063 |
x = grp.getDataAsDouble(10);
|
1064 |
y = grp.getDataAsDouble(20);
|
1065 |
z = grp.getDataAsDouble(30);
|
1066 |
/*if (grp.hasCode(30)){
|
1067 |
z = grp.getDataAsDouble(30);
|
1068 |
Double doub = new Double(z);
|
1069 |
String string = doub.toString();
|
1070 |
feature.setProp("elevation", string);
|
1071 |
} else {
|
1072 |
Double doub = new Double(0.0);
|
1073 |
feature.setProp("elevation", doub.toString());
|
1074 |
}*/
|
1075 |
if (grp.hasCode(210)) |
1076 |
xtruX = grp.getDataAsDouble(210);
|
1077 |
if (grp.hasCode(220)) |
1078 |
xtruY = grp.getDataAsDouble(220);
|
1079 |
if (grp.hasCode(230)) |
1080 |
xtruZ = grp.getDataAsDouble(230);
|
1081 |
Point3D point_in = new Point3D(x, y, z);
|
1082 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1083 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1084 |
x = point_out.getX(); |
1085 |
y = point_out.getY(); |
1086 |
z = point_out.getZ(); |
1087 |
Double doub = new Double(z); |
1088 |
feature.setProp("elevation", doub.toString());
|
1089 |
if (z!=0.0) dxf3DFile = true; |
1090 |
point.add(new Point3D(x, y, z));
|
1091 |
feature.setGeometry(point); |
1092 |
|
1093 |
// 041130: Rellena las props con los atributos.
|
1094 |
completeAttributes(feature); |
1095 |
|
1096 |
//features.add(feature);
|
1097 |
if (addingToBlock == false) { |
1098 |
features.add(feature); |
1099 |
} else {
|
1100 |
//System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
1101 |
blk.add(feature); |
1102 |
} |
1103 |
} |
1104 |
|
1105 |
public void createPoint(DxfGroupVector grp) throws Exception { |
1106 |
double x = 0.0, y = 0.0, z = 0.0; |
1107 |
DxfGroup g = null;
|
1108 |
Point3D pt = null;
|
1109 |
org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
1110 |
Feature feature = new Feature();
|
1111 |
|
1112 |
feature.setProp("dxfEntity", "Point"); |
1113 |
if (grp.hasCode(8)) |
1114 |
feature.setProp("layer", grp.getDataAsString(8)); |
1115 |
if (grp.hasCode(39)) { |
1116 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1117 |
String string = doub.toString();
|
1118 |
feature.setProp("thickness", string);
|
1119 |
} else {
|
1120 |
Double doub = new Double(0.0); |
1121 |
feature.setProp("thickness", doub.toString());
|
1122 |
} |
1123 |
if (grp.hasCode(62)) { |
1124 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1125 |
String string = integer.toString();
|
1126 |
feature.setProp("color", string);
|
1127 |
feature.setProp("colorByLayer", "false"); |
1128 |
} else {
|
1129 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1130 |
int clr = layer.colorNumber;
|
1131 |
Integer integer = new Integer(clr); |
1132 |
String string = integer.toString();
|
1133 |
feature.setProp("color", string);
|
1134 |
feature.setProp("colorByLayer", "true"); |
1135 |
} |
1136 |
x = grp.getDataAsDouble(10);
|
1137 |
y = grp.getDataAsDouble(20);
|
1138 |
z = grp.getDataAsDouble(30);
|
1139 |
/*if (grp.hasCode(30)) {
|
1140 |
z = grp.getDataAsDouble(30);
|
1141 |
Double doub = new Double(z);
|
1142 |
String string = doub.toString();
|
1143 |
feature.setProp("elevation", string);
|
1144 |
} else {
|
1145 |
Double doub = new Double(0.0);
|
1146 |
feature.setProp("elevation", doub.toString());
|
1147 |
}*/
|
1148 |
if (grp.hasCode(210)) |
1149 |
xtruX = grp.getDataAsDouble(210);
|
1150 |
if (grp.hasCode(220)) |
1151 |
xtruY = grp.getDataAsDouble(220);
|
1152 |
if (grp.hasCode(230)) |
1153 |
xtruZ = grp.getDataAsDouble(230);
|
1154 |
Point3D point_in = new Point3D(x, y, z);
|
1155 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1156 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1157 |
x = point_out.getX(); |
1158 |
y = point_out.getY(); |
1159 |
z = point_out.getZ(); |
1160 |
Double doub = new Double(z); |
1161 |
feature.setProp("elevation", doub.toString());
|
1162 |
if (z!=0.0) dxf3DFile = true; |
1163 |
point.add(new Point3D(x, y, z));
|
1164 |
feature.setGeometry(point); |
1165 |
|
1166 |
// 041130: Rellena las props con los atributos.
|
1167 |
completeAttributes(feature); |
1168 |
/*for (int i=0;i<attributes.size();i++) {
|
1169 |
String[] att = new String[2];
|
1170 |
att = (String[])attributes.get(i);
|
1171 |
feature.setProp(att[0],att[1]);
|
1172 |
}*/
|
1173 |
|
1174 |
//features.add(feature);
|
1175 |
if (addingToBlock == false) { |
1176 |
features.add(feature); |
1177 |
} else {
|
1178 |
//System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
|
1179 |
blk.add(feature); |
1180 |
} |
1181 |
} |
1182 |
|
1183 |
public void createCircle(DxfGroupVector grp) throws Exception { |
1184 |
double x = 0.0, y = 0.0, z = 0.0; |
1185 |
double r = 0.0; |
1186 |
Point3D firstPt = new Point3D();
|
1187 |
DxfGroup g = null;
|
1188 |
LineString3D lineString3D = new LineString3D();
|
1189 |
Polygon3D polygon3D = new Polygon3D();
|
1190 |
Feature feaBordes = new Feature();
|
1191 |
Feature feaFondos = new Feature();
|
1192 |
|
1193 |
feaBordes.setProp("dxfEntity", "Circle"); |
1194 |
feaFondos.setProp("dxfEntity", "Circle"); |
1195 |
if (grp.hasCode(8)) |
1196 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
1197 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
1198 |
if (grp.hasCode(39)) { |
1199 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1200 |
String string = doub.toString();
|
1201 |
feaBordes.setProp("thickness", string);
|
1202 |
feaFondos.setProp("thickness", string);
|
1203 |
} else {
|
1204 |
Double doub = new Double(0.0); |
1205 |
feaBordes.setProp("thickness", doub.toString());
|
1206 |
feaFondos.setProp("thickness", doub.toString());
|
1207 |
} |
1208 |
if (grp.hasCode(62)) { |
1209 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1210 |
String string = integer.toString();
|
1211 |
feaBordes.setProp("color", string);
|
1212 |
feaFondos.setProp("color", string);
|
1213 |
feaBordes.setProp("colorByLayer", "false"); |
1214 |
feaFondos.setProp("colorByLayer", "false"); |
1215 |
} else {
|
1216 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1217 |
int clr = layer.colorNumber;
|
1218 |
Integer integer = new Integer(clr); |
1219 |
String string = integer.toString();
|
1220 |
feaBordes.setProp("color", string);
|
1221 |
feaFondos.setProp("color", string);
|
1222 |
feaBordes.setProp("colorByLayer", "true"); |
1223 |
feaFondos.setProp("colorByLayer", "true"); |
1224 |
} |
1225 |
x = grp.getDataAsDouble(10);
|
1226 |
y = grp.getDataAsDouble(20);
|
1227 |
z = grp.getDataAsDouble(30);
|
1228 |
/*if (grp.hasCode(30)) {
|
1229 |
z = grp.getDataAsDouble(30);
|
1230 |
Double doub = new Double(z);
|
1231 |
String string = doub.toString();
|
1232 |
feaBordes.setProp("elevation", string);
|
1233 |
feaFondos.setProp("elevation", string);
|
1234 |
} else {
|
1235 |
Double doub = new Double(0.0);
|
1236 |
feaBordes.setProp("elevation", doub.toString());
|
1237 |
feaFondos.setProp("elevation", doub.toString());
|
1238 |
}*/
|
1239 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
1240 |
if (grp.hasCode(210)) |
1241 |
xtruX = grp.getDataAsDouble(210);
|
1242 |
if (grp.hasCode(220)) |
1243 |
xtruY = grp.getDataAsDouble(220);
|
1244 |
if (grp.hasCode(230)) |
1245 |
xtruZ = grp.getDataAsDouble(230);
|
1246 |
Point3D point_in = new Point3D(x, y, z);
|
1247 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1248 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1249 |
x = point_out.getX(); |
1250 |
y = point_out.getY(); |
1251 |
z = point_out.getZ(); |
1252 |
Double doub = new Double(z); |
1253 |
feaBordes.setProp("elevation", doub.toString());
|
1254 |
feaFondos.setProp("elevation", doub.toString());
|
1255 |
if (z!=0.0) dxf3DFile = true; |
1256 |
Point2D c = proj.createPoint( x, y);
|
1257 |
Point3D center = new Point3D(c.getX(), c.getY(), z);
|
1258 |
Point3D[] pts = new Point3D[360]; |
1259 |
int angulo = 0; |
1260 |
for (angulo=0; angulo<360; angulo++) { |
1261 |
pts[angulo] = new Point3D(center.getX(), center.getY(), center.getZ());
|
1262 |
pts[angulo] = new Point3D(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getZ()); |
1263 |
if (pts.length == 1) { |
1264 |
firstPt = pts[angulo]; |
1265 |
} |
1266 |
} |
1267 |
for (int i=0; i<pts.length; i++) { |
1268 |
lineString3D.add(pts[i]); |
1269 |
polygon3D.add(pts[i]); |
1270 |
} |
1271 |
|
1272 |
feaBordes.setGeometry(lineString3D); |
1273 |
feaFondos.setGeometry(polygon3D); |
1274 |
|
1275 |
// 041130: Rellena las props con los atributos.
|
1276 |
completeAttributes(feaBordes); |
1277 |
completeAttributes(feaFondos); |
1278 |
|
1279 |
//features.add(feature);
|
1280 |
if (addingToBlock == false) { |
1281 |
//System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
1282 |
features.add(feaBordes); |
1283 |
features.add(feaFondos); |
1284 |
} else {
|
1285 |
//System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
1286 |
blk.add(feaBordes); |
1287 |
blk.add(feaFondos); |
1288 |
} |
1289 |
} |
1290 |
|
1291 |
public void createArc(DxfGroupVector grp) throws Exception { |
1292 |
double x = 0.0, y = 0.0, z = 0.0; |
1293 |
double r = 0.0, empieza = 0.0, acaba = 0.0; |
1294 |
DxfGroup g = null;
|
1295 |
LineString3D lineString3D = new LineString3D();
|
1296 |
Feature feature = new Feature();
|
1297 |
|
1298 |
feature.setProp("dxfEntity", "Arc"); |
1299 |
if (grp.hasCode(8)) |
1300 |
feature.setProp("layer", grp.getDataAsString(8)); |
1301 |
if (grp.hasCode(39)) { |
1302 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1303 |
String string = doub.toString();
|
1304 |
feature.setProp("thickness", string);
|
1305 |
} else {
|
1306 |
Double doub = new Double(0.0); |
1307 |
feature.setProp("thickness", doub.toString());
|
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 |
x = grp.getDataAsDouble(10);
|
1323 |
y = grp.getDataAsDouble(20);
|
1324 |
z = grp.getDataAsDouble(30);
|
1325 |
/*if (grp.hasCode(30)) {
|
1326 |
z = grp.getDataAsDouble(30);
|
1327 |
Double doub = new Double(z);
|
1328 |
String string = doub.toString();
|
1329 |
feature.setProp("elevation", string);
|
1330 |
} else {
|
1331 |
Double doub = new Double(0.0);
|
1332 |
feature.setProp("elevation", doub.toString());
|
1333 |
}*/
|
1334 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
1335 |
if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50); |
1336 |
if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51); |
1337 |
if (grp.hasCode(210)) |
1338 |
xtruX = grp.getDataAsDouble(210);
|
1339 |
if (grp.hasCode(220)) |
1340 |
xtruY = grp.getDataAsDouble(220);
|
1341 |
if (grp.hasCode(230)) |
1342 |
xtruZ = grp.getDataAsDouble(230);
|
1343 |
Point3D point_in = new Point3D(x, y, z);
|
1344 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1345 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1346 |
x = point_out.getX(); |
1347 |
y = point_out.getY(); |
1348 |
z = point_out.getZ(); |
1349 |
Double doub = new Double(z); |
1350 |
feature.setProp("elevation", doub.toString());
|
1351 |
if (z!=0.0) dxf3DFile = true; |
1352 |
Point2D c = proj.createPoint( x, y);
|
1353 |
Point3D center = new Point3D(c.getX(), c.getY(), z);
|
1354 |
//System.out.println("empieza = " + empieza + ", acaba = " + acaba);
|
1355 |
int iempieza = (int)empieza; |
1356 |
int iacaba = (int)acaba; |
1357 |
//System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
|
1358 |
double angulo = 0; |
1359 |
Point3D[] pts = null; |
1360 |
if (empieza <= acaba) {
|
1361 |
pts = new Point3D[(iacaba-iempieza)+2]; |
1362 |
angulo = empieza; |
1363 |
pts[0] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1364 |
for (int i=1; i<=(iacaba-iempieza)+1; i++) { |
1365 |
angulo = (double)(iempieza+i);
|
1366 |
pts[i] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1367 |
} |
1368 |
angulo = acaba; |
1369 |
pts[(iacaba-iempieza)+1] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1370 |
} else {
|
1371 |
pts = new Point3D[(360-iempieza)+iacaba+2]; |
1372 |
angulo = empieza; |
1373 |
//System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
|
1374 |
pts[0] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1375 |
for (int i=1; i<=(360-iempieza); i++) { |
1376 |
angulo = (double)(iempieza+i);
|
1377 |
pts[i] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1378 |
} |
1379 |
for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) { |
1380 |
angulo = (double)(i-(360-iempieza)); |
1381 |
pts[i] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1382 |
} |
1383 |
angulo = acaba; |
1384 |
pts[(360-iempieza)+iacaba+1] = new Point3D(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getZ()); |
1385 |
} |
1386 |
for (int i=0; i<pts.length; i++) { |
1387 |
lineString3D.add(pts[i]); |
1388 |
} |
1389 |
|
1390 |
feature.setGeometry(lineString3D); |
1391 |
|
1392 |
// 041130: Rellena las props con los atributos.
|
1393 |
completeAttributes(feature); |
1394 |
|
1395 |
//features.add(feature);
|
1396 |
if (addingToBlock == false) { |
1397 |
features.add(feature); |
1398 |
} else {
|
1399 |
//System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
|
1400 |
blk.add(feature); |
1401 |
} |
1402 |
} |
1403 |
|
1404 |
public void createInsert(DxfGroupVector grp) throws Exception { |
1405 |
double x = 0.0, y = 0.0, z = 0.0; |
1406 |
DxfGroup g = null;
|
1407 |
Point3D pt = new Point3D(0.0, 0.0, 0.0); |
1408 |
Point3D scaleFactor = new Point3D(1.0, 1.0, 1.0); |
1409 |
double rotAngle = 0.0; |
1410 |
String blockName = ""; |
1411 |
|
1412 |
InsPoint3D insert = new InsPoint3D();
|
1413 |
Feature feature = new Feature();
|
1414 |
org.cresques.px.gml.Point3D secondGeom = new org.cresques.px.gml.Point3D();
|
1415 |
Feature secondFeat = new Feature();
|
1416 |
int attributesFollowFlag = 0; |
1417 |
|
1418 |
feature.setProp("dxfEntity", "Insert"); |
1419 |
secondFeat.setProp("dxfEntity", "Insert"); |
1420 |
if (grp.hasCode(2)) { |
1421 |
blockName = grp.getDataAsString(2);
|
1422 |
//feature.setProp("blockName", blockName);
|
1423 |
insert.setBlockName(blockName); |
1424 |
} |
1425 |
if (grp.hasCode(8)) { |
1426 |
feature.setProp("layer", grp.getDataAsString(8)); |
1427 |
secondFeat.setProp("layer", grp.getDataAsString(8)); |
1428 |
} |
1429 |
|
1430 |
Double doub = new Double(0.0); |
1431 |
secondFeat.setProp("thickness", doub.toString());
|
1432 |
|
1433 |
if (grp.hasCode(62)) { |
1434 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1435 |
String string = integer.toString();
|
1436 |
feature.setProp("color", string);
|
1437 |
secondFeat.setProp("color", string);
|
1438 |
feature.setProp("colorByLayer", "false"); |
1439 |
secondFeat.setProp("colorByLayer", "false"); |
1440 |
} else {
|
1441 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1442 |
int clr = layer.colorNumber;
|
1443 |
Integer integer = new Integer(clr); |
1444 |
String string = integer.toString();
|
1445 |
feature.setProp("color", string);
|
1446 |
secondFeat.setProp("color", string);
|
1447 |
feature.setProp("colorByLayer", "true"); |
1448 |
secondFeat.setProp("colorByLayer", "true"); |
1449 |
} |
1450 |
if (grp.hasCode(66)) { |
1451 |
attributesFollowFlag = grp.getDataAsInt(66);
|
1452 |
} |
1453 |
x = grp.getDataAsDouble(10);
|
1454 |
y = grp.getDataAsDouble(20);
|
1455 |
z = grp.getDataAsDouble(30);
|
1456 |
/*if (grp.hasCode(30)) {
|
1457 |
z = grp.getDataAsDouble(30);
|
1458 |
Double doubz = new Double(z);
|
1459 |
String string = doubz.toString();
|
1460 |
feature.setProp("elevation", string);
|
1461 |
secondFeat.setProp("elevation", string);
|
1462 |
} else {
|
1463 |
Double elev = new Double(z);
|
1464 |
//feature.setProp("elevation", doub.toString());
|
1465 |
feature.setProp("elevation", elev.toString());
|
1466 |
secondFeat.setProp("elevation", elev.toString());
|
1467 |
}*/
|
1468 |
if (grp.hasCode(41)) { |
1469 |
scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
|
1470 |
insert.setScaleFactor(scaleFactor); |
1471 |
} else {
|
1472 |
insert.setScaleFactor(scaleFactor); |
1473 |
} |
1474 |
if (grp.hasCode(42)) { |
1475 |
scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
|
1476 |
insert.setScaleFactor(scaleFactor); |
1477 |
} else {
|
1478 |
insert.setScaleFactor(scaleFactor); |
1479 |
} |
1480 |
if (grp.hasCode(43)) { |
1481 |
scaleFactor = new Point3D(scaleFactor.getX(), scaleFactor.getY(), grp.getDataAsDouble(43)); |
1482 |
insert.setScaleFactor(scaleFactor); |
1483 |
} else {
|
1484 |
insert.setScaleFactor(scaleFactor); |
1485 |
} |
1486 |
if (grp.hasCode(50)) { |
1487 |
rotAngle = grp.getDataAsDouble(50);
|
1488 |
insert.setRotAngle(rotAngle); |
1489 |
} |
1490 |
if (grp.hasCode(210)) |
1491 |
xtruX = grp.getDataAsDouble(210);
|
1492 |
if (grp.hasCode(220)) |
1493 |
xtruY = grp.getDataAsDouble(220);
|
1494 |
if (grp.hasCode(230)) |
1495 |
xtruZ = grp.getDataAsDouble(230);
|
1496 |
Point3D point_in = new Point3D(x, y, z);
|
1497 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1498 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1499 |
x = point_out.getX(); |
1500 |
y = point_out.getY(); |
1501 |
z = point_out.getZ(); |
1502 |
Double doubz = new Double(z); |
1503 |
feature.setProp("elevation", doubz.toString());
|
1504 |
secondFeat.setProp("elevation", doubz.toString());
|
1505 |
if (z!=0.0) dxf3DFile = true; |
1506 |
insert.setBlkList(blkList); |
1507 |
|
1508 |
insert.encuentraBloque(blockName); |
1509 |
|
1510 |
insert.add(new Point3D(x, y, z));
|
1511 |
secondGeom.add(new Point3D(x, y, z));
|
1512 |
|
1513 |
feature.setGeometry(insert); |
1514 |
secondFeat.setGeometry(secondGeom); |
1515 |
|
1516 |
// 041130: Rellena las props con los atributos.
|
1517 |
completeAttributes(feature); |
1518 |
completeAttributes(secondFeat); |
1519 |
/*for (int i=0;i<attributes.size();i++) {
|
1520 |
String[] att = new String[2];
|
1521 |
att = (String[])attributes.get(i);
|
1522 |
secondFeat.setProp(att[0],att[1]);
|
1523 |
}*/
|
1524 |
|
1525 |
if (insert.getBlockFound()==true && attributesFollowFlag!=1) gestionaInsert(feature); |
1526 |
|
1527 |
//if (addingToBlock == false) {
|
1528 |
//features.add(secondFeat);
|
1529 |
//}
|
1530 |
//if (addingToBlock == true/* && insert.getBlockFound() == true*/) {
|
1531 |
//System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
|
1532 |
//blk.add(feature);
|
1533 |
//}
|
1534 |
|
1535 |
// 041129: A?adido para implementar los ATTRIBS.
|
1536 |
if (attributesFollowFlag==1) { |
1537 |
isDoubleFeatured = true;
|
1538 |
lastFeaBordes = feature; |
1539 |
lastFeaFondos = secondFeat; |
1540 |
} else {
|
1541 |
if (addingToBlock == false) { |
1542 |
features.add(secondFeat); |
1543 |
} |
1544 |
if (addingToBlock == true/* && insert.getBlockFound() == true*/) { |
1545 |
//System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
|
1546 |
blk.add(feature); |
1547 |
} |
1548 |
} |
1549 |
} |
1550 |
|
1551 |
public void createSolid(DxfGroupVector grp) throws Exception { |
1552 |
double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0, z3 = 0.0, z4 = 0.0; |
1553 |
DxfGroup g = null;
|
1554 |
//Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
|
1555 |
Point3D[] pts = new Point3D[4]; |
1556 |
//DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1557 |
|
1558 |
LineString3D lineString3D = new LineString3D();
|
1559 |
Polygon3D polygon3D = new Polygon3D();
|
1560 |
Feature feaBordes = new Feature();
|
1561 |
Feature feaFondos = new Feature();
|
1562 |
//double elev = 0;
|
1563 |
|
1564 |
feaBordes.setProp("dxfEntity", "Solid"); |
1565 |
feaFondos.setProp("dxfEntity", "Solid"); |
1566 |
if (grp.hasCode(8)) |
1567 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
1568 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
1569 |
x = grp.getDataAsDouble(10);
|
1570 |
y = grp.getDataAsDouble(20);
|
1571 |
z1 = grp.getDataAsDouble(30);
|
1572 |
/*if (grp.hasCode(30)) {
|
1573 |
z1 = grp.getDataAsDouble(30);
|
1574 |
} else {
|
1575 |
Double doub = new Double(0.0);
|
1576 |
feaBordes.setProp("elevation", doub.toString());
|
1577 |
feaFondos.setProp("elevation", doub.toString());
|
1578 |
}*/
|
1579 |
Point2D pto = proj.createPoint(x, y);
|
1580 |
Point3D pto3D = new Point3D(pto.getX(), pto.getY(), z1);
|
1581 |
pts[0] = pto3D;
|
1582 |
x = grp.getDataAsDouble(11);
|
1583 |
y = grp.getDataAsDouble(21);
|
1584 |
z2 = grp.getDataAsDouble(31);
|
1585 |
pto = proj.createPoint(x, y); |
1586 |
pto3D = new Point3D(pto.getX(), pto.getY(), z2);
|
1587 |
pts[1] = pto3D;
|
1588 |
x = grp.getDataAsDouble(12);
|
1589 |
y = grp.getDataAsDouble(22);
|
1590 |
z3 = grp.getDataAsDouble(32);
|
1591 |
pto = proj.createPoint(x, y); |
1592 |
pto3D = new Point3D(pto.getX(), pto.getY(), z3);
|
1593 |
pts[2] = pto3D;
|
1594 |
if (grp.hasCode(13)) x = grp.getDataAsDouble(13); |
1595 |
if (grp.hasCode(23)) y = grp.getDataAsDouble(23); |
1596 |
if (grp.hasCode(33)) z4 = grp.getDataAsDouble(33); |
1597 |
pto = proj.createPoint(x, y); |
1598 |
pto3D = new Point3D(pto.getX(), pto.getY(), z4);
|
1599 |
pts[3] = pto3D;
|
1600 |
if (grp.hasCode(39)) { |
1601 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1602 |
String string = doub.toString();
|
1603 |
feaBordes.setProp("thickness", string);
|
1604 |
feaFondos.setProp("thickness", string);
|
1605 |
} else {
|
1606 |
Double doub = new Double(0.0); |
1607 |
feaBordes.setProp("thickness", doub.toString());
|
1608 |
feaFondos.setProp("thickness", doub.toString());
|
1609 |
} |
1610 |
if (grp.hasCode(62)) { |
1611 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1612 |
String string = integer.toString();
|
1613 |
feaBordes.setProp("color", string);
|
1614 |
feaFondos.setProp("color", string);
|
1615 |
feaBordes.setProp("colorByLayer", "false"); |
1616 |
feaFondos.setProp("colorByLayer", "false"); |
1617 |
} else {
|
1618 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1619 |
int clr = layer.colorNumber;
|
1620 |
Integer integer = new Integer(clr); |
1621 |
String string = integer.toString();
|
1622 |
feaBordes.setProp("color", string);
|
1623 |
feaFondos.setProp("color", string);
|
1624 |
feaBordes.setProp("colorByLayer", "true"); |
1625 |
feaFondos.setProp("colorByLayer", "true"); |
1626 |
} |
1627 |
if (grp.hasCode(210)) |
1628 |
xtruX = grp.getDataAsDouble(210);
|
1629 |
if (grp.hasCode(220)) |
1630 |
xtruY = grp.getDataAsDouble(220);
|
1631 |
if (grp.hasCode(230)) |
1632 |
xtruZ = grp.getDataAsDouble(230);
|
1633 |
Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1); |
1634 |
Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2); |
1635 |
Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3); |
1636 |
Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4); |
1637 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1638 |
Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru); |
1639 |
Point3D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru); |
1640 |
Point3D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru); |
1641 |
Point3D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru); |
1642 |
pts[0] = new Point3D(point_out1); |
1643 |
pts[1] = new Point3D(point_out2); |
1644 |
pts[2] = new Point3D(point_out3); |
1645 |
pts[3] = new Point3D(point_out4); |
1646 |
if (pts[0].getZ()!=0.0 || pts[1].getZ()!=0.0 || pts[2].getZ()!=0.0 || pts[3].getZ()!=0.0) dxf3DFile = true; |
1647 |
Point3D aux = pts[3];
|
1648 |
pts[2] = pts[3]; |
1649 |
pts[3] = aux;
|
1650 |
|
1651 |
if (pts[0].getZ()==pts[1].getZ() && pts[1].getZ()==pts[2].getZ() && pts[2].getZ()==pts[3].getZ()) { |
1652 |
Double doub = new Double(pts[0].getZ()); |
1653 |
String string = doub.toString();
|
1654 |
feaBordes.setProp("elevation", string);
|
1655 |
feaFondos.setProp("elevation", string);
|
1656 |
} else {
|
1657 |
Double doub = new Double(0.0); |
1658 |
String string = doub.toString();
|
1659 |
feaBordes.setProp("elevation", string);
|
1660 |
feaFondos.setProp("elevation", string);
|
1661 |
} |
1662 |
|
1663 |
for (int i=0; i<pts.length; i++) { |
1664 |
lineString3D.add(pts[i]); |
1665 |
polygon3D.add(pts[i]); |
1666 |
} |
1667 |
|
1668 |
// Para cerrarlos.
|
1669 |
lineString3D.add(pts[0]);
|
1670 |
polygon3D.add(pts[0]);
|
1671 |
|
1672 |
feaBordes.setGeometry(lineString3D); |
1673 |
feaFondos.setGeometry(polygon3D); |
1674 |
|
1675 |
// 041130: Rellena las props con los atributos.
|
1676 |
completeAttributes(feaBordes); |
1677 |
completeAttributes(feaFondos); |
1678 |
|
1679 |
//features.add(feature);
|
1680 |
if (addingToBlock == false) { |
1681 |
//System.out.println("createSolid(): A?ade un solid a la lista de entidades");
|
1682 |
features.add(feaBordes); |
1683 |
features.add(feaFondos); |
1684 |
} else {
|
1685 |
//System.out.println("createSolid(): A?adimos un circulo al bloque " + iterator);
|
1686 |
blk.add(feaBordes); |
1687 |
blk.add(feaFondos); |
1688 |
} |
1689 |
} |
1690 |
|
1691 |
public void createSpline(DxfGroupVector grp) throws Exception { |
1692 |
double x = 0.0, y = 0.0, z = 0.0; //elev = 0.0; |
1693 |
//double elev = 0.0;
|
1694 |
DxfGroup g = null;
|
1695 |
LineString3D lineString3D = new LineString3D();
|
1696 |
Polygon3D polygon3D = new Polygon3D();
|
1697 |
//Geometry geometria;
|
1698 |
//Feature feature= new Feature();
|
1699 |
Feature feaBordes= new Feature();
|
1700 |
Feature feaFondos= new Feature();
|
1701 |
int flags = 0; |
1702 |
|
1703 |
//feature.setProp("dxfEntity", "LwPolyline");
|
1704 |
feaBordes.setProp("dxfEntity", "Spline"); |
1705 |
feaFondos.setProp("dxfEntity", "Spline"); |
1706 |
if (grp.hasCode(8)) { |
1707 |
//feature.setProp("layer", grp.getDataAsString(8));
|
1708 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
1709 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
1710 |
} |
1711 |
if (grp.hasCode(39)) { |
1712 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1713 |
String string = doub.toString();
|
1714 |
//feature.setProp("thickness", string);
|
1715 |
feaBordes.setProp("thickness", string);
|
1716 |
feaFondos.setProp("thickness", string);
|
1717 |
} else {
|
1718 |
Double doub = new Double(0.0); |
1719 |
//feature.setProp("thickness", doub.toString());
|
1720 |
feaBordes.setProp("thickness", doub.toString());
|
1721 |
feaFondos.setProp("thickness", doub.toString());
|
1722 |
} |
1723 |
if (grp.hasCode(62)) { |
1724 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1725 |
String string = integer.toString();
|
1726 |
//feature.setProp("color", string);
|
1727 |
feaBordes.setProp("color", string);
|
1728 |
feaFondos.setProp("color", string);
|
1729 |
feaBordes.setProp("colorByLayer", "false"); |
1730 |
feaFondos.setProp("colorByLayer", "false"); |
1731 |
} else {
|
1732 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1733 |
int clr = layer.colorNumber;
|
1734 |
Integer integer = new Integer(clr); |
1735 |
String string = integer.toString();
|
1736 |
//feature.setProp("color", string);
|
1737 |
feaBordes.setProp("color", string);
|
1738 |
feaFondos.setProp("color", string);
|
1739 |
feaBordes.setProp("colorByLayer", "true"); |
1740 |
feaFondos.setProp("colorByLayer", "true"); |
1741 |
} |
1742 |
if (grp.hasCode(70)) |
1743 |
flags = grp.getDataAsInt(70);
|
1744 |
if ((flags & 0x01) == 0x01) { |
1745 |
//geometria = new Polygon();
|
1746 |
feaBordes.setGeometry(lineString3D); |
1747 |
feaFondos.setGeometry(polygon3D); |
1748 |
isDoubleFeatured = true;
|
1749 |
} else {
|
1750 |
//geometria = new LineString();
|
1751 |
feaBordes.setGeometry(lineString3D); |
1752 |
isDoubleFeatured = false;
|
1753 |
} |
1754 |
|
1755 |
int j = 0; |
1756 |
double firstX = 0.0; |
1757 |
double firstY = 0.0; |
1758 |
double firstZ = 0.0; |
1759 |
for (int i=0; i<grp.size(); i++) { |
1760 |
g = (DxfGroup) grp.get(i); |
1761 |
if (g.getCode() == 10) { |
1762 |
j++; |
1763 |
x = ((Double) g.getData()).doubleValue();
|
1764 |
} else if (g.getCode() == 20) { |
1765 |
y = ((Double) g.getData()).doubleValue();
|
1766 |
} else if (g.getCode() == 30) { |
1767 |
z = ((Double) g.getData()).doubleValue();
|
1768 |
Point2D p = proj.createPoint(x, y);
|
1769 |
Point3D p3d = new Point3D(p.getX(), p.getY(), z);
|
1770 |
lineString3D.add(p3d); |
1771 |
if (isDoubleFeatured) polygon3D.add(p3d);
|
1772 |
if (j == 1) { |
1773 |
firstX = x; |
1774 |
firstY = y; |
1775 |
firstZ = z; |
1776 |
} |
1777 |
//elev = z;
|
1778 |
x = 0.0; y = 0.0; z = 0.0; |
1779 |
} |
1780 |
} |
1781 |
|
1782 |
//Double doub = new Double(elev);
|
1783 |
//String string = doub.toString();
|
1784 |
//feature.setProp("elevation", string);
|
1785 |
//feaBordes.setProp("elevation", string);
|
1786 |
//feaFondos.setProp("elevation", string);
|
1787 |
|
1788 |
if (isDoubleFeatured) {
|
1789 |
Point2D p = proj.createPoint(firstX, firstY);
|
1790 |
Point3D p3d = new Point3D(p.getX(), p.getY(), z);
|
1791 |
lineString3D.add(p3d); |
1792 |
polygon3D.add(p3d); |
1793 |
} |
1794 |
|
1795 |
double zprev = 0; |
1796 |
boolean constSplineElev = true; |
1797 |
for (int i=0;i<lineString3D.pointNr();i++) { |
1798 |
z = lineString3D.getPoint3D(i).getZ(); |
1799 |
if (z!=0.0) dxf3DFile = true; |
1800 |
if (i>0 && z!=zprev) { |
1801 |
constSplineElev = false;
|
1802 |
} |
1803 |
zprev = z; |
1804 |
} |
1805 |
if (constSplineElev) {
|
1806 |
Double doub = new Double(lineString3D.getPoint3D(0).getZ()); |
1807 |
String string = doub.toString();
|
1808 |
feaBordes.setProp("elevation", string);
|
1809 |
if (isDoubleFeatured) feaFondos.setProp("elevation", string); |
1810 |
} else {
|
1811 |
Double doub = new Double(0.0); |
1812 |
String string = doub.toString();
|
1813 |
feaBordes.setProp("elevation", string);
|
1814 |
if (isDoubleFeatured) feaFondos.setProp("elevation", string); |
1815 |
} |
1816 |
|
1817 |
lastFeaBordes = feaBordes; |
1818 |
if (isDoubleFeatured) lastFeaFondos = feaFondos;
|
1819 |
|
1820 |
// 041130: Rellena las props con los atributos.
|
1821 |
completeAttributes(feaBordes); |
1822 |
completeAttributes(feaFondos); |
1823 |
|
1824 |
//features.add(feature);
|
1825 |
if (addingToBlock == false) { |
1826 |
features.add(feaBordes); |
1827 |
if (isDoubleFeatured) features.add(feaFondos);
|
1828 |
} else {
|
1829 |
//System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
1830 |
blk.add(feaBordes); |
1831 |
if (isDoubleFeatured) blk.add(feaFondos);
|
1832 |
} |
1833 |
isDoubleFeatured = false;
|
1834 |
} |
1835 |
public void createAttdef(DxfGroupVector grp) throws Exception { |
1836 |
DxfGroup g = null;
|
1837 |
|
1838 |
String defaultValue = ""; |
1839 |
String tagString = ""; |
1840 |
String textStyleName = ""; |
1841 |
String attribute[] = new String[2]; |
1842 |
boolean tagDefined = false; |
1843 |
boolean defValDefined = false; |
1844 |
|
1845 |
if (grp.hasCode(1)) { |
1846 |
defaultValue = grp.getDataAsString(1);
|
1847 |
attribute[1] = DxfConvTexts.ConvertText(defaultValue);
|
1848 |
defValDefined = true;
|
1849 |
if (tagDefined) attributes.add(attribute);
|
1850 |
} |
1851 |
if (grp.hasCode(2)) { |
1852 |
tagString = grp.getDataAsString(2);
|
1853 |
attribute[0] = DxfConvTexts.ConvertText(tagString);
|
1854 |
tagDefined = true;
|
1855 |
if (defValDefined) attributes.add(attribute);
|
1856 |
} |
1857 |
if (grp.hasCode(7)) { |
1858 |
textStyleName = grp.getDataAsString(7);
|
1859 |
textStyleName = DxfConvTexts.ConvertText(textStyleName); |
1860 |
} |
1861 |
setNewAttributes(); |
1862 |
} |
1863 |
public void createAttrib(DxfGroupVector grp) throws Exception { |
1864 |
double x = 0.0, y = 0.0, z = 0.0, h= 0.0, rot= 0.0; |
1865 |
DxfGroup g = null;
|
1866 |
//Point2D pt1 = null, pt2 = null;
|
1867 |
Point3D pt = null;
|
1868 |
org.cresques.px.gml.Point3D point = new org.cresques.px.gml.Point3D();
|
1869 |
|
1870 |
point.setTextPoint(true);
|
1871 |
|
1872 |
String defaultValue = ""; |
1873 |
String tagString = ""; |
1874 |
String textStyleName = ""; |
1875 |
String att[] = new String[2]; |
1876 |
boolean tagDefined = false; |
1877 |
boolean defValDefined = false; |
1878 |
int attributeFlags = 0; |
1879 |
|
1880 |
Feature insFea = lastFeaBordes; |
1881 |
Feature ptFea = lastFeaFondos; |
1882 |
|
1883 |
Feature feature = new Feature();
|
1884 |
|
1885 |
feature.setProp("dxfEntity", "Attrib"); // <-- Es un INSERT con attributes. |
1886 |
if (grp.hasCode(8)) |
1887 |
feature.setProp("layer", grp.getDataAsString(8)); |
1888 |
if (grp.hasCode(39)) { |
1889 |
Double doub = new Double(grp.getDataAsDouble(39)); |
1890 |
String string = doub.toString();
|
1891 |
feature.setProp("thickness", string);
|
1892 |
} else {
|
1893 |
Double doub = new Double(0.0); |
1894 |
feature.setProp("thickness", doub.toString());
|
1895 |
} |
1896 |
if (grp.hasCode(62)) { |
1897 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
1898 |
String string = integer.toString();
|
1899 |
feature.setProp("color", string);
|
1900 |
feature.setProp("colorByLayer", "false"); |
1901 |
} else {
|
1902 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1903 |
int clr = layer.colorNumber;
|
1904 |
Integer integer = new Integer(clr); |
1905 |
String string = integer.toString();
|
1906 |
feature.setProp("color", string);
|
1907 |
feature.setProp("colorByLayer", "true"); |
1908 |
} |
1909 |
|
1910 |
if (grp.hasCode(1)) { |
1911 |
String strAux1 = grp.getDataAsString(1); |
1912 |
strAux1 = DxfConvTexts.ConvertText(strAux1); |
1913 |
defaultValue = strAux1; |
1914 |
att[1] = DxfConvTexts.ConvertText(defaultValue);
|
1915 |
defValDefined = true;
|
1916 |
if (tagDefined) {
|
1917 |
insFea.setProp(att[0], att[1]); |
1918 |
ptFea.setProp(att[0], att[1]); |
1919 |
} |
1920 |
feature.setProp("text", strAux1);
|
1921 |
} |
1922 |
if (grp.hasCode(2)) { |
1923 |
String strAux2 = grp.getDataAsString(2); |
1924 |
strAux2 = DxfConvTexts.ConvertText(strAux2); |
1925 |
tagString = strAux2; |
1926 |
att[0] = DxfConvTexts.ConvertText(tagString);
|
1927 |
tagDefined = true;
|
1928 |
if (defValDefined) {
|
1929 |
insFea.setProp(att[0], att[1]); |
1930 |
ptFea.setProp(att[0], att[1]); |
1931 |
} |
1932 |
} |
1933 |
if (grp.hasCode(7)) { |
1934 |
textStyleName = grp.getDataAsString(7);
|
1935 |
textStyleName = DxfConvTexts.ConvertText(textStyleName); |
1936 |
} |
1937 |
if (grp.hasCode(70)) { |
1938 |
attributeFlags = grp.getDataAsInt(70);
|
1939 |
} |
1940 |
|
1941 |
if (grp.hasCode(40)) { |
1942 |
Double heightD = new Double(grp.getDataAsDouble(40)); |
1943 |
String heightS = heightD.toString();
|
1944 |
feature.setProp("textHeight", heightS);
|
1945 |
} else {
|
1946 |
feature.setProp("textHeight", "20.0"); |
1947 |
} |
1948 |
if (grp.hasCode(50)) { |
1949 |
Double rotD = new Double(grp.getDataAsDouble(50)); |
1950 |
String rotS = rotD.toString();
|
1951 |
feature.setProp("textRotation", rotS);
|
1952 |
} else {
|
1953 |
feature.setProp("textRotation", "0.0"); |
1954 |
} |
1955 |
x = grp.getDataAsDouble(10);
|
1956 |
y = grp.getDataAsDouble(20);
|
1957 |
z = grp.getDataAsDouble(30);
|
1958 |
/*if (grp.hasCode(30)){
|
1959 |
z = grp.getDataAsDouble(30);
|
1960 |
Double doub = new Double(z);
|
1961 |
String string = doub.toString();
|
1962 |
feature.setProp("elevation", string);
|
1963 |
} else {
|
1964 |
Double doub = new Double(0.0);
|
1965 |
feature.setProp("elevation", doub.toString());
|
1966 |
}*/
|
1967 |
if (grp.hasCode(210)) |
1968 |
xtruX = grp.getDataAsDouble(210);
|
1969 |
if (grp.hasCode(220)) |
1970 |
xtruY = grp.getDataAsDouble(220);
|
1971 |
if (grp.hasCode(230)) |
1972 |
xtruZ = grp.getDataAsDouble(230);
|
1973 |
Point3D point_in = new Point3D(x, y, z);
|
1974 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
1975 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
1976 |
x = point_out.getX(); |
1977 |
y = point_out.getY(); |
1978 |
z = point_out.getZ(); |
1979 |
Double doub = new Double(z); |
1980 |
feature.setProp("elevation", doub.toString());
|
1981 |
if (z!=0.0) dxf3DFile = true; |
1982 |
point.add(new Point3D(x, y, z));
|
1983 |
feature.setGeometry(point); |
1984 |
|
1985 |
// 041130: Rellena las props con los atributos.
|
1986 |
completeAttributes(feature); |
1987 |
|
1988 |
if (attributeFlags==8) { |
1989 |
if (addingToBlock == false) { |
1990 |
features.add(feature); |
1991 |
} else {
|
1992 |
blk.add(feature); |
1993 |
} |
1994 |
} |
1995 |
} |
1996 |
|
1997 |
public void createBlock(DxfGroupVector grp) throws Exception { |
1998 |
//DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1999 |
blk = new FeatureCollection(proj);
|
2000 |
|
2001 |
Point3D basePoint = new Point3D();
|
2002 |
String blockName = ""; |
2003 |
//System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
|
2004 |
|
2005 |
addingToBlock = true;
|
2006 |
//System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
|
2007 |
blkList.add(iterator, blk); |
2008 |
|
2009 |
//System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
|
2010 |
|
2011 |
if (grp.hasCode(8)) |
2012 |
blk.setProp("layer", grp.getDataAsString(8)); |
2013 |
if (grp.hasCode(62)) { |
2014 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
2015 |
String string = integer.toString();
|
2016 |
blk.setProp("color", string);
|
2017 |
blk.setProp("colorByLayer", "false"); |
2018 |
} else {
|
2019 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
2020 |
int clr = layer.colorNumber;
|
2021 |
Integer integer = new Integer(clr); |
2022 |
String string = integer.toString();
|
2023 |
blk.setProp("color", string);
|
2024 |
blk.setProp("colorByLayer", "true"); |
2025 |
} |
2026 |
|
2027 |
if (grp.hasCode(1)) { |
2028 |
blockName = grp.getDataAsString(1);
|
2029 |
//blk.setBlkName(blockName);
|
2030 |
blk.setProp("blockName", blockName);
|
2031 |
} |
2032 |
if (grp.hasCode(2)) { |
2033 |
blockName = grp.getDataAsString(2);
|
2034 |
//blk.setBlkName(blockName);
|
2035 |
blk.setProp("blockName", blockName);
|
2036 |
} |
2037 |
if (grp.hasCode(10)) { |
2038 |
Double basePointX = new Double(grp.getDataAsDouble(10)); |
2039 |
basePoint.X = grp.getDataAsDouble(10);
|
2040 |
blk.setProp("basePointX", basePointX.toString());
|
2041 |
} |
2042 |
if (grp.hasCode(20)) { |
2043 |
Double basePointY = new Double(grp.getDataAsDouble(20)); |
2044 |
basePoint.Y = grp.getDataAsDouble(20);
|
2045 |
blk.setProp("basePointY", basePointY.toString());
|
2046 |
} |
2047 |
if (grp.hasCode(30)) { |
2048 |
Double basePointZ = new Double(grp.getDataAsDouble(30)); |
2049 |
basePoint.Z = grp.getDataAsDouble(30);
|
2050 |
if (basePoint.getZ()!=0.0) dxf3DFile = true; |
2051 |
blk.setProp("basePointZ", basePointZ.toString());
|
2052 |
} |
2053 |
if (grp.hasCode(70)) { |
2054 |
//blk.flags = grp.getDataAsInt(70);
|
2055 |
Integer blockFlags = new Integer(grp.getDataAsInt(70)); |
2056 |
blk.setProp("blockFlags", blockFlags.toString());
|
2057 |
// 041103: Hoy por hoy esto no lo utilizamos.
|
2058 |
} |
2059 |
} |
2060 |
|
2061 |
public void endBlk(DxfGroupVector grp) throws Exception { |
2062 |
//DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
2063 |
setAddingToBlock(false);
|
2064 |
iterator = iterator + 1;
|
2065 |
} |
2066 |
|
2067 |
public void testBlocks() { |
2068 |
//System.out.println("getBlkList() = " + getBlkList());
|
2069 |
Vector blkList = getBlkList();
|
2070 |
FeatureCollection block = null;
|
2071 |
Feature feature = null;
|
2072 |
InsPoint3D insert = null;
|
2073 |
for (int i=0; i<blkList.size(); i++) { |
2074 |
//System.out.println("compruebaBloques(): Bloque " + i +" de " + blkList.size());
|
2075 |
block = (FeatureCollection) blkList.get(i); |
2076 |
int aux = block.size();
|
2077 |
for (int j=0; j<aux; j++) { |
2078 |
feature = (Feature)block.get(j); |
2079 |
//if (feature.getGeometry() instanceof InsPoint && feature.getProp("isAnInsert") == "true") {
|
2080 |
if (feature.getGeometry() instanceof InsPoint3D) { |
2081 |
insert = (InsPoint3D)feature.getGeometry(); |
2082 |
String nomBlock = insert.getBlockName();
|
2083 |
if (insert.getBlockFound() == false) { |
2084 |
//System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock);
|
2085 |
insert.encuentraBloque(nomBlock); |
2086 |
//gestionaInsert(feature);
|
2087 |
//block.add(feature);
|
2088 |
} |
2089 |
} |
2090 |
} |
2091 |
} |
2092 |
} |
2093 |
|
2094 |
private void gestionaInsert(Feature feature) { |
2095 |
Feature feature2 = null;
|
2096 |
org.cresques.px.gml.Point3D point = null;
|
2097 |
LineString3D lineString3D = null;
|
2098 |
Polygon3D polygon3D = null;
|
2099 |
InsPoint3D insert = new InsPoint3D();
|
2100 |
insert = (InsPoint3D)feature.getGeometry(); |
2101 |
double bPointX = 0.0; |
2102 |
double bPointY = 0.0; |
2103 |
double bPointZ = 0.0; |
2104 |
//if (insert.getBlockFound() == true) {
|
2105 |
bPointX = Double.parseDouble(insert.getBlock().getProp("basePointX")); |
2106 |
bPointY = Double.parseDouble(insert.getBlock().getProp("basePointY")); |
2107 |
bPointZ = Double.parseDouble(insert.getBlock().getProp("basePointZ")); |
2108 |
//}
|
2109 |
double sFactorX = insert.getScaleFactor().getX();
|
2110 |
double sFactorY = insert.getScaleFactor().getY();
|
2111 |
double sFactorZ = insert.getScaleFactor().getZ();
|
2112 |
double rAngleGra = insert.getRotAngle();
|
2113 |
double rAngleRad = rAngleGra*Math.PI/180.0; |
2114 |
InsPoint3D insert2 = null;
|
2115 |
|
2116 |
for (int i=0; i<insert.getBlock().size(); i++) { |
2117 |
//System.out.println("gestionaInserts: insert.getBlock().features.size() = " + insert.getBlock().size());
|
2118 |
feature2 = (Feature)insert.getBlock().get(i); |
2119 |
|
2120 |
// Para que los elementos dentro del bloque tengan la misma layer
|
2121 |
// y color que el insert al que corresponden.
|
2122 |
// Segun la especificacion del formato DXF de Autodesk, la layer
|
2123 |
// de las entities dentro de un bloque es la del bloque. La
|
2124 |
// layer especifica para estos elementos en la defincion del
|
2125 |
// bloque se ignora.
|
2126 |
//System.out.println("gestionaInsert(): layer = " + feature2.getProp("layer"));
|
2127 |
if ((feature2.getProp("colorByLayer").equals("false") || feature2.getProp("layer").equals("0")) && !feature.getProp("layer").equals("0")) { |
2128 |
feature2.setProp("color", feature.getProp("color")); |
2129 |
} |
2130 |
feature2.setProp("layer", feature.getProp("layer")); |
2131 |
|
2132 |
Point3D point1 = new Point3D();
|
2133 |
Point3D point11 = new Point3D();
|
2134 |
Point3D pointAux = null;
|
2135 |
|
2136 |
if (feature2.getGeometry() instanceof InsPoint3D){ |
2137 |
|
2138 |
//System.out.println("gestionaInsert(): Encuentra bloques dentro de bloques");
|
2139 |
|
2140 |
insert2 = (InsPoint3D)feature2.getGeometry(); |
2141 |
point1 = insert2.getPoint3D(0);
|
2142 |
|
2143 |
pointAux = new Point3D(point1.getX() - bPointX, point1.getY() - bPointY, point1.getZ() - bPointZ);
|
2144 |
double laX = insert.getPoint3D(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
2145 |
double laY = insert.getPoint3D(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
2146 |
double laZ = insert.getPoint3D(0).getZ() + (pointAux.getZ()*sFactorZ); |
2147 |
point11 = new Point3D(laX, laY, laZ);
|
2148 |
InsPoint3D insert3 = new InsPoint3D();
|
2149 |
|
2150 |
insert3.add(point11); |
2151 |
|
2152 |
insert3.setBlkList(insert2.getBlkList()); |
2153 |
insert3.setBlock(insert2.getBlock()); |
2154 |
insert3.setBlockName(insert2.getBlockName()); |
2155 |
insert3.setRotAngle(insert2.getRotAngle()); |
2156 |
Point3D newScale = new Point3D(insert2.getScaleFactor().getX() * sFactorX, insert2.getScaleFactor().getY() * sFactorY, insert2.getScaleFactor().getZ() * sFactorZ);
|
2157 |
insert3.setScaleFactor(newScale); |
2158 |
|
2159 |
Feature feature3 = new Feature();
|
2160 |
feature3.setProp("layer", feature2.getProp("layer")); |
2161 |
feature3.setProp("color", feature2.getProp("color")); |
2162 |
feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
2163 |
feature3.setProp("elevation", feature2.getProp("elevation")); |
2164 |
|
2165 |
//041130
|
2166 |
for (int j=0;j<attributes.size();j++) { |
2167 |
String[] att = new String[2]; |
2168 |
att = (String[])attributes.get(j); |
2169 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2170 |
} |
2171 |
|
2172 |
feature3.setGeometry(insert3); |
2173 |
|
2174 |
gestionaInsert(feature3); |
2175 |
} else if (feature2.getGeometry() instanceof LineString3D) { |
2176 |
lineString3D = (LineString3D)feature2.getGeometry(); |
2177 |
LineString3D lineString2 = new LineString3D();
|
2178 |
Point3D[] points = new Point3D[lineString3D.pointNr()]; |
2179 |
Point3D[] pointss = new Point3D[lineString3D.pointNr()]; |
2180 |
for (int j=0; j<lineString3D.pointNr(); j++) { |
2181 |
points[j] = (Point3D)lineString3D.get(j); |
2182 |
pointss[j] = new Point3D();
|
2183 |
|
2184 |
pointAux = new Point3D(points[j].getX() - bPointX, points[j].getY() - bPointY, points[j].getZ() - bPointZ);
|
2185 |
double laX = insert.getPoint3D(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
2186 |
double laY = insert.getPoint3D(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
2187 |
double laZ = insert.getPoint3D(0).getZ() + (pointAux.getZ()*sFactorZ); |
2188 |
pointss[j] = new Point3D(laX, laY, laZ);
|
2189 |
lineString2.add(pointss[j]); |
2190 |
} |
2191 |
|
2192 |
Feature feature3 = new Feature();
|
2193 |
feature3.setProp("layer", feature2.getProp("layer")); |
2194 |
feature3.setProp("color", feature2.getProp("color")); |
2195 |
feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
2196 |
if (feature2.getProp("elevation")!=null) feature3.setProp("elevation", feature2.getProp("elevation")); |
2197 |
feature3.setProp("thickness", feature2.getProp("thickness")); |
2198 |
|
2199 |
//041130
|
2200 |
for (int j=0;j<attributes.size();j++) { |
2201 |
String[] att = new String[2]; |
2202 |
att = (String[])attributes.get(j); |
2203 |
String str = att[0]; |
2204 |
feature3.setProp(str,feature2.getProp(str)); |
2205 |
} |
2206 |
|
2207 |
feature3.setGeometry(lineString2); |
2208 |
|
2209 |
if (addingToBlock == false) { |
2210 |
features.add(feature3); |
2211 |
} |
2212 |
} else if (feature2.getGeometry() instanceof Polygon3D) { |
2213 |
polygon3D = (Polygon3D)feature2.getGeometry(); |
2214 |
Polygon3D polygon2 = new Polygon3D();
|
2215 |
Point3D[] points = new Point3D[polygon3D.pointNr()]; |
2216 |
Point3D[] pointss = new Point3D[polygon3D.pointNr()]; |
2217 |
for (int j=0; j<polygon3D.pointNr(); j++) { |
2218 |
points[j] = (Point3D)polygon3D.get(j); |
2219 |
pointss[j] = new Point3D();
|
2220 |
|
2221 |
pointAux = new Point3D(points[j].getX() - bPointX, points[j].getY() - bPointY, points[j].getZ() - bPointZ);
|
2222 |
double laX = insert.getPoint3D(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
2223 |
double laY = insert.getPoint3D(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
2224 |
double laZ = insert.getPoint3D(0).getZ() + (pointAux.getZ()*sFactorZ); |
2225 |
pointss[j] = new Point3D(laX, laY, laZ);
|
2226 |
polygon2.add(pointss[j]); |
2227 |
} |
2228 |
|
2229 |
Feature feature3 = new Feature();
|
2230 |
feature3.setProp("layer", feature2.getProp("layer")); |
2231 |
feature3.setProp("color", feature2.getProp("color")); |
2232 |
feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
2233 |
if (feature2.getProp("elevation")!=null) feature3.setProp("elevation", feature2.getProp("elevation")); |
2234 |
feature3.setProp("thickness", feature2.getProp("thickness")); |
2235 |
|
2236 |
//041130
|
2237 |
for (int j=0;j<attributes.size();j++) { |
2238 |
String[] att = new String[2]; |
2239 |
att = (String[])attributes.get(j); |
2240 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2241 |
} |
2242 |
|
2243 |
feature3.setGeometry(polygon2); |
2244 |
|
2245 |
if (addingToBlock == false) { |
2246 |
features.add(feature3); |
2247 |
} |
2248 |
} else if (feature2.getGeometry() instanceof org.cresques.px.gml.Point3D) { |
2249 |
point = (org.cresques.px.gml.Point3D)feature2.getGeometry(); |
2250 |
point1 = point.getPoint3D(0);
|
2251 |
|
2252 |
pointAux = new Point3D(point1.getX() - bPointX, point1.getY() - bPointY, point1.getZ() - bPointZ);
|
2253 |
double laX = insert.getPoint3D(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
2254 |
double laY = insert.getPoint3D(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
2255 |
double laZ = insert.getPoint3D(0).getZ() + (pointAux.getZ()*sFactorZ); |
2256 |
point11 = new Point3D(laX, laY, laZ);
|
2257 |
org.cresques.px.gml.Point3D pointt = new org.cresques.px.gml.Point3D();
|
2258 |
pointt.add(point11); |
2259 |
|
2260 |
Feature feature3 = new Feature();
|
2261 |
feature3.setProp("layer", feature2.getProp("layer")); |
2262 |
feature3.setProp("color", feature2.getProp("color")); |
2263 |
feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
2264 |
feature3.setProp("elevation", feature2.getProp("elevation")); |
2265 |
feature3.setProp("thickness", feature2.getProp("thickness")); |
2266 |
if (point.isTextPoint()) {
|
2267 |
feature3.setProp("text", feature2.getProp("text")); |
2268 |
feature3.setProp("textHeight", feature2.getProp("textHeight")); |
2269 |
double auxR = Double.parseDouble(feature2.getProp("textRotation")); |
2270 |
//System.out.println("auxR = " + auxR);
|
2271 |
auxR = auxR + rAngleGra; |
2272 |
feature3.setProp("textRotation", Double.toString(auxR)); |
2273 |
//System.out.println("gestionaInsert(): feature3.getProp(textRotation) = " + feature3.getProp("textRotation"));
|
2274 |
pointt.setTextPoint(true);
|
2275 |
} |
2276 |
|
2277 |
//041130
|
2278 |
for (int j=0;j<attributes.size();j++) { |
2279 |
String[] att = new String[2]; |
2280 |
att = (String[])attributes.get(j); |
2281 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2282 |
} |
2283 |
|
2284 |
feature3.setGeometry(pointt); |
2285 |
|
2286 |
//if (addingToBlock == false) {
|
2287 |
features.add(feature3); |
2288 |
//}
|
2289 |
} else {
|
2290 |
System.out.println("gestionaInsert(): Encontrado elemento desconocido"); |
2291 |
} |
2292 |
} |
2293 |
} |
2294 |
|
2295 |
private void addFace(int [] face) { |
2296 |
hasFaces = true;
|
2297 |
if (faces == null) |
2298 |
faces = new Vector(); |
2299 |
faces.add(face); |
2300 |
} |
2301 |
|
2302 |
/**
|
2303 |
* Quita los atributos repetidos.
|
2304 |
*/
|
2305 |
public void depureAttributes() { |
2306 |
//String[] att = null;
|
2307 |
/*Set conjunto = new HashSet();
|
2308 |
for (int i=0;i<attributes.size();i++) {
|
2309 |
att = (String[])attributes.get(i);
|
2310 |
String str = att[0];
|
2311 |
conjunto.add(str);
|
2312 |
}
|
2313 |
//conjunto.addAll(attributes);
|
2314 |
Vector atts = new Vector();
|
2315 |
Vector atts2 = new Vector();
|
2316 |
atts.addAll(conjunto);
|
2317 |
for (int i=0;i<atts.size();i++) {
|
2318 |
if (((String[])(attributes.get(i)))[0] == atts.get(i)) {
|
2319 |
atts2.add(i, attributes.get(i));
|
2320 |
}
|
2321 |
}*/
|
2322 |
|
2323 |
String[] lastAtt = new String[2]; |
2324 |
for (int i=0;i<attributes.size();i++) { |
2325 |
String[] att = (String[])attributes.get(i); |
2326 |
for (int j=i+1;j<attributes.size();j++) { |
2327 |
//System.out.println("depureAttributes(): j = " + j);
|
2328 |
String[] st = (String[])attributes.get(j); |
2329 |
String st1 = att[0]; |
2330 |
String st2 = st[0]; |
2331 |
//System.out.println("depureAttributes(): st1 = " + st1);
|
2332 |
//System.out.println("depureAttributes(): st2 = " + st2);
|
2333 |
if (st2.equals(st1)) {
|
2334 |
//System.out.println("depureAttributes(): Borra el st2");
|
2335 |
attributes.remove(j); |
2336 |
} |
2337 |
if (i==attributes.size()-1) { |
2338 |
lastAtt = att; |
2339 |
} |
2340 |
} |
2341 |
} |
2342 |
for (int i=attributes.size()-2;i>=0;i--) { |
2343 |
String[] att = (String[])attributes.get(i); |
2344 |
String st1 = lastAtt[0]; |
2345 |
String st2 = att[0]; |
2346 |
if (st2.equals(st1)) {
|
2347 |
attributes.remove(i); |
2348 |
} |
2349 |
} |
2350 |
|
2351 |
/*String[] attStrs = new String[attributes.size()];
|
2352 |
Vector attribs = new Vector();
|
2353 |
for (int i=0;i<attributes.size();i++) {
|
2354 |
att = (String[])attributes.get(i);
|
2355 |
attStrs[i] = att[0];
|
2356 |
}
|
2357 |
Set attStrsNR = new HashSet();
|
2358 |
for (int i=0;i<attStrs.length;i++) {
|
2359 |
attStrsNR.add(attStrs[i]);
|
2360 |
}
|
2361 |
String[] attStrsNRA = new String[attStrsNR.size()];
|
2362 |
attStrsNR.toArray(attStrsNRA);
|
2363 |
for (int i=0;i<attStrsNR.size();i++) {
|
2364 |
att[0] = attStrsNRA[i];
|
2365 |
attribs.add(att);
|
2366 |
}
|
2367 |
for (int i=0;i<attributes.size();i++) {
|
2368 |
att = (String[])attributes.get(i);
|
2369 |
String[] att2 = new String[2];
|
2370 |
for (int j=0;j<attribs.size();j++) {
|
2371 |
att2 = (String[])attribs.get(j);
|
2372 |
if (att[0].equals(att2[0])) {
|
2373 |
att2[1] = att[1];
|
2374 |
}
|
2375 |
attribs.set(j, att2);
|
2376 |
}
|
2377 |
}
|
2378 |
attributes = attribs;*/
|
2379 |
} |
2380 |
|
2381 |
/**
|
2382 |
* Hace los setProp para los atributos extra.
|
2383 |
* @param feature
|
2384 |
*/
|
2385 |
private void completeAttributes(Feature feature) { |
2386 |
// 041130: Rellena las props con los atributos.
|
2387 |
for (int i=0;i<attributes.size();i++) { |
2388 |
String[] att = new String[2]; |
2389 |
att = (String[])attributes.get(i); |
2390 |
feature.setProp(att[0],att[1]); |
2391 |
} |
2392 |
} |
2393 |
|
2394 |
/**
|
2395 |
* Copia los atributos extra cargados en InsPoint y ya perfectamente definidos a los
|
2396 |
* elementos del bloque al que referencia el punto de insercion.
|
2397 |
* @param insert
|
2398 |
*/
|
2399 |
private void copyAttributes(Feature feaInsert) { |
2400 |
Feature feature = null;
|
2401 |
InsPoint3D insert = new InsPoint3D();
|
2402 |
insert = (InsPoint3D)feaInsert.getGeometry(); |
2403 |
for (int i=0; i<insert.getBlock().size(); i++) { |
2404 |
feature = (Feature)insert.getBlock().get(i); |
2405 |
for (int j=0;j<attributes.size();j++) { |
2406 |
String[] att = new String[2]; |
2407 |
att = (String[])attributes.get(j); |
2408 |
feature.setProp(att[0],feaInsert.getProp(att[0])); |
2409 |
} |
2410 |
} |
2411 |
} |
2412 |
|
2413 |
/**
|
2414 |
* Se ejecuta cuando se declaran nuevos atributos, es decir, tras cada ATTDEF.
|
2415 |
* A?ade estos atributos a las features existentes.
|
2416 |
*/
|
2417 |
private void setNewAttributes() { |
2418 |
for (int i=0;i<features.size();i++) { |
2419 |
Feature fea = new Feature();
|
2420 |
fea = (Feature)features.get(i); |
2421 |
completeAttributes(fea); |
2422 |
} |
2423 |
for (int i=0;i<blkList.size();i++) { |
2424 |
FeatureCollection bloque = new FeatureCollection(proj);
|
2425 |
bloque = (FeatureCollection)blkList.get(i); |
2426 |
for (int j=0;j<bloque.size();j++) { |
2427 |
Feature fea = new Feature();
|
2428 |
fea = (Feature)bloque.get(j); |
2429 |
completeAttributes(fea); |
2430 |
} |
2431 |
} |
2432 |
} |
2433 |
|
2434 |
public Vector getAttributes() { |
2435 |
return attributes;
|
2436 |
} |
2437 |
|
2438 |
/* (non-Javadoc)
|
2439 |
* @see org.cresques.io.DxfFile.EntityFactory#getExtent()
|
2440 |
*/
|
2441 |
public Extent getExtent() {
|
2442 |
Feature feature = new Feature();
|
2443 |
Extent extent = new Extent();
|
2444 |
Iterator iter = features.iterator();
|
2445 |
while (iter.hasNext()) {
|
2446 |
feature = (Feature)iter.next(); |
2447 |
extent.add(feature.getExtent()); |
2448 |
} |
2449 |
return extent;
|
2450 |
} |
2451 |
|
2452 |
public void setProjection(IProjection p) { |
2453 |
proj = p; |
2454 |
} |
2455 |
|
2456 |
/* (non-Javadoc)
|
2457 |
* @see org.cresques.io.DxfFile.EntityFactory#reProject(org.cresques.geo.ReProjection)
|
2458 |
*/
|
2459 |
public void reProject(ICoordTrans rp) { |
2460 |
Feature feature = new Feature();
|
2461 |
Extent extent = new Extent();
|
2462 |
Iterator iter = features.iterator();
|
2463 |
while (iter.hasNext()) {
|
2464 |
feature = (Feature)iter.next(); |
2465 |
((Projected) feature).reProject(rp); |
2466 |
extent.add(feature.getExtent()); |
2467 |
} |
2468 |
setProjection(rp.getPDest()); |
2469 |
} |
2470 |
|
2471 |
/* (non-Javadoc)
|
2472 |
* @see org.cresques.geo.Projected#getProjection()
|
2473 |
*/
|
2474 |
public IProjection getProjection() {
|
2475 |
return proj;
|
2476 |
} |
2477 |
|
2478 |
public IObjList getObjects() { return features;} |
2479 |
|
2480 |
public void draw(Graphics2D g, ViewPortData vp) { |
2481 |
Iterator iter = features.iterator();
|
2482 |
Extent extent; |
2483 |
while (iter.hasNext()) {
|
2484 |
Feature feature = new Feature();
|
2485 |
feature = (Feature)iter.next(); |
2486 |
extent = feature.getExtent(); |
2487 |
if (vp.getExtent().minX()> extent.maxX()) continue; |
2488 |
if (vp.getExtent().minY()> extent.maxY()) continue; |
2489 |
if (vp.getExtent().maxX()< extent.minX()) continue; |
2490 |
if (vp.getExtent().maxY()< extent.minY()) continue; |
2491 |
//if (!feature.layer.frozen)
|
2492 |
feature.draw(g, vp); |
2493 |
} |
2494 |
} |
2495 |
|
2496 |
public static Vector createArc(Point2D coord1, Point2D coord2, double bulge) { |
2497 |
return new DxfCalArcs(coord1, coord2, bulge).getPoints(1); |
2498 |
} |
2499 |
|
2500 |
/* (non-Javadoc)
|
2501 |
* @see org.cresques.io.DxfFile.EntityFactory#getBlkList()
|
2502 |
*/
|
2503 |
public Vector getBlkList() { |
2504 |
return blkList;
|
2505 |
} |
2506 |
|
2507 |
/* (non-Javadoc)
|
2508 |
* @see org.cresques.io.DxfFile.EntityFactory#getDxfEntityList()
|
2509 |
*/
|
2510 |
public DxfEntityList getDxfEntityList() {
|
2511 |
// TODO Auto-generated method stub
|
2512 |
return null; |
2513 |
} |
2514 |
|
2515 |
/* (non-Javadoc)
|
2516 |
* @see org.cresques.io.DxfFile.EntityFactory#getBlk()
|
2517 |
*/
|
2518 |
public DxfBlock getBlk() {
|
2519 |
// TODO Auto-generated method stub
|
2520 |
return null; |
2521 |
} |
2522 |
|
2523 |
/* (non-Javadoc)
|
2524 |
* @see org.cresques.io.DxfFile.EntityFactory#createEllipse(org.cresques.io.DxfGroupVector)
|
2525 |
*/
|
2526 |
public void createEllipse(DxfGroupVector v) throws Exception { |
2527 |
// TODO Auto-generated method stub
|
2528 |
|
2529 |
} |
2530 |
|
2531 |
/**
|
2532 |
* @return Returns the dxf3DFile.
|
2533 |
*/
|
2534 |
public boolean isDxf3DFile() { |
2535 |
return dxf3DFile;
|
2536 |
} |
2537 |
/**
|
2538 |
* @param dxf3DFile The dxf3DFile to set.
|
2539 |
*/
|
2540 |
public void setDxf3DFile(boolean dxf3DFile) { |
2541 |
this.dxf3DFile = dxf3DFile;
|
2542 |
} |
2543 |
} |