Revision 10537
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/DwgFileV12Reader.java | ||
---|---|---|
73 | 73 |
* DWG 13 and DWG 12 are very different formats (nor do DWG 13-14 and 2000). |
74 | 74 |
* Thats the reason why this IDwgFileReader is very different from the rest. |
75 | 75 |
* |
76 |
* http://www.iwriteiam.nl/DWG12.html |
|
76 |
* Documentation of reverse engineering of the format: |
|
77 |
* http://www.iwriteiam.nl/DWG12.html |
|
77 | 78 |
* |
78 | 79 |
* @author azabala |
79 | 80 |
* |
... | ... | |
193 | 194 |
bb.position(bb.position() + 6); |
194 | 195 |
|
195 | 196 |
Dwg12Table dimStyleTable = getTable(); |
196 |
bb.position(0x69); |
|
197 |
bb.position(0x69f); |
|
198 |
|
|
197 | 199 |
Dwg12Table p13table = getTable(); |
198 | 200 |
|
199 | 201 |
bb.position(bb.position() + 38); |
200 | 202 |
|
201 | 203 |
int currentPosition = bb.position(); |
202 |
// if(currentPosition != eStart){
|
|
203 |
// //Se supone que deber?amos estar en eStart
|
|
204 |
// throw new RuntimeException("Error: no se ha llegado al principio de las entidades de dibujo");
|
|
205 |
// }
|
|
204 |
if(currentPosition != eStart){ |
|
205 |
//Se supone que deber?amos estar en eStart |
|
206 |
throw new RuntimeException("Error: no se ha llegado al principio de las entidades de dibujo"); |
|
207 |
} |
|
206 | 208 |
|
207 | 209 |
//lee primero entidades normales? |
208 | 210 |
readEntities(eStart, eEnd); |
... | ... | |
867 | 869 |
byte b73 = bb.get(); |
868 | 870 |
txt.setValign(b73); |
869 | 871 |
} |
872 |
|
|
873 |
//TODO La especificaci?n DXF 12 dice que la extrusion |
|
874 |
//codigos DXF 210, 220, 230 se aplica sobre: |
|
875 |
/* |
|
876 |
Line, Point, Circle, Shape, Text, Arc, Trace, |
|
877 |
Solid, Block Reference, Polyline, |
|
878 |
Dimension, Attribute, and Attribute Definition entity |
|
879 |
|
|
880 |
Pero aqu? no aparece por ningun lado la extrusion |
|
881 |
* */ |
|
882 |
double[] ext = new double[]{0, 0, 1}; |
|
883 |
txt.setExtrusion(ext); |
|
870 | 884 |
} |
871 | 885 |
} |
872 | 886 |
|
... | ... | |
1353 | 1367 |
|
1354 | 1368 |
while(ant < (end - 32)){ |
1355 | 1369 |
bb.order(ByteOrder.LITTLE_ENDIAN); |
1370 |
|
|
1356 | 1371 |
byte kind = bb.get(); |
1357 |
|
|
1358 |
/* |
|
1359 |
* Para el caso de Polyline y Vertex, se instanciar? |
|
1360 |
* un 2D o un 3D en funcion del valor del flag |
|
1361 |
* |
|
1362 |
* */ |
|
1363 | 1372 |
if(kind < emax){ |
1364 | 1373 |
reader = (EntityReader) readers.get(kind); |
1365 | 1374 |
}//if |
1366 | 1375 |
|
1376 |
|
|
1367 | 1377 |
//PROPERTIES COMMON TO ALL DWG 12 ENTITIES |
1368 |
|
|
1369 |
|
|
1370 | 1378 |
byte flag = bb.get(); |
1371 | 1379 |
short lenght = bb.getShort(); |
1372 | 1380 |
|
1381 |
//segun esto los dos ultimos bytes son el CRC |
|
1373 | 1382 |
int crcpos = ant + (lenght - 2); |
1383 |
|
|
1384 |
|
|
1374 | 1385 |
short layer = bb.getShort(); |
1375 | 1386 |
short opts = bb.getShort(); |
1376 | 1387 |
|
... | ... | |
1378 | 1389 |
if ((flag & 0x1) > 0){ |
1379 | 1390 |
color = bb.get(); |
1380 | 1391 |
} |
1392 |
|
|
1381 | 1393 |
byte extra = 0; |
1382 | 1394 |
if ((flag & 0x40) > 0) |
1383 | 1395 |
extra = bb.get(); |
1384 | 1396 |
|
1397 |
|
|
1385 | 1398 |
String xdata = null; |
1386 | 1399 |
if((extra & 0x2) > 0) |
1387 | 1400 |
xdata = readXdata(); |
1388 | 1401 |
|
1402 |
|
|
1389 | 1403 |
short type = 0; |
1390 | 1404 |
if((flag & 0x2) > 0) |
1391 | 1405 |
type = bb.getShort(); |
1392 | 1406 |
|
1407 |
|
|
1393 | 1408 |
double z = 0d; |
1394 | 1409 |
if( (flag & 0x4) > 0 && (kind > 2) && (kind != 22)){ |
1395 | 1410 |
z = bb.getDouble(); |
... | ... | |
1403 | 1418 |
byte[] handle = null; |
1404 | 1419 |
if((flag & 0x20) > 0) |
1405 | 1420 |
handle = getHandle(); |
1421 |
|
|
1406 | 1422 |
short paper = 0; |
1407 | 1423 |
if((extra & 0x4) > 0){ |
1408 | 1424 |
paper = bb.getShort(); |
1409 | 1425 |
} |
1410 | 1426 |
|
1411 | 1427 |
if(reader != null){ |
1412 |
/* |
|
1413 |
* */ |
|
1414 | 1428 |
DwgObject entity = null; |
1415 | 1429 |
if(reader instanceof PlineReader){ |
1416 |
|
|
1430 |
System.out.println("plinereader"); |
|
1417 | 1431 |
}else if(reader instanceof VertexReader){ |
1418 |
|
|
1432 |
System.out.println("vertexreader"); |
|
1419 | 1433 |
}else{ |
1420 | 1434 |
entity = DwgObjectFactory. |
1421 | 1435 |
getInstance(). |
... | ... | |
1433 | 1447 |
* |
1434 | 1448 |
* De ser as?, y si indexamos las layers de esta forma |
1435 | 1449 |
* (con un HandleReference de code 0x5) ser? todo homogeneo |
1450 |
* |
|
1451 |
* TODO Construir instancias de DwgLayer a partir de las entradas |
|
1452 |
* de la tabla de layers, e indexarlas con un handle igual a su orden |
|
1436 | 1453 |
* */ |
1437 | 1454 |
|
1438 | 1455 |
entity.setLayerHandle(new DwgHandleReference(0x5, layer)); |
... | ... | |
1451 | 1468 |
|
1452 | 1469 |
|
1453 | 1470 |
//TODO HANDLES. Tampoco se si en DWG 12 se leen |
1454 |
//igual que en DWG 13 y posteriores |
|
1455 |
int offset = handle.hashCode(); |
|
1456 |
DwgHandleReference hdl = new DwgHandleReference(0, offset); |
|
1457 |
entity.setHandle(hdl); |
|
1471 |
//igual que en DWG 13 y posteriores |
|
1472 |
if(handle != null){ |
|
1473 |
int offset = handle.hashCode(); |
|
1474 |
DwgHandleReference hdl = new DwgHandleReference(0, offset); |
|
1475 |
entity.setHandle(hdl); |
|
1476 |
}else{ |
|
1477 |
System.out.println("HANDLE A NULL"); |
|
1478 |
bb.position(crcpos); |
|
1479 |
short crc = bb.getShort(); |
|
1480 |
continue; |
|
1481 |
} |
|
1458 | 1482 |
|
1459 | 1483 |
//TODO Idem con el espacio papel o el espacio modelo |
1460 | 1484 |
boolean paperSpace = false; |
... | ... | |
1466 | 1490 |
ant = bb.position(); |
1467 | 1491 |
if(ant < crcpos){ |
1468 | 1492 |
bb.position(bb.position() + (crcpos - ant)); |
1469 |
}else{ |
|
1470 |
System.out.println("nos hemos pasado"); |
|
1471 | 1493 |
} |
1472 | 1494 |
short crc = bb.getShort(); |
1473 | 1495 |
|
... | ... | |
1475 | 1497 |
dwgFile.addDwgObject(entity); |
1476 | 1498 |
|
1477 | 1499 |
}//if reader |
1500 |
else{ |
|
1501 |
System.out.println("Reader a NULL. DWG 12 MAL LEIDO"); |
|
1502 |
System.out.println("kind = " + kind); |
|
1503 |
bb.position(crcpos); |
|
1504 |
short crc = bb.getShort(); |
|
1505 |
continue; |
|
1506 |
|
|
1507 |
} |
|
1478 | 1508 |
ant = bb.position(); |
1479 |
byte[] crc32 = new byte[32]; |
|
1480 |
bb.get(crc32); |
|
1509 |
// byte[] crc32 = new byte[32];
|
|
1510 |
// bb.get(crc32);
|
|
1481 | 1511 |
index++; |
1482 | 1512 |
}//while |
1513 |
byte[] crc32 = new byte[32];//TODO va dentro o fuera del while?? |
|
1514 |
bb.get(crc32); |
|
1483 | 1515 |
} |
1484 | 1516 |
|
1485 | 1517 |
|
Also available in: Unified diff