From 5791310bb1bc706e0fd52f494924f9c9fd2daed5 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Wed, 25 May 2016 18:08:19 +0600 Subject: [PATCH] Annotate constants passed as boolean function arguments. This is to ensure that: * it is clear, when looking at the point of usage, what is the purpose of "true" or "false"; * when refactoring, a simple search will bring up any places that need to be changed. Also, argument names were synchronized between declaration and implementation. As an exception, these are not annotated: * Printf(/*halfLine=*/), to avoid pointless churn. --- src/bsp.cpp | 6 +++--- src/clipboard.cpp | 8 ++++---- src/confscreen.cpp | 14 +++++++------- src/constraint.cpp | 10 +++++----- src/draw.cpp | 2 +- src/drawconstraint.cpp | 14 +++++++------- src/drawentity.cpp | 8 ++++---- src/dsc.h | 4 ++-- src/export.cpp | 8 ++++---- src/exportstep.cpp | 4 ++-- src/exportvector.cpp | 6 +++--- src/file.cpp | 2 +- src/generate.cpp | 2 +- src/glhelper.cpp | 15 ++++++++------- src/graphicswin.cpp | 14 +++++++------- src/group.cpp | 24 ++++++++++++------------ src/groupmesh.cpp | 4 ++-- src/importdxf.cpp | 32 ++++++++++++++++---------------- src/lib.cpp | 2 +- src/mesh.cpp | 4 ++-- src/modify.cpp | 32 ++++++++++++++++---------------- src/mouse.cpp | 11 ++++++----- src/platform/w32main.cpp | 4 ++-- src/solvespace.cpp | 20 ++++++++++---------- src/solvespace.h | 2 +- src/srf/boolean.cpp | 30 ++++++++++++++++-------------- src/srf/merge.cpp | 4 ++-- src/srf/ratpoly.cpp | 36 ++++++++++++++++++------------------ src/srf/raycast.cpp | 40 +++++++++++++++++++++------------------- src/srf/surface.cpp | 30 +++++++++++++++--------------- src/srf/surface.h | 20 ++++++++++---------- src/srf/surfinter.cpp | 11 ++++++----- src/srf/triangulate.cpp | 6 +++--- src/textscreens.cpp | 10 +++++----- src/textwin.cpp | 2 +- src/toolbar.cpp | 6 +++--- src/util.cpp | 12 ++++++------ src/view.cpp | 2 +- 38 files changed, 234 insertions(+), 227 deletions(-) diff --git a/src/bsp.cpp b/src/bsp.cpp index c2da77f..283e9a3 100644 --- a/src/bsp.cpp +++ b/src/bsp.cpp @@ -118,7 +118,7 @@ alt: } else { // I suppose this actually is allowed to happen, if the coplanar // face is the leaf, and all of its neighbors are earlier in tree? - InsertInPlane(false, tr, instead); + InsertInPlane(/*pos2=*/false, tr, instead); } } else { instead->atLeastOneDiscarded = true; @@ -555,7 +555,7 @@ void SBsp2::InsertTriangleHow(BspClass how, STriangle *tr, SMesh *m, SBsp3 *bsp3 if(pos) { pos->InsertTriangle(tr, m, bsp3); } else { - bsp3->InsertInPlane(true, tr, m); + bsp3->InsertInPlane(/*pos2=*/true, tr, m); } break; @@ -563,7 +563,7 @@ void SBsp2::InsertTriangleHow(BspClass how, STriangle *tr, SMesh *m, SBsp3 *bsp3 if(neg) { neg->InsertTriangle(tr, m, bsp3); } else { - bsp3->InsertInPlane(false, tr, m); + bsp3->InsertInPlane(/*pos2=*/false, tr, m); } break; diff --git a/src/clipboard.cpp b/src/clipboard.cpp index 1129159..8a4a2c5 100644 --- a/src/clipboard.cpp +++ b/src/clipboard.cpp @@ -153,7 +153,7 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) { ClipboardRequest *cr; for(cr = SS.clipboard.r.First(); cr; cr = SS.clipboard.r.NextAfter(cr)) { - hRequest hr = AddRequest(cr->type, false); + hRequest hr = AddRequest(cr->type, /*rememberForUndo=*/false); Request *r = SK.GetRequest(hr); r->extraPoints = cr->extraPoints; r->style = cr->style; @@ -284,7 +284,7 @@ bool TextWindow::EditControlDoneForPaste(const char *s) { Expr *e; switch(edit.meaning) { case Edit::PASTE_TIMES_REPEATED: { - e = Expr::From(s, true); + e = Expr::From(s, /*popUpError=*/true); if(!e) break; int v = (int)e->Eval(); if(v > 0) { @@ -295,13 +295,13 @@ bool TextWindow::EditControlDoneForPaste(const char *s) { break; } case Edit::PASTE_ANGLE: - e = Expr::From(s, true); + e = Expr::From(s, /*popUpError=*/true); if(!e) break; shown.paste.theta = WRAP_SYMMETRIC((e->Eval())*PI/180, 2*PI); break; case Edit::PASTE_SCALE: { - e = Expr::From(s, true); + e = Expr::From(s, /*popUpError=*/true); double v = e->Eval(); if(fabs(v) > 1e-6) { shown.paste.scale = v; diff --git a/src/confscreen.cpp b/src/confscreen.cpp index 1be66ef..eaf6b59 100644 --- a/src/confscreen.cpp +++ b/src/confscreen.cpp @@ -378,7 +378,7 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { break; } case Edit::EXPORT_SCALE: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { double ev = e->Eval(); if(fabs(ev) < 0.001 || isnan(ev)) { @@ -390,7 +390,7 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { break; } case Edit::EXPORT_OFFSET: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { double ev = SS.ExprToMm(e); if(isnan(ev) || ev < 0) { @@ -402,7 +402,7 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { break; } case Edit::CANVAS_SIZE: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(!e) { break; } @@ -421,23 +421,23 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { break; } case Edit::G_CODE_DEPTH: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) SS.gCode.depth = (float)SS.ExprToMm(e); break; } case Edit::G_CODE_PASSES: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) SS.gCode.passes = (int)(e->Eval()); SS.gCode.passes = max(1, min(1000, SS.gCode.passes)); break; } case Edit::G_CODE_FEED: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) SS.gCode.feed = (float)SS.ExprToMm(e); break; } case Edit::G_CODE_PLUNGE_FEED: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) SS.gCode.plungeFeed = (float)SS.ExprToMm(e); break; } diff --git a/src/constraint.cpp b/src/constraint.cpp index 7327f1b..9681542 100644 --- a/src/constraint.cpp +++ b/src/constraint.cpp @@ -76,7 +76,7 @@ void Constraint::DeleteAllConstraintsFor(Constraint::Type type, hEntity entityA, } hConstraint Constraint::AddConstraint(Constraint *c) { - return AddConstraint(c, true); + return AddConstraint(c, /*rememberForUndo=*/true); } hConstraint Constraint::AddConstraint(Constraint *c, bool rememberForUndo) { @@ -103,16 +103,16 @@ hConstraint Constraint::Constrain(Constraint::Type type, hEntity ptA, hEntity pt c.entityB = entityB; c.other = other; c.other2 = other2; - return AddConstraint(&c, false); + return AddConstraint(&c, /*rememberForUndo=*/false); } hConstraint Constraint::Constrain(Constraint::Type type, hEntity ptA, hEntity ptB, hEntity entityA){ - return Constrain(type, ptA, ptB, entityA, Entity::NO_ENTITY, false, false); + return Constrain(type, ptA, ptB, entityA, Entity::NO_ENTITY, /*other=*/false, /*other2=*/false); } hConstraint Constraint::ConstrainCoincident(hEntity ptA, hEntity ptB) { return Constrain(Type::POINTS_COINCIDENT, ptA, ptB, - Entity::NO_ENTITY, Entity::NO_ENTITY, false, false); + Entity::NO_ENTITY, Entity::NO_ENTITY, /*other=*/false, /*other2=*/false); } void Constraint::MenuConstrain(Command id) { @@ -516,7 +516,7 @@ void Constraint::MenuConstrain(Command id) { nfree->NormalForceTo(Quaternion::From(fu, fv)); } - AddConstraint(&c, false); + AddConstraint(&c, /*rememberForUndo=*/false); break; } diff --git a/src/draw.cpp b/src/draw.cpp index e4eb907..480e9ec 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -709,7 +709,7 @@ nogrid:; glEnd(); // And the naked edges, if the user did Analyze -> Show Naked Edges. - ssglDrawEdges(&(SS.nakedEdges), true, { Style::DRAW_ERROR }); + ssglDrawEdges(&(SS.nakedEdges), /*endpointsToo=*/true, { Style::DRAW_ERROR }); // Then redraw whatever the mouse is hovering over, highlighted. glDisable(GL_DEPTH_TEST); diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 3fffe7b..f2d83f5 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -28,7 +28,7 @@ void Constraint::LineDrawOrGetDistance(Vector a, Vector b) { Point2d ap = SS.GW.ProjectPoint(a); Point2d bp = SS.GW.ProjectPoint(b); - double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), true); + double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), /*asSegment=*/true); dogd.dmin = min(dogd.dmin, d); } } @@ -109,7 +109,7 @@ void Constraint::DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu) { l = max(l, 5/SS.GW.scale); Point2d a = SS.GW.ProjectPoint(ref.Minus(gr.WithMagnitude(l))); Point2d b = SS.GW.ProjectPoint(ref.Plus (gr.WithMagnitude(l))); - double d = dogd.mp.DistanceToLine(a, b.Minus(a), true); + double d = dogd.mp.DistanceToLine(a, b.Minus(a), /*asSegment=*/true); dogd.dmin = min(dogd.dmin, d - (th / 2)); } @@ -432,7 +432,7 @@ void Constraint::DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db, dna.ScaledBy(r*sin(theta))).Plus(pi); if(i > 0) { if(trim) { - DoLineTrimmedAgainstBox(*ref, prev, p, false, gr, gu, swidth, sheight); + DoLineTrimmedAgainstBox(*ref, prev, p, /*extend=*/false, gr, gu, swidth, sheight); } else { LineDrawOrGetDistance(prev, p); } @@ -534,7 +534,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos, Vector *refps) { Vector ref = ((ap.Plus(bp)).ScaledBy(0.5)).Plus(disp.offset); if(refps) refps[0] = refps[1] = ref; - DoLineWithArrows(ref, ap, bp, false); + DoLineWithArrows(ref, ap, bp, /*onlyOneExt=*/false); DoLabel(ref, labelPos, gr, gu); return; } @@ -554,7 +554,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos, Vector *refps) { StippledLine(ap, bpp); StippledLine(bp, bpp); - DoLineWithArrows(ref, ap, bpp, false); + DoLineWithArrows(ref, ap, bpp, /*onlyOneExt=*/false); DoLabel(ref, labelPos, gr, gu); return; } @@ -579,7 +579,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos, Vector *refps) { if(refps) refps[0] = refps[1] = ref; if(!pt.Equals(closest)) { - DoLineWithArrows(ref, pt, closest, true); + DoLineWithArrows(ref, pt, closest, /*onlyOneExt=*/true); } DoLabel(ref, labelPos, gr, gu); @@ -607,7 +607,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos, Vector *refps) { DoLabel(ref, labelPos, gr, gu); if(!pt.Equals(closest)) { - DoLineWithArrows(ref, pt, closest, true); + DoLineWithArrows(ref, pt, closest, /*onlyOneExt=*/true); // Extensions to line double pixels = 1.0 / SS.GW.scale; diff --git a/src/drawentity.cpp b/src/drawentity.cpp index f8ffc36..83e2a90 100644 --- a/src/drawentity.cpp +++ b/src/drawentity.cpp @@ -29,7 +29,7 @@ void Entity::LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat, int data) Point2d ap = SS.GW.ProjectPoint(a); Point2d bp = SS.GW.ProjectPoint(b); - double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), true); + double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), /*asSegment=*/true); // A little bit easier to select in the active group if(group.v == SS.GW.activeGroup.v) d -= 1; if(d < dogd.dmin) { @@ -453,11 +453,11 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) const { break; } case Type::CUBIC: - ComputeInterpolatingSpline(sbl, false); + ComputeInterpolatingSpline(sbl, /*periodic=*/false); break; case Type::CUBIC_PERIODIC: - ComputeInterpolatingSpline(sbl, true); + ComputeInterpolatingSpline(sbl, /*periodic=*/true); break; case Type::CIRCLE: @@ -727,7 +727,7 @@ void Entity::DrawOrGetDistance() { dogd.data = -1; for(int i = 0; i < sel->l.n; i++) { SEdge *se = &(sel->l.elem[i]); - LineDrawOrGetDistance(se->a, se->b, true, se->auxB); + LineDrawOrGetDistance(se->a, se->b, /*maybeFat=*/true, se->auxB); } return; } diff --git a/src/dsc.h b/src/dsc.h index 74fa205..0b01030 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -98,7 +98,7 @@ public: static bool BoundingBoxesDisjoint(Vector amax, Vector amin, Vector bmax, Vector bmin); static bool BoundingBoxIntersectsLine(Vector amax, Vector amin, - Vector p0, Vector p1, bool segment); + Vector p0, Vector p1, bool asSegment); bool OutsideAndNotOn(Vector maxv, Vector minv) const; Vector InPerspective(Vector u, Vector v, Vector n, Vector origin, double cameraTan) const; @@ -134,7 +134,7 @@ public: double DivPivoting(Point2d delta) const; double Dot(Point2d p) const; double DistanceTo(const Point2d &p) const; - double DistanceToLine(const Point2d &p0, const Point2d &dp, bool segment) const; + double DistanceToLine(const Point2d &p0, const Point2d &dp, bool asSegment) const; double Angle() const; double AngleTo(const Point2d &p) const; double Magnitude() const; diff --git a/src/export.cpp b/src/export.cpp index b2a1630..20fca2e 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -110,7 +110,7 @@ void SolveSpaceUI::ExportSectionTo(const std::string &filename) { bl.Clear(); } -void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool wireframe) { +void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool exportWireframe) { int i; SEdgeList edges = {}; SBezierList beziers = {}; @@ -168,7 +168,7 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool wir } } - if(wireframe) { + if(exportWireframe) { Vector u = Vector::From(1.0, 0.0, 0.0), v = Vector::From(0.0, 1.0, 0.0), n = Vector::From(0.0, 0.0, 1.0), @@ -659,8 +659,8 @@ void VectorFileWriter::OutputLinesAndMesh(SBezierLoopSetSet *sblss, SMesh *sm) { hStyle hs = { (uint32_t)b->auxA }; Style *stl = Style::Get(hs); double lineWidth = Style::WidthMm(b->auxA)*s; - RgbaColor strokeRgb = Style::Color(hs, true); - RgbaColor fillRgb = Style::FillColor(hs, true); + RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true); + RgbaColor fillRgb = Style::FillColor(hs, /*forExport=*/true); StartPath(strokeRgb, lineWidth, stl->filled, fillRgb, hs); for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) { diff --git a/src/exportstep.cpp b/src/exportstep.cpp index 0edb960..af4270e 100644 --- a/src/exportstep.cpp +++ b/src/exportstep.cpp @@ -251,14 +251,14 @@ void StepFileWriter::ExportSurface(SSurface *ss, SBezierList *sbl) { List listOfLoops = {}; // Create the face outer boundary from the outer loop. - int fob = ExportCurveLoop(loop, false); + int fob = ExportCurveLoop(loop, /*inner=*/false); listOfLoops.Add(&fob); // And create the face inner boundaries from any inner loops that // lie within this contour. loop = sbls->l.NextAfter(loop); for(; loop; loop = sbls->l.NextAfter(loop)) { - int fib = ExportCurveLoop(loop, true); + int fib = ExportCurveLoop(loop, /*inner=*/true); listOfLoops.Add(&fib); } diff --git a/src/exportvector.cpp b/src/exportvector.cpp index 822e9ed..7bb2e88 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -450,7 +450,7 @@ public: void assignEntityDefaults(DRW_Entity *entity, hStyle hs) { Style *s = Style::Get(hs); - RgbaColor color = s->Color(hs, true); + RgbaColor color = s->Color(hs, /*forExport=*/true); entity->color24 = color.ToPackedIntBGRA(); entity->color = findDxfColor(color); entity->layer = s->DescriptionString(); @@ -692,7 +692,7 @@ void DxfFileWriter::Bezier(SBezier *sb) { void DxfFileWriter::FinishAndCloseFile() { dxfRW dxf(filename.c_str()); DxfWriteInterface interface(this, &dxf); - dxf.write(&interface, DRW::AC1021, false); + dxf.write(&interface, DRW::AC1021, /*bin=*/false); paths.clear(); constraint = NULL; } @@ -1123,7 +1123,7 @@ void SvgFileWriter::StartFile() { fprintf(f, "}\r\n"); for(int i = 0; i < SK.style.n; i++) { Style *s = &SK.style.elem[i]; - RgbaColor strokeRgb = Style::Color(s->h, true); + RgbaColor strokeRgb = Style::Color(s->h, /*forExport=*/true); StipplePattern pattern = Style::PatternType(s->h); double stippleScale = Style::StippleScaleMm(s->h); diff --git a/src/file.cpp b/src/file.cpp index a7b5b60..ee4f3a2 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -290,7 +290,7 @@ bool SolveSpaceUI::SaveToFile(const std::string &filename) { } for(i = 0; i < SK.entity.n; i++) { - (SK.entity.elem[i]).CalculateNumerical(true); + (SK.entity.elem[i]).CalculateNumerical(/*forExport=*/true); sv.e = SK.entity.elem[i]; SaveUsingTable('e'); fprintf(fh, "AddEntity\n\n"); diff --git a/src/generate.cpp b/src/generate.cpp index 65bd2cc..190b5b2 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -520,7 +520,7 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) { MarkDraggedParams(); g->solved.remove.Clear(); SolveResult how = sys.Solve(g, &(g->solved.dof), - &(g->solved.remove), true, andFindFree); + &(g->solved.remove), /*andFindBad=*/true, andFindFree); bool isOkay = how == SolveResult::OKAY || (g->allowRedundant && how == SolveResult::REDUNDANT_OKAY); if(!isOkay || (isOkay && !g->IsSolvedOkay())) diff --git a/src/glhelper.cpp b/src/glhelper.cpp index 67a4a66..c0fcff5 100644 --- a/src/glhelper.cpp +++ b/src/glhelper.cpp @@ -260,7 +260,7 @@ void ssglColorRGBa(RgbaColor rgb, double a) if(!ColorLocked) glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), a); } -static void Stipple(bool forSel) +static void Stipple(bool forSelection) { static bool Init; const int BYTES = (32*32)/8; @@ -284,19 +284,19 @@ static void Stipple(bool forSel) } glEnable(GL_POLYGON_STIPPLE); - if(forSel) { + if(forSelection) { glPolygonStipple(SelMask); } else { glPolygonStipple(HoverMask); } } -static void StippleTriangle(STriangle *tr, bool s, RgbaColor rgb) +static void StippleTriangle(STriangle *tr, bool forSelection, RgbaColor rgb) { glEnd(); glDisable(GL_LIGHTING); ssglColorRGB(rgb); - Stipple(s); + Stipple(forSelection); glBegin(GL_TRIANGLES); ssglVertex3v(tr->a); ssglVertex3v(tr->b); @@ -357,10 +357,10 @@ void ssglFillMesh(bool useSpecColor, RgbaColor specColor, if((s1 != 0 && tr->meta.face == s1) || (s2 != 0 && tr->meta.face == s2)) { - StippleTriangle(tr, true, rgbSelected); + StippleTriangle(tr, /*forSelection=*/true, rgbSelected); } if(h != 0 && tr->meta.face == h) { - StippleTriangle(tr, false, rgbHovered); + StippleTriangle(tr, /*forSelection=*/false, rgbHovered); } } glEnd(); @@ -624,7 +624,8 @@ static void LoadBitmapFont() { BuiltinBitmapFont.AddGlyph(0xE006, LoadPNG("fonts/private/6-stipple-dash.png")); BuiltinBitmapFont.AddGlyph(0xE007, LoadPNG("fonts/private/7-stipple-zigzag.png")); // Unifont doesn't have a glyph for U+0020. - BuiltinBitmapFont.AddGlyph(0x20, Pixmap({ 8, 16, 8*3, false, std::vector(8*16*3) })); + BuiltinBitmapFont.AddGlyph(0x20, + Pixmap({ 8, 16, 8*3, /*hasAlpha=*/false, std::vector(8*16*3) })); } void ssglInitializeBitmapFont() diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index ede37e6..6ed60ab 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -665,16 +665,16 @@ void GraphicsWindow::EnsureValidActives() { RadioMenuByCmd(Command::UNITS_INCHES, SS.viewUnits == Unit::INCHES); ShowTextWindow(SS.GW.showTextWindow); - CheckMenuByCmd(Command::SHOW_TEXT_WND, SS.GW.showTextWindow); + CheckMenuByCmd(Command::SHOW_TEXT_WND, /*checked=*/SS.GW.showTextWindow); #if defined(__APPLE__) - CheckMenuByCmd(Command::SHOW_MENU_BAR, MenuBarIsVisible()); + CheckMenuByCmd(Command::SHOW_MENU_BAR, /*checked=*/MenuBarIsVisible()); #endif - CheckMenuByCmd(Command::SHOW_TOOLBAR, SS.showToolbar); - CheckMenuByCmd(Command::PERSPECTIVE_PROJ, SS.usePerspectiveProj); - CheckMenuByCmd(Command::SHOW_GRID, SS.GW.showSnapGrid); + CheckMenuByCmd(Command::SHOW_TOOLBAR, /*checked=*/SS.showToolbar); + CheckMenuByCmd(Command::PERSPECTIVE_PROJ, /*checked=*/SS.usePerspectiveProj); + CheckMenuByCmd(Command::SHOW_GRID,/*checked=*/SS.GW.showSnapGrid); #if defined(HAVE_GTK) || defined(__APPLE__) - CheckMenuByCmd(Command::FULL_SCREEN, FullScreenIsActive()); + CheckMenuByCmd(Command::FULL_SCREEN, /*checked=*/FullScreenIsActive()); #endif if(change) SS.ScheduleShowTW(); @@ -698,7 +698,7 @@ bool GraphicsWindow::LockedInWorkplane() { void GraphicsWindow::ForceTextWindowShown() { if(!showTextWindow) { showTextWindow = true; - CheckMenuByCmd(Command::SHOW_TEXT_WND, true); + CheckMenuByCmd(Command::SHOW_TEXT_WND, /*checked=*/true); ShowTextWindow(true); } } diff --git a/src/group.cpp b/src/group.cpp index 6b38de1..ad07f26 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -411,18 +411,18 @@ void Group::Generate(IdList *entity, if(e->IsPoint()) pt = e->h; - e->CalculateNumerical(false); + e->CalculateNumerical(/*forExport=*/false); hEntity he = e->h; e = NULL; // As soon as I call CopyEntity, e may become invalid! That // adds entities, which may cause a realloc. CopyEntity(entity, SK.GetEntity(he), ai, REMAP_BOTTOM, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); CopyEntity(entity, SK.GetEntity(he), af, REMAP_TOP, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); MakeExtrusionLines(entity, he); } // Remapped versions of that arbitrary point will be used to @@ -446,7 +446,7 @@ void Group::Generate(IdList *entity, Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; - e->CalculateNumerical(false); + e->CalculateNumerical(/*forExport=*/false); hEntity he = e->h; // As soon as I call CopyEntity, e may become invalid! That @@ -454,17 +454,17 @@ void Group::Generate(IdList *entity, CopyEntity(entity, SK.GetEntity(predef.origin), 0, ai, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_START, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_END, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); MakeLatheCircles(entity, param, he, axis_pos, axis_dir, ai); ai++; @@ -488,13 +488,13 @@ void Group::Generate(IdList *entity, Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; - e->CalculateNumerical(false); + e->CalculateNumerical(/*forExport=*/false); CopyEntity(entity, e, a*2 - (subtype == Subtype::ONE_SIDED ? 0 : (n-1)), (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, - true, false); + /*asTrans=*/true, /*asAxisAngle=*/false); } } return; @@ -520,13 +520,13 @@ void Group::Generate(IdList *entity, Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; - e->CalculateNumerical(false); + e->CalculateNumerical(/*forExport=*/false); CopyEntity(entity, e, a*2 - (subtype == Subtype::ONE_SIDED ? 0 : (n-1)), (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), - false, true); + /*asTrans=*/false, /*asAxisAngle=*/true); } } return; @@ -547,7 +547,7 @@ void Group::Generate(IdList *entity, CopyEntity(entity, ie, 0, 0, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), - false, false); + /*asTrans=*/false, /*asAxisAngle=*/false); } return; } diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 15ead43..d85c67a 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -503,12 +503,12 @@ void Group::DrawDisplayItems(Group::Type t) { if(SS.GW.showHdnLines) { ssglDepthRangeOffset(0); glDepthFunc(GL_GREATER); - ssglDrawEdges(&displayEdges, false, { Style::HIDDEN_EDGE }); + ssglDrawEdges(&displayEdges, /*endpointsToo=*/false, { Style::HIDDEN_EDGE }); ssglDrawOutlines(&displayOutlines, projDir, { Style::HIDDEN_EDGE }); glDepthFunc(GL_LEQUAL); } ssglDepthRangeOffset(2); - ssglDrawEdges(&displayEdges, false, { Style::SOLID_EDGE }); + ssglDrawEdges(&displayEdges, /*endpointsToo=*/false, { Style::SOLID_EDGE }); if(SS.GW.showOutlines) { ssglDrawOutlines(&displayOutlines, projDir, { Style::OUTLINE }); } else { diff --git a/src/importdxf.cpp b/src/importdxf.cpp index 24f7a3c..12c7e53 100644 --- a/src/importdxf.cpp +++ b/src/importdxf.cpp @@ -124,7 +124,7 @@ public: if(reversed) std::swap(p0, p1); blockTransformArc(¢er, &p0, &p1); - hRequest hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, false); + hRequest hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false); SK.GetEntity(hr.entity(1))->PointForceTo(center); SK.GetEntity(hr.entity(2))->PointForceTo(p0); SK.GetEntity(hr.entity(3))->PointForceTo(p1); @@ -477,7 +477,7 @@ public: hEntity he = findPoint(p); if(he.v != Entity::NO_ENTITY.v) return he; - hRequest hr = SS.GW.AddRequest(Request::Type::DATUM_POINT, false); + hRequest hr = SS.GW.AddRequest(Request::Type::DATUM_POINT, /*rememberForUndo=*/false); he = hr.entity(0); SK.GetEntity(he)->PointForceTo(p); points.emplace(p, he); @@ -486,7 +486,7 @@ public: hEntity createLine(Vector p0, Vector p1, uint32_t style, bool constrainHV = false) { if(p0.Equals(p1)) return Entity::NO_ENTITY; - hRequest hr = SS.GW.AddRequest(Request::Type::LINE_SEGMENT, false); + hRequest hr = SS.GW.AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false); SK.GetEntity(hr.entity(1))->PointForceTo(p0); SK.GetEntity(hr.entity(2))->PointForceTo(p1); processPoint(hr.entity(1)); @@ -520,7 +520,7 @@ public: } hEntity createCircle(const Vector &c, double r, uint32_t style) { - hRequest hr = SS.GW.AddRequest(Request::Type::CIRCLE, false); + hRequest hr = SS.GW.AddRequest(Request::Type::CIRCLE, /*rememberForUndo=*/false); SK.GetEntity(hr.entity(1))->PointForceTo(c); processPoint(hr.entity(1)); SK.GetEntity(hr.entity(64))->DistanceForceTo(r); @@ -548,7 +548,7 @@ public: if(data.space != DRW::ModelSpace) return; if(addPendingBlockEntity(data)) return; - hRequest hr = SS.GW.AddRequest(Request::Type::DATUM_POINT, false); + hRequest hr = SS.GW.AddRequest(Request::Type::DATUM_POINT, /*rememberForUndo=*/false); SK.GetEntity(hr.entity(0))->PointForceTo(toVector(data.basePoint)); processPoint(hr.entity(0)); } @@ -557,14 +557,14 @@ public: if(data.space != DRW::ModelSpace) return; if(addPendingBlockEntity(data)) return; - createLine(toVector(data.basePoint), toVector(data.secPoint), styleFor(&data).v, true); + createLine(toVector(data.basePoint), toVector(data.secPoint), styleFor(&data).v, /*constrainHV=*/true); } void addArc(const DRW_Arc &data) override { if(data.space != DRW::ModelSpace) return; if(addPendingBlockEntity(data)) return; - hRequest hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, false); + hRequest hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false); double r = data.radious; double sa = data.staangle; double ea = data.endangle; @@ -625,7 +625,7 @@ public: hStyle hs = styleFor(&data); if(EXACT(data.vertlist[i]->bulge == 0.0)) { - createLine(blockTransform(p0), blockTransform(p1), hs.v, true); + createLine(blockTransform(p0), blockTransform(p1), hs.v, /*constrainHV=*/true); } else { hRequest hr = createBulge(p0, p1, c0.bulge); setStyle(hr, hs); @@ -662,7 +662,7 @@ public: hStyle hs = styleFor(&data); if(EXACT(bulge == 0.0)) { - createLine(blockTransform(p0), blockTransform(p1), hs.v, true); + createLine(blockTransform(p0), blockTransform(p1), hs.v, /*constrainHV=*/true); } else { hRequest hr = createBulge(p0, p1, bulge); setStyle(hr, hs); @@ -675,7 +675,7 @@ public: if(data->degree != 3) return; if(addPendingBlockEntity(*data)) return; - hRequest hr = SS.GW.AddRequest(Request::Type::CUBIC, false); + hRequest hr = SS.GW.AddRequest(Request::Type::CUBIC, /*rememberForUndo=*/false); for(int i = 0; i < 4; i++) { SK.GetEntity(hr.entity(i + 1))->PointForceTo(toVector(*data->controllist[i])); processPoint(hr.entity(i + 1)); @@ -737,7 +737,7 @@ public: } c.comment = data.text; c.disp.style = styleFor(&data); - Constraint::AddConstraint(&c, false); + Constraint::AddConstraint(&c, /*rememberForUndo=*/false); } void addDimAlign(const DRW_DimAligned *data) override { @@ -767,9 +767,9 @@ public: if(data->space != DRW::ModelSpace) return; if(addPendingBlockEntity(*data)) return; - Vector p0 = toVector(data->getDef1Point(), false); - Vector p1 = toVector(data->getDef2Point(), false); - Vector p2 = toVector(data->getTextPoint(), false); + Vector p0 = toVector(data->getDef1Point(), /*transform=*/false); + Vector p1 = toVector(data->getDef2Point(), /*transform=*/false); + Vector p2 = toVector(data->getTextPoint(), /*transform=*/false); double angle = data->getAngle() * PI / 180.0; Vector dir = Vector::From(cos(angle), sin(angle), 0.0); @@ -909,7 +909,7 @@ void ImportDxf(const std::string &filename) { dxfRW dxf(filename.c_str()); DxfReadInterface interface; interface.clearBlockTransform(); - if(!dxf.read(&interface, false)) { + if(!dxf.read(&interface, /*ext=*/false)) { Error("Corrupted DXF file!"); } if(interface.unknownEntities > 0) { @@ -923,7 +923,7 @@ void ImportDwg(const std::string &filename) { dwgR dwg(filename.c_str()); DxfReadInterface interface; interface.clearBlockTransform(); - if(!dwg.read(&interface, false)) { + if(!dwg.read(&interface, /*ext=*/false)) { Error("Corrupted DWG file!"); } if(interface.unknownEntities > 0) { diff --git a/src/lib.cpp b/src/lib.cpp index 8cb75d4..8a4bdf0 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -209,7 +209,7 @@ default: dbp("bad constraint type %d", sc->type); return; // Now we're finally ready to solve! bool andFindBad = ssys->calculateFaileds ? true : false; - SolveResult how = SYS.Solve(&g, &(ssys->dof), &bad, andFindBad, false); + SolveResult how = SYS.Solve(&g, &(ssys->dof), &bad, andFindBad, /*andFindFree=*/false); switch(how) { case SolveResult::OKAY: diff --git a/src/mesh.cpp b/src/mesh.cpp index 2aca565..36632a2 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -86,14 +86,14 @@ void SMesh::MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d) { SKdNode *root = SKdNode::From(&m); root->SnapToMesh(&m); root->MakeCertainEdgesInto(sel, EdgeKind::NAKED_OR_SELF_INTER, - false, NULL, NULL); + /*coplanarIsInter=*/false, NULL, NULL); m.Clear(); } void SMesh::MakeCertainEdgesAndOutlinesInto(SEdgeList *sel, SOutlineList *sol, EdgeKind type) { SKdNode *root = SKdNode::From(this); - root->MakeCertainEdgesInto(sel, type, false, NULL, NULL); + root->MakeCertainEdgesInto(sel, type, /*coplanarIsInter=*/false, NULL, NULL); root->MakeOutlinesInto(sol); } diff --git a/src/modify.cpp b/src/modify.cpp index e4308e7..b5e70da 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -167,7 +167,7 @@ hRequest GraphicsWindow::ParametricCurve::CreateRequestTrimmedTo(double t, hRequest hr; Entity *e; if(isLine) { - hr = SS.GW.AddRequest(Request::Type::LINE_SEGMENT, false), + hr = SS.GW.AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false), e = SK.GetEntity(hr.entity(0)); SK.GetEntity(e->point[0])->PointForceTo(PointAt(t)); SK.GetEntity(e->point[1])->PointForceTo(PointAt(1)); @@ -179,9 +179,9 @@ hRequest GraphicsWindow::ParametricCurve::CreateRequestTrimmedTo(double t, } Constraint::Constrain(Constraint::Type::ARC_LINE_TANGENT, Entity::NO_ENTITY, Entity::NO_ENTITY, - arc, e->h, arcFinish, false); + arc, e->h, /*other=*/arcFinish, /*other2=*/false); } else { - hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, false), + hr = SS.GW.AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false), e = SK.GetEntity(hr.entity(0)); SK.GetEntity(e->point[0])->PointForceTo(p0); if(dtheta > 0) { @@ -198,7 +198,7 @@ hRequest GraphicsWindow::ParametricCurve::CreateRequestTrimmedTo(double t, // so there's no need for more. Constraint::Constrain(Constraint::Type::CURVE_CURVE_TANGENT, Entity::NO_ENTITY, Entity::NO_ENTITY, - arc, e->h, arcFinish, (dtheta < 0)); + arc, e->h, /*other=*/arcFinish, /*other2=*/(dtheta < 0)); } return hr; } @@ -389,7 +389,7 @@ void GraphicsWindow::MakeTangentArc() { SS.UndoRemember(); - hRequest harc = AddRequest(Request::Type::ARC_OF_CIRCLE, false); + hRequest harc = AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false); Entity *earc = SK.GetEntity(harc.entity(0)); hEntity hearc = earc->h; @@ -400,9 +400,9 @@ void GraphicsWindow::MakeTangentArc() { earc = NULL; pc[0].CreateRequestTrimmedTo(t[0], !SS.tangentArcDeleteOld, - hent[0], hearc, (b == 1)); + hent[0], hearc, /*arcFinish=*/(b == 1)); pc[1].CreateRequestTrimmedTo(t[1], !SS.tangentArcDeleteOld, - hent[1], hearc, (a == 1)); + hent[1], hearc, /*arcFinish=*/(a == 1)); // Now either make the original entities construction, or delete them // entirely, according to user preference. @@ -432,8 +432,8 @@ hEntity GraphicsWindow::SplitLine(hEntity he, Vector pinter) { p1 = SK.GetEntity(hep1)->PointGetNum(); // Add the two line segments this one gets split into. - hRequest r0i = AddRequest(Request::Type::LINE_SEGMENT, false), - ri1 = AddRequest(Request::Type::LINE_SEGMENT, false); + hRequest r0i = AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false), + ri1 = AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false); // Don't get entities till after adding, realloc issues Entity *e0i = SK.GetEntity(r0i.entity(0)), @@ -457,7 +457,7 @@ hEntity GraphicsWindow::SplitCircle(hEntity he, Vector pinter) { Vector center = SK.GetEntity(circle->point[0])->PointGetNum(); circle = NULL; // shortly invalid! - hRequest hr = AddRequest(Request::Type::ARC_OF_CIRCLE, false); + hRequest hr = AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false); Entity *arc = SK.GetEntity(hr.entity(0)); @@ -477,8 +477,8 @@ hEntity GraphicsWindow::SplitCircle(hEntity he, Vector pinter) { finish = SK.GetEntity(hf)->PointGetNum(); circle = NULL; // shortly invalid! - hRequest hr0 = AddRequest(Request::Type::ARC_OF_CIRCLE, false), - hr1 = AddRequest(Request::Type::ARC_OF_CIRCLE, false); + hRequest hr0 = AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false), + hr1 = AddRequest(Request::Type::ARC_OF_CIRCLE, /*rememberForUndo=*/false); Entity *arc0 = SK.GetEntity(hr0.entity(0)), *arc1 = SK.GetEntity(hr1.entity(0)); @@ -518,15 +518,15 @@ hEntity GraphicsWindow::SplitCubic(hEntity he, Vector pinter) { SBezier *sb = &(sbl.l.elem[i]); ssassert(sb->deg == 3, "Expected a cubic bezier"); - sb->ClosestPointTo(pinter, &t, false); + sb->ClosestPointTo(pinter, &t, /*mustConverge=*/false); if(pinter.Equals(sb->PointAt(t))) { // Split that segment at the intersection. SBezier b0i, bi1, b01 = *sb; b01.SplitAt(t, &b0i, &bi1); // Add the two cubic segments this one gets split into. - hRequest r0i = AddRequest(Request::Type::CUBIC, false), - ri1 = AddRequest(Request::Type::CUBIC, false); + hRequest r0i = AddRequest(Request::Type::CUBIC, /*rememberForUndo=*/false), + ri1 = AddRequest(Request::Type::CUBIC, /*rememberForUndo=*/false); // Don't get entities till after adding, realloc issues Entity *e0i = SK.GetEntity(r0i.entity(0)), @@ -544,7 +544,7 @@ hEntity GraphicsWindow::SplitCubic(hEntity he, Vector pinter) { hep1n = ei1->point[3]; hepin = e0i->point[3]; } else { - hRequest r = AddRequest(Request::Type::CUBIC, false); + hRequest r = AddRequest(Request::Type::CUBIC, /*rememberForUndo=*/false); Entity *e = SK.GetEntity(r.entity(0)); for(j = 0; j <= 3; j++) { diff --git a/src/mouse.cpp b/src/mouse.cpp index fbb18f4..55414d0 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -223,7 +223,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown, if(hover.entity.v) { // Avoid accidentally selecting workplanes when // starting drags. - MakeUnselected(hover.entity, false); + MakeUnselected(hover.entity, /*coincidentPointTrick=*/false); hover.Clear(); } pending.operation = Pending::DRAGGING_MARQUEE; @@ -644,7 +644,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { case ContextCommand::UNSELECT_HOVERED: if(!hover.IsEmpty()) { - MakeUnselected(&hover, true); + MakeUnselected(&hover, /*coincidentPointTrick=*/true); } break; @@ -825,7 +825,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { } hRequest GraphicsWindow::AddRequest(Request::Type type) { - return AddRequest(type, true); + return AddRequest(type, /*rememberForUndo=*/true); } hRequest GraphicsWindow::AddRequest(Request::Type type, bool rememberForUndo) { if(rememberForUndo) SS.UndoRemember(); @@ -889,7 +889,8 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { } // Make sure the hover is up to date. - MouseMoved(mx, my, false, false, false, false, false); + MouseMoved(mx, my, /*leftDown=*/false, /*middleDown=*/false, /*rightDown=*/false, + /*shiftDown=*/false, /*ctrlDown=*/false); orig.mouse.x = mx; orig.mouse.y = my; orig.mouseOnButtonDown = orig.mouse; @@ -938,7 +939,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { int i; SS.UndoRemember(); for(i = 0; i < 4; i++) { - lns[i] = AddRequest(Request::Type::LINE_SEGMENT, false); + lns[i] = AddRequest(Request::Type::LINE_SEGMENT, /*rememberForUndo=*/false); } for(i = 0; i < 4; i++) { Constraint::ConstrainCoincident( diff --git a/src/platform/w32main.cpp b/src/platform/w32main.cpp index d776d4e..38ac5ef 100644 --- a/src/platform/w32main.cpp +++ b/src/platform/w32main.cpp @@ -1041,13 +1041,13 @@ static bool OpenSaveFile(bool isOpen, std::string *filename, const std::string & bool SolveSpace::GetOpenFile(std::string *filename, const std::string &defExtension, const FileFilter filters[]) { - return OpenSaveFile(true, filename, defExtension, filters); + return OpenSaveFile(/*isOpen=*/true, filename, defExtension, filters); } bool SolveSpace::GetSaveFile(std::string *filename, const std::string &defExtension, const FileFilter filters[]) { - return OpenSaveFile(false, filename, defExtension, filters); + return OpenSaveFile(/*isOpen=*/false, filename, defExtension, filters); } DialogChoice SolveSpace::SaveFileYesNoCancel() diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 692aec1..1c1a78c 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -335,12 +335,12 @@ void SolveSpaceUI::AfterNewFile() { // roughly in the window, since that sets the mesh tolerance. Consider // invisible entities, so we still get something reasonable if the only // thing visible is the not-yet-generated surfaces. - GW.ZoomToFit(true); + GW.ZoomToFit(/*includingInvisibles=*/true); GenerateAll(Generate::ALL); SS.ScheduleShowTW(); // Then zoom to fit again, to fit the triangles - GW.ZoomToFit(false); + GW.ZoomToFit(/*includingInvisibles=*/false); // Create all the default styles; they'll get created on the fly anyways, // but can't hurt to do it now. @@ -412,7 +412,7 @@ bool SolveSpaceUI::OkayToStartNewFile() { switch(SaveFileYesNoCancel()) { case DIALOG_YES: - return GetFilenameAndSave(false); + return GetFilenameAndSave(/*saveAs=*/false); case DIALOG_NO: return true; @@ -464,11 +464,11 @@ void SolveSpaceUI::MenuFile(Command id) { } case Command::SAVE: - SS.GetFilenameAndSave(false); + SS.GetFilenameAndSave(/*saveAs=*/false); break; case Command::SAVE_AS: - SS.GetFilenameAndSave(true); + SS.GetFilenameAndSave(/*saveAs=*/true); break; case Command::EXPORT_PNG: { @@ -496,7 +496,7 @@ void SolveSpaceUI::MenuFile(Command id) { "text window."); } - SS.ExportViewOrWireframeTo(exportFile, false); + SS.ExportViewOrWireframeTo(exportFile, /*exportWireframe*/false); break; } @@ -506,7 +506,7 @@ void SolveSpaceUI::MenuFile(Command id) { Vector3dFileFilter)) break; CnfFreezeString(Extension(exportFile), "WireframeExportFormat"); - SS.ExportViewOrWireframeTo(exportFile, true); + SS.ExportViewOrWireframeTo(exportFile, /*exportWireframe*/true); break; } @@ -610,7 +610,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) { SKdNode *root = SKdNode::From(m); bool inters, leaks; root->MakeCertainEdgesInto(&(SS.nakedEdges), - EdgeKind::NAKED_OR_SELF_INTER, true, &inters, &leaks); + EdgeKind::NAKED_OR_SELF_INTER, /*coplanarIsInter=*/true, &inters, &leaks); InvalidateGraphics(); @@ -641,7 +641,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) { SKdNode *root = SKdNode::From(m); bool inters, leaks; root->MakeCertainEdgesInto(&(SS.nakedEdges), - EdgeKind::SELF_INTER, false, &inters, &leaks); + EdgeKind::SELF_INTER, /*coplanarIsInter=*/false, &inters, &leaks); InvalidateGraphics(); @@ -734,7 +734,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) { SEdgeList sel = {}; g->polyLoops.MakeEdgesInto(&sel); SPolygon sp = {}; - sel.AssemblePolygon(&sp, NULL, true); + sel.AssemblePolygon(&sp, NULL, /*keepDir=*/true); sp.normal = sp.ComputeNormal(); sp.FixContourDirections(); double area = sp.SignedArea(); diff --git a/src/solvespace.h b/src/solvespace.h index e15ef32..1f0b582 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -853,7 +853,7 @@ public: void ExportMeshAsObjTo(FILE *f, SMesh *sm); void ExportMeshAsThreeJsTo(FILE *f, const std::string &filename, SMesh *sm, SEdgeList *sel); - void ExportViewOrWireframeTo(const std::string &filename, bool wireframe); + void ExportViewOrWireframeTo(const std::string &filename, bool exportWireframe); void ExportSectionTo(const std::string &filename); void ExportWireframeCurves(SEdgeList *sel, SBezierList *sbl, VectorFileWriter *out); diff --git a/src/srf/boolean.cpp b/src/srf/boolean.cpp index 70df591..844d1db 100644 --- a/src/srf/boolean.cpp +++ b/src/srf/boolean.cpp @@ -53,9 +53,11 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB, // Find all the intersections with the two passed shells if(agnstA) - agnstA->AllPointsIntersecting(prev.p, p->p, &il, true, false, true); + agnstA->AllPointsIntersecting(prev.p, p->p, &il, + /*asSegment=*/true, /*trimmed=*/false, /*inclTangent=*/true); if(agnstB) - agnstB->AllPointsIntersecting(prev.p, p->p, &il, true, false, true); + agnstB->AllPointsIntersecting(prev.p, p->p, &il, + /*asSegment=*/true, /*trimmed=*/false, /*inclTangent=*/true); if(il.n > 0) { // The intersections were generated by intersecting the pwl @@ -76,7 +78,7 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB, } Point2d puv; - (pi->srf)->ClosestPointTo(pi->p, &puv, false); + (pi->srf)->ClosestPointTo(pi->p, &puv, /*mustConverge=*/false); // Split the edge if the intersection lies within the surface's // trim curves, or within the chord tol of the trim curve; want @@ -359,7 +361,7 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv, SCurve *sc = shell->curve.FindById(hc); if(sc->isExact && sc->exact.deg != 1) { double t; - sc->exact.ClosestPointTo(*pt, &t, false); + sc->exact.ClosestPointTo(*pt, &t, /*mustConverge=*/false); *pt = sc->exact.PointAt(t); ClosestPointTo(*pt, &muv); } else if(!sc->isExact) { @@ -584,11 +586,11 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent, final.CullExtraneousEdges(); // Use our reassembled edges to trim the new surface. - ret.TrimFromEdgeList(&final, true); + ret.TrimFromEdgeList(&final, /*asUv=*/true); SPolygon poly = {}; final.l.ClearTags(); - if(!final.AssemblePolygon(&poly, NULL, true)) { + if(!final.AssemblePolygon(&poly, NULL, /*keepDir=*/true)) { into->booleanFailed = true; dbp("failed: I=%d, avoid=%d", I, choosing.l.n); DEBUGEDGELIST(&final, &ret); @@ -679,7 +681,7 @@ void SShell::MakeFromAssemblyOf(SShell *a, SShell *b) { for(i = 0; i < 2; i++) { ab = (i == 0) ? a : b; for(s = ab->surface.First(); s; s = ab->surface.NextAfter(s)) { - sn = SSurface::FromTransformationOf(s, t, q, 1.0, true); + sn = SSurface::FromTransformationOf(s, t, q, 1.0, /*includingTrims=*/true); // All the trim curve IDs get rewritten; we know the new handles // to the curves since we recorded them in the previous step. STrimBy *stb; @@ -704,8 +706,8 @@ void SShell::MakeFromBoolean(SShell *a, SShell *b, SSurface::CombineAs type) { // Copy over all the original curves, splitting them so that a // piecwise linear segment never crosses a surface from the other // shell. - a->CopyCurvesSplitAgainst(true, b, this); - b->CopyCurvesSplitAgainst(false, a, this); + a->CopyCurvesSplitAgainst(/*opA=*/true, b, this); + b->CopyCurvesSplitAgainst(/*opA=*/false, a, this); // Generate the intersection curves for each surface in A against all // the surfaces in B (which is all of the intersection curves). @@ -833,12 +835,12 @@ double SBspUv::ScaledSignedDistanceToLine(Point2d pt, Point2d a, Point2d b, return pt.Dot(n) - d; } -double SBspUv::ScaledDistanceToLine(Point2d pt, Point2d a, Point2d b, bool seg, +double SBspUv::ScaledDistanceToLine(Point2d pt, Point2d a, Point2d b, bool asSegment, SSurface *srf) const { ScalePoints(&pt, &a, &b, srf); - return pt.DistanceToLine(a, b, seg); + return pt.DistanceToLine(a, b, asSegment); } SBspUv *SBspUv::InsertOrCreateEdge(SBspUv *where, Point2d ea, Point2d eb, SSurface *srf) { @@ -905,8 +907,8 @@ SBspUv::Class SBspUv::ClassifyPoint(Point2d p, Point2d eb, SSurface *srf) const const SBspUv *f = this; while(f) { Point2d ba = (f->b).Minus(f->a); - if(ScaledDistanceToLine(p, f->a, ba, true, srf) < LENGTH_EPS) { - if(ScaledDistanceToLine(eb, f->a, ba, false, srf) < LENGTH_EPS){ + if(ScaledDistanceToLine(p, f->a, ba, /*asSegment=*/true, srf) < LENGTH_EPS) { + if(ScaledDistanceToLine(eb, f->a, ba, /*asSegment=*/false, srf) < LENGTH_EPS){ if(ba.Dot(eb.Minus(p)) > 0) { return Class::EDGE_PARALLEL; } else { @@ -950,7 +952,7 @@ double SBspUv::MinimumDistanceToEdge(Point2d p, SSurface *srf) const { Point2d as = a, bs = b; ScalePoints(&p, &as, &bs, srf); - double d = p.DistanceToLine(as, bs.Minus(as), true); + double d = p.DistanceToLine(as, bs.Minus(as), /*asSegment=*/true); return min(d, min(dn, dp)); } diff --git a/src/srf/merge.cpp b/src/srf/merge.cpp index 9e1d62e..575b1ea 100644 --- a/src/srf/merge.cpp +++ b/src/srf/merge.cpp @@ -32,7 +32,7 @@ void SShell::MergeCoincidentSurfaces() { for(j = i + 1; j < surface.n; j++) { sj = &(surface.elem[j]); if(sj->tag) continue; - if(!sj->CoincidentWith(si, true)) continue; + if(!sj->CoincidentWith(si, /*sameNormal=*/true)) continue; if(!sj->color.Equals(si->color)) continue; // But we do merge surfaces with different face entities, since // otherwise we'd hardly ever merge anything. @@ -72,7 +72,7 @@ void SShell::MergeCoincidentSurfaces() { if(merged) { sel.CullExtraneousEdges(); si->trim.Clear(); - si->TrimFromEdgeList(&sel, false); + si->TrimFromEdgeList(&sel, /*asUv=*/false); // And we must choose control points such that all the trims lie // with u and v in [0, 1], so that the bbox tests work. diff --git a/src/srf/ratpoly.cpp b/src/srf/ratpoly.cpp index 7060d20..304e124 100644 --- a/src/srf/ratpoly.cpp +++ b/src/srf/ratpoly.cpp @@ -130,7 +130,7 @@ Vector SBezier::TangentAt(double t) const { return ret; } -void SBezier::ClosestPointTo(Vector p, double *t, bool converge) const { +void SBezier::ClosestPointTo(Vector p, double *t, bool mustConverge) const { int i; double minDist = VERY_POSITIVE; *t = 0; @@ -147,7 +147,7 @@ void SBezier::ClosestPointTo(Vector p, double *t, bool converge) const { } Vector p0; - for(i = 0; i < (converge ? 15 : 5); i++) { + for(i = 0; i < (mustConverge ? 15 : 5); i++) { p0 = PointAt(*t); if(p0.Equals(p, RATPOLY_EPS)) { return; @@ -157,15 +157,15 @@ void SBezier::ClosestPointTo(Vector p, double *t, bool converge) const { Vector pc = p.ClosestPointOnLine(p0, dp); *t += (pc.Minus(p0)).DivPivoting(dp); } - if(converge) { + if(mustConverge) { dbp("didn't converge (closest point on bezier curve)"); } } bool SBezier::PointOnThisAndCurve(const SBezier *sbb, Vector *p) const { double ta, tb; - this->ClosestPointTo(*p, &ta, false); - sbb ->ClosestPointTo(*p, &tb, false); + this->ClosestPointTo(*p, &ta, /*mustConverge=*/false); + sbb ->ClosestPointTo(*p, &tb, /*mustConverge=*/false); int i; for(i = 0; i < 20; i++) { @@ -387,11 +387,11 @@ Vector SSurface::NormalAt(double u, double v) const { return tu.Cross(tv); } -void SSurface::ClosestPointTo(Vector p, Point2d *puv, bool converge) { - ClosestPointTo(p, &(puv->x), &(puv->y), converge); +void SSurface::ClosestPointTo(Vector p, Point2d *puv, bool mustConverge) { + ClosestPointTo(p, &(puv->x), &(puv->y), mustConverge); } -void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool converge) { +void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool mustConverge) { // A few special cases first; when control points are coincident the // derivative goes to zero at the conrol points, and would result in // nonconvergence. We avoid that here, and also guarantee a consistent @@ -418,9 +418,9 @@ void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool converge) { // good if we're working our way along a curve or something else where // we project successive points that are close to each other; something // like a 20% speedup empirically. - if(converge) { + if(mustConverge) { double ut = cached.x, vt = cached.y; - if(ClosestPointNewton(p, &ut, &vt, converge)) { + if(ClosestPointNewton(p, &ut, &vt, mustConverge)) { cached.x = *u = ut; cached.y = *v = vt; return; @@ -445,7 +445,7 @@ void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool converge) { } } - if(ClosestPointNewton(p, u, v, converge)) { + if(ClosestPointNewton(p, u, v, mustConverge)) { cached.x = *u; cached.y = *v; return; @@ -457,13 +457,13 @@ void SSurface::ClosestPointTo(Vector p, double *u, double *v, bool converge) { } } -bool SSurface::ClosestPointNewton(Vector p, double *u, double *v, bool converge) const +bool SSurface::ClosestPointNewton(Vector p, double *u, double *v, bool mustConverge) const { // Initial guess is in u, v; refine by Newton iteration. Vector p0 = Vector::From(0, 0, 0); - for(int i = 0; i < (converge ? 25 : 5); i++) { + for(int i = 0; i < (mustConverge ? 25 : 5); i++) { p0 = PointAt(*u, *v); - if(converge) { + if(mustConverge) { if(p0.Equals(p, RATPOLY_EPS)) { return true; } @@ -481,7 +481,7 @@ bool SSurface::ClosestPointNewton(Vector p, double *u, double *v, bool converge) *v += dv / (tv.MagSquared()); } - if(converge) { + if(mustConverge) { dbp("didn't converge"); dbp("have %.3f %.3f %.3f", CO(p0)); dbp("want %.3f %.3f %.3f", CO(p)); @@ -525,7 +525,7 @@ Vector SSurface::ClosestPointOnThisAndSurface(SSurface *srf2, Vector p) { SSurface *srf[2] = { this, srf2 }; for(j = 0; j < 2; j++) { - (srf[j])->ClosestPointTo(p, &(puv[j]), false); + (srf[j])->ClosestPointTo(p, &(puv[j]), /*mustConverge=*/false); } for(i = 0; i < 10; i++) { @@ -573,8 +573,8 @@ void SSurface::PointOnSurfaces(SSurface *s1, SSurface *s2, double *up, double *v // Get initial guesses for (u, v) in the other surfaces Vector p = PointAt(*u, *v); - (srf[1])->ClosestPointTo(p, &(u[1]), &(v[1]), false); - (srf[2])->ClosestPointTo(p, &(u[2]), &(v[2]), false); + (srf[1])->ClosestPointTo(p, &(u[1]), &(v[1]), /*mustConverge=*/false); + (srf[2])->ClosestPointTo(p, &(u[2]), &(v[2]), /*mustConverge=*/false); int i, j; for(i = 0; i < 20; i++) { diff --git a/src/srf/raycast.cpp b/src/srf/raycast.cpp index c1d0a8d..f3153cf 100644 --- a/src/srf/raycast.cpp +++ b/src/srf/raycast.cpp @@ -190,12 +190,12 @@ void SSurface::SplitInHalf(bool byU, SSurface *sa, SSurface *sb) { //----------------------------------------------------------------------------- void SSurface::AllPointsIntersectingUntrimmed(Vector a, Vector b, int *cnt, int *level, - List *l, bool segment, + List *l, bool asSegment, SSurface *sorig) { // Test if the line intersects our axis-aligned bounding box; if no, then // no possibility of an intersection - if(LineEntirelyOutsideBbox(a, b, segment)) return; + if(LineEntirelyOutsideBbox(a, b, asSegment)) return; if(*cnt > 2000) { dbp("!!! too many subdivisions (level=%d)!", *level); @@ -212,7 +212,7 @@ void SSurface::AllPointsIntersectingUntrimmed(Vector a, Vector b, ctrl[degm][0 ]).Plus( ctrl[degm][degn]).ScaledBy(0.25); Inter inter; - sorig->ClosestPointTo(p, &(inter.p.x), &(inter.p.y), false); + sorig->ClosestPointTo(p, &(inter.p.x), &(inter.p.y), /*mustConverge=*/false); if(sorig->PointIntersectingLine(a, b, &(inter.p.x), &(inter.p.y))) { Vector p = sorig->PointAt(inter.p.x, inter.p.y); // Debug check, verify that the point lies in both surfaces @@ -232,9 +232,9 @@ void SSurface::AllPointsIntersectingUntrimmed(Vector a, Vector b, int nextLevel = (*level) + 1; (*level) = nextLevel; - surf0.AllPointsIntersectingUntrimmed(a, b, cnt, level, l, segment, sorig); + surf0.AllPointsIntersectingUntrimmed(a, b, cnt, level, l, asSegment, sorig); (*level) = nextLevel; - surf1.AllPointsIntersectingUntrimmed(a, b, cnt, level, l, segment, sorig); + surf1.AllPointsIntersectingUntrimmed(a, b, cnt, level, l, asSegment, sorig); } //----------------------------------------------------------------------------- @@ -247,9 +247,9 @@ void SSurface::AllPointsIntersectingUntrimmed(Vector a, Vector b, //----------------------------------------------------------------------------- void SSurface::AllPointsIntersecting(Vector a, Vector b, List *l, - bool seg, bool trimmed, bool inclTangent) + bool asSegment, bool trimmed, bool inclTangent) { - if(LineEntirelyOutsideBbox(a, b, seg)) return; + if(LineEntirelyOutsideBbox(a, b, asSegment)) return; Vector ba = b.Minus(a); double bam = ba.Magnitude(); @@ -266,7 +266,7 @@ void SSurface::AllPointsIntersecting(Vector a, Vector b, double d = n.Dot(PointAt(0, 0)); // Trim to line segment now if requested, don't generate points that // would just get discarded later. - if(!seg || + if(!asSegment || (n.Dot(a) > d + LENGTH_EPS && n.Dot(b) < d - LENGTH_EPS) || (n.Dot(b) > d + LENGTH_EPS && n.Dot(a) < d - LENGTH_EPS)) { @@ -334,7 +334,7 @@ void SSurface::AllPointsIntersecting(Vector a, Vector b, } else { // General numerical solution by subdivision, fallback int cnt = 0, level = 0; - AllPointsIntersectingUntrimmed(a, b, &cnt, &level, &inters, seg, this); + AllPointsIntersectingUntrimmed(a, b, &cnt, &level, &inters, asSegment, this); } // Remove duplicate intersection points @@ -355,7 +355,7 @@ void SSurface::AllPointsIntersecting(Vector a, Vector b, // Make sure the point lies within the finite line segment Vector pxyz = PointAt(puv.x, puv.y); double t = (pxyz.Minus(a)).DivPivoting(ba); - if(seg && (t > 1 - LENGTH_EPS/bam || t < LENGTH_EPS/bam)) { + if(asSegment && (t > 1 - LENGTH_EPS/bam || t < LENGTH_EPS/bam)) { continue; } @@ -381,11 +381,12 @@ void SSurface::AllPointsIntersecting(Vector a, Vector b, void SShell::AllPointsIntersecting(Vector a, Vector b, List *il, - bool seg, bool trimmed, bool inclTangent) + bool asSegment, bool trimmed, bool inclTangent) { SSurface *ss; for(ss = surface.First(); ss; ss = surface.NextAfter(ss)) { - ss->AllPointsIntersecting(a, b, il, seg, trimmed, inclTangent); + ss->AllPointsIntersecting(a, b, il, + asSegment, trimmed, inclTangent); } } @@ -434,7 +435,7 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir, Vector inter_surf_n[2], inter_edge_n[2]; SSurface *srf; for(srf = surface.First(); srf; srf = surface.NextAfter(srf)) { - if(srf->LineEntirelyOutsideBbox(ea, eb, true)) continue; + if(srf->LineEntirelyOutsideBbox(ea, eb, /*asSegment=*/true)) continue; SEdgeList *sel = &(srf->edges); SEdge *se; @@ -446,7 +447,7 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir, if(edge_inters < 2) { // Edge-on-edge case Point2d pm; - srf->ClosestPointTo(p, &pm, false); + srf->ClosestPointTo(p, &pm, /*mustConverge=*/false); // A vector normal to the surface, at the intersection point inter_surf_n[edge_inters] = srf->NormalAt(pm); // A vector normal to the intersecting edge (but within the @@ -519,10 +520,10 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir, // the additional error from the line intersection. for(srf = surface.First(); srf; srf = surface.NextAfter(srf)) { - if(srf->LineEntirelyOutsideBbox(ea, eb, true)) continue; + if(srf->LineEntirelyOutsideBbox(ea, eb, /*asSegment=*/true)) continue; Point2d puv; - srf->ClosestPointTo(p, &(puv.x), &(puv.y), false); + srf->ClosestPointTo(p, &(puv.x), &(puv.y), /*mustConverge=*/false); Vector pp = srf->PointAt(puv); if((pp.Minus(p)).Magnitude() > LENGTH_EPS) continue; @@ -532,8 +533,8 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir, // Edge-on-face (unless edge-on-edge above superceded) Point2d pin, pout; - srf->ClosestPointTo(p.Plus(edge_n_in), &pin, false); - srf->ClosestPointTo(p.Plus(edge_n_out), &pout, false); + srf->ClosestPointTo(p.Plus(edge_n_in), &pin, /*mustConverge=*/false); + srf->ClosestPointTo(p.Plus(edge_n_out), &pout, /*mustConverge=*/false); Vector surf_n_in = srf->NormalAt(pin), surf_n_out = srf->NormalAt(pout); @@ -553,7 +554,8 @@ bool SShell::ClassifyEdge(Class *indir, Class *outdir, Vector ray = Vector::From(Random(1), Random(1), Random(1)); AllPointsIntersecting( - p.Minus(ray), p.Plus(ray), &l, false, true, false); + p.Minus(ray), p.Plus(ray), &l, + /*asSegment=*/false, /*trimmed=*/true, /*inclTangent=*/false); // no intersections means it's outside *indir = Class::OUTSIDE; diff --git a/src/srf/surface.cpp b/src/srf/surface.cpp index 18ee700..62e2088 100644 --- a/src/srf/surface.cpp +++ b/src/srf/surface.cpp @@ -187,10 +187,10 @@ void SSurface::GetAxisAlignedBounding(Vector *ptMax, Vector *ptMin) const { } } -bool SSurface::LineEntirelyOutsideBbox(Vector a, Vector b, bool segment) const { +bool SSurface::LineEntirelyOutsideBbox(Vector a, Vector b, bool asSegment) const { Vector amax, amin; GetAxisAlignedBounding(&amax, &amin); - if(!Vector::BoundingBoxIntersectsLine(amax, amin, a, b, segment)) { + if(!Vector::BoundingBoxIntersectsLine(amax, amin, a, b, asSegment)) { // The line segment could fail to intersect the bbox, but lie entirely // within it and intersect the surface. if(a.OutsideAndNotOn(amax, amin) && b.OutsideAndNotOn(amax, amin)) { @@ -367,7 +367,7 @@ void SSurface::MakeSectionEdgesInto(SShell *shell, SEdgeList *sel, SBezierList * for(i = sp + 1; i <= (fpt - 1); i++) { Vector p = sc->pts.elem[i].p; double t; - sb.ClosestPointTo(p, &t, false); + sb.ClosestPointTo(p, &t, /*mustConverge=*/false); Vector pp = sb.PointAt(t); if((pp.Minus(p)).Magnitude() > SS.ChordTolMm()/2) { tooFar = true; @@ -402,7 +402,7 @@ void SSurface::TriangulateInto(SShell *shell, SMesh *sm) { MakeEdgesInto(shell, &el, MakeAs::UV); SPolygon poly = {}; - if(el.AssemblePolygon(&poly, NULL, true)) { + if(el.AssemblePolygon(&poly, NULL, /*keepDir=*/true)) { int i, start = sm->l.n; if(degm == 1 && degn == 1) { // A surface with curvature along one direction only; so @@ -548,14 +548,14 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb STrimBy stb0, stb1; // The translated curves trim the flat top and bottom surfaces. - stb0 = STrimBy::EntireCurve(this, hc0, false); - stb1 = STrimBy::EntireCurve(this, hc1, true); + stb0 = STrimBy::EntireCurve(this, hc0, /*backwards=*/false); + stb1 = STrimBy::EntireCurve(this, hc1, /*backwards=*/true); (surface.FindById(hs0))->trim.Add(&stb0); (surface.FindById(hs1))->trim.Add(&stb1); // The translated curves also trim the surface of extrusion. - stb0 = STrimBy::EntireCurve(this, hc0, true); - stb1 = STrimBy::EntireCurve(this, hc1, false); + stb0 = STrimBy::EntireCurve(this, hc0, /*backwards=*/true); + stb1 = STrimBy::EntireCurve(this, hc1, /*backwards=*/false); (surface.FindById(hsext))->trim.Add(&stb0); (surface.FindById(hsext))->trim.Add(&stb1); @@ -581,9 +581,9 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb TrimLine *tlp = &(trimLines.elem[WRAP(i-1, trimLines.n)]); STrimBy stb; - stb = STrimBy::EntireCurve(this, tl->hc, true); + stb = STrimBy::EntireCurve(this, tl->hc, /*backwards=*/true); ss->trim.Add(&stb); - stb = STrimBy::EntireCurve(this, tlp->hc, false); + stb = STrimBy::EntireCurve(this, tlp->hc, /*backwards=*/false); ss->trim.Add(&stb); (curve.FindById(tl->hc))->surfA = ss->h; @@ -691,9 +691,9 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, hSCurve hcb = curve.AddAndAssignId(&sc); STrimBy stb; - stb = STrimBy::EntireCurve(this, hcb, true); + stb = STrimBy::EntireCurve(this, hcb, /*backwards=*/true); (surface.FindById(sc.surfA))->trim.Add(&stb); - stb = STrimBy::EntireCurve(this, hcb, false); + stb = STrimBy::EntireCurve(this, hcb, /*backwards=*/false); (surface.FindById(sc.surfB))->trim.Add(&stb); } @@ -716,9 +716,9 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, hSCurve hcc = curve.AddAndAssignId(&sc); STrimBy stb; - stb = STrimBy::EntireCurve(this, hcc, false); + stb = STrimBy::EntireCurve(this, hcc, /*backwards=*/false); (surface.FindById(sc.surfA))->trim.Add(&stb); - stb = STrimBy::EntireCurve(this, hcc, true); + stb = STrimBy::EntireCurve(this, hcc, /*backwards=*/true); (surface.FindById(sc.surfB))->trim.Add(&stb); } } @@ -821,7 +821,7 @@ void SShell::MakeFromTransformationOf(SShell *a, SSurface *s; for(s = a->surface.First(); s; s = a->surface.NextAfter(s)) { SSurface n; - n = SSurface::FromTransformationOf(s, t, q, scale, true); + n = SSurface::FromTransformationOf(s, t, q, scale, /*includingTrims=*/true); surface.Add(&n); // keeping the old ID } diff --git a/src/srf/surface.h b/src/srf/surface.h index 204b174..ebc716d 100644 --- a/src/srf/surface.h +++ b/src/srf/surface.h @@ -46,7 +46,7 @@ public: void ScalePoints(Point2d *pt, Point2d *a, Point2d *b, SSurface *srf) const; double ScaledSignedDistanceToLine(Point2d pt, Point2d a, Point2d b, SSurface *srf) const; - double ScaledDistanceToLine(Point2d pt, Point2d a, Point2d b, bool seg, + double ScaledDistanceToLine(Point2d pt, Point2d a, Point2d b, bool asSegment, SSurface *srf) const; void InsertEdge(Point2d a, Point2d b, SSurface *srf); @@ -86,7 +86,7 @@ public: Vector PointAt(double t) const; Vector TangentAt(double t) const; - void ClosestPointTo(Vector p, double *t, bool converge=true) const; + void ClosestPointTo(Vector p, double *t, bool mustConverge=true) const; void SplitAt(double t, SBezier *bef, SBezier *aft) const; bool PointOnThisAndCurve(const SBezier *sbb, Vector *p) const; @@ -233,7 +233,7 @@ public: Vector start; Vector finish; - static STrimBy EntireCurve(SShell *shell, hSCurve hsc, bool bkwds); + static STrimBy EntireCurve(SShell *shell, hSCurve hsc, bool backwards); }; // An intersection point between a line and a surface @@ -317,15 +317,15 @@ public: void SplitInHalf(bool byU, SSurface *sa, SSurface *sb); void AllPointsIntersecting(Vector a, Vector b, List *l, - bool seg, bool trimmed, bool inclTangent); + bool asSegment, bool trimmed, bool inclTangent); void AllPointsIntersectingUntrimmed(Vector a, Vector b, int *cnt, int *level, - List *l, bool segment, + List *l, bool asSegment, SSurface *sorig); - void ClosestPointTo(Vector p, Point2d *puv, bool converge=true); - void ClosestPointTo(Vector p, double *u, double *v, bool converge=true); - bool ClosestPointNewton(Vector p, double *u, double *v, bool converge=true) const; + void ClosestPointTo(Vector p, Point2d *puv, bool mustConverge=true); + void ClosestPointTo(Vector p, double *u, double *v, bool mustConverge=true); + bool ClosestPointNewton(Vector p, double *u, double *v, bool mustConverge=true) const; bool PointIntersectingLine(Vector p0, Vector p1, double *u, double *v) const; Vector ClosestPointOnThisAndSurface(SSurface *srf2, Vector p); @@ -335,7 +335,7 @@ public: void TangentsAt(double u, double v, Vector *tu, Vector *tv) const; Vector NormalAt(Point2d puv) const; Vector NormalAt(double u, double v) const; - bool LineEntirelyOutsideBbox(Vector a, Vector b, bool segment) const; + bool LineEntirelyOutsideBbox(Vector a, Vector b, bool asSegment) const; void GetAxisAlignedBounding(Vector *ptMax, Vector *ptMin) const; bool CoincidentWithPlane(Vector n, double d) const; bool CoincidentWith(SSurface *ss, bool sameNormal) const; @@ -387,7 +387,7 @@ public: void MakeIntersectionCurvesAgainst(SShell *against, SShell *into); void MakeClassifyingBsps(SShell *useCurvesFrom); void AllPointsIntersecting(Vector a, Vector b, List *il, - bool seg, bool trimmed, bool inclTangent); + bool asSegment, bool trimmed, bool inclTangent); void MakeCoincidentEdgesInto(SSurface *proto, bool sameNormal, SEdgeList *el, SShell *useCurvesFrom); void RewriteSurfaceHandlesForCurves(SShell *a, SShell *b); diff --git a/src/srf/surfinter.cpp b/src/srf/surfinter.cpp index 82657cb..91a91e8 100644 --- a/src/srf/surfinter.cpp +++ b/src/srf/surfinter.cpp @@ -216,8 +216,8 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB, p0 = n.ScaledBy(d).Plus(alu.ScaledBy(pm.Dot(alu))); List inters = {}; - sext->AllPointsIntersecting( - p0, p0.Plus(dp), &inters, false, false, true); + sext->AllPointsIntersecting(p0, p0.Plus(dp), &inters, + /*asSegment=*/false, /*trimmed=*/false, /*inclTangent=*/true); SInter *si; for(si = inters.First(); si; si = inters.NextAfter(si)) { @@ -283,14 +283,15 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB, pa = pa.Plus(axisc); pb = pb.Plus(axisc); - b->AllPointsIntersecting(pa, pb, &inters, true, false, false); + b->AllPointsIntersecting(pa, pb, &inters, + /*asSegment=*/true,/*trimmed=*/false, /*inclTangent=*/false); } SInter *si; for(si = inters.First(); si; si = inters.NextAfter(si)) { Vector p = (si->p).Minus(axis.ScaledBy((si->p).Dot(axis))); double ub, vb; - b->ClosestPointTo(p, &ub, &vb, true); + b->ClosestPointTo(p, &ub, &vb, /*mustConverge=*/true); SSurface plane; plane = SSurface::FromPlane(p, axis.Normal(0), axis.Normal(1)); @@ -324,7 +325,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB, List lsi = {}; srfB->AllPointsIntersecting(se->a, se->b, &lsi, - true, true, false); + /*asSegment=*/true, /*trimmed=*/true, /*inclTangent=*/false); if(lsi.n == 0) continue; // Find the other surface that this curve trims. diff --git a/src/srf/triangulate.cpp b/src/srf/triangulate.cpp index 8e040e6..316dd3f 100644 --- a/src/srf/triangulate.cpp +++ b/src/srf/triangulate.cpp @@ -434,9 +434,9 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) { lj = {}; double v = 0; li.Add(&v); - srf->MakeTriangulationGridInto(&li, 0, 1, true); + srf->MakeTriangulationGridInto(&li, 0, 1, /*swapped=*/true); lj.Add(&v); - srf->MakeTriangulationGridInto(&lj, 0, 1, false); + srf->MakeTriangulationGridInto(&lj, 0, 1, /*swapped=*/false); // Now iterate over each quad in the grid. If it's outside the polygon, // or if it intersects the polygon, then we discard it. Otherwise we @@ -486,7 +486,7 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) { holes.CullExtraneousEdges(); SPolygon hp = {}; - holes.AssemblePolygon(&hp, NULL, true); + holes.AssemblePolygon(&hp, NULL, /*keepDir=*/true); SContour *sc; for(sc = hp.l.First(); sc; sc = hp.l.NextAfter(sc)) { diff --git a/src/textscreens.cpp b/src/textscreens.cpp index ec85828..130996d 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -650,7 +650,7 @@ void TextWindow::EditControlDone(const char *s) { switch(edit.meaning) { case Edit::TIMES_REPEATED: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { SS.UndoRemember(); @@ -700,7 +700,7 @@ void TextWindow::EditControlDone(const char *s) { break; } case Edit::GROUP_SCALE: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { double ev = e->Eval(); if(fabs(ev) < 1e-6) { @@ -732,7 +732,7 @@ void TextWindow::EditControlDone(const char *s) { break; } case Edit::GROUP_OPACITY: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { double alpha = e->Eval(); if(alpha < 0 || alpha > 1) { @@ -758,7 +758,7 @@ void TextWindow::EditControlDone(const char *s) { break; } case Edit::STEP_DIM_FINISH: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(!e) { break; } @@ -774,7 +774,7 @@ void TextWindow::EditControlDone(const char *s) { break; case Edit::TANGENT_ARC_RADIUS: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(!e) break; if(e->Eval() < LENGTH_EPS) { Error("Radius cannot be zero or negative."); diff --git a/src/textwin.cpp b/src/textwin.cpp index b5e5841..2e9c8eb 100644 --- a/src/textwin.cpp +++ b/src/textwin.cpp @@ -865,7 +865,7 @@ void TextWindow::Paint() { // Move the quad down a bit, so that the descenders // still have the correct background. y += adj; - ssglAxisAlignedQuad(x, x + CHAR_WIDTH, y, y + bh, false); + ssglAxisAlignedQuad(x, x + CHAR_WIDTH, y, y + bh, /*lone=*/false); y -= adj; } } else if(a == 1) { diff --git a/src/toolbar.cpp b/src/toolbar.cpp index 92b3f61..8bc9c86 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -54,7 +54,7 @@ static ToolIcon Toolbar[] = { }; void GraphicsWindow::ToolbarDraw() { - ToolbarDrawOrHitTest(0, 0, true, NULL); + ToolbarDrawOrHitTest(0, 0, /*paint=*/true, NULL); } bool GraphicsWindow::ToolbarMouseMoved(int x, int y) { @@ -62,7 +62,7 @@ bool GraphicsWindow::ToolbarMouseMoved(int x, int y) { y += ((int)height/2); Command nh = Command::NONE; - bool withinToolbar = ToolbarDrawOrHitTest(x, y, false, &nh); + bool withinToolbar = ToolbarDrawOrHitTest(x, y, /*paint=*/false, &nh); if(!withinToolbar) nh = Command::NONE; if(nh != toolbarTooltipped) { @@ -89,7 +89,7 @@ bool GraphicsWindow::ToolbarMouseDown(int x, int y) { y += ((int)height/2); Command nh = Command::NONE; - bool withinToolbar = ToolbarDrawOrHitTest(x, y, false, &nh); + bool withinToolbar = ToolbarDrawOrHitTest(x, y, /*paint=*/false, &nh); // They might have clicked within the toolbar, but not on a button. if(withinToolbar && nh != Command::NONE) { for(int i = 0; SS.GW.menu[i].level >= 0; i++) { diff --git a/src/util.cpp b/src/util.cpp index ab649ff..3e13c90 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -148,14 +148,14 @@ void SolveSpace::Error(const char *str, ...) { va_list f; va_start(f, str); - DoStringForMessageBox(str, f, true); + DoStringForMessageBox(str, f, /*error=*/true); va_end(f); } void SolveSpace::Message(const char *str, ...) { va_list f; va_start(f, str); - DoStringForMessageBox(str, f, false); + DoStringForMessageBox(str, f, /*error=*/false); va_end(f); } @@ -749,7 +749,7 @@ bool Vector::BoundingBoxesDisjoint(Vector amax, Vector amin, } bool Vector::BoundingBoxIntersectsLine(Vector amax, Vector amin, - Vector p0, Vector p1, bool segment) + Vector p0, Vector p1, bool asSegment) { Vector dp = p1.Minus(p0); double lp = dp.Magnitude(); @@ -767,7 +767,7 @@ bool Vector::BoundingBoxIntersectsLine(Vector amax, Vector amin, double t = (d - p0.Element(i)) / dp.Element(i); Vector p = p0.Plus(dp.ScaledBy(t)); - if(segment && (t < -LENGTH_EPS || t > (lp+LENGTH_EPS))) continue; + if(asSegment && (t < -LENGTH_EPS || t > (lp+LENGTH_EPS))) continue; if(p.Element(j) > amax.Element(j) + LENGTH_EPS) continue; if(p.Element(k) > amax.Element(k) + LENGTH_EPS) continue; @@ -998,14 +998,14 @@ double Point2d::Dot(Point2d p) const { return x*p.x + y*p.y; } -double Point2d::DistanceToLine(const Point2d &p0, const Point2d &dp, bool segment) const { +double Point2d::DistanceToLine(const Point2d &p0, const Point2d &dp, bool asSegment) const { double m = dp.x*dp.x + dp.y*dp.y; if(m < LENGTH_EPS*LENGTH_EPS) return VERY_POSITIVE; // Let our line be p = p0 + t*dp, for a scalar t from 0 to 1 double t = (dp.x*(x - p0.x) + dp.y*(y - p0.y))/m; - if(segment) { + if(asSegment) { if(t < 0.0) return DistanceTo(p0); if(t > 1.0) return DistanceTo(p0.Plus(dp)); } diff --git a/src/view.cpp b/src/view.cpp index aeec367..c1a2bfa 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -63,7 +63,7 @@ void TextWindow::ScreenChangeViewProjection(int link, uint32_t v) { bool TextWindow::EditControlDoneForView(const char *s) { switch(edit.meaning) { case Edit::VIEW_SCALE: { - Expr *e = Expr::From(s, true); + Expr *e = Expr::From(s, /*popUpError=*/true); if(e) { double v = e->Eval() / SS.MmPerUnit(); if(v > LENGTH_EPS) {