chiark
/
gitweb
/
~ianmdlvl
/
reprap-play.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0b7257c
)
distort-stl: new approach, wip fixes
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 7 Jan 2018 22:24:37 +0000
(22:24 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 7 Jan 2018 22:24:37 +0000
(22:24 +0000)
distort-stl
patch
|
blob
|
history
diff --git
a/distort-stl
b/distort-stl
index eb3a7a15deb92a6c393b45fd3db21f63426cab00..1b512f853a3a2cc6047878f6783573c7c725dbe4 100755
(executable)
--- a/
distort-stl
+++ b/
distort-stl
@@
-25,8
+25,11
@@
use strict;
use autodie;
use strict;
use autodie;
-use File::Temp;
use List::Util;
use List::Util;
+use POSIX;
+use File::Temp ();
+
+sub TAU () { M_PI * 2; }
our $fa = 10;
our $fa = 10;
@@
-38,19
+41,19
@@
sub shift_arg () {
}
sub subdivide_triangle ($$) {
}
sub subdivide_triangle ($$) {
- my ($
i
t, $fn) = @_;
+ my ($t, $fn) = @_;
my @mids;
foreach my $ix (0..2) {
my $jx = ($ix+1) % 3;
my @midp;
foreach my $ci (0..2) {
my @mids;
foreach my $ix (0..2) {
my $jx = ($ix+1) % 3;
my @midp;
foreach my $ci (0..2) {
- push @midp, 0.5 * ($
it->[$ix][$ci] + $i
t->[$jx][$ci]);
+ push @midp, 0.5 * ($
t->[$ix][$ci] + $
t->[$jx][$ci]);
}
push @mids, @midp;
}
foreach my $ix (0..2) {
my $kx = ($ix+2) % 3;
}
push @mids, @midp;
}
foreach my $ix (0..2) {
my $kx = ($ix+2) % 3;
- $fn->([ $
it->[$ix], $mids[$ix], $i
t->[$kx] ]);
+ $fn->([ $
t->[$ix], $mids[$ix], $
t->[$kx] ]);
}
$fn->(\@mids);
}
}
$fn->(\@mids);
}
@@
-61,22
+64,22
@@
our $project_cylinder_radius;
our $project_cylinder_max_d_theta;
sub project_cylinder_tri {
our $project_cylinder_max_d_theta;
sub project_cylinder_tri {
- my ($
i
t) = @_;
+ my ($t) = @_;
- my $radius = project_cylinder_radius;
+ my $radius =
$
project_cylinder_radius;
- my @thetas = map { $_->[0] / $radius } @$
i
t;
+ my @thetas = map { $_->[0] / $radius } @$t;
foreach my $ix (0..2) {
if (abs($thetas[$ix] - $thetas[($ix+1)%3])
> $project_cylinder_max_d_theta) {
foreach my $ix (0..2) {
if (abs($thetas[$ix] - $thetas[($ix+1)%3])
> $project_cylinder_max_d_theta) {
- subdivide_triangle $
i
t, \&project_cylinder_tri;
+ subdivide_triangle $t, \&project_cylinder_tri;
return;
}
}
my @ot;
return;
}
}
my @ot;
- foreach my $p (
@i
t) {
+ foreach my $p (
$
t) {
my ($x,$y,$z) = @$p;
my $r = $radius - $y;
my $theta = $x / $radius;
my ($x,$y,$z) = @$p;
my $r = $radius - $y;
my $theta = $x / $radius;
@@
-115,19
+118,21
@@
open I, "admesh $admesh_stdout $itmp |";
my $triangle;
while (<I>) {
my $triangle;
while (<I>) {
- if (m/^\s+outer\s+loop/) {
+ s/^\s*//;
+ if (m/^outer\s+loop/) {
die if $triangle;
$triangle = [];
die if $triangle;
$triangle = [];
- } elsif (s/^
\s+
vertex\s+//) {
+ } elsif (s/^vertex\s+//) {
my $lhs = $&;
s/\s+$//;
my @xyz = split /\s+/, $_;
die unless $triangle;
my $lhs = $&;
s/\s+$//;
my @xyz = split /\s+/, $_;
die unless $triangle;
- push @$triangle, \@xy
a
;
- } elsif (m/^
\s+
endloop/) {
+ push @$triangle, \@xy
z
;
+ } elsif (m/^endloop/) {
die unless @$triangle == 3;
push @triangles, $triangle;
die unless @$triangle == 3;
push @triangles, $triangle;
- } elsif (m/^\s+(?:solid|facet\s+normal|endfacet|endsolid)\s/) {
+ undef $triangle;
+ } elsif (m/^(?:solid|facet\s+normal|endfacet|endsolid)\s/) {
} else {
die "$_ ?";
}
} else {
die "$_ ?";
}