diff --git a/src/export.cpp b/src/export.cpp index d060d151..d3b44b1d 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -812,7 +812,7 @@ void SolveSpaceUI::ExportMeshTo(const std::string &filename) { Error("Couldn't write to '%s'", filename.c_str()); return; } - + ShowNakedEdges(/*reportOnlyWhenNotOkay=*/true); if(FilenameHasExtension(filename, ".stl")) { ExportMeshAsStlTo(f, m); } else if(FilenameHasExtension(filename, ".obj")) { diff --git a/src/solvespace.cpp b/src/solvespace.cpp index e4dc7205..6a0b835a 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -596,34 +596,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) { break; case Command::NAKED_EDGES: { - SS.nakedEdges.Clear(); - - Group *g = SK.GetGroup(SS.GW.activeGroup); - SMesh *m = &(g->displayMesh); - SKdNode *root = SKdNode::From(m); - bool inters, leaks; - root->MakeCertainEdgesInto(&(SS.nakedEdges), - EdgeKind::NAKED_OR_SELF_INTER, /*coplanarIsInter=*/true, &inters, &leaks); - - InvalidateGraphics(); - - const char *intersMsg = inters ? - "The mesh is self-intersecting (NOT okay, invalid)." : - "The mesh is not self-intersecting (okay, valid)."; - const char *leaksMsg = leaks ? - "The mesh has naked edges (NOT okay, invalid)." : - "The mesh is watertight (okay, valid)."; - - std::string cntMsg = ssprintf("\n\nThe model contains %d triangles, from " - "%d surfaces.", g->displayMesh.l.n, g->runningShell.surface.n); - - if(SS.nakedEdges.l.n == 0) { - Message("%s\n\n%s\n\nZero problematic edges, good.%s", - intersMsg, leaksMsg, cntMsg.c_str()); - } else { - Error("%s\n\n%s\n\n%d problematic edges, bad.%s", - intersMsg, leaksMsg, SS.nakedEdges.l.n, cntMsg.c_str()); - } + ShowNakedEdges(/*reportOnlyWhenNotOkay=*/false); break; } @@ -811,6 +784,40 @@ void SolveSpaceUI::MenuAnalyze(Command id) { } } +void SolveSpaceUI::ShowNakedEdges(bool reportOnlyWhenNotOkay) { + SS.nakedEdges.Clear(); + + Group *g = SK.GetGroup(SS.GW.activeGroup); + SMesh *m = &(g->displayMesh); + SKdNode *root = SKdNode::From(m); + bool inters, leaks; + root->MakeCertainEdgesInto(&(SS.nakedEdges), + EdgeKind::NAKED_OR_SELF_INTER, /*coplanarIsInter=*/true, &inters, &leaks); + + if(reportOnlyWhenNotOkay && !inters && !leaks && SS.nakedEdges.l.n == 0) { + return; + } + InvalidateGraphics(); + + const char *intersMsg = inters ? + "The mesh is self-intersecting (NOT okay, invalid)." : + "The mesh is not self-intersecting (okay, valid)."; + const char *leaksMsg = leaks ? + "The mesh has naked edges (NOT okay, invalid)." : + "The mesh is watertight (okay, valid)."; + + std::string cntMsg = ssprintf("\n\nThe model contains %d triangles, from " + "%d surfaces.", g->displayMesh.l.n, g->runningShell.surface.n); + + if(SS.nakedEdges.l.n == 0) { + Message("%s\n\n%s\n\nZero problematic edges, good.%s", + intersMsg, leaksMsg, cntMsg.c_str()); + } else { + Error("%s\n\n%s\n\n%d problematic edges, bad.%s", + intersMsg, leaksMsg, SS.nakedEdges.l.n, cntMsg.c_str()); + } +} + void SolveSpaceUI::MenuHelp(Command id) { switch(id) { case Command::WEBSITE: diff --git a/src/solvespace.h b/src/solvespace.h index f2998224..1593952d 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -881,6 +881,7 @@ public: bool PruneGroups(hGroup hg); bool PruneRequests(hGroup hg); bool PruneConstraints(hGroup hg); + static void ShowNakedEdges(bool reportOnlyWhenNotOkay); enum class Generate : uint32_t { DIRTY,