Graphics-Penplotter-GcodeXY
view release on metacpan or search on metacpan
lib/Graphics/Penplotter/GcodeXY/Geometry3D.pm view on Meta::CPAN
}
sub mesh_from_obj ($self, $str) {
my (@verts, @faces);
for my $line (split /\n/, $str) {
$line =~ s/^\s+//;
if ($line =~ /^v\s+([\d.eE+\-]+)\s+([\d.eE+\-]+)\s+([\d.eE+\-]+)/) {
push @verts, [$1+0, $2+0, $3+0];
}
elsif ($line =~ /^f\s+(\S+)\s+(\S+)\s+(\S+)/) {
my @idx = map { (split m{/}, $_)[0] - 1 } ($1,$2,$3);
push @faces, \@idx;
}
}
return $self->mesh(\@verts, \@faces);
}
# ==========================================================================
# SECTION: Mesh I/O -- STL (ASCII)
# ==========================================================================
( run in 0.517 second using v1.01-cache-2.11-cpan-71847e10f99 )