Skip to content

Commit

Permalink
the +STL notation now properly causes CAD::Mesh3D->import() to enable…
Browse files Browse the repository at this point in the history
…Format('STL')
  • Loading branch information
pryrt committed Feb 26, 2019
1 parent c315a71 commit 8bfdf6e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
14 changes: 8 additions & 6 deletions lib/CAD/Mesh3D.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ our %EXPORT_TAGS = (

sub import
{
my @list = @_;
my @passthru;

# pass most arguments thru, but if it starts with +, then try to enable that format
foreach (@_) {
if( /^\+/ ) {
s/^\+//;
enableFormat($_);
foreach my $arg (@list) {
next unless defined $arg;
if( $arg =~ /^\+/ ) {
$arg =~ s/^\+//;
enableFormat($arg);
next;
}
push @passthru, $_;
push @passthru, $arg;
}
CAD::Mesh3D->export_to_level(1, @passthru);
}
Expand Down Expand Up @@ -350,7 +352,7 @@ sub enableFormat {
my $formatName = defined $_[0] ? $_[0] : croak "!ERROR! enableFormat(...): requires name of format";
my $formatModule = defined $_[1] ? $_[1] : "CAD::Mesh3D::$formatName";
(my $key = $formatModule . '.pm') =~ s{::}{/}g;
eval { require $formatModule unless exists $INC{$key}; 1; } or do {
eval { require $key unless exists $INC{$key}; 1; } or do {
local $" = ", ";
croak "!ERROR! enableFormat( @_ ): \n\tcould not import $formatModule\n\t$@";
};
Expand Down
2 changes: 1 addition & 1 deletion t/30-outputStl.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strict;
use warnings;
use Test::More tests => 5 + 5*28 + 3;

use CAD::Mesh3D qw(:all);
use CAD::Mesh3D qw(+STL :all);
use CAD::Mesh3D::STL qw(outputStl);

my $lft = createVertex(0,0,0);
Expand Down
4 changes: 1 addition & 3 deletions t/40-format.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use warnings;
use Test::More tests => 21;
use Test::Exception;

use CAD::Mesh3D qw(:all);
use CAD::Mesh3D::STL ();
enableFormat('STL');
use CAD::Mesh3D qw(+STL :all);

sub test_format {
my $format = shift;
Expand Down
3 changes: 1 addition & 2 deletions t/99-fault.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use warnings;
use Test::More tests => 48;
use Test::Exception;

use CAD::Mesh3D qw(:all);
use CAD::Mesh3D qw(+STL :all);
use CAD::Mesh3D::STL qw(outputStl);


################################################################
# error handling
################################################################
Expand Down

0 comments on commit 8bfdf6e

Please sign in to comment.