svn-gvsig-desktop / tags / v1_9_Build_1236 / libraries / libDwg / doc / dev_guide.txt @ 40002
History | View | Annotate | Download (3.29 KB)
1 | 2896 | jmorell | jdwglib Developer's Guide |
---|---|---|---|
2 | |||
3 | Overview |
||
4 | |||
5 | The Java DWG Library (jdwglib) is a Java libray designed for reading, handling and |
||
6 | writing drawing files in the Autodesk DWG format. This document is the design |
||
7 | specification for the classes, methods and algorithms implemented in the Java DWG |
||
8 | Library. |
||
9 | |||
10 | jdwglib has two different parts, first for DWG file accesing, and second for DWG file |
||
11 | handling. The part for accesing DWG files support the reading of DWG files and in |
||
12 | future versions we hope that writing of DWG files will be supported too. The part for |
||
13 | handling DWG files is designed for managing DWG complex objects like polylines or |
||
14 | blocks with the objective that the spatial position and the attributes of DWG objects |
||
15 | will be definitive and no one operation is required for obtaining the same results |
||
16 | that Autocad. |
||
17 | |||
18 | The detailed documentation of the class hierarchy and methods will be presented in the |
||
19 | form of JavaDoc for the source code. |
||
20 | |||
21 | |||
22 | Other resources |
||
23 | |||
24 | - Pythoncad DWG Library by Art Haas (www.pythoncad.org). The part of jdwglib that reads |
||
25 | DWG files is a port of this library with an object oriented model added. |
||
26 | |||
27 | - The AutoCAD R13/R14/R2000 DWG File Specification by the OpenDWG Alliance. This is the |
||
28 | public specification of the DWG format obtained using reverse engineering methods by |
||
29 | the OpenDWG Alliance (www.opendwg.org). |
||
30 | |||
31 | |||
32 | Handling DWG files |
||
33 | |||
34 | jdwglib has been developed to allow GPL GIS applications to handle the information |
||
35 | stored in DWG files. |
||
36 | |||
37 | jdwglib has been designed to allow developers to create DWG drivers for their |
||
38 | CAD/GIS applications easily and in a GPL environment. |
||
39 | |||
40 | The use of jdwglib for any driver is ever the same: |
||
41 | |||
42 | - DwgFile dwgFile = new DwgFile(dwg.getAbsolutePath()); Creates a new DwgFile |
||
43 | object for reading a DWG file. |
||
44 | |||
45 | - dwgFile.read(); Reads the DWG file but don't configure its objects. |
||
46 | |||
47 | - dwgFile.initializeLayerTable(); Creates a table with the DWG file layer |
||
48 | information. |
||
49 | |||
50 | - dwgFile.calculateGisModelDwgPolylines() or dwgFile.calculateCadModelDwgPolylines(); |
||
51 | calculateGisModelDwgPolylines() configures Polyline's geometry. In Polylines with |
||
52 | arcs, these arcs are defined by a set of points and a distance between these points. |
||
53 | calculateCadModelDwgPolylines() configures Polyline's geometry. In Polylines with |
||
54 | arcs, these arcs are defined by a curvature parameter called bulge that is associated |
||
55 | with the points. |
||
56 | |||
57 | - dwgFile.applyExtrusions(); The extrusion parameters of the objets in a DWG file |
||
58 | changes the location of these objects. |
||
59 | |||
60 | - dwgFile.testDwg3D(): test if the DWG file has elevation information. |
||
61 | |||
62 | - dwgFile.blockManagement(); This method manages the blocks contained in a DWG file. |
||
63 | |||
64 | - Vector dwgObjects = dwgFile.getDwgObjects(); Import the set of DWG objects. Now they |
||
65 | are correctly configured. |
||
66 | |||
67 | - for (int i=0;i<dwgObjects.size();i++) { |
||
68 | DwgObject iObj = (DwgObject)dwgObjects.get(i); |
||
69 | if (iObj instanceof DwgArc) { |
||
70 | //Convert iObj to the corresponding object model |
||
71 | } |
||
72 | } Convert DWG objects to the corresponding object model. |
||
73 | |||
74 | - String layerName = dwgFile.getLayerName(iObj); Returns the layer name of a DWG |
||
75 | object. |
||
76 | |||
77 | - int colorByLayer = dwgFile.getColorByLayer(iObj); Returns color of the layer of a |
||
78 | DWG object. |
||
79 | |||
80 | The author has implemented a DWG driver for gvSIG based on this library, and a DWG |
||
81 | driver for other Java GIS application like Jump or uDig must be easy to implement too. |
||
82 |