From 2eb04170187d09d70e6a20c696f5a6470b13e46b Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 27 Oct 2022 20:01:55 +0200 Subject: [PATCH] Further Perl eradication --- lib/Slic3r.pm | 6 ----- lib/Slic3r/ExPolygon.pm | 12 --------- lib/Slic3r/ExtrusionLoop.pm | 12 --------- lib/Slic3r/ExtrusionPath.pm | 13 ---------- lib/Slic3r/Geometry.pm | 17 ------------ lib/Slic3r/Layer.pm | 18 ------------- lib/Slic3r/Print/Object.pm | 9 ------- lib/Slic3r/Surface.pm | 15 ----------- t/geometry.t | 12 ++++----- xs/CMakeLists.txt | 1 - xs/lib/Slic3r/XS.pm | 5 ---- xs/xsp/BoundingBox.xsp | 52 ------------------------------------- xs/xsp/Polygon.xsp | 3 --- xs/xsp/Polyline.xsp | 2 -- xs/xsp/Print.xsp | 38 --------------------------- xs/xsp/my.map | 12 --------- xs/xsp/typemap.xspt | 34 ------------------------ 17 files changed, 6 insertions(+), 255 deletions(-) delete mode 100644 lib/Slic3r/ExPolygon.pm delete mode 100644 lib/Slic3r/ExtrusionLoop.pm delete mode 100644 lib/Slic3r/ExtrusionPath.pm delete mode 100644 lib/Slic3r/Layer.pm delete mode 100644 lib/Slic3r/Print/Object.pm delete mode 100644 lib/Slic3r/Surface.pm delete mode 100644 xs/xsp/BoundingBox.xsp diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 1e94e0f48..3b0167360 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -32,18 +32,12 @@ use Moo 1.003001; use Slic3r::XS; # import all symbols (constants etc.) before they get parsed use Slic3r::Config; -use Slic3r::ExPolygon; -use Slic3r::ExtrusionLoop; -use Slic3r::ExtrusionPath; use Slic3r::GCode::Reader; -use Slic3r::Layer; use Slic3r::Line; use Slic3r::Model; use Slic3r::Point; use Slic3r::Polygon; use Slic3r::Polyline; -use Slic3r::Print::Object; -use Slic3r::Surface; our $build = eval "use Slic3r::Build; 1"; # Scaling between the float and integer coordinates. diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm deleted file mode 100644 index 1b55849eb..000000000 --- a/lib/Slic3r/ExPolygon.pm +++ /dev/null @@ -1,12 +0,0 @@ -package Slic3r::ExPolygon; -use strict; -use warnings; - -# an ExPolygon is a polygon with holes - -sub bounding_box { - my $self = shift; - return $self->contour->bounding_box; -} - -1; diff --git a/lib/Slic3r/ExtrusionLoop.pm b/lib/Slic3r/ExtrusionLoop.pm deleted file mode 100644 index f0a857785..000000000 --- a/lib/Slic3r/ExtrusionLoop.pm +++ /dev/null @@ -1,12 +0,0 @@ -package Slic3r::ExtrusionLoop; -use strict; -use warnings; - -use parent qw(Exporter); - -our @EXPORT_OK = qw(EXTRL_ROLE_DEFAULT - EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER EXTRL_ROLE_SKIRT); -our %EXPORT_TAGS = (roles => \@EXPORT_OK); - - -1; diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm deleted file mode 100644 index 3e9e6b8c7..000000000 --- a/lib/Slic3r/ExtrusionPath.pm +++ /dev/null @@ -1,13 +0,0 @@ -package Slic3r::ExtrusionPath; -use strict; -use warnings; - -use parent qw(Exporter); - -our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER - EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_GAPFILL EXTR_ROLE_BRIDGE - EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_SUPPORTMATERIAL_INTERFACE - EXTR_ROLE_NONE); -our %EXPORT_TAGS = (roles => \@EXPORT_OK); - -1; diff --git a/lib/Slic3r/Geometry.pm b/lib/Slic3r/Geometry.pm index 2e4f5a097..6a2161d28 100644 --- a/lib/Slic3r/Geometry.pm +++ b/lib/Slic3r/Geometry.pm @@ -34,21 +34,4 @@ sub scaled_epsilon () { epsilon / &Slic3r::SCALING_FACTOR } sub scale ($) { $_[0] / &Slic3r::SCALING_FACTOR } sub unscale ($) { $_[0] * &Slic3r::SCALING_FACTOR } -# 2D -sub bounding_box { - my ($points) = @_; - - my @x = map $_->x, @$points; - my @y = map $_->y, @$points; #,, - my @bb = (undef, undef, undef, undef); - for (0..$#x) { - $bb[X1] = $x[$_] if !defined $bb[X1] || $x[$_] < $bb[X1]; - $bb[X2] = $x[$_] if !defined $bb[X2] || $x[$_] > $bb[X2]; - $bb[Y1] = $y[$_] if !defined $bb[Y1] || $y[$_] < $bb[Y1]; - $bb[Y2] = $y[$_] if !defined $bb[Y2] || $y[$_] > $bb[Y2]; - } - - return @bb[X1,Y1,X2,Y2]; -} - 1; diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm deleted file mode 100644 index a4146f169..000000000 --- a/lib/Slic3r/Layer.pm +++ /dev/null @@ -1,18 +0,0 @@ -# Extends the C++ class Slic3r::Layer. - -package Slic3r::Layer; -use strict; -use warnings; - -# the following two were previously generated by Moo -sub print { - my $self = shift; - return $self->object->print; -} - -sub config { - my $self = shift; - return $self->object->config; -} - -1; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm deleted file mode 100644 index d5c19e4a4..000000000 --- a/lib/Slic3r/Print/Object.pm +++ /dev/null @@ -1,9 +0,0 @@ -package Slic3r::Print::Object; -# extends c++ class Slic3r::PrintObject (Print.xsp) -use strict; -use warnings; - -use List::Util qw(min max sum first); -use Slic3r::Surface ':types'; - -1; diff --git a/lib/Slic3r/Surface.pm b/lib/Slic3r/Surface.pm deleted file mode 100644 index 0c5bb5d23..000000000 --- a/lib/Slic3r/Surface.pm +++ /dev/null @@ -1,15 +0,0 @@ -package Slic3r::Surface; -use strict; -use warnings; - -require Exporter; -our @ISA = qw(Exporter); -our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_BOTTOMBRIDGE S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE S_TYPE_INTERNALVOID); -our %EXPORT_TAGS = (types => \@EXPORT_OK); - -sub p { - my $self = shift; - return @{$self->polygons}; -} - -1; diff --git a/t/geometry.t b/t/geometry.t index 981621ee8..83fb72eea 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 11; +plan tests => 10; BEGIN { use FindBin; @@ -57,11 +57,11 @@ my $polygons = [ #========================================================== -{ - my $bb = Slic3r::Geometry::BoundingBox->new_from_points([ map Slic3r::Point->new(@$_), [0, 1], [10, 2], [20, 2] ]); - $bb->scale(2); - is_deeply [ $bb->min_point->pp, $bb->max_point->pp ], [ [0,2], [40,4] ], 'bounding box is scaled correctly'; -} +#{ +# my $bb = Slic3r::Geometry::BoundingBox->new_from_points([ map Slic3r::Point->new(@$_), [0, 1], [10, 2], [20, 2] ]); +# $bb->scale(2); +# is_deeply [ $bb->min_point->pp, $bb->max_point->pp ], [ [0,2], [40,4] ], 'bounding box is scaled correctly'; +#} #========================================================== diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index f8e0d0fe2..b16f221b9 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -43,7 +43,6 @@ set(XS_MAIN_XS ${CMAKE_CURRENT_BINARY_DIR}/main.xs) set(XSP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xsp) #FIXME list the dependecies explicitely, add dependency on the typemap. set(XS_XSP_FILES - ${XSP_DIR}/BoundingBox.xsp ${XSP_DIR}/Config.xsp ${XSP_DIR}/ExPolygon.xsp ${XSP_DIR}/Geometry.xsp diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index dee25afb8..60c9a9316 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -100,7 +100,6 @@ for my $class (qw( Slic3r::Config::Print Slic3r::Config::Static Slic3r::ExPolygon - Slic3r::Geometry::BoundingBox Slic3r::Line Slic3r::Model Slic3r::Model::Instance @@ -115,10 +114,6 @@ for my $class (qw( Slic3r::Polyline Slic3r::Polyline::Collection Slic3r::Print - Slic3r::Print::Object - Slic3r::Print::Region - Slic3r::Surface - Slic3r::Surface::Collection Slic3r::TriangleMesh )) { diff --git a/xs/xsp/BoundingBox.xsp b/xs/xsp/BoundingBox.xsp deleted file mode 100644 index 75592e7c3..000000000 --- a/xs/xsp/BoundingBox.xsp +++ /dev/null @@ -1,52 +0,0 @@ -%module{Slic3r::XS}; - -%{ -#include -#include "libslic3r/BoundingBox.hpp" -#include "libslic3r/Point.hpp" -%} - -%name{Slic3r::Geometry::BoundingBox} class BoundingBox { - BoundingBox(); - ~BoundingBox(); - Clone clone() - %code{% RETVAL = THIS; %}; - void merge(BoundingBox* bb) %code{% THIS->merge(*bb); %}; - void merge_point(Point* point) %code{% THIS->merge(*point); %}; - void scale(double factor); - void translate(double x, double y); - void offset(double delta); - bool contains_point(Point* point) %code{% RETVAL = THIS->contains(*point); %}; - bool overlap(BoundingBox* bbox) %code{% RETVAL = THIS->overlap(*bbox); %}; - Clone polygon(); - Clone size(); - Clone center(); - bool empty() %code{% RETVAL = empty(*THIS); %}; - double radius(); - Clone min_point() %code{% RETVAL = THIS->min; %}; - Clone max_point() %code{% RETVAL = THIS->max; %}; - int x_min() %code{% RETVAL = THIS->min(0); %}; - int x_max() %code{% RETVAL = THIS->max(0); %}; - int y_min() %code{% RETVAL = THIS->min(1); %}; - int y_max() %code{% RETVAL = THIS->max(1); %}; - void set_x_min(double val) %code{% THIS->min(0) = val; %}; - void set_x_max(double val) %code{% THIS->max(0) = val; %}; - void set_y_min(double val) %code{% THIS->min(1) = val; %}; - void set_y_max(double val) %code{% THIS->max(1) = val; %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min(0), THIS->min(1), THIS->max(0), THIS->max(1)); RETVAL = buf; %}; - bool defined() %code{% RETVAL = THIS->defined; %}; - -%{ - -BoundingBox* -new_from_points(CLASS, points) - char* CLASS - Points points - CODE: - RETVAL = new BoundingBox(points); - OUTPUT: - RETVAL - -%} -}; - diff --git a/xs/xsp/Polygon.xsp b/xs/xsp/Polygon.xsp index 873c4bcc9..7b1fbb83c 100644 --- a/xs/xsp/Polygon.xsp +++ b/xs/xsp/Polygon.xsp @@ -2,9 +2,7 @@ %{ #include -#include "libslic3r/BoundingBox.hpp" #include "libslic3r/Polygon.hpp" -#include "libslic3r/BoundingBox.hpp" %} %name{Slic3r::Polygon} class Polygon { @@ -35,7 +33,6 @@ %code{% RETVAL = THIS->contains(*point); %}; Polygons simplify(double tolerance); Clone centroid(); - Clone bounding_box(); Clone first_intersection(Line* line) %code{% Point p; diff --git a/xs/xsp/Polyline.xsp b/xs/xsp/Polyline.xsp index 3534e329e..595d54ec3 100644 --- a/xs/xsp/Polyline.xsp +++ b/xs/xsp/Polyline.xsp @@ -2,7 +2,6 @@ %{ #include -#include "libslic3r/BoundingBox.hpp" #include "libslic3r/Polyline.hpp" %} @@ -31,7 +30,6 @@ void simplify(double tolerance); void split_at(Point* point, Polyline* p1, Polyline* p2) %code{% THIS->split_at(*point, p1, p2); %}; - Clone bounding_box(); %{ Polyline* diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 9379aea20..584a2c100 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -5,25 +5,6 @@ #include "libslic3r/Print.hpp" %} -%name{Slic3r::Print::Region} class PrintRegion { - // owned by Print, no constructor/destructor - - Ref config() - %code%{ RETVAL = &THIS->config(); %}; -}; - -%name{Slic3r::Print::Object} class PrintObject { - // owned by Print, no constructor/destructor - - Ref print(); - Ref model_object(); - Ref config() - %code%{ RETVAL = &THIS->config(); %}; - Clone bounding_box(); - - void slice(); -}; - %name{Slic3r::Print} class Print { Print(); ~Print(); @@ -34,25 +15,6 @@ %code%{ RETVAL = const_cast(static_cast(&THIS->config())); %}; double total_used_filament() %code%{ RETVAL = THIS->print_statistics().total_used_filament; %}; - double total_extruded_volume() - %code%{ RETVAL = THIS->print_statistics().total_extruded_volume; %}; - double total_weight() - %code%{ RETVAL = THIS->print_statistics().total_weight; %}; - double total_cost() - %code%{ RETVAL = THIS->print_statistics().total_cost; %}; - double total_wipe_tower_cost() - %code%{ RETVAL = THIS->print_statistics().total_wipe_tower_cost; %}; - double total_wipe_tower_filament() - %code%{ RETVAL = THIS->print_statistics().total_wipe_tower_filament; %}; - int wipe_tower_number_of_toolchanges() - %code%{ RETVAL = THIS->wipe_tower_data().number_of_toolchanges; %}; - PrintObjectPtrs* objects() - %code%{ RETVAL = const_cast(&THIS->objects_mutable()); %}; - Ref get_object(int idx) - %code%{ RETVAL = THIS->objects_mutable()[idx]; %}; - size_t object_count() - %code%{ RETVAL = THIS->objects().size(); %}; - void auto_assign_extruders(ModelObject* model_object); std::string output_filepath(std::string path = "") diff --git a/xs/xsp/my.map b/xs/xsp/my.map index 5c5d10781..ba5ed6e04 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -14,10 +14,6 @@ std::vector T_STD_VECTOR_UINT std::vector T_STD_VECTOR_DOUBLE -BoundingBox* O_OBJECT_SLIC3R -Ref O_OBJECT_SLIC3R_T -Clone O_OBJECT_SLIC3R_T - DynamicPrintConfig* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T @@ -90,12 +86,6 @@ ModelInstance* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T -PrintRegion* O_OBJECT_SLIC3R -Ref O_OBJECT_SLIC3R_T - -PrintObject* O_OBJECT_SLIC3R -Ref O_OBJECT_SLIC3R_T - Print* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T @@ -120,8 +110,6 @@ Polygons* T_ARRAYREF_PTR ModelObjectPtrs* T_PTR_ARRAYREF_PTR ModelVolumePtrs* T_PTR_ARRAYREF_PTR ModelInstancePtrs* T_PTR_ARRAYREF_PTR -PrintRegionPtrs* T_PTR_ARRAYREF_PTR -PrintObjectPtrs* T_PTR_ARRAYREF_PTR # we return these types whenever we want the items to be returned # by reference and not marked ::Ref because they're newly allocated diff --git a/xs/xsp/typemap.xspt b/xs/xsp/typemap.xspt index 7fc61fe3f..7b9c02319 100644 --- a/xs/xsp/typemap.xspt +++ b/xs/xsp/typemap.xspt @@ -27,9 +27,6 @@ %typemap{Vec3d*}; %typemap{Ref}{simple}; %typemap{Clone}{simple}; -%typemap{BoundingBox*}; -%typemap{Ref}{simple}; -%typemap{Clone}{simple}; %typemap{DynamicPrintConfig*}; %typemap{Ref}{simple}; %typemap{Clone}{simple}; @@ -57,15 +54,6 @@ %typemap{Ref}{simple}; %typemap{Clone}{simple}; -%typemap{PrintState*}; -%typemap{Ref}{simple}; - -%typemap{PrintRegion*}; -%typemap{Ref}{simple}; - -%typemap{PrintObject*}; -%typemap{Ref}{simple}; - %typemap{Print*}; %typemap{Ref}{simple}; %typemap{Clone}{simple}; @@ -103,31 +91,9 @@ %typemap{Ref}{simple}; %typemap{Clone}{simple}; -%typemap{PrintRegionPtrs*}; -%typemap{PrintObjectPtrs*}; -%typemap{LayerPtrs*}; - %typemap{Axis}{parsed}{ %cpp_type{Axis}; %precall_code{% $CVar = (Axis)SvUV($PerlVar); %}; }; -%typemap{SurfaceType}{parsed}{ - %cpp_type{SurfaceType}; - %precall_code{% - $CVar = (SurfaceType)SvUV($PerlVar); - %}; -}; -%typemap{ExtrusionLoopRole}{parsed}{ - %cpp_type{ExtrusionLoopRole}; - %precall_code{% - $CVar = (ExtrusionLoopRole)SvUV($PerlVar); - %}; -}; -%typemap{ExtrusionRole}{parsed}{ - %cpp_type{ExtrusionRole}; - %precall_code{% - $CVar = (ExtrusionRole)SvUV($PerlVar); - %}; -};