Wired2Code

Just another WordPress.com site

DrawGin, 12.26.2012 status

After 18 months I’ve finally started to code on the DrawGin library again and made the following changes.

  • * Refactored project directory structure.
  • ** Added VS 2008 solution file (no longer need cmake to build one).
  • Some code cleanup.
  • Fix bug when decoding class maps with multiple sections and added additional logging to help locate said bug.

In the VS property page for DrawinApp, added the following line to the Debugging/Command Arguments section:
–v=4 –log_dir=$(OutDir)\logs –alsologtostderr=1 –drawing=C:\Users\Paul\Documents\TestDwgs\TestDwg3.dwg

Decoding the Objects section is still a todo item. Once completed the library should be able to read AutoCAD R14 drawing files.

* The CMake projects files have not been updated to reflect the changed directory structure.  Then means creating projects/solutions for your favorite IDE is temporarily broken.

December 26, 2012 Posted by | C++ Programming, DrawGin, gcc | , , , , , | Leave a comment

DrawGin, 06.01.2011 status

The DrawGin library is rapidly taking shape and able to read most sections of an AutoCAD R14 formatted drawing. The next section to code up is the area where AcDbObject and AcDbEntity derived objects are stored (section 6 below). For the purpose of deserializing the bit encoded drawing data, sections 1, 2, 3, 4, 5 are completed.

  1. Drawing File Header – Defines where key sections are located within the drawing file.
  2. Preview Image – Bitmap image created when drawing was last saved.
  3. Header Variables – various setting variables associated with the drawing file.
  4. Classes Map – Holds information about various application defined classes that are used (instances of) in the drawing.
  5. Objects Map – Tells the file position of each object stored in the drawing (with AutoCAD object handle)
  6. Objects – The object instances referenced in the Objects Map (these are AcDbObject and AcDbEntity derived).

Most of the drawing format is defined at the bit level, which require special IO routines found in the OcBs directory (OcBitStream). The OcBsStreamIn class handles reading the various bit level data types and keeps track of the running CRC calculation. The stream also has a 4K memory buffer and handles huge 100 meg files, no problem.

Class DwgArchiveIn (will be renamed later to OcBsDwgArchive) is an archive class that will work much like MFC’s CArchive.

Classes in the OcDb represent the various data types that make up a drawing. Most of the classes will have a one-to-one similarity by name to those found in Autodesk’s ObjectARX SDK. At this time DrawGin is not going for ObjectARX compatibility, so member function names and signatures will not be the same.

Future blog entries will delve into the framework and implementation details. For now just wanted to post a quick status update.

June 1, 2011 Posted by | C++ Programming, DrawGin, gcc | , , , , , | Leave a comment

DrawGin

DrawGin is a new open source project to read and write “.dwg” file formats. Current work is focused on the cross platform C++ framework to support reading drawing files in the AutoCAD R14 format, with write support to follow shortly thereafter.

There is lots of source code to view at the project page, and if you are interested in contributing to DrawGin, let me know. The code currently compiles in OS X and Linux using the Codelite IDE, and in Windows using Visual C++ 2008.

The “.dwg” format specification, versions 4.0 and 5.1, published by the Open Design Alliance are the reference documents used to write the DrawGin library.

May 17, 2011 Posted by | Boost, C++ Programming, gcc, STL Containers, Templates, Uncategorized | Leave a comment

Visual C++ Code Formatting with AStyle

Visual Studio VBA macro to format the current C++/h document using the open source code formatter AStyle. Simply copy the macro to the “Macros->Module1” is Visual Studio, then hookup a hot key to it.

Download AStyle from http://astyle.sourceforge.net/ and extract to a directory (code will look in the download directory off the user’s home directory). Update the shellCmd string variable with any formatting options AStyle should apply (http://astyle.sourceforge.net/astyle.html).

Format string “-A4Uxpfn”
-A4 = stroustrup style
-U  = unpad paren
-x  = delete empty lines
-p  = pad operators
-f  = break blocks
-n  = do not retain backup

Code Snippet
  1. Public Sub formatDocWithAStyle()
  2. Dim fileName As String
  3. Dim textDocument As TextDocument
  4. Dim startPoint As EnvDTE.EditPoint
  5. Dim endPoint As EnvDTE.EditPoint
  6. Dim text As String
  7. Dim shellCmd As String
  8. Dim procId As Integer
  9. If DTE.ActiveDocument Is Nothing Then
  10. Return
  11. End If
  12. fileName = Environ$(“TEMP”) & “\formattedCode”
  13. shellCmd = “””” & Environ$(“HOMEPATH”) & “\Downloads\AStyle\bin\AStyle” & “””” & ” -A4Uxpfn “ & “””” & fileName & “”””
  14. textDocument = DTE.ActiveDocument.Object
  15. startPoint = textDocument.StartPoint.CreateEditPoint
  16. endPoint = textDocument.EndPoint.CreateEditPoint
  17. text = startPoint.GetText(endPoint)
  18. My.Computer.FileSystem.WriteAllText(fileName, text, False)
  19. procId = Shell(shellCmd, AppWinStyle.Hide, True, 30000)
  20. If procId = 0 Then
  21. text = My.Computer.FileSystem.ReadAllText(fileName)
  22. startPoint.ReplaceText(endPoint, text, vsEPReplaceTextOptions.vsEPReplaceTextTabsSpaces)
  23. End If
  24. End Sub

January 23, 2011 Posted by | Code Formatting | , , , , | 1 Comment

Installing latest gdb on Snow Leopard

Figures there would be a problem installing gdb on Snow Leopard using Macports. The error message was
libbfd.c: In function ‘bfd_get_b_signed_64’:

lipo: can’t figure out the architecture type of: …

Looking at the build log file shows gdb being built for i386 and x86_64. After a little poking around I found the culprit to be in
/opt/local/etc/macports/variants.conf

where when I initially installed Macports had enabled +universal (don’t recall why). So, comment out the +universal line and rebuilt gdb.

sudo port clean gdb
sudo port install gdb

Afterwards, the new gdb will be installed to

/opt/local/bin/fsf-gdb

 

October 11, 2010 Posted by | C++ Programming, gcc, Macports | , , , | Leave a comment