mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-06 13:34:05 -06:00
Add libnest tests for various basic object functions
This commit is contained in:
parent
8c04536514
commit
69c02a407b
4 changed files with 133 additions and 32 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue