diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2020-03-27 11:20:06 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2020-04-23 19:17:58 +0300 |
commit | 69c02a407bb3ce4463efa207053a18634871db02 (patch) | |
tree | b340c2f69b24922b4d5f01cb13fefb903859f6f3 /src | |
parent | 8c0453651423eabaa8536620abb4599b365ad318 (diff) |
Add libnest tests for various basic object functions
Diffstat (limited to 'src')
-rw-r--r-- | src/libnest2d/include/libnest2d/geometry_traits.hpp | 3 | ||||
-rw-r--r-- | src/libnest2d/include/libnest2d/libnest2d.hpp | 1 | ||||
-rw-r--r-- | src/libnest2d/tools/svgtools.hpp | 25 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/libnest2d/include/libnest2d/geometry_traits.hpp b/src/libnest2d/include/libnest2d/geometry_traits.hpp index 72e239a70..c447cfcd9 100644 --- a/src/libnest2d/include/libnest2d/geometry_traits.hpp +++ b/src/libnest2d/include/libnest2d/geometry_traits.hpp @@ -982,6 +982,9 @@ template<class S> inline double area(const S& poly, const PolygonTag& ) }); } +template<class RawShapes> +inline double area(const RawShapes& shapes, const MultiPolygonTag&); + template<class S> // Dispatching function inline double area(const S& sh) { diff --git a/src/libnest2d/include/libnest2d/libnest2d.hpp b/src/libnest2d/include/libnest2d/libnest2d.hpp index b6d7fcdcf..5eef28c40 100644 --- a/src/libnest2d/include/libnest2d/libnest2d.hpp +++ b/src/libnest2d/include/libnest2d/libnest2d.hpp @@ -27,6 +27,7 @@ using Coord = TCoord<PointImpl>; using Box = _Box<PointImpl>; using Segment = _Segment<PointImpl>; using Circle = _Circle<PointImpl>; +using MultiPolygon = TMultiShape<PolygonImpl>; using Item = _Item<PolygonImpl>; using Rectangle = _Rectangle<PolygonImpl>; diff --git a/src/libnest2d/tools/svgtools.hpp b/src/libnest2d/tools/svgtools.hpp index e1ed1ad05..2a05b551d 100644 --- a/src/libnest2d/tools/svgtools.hpp +++ b/src/libnest2d/tools/svgtools.hpp @@ -5,7 +5,7 @@ #include <fstream> #include <string> -#include <libnest2d/libnest2d.hpp> +#include <libnest2d/nester.hpp> namespace libnest2d { namespace svg { @@ -48,23 +48,28 @@ public: conf_.width = static_cast<double>(box.width()) / conf_.mm_in_coord_units; } - - void writeItem(const Item& item) { + + void writeShape(RawShape tsh) { if(svg_layers_.empty()) addLayer(); - auto tsh = item.transformedShape(); if(conf_.origo_location == BOTTOMLEFT) { auto d = static_cast<Coord>( - std::round(conf_.height*conf_.mm_in_coord_units) ); - + std::round(conf_.height*conf_.mm_in_coord_units) ); + auto& contour = shapelike::contour(tsh); for(auto& v : contour) setY(v, -getY(v) + d); - + auto& holes = shapelike::holes(tsh); for(auto& h : holes) for(auto& v : h) setY(v, -getY(v) + d); - + } - currentLayer() += shapelike::serialize<Formats::SVG>(tsh, - 1.0/conf_.mm_in_coord_units) + "\n"; + currentLayer() += + shapelike::serialize<Formats::SVG>(tsh, + 1.0 / conf_.mm_in_coord_units) + + "\n"; + } + + void writeItem(const Item& item) { + writeShape(item.transformedShape()); } void writePackGroup(const PackGroup& result) { |