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