Stefan Schuermans commited on 2013-01-27 21:19:38
Showing 6 changed files, with 56 additions and 19 deletions.
| ... | ... |
@@ -21,14 +21,14 @@ $DIMGAP |
| 21 | 21 |
40 |
| 22 | 22 |
0.625 |
| 23 | 23 |
9 |
| 24 |
-$INSUNITS |
|
| 25 |
- 70 |
|
| 26 |
-4 |
|
| 27 |
- 9 |
|
| 28 | 24 |
$DIMEXO |
| 29 | 25 |
40 |
| 30 | 26 |
0.625 |
| 31 | 27 |
9 |
| 28 |
+$INSUNITS |
|
| 29 |
+ 70 |
|
| 30 |
+4 |
|
| 31 |
+ 9 |
|
| 32 | 32 |
$DIMTXT |
| 33 | 33 |
40 |
| 34 | 34 |
2.5 |
| ... | ... |
@@ -37,18 +37,18 @@ $DIMSTYLE |
| 37 | 37 |
2 |
| 38 | 38 |
Standard |
| 39 | 39 |
9 |
| 40 |
-$PLIMMIN |
|
| 41 |
- 10 |
|
| 42 |
-0.0 |
|
| 43 |
- 20 |
|
| 44 |
-0.0 |
|
| 45 |
- 9 |
|
| 46 | 40 |
$PLIMMAX |
| 47 | 41 |
10 |
| 48 | 42 |
210.0 |
| 49 | 43 |
20 |
| 50 | 44 |
297.0 |
| 51 | 45 |
9 |
| 46 |
+$PLIMMIN |
|
| 47 |
+ 10 |
|
| 48 |
+0.0 |
|
| 49 |
+ 20 |
|
| 50 |
+0.0 |
|
| 51 |
+ 9 |
|
| 52 | 52 |
$DIMEXE |
| 53 | 53 |
40 |
| 54 | 54 |
1.25 |
| ... | ... |
@@ -120,10 +120,13 @@ bool CmdParser::procCmd_cut_inside(std::istream &strm) |
| 120 | 120 |
if (!getLayerPolys(strm, layerName, layer, polys)) |
| 121 | 121 |
return false; |
| 122 | 122 |
|
| 123 |
- // TODO |
|
| 124 |
- std::cerr << "TODO: cut_inside" << std::endl; |
|
| 123 |
+ // innner offset polygons |
|
| 124 |
+ Polygons newPolys; |
|
| 125 |
+ polys.createInnerOffset(mSettings.tool_diameter * 0.5, newPolys); |
|
| 126 |
+ |
|
| 127 |
+ // convert polygons back to layer (containing paths) |
|
| 125 | 128 |
Layer newLayer; |
| 126 |
- polys.writeToLayer(newLayer); |
|
| 129 |
+ newPolys.writeToLayer(newLayer); |
|
| 127 | 130 |
|
| 128 | 131 |
// convert layer to G-code |
| 129 | 132 |
newLayer.toGCode(mSettings, mGCode); |
| ... | ... |
@@ -10,8 +10,8 @@ |
| 10 | 10 |
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> |
| 11 | 11 |
#include <CGAL/Polygon_2.h> |
| 12 | 12 |
#include <CGAL/Polygon_with_holes_2.h> |
| 13 |
-#include <CGAL/create_offset_polygons_2.h> |
|
| 14 | 13 |
#include <CGAL/Boolean_set_operations_2.h> |
| 14 |
+#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h> |
|
| 15 | 15 |
|
| 16 | 16 |
#include "layer.h" |
| 17 | 17 |
#include "path.h" |
| ... | ... |
@@ -147,6 +147,36 @@ bool Polygons::loadLayer(const Layer &layer, double eqDist) |
| 147 | 147 |
return addLayer(layer, eqDist); |
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
+/** |
|
| 151 |
+ * @brief create inner offset polygons |
|
| 152 |
+ * @param[in] offset offset, > 0.0 |
|
| 153 |
+ * @param[out] offsetPolys offset polygons (!= *this) |
|
| 154 |
+ */ |
|
| 155 |
+void Polygons::createInnerOffset(double offset, Polygons &offsetPolys) const |
|
| 156 |
+{
|
|
| 157 |
+ // clear output polygons |
|
| 158 |
+ offsetPolys.mPolys.clear(); |
|
| 159 |
+ // leave if tool diameter is invalid |
|
| 160 |
+ if (offset <= 0.0) |
|
| 161 |
+ return; |
|
| 162 |
+ |
|
| 163 |
+ // process all polygons |
|
| 164 |
+ CgPolyHolesVec::const_iterator poly; |
|
| 165 |
+ for (poly = mPolys.begin(); poly != mPolys.end(); ++poly) {
|
|
| 166 |
+ |
|
| 167 |
+ // create inner offset polygons |
|
| 168 |
+ CgPolyHolesPtrVec offPolys = |
|
| 169 |
+ CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2( |
|
| 170 |
+ offset, *poly); |
|
| 171 |
+ |
|
| 172 |
+ // add offset polygons to output polygons |
|
| 173 |
+ CgPolyHolesPtrVec::const_iterator offPoly; |
|
| 174 |
+ for (offPoly = offPolys.begin(); offPoly != offPolys.end(); ++offPoly) |
|
| 175 |
+ offsetPolys.mPolys.push_back(**offPoly); |
|
| 176 |
+ |
|
| 177 |
+ } // for poly |
|
| 178 |
+} |
|
| 179 |
+ |
|
| 150 | 180 |
/** |
| 151 | 181 |
* @brief add all polygons with holes as multiple paths to a layer |
| 152 | 182 |
* @param[in,out] layer layer to add paths to |
| ... | ... |
@@ -12,7 +12,6 @@ |
| 12 | 12 |
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> |
| 13 | 13 |
#include <CGAL/Polygon_2.h> |
| 14 | 14 |
#include <CGAL/Polygon_with_holes_2.h> |
| 15 |
-#include <CGAL/create_offset_polygons_2.h> |
|
| 16 | 15 |
|
| 17 | 16 |
#include "layer.h" |
| 18 | 17 |
|
| ... | ... |
@@ -24,12 +23,10 @@ public: |
| 24 | 23 |
typedef CgKern::Point_2 CgPoint; |
| 25 | 24 |
typedef CGAL::Polygon_2<CgKern> CgPoly; |
| 26 | 25 |
typedef CGAL::Polygon_with_holes_2<CgKern> CgPolyHoles; |
| 27 |
- typedef CGAL::Straight_skeleton_2<CgKern> CgSskel; |
|
| 28 | 26 |
typedef std::vector<CgPoly> CgPolyVec; |
| 29 | 27 |
typedef std::vector<CgPolyHoles> CgPolyHolesVec; |
| 30 | 28 |
typedef boost::shared_ptr<CgPoly> CgPolyPtr; |
| 31 | 29 |
typedef boost::shared_ptr<CgPolyHoles> CgPolyHolesPtr; |
| 32 |
- typedef boost::shared_ptr<CgSskel> CgSskelPtr; |
|
| 33 | 30 |
typedef std::vector<CgPolyPtr> CgPolyPtrVec; |
| 34 | 31 |
typedef std::vector<CgPolyHolesPtr> CgPolyHolesPtrVec; |
| 35 | 32 |
|
| ... | ... |
@@ -54,6 +51,13 @@ public: |
| 54 | 51 |
*/ |
| 55 | 52 |
bool loadLayer(const Layer &layer, double eqDist); |
| 56 | 53 |
|
| 54 |
+ /** |
|
| 55 |
+ * @brief create inner offset polygons |
|
| 56 |
+ * @param[in] offset offset, > 0.0 |
|
| 57 |
+ * @param[out] offsetPolys offset polygons (!= *this) |
|
| 58 |
+ */ |
|
| 59 |
+ void createInnerOffset(double offset, Polygons &offsetPolys) const; |
|
| 60 |
+ |
|
| 57 | 61 |
/** |
| 58 | 62 |
* @brief add all polygons with holes as multiple paths to a layer |
| 59 | 63 |
* @param[in,out] layer layer to add paths to |