Coder Social home page Coder Social logo

kenedy1 / libopencad Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sandyre/libopencad

0.0 0.0 0.0 6.5 MB

OpenSource library under X/MIT license to work with CAD files (DWG/DXF). Please use repository linked below, this one is abandoned.

Home Page: https://github.com/nextgis-borsch/lib_opencad

License: MIT License

C++ 73.97% C 1.17% Objective-C 1.38% CMake 23.47%

libopencad's Introduction

libopencad

Ubuntu 14.04 (gcc 4.8 + clang): Build Status

OpenSource library under X11/MIT license for everyday use. Under development, but some of basic functionality is already available. This project is being developed by Alexandr Borzykh (sandyre) under mentorship of Dmitry Baryshnikov (NextGIS).

Current project state:

DWG Read Write Features Missing
R13-14 - - - -
R15 + - Reading of layers.Basic geometry reading. Exporting header variables and classes. Linetypes, CRC calculation, by-block reading.
R17 - - - -

Getting started

First you need to download repository

git clone https://github.com/sandyre/libopencad

Static library way

Then, run cmake

cmake CMakeLists.txt

Build the project

make -j4

At this point, you will have a static library at lib/libopencadstatic.(your OS static library extension) All you have to do now - is to link library with your project, and include associated header files - opencad_api.h, cadgeometries.h and others.

Dynamic library way

Then, run cmake

cmake -DBUILD_SHARED_LIBS=ON CMakeLists.txt

Build the project

make -j4

At this point, you will have a dynamic library at lib/libopencad{library version}.(your OS dynamic library extension) All you have to do now - is to link library with your project, and include associated header files - opencad_api.h, cadgeometries.h and others.

Library sources inclusion way

All you have to do is to link the lib/ directory to your project file tree, that's actually it.

Usage example

As an example of library usage, there is a built-in app called cadinfo (builds by default with library, available in apps/ directory).

#include <iostream>
# include "lib/opencad_api.h"

// returns nullptr on fail. GetLastErrorCode() returns an error code.
CADFile *pCADFile = OpenCADFile( pszCADFilePath,
                                      CADFile::OpenOptions::READ_ALL );

const CADHeader& header = pCADFile->getHeader ();
header.print (); // prints CAD Header variables.
cout << endl;

const CADClasses& classes = pCADFile->getClasses ();
classes.print (); // prints custom CAD classes
cout << endl;

for ( size_t i = 0; i < pCADFile->getLayersCount (); ++i )
{
    CADLayer &layer = pCADFile->getLayer (i);
    cout << "Layer #" << i << " contains "
         << layer.getGeometryCount () << " geometries" << endl;

    for ( size_t j = 0; j < layer.getGeometryCount (); ++j )
    {
        unique_ptr<CADGeometry> geom(layer.getGeometry (j));

        if ( geom == nullptr )
            continue;

        switch ( geom->getType() ) // returns GeometryType enum.
        {
            case CADGeometry::CIRCLE:
                CADCircle * poCADCircle = ( CADCircle* ) geom.get();
                std::cout << poCADCircle->getPosition().getX() << std::endl;
                std::cout << poCADCircle->getPosition().getY() << std::endl;
                std::cout << poCADCircle->getPosition().getZ() << std::endl;
                break;
            // any other geometry type you need.
        }
    }
}

Contribution

Feel free to submit an issue, or make a pull request. To begin with, it's better to fix some FIXME/TODO's, to get more familiar with code base.

Library documentation

Documentation is generated by Doxygen, available at this link

libopencad's People

Contributors

bishopgis avatar jamierobertson1 avatar feragon avatar lbartoletti avatar luzpaz avatar amdmi3 avatar mush3d avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.