Revision 1865
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dwg/DwgMemoryDriver.java | ||
---|---|---|
117 | 117 |
System.out.println("Tiempo empleado en leer el fichero dwg = " + timeElapsed); |
118 | 118 |
dwgObjects = dwg.getDwgObjects(); |
119 | 119 |
|
120 |
/*for (int i=0;i<dwgObjects.size();i++) { |
|
121 |
DwgObject ob = (DwgObject)dwgObjects.get(i); |
|
122 |
int type = ob.getType(); |
|
123 |
if (type==0x0F) { |
|
124 |
DwgObjectSpecificDataItem dataa = ob.getDwgObjectSpecificDataItem("FIRST_VERTEX_HANDLE"); |
|
125 |
int firstHandle = ((Integer)dataa.getValue()).intValue(); |
|
126 |
System.out.println("firstHandle = " + firstHandle); |
|
127 |
for (int j=0;j<dwgObjects.size();j++) { |
|
128 |
DwgObject v = (DwgObject)dwgObjects.get(j); |
|
129 |
int handle = v.getHandle(); |
|
130 |
System.out.println("handle = " + handle); |
|
131 |
if (handle==firstHandle) { |
|
132 |
System.out.println("Encontrado primer vertice! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); |
|
133 |
} |
|
134 |
} |
|
135 |
//DwgObject v = (DwgObject)dwgObjects.get(i+2); |
|
136 |
//System.out.println("v.getType() = " + v.getType()); |
|
137 |
//DwgObjectSpecificDataItem dataa = v.getDwgObjectSpecificDataItem("POINT"); |
|
138 |
//System.out.println("((double[])dataa.getValue())[0] = " + ((double[])dataa.getValue())[0] + "++++++++++++++++++++++++++++++++++"); |
|
139 |
} |
|
140 |
}*/ |
|
141 |
|
|
142 | 120 |
//int nAtt = featureMaker.getAttributes().size(); |
143 | 121 |
|
144 | 122 |
// Campos de las MemoryLayer: |
... | ... | |
174 | 152 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER"); |
175 | 153 |
double[] coord = (double[])data.getValue(); |
176 | 154 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
177 |
//System.out.println("center.getX() = " + center.getX()); |
|
178 |
//System.out.println("center.getY() = " + center.getY()); |
|
179 | 155 |
data = entity.getDwgObjectSpecificDataItem("RADIUS"); |
180 | 156 |
double radius = ((Double)data.getValue()).doubleValue(); |
181 |
//System.out.println("radius = " + radius); |
|
182 | 157 |
data = entity.getDwgObjectSpecificDataItem("START_ANGLE"); |
183 | 158 |
double startAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
184 |
//System.out.println("startAngle = " + startAngle); |
|
185 | 159 |
data = entity.getDwgObjectSpecificDataItem("END_ANGLE"); |
186 | 160 |
double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
187 |
//System.out.println("endAngle = " + endAngle); |
|
188 | 161 |
FPolyline2D arc = createArc(center, radius, startAngle, endAngle); |
189 |
//pto = (Point2D.Double)point.get(0); |
|
190 |
//FShape nuevoShp; |
|
191 | 162 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
192 | 163 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
193 | 164 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
211 | 182 |
data = entity.getDwgObjectSpecificDataItem("RADIUS"); |
212 | 183 |
double radius = ((Double)data.getValue()).doubleValue(); |
213 | 184 |
FPolyline2D circle = createCircle(center, radius); |
214 |
//pto = (Point2D.Double)point.get(0); |
|
215 |
//FShape nuevoShp; |
|
216 | 185 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
217 | 186 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
218 | 187 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
237 | 206 |
coord = (double[])data.getValue(); |
238 | 207 |
Point2D p2 = new Point2D.Double(coord[0], coord[1]); |
239 | 208 |
FPolyline2D line = createLine(p1, p2); |
240 |
//pto = (Point2D.Double)point.get(0); |
|
241 |
//FShape nuevoShp; |
|
242 | 209 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
243 | 210 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
244 | 211 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
260 | 227 |
double[] coord = (double[])data.getValue(); |
261 | 228 |
Point2D p = new Point2D.Double(coord[0], coord[1]); |
262 | 229 |
FPoint2D point = createPoint(p); |
263 |
//pto = (Point2D.Double)point.get(0); |
|
264 |
//FShape nuevoShp; |
|
265 | 230 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
266 | 231 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
267 | 232 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
289 | 254 |
if (firstVertexHandle.length>4) firstHandleBytes[1] = (byte)firstVertexHandle[4]; |
290 | 255 |
if (firstVertexHandle.length>5) firstHandleBytes[0] = (byte)firstVertexHandle[5]; |
291 | 256 |
int firstHandle = ByteUtils.bytesToInt(firstHandleBytes, new int[]{0}); |
292 |
//System.out.println("firstHandle = " + firstHandle); |
|
293 |
/*System.out.println("firstVertexHandle[0] = " + firstVertexHandle[0]); |
|
294 |
System.out.println("firstVertexHandle[1] = " + firstVertexHandle[1]); |
|
295 |
if (firstVertexHandle.length>2) System.out.println("firstVertexHandle[2] = " + firstVertexHandle[2]); |
|
296 |
if (firstVertexHandle.length>3) System.out.println("firstVertexHandle[3] = " + firstVertexHandle[3]); |
|
297 |
if (firstVertexHandle.length>4) System.out.println("firstVertexHandle[4] = " + firstVertexHandle[4]);*/ |
|
298 | 257 |
data = entity.getDwgObjectSpecificDataItem("LAST_VERTEX_HANDLE"); |
299 | 258 |
int[] lastVertexHandle = (int[])data.getValue(); |
300 | 259 |
byte[] lastHandleBytes = new byte[]{0,0,0,0}; |
... | ... | |
303 | 262 |
if (lastVertexHandle.length>4) lastHandleBytes[1] = (byte)lastVertexHandle[4]; |
304 | 263 |
if (lastVertexHandle.length>5) lastHandleBytes[0] = (byte)lastVertexHandle[5]; |
305 | 264 |
int lastHandle = ByteUtils.bytesToInt(lastHandleBytes, new int[]{0}); |
306 |
//System.out.println("lastHandle = " + lastHandle); |
|
307 |
/*System.out.println("lastVertexHandle[0] = " + lastVertexHandle[0]); |
|
308 |
System.out.println("lastVertexHandle[1] = " + lastVertexHandle[1]); |
|
309 |
if (lastVertexHandle.length>2) System.out.println("lastVertexHandle[2] = " + lastVertexHandle[2]); |
|
310 |
if (lastVertexHandle.length>3) System.out.println("lastVertexHandle[3] = " + lastVertexHandle[3]); |
|
311 |
if (lastVertexHandle.length>4) System.out.println("lastVertexHandle[4] = " + lastVertexHandle[4]);*/ |
|
312 |
data = entity.getDwgObjectSpecificDataItem("SEQEND_HANDLE"); |
|
313 |
int[] seqendHandle = (int[])data.getValue(); |
|
314 |
//int vertexNumber = (lastVertexHandle-firstVertexHandle)+1; |
|
315 |
//int vertexNumber = calculateVertexNumber(firstVertexHandle, lastVertexHandle); |
|
316 |
//int vertexNumber = lastHandle - firstHandle + 1; |
|
317 |
//System.out.println("vertexNumber = " + vertexNumber); |
|
318 |
//Point2D[] pts = new Point2D[vertexNumber]; |
|
319 | 265 |
Vector pts = new Vector(); |
320 |
//Vector pts = new Vector(); |
|
321 | 266 |
double[] pt = new double[2]; |
322 | 267 |
|
323 |
// Buscando el primer v?rtice ... |
|
324 |
/*for (int j=0;j<dwgObjects.size();j++) { |
|
325 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
|
326 |
Vector handle = obj.getHandle(); |
|
327 |
if (handle.size()==firstVertexHandle.length) { |
|
328 |
if (((Integer)handle.get(handle.size()-2)).intValue()==firstVertexHandle[handle.size()-2] && ((Integer)handle.get(handle.size()-1)).intValue()==firstVertexHandle[handle.size()-1]) { |
|
329 |
for (int k=0; k<vertexNumber; k++) { |
|
330 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
331 |
data = vertex.getDwgObjectSpecificDataItem("POINT"); |
|
332 |
pt = (double[])data.getValue(); |
|
333 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
|
334 |
}*/ |
|
335 |
/*int cnt = 0; |
|
336 |
while (true) { |
|
337 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+cnt); |
|
338 |
Vector vHandle = vertex.getHandle(); |
|
339 |
data = vertex.getDwgObjectSpecificDataItem("POINT"); |
|
340 |
pt = (double[])data.getValue(); |
|
341 |
pts.add(new Point2D.Double(pt[0], pt[1])); |
|
342 |
if (((Integer)handle.get(handle.size()-2)).intValue()==firstVertexHandle[handle.size()-2] && ((Integer)handle.get(handle.size()-1)).intValue()==firstVertexHandle[handle.size()-1]) { |
|
343 |
break; |
|
344 |
} |
|
345 |
cnt++; |
|
346 |
}*/ |
|
347 |
/*} |
|
348 |
} |
|
349 |
}*/ |
|
350 |
/*for (int j=0;j<dwgObjects.size();j++) { |
|
351 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
|
352 |
Vector handle = obj.getHandle(); |
|
353 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
|
354 |
if (handle.size()>2) handleBytes[3] = ((Integer)handle.get(2)).byteValue(); |
|
355 |
if (handle.size()>3) handleBytes[2] = ((Integer)handle.get(3)).byteValue(); |
|
356 |
if (handle.size()>4) handleBytes[1] = ((Integer)handle.get(4)).byteValue(); |
|
357 |
if (handle.size()>5) handleBytes[0] = ((Integer)handle.get(5)).byteValue(); |
|
358 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
|
359 |
if (objHandle==firstHandle) { |
|
360 |
System.out.println("firstHandle = " + firstHandle + "*****************************"); |
|
361 |
System.out.println("firstVertexHandle[0] = " + firstVertexHandle[0]); |
|
362 |
System.out.println("firstVertexHandle[1] = " + firstVertexHandle[1]); |
|
363 |
if (firstVertexHandle.length>2) System.out.println("firstVertexHandle[2] = " + firstVertexHandle[2]); |
|
364 |
if (firstVertexHandle.length>3) System.out.println("firstVertexHandle[3] = " + firstVertexHandle[3]); |
|
365 |
System.out.println("objHandle = " + objHandle + "*****************************"); |
|
366 |
System.out.println("handle.get(0) = " + handle.get(0)); |
|
367 |
System.out.println("handle.get(1) = " + handle.get(1)); |
|
368 |
if (handle.size()>2) System.out.println("handle.get(2) = " + handle.get(2)); |
|
369 |
if (handle.size()>3) System.out.println("handle.get(3) = " + handle.get(3)); |
|
370 |
} |
|
371 |
}*/ |
|
372 | 268 |
for (int j=0;j<dwgObjects.size();j++) { |
373 | 269 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
374 | 270 |
Vector handle = obj.getHandle(); |
375 |
//System.out.println("handleInts[0] = " + handleInts[0]); |
|
376 |
//System.out.println("handleInts[1] = " + handleInts[1]); |
|
377 |
//if (handle.size()>2) System.out.println("handleInts[2] = " + handleInts[2]); |
|
378 |
//if (handle.size()>3) System.out.println("handleInts[3] = " + handleInts[3]); |
|
379 | 271 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
380 | 272 |
if (handle.size()>2) handleBytes[3] = ((Integer)handle.get(2)).byteValue(); |
381 | 273 |
if (handle.size()>3) handleBytes[2] = ((Integer)handle.get(3)).byteValue(); |
382 | 274 |
if (handle.size()>4) handleBytes[1] = ((Integer)handle.get(4)).byteValue(); |
383 | 275 |
if (handle.size()>5) handleBytes[0] = ((Integer)handle.get(5)).byteValue(); |
384 | 276 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
385 |
//System.out.println("objHandle = " + objHandle); |
|
386 | 277 |
if (objHandle==firstHandle && ((Integer)handle.get(1)).intValue()==firstVertexHandle[1]) { |
387 |
/*for (int k=0; k<vertexNumber; k++) { |
|
388 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
389 |
data = vertex.getDwgObjectSpecificDataItem("POINT"); |
|
390 |
pt = (double[])data.getValue(); |
|
391 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
|
392 |
}*/ |
|
393 | 278 |
int k=0; |
394 |
/*System.out.println("firstHandle = " + firstHandle + "*****************************"); |
|
395 |
System.out.println("firstVertexHandle[0] = " + firstVertexHandle[0]); |
|
396 |
System.out.println("firstVertexHandle[1] = " + firstVertexHandle[1]); |
|
397 |
if (firstVertexHandle.length>2) System.out.println("firstVertexHandle[2] = " + firstVertexHandle[2]); |
|
398 |
if (firstVertexHandle.length>3) System.out.println("firstVertexHandle[3] = " + firstVertexHandle[3]); |
|
399 |
System.out.println("objHandle = " + objHandle + "*****************************"); |
|
400 |
System.out.println("handle.get(0) = " + handle.get(0)); |
|
401 |
System.out.println("handle.get(1) = " + handle.get(1)); |
|
402 |
if (handle.size()>2) System.out.println("handle.get(2) = " + handle.get(2)); |
|
403 |
if (handle.size()>3) System.out.println("handle.get(3) = " + handle.get(3));*/ |
|
404 | 279 |
while (true) { |
405 | 280 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
406 | 281 |
Vector vertexHandle = vertex.getHandle(); |
... | ... | |
421 | 296 |
} |
422 | 297 |
} |
423 | 298 |
|
424 |
//Point2D[] newPts = new Point2D[pts.length]; |
|
425 | 299 |
Point2D[] newPts = new Point2D[pts.size()]; |
426 | 300 |
if (flags==0 || flags==2 || flags==4 || flags==8 || flags==16 || flags==32 || flags==64 || flags==128) { |
427 |
//newPts = pts; |
|
428 | 301 |
for (int j=0;j<pts.size();j++) { |
429 | 302 |
newPts[j] = (Point2D)pts.get(j); |
430 | 303 |
} |
431 | 304 |
} else if (flags==1 || flags==3 || flags==5 || flags==9 || flags==17 || flags==33 || flags==65 || flags==129) { |
432 |
//newPts = new Point2D[pts.length+1]; |
|
433 | 305 |
newPts = new Point2D[pts.size()+1]; |
434 |
/*for (int j=0;j<pts.length;j++) { |
|
435 |
newPts[j] = pts[j]; |
|
436 |
}*/ |
|
437 | 306 |
for (int j=0;j<pts.size();j++) { |
438 | 307 |
newPts[j] = (Point2D)pts.get(j); |
439 | 308 |
} |
440 |
//newPts[pts.length] = pts[0]; |
|
441 | 309 |
newPts[pts.size()] = (Point2D)pts.get(0); |
442 | 310 |
} |
443 | 311 |
FPolyline2D pline = createPolyline2D(newPts); |
444 |
//pto = (Point2D.Double)point.get(0); |
|
445 |
//FShape nuevoShp; |
|
446 | 312 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
447 | 313 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
448 | 314 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
468 | 334 |
int[] lastVertexHandle = (int[])data.getValue(); |
469 | 335 |
data = entity.getDwgObjectSpecificDataItem("SEQEND_HANDLE"); |
470 | 336 |
int[] seqendHandle = (int[])data.getValue(); |
471 |
//int vertexNumber = (lastVertexHandle-firstVertexHandle)+1; |
|
472 | 337 |
int vertexNumber = calculateVertexNumber(firstVertexHandle, lastVertexHandle); |
473 | 338 |
Point2D[] pts = new Point2D[vertexNumber]; |
474 | 339 |
double[] pt = new double[2]; |
475 | 340 |
|
476 |
// Buscando el primer v?rtice ... |
|
477 | 341 |
for (int j=0;j<dwgObjects.size();j++) { |
478 | 342 |
DwgObject v = (DwgObject)dwgObjects.get(j); |
479 | 343 |
Vector handle = v.getHandle(); |
... | ... | |
485 | 349 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
486 | 350 |
} |
487 | 351 |
} |
488 |
/*if (handle.size()==4) { |
|
489 |
if (((Integer)handle.get(2)).intValue()==firstVertexHandle[2] && ((Integer)handle.get(3)).intValue()==firstVertexHandle[3]) { |
|
490 |
for (int k=0; k<vertexNumber; k++) { |
|
491 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
492 |
data = vertex.getDwgObjectSpecificDataItem("POINT"); |
|
493 |
pt = (double[])data.getValue(); |
|
494 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
|
495 |
} |
|
496 |
} |
|
497 |
} else if (handle.size()==3) { |
|
498 |
if (((Integer)handle.get(2)).intValue()==firstVertexHandle[2]) { |
|
499 |
for (int k=0; k<vertexNumber; k++) { |
|
500 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
501 |
data = vertex.getDwgObjectSpecificDataItem("POINT"); |
|
502 |
pt = (double[])data.getValue(); |
|
503 |
pts[k] = new Point2D.Double(pt[0], pt[1]); |
|
504 |
} |
|
505 |
} |
|
506 |
}*/ |
|
507 | 352 |
} |
508 | 353 |
Point2D[] newPts = new Point2D[pts.length]; |
509 | 354 |
if (flags==0 || flags==2 || flags==4 || flags==8 || flags==16 || flags==32 || flags==64 || flags==128) { |
... | ... | |
516 | 361 |
newPts[pts.length] = pts[0]; |
517 | 362 |
} |
518 | 363 |
FPolyline2D pline3d = createPolyline2D(newPts); |
519 |
//pto = (Point2D.Double)point.get(0); |
|
520 |
//FShape nuevoShp; |
|
521 | 364 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
522 | 365 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
523 | 366 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
538 | 381 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT"); |
539 | 382 |
Point2D p = (Point2D)data.getValue(); |
540 | 383 |
FPoint2D point = createPoint(p); |
541 |
//pto = (Point2D.Double)point.get(0); |
|
542 |
//FShape nuevoShp; |
|
543 | 384 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
544 | 385 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
545 | 386 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
557 | 398 |
}*/ |
558 | 399 |
addShape(point, auxRow); |
559 | 400 |
} else if (entity.getType()==0x4) { |
560 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("NAME"); |
|
561 |
String blockName = (String)data.getValue(); |
|
401 |
//DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("NAME");
|
|
402 |
//String blockName = (String)data.getValue();
|
|
562 | 403 |
//addingToBlock = true; |
563 | 404 |
//pto = (Point2D.Double)point.get(0); |
564 | 405 |
//FShape nuevoShp; |
... | ... | |
598 | 439 |
} |
599 | 440 |
}*/ |
600 | 441 |
//addShape(point, auxRow); |
601 |
/*} else if (entity.getType()==0x30) {
|
|
442 |
} else if (entity.getType()==0x30) { |
|
602 | 443 |
//addingToBlock = false; |
603 | 444 |
//pto = (Point2D.Double)point.get(0); |
604 | 445 |
//FShape nuevoShp; |
... | ... | |
607 | 448 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
608 | 449 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
609 | 450 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0); |
610 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
|
|
451 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0); |
|
611 | 452 |
// Attributes |
612 | 453 |
/*for (int j=0;j<nAtt;j++) { |
613 | 454 |
String[] attributes = new String[2]; |
... | ... | |
618 | 459 |
} |
619 | 460 |
}*/ |
620 | 461 |
//addShape(point, auxRow); |
621 |
/*} else if (entity.getType()==0x31) {
|
|
462 |
} else if (entity.getType()==0x31) { |
|
622 | 463 |
//addingToBlock = false; |
623 | 464 |
//pto = (Point2D.Double)point.get(0); |
624 | 465 |
//FShape nuevoShp; |
... | ... | |
627 | 468 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
628 | 469 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
629 | 470 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0); |
630 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
|
|
471 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0); |
|
631 | 472 |
// Attributes |
632 | 473 |
/*for (int j=0;j<nAtt;j++) { |
633 | 474 |
String[] attributes = new String[2]; |
... | ... | |
638 | 479 |
} |
639 | 480 |
}*/ |
640 | 481 |
//addShape(point, auxRow); |
641 |
/*} else if (entity.getType()==0x7) {
|
|
482 |
} else if (entity.getType()==0x7) { |
|
642 | 483 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT"); |
643 |
Point2D p = (Point2D)data.getValue(); |
|
644 |
FPoint2D point = createPoint(p); |
|
645 |
//pto = (Point2D.Double)point.get(0); |
|
646 |
//FShape nuevoShp; |
|
647 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
484 |
double[] p = (double[])data.getValue(); |
|
485 |
Point2D point = new Point2D.Double(p[0], p[1]); |
|
486 |
data = entity.getDwgObjectSpecificDataItem("SCALE"); |
|
487 |
double[] scale = (double[])data.getValue(); |
|
488 |
data = entity.getDwgObjectSpecificDataItem("ROTATION"); |
|
489 |
double rot = ((Double)data.getValue()).doubleValue(); |
|
490 |
data = entity.getDwgObjectSpecificDataItem("BLOCK_HEADER_HANDLE"); |
|
491 |
int[] blockHandle = (int[])data.getValue(); |
|
492 |
byte[] blockHandleBytes = new byte[]{0,0,0,0}; |
|
493 |
if (blockHandle.length>2) blockHandleBytes[3] = (byte)blockHandle[2]; |
|
494 |
if (blockHandle.length>3) blockHandleBytes[2] = (byte)blockHandle[3]; |
|
495 |
if (blockHandle.length>4) blockHandleBytes[1] = (byte)blockHandle[4]; |
|
496 |
if (blockHandle.length>5) blockHandleBytes[0] = (byte)blockHandle[5]; |
|
497 |
int bHandle = ByteUtils.bytesToInt(blockHandleBytes, new int[]{0}); |
|
498 |
|
|
499 |
for (int j=0;j<dwgObjects.size();j++) { |
|
500 |
DwgObject obj = (DwgObject)dwgObjects.get(j); |
|
501 |
Vector handle = obj.getHandle(); |
|
502 |
byte[] handleBytes = new byte[]{0,0,0,0}; |
|
503 |
if (handle.size()>2) handleBytes[3] = ((Integer)handle.get(2)).byteValue(); |
|
504 |
if (handle.size()>3) handleBytes[2] = ((Integer)handle.get(3)).byteValue(); |
|
505 |
if (handle.size()>4) handleBytes[1] = ((Integer)handle.get(4)).byteValue(); |
|
506 |
if (handle.size()>5) handleBytes[0] = ((Integer)handle.get(5)).byteValue(); |
|
507 |
int objHandle = ByteUtils.bytesToInt(handleBytes, new int[]{0}); |
|
508 |
if (objHandle==bHandle && ((Integer)handle.get(1)).intValue()==blockHandle[1]) { |
|
509 |
|
|
510 |
data = entity.getDwgObjectSpecificDataItem("BASE_POINT"); |
|
511 |
double[] bPoint = (double[])data.getValue(); |
|
512 |
data = entity.getDwgObjectSpecificDataItem("FIRST_ENTITY_HANDLE"); |
|
513 |
int[] firstEntityHandle = (int[])data.getValue(); |
|
514 |
byte[] firstEntityBytes = new byte[]{0,0,0,0}; |
|
515 |
if (firstEntityHandle.length>2) firstEntityBytes[3] = (byte)firstEntityHandle[2]; |
|
516 |
if (firstEntityHandle.length>3) firstEntityBytes[2] = (byte)firstEntityHandle[3]; |
|
517 |
if (firstEntityHandle.length>4) firstEntityBytes[1] = (byte)firstEntityHandle[4]; |
|
518 |
if (firstEntityHandle.length>5) firstEntityBytes[0] = (byte)firstEntityHandle[5]; |
|
519 |
int firstHandle = ByteUtils.bytesToInt(firstEntityBytes, new int[]{0}); |
|
520 |
data = entity.getDwgObjectSpecificDataItem("LAST_ENTITY_HANDLE"); |
|
521 |
int[] lastEntityHandle = (int[])data.getValue(); |
|
522 |
byte[] lastEntityBytes = new byte[]{0,0,0,0}; |
|
523 |
if (lastEntityHandle.length>2) lastEntityBytes[3] = (byte)lastEntityHandle[2]; |
|
524 |
if (lastEntityHandle.length>3) lastEntityBytes[2] = (byte)lastEntityHandle[3]; |
|
525 |
if (lastEntityHandle.length>4) lastEntityBytes[1] = (byte)lastEntityHandle[4]; |
|
526 |
if (lastEntityHandle.length>5) lastEntityBytes[0] = (byte)lastEntityHandle[5]; |
|
527 |
int lastHandle = ByteUtils.bytesToInt(lastEntityBytes, new int[]{0}); |
|
528 |
|
|
529 |
for (int k=0;k<dwgObjects.size();k++) { |
|
530 |
DwgObject ent = (DwgObject)dwgObjects.get(k); |
|
531 |
Vector entHandle = ent.getHandle(); |
|
532 |
byte[] entHandleBytes = new byte[]{0,0,0,0}; |
|
533 |
if (entHandle.size()>2) entHandleBytes[3] = ((Integer)entHandle.get(2)).byteValue(); |
|
534 |
if (entHandle.size()>3) entHandleBytes[2] = ((Integer)entHandle.get(3)).byteValue(); |
|
535 |
if (entHandle.size()>4) entHandleBytes[1] = ((Integer)entHandle.get(4)).byteValue(); |
|
536 |
if (entHandle.size()>5) entHandleBytes[0] = ((Integer)entHandle.get(5)).byteValue(); |
|
537 |
int eHandle = ByteUtils.bytesToInt(entHandleBytes, new int[]{0}); |
|
538 |
if (eHandle==firstHandle && ((Integer)entHandle.get(1)).intValue()==firstEntityHandle[1]) { |
|
539 |
int l=0; |
|
540 |
while (true) { |
|
541 |
DwgObject blockEntity = (DwgObject)dwgObjects.get(k+l); |
|
542 |
Vector blockEntityHandle = blockEntity.getHandle(); |
|
543 |
byte[] blockEntityHandleBytes = new byte[]{0,0,0,0}; |
|
544 |
if (blockEntityHandle.size()>2) blockEntityHandleBytes[3] = ((Integer)blockEntityHandle.get(2)).byteValue(); |
|
545 |
if (blockEntityHandle.size()>3) blockEntityHandleBytes[2] = ((Integer)blockEntityHandle.get(3)).byteValue(); |
|
546 |
if (blockEntityHandle.size()>4) blockEntityHandleBytes[1] = ((Integer)blockEntityHandle.get(4)).byteValue(); |
|
547 |
if (blockEntityHandle.size()>5) blockEntityHandleBytes[0] = ((Integer)blockEntityHandle.get(5)).byteValue(); |
|
548 |
int bEntityHandle = ByteUtils.bytesToInt(blockEntityHandleBytes, new int[]{0}); |
|
549 |
manageBlockEntity(blockEntity, bPoint, point, scale, rot, auxRow); |
|
550 |
l++; |
|
551 |
if (bEntityHandle==lastHandle && ((Integer)entHandle.get(1)).intValue()==lastEntityHandle[1]) { |
|
552 |
break; |
|
553 |
} |
|
554 |
} |
|
555 |
} |
|
556 |
} |
|
557 |
} |
|
558 |
} |
|
559 |
|
|
560 |
/*auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
|
648 | 561 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
649 | 562 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
650 | 563 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
... | ... | |
665 | 578 |
double[] coord = (double[])data.getValue(); |
666 | 579 |
Point2D p = new Point2D.Double(coord[0], coord[1]); |
667 | 580 |
FPoint2D point = createPoint(p); |
668 |
//pto = (Point2D.Double)point.get(0); |
|
669 |
//FShape nuevoShp; |
|
670 | 581 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
671 | 582 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
672 | 583 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
696 | 607 |
data = entity.getDwgObjectSpecificDataItem("CORNER4"); |
697 | 608 |
coord = (double[])data.getValue(); |
698 | 609 |
Point2D p4 = new Point2D.Double(coord[0], coord[1]); |
699 |
//FPolygon2D solid = createSolid(new Point2D[]{p1, p2, p3, p4}); |
|
700 | 610 |
FPolygon2D solid = createSolid(new Point2D[]{p1, p2, p4, p3}); |
701 |
//FPolyline2D solid = createLwPolyline(new Point2D[]{p1, p2, p3, p4, p1}); |
|
702 |
//pto = (Point2D.Double)point.get(0); |
|
703 |
//FShape nuevoShp; |
|
704 | 611 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
705 | 612 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
706 | 613 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
733 | 640 |
pts[j] = new Point2D.Double(pt[0], pt[1]); |
734 | 641 |
} |
735 | 642 |
FPolyline2D spline = createLwPolyline(pts); |
736 |
//pto = (Point2D.Double)point.get(0); |
|
737 |
//FShape nuevoShp; |
|
738 | 643 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
739 | 644 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
740 | 645 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
770 | 675 |
pts[j] = new Point2D.Double(pt[0], pt[1]); |
771 | 676 |
} |
772 | 677 |
FPolyline2D lwpline = createLwPolyline(pts); |
773 |
//pto = (Point2D.Double)point.get(0); |
|
774 |
//FShape nuevoShp; |
|
775 | 678 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
776 | 679 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
777 | 680 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
... | ... | |
977 | 880 |
} |
978 | 881 |
|
979 | 882 |
private int calculateVertexNumber(int[] firstVertexHandle, int[] lastVertexHandle) { |
980 |
/*System.out.println("firstVertexHandle[0]" + firstVertexHandle[0]); |
|
981 |
System.out.println("firstVertexHandle[1]" + firstVertexHandle[1]); |
|
982 |
System.out.println("firstVertexHandle[2]" + firstVertexHandle[2]); |
|
983 |
System.out.println("firstVertexHandle[3]" + firstVertexHandle[3]); |
|
984 |
System.out.println("lastVertexHandle[0]" + lastVertexHandle[0]); |
|
985 |
System.out.println("lastVertexHandle[1]" + lastVertexHandle[1]); |
|
986 |
System.out.println("lastVertexHandle[2]" + lastVertexHandle[2]); |
|
987 |
System.out.println("lastVertexHandle[3]" + lastVertexHandle[3]);*/ |
|
988 | 883 |
if (firstVertexHandle.length==lastVertexHandle.length) { |
989 | 884 |
if (firstVertexHandle[firstVertexHandle.length-2]==lastVertexHandle[firstVertexHandle.length-2]) { |
990 | 885 |
return (lastVertexHandle[firstVertexHandle.length-1]-firstVertexHandle[firstVertexHandle.length-1]+1); |
... | ... | |
1005 | 900 |
System.out.println("ERROR: firstVertexHandle y lastVertexHandle tienen tama?os inesperados"); |
1006 | 901 |
return 0; |
1007 | 902 |
} |
1008 |
/*if (firstVertexHandle.length==3 && lastVertexHandle.length==3) { |
|
1009 |
return (lastVertexHandle[2]-firstVertexHandle[2]+1); |
|
1010 |
} else if (firstVertexHandle.length==4 && lastVertexHandle.length==4) { |
|
1011 |
if (firstVertexHandle[2]==lastVertexHandle[2]) { |
|
1012 |
return (lastVertexHandle[3]-firstVertexHandle[3]+1); |
|
1013 |
} else { |
|
1014 |
int vn = 0; |
|
1015 |
int aux = 255-firstVertexHandle[3]+1; |
|
1016 |
int aux2 = lastVertexHandle[3]+1; |
|
1017 |
int aux3 = (lastVertexHandle[2]-firstVertexHandle[2]-1)*255; |
|
1018 |
vn = aux + aux2 + aux3; |
|
1019 |
return vn; |
|
1020 |
} |
|
1021 |
} else if (firstVertexHandle.length==3 && lastVertexHandle.length==4) { |
|
1022 |
int vn = 0; |
|
1023 |
int aux = 255-firstVertexHandle[2]+1; |
|
1024 |
int aux2 = lastVertexHandle[3]+1; |
|
1025 |
vn = aux + aux2; |
|
1026 |
//System.out.println("vn = " + vn); |
|
1027 |
return vn; |
|
1028 |
} else { |
|
1029 |
System.out.println("ERROR: firstVertexHandle y lastVertexHandle tienen tama?os inesperados"); |
|
1030 |
return 0; |
|
1031 |
}*/ |
|
1032 | 903 |
} |
904 |
|
|
905 |
private void manageBlockEntity(DwgObject entity, double[] bPoint, Point2D insPoint, double[] scale, double rot, Value[] auxRow) { |
|
906 |
if (entity.getType()==0x11) { |
|
907 |
/*DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER"); |
|
908 |
double[] coord = (double[])data.getValue(); |
|
909 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
|
910 |
data = entity.getDwgObjectSpecificDataItem("RADIUS"); |
|
911 |
double radius = ((Double)data.getValue()).doubleValue(); |
|
912 |
data = entity.getDwgObjectSpecificDataItem("START_ANGLE"); |
|
913 |
double startAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
|
914 |
data = entity.getDwgObjectSpecificDataItem("END_ANGLE"); |
|
915 |
double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue()); |
|
916 |
FPolyline2D arc = createArc(center, radius, startAngle, endAngle); |
|
917 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(0); |
|
918 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
|
919 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
|
920 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
|
921 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0); |
|
922 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/ |
|
923 |
// Attributes |
|
924 |
/*for (int j=0;j<nAtt;j++) { |
|
925 |
String[] attributes = new String[2]; |
|
926 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
927 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
928 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
929 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
930 |
} |
|
931 |
}*/ |
|
932 |
//addShape(arc, auxRow); |
|
933 |
} else if (entity.getType()==0x12) { |
|
934 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER"); |
|
935 |
double[] coord = (double[])data.getValue(); |
|
936 |
Point2D center = new Point2D.Double(coord[0], coord[1]); |
|
937 |
data = entity.getDwgObjectSpecificDataItem("RADIUS"); |
|
938 |
double radius = ((Double)data.getValue()).doubleValue(); |
|
939 |
|
|
940 |
Point2D pointAux = new Point2D.Double(center.getX() - bPoint[0], center.getY() - bPoint[1]); |
|
941 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*(-1)*Math.sin(Math.toRadians(rot))); |
|
942 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*Math.cos(Math.toRadians(rot))); |
|
943 |
center = new Point2D.Double(laX, laY); |
|
944 |
// Escala en X = escala en Y ... |
|
945 |
radius = radius * scale[0]; |
|
946 |
|
|
947 |
FPolyline2D circle = createCircle(center, radius); |
|
948 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(0); |
|
949 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
|
950 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
|
951 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
|
952 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0); |
|
953 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0); |
|
954 |
// Attributes |
|
955 |
/*for (int j=0;j<nAtt;j++) { |
|
956 |
String[] attributes = new String[2]; |
|
957 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
958 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
959 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
960 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
961 |
} |
|
962 |
}*/ |
|
963 |
addShape(circle, auxRow); |
|
964 |
} else if (entity.getType()==0x13) { |
|
965 |
DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("P1"); |
|
966 |
double[] coord = (double[])data.getValue(); |
|
967 |
Point2D p1 = new Point2D.Double(coord[0], coord[1]); |
|
968 |
data = entity.getDwgObjectSpecificDataItem("P2"); |
|
969 |
coord = (double[])data.getValue(); |
|
970 |
Point2D p2 = new Point2D.Double(coord[0], coord[1]); |
|
971 |
|
|
972 |
Point2D pointAux = new Point2D.Double(p1.getX() - bPoint[0], p1.getY() - bPoint[1]); |
|
973 |
double laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*(-1)*Math.sin(Math.toRadians(rot))); |
|
974 |
double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*Math.cos(Math.toRadians(rot))); |
|
975 |
p1 = new Point2D.Double(laX, laY); |
|
976 |
pointAux = new Point2D.Double(p2.getX() - bPoint[0], p2.getY() - bPoint[1]); |
|
977 |
laX = insPoint.getX() + ((pointAux.getX()*scale[0])*Math.cos(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*(-1)*Math.sin(Math.toRadians(rot))); |
|
978 |
laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(Math.toRadians(rot)) + (pointAux.getY()*scale[1])*Math.cos(Math.toRadians(rot))); |
|
979 |
p2 = new Point2D.Double(laX, laY); |
|
980 |
|
|
981 |
FPolyline2D line = createLine(p1, p2); |
|
982 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(0); |
|
983 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity")); |
|
984 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer")); |
|
985 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0); |
|
986 |
auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0); |
|
987 |
auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0); |
|
988 |
// Attributes |
|
989 |
/*for (int j=0;j<nAtt;j++) { |
|
990 |
String[] attributes = new String[2]; |
|
991 |
attributes = (String[])featureMaker.getAttributes().get(j); |
|
992 |
auxRow[9+j] = ValueFactory.createValue(new String((String)attributes[1])); |
|
993 |
if (!fea.getProp(attributes[0]).equals(attributes[1])) { |
|
994 |
auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0]))); |
|
995 |
} |
|
996 |
}*/ |
|
997 |
addShape(line, auxRow); |
|
998 |
} |
|
999 |
} |
|
1033 | 1000 |
|
1034 | 1001 |
/* (non-Javadoc) |
1035 | 1002 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File) |
Also available in: Unified diff