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