mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	Refactoring: moved Slic3r::STL and Slic3r::AMF to Slic3r::Format::*
This commit is contained in:
		
							parent
							
								
									2a86932cfe
								
							
						
					
					
						commit
						959230b099
					
				
					 9 changed files with 18 additions and 18 deletions
				
			
		
							
								
								
									
										6
									
								
								MANIFEST
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								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 | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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, | ||||
|  | @ -1,4 +1,4 @@ | |||
| package Slic3r::AMF::Parser; | ||||
| package Slic3r::Format::AMF::Parser; | ||||
| use strict; | ||||
| use warnings; | ||||
| 
 | ||||
|  | @ -1,4 +1,4 @@ | |||
| package Slic3r::STL; | ||||
| package Slic3r::Format::STL; | ||||
| use Moo; | ||||
| 
 | ||||
| use Slic3r::Geometry qw(X Y Z triangle_normal); | ||||
|  | @ -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 { | ||||
|  |  | |||
|  | @ -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}); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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}); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci