Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 'x' qualified thumbnail dimensions #195

Open
wants to merge 1 commit into
base: release-v5.0.3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions crslice/gcode/gcode/parasegcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ namespace gcode

void Stringsplit(std::string str, const char split, std::vector<std::string>& res)
{
std::istringstream iss(str); // ������
std::string token; // ���ջ�����
while (getline(iss, token, split)) // ��splitΪ�ָ���
std::istringstream iss(str); // 输入流
std::string token; // 接收缓冲区
while (getline(iss, token, split)) // 以split为分隔符
{
removeSpace(token);
res.push_back(token);
Expand All @@ -264,7 +264,7 @@ namespace gcode

void getKvs(const std::string& comment, const SliceCompany& sliceCompany, std::unordered_map<std::string, std::string>& kvs)
{
//�ռ����еIJ�����Ϣ
//收集所有的参数信息
std::vector<std::string> _kvs;
switch (sliceCompany)
{
Expand Down Expand Up @@ -2026,7 +2026,7 @@ namespace gcode
iter = kvs.find("LAYER_HEIGHT");
if (iter != kvs.end())
{
////orca��ÿһ���ж������޸�ʱ��ֻȡ��һ�εIJ��ֵ�� ���֣����ղ�Ԥ���ϲ�
////orca当每一层有多个层高修改时,只取第一次的层高值, 表现:悬空层预览断层
//if (gCodeProcessor.sliceCompany == SliceCompany::bambu)
//{
// if (gCodeProcessor.isFirstLayerHeight)
Expand Down Expand Up @@ -2303,7 +2303,7 @@ namespace gcode
if (v.find("x") != std::string::npos)
{
std::vector<std::string> _vs;
Stringsplit(v, '*', _vs);
Stringsplit(v, 'x', _vs);
if (_vs.size() > 1)
{
imageSize.x = std::atoi(_vs[0].c_str());
Expand Down Expand Up @@ -2499,10 +2499,10 @@ namespace gcode
std::string removeTrailingNewline(std::string str) {
if (!str.empty() && str[str.size() - 1] == '\n') {
if (str.size() > 1 && str[str.size() - 2] == '\r') {
str.erase(str.size() - 2); // ȥ��"\r\n"
str.erase(str.size() - 2); // 去除"\r\n"
}
else {
str.erase(str.size() - 1); // ֻȥ��"\n"
str.erase(str.size() - 1); // 只去除"\n"
}
}
return str;
Expand Down Expand Up @@ -2596,7 +2596,7 @@ namespace gcode
process_filaments(gcodeProcessor, GCodeType::ToolChange);
gcodeProcessor.m_extruder_id = extruder_id;

//todo ���غIJ�ʱ��
//todo 加载耗材时间
}
}
pathData->getNotPath();
Expand Down Expand Up @@ -3443,7 +3443,7 @@ namespace gcode
}
}

//����
//设置参数
void _setParam(GCodeProcessor& gcodeProcessor)
{
std::unordered_map<std::string, std::string>& kvs = gcodeProcessor.kvs;
Expand All @@ -3459,13 +3459,13 @@ namespace gcode
//float machine_width;
//float machine_depth;
float materialLenth;
float materialDensity;//��λ����ܶ�
float material_diameter = { 1.75f }; //����ֱ��
float material_density = { 1.24f }; //�����ܶ�
float materialDensity;//单位面积密度
float material_diameter = { 1.75f }; //材料直径
float material_density = { 1.24f }; //材料密度
pathParam.materialLenth = std::atof(getValue(kvs, "filament_used").c_str());
pathParam.material_diameter = std::atof(getValue(kvs, "material_diameter").c_str());
pathParam.material_density = std::atof(getValue(kvs, "material_density").c_str());
pathParam.materialDensity = M_PI * (pathParam.material_diameter * 0.5) * (pathParam.material_diameter * 0.5) * pathParam.material_density;//��λ����ܶ�
pathParam.materialDensity = M_PI * (pathParam.material_diameter * 0.5) * (pathParam.material_diameter * 0.5) * pathParam.material_density;//单位面积密度
pathParam.lineWidth = std::atof(getValue(kvs, "wall_line_width").c_str());
pathParam.layerHeight = std::atof(getValue(kvs, "layer_height").c_str());
pathParam.cost = std::atof(getValue(kvs, "gcode_filament_cost").c_str());
Expand Down Expand Up @@ -3596,13 +3596,13 @@ namespace gcode
{
SliceCompany sliceCompany = SliceCompany::none;

//��ȡԭʼ����
//获取原始数据
_paraseGcode(sliceCompany,gCodeFile,box,m_sliceLayers,kvs);

//������ͨ�ò���
//解析成通用参数
//_paraseKvs(sliceCompany, box, kvs);

//������������
//过滤其他参数
_removeOthersKvs(kvs);
}

Expand All @@ -3619,15 +3619,15 @@ namespace gcode
//double weight = volume.second * extruder->filament_density() * 0.001;
//total_used_filament += volume.second / s;

//��ȡԭʼ����
//获取原始数据
trimesh::box3 box;
_paraseGcodeAndPreview(gCodeFile, gcodeProcessor, pathData, tracer);

//������ͨ�ò���
//解析成通用参数
_paraseKvs(gcodeProcessor, box);

//����
//设置参数
_setParam(gcodeProcessor);
pathData->setParam(gcodeProcessor.gcodeParaseInfo);
}
}
}