Comparar commits

..

12 Commits

Autor SHA1 Mensagem Data
Tim Kuipers c0495edf48 fix: turn off fans if fans are disabled (CURA-2603) 2016-10-11 16:42:56 +02:00
Tim Kuipers 1574292945 fix: forgot to write retractions with given precision (CURA-2619) 2016-10-11 16:14:01 +02:00
Tim Kuipers ed3f9f107c fix: only wipe on prime tower when enabled (CURA-2605) 2016-10-11 15:55:05 +02:00
Tim Kuipers 18bf08a1b5 fix: retrieve adhesion_type globally (CURA-2605) 2016-10-11 15:00:51 +02:00
Tim Kuipers f30c309249 Merge branch 'master' of github.com:Ultimaker/CuraEngine 2016-10-10 16:08:31 +02:00
Tim Kuipers af3536b307 Merge remote-tracking branch 'remotes/origin/feature_remove_trailing_zeros' 2016-10-10 16:08:22 +02:00
Tim Kuipers 8aed4c9139 Merge pull request #399 from Renha/master
Extra dollars removed from readme.
2016-10-10 15:48:30 +02:00
Renha 03fa1c2d37 Extra dollars removed from readme.
There are no need to write $s twice.
2016-10-10 16:40:49 +03:00
Ghostkeeper fb7cd6a572 Fix indenting
Contributes to issue CURA-1962.
2016-09-30 16:26:39 +02:00
Tim Kuipers 1de4107ea6 refactor: also use my own << operator for writing integers to stream (CURA-1962) 2016-09-30 15:30:59 +02:00
Tim Kuipers 6306321007 lil fixes (CURA-1962) 2016-09-30 15:26:55 +02:00
Tim Kuipers 7281e2187e feat: faster double to stream without trailing zeros (CURA-1962) 2016-09-30 15:26:14 +02:00
6 arquivos alterados com 112 adições e 47 exclusões
+5 -5
Ver Arquivo
@@ -39,11 +39,11 @@ Installing Protobuf
-------------------
1. Be sure to have libtool installed.
2. Download protobuf from https://github.com/google/protobuf/releases (download ZIP and unZIP at desired location, or clone the repo). The protocol buffer is used for communication between the CuraEngine and the GUI.
3. Run ```$ autogen.sh``` from the protobuf directory:
$ ```$ ./autogen.sh```
4. $ ```$ ./configure```
5. $ ```$ make```
6. $ ```# make install```
3. Run ```autogen.sh``` from the protobuf directory:
```$ ./autogen.sh```
4. ```$ ./configure```
5. ```$ make```
6. ```# make install```
(Please note the ```#```. It indicates the need of superuser, as known as root, priviliges.)
7. (In case the shared library cannot be loaded, you can try ```sudo ldconfig``` on Linux systems)
+7 -4
Ver Arquivo
@@ -109,6 +109,11 @@ void FffGcodeWriter::setConfigFanSpeedLayerTime(SliceDataStorage& storage)
fan_speed_layer_time_settings.cool_fan_speed_max = train->getSettingInPercentage("cool_fan_speed_max");
fan_speed_layer_time_settings.cool_min_speed = train->getSettingInMillimetersPerSecond("cool_min_speed");
fan_speed_layer_time_settings.cool_fan_full_layer = train->getSettingAsLayerNumber("cool_fan_full_layer");
if (!train->getSettingBoolean("cool_fan_enabled"))
{
fan_speed_layer_time_settings.cool_fan_speed_min = 0;
fan_speed_layer_time_settings.cool_fan_speed_max = 0;
}
}
}
@@ -393,8 +398,7 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
if (layer_nr < 0)
{
#ifdef DEBUG
const ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("adhesion_extruder_nr"));
assert(train.getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT && "negative layer_number means post-raft, pre-model layer!");
assert(getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT && "negative layer_number means post-raft, pre-model layer!");
#endif // DEBUG
const int filler_layer_count = Raft::getFillerLayerCount(storage);
layer_thickness = Raft::getFillerLayerHeight(storage);
@@ -410,8 +414,7 @@ void FffGcodeWriter::processLayer(SliceDataStorage& storage, int layer_nr, unsig
z = storage.meshes[0].layers[layer_nr].printZ;
if (layer_nr == 0)
{
const ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("adhesion_extruder_nr"));
if (train.getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT)
if (getSettingAsPlatformAdhesion("adhesion_type") == EPlatformAdhesion::RAFT)
{
include_helper_parts = false;
}
+4 -1
Ver Arquivo
@@ -185,7 +185,10 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, GCodePlanner& gcode
wipe = false;
}
// pre-wipe:
preWipe(storage, gcodeLayer, new_extruder);
if (wipe)
{
preWipe(storage, gcodeLayer, new_extruder);
}
addToGcode_denseInfill(storage, gcodeLayer, gcode, layer_nr, prev_extruder);
+21 -32
Ver Arquivo
@@ -7,7 +7,7 @@
#include "utils/logoutput.h"
#include "PrintFeature.h"
#include "utils/Date.h"
#include "utils/string.h" // writeInt2mm
#include "utils/string.h" // MMtoStream, PrecisionedDouble
namespace cura {
@@ -494,7 +494,7 @@ void GCodeExport::writeMoveBFB(int x, int y, int z, double speed, double extrusi
{
//fprintf(f, "; %f e-per-mm %d mm-width %d mm/s\n", extrusion_per_mm, lineWidth, speed);
//fprintf(f, "M108 S%0.1f\r\n", rpm);
*output_stream << "M108 S" << std::setprecision(1) << rpm << new_line;
*output_stream << "M108 S" << PrecisionedDouble{1, rpm} << new_line;
currentSpeed = double(rpm);
}
//Add M101 or M201 to enable the proper extruder.
@@ -519,13 +519,8 @@ void GCodeExport::writeMoveBFB(int x, int y, int z, double speed, double extrusi
extruder_attr[current_extruder].retraction_e_amount_current = 1.0; // 1.0 used as stub; BFB doesn't use the actual retraction amount; it performs retraction on the firmware automatically
}
}
*output_stream << "G1 X";
writeInt2mm(gcode_pos.X, *output_stream);
*output_stream << " Y";
writeInt2mm(gcode_pos.Y, *output_stream);
*output_stream << " Z";
writeInt2mm(z, *output_stream);
*output_stream << std::setprecision(1) << " F" << fspeed << new_line;
*output_stream << "G1 X" << MMtoStream{gcode_pos.X} << " Y" << MMtoStream{gcode_pos.Y} << " Z" << MMtoStream{z};
*output_stream << " F" << PrecisionedDouble{1, fspeed} << new_line;
currentPosition = Point3(x, y, z);
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), speed);
@@ -561,9 +556,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
Point3 diff = Point3(x,y,z) - getPosition();
if (isZHopped > 0)
{
*output_stream << "G1 Z";
writeInt2mm(currentPosition.z, *output_stream);
*output_stream << new_line;
*output_stream << "G1 Z" << MMtoStream{currentPosition.z} << new_line;
isZHopped = 0;
}
double prime_volume = extruder_attr[current_extruder].prime_volume;
@@ -576,7 +569,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
//Assume default UM2 retraction settings.
if (prime_volume > 0)
{
*output_stream << "G1 F" << std::setprecision(1) << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << new_line;
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
}
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), 25.0);
@@ -584,7 +577,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
else
{
current_e_value += extruder_attr[current_extruder].retraction_e_amount_current;
*output_stream << "G1 F" << std::setprecision(1) << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << new_line;
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
}
@@ -596,7 +589,7 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
}
else if (prime_volume > 0.0)
{
*output_stream << "G1 F" << std::setprecision(1) << (extruder_attr[current_extruder].last_retraction_prime_speed * 60) << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value << new_line;
*output_stream << "G1 F" << PrecisionedDouble{1, extruder_attr[current_extruder].last_retraction_prime_speed * 60} << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = extruder_attr[current_extruder].last_retraction_prime_speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
}
@@ -613,21 +606,17 @@ void GCodeExport::writeMove(int x, int y, int z, double speed, double extrusion_
if (currentSpeed != speed)
{
*output_stream << " F" << std::setprecision(1) << (speed * 60);
*output_stream << " F" << PrecisionedDouble{1, speed * 60};
currentSpeed = speed;
}
*output_stream << " X";
writeInt2mm(gcode_pos.X, *output_stream);
*output_stream << " Y";
writeInt2mm(gcode_pos.Y, *output_stream);
*output_stream << " X" << MMtoStream{gcode_pos.X} << " Y" << MMtoStream{gcode_pos.Y};
if (z != currentPosition.z + isZHopped)
{
*output_stream << " Z";
writeInt2mm(z + isZHopped, *output_stream);
*output_stream << " Z" << MMtoStream{z + isZHopped};
}
if (extrusion_mm3_per_mm > 0.000001)
*output_stream << " " << extruder_attr[current_extruder].extruderCharacter << std::setprecision(5) << current_e_value;
*output_stream << " " << extruder_attr[current_extruder].extruderCharacter << PrecisionedDouble{5, current_e_value};
*output_stream << new_line;
currentPosition = Point3(x, y, z);
@@ -702,8 +691,8 @@ void GCodeExport::writeRetraction(RetractionConfig* config, bool force, bool ext
{
double speed = ((retraction_diff_e_amount < 0.0)? config->speed : extr_attr.last_retraction_prime_speed) * 60;
current_e_value += retraction_diff_e_amount;
*output_stream << "G1 F" << speed << " "
<< extr_attr.extruderCharacter << std::setprecision(5) << current_e_value << new_line;
*output_stream << "G1 F" << PrecisionedDouble{1, speed} << " "
<< extr_attr.extruderCharacter << PrecisionedDouble{5, current_e_value} << new_line;
currentSpeed = speed;
estimateCalculator.plan(TimeEstimateCalculator::Position(INT2MM(currentPosition.x), INT2MM(currentPosition.y), INT2MM(currentPosition.z), eToMm(current_e_value)), currentSpeed);
extr_attr.last_retraction_prime_speed = config->primeSpeed;
@@ -719,7 +708,7 @@ void GCodeExport::writeZhopStart(int hop_height)
if (hop_height > 0)
{
isZHopped = hop_height;
*output_stream << std::setprecision(3) << "G1 Z" << INT2MM(currentPosition.z + isZHopped) << new_line;
*output_stream << "G1 Z" << MMtoStream{currentPosition.z + isZHopped} << new_line;
}
}
@@ -808,7 +797,7 @@ void GCodeExport::writeFanCommand(double speed)
if (flavor == EGCodeFlavor::MAKERBOT)
*output_stream << "M126 T0" << new_line; //value = speed * 255 / 100 // Makerbot cannot set fan speed...;
else
*output_stream << "M106 S" << std::setprecision(1) << (speed * 255 / 100) << new_line;
*output_stream << "M106 S" << PrecisionedDouble{1, speed * 255 / 100} << new_line;
}
else
{
@@ -834,7 +823,7 @@ void GCodeExport::writeTemperatureCommand(int extruder, double temperature, bool
#ifdef ASSERT_INSANE_OUTPUT
assert(temperature >= 0);
#endif // ASSERT_INSANE_OUTPUT
*output_stream << " S" << std::setprecision(1) << temperature << new_line;
*output_stream << " S" << PrecisionedDouble{1, temperature} << new_line;
extruder_attr[extruder].currentTemperature = temperature;
}
@@ -844,14 +833,14 @@ void GCodeExport::writeBedTemperatureCommand(double temperature, bool wait)
*output_stream << "M190 S";
else
*output_stream << "M140 S";
*output_stream << std::setprecision(1) << temperature << new_line;
*output_stream << PrecisionedDouble{1, temperature} << new_line;
}
void GCodeExport::writeAcceleration(double acceleration)
{
if (current_acceleration != acceleration)
{
*output_stream << "M204 S" << std::setprecision(0) << acceleration << new_line; // Print and Travel acceleration
*output_stream << "M204 S" << PrecisionedDouble{0, acceleration} << new_line; // Print and Travel acceleration
current_acceleration = acceleration;
estimateCalculator.setAcceleration(acceleration);
}
@@ -869,7 +858,7 @@ void GCodeExport::writeJerk(double jerk)
{
*output_stream << "M205 X";
}
*output_stream << std::setprecision(2) << jerk << new_line;
*output_stream << PrecisionedDouble{2, jerk} << new_line;
current_jerk = jerk;
estimateCalculator.setMaxXyJerk(jerk);
}
@@ -879,7 +868,7 @@ void GCodeExport::writeMaxZFeedrate(double max_z_feedrate)
{
if (current_max_z_feedrate != max_z_feedrate)
{
*output_stream << "M203 Z" << std::setprecision(1) << int(max_z_feedrate * 60) << new_line;
*output_stream << "M203 Z" << int(max_z_feedrate * 60) << new_line;
current_max_z_feedrate = max_z_feedrate;
estimateCalculator.setMaxZFeedrate(max_z_feedrate);
}
+3 -4
Ver Arquivo
@@ -39,7 +39,7 @@ int Raft::getTotalThickness(const SliceDataStorage& storage)
int Raft::getZdiffBetweenRaftAndLayer1(const SliceDataStorage& storage)
{
const ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("adhesion_extruder_nr"));
if (train.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::RAFT)
if (storage.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::RAFT)
{
return 0;
}
@@ -62,10 +62,9 @@ int Raft::getFillerLayerCount(const SliceDataStorage& storage)
int Raft::getFillerLayerHeight(const SliceDataStorage& storage)
{
const ExtruderTrain& train = *storage.meshgroup->getExtruderTrain(storage.getSettingAsIndex("adhesion_extruder_nr"));
const int64_t normal_layer_height = storage.getSettingInMicrons("layer_height");
if (train.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::RAFT)
if (storage.getSettingAsPlatformAdhesion("adhesion_type") != EPlatformAdhesion::RAFT)
{
const int64_t normal_layer_height = storage.getSettingInMicrons("layer_height");
return normal_layer_height;
}
const unsigned int filler_layer_height = round_divide(getZdiffBetweenRaftAndLayer1(storage), getFillerLayerCount(storage));
+72 -1
Ver Arquivo
@@ -27,7 +27,7 @@ static inline int stringcasecompare(const char* a, const char* b)
* \param coord The micron unit to convert
* \param ss The output stream to write the string to
*/
static inline void writeInt2mm(int64_t coord, std::ostream& ss)
static inline void writeInt2mm(const int64_t coord, std::ostream& ss)
{
char buffer[24];
int char_count = sprintf(buffer, "%ld", coord); // convert int to string
@@ -76,5 +76,76 @@ static inline void writeInt2mm(int64_t coord, std::ostream& ss)
}
}
/*!
* Struct to make it possible to inline calls to writeInt2mm with writing other stuff to the output stream
*/
struct MMtoStream
{
int64_t value; //!< The coord in micron
friend inline std::ostream& operator<< (std::ostream& out, const MMtoStream precision_and_input)
{
writeInt2mm(precision_and_input.value, out);
return out;
}
};
/*!
* Efficient writing of a double to a stringstream
*
* writes with \p precision digits after the decimal dot, but removes trailing zeros
*
* \warning only works with precision up to 9 and input up to 10^14
*
* \param precision The number of (non-zero) digits after the decimal dot
* \param coord double to output
* \param ss The output stream to write the string to
*/
static inline void writeDoubleToStream(const unsigned int precision, const double coord, std::ostream& ss)
{
char format[5] = "%.xf"; // write a float with [x] digits after the dot
format[2] = '0' + precision; // set [x]
char buffer[24];
int char_count = snprintf(buffer, 24, format, coord);
if (char_count <= 0)
{
return;
}
if (buffer[char_count - precision - 1] == '.')
{
int non_nul_pos = char_count - 1;
while (buffer[non_nul_pos] == '0')
{
non_nul_pos--;
}
if (buffer[non_nul_pos] == '.')
{
buffer[non_nul_pos] = '\0';
}
else
{
buffer[non_nul_pos + 1] = '\0';
}
}
ss << buffer;
}
/*!
* Struct to make it possible to inline calls to writeDoubleToStream with writing other stuff to the output stream
*/
struct PrecisionedDouble
{
unsigned int precision; //!< Number of digits after the decimal mark with which to convert to string
double value; //!< The double value
friend inline std::ostream& operator<< (std::ostream& out, const PrecisionedDouble precision_and_input)
{
writeDoubleToStream(precision_and_input.precision, precision_and_input.value, out);
return out;
}
};
}//namespace cura
#endif//UTILS_STRING_H