mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
NEW:step mesh add 'Split compound and compsolid'
Optimize getting STEP node names. Fix load_same_type_files() GITHUB: #5214 Change-Id: I7d1035c122f21e3b08305509489bce415634ae80 (cherry picked from commit 76a401bfca1897994795cb37ffa9cbcbdaca8b6c) (cherry picked from commit a0669137ec7e698320d0bc50ee986cb3f0e85164)
This commit is contained in:
parent
1e75686221
commit
588f42e2e2
8 changed files with 56 additions and 21 deletions
|
@ -416,6 +416,9 @@ void AppConfig::set_defaults()
|
||||||
set("linear_defletion", "0.003");
|
set("linear_defletion", "0.003");
|
||||||
set("angle_defletion", "0.5");
|
set("angle_defletion", "0.5");
|
||||||
}
|
}
|
||||||
|
if (get("is_split_compound").empty()) {
|
||||||
|
set_bool("is_split_compound", false);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove legacy window positions/sizes
|
// Remove legacy window positions/sizes
|
||||||
erase("app", "main_frame_maximized");
|
erase("app", "main_frame_maximized");
|
||||||
|
|
|
@ -165,16 +165,21 @@ int StepPreProcessor::preNum(const unsigned char byte) {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getNamedSolids(const TopLoc_Location& location, const std::string& prefix,
|
static void getNamedSolids(const TopLoc_Location& location,
|
||||||
unsigned int& id, const Handle(XCAFDoc_ShapeTool) shapeTool,
|
const std::string& prefix,
|
||||||
const TDF_Label label, std::vector<NamedSolid>& namedSolids) {
|
unsigned int& id,
|
||||||
|
const Handle(XCAFDoc_ShapeTool) shapeTool,
|
||||||
|
const TDF_Label label,
|
||||||
|
std::vector<NamedSolid>& namedSolids,
|
||||||
|
bool isSplitCompound = false) {
|
||||||
TDF_Label referredLabel{label};
|
TDF_Label referredLabel{label};
|
||||||
if (shapeTool->IsReference(label))
|
if (shapeTool->IsReference(label))
|
||||||
shapeTool->GetReferredShape(label, referredLabel);
|
shapeTool->GetReferredShape(label, referredLabel);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
Handle(TDataStd_Name) shapeName;
|
Handle(TDataStd_Name) shapeName;
|
||||||
if (referredLabel.FindAttribute(TDataStd_Name::GetID(), shapeName))
|
if (referredLabel.FindAttribute(TDataStd_Name::GetID(), shapeName) ||
|
||||||
|
label.FindAttribute(TDataStd_Name::GetID(), shapeName))
|
||||||
name = TCollection_AsciiString(shapeName->Get()).ToCString();
|
name = TCollection_AsciiString(shapeName->Get()).ToCString();
|
||||||
|
|
||||||
if (name == "" || !StepPreProcessor::isUtf8(name))
|
if (name == "" || !StepPreProcessor::isUtf8(name))
|
||||||
|
@ -185,7 +190,7 @@ static void getNamedSolids(const TopLoc_Location& location, const std::string& p
|
||||||
TDF_LabelSequence components;
|
TDF_LabelSequence components;
|
||||||
if (shapeTool->GetComponents(referredLabel, components)) {
|
if (shapeTool->GetComponents(referredLabel, components)) {
|
||||||
for (Standard_Integer compIndex = 1; compIndex <= components.Length(); ++compIndex) {
|
for (Standard_Integer compIndex = 1; compIndex <= components.Length(); ++compIndex) {
|
||||||
getNamedSolids(localLocation, fullName, id, shapeTool, components.Value(compIndex), namedSolids);
|
getNamedSolids(localLocation, fullName, id, shapeTool, components.Value(compIndex), namedSolids, isSplitCompound);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TopoDS_Shape shape;
|
TopoDS_Shape shape;
|
||||||
|
@ -196,12 +201,20 @@ static void getNamedSolids(const TopLoc_Location& location, const std::string& p
|
||||||
int i = 0;
|
int i = 0;
|
||||||
switch (shape_type) {
|
switch (shape_type) {
|
||||||
case TopAbs_COMPOUND:
|
case TopAbs_COMPOUND:
|
||||||
|
if (!isSplitCompound) {
|
||||||
|
namedSolids.emplace_back(TopoDS::Compound(transform.Shape()), fullName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TopAbs_COMPSOLID:
|
case TopAbs_COMPSOLID:
|
||||||
|
if (!isSplitCompound) {
|
||||||
|
namedSolids.emplace_back(TopoDS::CompSolid(transform.Shape()), fullName);
|
||||||
|
} else {
|
||||||
for (explorer.Init(transform.Shape(), TopAbs_SOLID); explorer.More(); explorer.Next()) {
|
for (explorer.Init(transform.Shape(), TopAbs_SOLID); explorer.More(); explorer.Next()) {
|
||||||
i++;
|
i++;
|
||||||
const TopoDS_Shape& currentShape = explorer.Current();
|
const TopoDS_Shape& currentShape = explorer.Current();
|
||||||
namedSolids.emplace_back(TopoDS::Solid(currentShape), fullName + "-SOLID-" + std::to_string(i));
|
namedSolids.emplace_back(TopoDS::Solid(currentShape), fullName + "-SOLID-" + std::to_string(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TopAbs_SOLID:
|
case TopAbs_SOLID:
|
||||||
namedSolids.emplace_back(TopoDS::Solid(transform.Shape()), fullName);
|
namedSolids.emplace_back(TopoDS::Solid(transform.Shape()), fullName);
|
||||||
|
@ -218,6 +231,7 @@ static void getNamedSolids(const TopLoc_Location& location, const std::string& p
|
||||||
bool load_step(const char *path, Model *model, bool& is_cancel,
|
bool load_step(const char *path, Model *model, bool& is_cancel,
|
||||||
double linear_defletion/*=0.003*/,
|
double linear_defletion/*=0.003*/,
|
||||||
double angle_defletion/*= 0.5*/,
|
double angle_defletion/*= 0.5*/,
|
||||||
|
bool isSplitCompound,
|
||||||
ImportStepProgressFn stepFn, StepIsUtf8Fn isUtf8Fn, long& mesh_face_num)
|
ImportStepProgressFn stepFn, StepIsUtf8Fn isUtf8Fn, long& mesh_face_num)
|
||||||
{
|
{
|
||||||
bool cb_cancel = false;
|
bool cb_cancel = false;
|
||||||
|
@ -266,7 +280,7 @@ bool load_step(const char *path, Model *model, bool& is_cancel,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getNamedSolids(TopLoc_Location{}, "", id, shapeTool, topLevelShapes.Value(iLabel), namedSolids);
|
getNamedSolids(TopLoc_Location{}, "", id, shapeTool, topLevelShapes.Value(iLabel), namedSolids, isSplitCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<stl_file> stl;
|
std::vector<stl_file> stl;
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern bool load_step(const char *path, Model *model,
|
||||||
bool& is_cancel,
|
bool& is_cancel,
|
||||||
double linear_defletion = 0.003,
|
double linear_defletion = 0.003,
|
||||||
double angle_defletion = 0.5,
|
double angle_defletion = 0.5,
|
||||||
|
bool isSplitCompound = false,
|
||||||
ImportStepProgressFn proFn = nullptr,
|
ImportStepProgressFn proFn = nullptr,
|
||||||
StepIsUtf8Fn isUtf8Fn = nullptr,
|
StepIsUtf8Fn isUtf8Fn = nullptr,
|
||||||
long& mesh_face_num = *(new long(-1)));
|
long& mesh_face_num = *(new long(-1)));
|
||||||
|
|
|
@ -181,9 +181,10 @@ Model Model::read_from_step(const std::string&
|
||||||
LoadStrategy options,
|
LoadStrategy options,
|
||||||
ImportStepProgressFn stepFn,
|
ImportStepProgressFn stepFn,
|
||||||
StepIsUtf8Fn stepIsUtf8Fn,
|
StepIsUtf8Fn stepIsUtf8Fn,
|
||||||
std::function<int(Slic3r::Step&, double&, double&)> step_mesh_fn,
|
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||||
double linear_defletion,
|
double linear_defletion,
|
||||||
double angle_defletion)
|
double angle_defletion,
|
||||||
|
bool is_split_compound)
|
||||||
{
|
{
|
||||||
Model model;
|
Model model;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
@ -192,12 +193,12 @@ Model Model::read_from_step(const std::string&
|
||||||
Step step_file(input_file);
|
Step step_file(input_file);
|
||||||
step_file.load();
|
step_file.load();
|
||||||
if (step_mesh_fn) {
|
if (step_mesh_fn) {
|
||||||
if (step_mesh_fn(step_file, linear_defletion, angle_defletion) == -1) {
|
if (step_mesh_fn(step_file, linear_defletion, angle_defletion, is_split_compound) == -1) {
|
||||||
Model empty_model;
|
Model empty_model;
|
||||||
return empty_model;
|
return empty_model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = load_step(input_file.c_str(), &model, is_cb_cancel, linear_defletion, angle_defletion, stepFn, stepIsUtf8Fn);
|
result = load_step(input_file.c_str(), &model, is_cb_cancel, linear_defletion, angle_defletion, is_split_compound, stepFn, stepIsUtf8Fn);
|
||||||
if (is_cb_cancel) {
|
if (is_cb_cancel) {
|
||||||
Model empty_model;
|
Model empty_model;
|
||||||
return empty_model;
|
return empty_model;
|
||||||
|
|
|
@ -1535,9 +1535,10 @@ public:
|
||||||
LoadStrategy options,
|
LoadStrategy options,
|
||||||
ImportStepProgressFn stepFn,
|
ImportStepProgressFn stepFn,
|
||||||
StepIsUtf8Fn stepIsUtf8Fn,
|
StepIsUtf8Fn stepIsUtf8Fn,
|
||||||
std::function<int(Slic3r::Step&, double&, double&)> step_mesh_fn,
|
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||||
double linear_defletion,
|
double linear_defletion,
|
||||||
double angle_defletion);
|
double angle_defletion,
|
||||||
|
bool is_split_compound);
|
||||||
|
|
||||||
//BBS: add part plate related logic
|
//BBS: add part plate related logic
|
||||||
// BBS: backup
|
// BBS: backup
|
||||||
|
|
|
@ -4162,6 +4162,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
if (linear <= 0) linear = 0.003;
|
if (linear <= 0) linear = 0.003;
|
||||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
||||||
if (angle <= 0) angle = 0.5;
|
if (angle <= 0) angle = 0.5;
|
||||||
|
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
|
||||||
model = Slic3r::Model:: read_from_step(path.string(), strategy,
|
model = Slic3r::Model:: read_from_step(path.string(), strategy,
|
||||||
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
|
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
|
||||||
{
|
{
|
||||||
|
@ -4187,22 +4188,24 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[this, &path, &is_user_cancel, &linear, &angle](Slic3r::Step& file, double& linear_value, double& angle_value)-> int {
|
[this, &path, &is_user_cancel, &linear, &angle, &split_compound](Slic3r::Step& file, double& linear_value, double& angle_value, bool& is_split)-> int {
|
||||||
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
|
||||||
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
|
||||||
if (mesh_dlg.ShowModal() == wxID_OK) {
|
if (mesh_dlg.ShowModal() == wxID_OK) {
|
||||||
linear_value = mesh_dlg.get_linear_defletion();
|
linear_value = mesh_dlg.get_linear_defletion();
|
||||||
angle_value = mesh_dlg.get_angle_defletion();
|
angle_value = mesh_dlg.get_angle_defletion();
|
||||||
|
is_split = mesh_dlg.get_split_compound_value();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
linear_value = linear;
|
linear_value = linear;
|
||||||
angle_value = angle;
|
angle_value = angle;
|
||||||
|
is_split = split_compound;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
is_user_cancel = true;
|
is_user_cancel = true;
|
||||||
return -1;
|
return -1;
|
||||||
}, linear, angle);
|
}, linear, angle, split_compound);
|
||||||
}else {
|
}else {
|
||||||
model = Slic3r::Model:: read_from_file(
|
model = Slic3r::Model:: read_from_file(
|
||||||
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
|
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
|
||||||
|
@ -5966,7 +5969,8 @@ void Plater::priv::reload_from_disk()
|
||||||
boost::iends_with(path, ".step")) {
|
boost::iends_with(path, ".step")) {
|
||||||
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
double linear = string_to_double_decimal_point(wxGetApp().app_config->get("linear_defletion"));
|
||||||
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
double angle = string_to_double_decimal_point(wxGetApp().app_config->get("angle_defletion"));
|
||||||
new_model = Model::read_from_step(path, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, nullptr, nullptr, nullptr, linear, angle);
|
bool is_split = wxGetApp().app_config->get_bool("is_split_compound");
|
||||||
|
new_model = Model::read_from_step(path, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, nullptr, nullptr, nullptr, linear, angle, is_split);
|
||||||
}else {
|
}else {
|
||||||
new_model = Model::read_from_file(path, nullptr, nullptr, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, &plate_data, &project_presets, nullptr, nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
|
new_model = Model::read_from_file(path, nullptr, nullptr, LoadStrategy::AddDefaultInstances | LoadStrategy::LoadModel, &plate_data, &project_presets, nullptr, nullptr, nullptr, nullptr, nullptr, 0, obj_color_fun);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,12 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
||||||
|
|
||||||
bSizer->Add(angle_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, LEFT_RIGHT_PADING);
|
bSizer->Add(angle_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, LEFT_RIGHT_PADING);
|
||||||
|
|
||||||
|
wxBoxSizer* check_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
m_split_compound_checkbox = new wxCheckBox(this, wxID_ANY, _L("Split compound and compsolid into multiple objects"), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_split_compound_checkbox->SetValue(wxGetApp().app_config->get_bool("is_split_compound"));
|
||||||
|
check_sizer->Add(m_split_compound_checkbox, 0, wxALIGN_LEFT);
|
||||||
|
bSizer->Add(check_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, LEFT_RIGHT_PADING);
|
||||||
|
|
||||||
wxBoxSizer* mesh_face_number_sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* mesh_face_number_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxStaticText *mesh_face_number_title = new wxStaticText(this, wxID_ANY, _L("Number of triangular facets") + ": ");
|
wxStaticText *mesh_face_number_title = new wxStaticText(this, wxID_ANY, _L("Number of triangular facets") + ": ");
|
||||||
mesh_face_number_text = new wxStaticText(this, wxID_ANY, _L("0"));
|
mesh_face_number_text = new wxStaticText(this, wxID_ANY, _L("0"));
|
||||||
|
@ -267,6 +273,7 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
||||||
if (m_checkbox->IsChecked()) {
|
if (m_checkbox->IsChecked()) {
|
||||||
wxGetApp().app_config->set_bool("enable_step_mesh_setting", false);
|
wxGetApp().app_config->set_bool("enable_step_mesh_setting", false);
|
||||||
}
|
}
|
||||||
|
wxGetApp().app_config->set_bool("is_split_compound", m_split_compound_checkbox->GetValue());
|
||||||
wxGetApp().app_config->set("linear_defletion", float_to_string_decimal_point(get_linear_defletion(), 3));
|
wxGetApp().app_config->set("linear_defletion", float_to_string_decimal_point(get_linear_defletion(), 3));
|
||||||
wxGetApp().app_config->set("angle_defletion", float_to_string_decimal_point(get_angle_defletion(), 2));
|
wxGetApp().app_config->set("angle_defletion", float_to_string_decimal_point(get_angle_defletion(), 2));
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,15 @@ public:
|
||||||
return m_last_angle;
|
return m_last_angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline bool get_split_compound_value() {
|
||||||
|
return m_split_compound_checkbox->GetValue();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
Slic3r::Step& m_file;
|
Slic3r::Step& m_file;
|
||||||
Button* m_button_ok = nullptr;
|
Button* m_button_ok = nullptr;
|
||||||
Button* m_button_cancel = nullptr;
|
Button* m_button_cancel = nullptr;
|
||||||
wxCheckBox* m_checkbox = nullptr;
|
wxCheckBox* m_checkbox = nullptr;
|
||||||
|
wxCheckBox* m_split_compound_checkbox = nullptr;
|
||||||
wxString m_linear_last;
|
wxString m_linear_last;
|
||||||
wxString m_angle_last;
|
wxString m_angle_last;
|
||||||
wxStaticText* mesh_face_number_text;
|
wxStaticText* mesh_face_number_text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue