App-HPGL2Cadsoft

 view release on metacpan or  search on metacpan

lib/App/HPGL2Cadsoft.pm  view on Meta::CPAN


# And update the last location to ensure we create a valid line when the next command is PD again
                $pos_start = $pos_end;
            }
            else {
                $zero_length_stubs++;
            }
            next;
        }
        if ( $command =~ /IN/ ) {
            say "Init sequence found";
            next;
        }

        if ( $command =~ /SP(\d+)/ ) {
            say "Selected pen $1";
            next;
        }
       
        if ( $command =~ /^PU$/) {
            # Final PU command
            next;
        }

        carp "HPGL command not parsed: '$command'\n";
    }

lib/App/HPGL2Cadsoft.pm  view on Meta::CPAN

        push( @lines_scaled, [ $start_scaled, $stop_scaled ] );
    }  
    
    $self->_hpgl_lines(\@lines_scaled);
}

sub run {
    my $self = shift();
    
    my ($lines, $zero_stubs)= $self->_parse_hpgl();
    say "Found $lines valid segments in HPGL file";
    say "Skipped $zero_stubs segments with zero length";
    
    $self->_scale();
    $self->_calculate_bbox();
    
    # Report bounding box dimensions, maybe the user wants to change the scaling factor
       say "Object bounding box stretches from (x,y) to (x,y) in millimeter:";
    say "   ("
      . sprintf( '%.3f', $self->_bbox->min_x() ) . " "
      . sprintf( '%.3f', $self->_bbox->min_y() ) . ") ("
      . sprintf( '%.3f', $self->_bbox->max_x() ) . " "
      . sprintf( '%.3f', $self->_bbox->max_y() ) . ")";

    say
"Total dimensions in x and y directions with scaling factor " . $self->scaling_factor() . " in mm are:";
    say "   ("
      . sprintf( '%.3f', $self->_bbox->max_x() - $self->_bbox->min_x() ) . " "
      . sprintf( '%.3f', $self->_bbox->max_y() - $self->_bbox->min_y() ) . ")";
      
    $self->_write_script();
    
    say "Done!";
}


sub _calculate_bbox {
    my $self = shift();

    # Init min and max values to the first point in the dataset
    my $l = $self->_hpgl_lines()->[0]->[0];

# Create bounding box with min and max values to be equal to the first point in the dataset



( run in 1.736 second using v1.01-cache-2.11-cpan-a1f116cd669 )