Ejemplo n.º 1
0
double SettingsBase::getSettingInMillimetersPerSecond(std::string key)
{
    std::string value = getSettingString(key);
    //  return std::max(1.0, atof(value.c_str()));

    return 1.0 > atof(value.c_str()) ? 1.0 : atof(value.c_str());
}
Ejemplo n.º 2
0
EPlatformAdhesion SettingsBaseVirtual::getSettingAsPlatformAdhesion(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "brim")
        return EPlatformAdhesion::BRIM;
    if (value == "raft")
        return EPlatformAdhesion::RAFT;
    return EPlatformAdhesion::SKIRT;
}
Ejemplo n.º 3
0
ESupportType SettingsBaseVirtual::getSettingAsSupportType(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "everywhere")
        return ESupportType::EVERYWHERE;
    if (value == "buildplate")
        return ESupportType::PLATFORM_ONLY;
    return ESupportType::NONE;
}
Ejemplo n.º 4
0
ESupportType SettingsBase::getSettingAsSupportType(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "Everywhere")
        return Support_Everywhere;
    if (value == "Touching Buildplate")
        return Support_PlatformOnly;
    return Support_None;
}
Ejemplo n.º 5
0
EPlatformAdhesion SettingsBase::getSettingAsPlatformAdhesion(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "Brim")
        return Adhesion_Brim;
    if (value == "Raft")
        return Adhesion_Raft;
    return Adhesion_Skirt;
}
Ejemplo n.º 6
0
FlowTempGraph SettingsBaseVirtual::getSettingAsFlowTempGraph(std::string key) const
{
    FlowTempGraph ret;
    const char* c_str = getSettingString(key).c_str();
    char const* char_p = c_str;
    while (*char_p != '[')
    {
        if (*char_p == '\0') //We've reached the end of string without encountering the first opening bracket.
        {
            return ret; //Empty at this point.
        }
        char_p++;
    }
    char_p++; // skip the '['
    for (; *char_p != '\0'; char_p++)
    {
        while (*char_p != '[')
        {
            if (*char_p == '\0') //We've reached the end of string without finding the next opening bracket.
            {
                return ret; //Don't continue parsing this item then. Just stop and return.
            }
            char_p++;
        }
        char_p++; // skip the '['
        char* end;
        double first = strtod(char_p, &end); //If not a valid number, this becomes zero.
        char_p = end;
        while (*char_p != ',')
        {
            if (*char_p == '\0') //We've reached the end of string without finding the comma.
            {
                return ret; //This entry is incomplete.
            }
            char_p++;
        }
        char_p++; // skip the ','
        double second = strtod(char_p, &end); //If not a valid number, this becomes zero.
        ret.data.emplace_back(first, second);
        char_p = end;
        while (*char_p != ']')
        {
            if (*char_p == '\0') //We've reached the end of string without finding the closing bracket.
            {
                return ret; //This entry is probably complete and has been added, but stop searching.
            }
            char_p++;
        }
        char_p++; // skip the ']'
        if (*char_p == ']' || *char_p == '\0')
        {
            break;
        }
    }
    return ret;
}
Ejemplo n.º 7
0
unsigned int SettingsBaseVirtual::getSettingAsLayerNumber(std::string key) const
{
    const unsigned int indicated_layer_number = stoul(getSettingString(key));
    if (indicated_layer_number < 1) //Input checking: Layer 0 is not allowed.
    {
        cura::logWarning("Invalid layer number %i for setting %s.", indicated_layer_number, key.c_str());
        return 0; //Assume layer 1.
    }
    return indicated_layer_number - 1; //Input starts counting at layer 1, but engine code starts counting at layer 0.
}
Ejemplo n.º 8
0
EZSeamType SettingsBaseVirtual::getSettingAsZSeamType(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "random")
        return EZSeamType::RANDOM;
    if (value == "shortest")
        return EZSeamType::SHORTEST;
    if (value == "back")
        return EZSeamType::BACK;
    return EZSeamType::SHORTEST;
}
Ejemplo n.º 9
0
bool SettingsBase::getSettingBoolean(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "on")
        return true;
    if (value == "yes")
        return true;
    if (value == "true" or value == "True") //Python uses "True"
        return true;
    return atoi(value.c_str()) != 0;
}
Ejemplo n.º 10
0
ESurfaceMode SettingsBaseVirtual::getSettingAsSurfaceMode(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "normal")
        return ESurfaceMode::NORMAL;
    if (value == "surface")
        return ESurfaceMode::SURFACE;
    if (value == "both")
        return ESurfaceMode::BOTH;
    return ESurfaceMode::NORMAL;
}
Ejemplo n.º 11
0
bool SettingsBaseVirtual::getSettingBoolean(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "on")
        return true;
    if (value == "yes")
        return true;
    if (value == "true" or value == "True") //Python uses "True"
        return true;
    int num = atoi(value.c_str());
    return num != 0;
}
Ejemplo n.º 12
0
SupportDistPriority SettingsBaseVirtual::getSettingAsSupportDistPriority(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "xy_overrides_z")
    {
        return SupportDistPriority::XY_OVERRIDES_Z;
    }
    if (value == "z_overrides_xy")
    {
        return SupportDistPriority::Z_OVERRIDES_XY;
    }
    return SupportDistPriority::XY_OVERRIDES_Z;
}
Ejemplo n.º 13
0
DraftShieldHeightLimitation SettingsBaseVirtual::getSettingAsDraftShieldHeightLimitation(const std::string key) const
{
    const std::string value = getSettingString(key);
    if (value == "full")
    {
        return DraftShieldHeightLimitation::FULL;
    }
    else if (value == "limited")
    {
        return DraftShieldHeightLimitation::LIMITED;
    }
    return DraftShieldHeightLimitation::FULL; //Default.
}
Ejemplo n.º 14
0
EFillMethod SettingsBaseVirtual::getSettingAsFillMethod(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "lines")
        return EFillMethod::LINES;
    if (value == "grid")
        return EFillMethod::GRID;
    if (value == "triangles")
        return EFillMethod::TRIANGLES;
    if (value == "concentric")
        return EFillMethod::CONCENTRIC;
    if (value == "zigzag")
        return EFillMethod::ZIG_ZAG;
    return EFillMethod::NONE;
}
Ejemplo n.º 15
0
EFillMethod SettingsBase::getSettingAsFillMethod(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "Lines")
        return Fill_Lines;
    if (value == "Grid")
        return Fill_Grid;
    if (value == "Triangles")
        return Fill_Triangles;
    if (value == "Concentric")
        return Fill_Concentric;
    if (value == "ZigZag")
        return Fill_ZigZag;
    return Fill_None;
}
Ejemplo n.º 16
0
FillPerimeterGapMode SettingsBaseVirtual::getSettingAsFillPerimeterGapMode(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "nowhere")
    {
        return FillPerimeterGapMode::NOWHERE;
    }
    if (value == "everywhere")
    {
        return FillPerimeterGapMode::EVERYWHERE;
    }
    if (value == "skin")
    {
        return FillPerimeterGapMode::SKIN;
    }
    return FillPerimeterGapMode::NOWHERE;
}
Ejemplo n.º 17
0
EGCodeFlavor SettingsBase::getSettingAsGCodeFlavor(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "RepRap")
        return GCODE_FLAVOR_REPRAP;
    else if (value == "UltiGCode")
        return GCODE_FLAVOR_ULTIGCODE;
    else if (value == "Makerbot")
        return GCODE_FLAVOR_MAKERBOT;
    else if (value == "BFB")
        return GCODE_FLAVOR_BFB;
    else if (value == "MACH3")
        return GCODE_FLAVOR_MACH3;
    else if (value == "RepRap (Volumatric)")
        return GCODE_FLAVOR_REPRAP_VOLUMATRIC;
    return GCODE_FLAVOR_REPRAP;
}
Ejemplo n.º 18
0
CombingMode SettingsBaseVirtual::getSettingAsCombingMode(std::string key)
{
    std::string value = getSettingString(key);
    if (value == "off")
    {
        return CombingMode::OFF;
    }
    if (value == "all")
    {
        return CombingMode::ALL;
    }
    if (value == "noskin")
    {
        return CombingMode::NO_SKIN;
    }
    return CombingMode::ALL;
}
Ejemplo n.º 19
0
EGCodeFlavor SettingsBaseVirtual::getSettingAsGCodeFlavor(std::string key) const
{
    std::string value = getSettingString(key);
    if (value == "Griffin")
        return EGCodeFlavor::GRIFFIN;
    else if (value == "UltiGCode")
        return EGCodeFlavor::ULTIGCODE;
    else if (value == "Makerbot")
        return EGCodeFlavor::MAKERBOT;
    else if (value == "BFB")
        return EGCodeFlavor::BFB;
    else if (value == "MACH3")
        return EGCodeFlavor::MACH3;
    else if (value == "RepRap (Volumatric)")
        return EGCodeFlavor::REPRAP_VOLUMATRIC;
    return EGCodeFlavor::REPRAP;
}
Ejemplo n.º 20
0
FlowTempGraph SettingsBaseVirtual::getSettingAsFlowTempGraph(std::string key) const
{
    FlowTempGraph ret;
    std::string value_string = getSettingString(key);
    if (value_string.empty())
    {
        return ret; //Empty at this point.
    }
    std::regex regex("(\\[([^,\\[]*),([^,\\]]*)\\])");
    // match with:
    // - the last opening bracket '['
    // - then a bunch of characters until the first comma
    // - a comma
    // - a bunch of cahracters until the first closing bracket ']'
    // matches with any substring which looks like "[  124.512 , 124.1 ]"

    // default constructor = end-of-sequence:
    std::regex_token_iterator<std::string::iterator> rend;

    int submatches[] = { 1, 2, 3 }; // match whole pair, first number and second number of a pair
    std::regex_token_iterator<std::string::iterator> match_iter(value_string.begin(), value_string.end(), regex, submatches);
    while (match_iter != rend)
    {
        match_iter++; // match the whole pair
        if (match_iter == rend)
        {
            break;
        }
        std::string first_substring = *match_iter++;
        std::string second_substring = *match_iter++;
        try
        {
            double first = std::stod(first_substring);
            double second = std::stod(second_substring);
            ret.data.emplace_back(first, second);
        }
        catch (const std::invalid_argument& e)
        {
            logError("Couldn't read 2D graph element [%s,%s] in setting '%s'. Ignored.\n", first_substring.c_str(), second_substring.c_str(), key.c_str());
        }
    }
    return ret;
}
Ejemplo n.º 21
0
void Lightcone::write() {
	stringstream ss;
	ss << OUTPUT_PATH;
	ss << getSettingString();
	ss << "." << "csv";
	outputFilePath = ss.str();

	ofstream file(ss.str().c_str());
	if (file.is_open()) {
		file << "x, y, z, sid, id\n";
		for (vector<Particle>::iterator it = mParticles.begin();
				it != mParticles.end(); it++) {
			file << it->x << ", " << it->y << ", " << it->z << ", " << it->sid
					<< "," << it->id << "\n";
		}
		printf("[SUCCESS] Saved Lightcone file to %s\n", ss.str().c_str());
	} else {
		printf("[FAIL] Unable to write to %s\n", ss.str().c_str());
	}
}
Ejemplo n.º 22
0
FlowTempGraph SettingsBaseVirtual::getSettingAsFlowTempGraph(std::string key)
{
    FlowTempGraph ret;
    const char* c_str = getSettingString(key).c_str();
    char const* char_p = c_str;
    while (*char_p != '[')
    {
        char_p++;
    }
    char_p++; // skip the '['
    for (; *char_p != '\0'; char_p++)
    {
        while (*char_p != '[')
        {
            char_p++;
        }
        char_p++; // skip the '['
        char* end;
        double first = strtod(char_p, &end);
        char_p = end;
        while (*char_p != ',')
        {
            char_p++;
        }
        char_p++; // skip the ','
        double second = strtod(char_p, &end);
        char_p = end;
        while (*char_p != ']')
        {
            char_p++;
        }
        char_p++; // skip the ']'
        ret.data.emplace_back(first, second);
        if (*char_p == ']')
        {
            break;
        }
    }
    return ret;
}
Ejemplo n.º 23
0
int SettingsBaseVirtual::getSettingAsCount(std::string key) const
{
    std::string value = getSettingString(key);
    return atoi(value.c_str());
}
Ejemplo n.º 24
0
int SettingsBaseVirtual::getSettingInMicrons(std::string key) const
{
    std::string value = getSettingString(key);
    return atof(value.c_str()) * 1000.0;
}
Ejemplo n.º 25
0
double SettingsBaseVirtual::getSettingInAngleRadians(std::string key) const
{
    std::string value = getSettingString(key);
    return atof(value.c_str()) / 180.0 * M_PI;
}
Ejemplo n.º 26
0
double SettingsBaseVirtual::getSettingInSeconds(std::string key) const
{
    std::string value = getSettingString(key);
    return std::max(0.0, atof(value.c_str()));
}
Ejemplo n.º 27
0
double SettingsBaseVirtual::getSettingInMillimetersPerSecond(std::string key) const
{
    std::string value = getSettingString(key);
    return std::max(1.0, atof(value.c_str()));
}
Ejemplo n.º 28
0
double SettingsBaseVirtual::getSettingInDegreeCelsius(std::string key) const
{
    std::string value = getSettingString(key);
    return atof(value.c_str());
}
Ejemplo n.º 29
0
String ProjectExporter::getLegacyModulePath() const
{
    return getSettingString ("juceFolder");
}
Ejemplo n.º 30
0
double SettingsBaseVirtual::getSettingInMillimeters(std::string key) const
{
    std::string value = getSettingString(key);
    return atof(value.c_str());
}