BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
1030916
Branches
Tags
master
dxfngc
src
polygons.h
license CC-BY-SA --> GPL (more suitable for source code)
Stefan Schuermans
commited
1030916
at 2013-05-27 17:35:02
polygons.h
Blame
History
Raw
/* 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 */ #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_straight_skeleton_from_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 CGAL::Straight_skeleton_2<CgKern> CgSs; 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<CgSs> CgSsPtr; 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 fill insides of polygons by creating inner offset polygons * @param[in] offset offset, > 0.0 * @param[out] offsetPolys offset polygons (!= *this) * @return if insides of polygons could be filles with inner offset polygons */ bool fillInnerOffset(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