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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
// Likewise the scale, which could otherwise take us out of the
// workplane.
pt = pt.ScaledBy(fabs(scale));
pt = pt.ScaleOutOfCsys(u, v, Vector::From(0, 0, 0));
pt = pt.ScaleOutOfCsys(u, v, {0, 0, 0});
pt = pt.Plus(p);
pt = pt.RotatedAbout(n, theta);
pt = pt.Plus(trans);
Expand Down Expand Up @@ -338,7 +338,7 @@ void GraphicsWindow::MenuClipboard(Command id) {
Entity *wrkpl = SK.GetEntity(SS.GW.ActiveWorkplane());
Vector p = SK.GetEntity(wrkpl->point[0])->PointGetNum();
SS.TW.shown.paste.times = 1;
SS.TW.shown.paste.trans = Vector::From(0, 0, 0);
SS.TW.shown.paste.trans = {};
SS.TW.shown.paste.theta = 0;
SS.TW.shown.paste.origin = p;
SS.TW.shown.paste.scale = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/confscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void TextWindow::ScreenChangeTurntableNav(int link, uint32_t v) {
SS.turntableNav = !SS.turntableNav;
if(SS.turntableNav) {
// If turntable nav is being turned on, align view so Z is vertical
SS.GW.AnimateOnto(Quaternion::From(Vector::From(-1, 0, 0), Vector::From(0, 0, 1)),
SS.GW.AnimateOnto(Quaternion::From({-1, 0, 0}, {0, 0, 1}),
SS.GW.offset);
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
case Edit::LIGHT_DIRECTION: {
double x, y, z;
if(sscanf(s.c_str(), "%lf, %lf, %lf", &x, &y, &z)==3) {
SS.lightDir[edit.i] = Vector::From(x, y, z);
SS.lightDir[edit.i] = {x, y, z};
SS.GW.Invalidate();
} else {
Error(_("Bad format: specify coordinates as x, y, z"));
Expand Down
2 changes: 1 addition & 1 deletion src/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void Constraint::MenuConstrain(Command id) {
c.disp.offset = n.Cross(a.Minus(b));
c.disp.offset = (c.disp.offset).WithMagnitude(50/SS.GW.scale);
} else {
c.disp.offset = Vector::From(0, 0, 0);
c.disp.offset = {};
}

if(id == Command::REF_DISTANCE) {
Expand Down
6 changes: 3 additions & 3 deletions src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ void GraphicsWindow::MakeSelected(Selection *stog) {
//-----------------------------------------------------------------------------
void GraphicsWindow::SelectByMarquee() {
Point2d marqueePoint = ProjectPoint(orig.marqueePoint);
BBox marqueeBBox = BBox::From(Vector::From(marqueePoint.x, marqueePoint.y, VERY_NEGATIVE),
Vector::From(orig.mouse.x, orig.mouse.y, VERY_POSITIVE));
BBox marqueeBBox = BBox::From({marqueePoint.x, marqueePoint.y, VERY_NEGATIVE},
{orig.mouse.x, orig.mouse.y, VERY_POSITIVE});

for(Entity &e : SK.entity) {
if(e.group != SS.GW.activeGroup) continue;
Expand Down Expand Up @@ -583,7 +583,7 @@ Vector GraphicsWindow::UnProjectPoint3(Vector p) {

void GraphicsWindow::NormalizeProjectionVectors() {
if(projRight.Magnitude() < LENGTH_EPS) {
projRight = Vector::From(1, 0, 0);
projRight = {1, 0, 0};
}

Vector norm = projRight.Cross(projUp);
Expand Down
15 changes: 7 additions & 8 deletions src/drawconstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ void Constraint::DoLayout(DrawAs how, Canvas *canvas,
RgbaColor cd = Style::Color(Style::DATUM),
cc = Style::Color(Style::CONSTRAINT);
// convert from 8-bit color to a vector
Vector vd = Vector::From(cd.redF(), cd.greenF(), cd.blueF()),
vc = Vector::From(cc.redF(), cc.greenF(), cc.blueF());
Vector vd = {cd.redF(), cd.greenF(), cd.blueF()},
vc = {cc.redF(), cc.greenF(), cc.blueF()};
// and scale the constraint color to have the same magnitude as
// the datum color, maybe a bit dimmer
vc = vc.WithMagnitude(vd.Magnitude()*0.9);
Expand Down Expand Up @@ -886,7 +886,7 @@ void Constraint::DoLayout(DrawAs how, Canvas *canvas,
}

case Type::PERPENDICULAR: {
Vector u = Vector::From(0, 0, 0), v = Vector::From(0, 0, 0);
Vector u = {}, v = {};
Vector rn, ru;
if(workplane == Entity::FREE_IN_3D) {
rn = gn;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ void Constraint::DoLayout(DrawAs how, Canvas *canvas,
case Type::LENGTH_RATIO:
case Type::LENGTH_DIFFERENCE:
case Type::EQUAL_LENGTH_LINES: {
Vector a, b = Vector::From(0, 0, 0);
Vector a, b;
for(int i = 0; i < 2; i++) {
Entity *e = SK.GetEntity(i == 0 ? entityA : entityB);
a = SK.GetEntity(e->point[0])->PointGetNum();
Expand Down Expand Up @@ -1092,11 +1092,10 @@ void Constraint::DoLayout(DrawAs how, Canvas *canvas,
}
case Type::ARC_LINE_LEN_RATIO:
case Type::ARC_LINE_DIFFERENCE: {
Vector a, b = Vector::From(0, 0, 0);
Vector ref;
Entity *e = SK.GetEntity(entityA);
a = SK.GetEntity(e->point[0])->PointGetNum();
b = SK.GetEntity(e->point[1])->PointGetNum();
Vector a = SK.GetEntity(e->point[0])->PointGetNum(),
b = SK.GetEntity(e->point[1])->PointGetNum();
Vector ref;
DoEqualLenTicks(canvas, hcs, a, b, gn, &ref);
if(refs) refs->push_back(ref);
DoEqualRadiusTicks(canvas, hcs, entityB, &ref);
Expand Down
14 changes: 7 additions & 7 deletions src/drawentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ void Entity::ComputeInterpolatingSpline(SBezierList *sbl, bool periodic) const {

// The starting and finishing control points that define our end tangents
// (if the spline isn't periodic), and the on-curve points.
Vector ctrl_s = Vector::From(0, 0, 0);
Vector ctrl_f = Vector::From(0, 0, 0);
Vector ctrl_s = {};
Vector ctrl_f = {};
Vector pt[MAX_N+4];
if(periodic) {
for(i = 0; i < ep + 3; i++) {
Expand Down Expand Up @@ -362,24 +362,24 @@ void Entity::ComputeInterpolatingSpline(SBezierList *sbl, bool periodic) const {
if(periodic) {
p0 = pt[i];
int iw = WRAP(i - 1, n);
p1 = p0.Plus(Vector::From(Xx[iw], Xy[iw], Xz[iw]));
p1 = p0.Plus({Xx[iw], Xy[iw], Xz[iw]});
} else if(i == 0) {
p0 = pt[0];
p1 = ctrl_s;
} else {
p0 = pt[i];
p1 = p0.Plus(Vector::From(Xx[i-1], Xy[i-1], Xz[i-1]));
p1 = p0.Plus({Xx[i-1], Xy[i-1], Xz[i-1]});
}
if(periodic) {
p3 = pt[i+1];
int iw = WRAP(i, n);
p2 = p3.Minus(Vector::From(Xx[iw], Xy[iw], Xz[iw]));
p2 = p3.Minus({Xx[iw], Xy[iw], Xz[iw]});
} else if(i == (pts - 2)) {
p3 = pt[pts-1];
p2 = ctrl_f;
} else {
p3 = pt[i+1];
p2 = p3.Minus(Vector::From(Xx[i], Xy[i], Xz[i]));
p2 = p3.Minus({Xx[i], Xy[i], Xz[i]});
}
SBezier sb = SBezier::From(p0, p1, p2, p3);
sbl->l.Add(&sb);
Expand Down Expand Up @@ -503,7 +503,7 @@ Vector Entity::ExplodeOffset() const {
double offset = SS.explodeDistance * (requestIdx + 1);
return SK.GetEntity(workplane)->Normal()->NormalN().ScaledBy(offset);
} else {
return Vector::From(0, 0, 0);
return {};
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ bool EntityBase::IsFace() const {
ExprVector EntityBase::FaceGetNormalExprs() const {
ExprVector r;
if(type == Type::FACE_NORMAL_PT) {
Vector v = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
Vector v = {numNormal.vx, numNormal.vy, numNormal.vz};
r = ExprVector::From(v.WithMagnitude(1));
} else if(type == Type::FACE_XPROD) {
ExprVector vc = ExprVector::From(param[0], param[1], param[2]);
Expand Down Expand Up @@ -752,20 +752,20 @@ ExprVector EntityBase::FaceGetNormalExprs() const {
Vector EntityBase::FaceGetNormalNum() const {
Vector r;
if(type == Type::FACE_NORMAL_PT) {
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
r = {numNormal.vx, numNormal.vy, numNormal.vz};
} else if(type == Type::FACE_XPROD) {
Vector vc = Vector::From(param[0], param[1], param[2]);
Vector vn = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
Vector vn = {numNormal.vx, numNormal.vy, numNormal.vz};
r = vc.Cross(vn);
} else if(type == Type::FACE_N_ROT_TRANS) {
// The numerical normal vector gets the rotation
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
r = {numNormal.vx, numNormal.vy, numNormal.vz};
Quaternion q = Quaternion::From(param[3], param[4], param[5], param[6]);
r = q.Rotate(r);
} else if(type == Type::FACE_N_TRANS) {
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
r = {numNormal.vx, numNormal.vy, numNormal.vz};
} else if((type == Type::FACE_N_ROT_AA) || (type == Type::FACE_ROT_NORMAL_PT)) {
r = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
r = {numNormal.vx, numNormal.vy, numNormal.vz};
Quaternion q = GetAxisAngleQuaternion(3);
r = q.Rotate(r);
} else ssassert(false, "Unexpected entity type");
Expand Down
20 changes: 10 additions & 10 deletions src/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const Platform::Path &filename, bool
}

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),
origin = Vector::From(0.0, 0.0, 0.0);
Vector u = {1.0, 0.0, 0.0},
v = {0.0, 1.0, 0.0},
n = {0.0, 0.0, 1.0},
origin = {};
double cameraTan = 0.0,
scale = 1.0;

Expand Down Expand Up @@ -344,7 +344,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
sel->Clear();

SPolygon compd = {};
sp.normal = Vector::From(0, 0, -1);
sp.normal = {0, 0, -1};
sp.FixContourDirections();
sp.OffsetInto(&compd, SS.exportOffset*s);
sp.Clear();
Expand Down Expand Up @@ -591,9 +591,9 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// will then get exported as closed paths.
SBezierLoopSetSet sblss = {};
SBezierLoopSet leftovers = {};
SSurface srf = SSurface::FromPlane(Vector::From(0, 0, 0),
Vector::From(1, 0, 0),
Vector::From(0, 1, 0));
SSurface srf = SSurface::FromPlane({0, 0, 0},
{1, 0, 0},
{0, 1, 0});
SPolygon spxyz = {};
bool allClosed;
SEdge notClosedAt;
Expand Down Expand Up @@ -685,8 +685,8 @@ void VectorFileWriter::OutputLinesAndMesh(SBezierLoopSetSet *sblss, SMesh *sm) {
SBezier *b;

// First calculate the bounding box.
ptMin = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
ptMax = Vector::From(VERY_NEGATIVE, VERY_NEGATIVE, VERY_NEGATIVE);
ptMin = {VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE};
ptMax = {VERY_NEGATIVE, VERY_NEGATIVE, VERY_NEGATIVE};
if(sm) {
for(tr = sm->l.First(); tr; tr = sm->l.NextAfter(tr)) {
(tr->a).MakeMaxMin(&ptMax, &ptMin);
Expand Down
16 changes: 8 additions & 8 deletions src/exportvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ class DxfWriteInterface : public DRW_Interface {
int findDxfColor(const RgbaColor &src) {
int best = 0;
double minDist = VERY_POSITIVE;
Vector srcv = Vector::From(src.redF(), src.greenF(), src.blueF());
Vector srcv = {src.redF(), src.greenF(), src.blueF()};
for(int i = 1; i < 256; i++) {
RgbaColor dst = RGBi(DRW::dxfColors[i][0], DRW::dxfColors[i][1], DRW::dxfColors[i][2]);
Vector dstv = Vector::From(dst.redF(), dst.greenF(), dst.blueF());
Vector dstv = {dst.redF(), dst.greenF(), dst.blueF()};
double dist = srcv.Minus(dstv).Magnitude();
if(dist < minDist || best == 0) {
best = i;
Expand Down Expand Up @@ -421,7 +421,7 @@ class DxfWriteInterface : public DRW_Interface {
void writeBezier(SBezier *sb) {
hStyle hs = { (uint32_t)sb->auxA };
Vector c;
Vector n = Vector::From(0.0, 0.0, 1.0);
Vector n = {0.0, 0.0, 1.0};
double r;

if(sb->deg == 1) {
Expand Down Expand Up @@ -732,7 +732,7 @@ void EpsFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb, hStyle hs)
{
fprintf(f, "newpath\r\n");
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
prevPt = {VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE};
}
void EpsFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb, hStyle hs)
Expand Down Expand Up @@ -789,7 +789,7 @@ void EpsFileWriter::Triangle(STriangle *tr) {
}

void EpsFileWriter::Bezier(SBezier *sb) {
Vector c, n = Vector::From(0, 0, 1);
Vector c, n = {0, 0, 1};
double r;
if(sb->deg == 1) {
MaybeMoveTo(sb->ctrl[0], sb->ctrl[1]);
Expand Down Expand Up @@ -999,7 +999,7 @@ void PdfFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
fillRgb.redF(), fillRgb.greenF(), fillRgb.blueF());
}

prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
prevPt = {VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE};
}
void PdfFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb, hStyle hs)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ void SvgFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb, hStyle hs)
{
fprintf(f, "<path d='");
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
prevPt = {VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE};
}
void SvgFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb, hStyle hs)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ void SvgFileWriter::Triangle(STriangle *tr) {
}

void SvgFileWriter::Bezier(SBezier *sb) {
Vector c, n = Vector::From(0, 0, 1);
Vector c, n = {0, 0, 1};
double r;
if(sb->deg == 1) {
MaybeMoveTo(sb->ctrl[0], sb->ctrl[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/generate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void SolveSpaceUI::ForceReferences() {
Entity *wrkpl = SK.GetEntity(hr.entity(0));
// The origin for our coordinate system, always zero
Entity *origin = SK.GetEntity(wrkpl->point[0]);
origin->PointForceTo(Vector::From(0, 0, 0));
origin->PointForceTo({0, 0, 0});
origin->construction = true;
SK.GetParam(origin->param[0])->known = true;
SK.GetParam(origin->param[1])->known = true;
Expand Down
14 changes: 7 additions & 7 deletions src/graphicswin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ void GraphicsWindow::PopulateRecentFiles() {

void GraphicsWindow::Init() {
scale = 5;
offset = Vector::From(0, 0, 0);
projRight = Vector::From(1, 0, 0);
projUp = Vector::From(0, 1, 0);
offset = {0, 0, 0};
projRight = {1, 0, 0};
projUp = {0, 1, 0};

// Make sure those are valid; could get a mouse move without a mouse
// down if someone depresses the button, then drags into our window.
Expand Down Expand Up @@ -816,9 +816,9 @@ void GraphicsWindow::MenuView(Command id) {
case Command::NEAREST_ORTHO:
case Command::NEAREST_ISO: {
static const Vector ortho[3] = {
Vector::From(1, 0, 0),
Vector::From(0, 1, 0),
Vector::From(0, 0, 1)
{1, 0, 0},
{0, 1, 0},
{0, 0, 1}
};
double sqrt2 = sqrt(2.0), sqrt6 = sqrt(6.0);
Quaternion quat0 = Quaternion::From(SS.GW.projRight, SS.GW.projUp);
Expand Down Expand Up @@ -1216,7 +1216,7 @@ void GraphicsWindow::MenuEdit(Command id) {
norm = norm.WithMagnitude(1);
Quaternion qaa = Quaternion::From(norm, PI/2);

g->TransformImportedBy(Vector::From(0, 0, 0), qaa);
g->TransformImportedBy({0, 0, 0}, qaa);

// and regenerate as necessary.
SS.MarkGroupDirty(hg);
Expand Down
4 changes: 2 additions & 2 deletions src/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ void Group::MakeRevolveEndFaces(EntityList *el, hEntity pt, int ai, int af)

// When there is no loop normal (e.g. if the loop is broken), use normal of workplane
// as fallback, to avoid breaking constraints depending on the faces.
if(n.Equals(Vector::From(0.0, 0.0, 0.0)) && src->type == Group::Type::DRAWING_WORKPLANE) {
if(n.Equals({0, 0, 0}) && src->type == Group::Type::DRAWING_WORKPLANE) {
n = SK.GetEntity(src->h.entity(0))->Normal()->NormalN();
}

Expand Down Expand Up @@ -1039,7 +1039,7 @@ void Group::MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt)

// When there is no loop normal (e.g. if the loop is broken), use normal of workplane
// as fallback, to avoid breaking constraints depending on the faces.
if(n.Equals(Vector::From(0.0, 0.0, 0.0)) && src->type == Group::Type::DRAWING_WORKPLANE) {
if(n.Equals({0, 0, 0}) && src->type == Group::Type::DRAWING_WORKPLANE) {
n = SK.GetEntity(src->h.entity(0))->Normal()->NormalN();
}

Expand Down
10 changes: 5 additions & 5 deletions src/groupmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void Group::GenerateShellAndMesh() {

Vector tbot, ttop;
if(subtype == Subtype::ONE_SIDED || subtype == Subtype::ONE_SKEWED) {
tbot = Vector::From(0, 0, 0); ttop = translate.ScaledBy(2);
tbot = {}; ttop = translate.ScaledBy(2);
} else {
tbot = translate.ScaledBy(-1); ttop = translate.ScaledBy(1);
}
Expand Down Expand Up @@ -779,10 +779,10 @@ void Group::DrawContourAreaLabels(Canvas *canvas) {

Vector min = sbls.l[0].l[0].ctrl[0];
Vector max = min;
Vector zero = Vector::From(0.0, 0.0, 0.0);
sbls.GetBoundingProjd(Vector::From(1.0, 0.0, 0.0), zero, &min.x, &max.x);
sbls.GetBoundingProjd(Vector::From(0.0, 1.0, 0.0), zero, &min.y, &max.y);
sbls.GetBoundingProjd(Vector::From(0.0, 0.0, 1.0), zero, &min.z, &max.z);
Vector zero = {};
sbls.GetBoundingProjd({1.0, 0.0, 0.0}, zero, &min.x, &max.x);
sbls.GetBoundingProjd({0.0, 1.0, 0.0}, zero, &min.y, &max.y);
sbls.GetBoundingProjd({0.0, 0.0, 1.0}, zero, &min.z, &max.z);

Vector mid = min.Plus(max).ScaledBy(0.5);

Expand Down
Loading
Loading