/* drawing (DXF) to G-code (NGC) converter
* Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
*/
#include <fstream>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include "cmdparser.h"
#include "drawing.h"
#include "filename.h"
#include "gcode.h"
#include "polygons.h"
#include "settings.h"
/**
* @brief get layer by name from stream
* @param[in] strm stream to read layer name from
* @param[out] name layer name from stream
* @param[out] layer layer indicated by name from stream
* @return if layer could be found
*/
bool CmdParser::getLayer(std::istream &strm, std::string &name,
const Layer *&layer) const
{
// get layer name argument
strm >> name;
if (strm.fail()) {
std::cerr << "missing layer name" << std::endl;
return false;
}
// get layer
Drawing::Layers::const_iterator itLayer = mDrawing.mLayers.find(name);
if (itLayer == mDrawing.mLayers.end()) {
std::cerr << "layer \"" << name << "\" not found" << std::endl;
return false;
}
layer = &itLayer->second;
return true;
}
/**
* @brief get layer by name from stream and convert to polygons
* @param[in] strm stream to read layer name from
* @param[out] name layer name from stream
* @param[out] layer layer indicated by name from stream