push @$output, $t;
}
+#---------- set-fa ----------
+
+sub op__set_fa () {
+ $fa = shift_arg;
+}
+
#---------- project-cylinder ----------
our $project_cylinder_radius;
our $project_cylinder_max_d_theta;
-sub project_cylinder_need_subdivide () {
- foreach my $t (@$triangles) {
- my @thetas = map { $_->[0] / $project_cylinder_radius } @$t;
+sub project_cylinder_triangle_need_subdivide ($) {
+ my ($t) = @_;
+ my @thetas = map { $_->[0] / $project_cylinder_radius } @$t;
- foreach my $ix (0..2) {
- if (abs($thetas[$ix] - $thetas[($ix+1)%3])
- > $project_cylinder_max_d_theta) {
- return 1;
- }
+ foreach my $ix (0..2) {
+ if (abs($thetas[$ix] - $thetas[($ix+1)%3])
+ > $project_cylinder_max_d_theta) {
+ return 1;
}
}
return 0;
$project_cylinder_radius = shift_arg;
$project_cylinder_max_d_theta = $fa * TAU/360;
- while (project_cylinder_need_subdivide()) {
- $output = [];
- foreach my $t (@$triangles) {
+ my @small_enough = ();
+ while (my $t = shift @$triangles) {
+ if (!project_cylinder_triangle_need_subdivide $t) {
+ push @small_enough, $t;
+ } else {
+ local $output = $triangles;
subdivide_triangle $t, \&append_triangle;
}
- $triangles = $output;
}
+ $triangles = \@small_enough;
+
$output = [];
foreach my $t (@$triangles) {
project_cylinder_tri $t;