| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b5f36a4 commit 5ada4db
22 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -287,7 +287,7 @@ void GraphicsWindow::MenuClipboard(Command id) { | |||
| 287 | 287 | } | |
| 288 | 288 | ||
| 289 | 289 | case Command::PASTE_TRANSFORM: { | |
| 290 | - if(SS.clipboard.r.n == 0) { | ||
| 290 | + if(SS.clipboard.r.IsEmpty()) { | ||
| 291 | 291 | Error(_("Clipboard is empty; nothing to paste.")); | |
| 292 | 292 | break; | |
| 293 | 293 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -329,7 +329,8 @@ Lighting GraphicsWindow::GetLighting() const { | |||
| 329 | 329 | ||
| 330 | 330 | GraphicsWindow::Selection GraphicsWindow::ChooseFromHoverToSelect() { | |
| 331 | 331 | Selection sel = {}; | |
| 332 | - if(hoverList.n == 0) return sel; | ||
| 332 | + if(hoverList.IsEmpty()) | ||
| 333 | + return sel; | ||
| 333 | 334 | ||
| 334 | 335 | Group *activeGroup = SK.GetGroup(SS.GW.activeGroup); | |
| 335 | 336 | int bestOrder = -1; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,18 +34,18 @@ void Entity::GenerateEdges(SEdgeList *el) { | |||
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | SBezierList *Entity::GetOrGenerateBezierCurves() { | |
| 37 | - if(beziers.l.n == 0) | ||
| 37 | + if(beziers.l.IsEmpty()) | ||
| 38 | 38 | GenerateBezierCurves(&beziers); | |
| 39 | 39 | return &beziers; | |
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | SEdgeList *Entity::GetOrGenerateEdges() { | |
| 43 | - if(edges.l.n != 0) { | ||
| 43 | + if(!edges.l.IsEmpty()) { | ||
| 44 | 44 | if(EXACT(edgesChordTol == SS.ChordTolMm())) | |
| 45 | 45 | return &edges; | |
| 46 | 46 | edges.l.Clear(); | |
| 47 | 47 | } | |
| 48 | - if(edges.l.n == 0) | ||
| 48 | + if(edges.l.IsEmpty()) | ||
| 49 | 49 | GenerateEdges(&edges); | |
| 50 | 50 | edgesChordTol = SS.ChordTolMm(); | |
| 51 | 51 | return &edges; | |
@@ -55,7 +55,7 @@ BBox Entity::GetOrGenerateScreenBBox(bool *hasBBox) { | |||
| 55 | 55 | SBezierList *sbl = GetOrGenerateBezierCurves(); | |
| 56 | 56 | ||
| 57 | 57 | // We don't bother with bounding boxes for workplanes, etc. | |
| 58 | - *hasBBox = (IsPoint() || IsNormal() || sbl->l.n > 0); | ||
| 58 | + *hasBBox = (IsPoint() || IsNormal() || !sbl->l.IsEmpty()); | ||
| 59 | 59 | if(!*hasBBox) return {}; | |
| 60 | 60 | ||
| 61 | 61 | if(screenBBoxValid) | |
@@ -67,16 +67,14 @@ BBox Entity::GetOrGenerateScreenBBox(bool *hasBBox) { | |||
| 67 | 67 | } else if(IsNormal()) { | |
| 68 | 68 | Vector proj = SK.GetEntity(point[0])->PointGetNum(); | |
| 69 | 69 | screenBBox = BBox::From(proj, proj); | |
| 70 | - } else if(sbl->l.n > 0) { | ||
| 70 | + } else if(!sbl->l.IsEmpty()) { | ||
| 71 | 71 | Vector first = SS.GW.ProjectPoint3(sbl->l.elem[0].ctrl[0]); | |
| 72 | 72 | screenBBox = BBox::From(first, first); | |
| 73 | - for(int i = 0; i < sbl->l.n; i++) { | ||
| 74 | - SBezier *sb = &sbl->l.elem[i]; | ||
| 75 | - for(int i = 0; i <= sb->deg; i++) { | ||
| 76 | - screenBBox.Include(SS.GW.ProjectPoint3(sb->ctrl[i])); | ||
| 77 | - } | ||
| 73 | + for(auto &sb : sbl->l) { | ||
| 74 | + for(int i = 0; i < sb.deg; ++i) { screenBBox.Include(SS.GW.ProjectPoint3(sb.ctrl[i])); } | ||
| 78 | 75 | } | |
| 79 | - } else ssassert(false, "Expected entity to be a point or have beziers"); | ||
| 76 | + } else | ||
| 77 | + ssassert(false, "Expected entity to be a point or have beziers"); | ||
| 80 | 78 | ||
| 81 | 79 | screenBBoxValid = true; | |
| 82 | 80 | return screenBBox; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -325,8 +325,12 @@ class IdList { | |||
| 325 | 325 | int n; | |
| 326 | 326 | int elemsAllocated; | |
| 327 | 327 | ||
| 328 | + bool IsEmpty() const { | ||
| 329 | + return n == 0; | ||
| 330 | + } | ||
| 331 | + | ||
| 328 | 332 | uint32_t MaximumId() { | |
| 329 | - if(n == 0) { | ||
| 333 | + if(IsEmpty()) { | ||
| 330 | 334 | return 0; | |
| 331 | 335 | } else { | |
| 332 | 336 | return elem[n - 1].h.v; | |
@@ -385,6 +389,9 @@ class IdList { | |||
| 385 | 389 | } | |
| 386 | 390 | ||
| 387 | 391 | int IndexOf(H h) { | |
| 392 | + if(IsEmpty()) { | ||
| 393 | + return -1; | ||
| 394 | + } | ||
| 388 | 395 | int first = 0, last = n-1; | |
| 389 | 396 | while(first <= last) { | |
| 390 | 397 | int mid = (first + last)/2; | |
@@ -401,6 +408,9 @@ class IdList { | |||
| 401 | 408 | } | |
| 402 | 409 | ||
| 403 | 410 | T *FindByIdNoOops(H h) { | |
| 411 | + if(IsEmpty()) { | ||
| 412 | + return nullptr; | ||
| 413 | + } | ||
| 404 | 414 | int first = 0, last = n-1; | |
| 405 | 415 | while(first <= last) { | |
| 406 | 416 | int mid = (first + last)/2; | |
@@ -417,10 +427,10 @@ class IdList { | |||
| 417 | 427 | } | |
| 418 | 428 | ||
| 419 | 429 | T *First() { | |
| 420 | - return (n == 0) ? NULL : &(elem[0]); | ||
| 430 | + return (IsEmpty()) ? NULL : &(elem[0]); | ||
| 421 | 431 | } | |
| 422 | 432 | T *NextAfter(T *prev) { | |
| 423 | - if(!prev) return NULL; | ||
| 433 | + if(IsEmpty() || !prev) return NULL; | ||
| 424 | 434 | if(prev - elem == (n - 1)) return NULL; | |
| 425 | 435 | return prev + 1; | |
| 426 | 436 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,12 +296,13 @@ void StepFileWriter::ExportSurfacesTo(const Platform::Path &filename) { | |||
| 296 | 296 | Group *g = SK.GetGroup(SS.GW.activeGroup); | |
| 297 | 297 | SShell *shell = &(g->runningShell); | |
| 298 | 298 | ||
| 299 | - if(shell->surface.n == 0) { | ||
| 299 | + if(shell->surface.IsEmpty()) { | ||
| 300 | 300 | Error("The model does not contain any surfaces to export.%s", | |
| 301 | - g->runningMesh.l.n > 0 ? | ||
| 302 | - "\n\nThe model does contain triangles from a mesh, but " | ||
| 303 | - "a triangle mesh cannot be exported as a STEP file. Try " | ||
| 304 | - "File -> Export Mesh... instead." : ""); | ||
| 301 | + !g->runningMesh.l.IsEmpty() | ||
| 302 | + ? "\n\nThe model does contain triangles from a mesh, but " | ||
| 303 | + "a triangle mesh cannot be exported as a STEP file. Try " | ||
| 304 | + "File -> Export Mesh... instead." | ||
| 305 | + : ""); | ||
| 305 | 306 | return; | |
| 306 | 307 | } | |
| 307 | 308 | ||
@@ -318,7 +319,8 @@ void StepFileWriter::ExportSurfacesTo(const Platform::Path &filename) { | |||
| 318 | 319 | ||
| 319 | 320 | SSurface *ss; | |
| 320 | 321 | for(ss = shell->surface.First(); ss; ss = shell->surface.NextAfter(ss)) { | |
| 321 | - if(ss->trim.n == 0) continue; | ||
| 322 | + if(ss->trim.IsEmpty()) | ||
| 323 | + continue; | ||
| 322 | 324 | ||
| 323 | 325 | // Get all of the loops of Beziers that trim our surface (with each | |
| 324 | 326 | // Bezier split so that we use the section as t goes from 0 to 1), and | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -549,7 +549,7 @@ bool SolveSpaceUI::LoadFromFile(const Platform::Path &filename, bool canCancel) | |||
| 549 | 549 | Error(_("Unrecognized data in file. This file may be corrupt, or " | |
| 550 | 550 | "from a newer version of the program.")); | |
| 551 | 551 | // At least leave the program in a non-crashing state. | |
| 552 | - if(SK.group.n == 0) { | ||
| 552 | + if(SK.group.IsEmpty()) { | ||
| 553 | 553 | NewFile(); | |
| 554 | 554 | } | |
| 555 | 555 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1306,7 +1306,7 @@ void GraphicsWindow::ToggleBool(bool *v) { | |||
| 1306 | 1306 | // If the mesh or edges were previously hidden, they haven't been generated, | |
| 1307 | 1307 | // and if we are going to show them, we need to generate them first. | |
| 1308 | 1308 | Group *g = SK.GetGroup(SS.GW.activeGroup); | |
| 1309 | - if(*v && (g->displayOutlines.l.n == 0 && (v == &showEdges || v == &showOutlines))) { | ||
| 1309 | + if(*v && (g->displayOutlines.l.IsEmpty() && (v == &showEdges || v == &showOutlines))) { | ||
| 1310 | 1310 | SS.GenerateAll(SolveSpaceUI::Generate::UNTIL_ACTIVE); | |
| 1311 | 1311 | } | |
| 1312 | 1312 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -297,7 +297,7 @@ void Group::MenuGroup(Command id, Platform::Path linkFile) { | |||
| 297 | 297 | } | |
| 298 | 298 | ||
| 299 | 299 | // Copy color from the previous mesh-contributing group. | |
| 300 | - if(g.IsMeshGroup() && SK.groupOrder.n > 0) { | ||
| 300 | + if(g.IsMeshGroup() && !SK.groupOrder.IsEmpty()) { | ||
| 301 | 301 | Group *running = SK.GetRunningMeshGroupFor(SS.GW.activeGroup); | |
| 302 | 302 | if(running != NULL) { | |
| 303 | 303 | g.color = running->color; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -466,7 +466,7 @@ void Group::GenerateDisplayItems() { | |||
| 466 | 466 | ||
| 467 | 467 | if(SS.GW.showEdges || SS.GW.showOutlines) { | |
| 468 | 468 | SOutlineList rawOutlines = {}; | |
| 469 | - if(runningMesh.l.n > 0) { | ||
| 469 | + if(!runningMesh.l.IsEmpty()) { | ||
| 470 | 470 | // Triangle mesh only; no shell or emphasized edges. | |
| 471 | 471 | runningMesh.MakeOutlinesInto(&rawOutlines, EdgeKind::EMPHASIZED); | |
| 472 | 472 | } else { | |
@@ -706,7 +706,8 @@ void Group::DrawPolyError(Canvas *canvas) { | |||
| 706 | 706 | ||
| 707 | 707 | void Group::DrawFilledPaths(Canvas *canvas) { | |
| 708 | 708 | for(const SBezierLoopSet &sbls : bezierLoops.l) { | |
| 709 | - if(sbls.l.n == 0 || sbls.l.elem[0].l.n == 0) continue; | ||
| 709 | + if(sbls.l.IsEmpty() || sbls.l[0].l.IsEmpty()) | ||
| 710 | + continue; | ||
| 710 | 711 | ||
| 711 | 712 | // In an assembled loop, all the styles should be the same; so doesn't | |
| 712 | 713 | // matter which one we grab. | |
@@ -740,7 +741,8 @@ void Group::DrawContourAreaLabels(Canvas *canvas) { | |||
| 740 | 741 | Vector gu = camera.projUp.ScaledBy(1 / camera.scale); | |
| 741 | 742 | ||
| 742 | 743 | for(SBezierLoopSet &sbls : bezierLoops.l) { | |
| 743 | - if(sbls.l.n == 0 || sbls.l.elem[0].l.n == 0) continue; | ||
| 744 | + if(sbls.l.IsEmpty() || sbls.l[0].l.IsEmpty()) | ||
| 745 | + continue; | ||
| 744 | 746 | ||
| 745 | 747 | Vector min = sbls.l.elem[0].l.elem[0].ctrl[0]; | |
| 746 | 748 | Vector max = min; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,7 +182,7 @@ default: dbp("bad constraint type %d", sc->type); return; | |||
| 182 | 182 | c.other2 = (sc->other2) ? true : false; | |
| 183 | 183 | ||
| 184 | 184 | c.Generate(¶ms); | |
| 185 | - if(params.n > 0) { | ||
| 185 | + if(!params.IsEmpty()) { | ||
| 186 | 186 | for(Param &p : params) { | |
| 187 | 187 | p.h = SK.param.AddAndAssignId(&p); | |
| 188 | 188 | c.valP = p.h; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments