From 7e823df94a449cb542599d4d7f880b4a28b043da Mon Sep 17 00:00:00 2001 From: Tom Sutcliffe Date: Tue, 24 Aug 2021 20:44:51 +0100 Subject: [PATCH] Correct which group is forced to mesh when linking an STL file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By making IsForcedToMesh() always return true for STL link groups, rather than trying to set forceToMesh=true during the import phase. STL link groups are now always shown as "model already forced to triangle mesh" in the details screen, but also (unlike when the model is forced to mesh by a parent group) show the '∆' icon in the group list. --- src/group.cpp | 6 +++++- src/importmesh.cpp | 1 - src/sketch.h | 1 + src/textscreens.cpp | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/group.cpp b/src/group.cpp index 0f5a9e6..1cb1a1b 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -404,7 +404,11 @@ bool Group::IsForcedToMeshBySource() const { } bool Group::IsForcedToMesh() const { - return forceToMesh || IsForcedToMeshBySource(); + return forceToMesh || IsTriangleMeshAssembly() || IsForcedToMeshBySource(); +} + +bool Group::IsTriangleMeshAssembly() const { + return type == Type::LINKED && linkFile.Extension() == "stl"; } std::string Group::DescriptionString() { diff --git a/src/importmesh.cpp b/src/importmesh.cpp index 2115175..df9a65b 100644 --- a/src/importmesh.cpp +++ b/src/importmesh.cpp @@ -171,7 +171,6 @@ bool LinkStl(const Platform::Path &filename, EntityList *el, SMesh *m, SShell *s addUnique(verts, tr.b, normal); addUnique(verts, tr.c, normal); } - SK.GetGroup(SS.GW.activeGroup)->forceToMesh = true; dbp("%d verticies", verts.size()); BBox box = {}; diff --git a/src/sketch.h b/src/sketch.h index 6b58bb8..812375f 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -269,6 +269,7 @@ public: void Generate(EntityList *entity, ParamList *param); bool IsSolvedOkay(); void TransformImportedBy(Vector t, Quaternion q); + bool IsTriangleMeshAssembly() const; bool IsForcedToMeshBySource() const; bool IsForcedToMesh() const; // When a request generates entities from entities, and the source diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 628aff3..2255382 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -124,7 +124,7 @@ void TextWindow::ShowListOfGroups() { } } std::string suffix; - if(g->forceToMesh) { + if(g->forceToMesh || g->IsTriangleMeshAssembly()) { suffix = " (∆)"; } @@ -495,7 +495,7 @@ void TextWindow::ShowGroupInfo() { &TextWindow::ScreenChangeGroupOption, g->visible ? CHECK_TRUE : CHECK_FALSE); - if(!g->IsForcedToMeshBySource()) { + if(!g->IsForcedToMeshBySource() && !g->IsTriangleMeshAssembly()) { Printf(false, " %f%Lf%Fd%s force NURBS surfaces to triangle mesh", &TextWindow::ScreenChangeGroupOption, g->forceToMesh ? CHECK_TRUE : CHECK_FALSE);