BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
986c763
Branches
Tags
master
dxfngc
src
polygons.h
implement converting polygons back to paths
Stefan Schuermans
commited
986c763
at 2013-01-27 17:06: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 <CGAL/create_offset_polygons_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 CGAL::Straight_skeleton_2<CgKern> CgSskel; typedef std::vector<CgPoly> CgPolyVec; typedef std::vector<CgPolyHoles> CgPolyHolesVec; typedef boost::shared_ptr<CgPoly> CgPolyPtr; typedef boost::shared_ptr<CgPolyHoles> CgPolyHolesPtr; typedef boost::shared_ptr<CgSskel> CgSskelPtr; 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 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 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