BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
be85cfc
Branches
Tags
master
dxfngc
src
drawing.cpp
initial version, DXFs can be read, some G-code can be produced
Stefan Schuermans
commited
be85cfc
at 2013-01-20 20:53:53
drawing.cpp
Blame
History
Raw
/* drawing (DXF) to G-code (NGC) converter * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/ */ #include <dime/Input.h> #include <dime/Model.h> #include <iostream> #include <map> #include <string> #include "drawing.h" #include "layer.h" #include "traverse.h" /** * @brief clear all contents of drawing */ void Drawing::clear() { mLayers.clear(); } /** * @brief add a DXF file to this drawing * @param[in] strFileName name of the DXF file to read * @return if the DXF file could be read */ bool Drawing::addDxf(const std::string &strFileName) { // read DXF file dimeInput in; if (!in.setFile(strFileName.c_str())) { std::cerr << "error opening file \"" << strFileName << "\" for reading" << std::endl; return false; } dimeModel model; if (!model.read(&in)) { std::cerr << "DXF read error in line " << in.getFilePosition() << " of file \"" << strFileName << "\"" << std::endl; return false; } // enumerate all entities and add them to drawing struct traverse_ctx ctx; ctx.mpDrawing = this; model.traverseEntities(traverse_entity, &ctx); return true; } /** * @brief load a DXF file to this drawing * @param[in] strFileName name of the DXF file to read * @return if the DXF file could be read */ bool Drawing::loadDxf(const std::string &strFileName) { clear(); return addDxf(strFileName); }