BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
36b0d97
Branches
Tags
master
dxfngc
src
polygons.h
implement outer polygon offset and cutting outside contour
Stefan Schuermans
commited
36b0d97
at 2013-01-28 21:04:35
polygons.h
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/ */ #ifndef POLYGONS_H #define POLYGONS_H #include <boost/shared_ptr.hpp> #include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Polygon_2.h> #include <CGAL/Polygon_with_holes_2.h> #include "layer.h" /// a set of polygons class Polygons { public: typedef CGAL::Exact_predicates_inexact_constructions_kernel CgKern; typedef CgKern::Point_2 CgPoint; typedef CGAL::Polygon_2<CgKern> CgPoly; typedef CGAL::Polygon_with_holes_2<CgKern> CgPolyHoles; typedef std::vector<CgPoly> CgPolyVec; typedef std::vector<CgPolyHoles> CgPolyHolesVec; typedef boost::shared_ptr<CgPoly> CgPolyPtr; typedef boost::shared_ptr<CgPolyHoles> CgPolyHolesPtr; typedef std::vector<CgPolyPtr> CgPolyPtrVec; typedef std::vector<CgPolyHolesPtr> CgPolyHolesPtrVec; /** * @brief clear all polygons */ void clear(); /** * @brief add polygons from layer * @param[in] layer layer to obtain the polygons from * @param[in] eqDist maximum distance of two points to be considered equal * @return if the layer could be converted to polygons and imported */ bool addLayer(const Layer &layer, double eqDist); /** * @brief load polygons from layer * @param[in] layer layer to obtain the polygons from * @param[in] eqDist maximum distance of two points to be considered equal * @return if the layer could be converted to polygons and imported */ bool loadLayer(const Layer &layer, double eqDist); /** * @brief create inner offset polygons * @param[in] offset offset, > 0.0 * @param[out] offsetPolys offset polygons (!= *this) * @return if inner offset polygons could be constructed */ bool createInnerOffset(double offset, Polygons &offsetPolys) const; /** * @brief create outer offset polygons * @param[in] offset offset, > 0.0 * @param[out] offsetPolys offset polygons (!= *this) * @return if outer offset polygons could be constructed */ bool createOuterOffset(double offset, Polygons &offsetPolys) const; /** * @brief add all polygons with holes as multiple paths to a layer * @param[in,out] layer layer to add paths to */ void addToLayer(Layer &layer) const; /** * @brief write all polygons with holes as multiple paths to a layer * @param[in,out] layer layer to write paths to */ void writeToLayer(Layer &layer) const; protected: /** * @brief create outer offset polygon * @param[in] poly polygon to create outer offset of * @param[in] offset offset, > 0.0 * @param[out] offsetPoly offset polygon (!= *this) * @return if outer offset polygon could be constructed */ static bool createOuterOffsetPoly(const CgPolyHoles &poly, double offset, CgPolyHoles &offsetPoly); /** * @brief add a polygon as path to a layer * @param[in] poly polygon to add to layer * @param[in,out] layer layer to add path to */ static void PolyToLayer(const CgPoly &poly, Layer &layer); /** * @brief add a polygon with holes as multiple paths to a layer * @param[in] poly polygon with holes to add to layer * @param[in,out] layer layer to add paths to */ static void PolyHolesToLayer(const CgPolyHoles &poly, Layer &layer); public: /// polygons CgPolyHolesVec mPolys; }; #endif // #ifndef POLYGONS_H