From 959230b0994e0367bff4d2a02cec91993322dd14 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 25 Feb 2012 17:35:25 +0100 Subject: [PATCH] Refactoring: moved Slic3r::STL and Slic3r::AMF to Slic3r::Format::* --- MANIFEST | 6 +++--- lib/Slic3r.pm | 4 ++-- lib/Slic3r/{ => Format}/AMF.pm | 6 +++--- lib/Slic3r/{ => Format}/AMF/Parser.pm | 2 +- lib/Slic3r/{ => Format}/STL.pm | 2 +- lib/Slic3r/Skein.pm | 4 ++-- utils/amf-to-stl.pl | 4 ++-- utils/split_stl.pl | 4 ++-- utils/stl-to-amf.pl | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) rename lib/Slic3r/{ => Format}/AMF.pm (95%) rename lib/Slic3r/{ => Format}/AMF/Parser.pm (98%) rename lib/Slic3r/{ => Format}/STL.pm (99%) diff --git a/MANIFEST b/MANIFEST index 4170fa50e..710940c98 100644 --- a/MANIFEST +++ b/MANIFEST @@ -31,9 +31,9 @@ lib/Slic3r/Polygon.pm lib/Slic3r/Polyline.pm lib/Slic3r/Print.pm lib/Slic3r/Skein.pm -lib/Slic3r/AMF.pm -lib/Slic3r/AMF/Parser.pm -lib/Slic3r/STL.pm +lib/Slic3r/Format/AMF.pm +lib/Slic3r/Format/AMF/Parser.pm +lib/Slic3r/Format/STL.pm lib/Slic3r/Surface.pm lib/Slic3r/SVG.pm lib/Slic3r/TriangleMesh.pm diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 248210165..3b57f85c9 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -22,6 +22,8 @@ use Slic3r::ExtrusionPath; use Slic3r::ExtrusionPath::Arc; use Slic3r::ExtrusionPath::Collection; use Slic3r::Fill; +use Slic3r::Format::AMF; +use Slic3r::Format::STL; use Slic3r::Geometry qw(PI); use Slic3r::Layer; use Slic3r::Line; @@ -31,8 +33,6 @@ use Slic3r::Polygon; use Slic3r::Polyline; use Slic3r::Print; use Slic3r::Skein; -use Slic3r::AMF; -use Slic3r::STL; use Slic3r::Surface; use Slic3r::TriangleMesh; use Slic3r::TriangleMesh::IntersectionLine; diff --git a/lib/Slic3r/AMF.pm b/lib/Slic3r/Format/AMF.pm similarity index 95% rename from lib/Slic3r/AMF.pm rename to lib/Slic3r/Format/AMF.pm index c31aa6055..5d174230b 100644 --- a/lib/Slic3r/AMF.pm +++ b/lib/Slic3r/Format/AMF.pm @@ -1,4 +1,4 @@ -package Slic3r::AMF; +package Slic3r::Format::AMF; use Moo; use Slic3r::Geometry qw(X Y Z); @@ -8,7 +8,7 @@ sub read_file { my $self = shift; my ($file) = @_; - eval "require Slic3r::AMF::Parser; 1" + eval "require Slic3r::Format::AMF::Parser; 1" or die "AMF parsing requires XML::SAX::ExpatXS\n"; open my $fh, '<', $file or die "Failed to open $file\n"; @@ -17,7 +17,7 @@ sub read_file { my $materials = {}; my $meshes_by_material = {}; XML::SAX::ExpatXS - ->new(Handler => Slic3r::AMF::Parser->new( + ->new(Handler => Slic3r::Format::AMF::Parser->new( _vertices => $vertices, _materials => $materials, _meshes_by_material => $meshes_by_material, diff --git a/lib/Slic3r/AMF/Parser.pm b/lib/Slic3r/Format/AMF/Parser.pm similarity index 98% rename from lib/Slic3r/AMF/Parser.pm rename to lib/Slic3r/Format/AMF/Parser.pm index 2440acbae..edac0929d 100644 --- a/lib/Slic3r/AMF/Parser.pm +++ b/lib/Slic3r/Format/AMF/Parser.pm @@ -1,4 +1,4 @@ -package Slic3r::AMF::Parser; +package Slic3r::Format::AMF::Parser; use strict; use warnings; diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/Format/STL.pm similarity index 99% rename from lib/Slic3r/STL.pm rename to lib/Slic3r/Format/STL.pm index cbaa22b47..91630a7b7 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/Format/STL.pm @@ -1,4 +1,4 @@ -package Slic3r::STL; +package Slic3r::Format::STL; use Moo; use Slic3r::Geometry qw(X Y Z triangle_normal); diff --git a/lib/Slic3r/Skein.pm b/lib/Slic3r/Skein.pm index c066e5dc0..71e5dce29 100644 --- a/lib/Slic3r/Skein.pm +++ b/lib/Slic3r/Skein.pm @@ -27,11 +27,11 @@ sub go { $self->status_cb->(10, "Processing triangulated mesh"); my $print; if ($self->input_file =~ /\.stl$/i) { - my $mesh = Slic3r::STL->read_file($self->input_file); + my $mesh = Slic3r::Format::STL->read_file($self->input_file); $mesh->check_manifoldness; $print = Slic3r::Print->new_from_mesh($mesh); } elsif ( $self->input_file =~ /\.amf(\.xml)?$/i) { - my ($materials, $meshes_by_material) = Slic3r::AMF->read_file($self->input_file); + my ($materials, $meshes_by_material) = Slic3r::Format::AMF->read_file($self->input_file); $_->check_manifoldness for values %$meshes_by_material; $print = Slic3r::Print->new_from_mesh($meshes_by_material->{_} || +(values %$meshes_by_material)[0]); } else { diff --git a/utils/amf-to-stl.pl b/utils/amf-to-stl.pl index ce078f1ae..847e5e749 100755 --- a/utils/amf-to-stl.pl +++ b/utils/amf-to-stl.pl @@ -25,12 +25,12 @@ my %opt = (); } { - my $mesh = Slic3r::AMF->read_file($ARGV[0]); + my $mesh = Slic3r::Format::AMF->read_file($ARGV[0]); my $output_file = $ARGV[0]; $output_file =~ s/\.amf(?:\.xml)?$/\.stl/i; printf "Writing to %s\n", basename($output_file); - Slic3r::STL->write_file($output_file, $mesh, !$opt{ascii}); + Slic3r::Format::STL->write_file($output_file, $mesh, !$opt{ascii}); } diff --git a/utils/split_stl.pl b/utils/split_stl.pl index 6fbc0b324..12fcd1af0 100755 --- a/utils/split_stl.pl +++ b/utils/split_stl.pl @@ -25,7 +25,7 @@ my %opt = (); } { - my $mesh = Slic3r::STL->read_file($ARGV[0]); + my $mesh = Slic3r::Format::STL->read_file($ARGV[0]); my $basename = $ARGV[0]; $basename =~ s/\.stl$//i; @@ -53,7 +53,7 @@ my %opt = (); my $output_file = sprintf '%s_%02d.stl', $basename, ++$part_count; printf "Writing to %s\n", basename($output_file); my $new_mesh = Slic3r::TriangleMesh->new(facets => \@facets, vertices => $mesh->vertices); - Slic3r::STL->write_file($output_file, $new_mesh, !$opt{ascii}); + Slic3r::Format::STL->write_file($output_file, $new_mesh, !$opt{ascii}); } } diff --git a/utils/stl-to-amf.pl b/utils/stl-to-amf.pl index 32aed21bc..f4805369b 100755 --- a/utils/stl-to-amf.pl +++ b/utils/stl-to-amf.pl @@ -24,7 +24,7 @@ my %opt = (); } { - my @meshes = map Slic3r::STL->read_file($_), @ARGV; + my @meshes = map Slic3r::Format::STL->read_file($_), @ARGV; my $output_file = $ARGV[0]; $output_file =~ s/\.stl$/.amf.xml/i; @@ -40,7 +40,7 @@ my %opt = (); } printf "Writing to %s\n", basename($output_file); - Slic3r::AMF->write_file($output_file, $materials, $meshes_by_material); + Slic3r::Format::AMF->write_file($output_file, $materials, $meshes_by_material); }