воскресенье, 14 августа 2016 г.

Week 12 Report [Final]

Brief description of the idea.
The aim of my project was to extend GDAL supported formats with DWG.

The state of the project as it was BEFORE your GSOC.
There was a DWG support, but it was not built-in by default, and GDAL Driver was based on third-party library Teigha (which is not X/MIT licensed, not even close).

The addition that your project brought to the software.

Libopencad (GDAL CAD Driver engine)
Overview
Libopencad is a library written in C++11, which provides a way to read/write CAD (DWG/DXF/DXFB) files. It was designed to have a uniformal API to work with any CAD files. It has a base class - CADFile. Inheriting this class it’s possible to create a ‘driver’ for any CAD format, all you need to do - is to overwrite interface functions like ‘GetGeometry(index)’, and others. Now it has an implementation for DWG2000 (R15), but only for read.
Library comes with ‘cadinfo’ utility, which prints out everything library can get from file - header variables, CAD custom classes, presented layers and geometries with their attributes.
Internal structure
Library presents CAD objects in different ways - base class CADObject and other CAD...Object classes are exact analogues of how DWG format stores information about its objects. CADGeometry, and other classes which inherits it, are done for API access to CAD...Object classes.
Library supports 3 modes of reading - READ_ALL (means everything which can be extracted from CAD file will be read) READ_FAST (skipping some kind of meanless information - linetypes, CRC check, etc), READ_FASTEST (only geometries reading, additional info is skipped).
When parsing the file, library does not store any information it does not need. First, it reads file meta-information, and creates a file map. It only stores some info about presented layers, and header variables. Then, when calling application uses CADLayer.GetGeometry(index), it actually reads a geometry from file, using prepared file map. Sometimes it will be slower than having everything you have read in cache, but gives you more flexibility what you want to store in memory, and what you wont.
Library also has special classes which incapsulates I/O functions, so it’s possible to reimplement them for your needs - by default it uses std::fstream, but you can make it possible to work with network by make a class inherited from CADFileIO.

Supported geometries list:
Point, Circle, Ellipse, Arc, Text, Solid, Spline, Line, Polyline 2D, Polyline 3D, LWPolyline, Ray, Raster (Images), MText, MLine, XLine, Polyface Mesh, 3DFace.



GDAL CAD Driver
Overview
GDAL CAD Driver uses libopencad as a datasource. Not everything that libopencad can read from file is mapped into OGR infrastructure, but it will be done in near future. Current features are:
  1. OpenOptions are presented with 2 options:
- MODE - READ_ALL/READ_FAST/READ_FASTEST (means the same as library OpenOptions).
- ADD_UNSUPPORTED_GEOMETRIES_DATA (YES/NO) - unstable feature, if some of the objects cannot be mapped into OGR representation (or its just not implemented yet), it will be presented as a CADUnknown object - OGRFeature without geometric representation, but with basic info - geometry type, some additional params.
  1. CAD header variables are mapped into metadata.
  2. Unlike DXF driver, CAD driver stores vector data in the appropriate layers (not all entities in single layer).
  3. Raster subdatasets are also supported.
  4. Coordinate system is extracted from DWG file (if it is presented in accordance with ESRI Docs for DWG files), or from %FILENAME%.prj file in the same directory.
  5. CAD Geometry attributes mapping is completely done into OGRLayerDefn. So, any ACAD BlockReference attributes will be seen in OGRLayerDefn.

Add all the links (hopefully permanent) to access the relevant code and documentation for the user to get started with testing your application.
During the planning stage, I decided to separate my project into 2 parts: separated CAD formats support library (named libopencad), and GDAL driver, which uses it. Library can be used by itself for any reason, and will be maintained after GSoC.

Links:
Libopencad repository (installation is described in REAME.MD)

A slide / image should serve to show the main elements of your project.
Blockreference attributes mapping into OGRLayerDefn:

Raster and vector layers by the same driver (left - ArcGIS, right - QGIS):

A little comparison between original data source (ACAD) and QGIS with new DWG driver:



Week 11 Report [Restored]

1. This week I've done:
OGR CAD Driver changes:
- A lot of warnings fixed.
- Travis build passes.
- Configure script checks c++ compiler compability with C++11 and enables CAD driver if it exists.

2. Plan on doing next week:
Windows build, fixes of various problems mentioned in PR.

3. Blocking:
None.

Best regards,
Alexandr Borzykh

Links:

воскресенье, 31 июля 2016 г.

Week 10 Report.

1. This week I've done:
Pull request to GDAL-trunk was opened.
OGR CAD Driver changes:
- Python tests are done.
- Code style fixes, memory leaks removements.
- Custom geometries attributes support (which are taken from BlockReference attdefs). Example:
- Code refactoring and cleaning.

2. Plan on doing next week:
Fix builds (travis/windows), testing and documentation update.

3. Blocking:
None.

Best regards,
Alexandr Borzykh

Links:

воскресенье, 24 июля 2016 г.

Week 9 Report.

1. This week I've done:
OGR CAD Driver changes:
- Implemented python autotests for CAD driver (more than half of the tests are done, a small part will be done next week).
- Finally a lwpolyline tesselation (now it can have arc segments).
- Text geometries now sets up OGR Style String to LABEL(…) with correct params.
- Arc geometry reading fix.
- Small code refactoring and cleaning.

2. Plan on doing next week:
Complete python tests, testing driver with QGIS, code refactoring. Fix windows, try to fix travis build.

3. Blocking:
None.

Best regards,

Alexandr Borzykh

Links:

воскресенье, 17 июля 2016 г.

Week 8 Report.

1. This week I've done:
Libopencad changes:
- BlockReference is now handled properly.
- Added a new API to work with Dictionaries (NamedObjectDictionary XRecords can be got, nested dictionaries isnt supported right now).
- Every geometry now has a list of attributes (can be got by calling CADGeometry::getBlockAttributes()). This attributes are being got from BlockReference (every geometry in block reference has it's block reference attributes).

OGR CAD Driver changes:
- Basic spline geometry support added.
- CADRecode() function, which does recoding CAD file strings (usually they are not UTF compatible, so it does recoding it to UTF).
- OGR Feature Style now sets to PEN(geometry color). Thickness and dash-dot styles needs LineType information (libopencad doesnot read it).
- Fixed a lot of errors which occured in test_ogrsf utility.

2. Plan on doing next week:
Library code refactoring and preparation it for GDAL-trunk, map geometry attributes into Feature attributes. Remove C++11 code from driver code, fix windows build.

3. Blocking:
None.

Links:

воскресенье, 10 июля 2016 г.

Week 7 Report.

1. This week I've done:
Libopencad changes:
- Fixed reading of files with only 1 object inside (before, it used to enter endless loop).
- Filemap creation speeded up.
- Added a bunch of various tests.
- Minor fixes and code formatting.

OGR CAD Driver changes:
- Basic spline geometry support added.
- Code refactoring, memory leaks fixes.
- I've started removing any dependencies on C++11 in driver code (but libopencad still will require -std=c++11).

2. Plan on doing next week:
Complete spline geometry, polylines interpolation, remove any dependencies on c++11 from driver code, fix ERRORs that appears when using test_ogrsf util. Get info about OGR Feature Style and make geometry parameters mapping into it.

3. Blocking:
None.

Links:

Extra:
This week my mentor (Dmitry Baryshnikov) have succesfully built QGIS with CAD Driver. There are some screenshots and little comparisons to ArcGIS and ACAD.
ACAD vs QGIS (with CAD driver)
ArcGIS vs QGis