mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 21:02:23 +00:00
Exposing STEP import values (#14484)
Co-authored-by: yw4z <ywsyildiz@gmail.com>
This commit is contained in:
@@ -579,9 +579,16 @@ void AppConfig::set_defaults()
|
||||
if (get("enable_step_mesh_setting").empty()) {
|
||||
set_bool("enable_step_mesh_setting", true);
|
||||
}
|
||||
if (get("linear_defletion", "angle_defletion").empty()) {
|
||||
set("linear_defletion", "0.003");
|
||||
set("angle_defletion", "0.5");
|
||||
// Migrate legacy misspelled keys (linear_defletion/angle_defletion) to the corrected spelling.
|
||||
if (get("linear_deflection").empty() && !get("linear_defletion").empty())
|
||||
set("linear_deflection", get("linear_defletion"));
|
||||
if (get("angle_deflection").empty() && !get("angle_defletion").empty())
|
||||
set("angle_deflection", get("angle_defletion"));
|
||||
if (get("linear_deflection").empty()) {
|
||||
set("linear_deflection", "0.003");
|
||||
}
|
||||
if (get("angle_deflection").empty()) {
|
||||
set("angle_deflection", "0.5");
|
||||
}
|
||||
if (get("is_split_compound").empty()) {
|
||||
set_bool("is_split_compound", false);
|
||||
|
||||
@@ -230,8 +230,8 @@ static void getNamedSolids(const TopLoc_Location& location,
|
||||
}
|
||||
|
||||
//bool load_step(const char *path, Model *model, bool& is_cancel,
|
||||
// double linear_defletion/*=0.003*/,
|
||||
// double angle_defletion/*= 0.5*/,
|
||||
// double linear_deflection/*=0.003*/,
|
||||
// double angle_deflection/*= 0.5*/,
|
||||
// bool isSplitCompound,
|
||||
// ImportStepProgressFn stepFn, StepIsUtf8Fn isUtf8Fn, long& mesh_face_num)
|
||||
//{
|
||||
@@ -288,7 +288,7 @@ static void getNamedSolids(const TopLoc_Location& location,
|
||||
// stl.resize(namedSolids.size());
|
||||
// tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t> &range) {
|
||||
// for (size_t i = range.begin(); i < range.end(); i++) {
|
||||
// BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_defletion, false, angle_defletion, true);
|
||||
// BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||
// // BBS: calculate total number of the nodes and triangles
|
||||
// int aNbNodes = 0;
|
||||
// int aNbTriangles = 0;
|
||||
@@ -511,8 +511,8 @@ Step::Step_Status Step::load()
|
||||
Step::Step_Status Step::mesh(Model* model,
|
||||
bool& is_cancel,
|
||||
bool isSplitCompound,
|
||||
double linear_defletion/*=0.003*/,
|
||||
double angle_defletion/*= 0.5*/)
|
||||
double linear_deflection/*=0.003*/,
|
||||
double angle_deflection/*= 0.5*/)
|
||||
|
||||
{
|
||||
bool task_result = false;
|
||||
@@ -544,7 +544,7 @@ Step::Step_Status Step::mesh(Model* model,
|
||||
stl.resize(namedSolids.size());
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, namedSolids.size()), [&](const tbb::blocked_range<size_t>& range) {
|
||||
for (size_t i = range.begin(); i < range.end(); i++) {
|
||||
BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_defletion, false, angle_defletion, true);
|
||||
BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||
// BBS: calculate total number of the nodes and triangles
|
||||
int aNbNodes = 0;
|
||||
int aNbTriangles = 0;
|
||||
@@ -689,15 +689,15 @@ void Step::clean_mesh_data()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Step::get_triangle_num(double linear_defletion, double angle_defletion)
|
||||
unsigned int Step::get_triangle_num(double linear_deflection, double angle_deflection)
|
||||
{
|
||||
unsigned int tri_num = 0;
|
||||
try {
|
||||
Handle(StepProgressIncdicator) progress = new StepProgressIncdicator(m_stop_mesh);
|
||||
clean_mesh_data();
|
||||
IMeshTools_Parameters param;
|
||||
param.Deflection = linear_defletion;
|
||||
param.Angle = angle_defletion;
|
||||
param.Deflection = linear_deflection;
|
||||
param.Angle = angle_deflection;
|
||||
param.InParallel = true;
|
||||
for (int i = 0; i < m_name_solids.size(); ++i) {
|
||||
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, param, progress->Start());
|
||||
@@ -719,7 +719,7 @@ unsigned int Step::get_triangle_num(double linear_defletion, double angle_deflet
|
||||
return tri_num;
|
||||
}
|
||||
|
||||
unsigned int Step::get_triangle_num_tbb(double linear_defletion, double angle_defletion)
|
||||
unsigned int Step::get_triangle_num_tbb(double linear_deflection, double angle_deflection)
|
||||
{
|
||||
unsigned int tri_num = 0;
|
||||
clean_mesh_data();
|
||||
@@ -727,7 +727,7 @@ unsigned int Step::get_triangle_num_tbb(double linear_defletion, double angle_de
|
||||
[&](const tbb::blocked_range<size_t>& range) {
|
||||
for (size_t i = range.begin(); i < range.end(); i++) {
|
||||
unsigned int solids_tri_num = 0;
|
||||
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, linear_defletion, false, angle_defletion, true);
|
||||
BRepMesh_IncrementalMesh mesh(m_name_solids[i].solid, linear_deflection, false, angle_deflection, true);
|
||||
for (TopExp_Explorer anExpSF(m_name_solids[i].solid, TopAbs_FACE); anExpSF.More(); anExpSF.Next()) {
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(TopoDS::Face(anExpSF.Current()), aLoc);
|
||||
|
||||
@@ -38,8 +38,8 @@ struct NamedSolid
|
||||
//BBS: Load an step file into a provided model.
|
||||
extern bool load_step(const char *path, Model *model,
|
||||
bool& is_cancel,
|
||||
double linear_defletion = 0.003,
|
||||
double angle_defletion = 0.5,
|
||||
double linear_deflection = 0.003,
|
||||
double angle_deflection = 0.5,
|
||||
bool isSplitCompound = false,
|
||||
ImportStepProgressFn proFn = nullptr,
|
||||
StepIsUtf8Fn isUtf8Fn = nullptr,
|
||||
@@ -98,14 +98,14 @@ public:
|
||||
Step(std::string path, ImportStepProgressFn stepFn = nullptr, StepIsUtf8Fn isUtf8Fn = nullptr);
|
||||
~Step();
|
||||
Step_Status load();
|
||||
unsigned int get_triangle_num(double linear_defletion, double angle_defletion);
|
||||
unsigned int get_triangle_num_tbb(double linear_defletion, double angle_defletion);
|
||||
unsigned int get_triangle_num(double linear_deflection, double angle_deflection);
|
||||
unsigned int get_triangle_num_tbb(double linear_deflection, double angle_deflection);
|
||||
void clean_mesh_data();
|
||||
Step_Status mesh(Model* model,
|
||||
bool& is_cancel,
|
||||
bool isSplitCompound,
|
||||
double linear_defletion = 0.003,
|
||||
double angle_defletion = 0.5);
|
||||
double linear_deflection = 0.003,
|
||||
double angle_deflection = 0.5);
|
||||
|
||||
std::atomic<bool> m_stop_mesh{false};
|
||||
void update_process(int load_stage, int current, int total, bool& cancel);
|
||||
|
||||
@@ -187,8 +187,8 @@ Model Model::read_from_step(const std::string&
|
||||
ImportStepProgressFn stepFn,
|
||||
StepIsUtf8Fn stepIsUtf8Fn,
|
||||
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||
double linear_defletion,
|
||||
double angle_defletion,
|
||||
double linear_deflection,
|
||||
double angle_deflection,
|
||||
bool is_split_compound)
|
||||
{
|
||||
Model model;
|
||||
@@ -201,13 +201,13 @@ Model Model::read_from_step(const std::string&
|
||||
goto _finished;
|
||||
}
|
||||
if (step_mesh_fn) {
|
||||
if (step_mesh_fn(step_file, linear_defletion, angle_defletion, is_split_compound) == -1) {
|
||||
if (step_mesh_fn(step_file, linear_deflection, angle_deflection, is_split_compound) == -1) {
|
||||
status = Step::Step_Status::CANCEL;
|
||||
goto _finished;
|
||||
}
|
||||
}
|
||||
|
||||
status = step_file.mesh(&model, is_cb_cancel, is_split_compound, linear_defletion, angle_defletion);
|
||||
status = step_file.mesh(&model, is_cb_cancel, is_split_compound, linear_deflection, angle_deflection);
|
||||
|
||||
_finished:
|
||||
|
||||
|
||||
@@ -1588,8 +1588,8 @@ public:
|
||||
ImportStepProgressFn stepFn,
|
||||
StepIsUtf8Fn stepIsUtf8Fn,
|
||||
std::function<int(Slic3r::Step&, double&, double&, bool&)> step_mesh_fn,
|
||||
double linear_defletion,
|
||||
double angle_defletion,
|
||||
double linear_deflection,
|
||||
double angle_deflection,
|
||||
bool is_split_compound);
|
||||
|
||||
//BBS: add part plate related logic
|
||||
|
||||
Reference in New Issue
Block a user