Skip to content

Commit

Permalink
Remove dpi option
Browse files Browse the repository at this point in the history
  • Loading branch information
eyal0 committed Mar 6, 2019
1 parent c24f63c commit 7a81066
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 74 deletions.
29 changes: 11 additions & 18 deletions autoleveller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ boost::format silent_format(const string &f_string)
}

autoleveller::autoleveller( const boost::program_options::variables_map &options, uniqueCodes *ocodes,
uniqueCodes *globalVars, double quantization_error, double xoffset, double yoffset,
uniqueCodes *globalVars, double xoffset, double yoffset,
const struct Tiling::TileInfo tileInfo ) :
input_unitconv( options["metric"].as<bool>() ? 1.0/25.4 : 1),
output_unitconv( options["metricoutput"].as<bool>() ? 25.4 : 1),
Expand All @@ -75,7 +75,6 @@ autoleveller::autoleveller( const boost::program_options::variables_map &options
probeOn( boost::replace_all_copy(options["al-probe-on"].as<string>(), "@", "\n") ),
probeOff( boost::replace_all_copy(options["al-probe-off"].as<string>(), "@", "\n") ),
software( options["software"].as<Software::Software>() ),
quantization_error( quantization_error * cfactor ),
xoffset( xoffset ),
yoffset( yoffset ),
g01InterpolatedNum( ocodes->getUniqueCode() ),
Expand Down Expand Up @@ -120,7 +119,6 @@ bool autoleveller::prepareWorkarea(const vector<pair<coordinate_type_fp, vector<
box_type_fp workarea;
double workareaLenX;
double workareaLenY;
int temp;

workarea = computeWorkarea(toolpaths);
workarea.min_corner().x(workarea.min_corner().x() - xoffset);
Expand All @@ -136,27 +134,22 @@ bool autoleveller::prepareWorkarea(const vector<pair<coordinate_type_fp, vector<
startPointX = workarea.min_corner().x() * cfactor;
startPointY = workarea.min_corner().y() * cfactor;

temp = ceil(workareaLenX / XProbeDistRequired); //We need at least 2 probe points
if( temp > 1 )
numXPoints = temp + 1;
else
numXPoints = 2;
numXPoints = ceil(workareaLenX / XProbeDistRequired) + 1;
numXPoints = std::max(2U, numXPoints); //We need at least 2 probe points

temp = ceil(workareaLenY / YProbeDistRequired); //We need at least 2 probe points
if( temp > 1 )
numYPoints = temp + 1;
else
numYPoints = 2;
numYPoints = ceil(workareaLenY / YProbeDistRequired) + 1; //We need at least 2 probe points
numYPoints = std::max(2U, numYPoints); //We need at least 2 probe points

XProbeDist = workareaLenX / ( numXPoints - 1 );
YProbeDist = workareaLenY / ( numYPoints - 1 );
averageProbeDist = ( XProbeDist + YProbeDist ) / 2;

if( ( software == Software::LINUXCNC && numXPoints * numYPoints > 4501 ) ||
( software != Software::LINUXCNC && numXPoints * numYPoints > 500 ) )
return false;
else
return true;
if((software == Software::LINUXCNC && numXPoints * numYPoints > 4501) ||
(software != Software::LINUXCNC && numXPoints * numYPoints > 500)) {
return false;
} else {
return true;
}
}

void autoleveller::header( std::ofstream &of )
Expand Down
3 changes: 1 addition & 2 deletions autoleveller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class autoleveller
public:
// The constructor just initialize the common parameters variables (parameters are in inches)
autoleveller( const boost::program_options::variables_map &options, uniqueCodes *ocodes,
uniqueCodes *globalVars, double quantization_error, double xoffset, double yoffset,
uniqueCodes *globalVars, double xoffset, double yoffset,
const struct Tiling::TileInfo tileInfo );

// prepareWorkarea computes the area of the milling project and computes the required number of probe
Expand Down Expand Up @@ -113,7 +113,6 @@ class autoleveller
const std::string probeOn;
const std::string probeOff;
const Software::Software software;
const double quantization_error;
const double xoffset;
const double yoffset;

Expand Down
7 changes: 1 addition & 6 deletions board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ typedef pair<string, shared_ptr<Layer> > layer_t;
/*
*/
/******************************************************************************/
Board::Board(int dpi, bool fill_outline, string outputdir, bool tsp_2opt,
Board::Board(bool fill_outline, string outputdir, bool tsp_2opt,
MillFeedDirection::MillFeedDirection mill_feed_direction, bool invert_gerbers,
bool render_paths_to_shapes) :
margin(0.0),
dpi(dpi),
fill_outline(fill_outline),
outputdir(outputdir),
tsp_2opt(tsp_2opt),
Expand All @@ -67,10 +66,6 @@ double Board::get_height() {
return layers.begin()->second->surface->get_height_in();
}

unsigned int Board::get_dpi() {
return dpi;
}

void Board::prepareLayer(string layername, shared_ptr<LayerImporter> importer, shared_ptr<RoutingMill> manufacturer, bool backside) {
// see comment for prep_t in board.hpp
prepared_layers.insert(std::make_pair(layername, make_tuple(importer, manufacturer, backside)));
Expand Down
5 changes: 1 addition & 4 deletions board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
class Board
{
public:
Board(int dpi,
bool fill_outline,
Board(bool fill_outline,
std::string outputdir, bool tsp_2opt,
MillFeedDirection::MillFeedDirection mill_feed_direction, bool invert_gerbers,
bool render_paths_to_shapes);
Expand All @@ -71,11 +70,9 @@ class Board
std::vector<std::pair<coordinate_type_fp, std::vector<std::shared_ptr<icoords>>>> get_toolpath(std::string layername);

void createLayers(); // should be private
unsigned int get_dpi();

private:
ivalue_t margin;
const unsigned int dpi;
const bool fill_outline;
const std::string outputdir;
const bool tsp_2opt;
Expand Down
1 change: 0 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ void do_pcb2gcode(int argc, const char* argv[]) {

shared_ptr<Board> board(
new Board(
vm["dpi"].as<int>(),
vm["fill-outline"].as<bool>(),
outputdir,
vm["tsp-2opt"].as<bool>(),
Expand Down
12 changes: 3 additions & 9 deletions ngc_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ using boost::format;

#include "units.hpp"

/******************************************************************************/
/*
*/
/******************************************************************************/
NGC_Exporter::NGC_Exporter(shared_ptr<Board> board)
: Exporter(board), dpi(board->get_dpi()),
quantization_error( 2.0 / dpi ), ocodes(1), globalVars(100)
{
this->board = board;
: Exporter(board), ocodes(1), globalVars(100) {
this->board = board;
}

/******************************************************************************/
Expand Down Expand Up @@ -127,7 +121,7 @@ void NGC_Exporter::export_all(boost::program_options::variables_map& options)
boost::optional<autoleveller> leveller = boost::none;
if ((options["al-front"].as<bool>() && layername == "front") ||
(options["al-back"].as<bool>() && layername == "back")) {
leveller.emplace(options, &ocodes, &globalVars, quantization_error,
leveller.emplace(options, &ocodes, &globalVars,
xoffset, yoffset, tileInfo);
}

Expand Down
2 changes: 0 additions & 2 deletions ngc_exporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ class NGC_Exporter: public Exporter
bool bMetricinput; //if true, input parameters are in metric units
bool bMetricoutput; //if true, metric g-code output
bool bZchangeG53;
const unsigned int dpi;
const double quantization_error;

bool bTile;

Expand Down
14 changes: 0 additions & 14 deletions options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ options::options()
("optimise", po::value<bool>()->default_value(true)->implicit_value(true),
"Reduce output file size by up to 40% while accepting a little loss of precision (enabled by default).")
("eulerian-paths", po::value<bool>()->default_value(true)->implicit_value(true), "Don't mill the same path twice if milling loops overlap. This can save up to 50% of milling time. Enabled by default.")
("dpi", po::value<int>()->default_value(1000), "virtual photoplot resolution")
("vectorial", po::value<bool>()->default_value(true)->implicit_value(true), "enable or disable the vectorial rendering engine")
("tsp-2opt", po::value<bool>()->default_value(true)->implicit_value(true), "use TSP 2OPT to find a faster toolpath (but slows down gcode generation)")
("path-finding-limit", po::value<size_t>()->default_value(0), "Use path finding for up to this many steps in the search (more is slower but makes a faster gcode path)")
Expand Down Expand Up @@ -350,19 +349,6 @@ static void check_generic_parameters(po::variables_map const& vm)

unit = vm["metric"].as<bool>() ? (1. / 25.4) : 1;

//---------------------------------------------------------------------------
//Check dpi parameter:

if (vm["dpi"].as<int>() < 100)
{
cerr << "Warning: very low DPI value." << endl;
}
else if (vm["dpi"].as<int>() > 10000)
{
cerr << "Warning: very high DPI value, processing may take extremely long"
<< endl;
}

//---------------------------------------------------------------------------
//Check spinup(down)-time parameters:

Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/am-test-extended/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=400

back=am-test.gbx

offset=0.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=400

back=am-test.gbx

offset=0.01
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/am-test-voronoi-front/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=400

front=am-test.gbx

offset=0.1
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/am-test-voronoi/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=400

back=am-test.gbx

offset=0.1
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/am-test/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=400

back=am-test.gbx

mill-diameters=0.2
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/dan/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=500

front=top.gbx
back=top_sr.gbx

Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/eaglecad1/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=1000

back=top-cop.gbx

offset=0.010
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/ekf2/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=1000

front=l3.grb
back=l4.grb
drill=drill0.exc
Expand Down
2 changes: 0 additions & 2 deletions testing/gerbv_example/jj/millproject
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dpi=500

back=l1-orig.grb

offset=0.5
Expand Down

0 comments on commit 7a81066

Please sign in to comment.