From 438d517c5ab6bba4333cafd51abb5596a20b7197 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Sat, 30 May 2009 00:49:09 -0800 Subject: [PATCH] If a Boolean fails, then make a note of it in the group's text window screen, and remind the user that they could 'fix' the problem by working with meshes instead. [git-p4: depot-paths = "//depot/solvespace/": change = 1962] --- groupmesh.cpp | 12 +++++++++++- sketch.h | 2 ++ srf/boolean.cpp | 5 +++++ srf/surface.cpp | 2 ++ srf/surface.h | 2 ++ textscreens.cpp | 6 ++++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/groupmesh.cpp b/groupmesh.cpp index c360c38..1896c43 100644 --- a/groupmesh.cpp +++ b/groupmesh.cpp @@ -148,7 +148,10 @@ void Group::GenerateForBoolean(T *prevs, T *thiss, T *outs) { } } -void Group::GenerateShellAndMesh(void) { +void Group::GenerateShellAndMesh(void) { + bool prevBooleanFailed = booleanFailed; + booleanFailed = false; + thisShell.Clear(); thisMesh.Clear(); runningShell.Clear(); @@ -292,6 +295,13 @@ void Group::GenerateShellAndMesh(void) { if(pg->runningMesh.IsEmpty() && thisMesh.IsEmpty() && !forceToMesh) { SShell *prevs = &(pg->runningShell); GenerateForBoolean(prevs, &thisShell, &runningShell); + + // If the Boolean failed, then we should note that in the text screen + // for this group. + booleanFailed = runningShell.booleanFailed; + if(booleanFailed != prevBooleanFailed) { + SS.later.showTW = true; + } } else { SMesh prevm, thism; ZERO(&prevm); diff --git a/sketch.h b/sketch.h index 96fb9df..2da9169 100644 --- a/sketch.h +++ b/sketch.h @@ -145,6 +145,8 @@ public: Vector errorPointAt; } polyError; + bool booleanFailed; + SShell thisShell; SShell runningShell; diff --git a/srf/boolean.cpp b/srf/boolean.cpp index c8e5164..8b720ec 100644 --- a/srf/boolean.cpp +++ b/srf/boolean.cpp @@ -454,6 +454,7 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *agnst, SShell *parent, ZERO(&poly); final.l.ClearTags(); if(!final.AssemblePolygon(&poly, NULL, true)) { + into->booleanFailed = true; DEBUGEDGELIST(&final, &ret); } poly.Clear(); @@ -530,6 +531,8 @@ void SShell::RewriteSurfaceHandlesForCurves(SShell *a, SShell *b) { // much faster than merging as union. //----------------------------------------------------------------------------- void SShell::MakeFromAssemblyOf(SShell *a, SShell *b) { + booleanFailed = false; + Vector t = Vector::From(0, 0, 0); Quaternion q = Quaternion::IDENTITY; int i = 0; @@ -571,6 +574,8 @@ void SShell::MakeFromAssemblyOf(SShell *a, SShell *b) { } void SShell::MakeFromBoolean(SShell *a, SShell *b, int type) { + booleanFailed = false; + a->MakeClassifyingBsps(); b->MakeClassifyingBsps(); diff --git a/srf/surface.cpp b/srf/surface.cpp index 3b685c2..ed33593 100644 --- a/srf/surface.cpp +++ b/srf/surface.cpp @@ -626,6 +626,8 @@ void SShell::MakeFromCopyOf(SShell *a) { } void SShell::MakeFromTransformationOf(SShell *a, Vector t, Quaternion q) { + booleanFailed = false; + SSurface *s; for(s = a->surface.First(); s; s = a->surface.NextAfter(s)) { SSurface n; diff --git a/srf/surface.h b/srf/surface.h index 25492df..c8bb888 100644 --- a/srf/surface.h +++ b/srf/surface.h @@ -278,6 +278,8 @@ public: IdList curve; IdList surface; + bool booleanFailed; + void MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, int color); void MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, diff --git a/textscreens.cpp b/textscreens.cpp index 0b4a317..3a37f5d 100644 --- a/textscreens.cpp +++ b/textscreens.cpp @@ -475,6 +475,12 @@ void TextWindow::ShowGroupInfo(void) { Printf(false, "%FtSURFACES%E %Fsas mesh%E"); } + + if(g->booleanFailed) { + Printf(true, "The Boolean operation failed. It may be "); + Printf(false, "possible to fix the problem by choosing "); + Printf(false, "surfaces 'as mesh' instead of 'as NURBS'."); + } } // Leave more space if the group has configuration stuff above the req/