FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

More cleanups and simplification by rpavlik · Pull Request #428 · solvespace/solvespace · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (37) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 4 additions & 11 deletions src/bsp.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,19 @@ SBsp2 *SBsp2::Alloc() { return (SBsp2 *)AllocTemporary(sizeof(SBsp2)); }
SBsp3 *SBsp3::Alloc() { return (SBsp3 *)AllocTemporary(sizeof(SBsp3)); }

SBsp3 *SBsp3::FromMesh(const SMesh *m) {
SBsp3 *bsp3 = NULL;
int i;

SMesh mc = {};
for(i = 0; i < m->l.n; i++) {
mc.AddTriangle(&(m->l.elem[i]));
}
for(auto const &elt : m->l) { mc.AddTriangle(&elt); }

srand(0); // Let's be deterministic, at least!
int n = mc.l.n;
while(n > 1) {
int k = rand() % n;
n--;
swap(mc.l.elem[k], mc.l.elem[n]);
}

for(i = 0; i < mc.l.n; i++) {
bsp3 = InsertOrCreate(bsp3, &(mc.l.elem[i]), NULL);
swap(mc.l[k], mc.l[n]);
}

SBsp3 *bsp3 = NULL;
for(auto &elt : mc.l) { bsp3 = InsertOrCreate(bsp3, &elt, NULL); }
mc.Clear();
return bsp3;
}
Expand Down
2 changes: 1 addition & 1 deletion src/clipboard.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void GraphicsWindow::MenuClipboard(Command id) {
}

case Command::PASTE_TRANSFORM: {
if(SS.clipboard.r.n == 0) {
if(SS.clipboard.r.IsEmpty()) {
Error(_("Clipboard is empty; nothing to paste."));
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/constraint.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ std::string Constraint::DescriptionString() const {
void Constraint::DeleteAllConstraintsFor(Constraint::Type type, hEntity entityA, hEntity ptA)
{
SK.constraint.ClearTags();
for(int i = 0; i < SK.constraint.n; i++) {
ConstraintBase *ct = &(SK.constraint.elem[i]);
for(auto &constraint : SK.constraint) {
ConstraintBase *ct = &constraint;
if(ct->type != type) continue;

if(ct->entityA != entityA) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/constrainteq.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void ConstraintBase::ModifyToSatisfy() {

// These equations are written in the form f(...) - d = 0, where
// d is the value of the valA.
valA += (l.elem[0].e)->Eval();
valA += (l[0].e)->Eval();

l.Clear();
}
Expand Down
4 changes: 2 additions & 2 deletions src/describescreen.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void TextWindow::ScreenSetTtfFont(int link, uint32_t v) {
if(!r) return;

SS.UndoRemember();
r->font = SS.fonts.l.elem[i].FontFileBaseName();
r->font = SS.fonts.l[i].FontFileBaseName();
SS.MarkGroupDirty(r->group);
SS.ScheduleShowTW();
}
Expand Down Expand Up @@ -177,7 +177,7 @@ void TextWindow::DescribeSelection() {
SS.fonts.LoadAll();
int i;
for(i = 0; i < SS.fonts.l.n; i++) {
TtfFont *tf = &(SS.fonts.l.elem[i]);
TtfFont *tf = &(SS.fonts.l[i]);
if(e->font == tf->FontFileBaseName()) {
Printf(false, "%Bp %s",
(i & 1) ? 'd' : 'a',
Expand Down
5 changes: 3 additions & 2 deletions src/draw.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void GraphicsWindow::GroupSelection() {
gs = {};
int i;
for(i = 0; i < selection.n; i++) {
Selection *s = &(selection.elem[i]);
Selection *s = &(selection[i]);
if(s->entity.v) {
(gs.n)++;

Expand Down Expand Up @@ -329,7 +329,8 @@ Lighting GraphicsWindow::GetLighting() const {

GraphicsWindow::Selection GraphicsWindow::ChooseFromHoverToSelect() {
Selection sel = {};
if(hoverList.n == 0) return sel;
if(hoverList.IsEmpty())
return sel;

Group *activeGroup = SK.GetGroup(SS.GW.activeGroup);
int bestOrder = -1;
Expand Down
28 changes: 13 additions & 15 deletions src/drawentity.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ void Entity::GenerateEdges(SEdgeList *el) {

int i, j;
for(i = 0; i < sbl->l.n; i++) {
SBezier *sb = &(sbl->l.elem[i]);
SBezier *sb = &(sbl->l[i]);

List<Vector> lv = {};
sb->MakePwlInto(&lv);
for(j = 1; j < lv.n; j++) {
el->AddEdge(lv.elem[j-1], lv.elem[j], style.v, i);
el->AddEdge(lv[j-1], lv[j], style.v, i);
}
lv.Clear();
}
}

SBezierList *Entity::GetOrGenerateBezierCurves() {
if(beziers.l.n == 0)
if(beziers.l.IsEmpty())
GenerateBezierCurves(&beziers);
return &beziers;
}

SEdgeList *Entity::GetOrGenerateEdges() {
if(edges.l.n != 0) {
if(!edges.l.IsEmpty()) {
if(EXACT(edgesChordTol == SS.ChordTolMm()))
return &edges;
edges.l.Clear();
}
if(edges.l.n == 0)
if(edges.l.IsEmpty())
GenerateEdges(&edges);
edgesChordTol = SS.ChordTolMm();
return &edges;
Expand All @@ -55,7 +55,7 @@ BBox Entity::GetOrGenerateScreenBBox(bool *hasBBox) {
SBezierList *sbl = GetOrGenerateBezierCurves();

// We don't bother with bounding boxes for workplanes, etc.
*hasBBox = (IsPoint() || IsNormal() || sbl->l.n > 0);
*hasBBox = (IsPoint() || IsNormal() || !sbl->l.IsEmpty());
if(!*hasBBox) return {};

if(screenBBoxValid)
Expand All @@ -67,16 +67,14 @@ BBox Entity::GetOrGenerateScreenBBox(bool *hasBBox) {
} else if(IsNormal()) {
Vector proj = SK.GetEntity(point[0])->PointGetNum();
screenBBox = BBox::From(proj, proj);
} else if(sbl->l.n > 0) {
Vector first = SS.GW.ProjectPoint3(sbl->l.elem[0].ctrl[0]);
} else if(!sbl->l.IsEmpty()) {
Vector first = SS.GW.ProjectPoint3(sbl->l[0].ctrl[0]);
screenBBox = BBox::From(first, first);
for(int i = 0; i < sbl->l.n; i++) {
SBezier *sb = &sbl->l.elem[i];
for(int i = 0; i <= sb->deg; i++) {
screenBBox.Include(SS.GW.ProjectPoint3(sb->ctrl[i]));
}
for(auto &sb : sbl->l) {
for(int i = 0; i < sb.deg; ++i) { screenBBox.Include(SS.GW.ProjectPoint3(sb.ctrl[i])); }
}
} else ssassert(false, "Expected entity to be a point or have beziers");
} else
ssassert(false, "Expected entity to be a point or have beziers");

screenBBoxValid = true;
return screenBBox;
Expand Down Expand Up @@ -441,7 +439,7 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) const {

// Record our style for all of the Beziers that we just created.
for(; i < sbl->l.n; i++) {
sbl->l.elem[i].auxA = style.v;
sbl->l[i].auxA = style.v;
}
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL