Replace all ZERO and memset with C++11 brace-initialization.

This will allow us to use non-POD classes inside these objects
in future and is otherwise functionally equivalent, as well
as more concise.

Note that there are some subtleties with handling of
brace-initialization. Specifically:

On aggregates (e.g. simple C-style structures) using an empty
brace-initializer zero-initializes the aggregate, i.e. it makes
all members zero.

On non-aggregates an empty brace-initializer calls the default
constructor. And if the constructor doesn't explicitly initialize
the members (which the auto-generated constructor doesn't) then
the members will be constructed but otherwise uninitialized.

So, what is an aggregate class? To quote the C++ standard
(C++03 8.5.1 §1):

An aggregate is an array or a class (clause 9) with no
user-declared constructors (12.1), no private or protected
non-static data members (clause 11), no base classes (clause 10),
and no virtual functions (10.3).

In SolveSpace, we only have to handle the case of base classes;
Constraint and Entity have those. Thus, they had to gain a default
constructor that does nothing but initializes the members to zero.
pull/4/head
whitequark 2015-03-27 18:31:23 +03:00
parent 02c30e6f87
commit 45f056c852
40 changed files with 249 additions and 401 deletions

View File

@ -256,7 +256,6 @@ static void Example2d(void)
int main(void)
{
memset(&sys, 0, sizeof(sys));
sys.param = CheckMalloc(50*sizeof(sys.param[0]));
sys.entity = CheckMalloc(50*sizeof(sys.entity[0]));
sys.constraint = CheckMalloc(50*sizeof(sys.constraint[0]));

View File

@ -15,7 +15,7 @@ SBsp3 *SBsp3::FromMesh(SMesh *m) {
SBsp3 *bsp3 = NULL;
int i;
SMesh mc; ZERO(&mc);
SMesh mc = {};
for(i = 0; i < m->l.n; i++) {
mc.AddTriangle(&(m->l.elem[i]));
}
@ -288,8 +288,7 @@ SBsp3 *SBsp3::Insert(STriangle *tr, SMesh *instead) {
double dt[3] = { (tr->a).Dot(n), (tr->b).Dot(n), (tr->c).Dot(n) };
int inc = 0, posc = 0, negc = 0;
bool isPos[3], isNeg[3], isOn[3];
ZERO(&isPos); ZERO(&isNeg); ZERO(&isOn);
bool isPos[3] = {}, isNeg[3] = {}, isOn[3] = {};
// Count vertices in the plane
for(int i = 0; i < 3; i++) {
if(fabs(dt[i] - d) < LENGTH_EPS) {
@ -492,8 +491,7 @@ SBsp2 *SBsp2::InsertEdge(SEdge *nedge, Vector nnp, Vector out) {
double dt[2] = { (nedge->a).Dot(no), (nedge->b).Dot(no) };
bool isPos[2], isNeg[2], isOn[2];
ZERO(&isPos); ZERO(&isNeg); ZERO(&isOn);
bool isPos[2] = {}, isNeg[2] = {}, isOn[2] = {};
for(int i = 0; i < 2; i++) {
if(fabs(dt[i] - d) < LENGTH_EPS) {
isOn[i] = true;
@ -570,9 +568,8 @@ void SBsp2::InsertTriangleHow(int how, STriangle *tr, SMesh *m, SBsp3 *bsp3) {
void SBsp2::InsertTriangle(STriangle *tr, SMesh *m, SBsp3 *bsp3) {
double dt[3] = { (tr->a).Dot(no), (tr->b).Dot(no), (tr->c).Dot(no) };
bool isPos[3], isNeg[3], isOn[3];
bool isPos[3] = {}, isNeg[3] = {}, isOn[3] = {};
int inc = 0, posc = 0, negc = 0;
ZERO(&isPos); ZERO(&isNeg); ZERO(&isOn);
for(int i = 0; i < 3; i++) {
if(fabs(dt[i] - d) < LENGTH_EPS) {
isOn[i] = true;

View File

@ -82,8 +82,7 @@ void GraphicsWindow::CopySelection(void) {
}
if(req == Request::WORKPLANE) continue;
ClipboardRequest cr;
ZERO(&cr);
ClipboardRequest cr = {};
cr.type = req;
cr.extraPoints = e->extraPoints;
cr.style = e->style;

View File

@ -1063,8 +1063,7 @@ void SolveSpace::LoadAllFontFiles(void) {
CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fontRef, kCTFontURLAttribute);
NSString *fontPath = [NSString stringWithString:[(NSURL *)CFBridgingRelease(url) path]];
if([[fontPath pathExtension] isEqual:@"ttf"]) {
TtfFont tf;
ZERO(&tf);
TtfFont tf = {};
strcpy(tf.fontFile, [[NSFileManager defaultManager]
fileSystemRepresentationWithPath:fontPath]);
SS.fonts.l.Add(&tf);

View File

@ -94,8 +94,7 @@ void Constraint::Constrain(int type, hEntity ptA, hEntity ptB,
hEntity entityA, hEntity entityB,
bool other, bool other2)
{
Constraint c;
memset(&c, 0, sizeof(c));
Constraint c = {};
c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane();
c.type = type;
@ -116,8 +115,7 @@ void Constraint::ConstrainCoincident(hEntity ptA, hEntity ptB) {
}
void Constraint::MenuConstrain(int id) {
Constraint c;
ZERO(&c);
Constraint c = {};
c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane();

View File

@ -179,9 +179,7 @@ void ConstraintBase::ModifyToSatisfy(void) {
} else {
// We'll fix these ones up by looking at their symbolic equation;
// that means no extra work.
IdList<Equation,hEquation> l;
// An uninit IdList could lead us to free some random address, bad.
ZERO(&l);
IdList<Equation,hEquation> l = {};
// Generate the equations even if this is a reference dimension
GenerateReal(&l);
if(l.n != 1) oops();

View File

@ -99,8 +99,7 @@ void GraphicsWindow::ClearNonexistentSelectionItems(void) {
// Is this entity/constraint selected?
//-----------------------------------------------------------------------------
bool GraphicsWindow::IsSelected(hEntity he) {
Selection s;
ZERO(&s);
Selection s = {};
s.entity = he;
return IsSelected(&s);
}
@ -121,8 +120,7 @@ bool GraphicsWindow::IsSelected(Selection *st) {
// would otherwise be impossible to de-select the lower of the two.
//-----------------------------------------------------------------------------
void GraphicsWindow::MakeUnselected(hEntity he, bool coincidentPointTrick) {
Selection stog;
ZERO(&stog);
Selection stog = {};
stog.entity = he;
MakeUnselected(&stog, coincidentPointTrick);
}
@ -164,8 +162,7 @@ void GraphicsWindow::MakeUnselected(Selection *stog, bool coincidentPointTrick){
// Select an item, if it isn't selected already.
//-----------------------------------------------------------------------------
void GraphicsWindow::MakeSelected(hEntity he) {
Selection stog;
ZERO(&stog);
Selection stog = {};
stog.entity = he;
MakeSelected(&stog);
}
@ -225,8 +222,7 @@ void GraphicsWindow::SelectByMarquee(void) {
// includes the z = 0 plane.
Vector ptMin = Vector::From(xmin, ymin, -1),
ptMax = Vector::From(xmax, ymax, 1);
SEdgeList sel;
ZERO(&sel);
SEdgeList sel = {};
e->GenerateEdges(&sel, true);
SEdge *se;
for(se = sel.l.First(); se; se = sel.l.NextAfter(se)) {
@ -254,7 +250,7 @@ void GraphicsWindow::SelectByMarquee(void) {
// lines, etc.), and so on.
//-----------------------------------------------------------------------------
void GraphicsWindow::GroupSelection(void) {
memset(&gs, 0, sizeof(gs));
gs = {};
int i;
for(i = 0; i < selection.n && i < MAX_SELECTED; i++) {
Selection *s = &(selection.elem[i]);
@ -321,8 +317,7 @@ void GraphicsWindow::GroupSelection(void) {
void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
int i;
double d, dmin = 1e12;
Selection s;
ZERO(&s);
Selection s = {};
// Always do the entities; we might be dragging something that should
// be auto-constrained, and we need the hover for that.
@ -343,7 +338,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
d = e->GetDistance(mp);
if(d < 10 && d < dmin) {
memset(&s, 0, sizeof(s));
s = {};
s.entity = e->h;
dmin = d;
}
@ -355,7 +350,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
for(i = 0; i < SK.constraint.n; i++) {
d = SK.constraint.elem[i].GetDistance(mp);
if(d < 10 && d < dmin) {
memset(&s, 0, sizeof(s));
s = {};
s.constraint = SK.constraint.elem[i].h;
dmin = d;
}
@ -714,8 +709,7 @@ nogrid:;
SuggestedConstraint suggested =
SS.GW.SuggestLineConstraint(SS.GW.pending.request);
if(suggested != GraphicsWindow::SUGGESTED_NONE) {
Constraint c;
ZERO(&c);
Constraint c = {};
c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane();
c.type = suggested;

View File

@ -124,16 +124,14 @@ void Entity::Draw(void) {
void Entity::GenerateEdges(SEdgeList *el, bool includingConstruction) {
if(construction && !includingConstruction) return;
SBezierList sbl;
ZERO(&sbl);
SBezierList sbl = {};
GenerateBezierCurves(&sbl);
int i, j;
for(i = 0; i < sbl.l.n; i++) {
SBezier *sb = &(sbl.l.elem[i]);
List<Vector> lv;
ZERO(&lv);
List<Vector> lv = {};
sb->MakePwlInto(&lv);
for(j = 1; j < lv.n; j++) {
el->AddEdge(lv.elem[j-1], lv.elem[j], style.v);
@ -266,8 +264,7 @@ void Entity::ComputeInterpolatingSpline(SBezierList *sbl, bool periodic) {
// f''(0) = 6*(P0 - 2*P1 + P2)
// f''(1) = 6*(P3 - 2*P2 + P1)
for(a = 0; a < 3; a++) {
BandedMatrix bm;
ZERO(&bm);
BandedMatrix bm = {};
bm.n = n;
for(i = 0; i < n; i++) {
@ -650,8 +647,7 @@ void Entity::DrawOrGetDistance(void) {
// And draw the curves; generate the rational polynomial curves for
// everything, then piecewise linearize them, and display those.
SEdgeList sel;
ZERO(&sel);
SEdgeList sel = {};
GenerateEdges(&sel, true);
int i;
for(i = 0; i < sel.l.n; i++) {

View File

@ -71,10 +71,8 @@ void SolveSpaceUI::ExportSectionTo(const char *filename) {
n = n.WithMagnitude(1);
d = origin.Dot(n);
SEdgeList el;
ZERO(&el);
SBezierList bl;
ZERO(&bl);
SEdgeList el = {};
SBezierList bl = {};
// If there's a mesh, then grab the edges from it.
g->runningMesh.MakeEdgesInPlaneInto(&el, n, d);
@ -111,10 +109,8 @@ void SolveSpaceUI::ExportSectionTo(const char *filename) {
void SolveSpaceUI::ExportViewOrWireframeTo(const char *filename, bool wireframe) {
int i;
SEdgeList edges;
ZERO(&edges);
SBezierList beziers;
ZERO(&beziers);
SEdgeList edges = {};
SBezierList beziers = {};
SMesh *sm = NULL;
if(SS.GW.showShaded) {
@ -197,8 +193,7 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const char *filename, bool wireframe)
void SolveSpaceUI::ExportWireframeCurves(SEdgeList *sel, SBezierList *sbl,
VectorFileWriter *out)
{
SBezierLoopSetSet sblss;
ZERO(&sblss);
SBezierLoopSetSet sblss = {};
SEdge *se;
for(se = sel->l.First(); se; se = sel->l.NextAfter(se)) {
SBezier sb = SBezier::From(
@ -247,13 +242,11 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// If cutter radius compensation is requested, then perform it now
if(fabs(SS.exportOffset) > LENGTH_EPS) {
// assemble those edges into a polygon, and clear the edge list
SPolygon sp;
ZERO(&sp);
SPolygon sp = {};
sel->AssemblePolygon(&sp, NULL);
sel->Clear();
SPolygon compd;
ZERO(&compd);
SPolygon compd = {};
sp.normal = Vector::From(0, 0, -1);
sp.FixContourDirections();
sp.OffsetInto(&compd, SS.exportOffset*s);
@ -265,8 +258,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// Now the triangle mesh; project, then build a BSP to perform
// occlusion testing and generated the shaded surfaces.
SMesh smp;
ZERO(&smp);
SMesh smp = {};
if(sm) {
Vector l0 = (SS.lightDir[0]).WithMagnitude(1),
l1 = (SS.lightDir[1]).WithMagnitude(1);
@ -292,8 +284,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// Use the BSP routines to generate the split triangles in paint order.
SBsp3 *bsp = SBsp3::FromMesh(&smp);
SMesh sms;
ZERO(&sms);
SMesh sms = {};
bsp->GenerateInPaintOrder(&sms);
// And cull the back-facing triangles
STriangle *tr;
@ -307,8 +298,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
sms.l.RemoveTagged();
// And now we perform hidden line removal if requested
SEdgeList hlrd;
ZERO(&hlrd);
SEdgeList hlrd = {};
if(sm && !SS.GW.showHdnLines) {
SKdNode *root = SKdNode::From(&smp);
@ -331,8 +321,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
continue;
}
SEdgeList out;
ZERO(&out);
SEdgeList out = {};
// Split the original edge against the mesh
out.AddEdge(se->a, se->b, se->auxA);
root->OcclusionTestLine(*se, &out, cnt);
@ -366,15 +355,12 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// If possible, then we will assemble these output curves into loops. They
// will then get exported as closed paths.
SBezierLoopSetSet sblss;
ZERO(&sblss);
SBezierList leftovers;
ZERO(&leftovers);
SBezierLoopSetSet sblss = {};
SBezierList leftovers = {};
SSurface srf = SSurface::FromPlane(Vector::From(0, 0, 0),
Vector::From(1, 0, 0),
Vector::From(0, 1, 0));
SPolygon spxyz;
ZERO(&spxyz);
SPolygon spxyz = {};
bool allClosed;
SEdge notClosedAt;
sbl->l.ClearTags();
@ -522,8 +508,7 @@ void VectorFileWriter::Output(SBezierLoopSetSet *sblss, SMesh *sm) {
}
void VectorFileWriter::BezierAsPwl(SBezier *sb) {
List<Vector> lv;
ZERO(&lv);
List<Vector> lv = {};
sb->MakePwlInto(&lv, SS.ChordTolMm() / SS.exportScale);
int i;
for(i = 1; i < lv.n; i++) {
@ -606,8 +591,7 @@ void SolveSpaceUI::ExportMeshTo(const char *filename) {
// not self-intersecting, so not much to do.
//-----------------------------------------------------------------------------
void SolveSpaceUI::ExportMeshAsStlTo(FILE *f, SMesh *sm) {
char str[80];
memset(str, 0, sizeof(str));
char str[80] = {};
strcpy(str, "STL exported mesh");
fwrite(str, 1, 80, f);
@ -642,8 +626,7 @@ void SolveSpaceUI::ExportMeshAsStlTo(FILE *f, SMesh *sm) {
// identical vertices to the same identifier, so do that first.
//-----------------------------------------------------------------------------
void SolveSpaceUI::ExportMeshAsObjTo(FILE *f, SMesh *sm) {
SPointList spl;
ZERO(&spl);
SPointList spl = {};
STriangle *tr;
for(tr = sm->l.First(); tr; tr = sm->l.NextAfter(tr)) {
spl.IncrementTagFor(tr->a);
@ -678,8 +661,7 @@ void SolveSpaceUI::ExportMeshAsObjTo(FILE *f, SMesh *sm) {
void SolveSpaceUI::ExportMeshAsThreeJsTo(FILE *f, const char * filename, SMesh *sm,
SEdgeList *sel)
{
SPointList spl;
ZERO(&spl);
SPointList spl = {};
STriangle *tr;
SEdge *e;
Vector bndl, bndh;

View File

@ -119,8 +119,7 @@ int StepFileWriter::ExportCurve(SBezier *sb) {
int StepFileWriter::ExportCurveLoop(SBezierLoop *loop, bool inner) {
if(loop->l.n < 1) oops();
List<int> listOfTrims;
ZERO(&listOfTrims);
List<int> listOfTrims = {};
SBezier *sb = &(loop->l.elem[loop->l.n - 1]);
@ -229,10 +228,8 @@ void StepFileWriter::ExportSurface(SSurface *ss, SBezierList *sbl) {
// Now we do the trim curves. We must group each outer loop separately
// along with its inner faces, so do that now.
SBezierLoopSetSet sblss;
ZERO(&sblss);
SPolygon spxyz;
ZERO(&spxyz);
SBezierLoopSetSet sblss = {};
SPolygon spxyz = {};
bool allClosed;
SEdge notClosedAt;
// We specify a surface, so it doesn't check for coplanarity; and we
@ -252,8 +249,7 @@ void StepFileWriter::ExportSurface(SSurface *ss, SBezierList *sbl) {
for(sbls = sblss.l.First(); sbls; sbls = sblss.l.NextAfter(sbls)) {
SBezierLoop *loop = sbls->l.First();
List<int> listOfLoops;
ZERO(&listOfLoops);
List<int> listOfLoops = {};
// Create the face outer boundary from the outer loop.
int fob = ExportCurveLoop(loop, false);
listOfLoops.Add(&fob);
@ -318,7 +314,7 @@ void StepFileWriter::ExportSurfacesTo(char *file) {
WriteHeader();
WriteProductHeader();
ZERO(&advancedFaces);
advancedFaces = {};
SSurface *ss;
for(ss = shell->surface.First(); ss; ss = shell->surface.NextAfter(ss)) {
@ -327,8 +323,7 @@ void StepFileWriter::ExportSurfacesTo(char *file) {
// Get all of the loops of Beziers that trim our surface (with each
// Bezier split so that we use the section as t goes from 0 to 1), and
// the piecewise linearization of those loops in xyz space.
SBezierList sbl;
ZERO(&sbl);
SBezierList sbl = {};
ss->MakeSectionEdgesInto(shell, NULL, &sbl);
// Apply the export scale factor.

View File

@ -626,7 +626,7 @@ void HpglFileWriter::FinishAndCloseFile(void) {
// set in the configuration screen.
//-----------------------------------------------------------------------------
void GCodeFileWriter::StartFile(void) {
ZERO(&sel);
sel = {};
}
void GCodeFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth,
bool filled, RgbaColor fillRgb)
@ -648,8 +648,7 @@ void GCodeFileWriter::Bezier(SBezier *sb) {
}
void GCodeFileWriter::FinishAndCloseFile(void) {
SPolygon sp;
ZERO(&sp);
SPolygon sp = {};
sel.AssemblePolygon(&sp, NULL);
int i;
@ -689,7 +688,7 @@ void GCodeFileWriter::FinishAndCloseFile(void) {
// can also be used for surfaces or 3d curves.
//-----------------------------------------------------------------------------
void Step2dFileWriter::StartFile(void) {
ZERO(&sfw);
sfw = {};
sfw.f = f;
sfw.WriteHeader();
}

View File

@ -35,8 +35,7 @@ void SolveSpaceUI::ClearExisting(void) {
}
hGroup SolveSpaceUI::CreateDefaultDrawingGroup(void) {
Group g;
ZERO(&g);
Group g = {};
// And an empty group, for the first stuff the user draws.
g.visible = true;
@ -55,8 +54,7 @@ void SolveSpaceUI::NewFile(void) {
ClearExisting();
// Our initial group, that contains the references.
Group g;
memset(&g, 0, sizeof(g));
Group g = {};
g.visible = true;
g.name.strcpy("#references");
g.type = Group::DRAWING_3D;
@ -65,8 +63,7 @@ void SolveSpaceUI::NewFile(void) {
// Let's create three two-d coordinate systems, for the coordinate
// planes; these are our references, present in every sketch.
Request r;
ZERO(&r);
Request r = {};
r.type = Request::WORKPLANE;
r.group = Group::HGROUP_REFERENCES;
r.workplane = Entity::FREE_IN_3D;
@ -396,7 +393,7 @@ void SolveSpaceUI::LoadUsingTable(char *key, char *val) {
// makes a shallow copy, so that would result in us
// freeing memory that we want to keep around. Just
// zero it out so that new memory is allocated.
memset(&(p->M), 0, sizeof(p->M));
p->M = {};
for(;;) {
EntityMap em;
char line2[1024];
@ -435,7 +432,7 @@ bool SolveSpaceUI::LoadFromFile(const char *filename) {
ClearExisting();
memset(&sv, 0, sizeof(sv));
sv = {};
sv.g.scale = 1; // default is 1, not 0; so legacy files need this
char line[1024];
@ -456,24 +453,24 @@ bool SolveSpaceUI::LoadFromFile(const char *filename) {
LoadUsingTable(key, val);
} else if(strcmp(line, "AddGroup")==0) {
SK.group.Add(&(sv.g));
ZERO(&(sv.g));
sv.g = {};
sv.g.scale = 1; // default is 1, not 0; so legacy files need this
} else if(strcmp(line, "AddParam")==0) {
// params are regenerated, but we want to preload the values
// for initial guesses
SK.param.Add(&(sv.p));
ZERO(&(sv.p));
sv.p = {};
} else if(strcmp(line, "AddEntity")==0) {
// entities are regenerated
} else if(strcmp(line, "AddRequest")==0) {
SK.request.Add(&(sv.r));
ZERO(&(sv.r));
sv.r = {};
} else if(strcmp(line, "AddConstraint")==0) {
SK.constraint.Add(&(sv.c));
ZERO(&(sv.c));
sv.c = {};
} else if(strcmp(line, "AddStyle")==0) {
SK.style.Add(&(sv.s));
ZERO(&(sv.s));
sv.s = {};
} else if(strcmp(line, VERSION_STRING)==0) {
// do nothing, version string
} else if(StrStartsWith(line, "Triangle ") ||
@ -507,18 +504,16 @@ bool SolveSpaceUI::LoadFromFile(const char *filename) {
}
bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
SMesh *m, SShell *sh)
SMesh *m, SShell *sh)
{
SSurface srf;
ZERO(&srf);
SCurve crv;
ZERO(&crv);
SSurface srf = {};
SCurve crv = {};
fh = fopen(file, "rb");
if(!fh) return false;
le->Clear();
memset(&sv, 0, sizeof(sv));
sv = {};
char line[1024];
while(fgets(line, (int)sizeof(line), fh)) {
@ -544,7 +539,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
} else if(strcmp(line, "AddEntity")==0) {
le->Add(&(sv.e));
memset(&(sv.e), 0, sizeof(sv.e));
sv.e = {};
} else if(strcmp(line, "AddRequest")==0) {
} else if(strcmp(line, "AddConstraint")==0) {
@ -554,7 +549,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
} else if(strcmp(line, VERSION_STRING)==0) {
} else if(StrStartsWith(line, "Triangle ")) {
STriangle tr; ZERO(&tr);
STriangle tr = {};
unsigned int rgba = 0;
if(sscanf(line, "Triangle %x %x "
"%lf %lf %lf %lf %lf %lf %lf %lf %lf",
@ -586,8 +581,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
srf.ctrl[i][j] = c;
srf.weight[i][j] = w;
} else if(StrStartsWith(line, "TrimBy ")) {
STrimBy stb;
ZERO(&stb);
STrimBy stb = {};
int backwards;
if(sscanf(line, "TrimBy %x %d %lf %lf %lf %lf %lf %lf",
&(stb.curve.v), &backwards,
@ -600,7 +594,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
srf.trim.Add(&stb);
} else if(strcmp(line, "AddSurface")==0) {
sh->surface.Add(&srf);
ZERO(&srf);
srf = {};
} else if(StrStartsWith(line, "Curve ")) {
int isExact;
if(sscanf(line, "Curve %x %d %d %x %x",
@ -636,7 +630,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le,
crv.pts.Add(&scpt);
} else if(strcmp(line, "AddCurve")==0) {
sh->curve.Add(&crv);
ZERO(&crv);
crv = {};
} else {
oops();
}

View File

@ -175,7 +175,7 @@ void SolveSpaceUI::GenerateAll(int first, int last, bool andFindFree) {
;
// Don't lose our numerical guesses when we regenerate.
IdList<Param,hParam> prev;
IdList<Param,hParam> prev = {};
SK.param.MoveSelfInto(&prev);
SK.entity.Clear();
@ -336,7 +336,8 @@ void SolveSpaceUI::GenerateAll(int first, int last, bool andFindFree) {
deleted.constraints, deleted.constraints == 1 ? "" : "s",
deleted.groups, deleted.groups == 1 ? "" : "s");
}
memset(&deleted, 0, sizeof(deleted));
deleted = {};
}
FreeAllTemporary();

View File

@ -215,8 +215,6 @@ bool SolveSpace::MakeAcceleratorLabel(int accel, char *out) {
}
void GraphicsWindow::Init(void) {
memset(this, 0, sizeof(*this));
scale = 5;
offset = Vector::From(0, 0, 0);
projRight = Vector::From(1, 0, 0);

View File

@ -37,8 +37,7 @@ void Group::Clear(void) {
}
void Group::AddParam(IdList<Param,hParam> *param, hParam hp, double v) {
Param pa;
memset(&pa, 0, sizeof(pa));
Param pa = {};
pa.h = hp;
pa.val = v;
@ -52,8 +51,7 @@ bool Group::IsVisible(void) {
}
void Group::MenuGroup(int id) {
Group g;
ZERO(&g);
Group g = {};
g.visible = true;
g.color = RGBi(100, 100, 100);
g.scale = 1;
@ -326,8 +324,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
q = predef.q;
} else oops();
Entity normal;
memset(&normal, 0, sizeof(normal));
Entity normal = {};
normal.type = Entity::NORMAL_N_COPY;
normal.numNormal = q;
normal.point[0] = h.entity(2);
@ -335,16 +332,14 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
normal.h = h.entity(1);
entity->Add(&normal);
Entity point;
memset(&point, 0, sizeof(point));
Entity point = {};
point.type = Entity::POINT_N_COPY;
point.numPoint = SK.GetEntity(predef.origin)->PointGetNum();
point.group = h;
point.h = h.entity(2);
entity->Add(&point);
Entity wp;
memset(&wp, 0, sizeof(wp));
Entity wp = {};
wp.type = Entity::WORKPLANE;
wp.normal = normal.h;
wp.point[0] = point.h;
@ -489,8 +484,7 @@ void Group::AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index) {
}
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
Equation eq;
ZERO(&eq);
Equation eq = {};
if(type == IMPORTED) {
// Normalize the quaternion
ExprQuaternion q = {
@ -573,8 +567,7 @@ hEntity Group::Remap(hEntity in, int copyNumber) {
void Group::MakeExtrusionLines(IdList<Entity,hEntity> *el, hEntity in) {
Entity *ep = SK.GetEntity(in);
Entity en;
ZERO(&en);
Entity en = {};
if(ep->IsPoint()) {
// A point gets extruded to form a line segment
en.point[0] = Remap(ep->h, REMAP_TOP);
@ -613,8 +606,7 @@ void Group::MakeExtrusionTopBottomFaces(IdList<Entity,hEntity> *el, hEntity pt)
Group *src = SK.GetGroup(opA);
Vector n = src->polyLoops.normal;
Entity en;
ZERO(&en);
Entity en = {};
en.type = Entity::FACE_NORMAL_PT;
en.group = h;
@ -634,8 +626,7 @@ void Group::CopyEntity(IdList<Entity,hEntity> *el,
hParam qw, hParam qvx, hParam qvy, hParam qvz,
bool asTrans, bool asAxisAngle)
{
Entity en;
ZERO(&en);
Entity en = {};
en.type = ep->type;
en.extraPoints = ep->extraPoints;
en.h = Remap(ep->h, remap);

View File

@ -13,8 +13,7 @@ void Group::AssembleLoops(bool *allClosed,
bool *allCoplanar,
bool *allNonZeroLen)
{
SBezierList sbl;
ZERO(&sbl);
SBezierList sbl = {};
int i;
for(i = 0; i < SK.entity.n; i++) {
@ -108,8 +107,8 @@ void SMesh::RemapFaces(Group *g, int remap) {
template<class T>
void Group::GenerateForStepAndRepeat(T *steps, T *outs) {
T workA, workB;
ZERO(&workA);
ZERO(&workB);
workA = {};
workB = {};
T *soFar = &workA, *scratch = &workB;
int n = (int)valA, a0 = 0;
@ -121,8 +120,7 @@ void Group::GenerateForStepAndRepeat(T *steps, T *outs) {
int ap = a*2 - (subtype == ONE_SIDED ? 0 : (n-1));
int remap = (a == (n - 1)) ? REMAP_LAST : a;
T transd;
ZERO(&transd);
T transd = {};
if(type == TRANSLATE) {
Vector trans = Vector::From(h.param(0), h.param(1), h.param(2));
trans = trans.ScaledBy(ap);
@ -334,8 +332,8 @@ void Group::GenerateShellAndMesh(void) {
}
} else {
SMesh prevm, thism;
ZERO(&prevm);
ZERO(&thism);
prevm = {};
thism = {};
prevm.MakeFromCopyOf(&(prevg->runningMesh));
prevg->runningShell.TriangulateInto(&prevm);
@ -343,8 +341,7 @@ void Group::GenerateShellAndMesh(void) {
thism.MakeFromCopyOf(&thisMesh);
thisShell.TriangulateInto(&thism);
SMesh outm;
ZERO(&outm);
SMesh outm = {};
GenerateForBoolean<SMesh>(&prevm, &thism, &outm, srcg->meshCombine);
// And make sure that the output mesh is vertex-to-vertex.
@ -540,8 +537,7 @@ void Group::Draw(void) {
}
void Group::FillLoopSetAsPolygon(SBezierLoopSet *sbls) {
SPolygon sp;
ZERO(&sp);
SPolygon sp = {};
sbls->MakePwlInto(&sp);
ssglDepthRangeOffset(1);
ssglFillPolygon(&sp);

View File

@ -1446,8 +1446,7 @@ void LoadAllFontFiles(void) {
Glib::ustring ufilename = (char*) filename;
if(ufilename.length() > 4 &&
ufilename.substr(ufilename.length() - 4, 4).lowercase() == ".ttf") {
TtfFont tf;
ZERO(&tf);
TtfFont tf = {};
strcpy(tf.fontFile, (char*) filename);
SS.fonts.l.Add(&tf);
}

View File

@ -8,7 +8,7 @@
#define EXPORT_DLL
#include <slvs.h>
Sketch SolveSpace::SK;
Sketch SolveSpace::SK = {};
static System SYS;
static int IsInit = 0;
@ -88,8 +88,7 @@ void Slvs_Solve(Slvs_System *ssys, Slvs_hGroup shg)
int i;
for(i = 0; i < ssys->params; i++) {
Slvs_Param *sp = &(ssys->param[i]);
Param p;
ZERO(&p);
Param p = {};
p.h.v = sp->h;
p.val = sp->val;
@ -101,8 +100,7 @@ void Slvs_Solve(Slvs_System *ssys, Slvs_hGroup shg)
for(i = 0; i < ssys->entities; i++) {
Slvs_Entity *se = &(ssys->entity[i]);
EntityBase e;
ZERO(&e);
EntityBase e = {};
switch(se->type) {
case SLVS_E_POINT_IN_3D: e.type = Entity::POINT_IN_3D; break;
@ -137,8 +135,7 @@ default: dbp("bad entity type %d", se->type); return;
for(i = 0; i < ssys->constraints; i++) {
Slvs_Constraint *sc = &(ssys->constraint[i]);
ConstraintBase c;
ZERO(&c);
ConstraintBase c = {};
int t;
switch(sc->type) {
@ -205,12 +202,10 @@ default: dbp("bad constraint type %d", sc->type); return;
}
}
Group g;
ZERO(&g);
Group g = {};
g.h.v = shg;
List<hConstraint> bad;
ZERO(&bad);
List<hConstraint> bad = {};
// Now we're finally ready to solve!
bool andFindBad = ssys->calculateFaileds ? true : false;

View File

@ -24,7 +24,7 @@ void SMesh::AddTriangle(STriMeta meta, Vector n, Vector a, Vector b, Vector c) {
}
}
void SMesh::AddTriangle(STriMeta meta, Vector a, Vector b, Vector c) {
STriangle t; ZERO(&t);
STriangle t = {};
t.meta = meta;
t.a = a;
t.b = b;
@ -62,8 +62,7 @@ void SMesh::GetBounding(Vector *vmax, Vector *vmin) {
// within the plane n dot p = d.
//----------------------------------------------------------------------------
void SMesh::MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d) {
SMesh m;
ZERO(&m);
SMesh m = {};
m.MakeFromCopyOf(this);
// Delete all triangles in the mesh that do not lie in our export plane.
@ -623,8 +622,7 @@ void SKdNode::SnapToMesh(SMesh *m) {
((j == 1) ? tr->b :
tr->c));
SMesh extra;
ZERO(&extra);
SMesh extra = {};
SnapToVertex(v, &extra);
for(k = 0; k < extra.l.n; k++) {
@ -643,8 +641,7 @@ void SKdNode::SnapToMesh(SMesh *m) {
// and our output.
//-----------------------------------------------------------------------------
void SKdNode::SplitLinesAgainstTriangle(SEdgeList *sel, STriangle *tr) {
SEdgeList seln;
ZERO(&seln);
SEdgeList seln = {};
Vector tn = tr->Normal().WithMagnitude(1);
double td = tn.Dot(tr->a);
@ -904,8 +901,7 @@ void SKdNode::MakeCertainEdgesInto(SEdgeList *sel, int how,
if(inter) *inter = false;
if(leaky) *leaky = false;
SMesh m;
ZERO(&m);
SMesh m = {};
ClearTags();
MakeMeshInto(&m);

View File

@ -50,8 +50,7 @@ void GraphicsWindow::FixConstraintsForRequestBeingDeleted(hRequest hr) {
}
}
void GraphicsWindow::FixConstraintsForPointBeingDeleted(hEntity hpt) {
List<hEntity> ld;
ZERO(&ld);
List<hEntity> ld = {};
Constraint *c;
SK.constraint.ClearTags();
@ -89,7 +88,7 @@ void GraphicsWindow::FixConstraintsForPointBeingDeleted(hEntity hpt) {
// arcs by a numerical method.
//-----------------------------------------------------------------------------
void GraphicsWindow::ParametricCurve::MakeFromEntity(hEntity he, bool reverse) {
ZERO(this);
*this = {};
Entity *e = SK.GetEntity(he);
if(e->type == Entity::LINE_SEGMENT) {
isLine = true;
@ -483,8 +482,7 @@ hEntity GraphicsWindow::SplitCircle(hEntity he, Vector pinter) {
hEntity GraphicsWindow::SplitCubic(hEntity he, Vector pinter) {
// Save the original endpoints, since we're about to delete this entity.
Entity *e01 = SK.GetEntity(he);
SBezierList sbl;
ZERO(&sbl);
SBezierList sbl = {};
e01->GenerateBezierCurves(&sbl);
hEntity hep0 = e01->point[0],
@ -606,13 +604,12 @@ void GraphicsWindow::SplitLinesOrCurves(void) {
// Compute the possibly-rational Bezier curves for each of these entities
SBezierList sbla, sblb;
ZERO(&sbla);
ZERO(&sblb);
sbla = {};
sblb = {};
ea->GenerateBezierCurves(&sbla);
eb->GenerateBezierCurves(&sblb);
// and then compute the points where they intersect, based on those curves.
SPointList inters;
ZERO(&inters);
SPointList inters = {};
sbla.AllIntersectionsWith(&sblb, &inters);
if(inters.l.n > 0) {

View File

@ -454,7 +454,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
void GraphicsWindow::ClearPending(void) {
pending.points.Clear();
ZERO(&pending);
pending = {};
SS.ScheduleShowTW();
}
@ -727,8 +727,7 @@ hRequest GraphicsWindow::AddRequest(int type) {
hRequest GraphicsWindow::AddRequest(int type, bool rememberForUndo) {
if(rememberForUndo) SS.UndoRemember();
Request r;
memset(&r, 0, sizeof(r));
Request r = {};
r.group = activeGroup;
Group *g = SK.GetGroup(activeGroup);
if(g->type == Group::DRAWING_3D || g->type == Group::DRAWING_WORKPLANE) {
@ -948,8 +947,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
case MNU_COMMENT: {
ClearSuper();
Constraint c;
ZERO(&c);
Constraint c = {};
c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane();
c.type = Constraint::COMMENT;

View File

@ -48,8 +48,7 @@ void STriangle::FlipNormal(void) {
}
STriangle STriangle::From(STriMeta meta, Vector a, Vector b, Vector c) {
STriangle tr;
ZERO(&tr);
STriangle tr = {};
tr.meta = meta;
tr.a = a;
tr.b = b;
@ -58,8 +57,7 @@ STriangle STriangle::From(STriMeta meta, Vector a, Vector b, Vector c) {
}
SEdge SEdge::From(Vector a, Vector b) {
SEdge se;
ZERO(&se);
SEdge se = {};
se.a = a;
se.b = b;
return se;
@ -152,7 +150,7 @@ void SEdgeList::Clear(void) {
}
void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB) {
SEdge e; ZERO(&e);
SEdge e = {};
e.a = a;
e.b = b;
e.auxA = auxA;
@ -303,12 +301,12 @@ void SEdgeList::CullExtraneousEdges(void) {
//-----------------------------------------------------------------------------
SKdNodeEdges *SKdNodeEdges::Alloc(void) {
SKdNodeEdges *ne = (SKdNodeEdges *)AllocTemporary(sizeof(SKdNodeEdges));
ZERO(ne);
*ne = {};
return ne;
}
SEdgeLl *SEdgeLl::Alloc(void) {
SEdgeLl *sell = (SEdgeLl *)AllocTemporary(sizeof(SEdgeLl));
ZERO(sell);
*sell = {};
return sell;
}
SKdNodeEdges *SKdNodeEdges::From(SEdgeList *sel) {
@ -499,8 +497,7 @@ void SPointList::IncrementTagFor(Vector pt) {
}
void SPointList::Add(Vector pt) {
SPoint p;
ZERO(&p);
SPoint p = {};
p.p = pt;
l.Add(&p);
}
@ -621,8 +618,7 @@ void SPolygon::Clear(void) {
}
void SPolygon::AddEmptyContour(void) {
SContour c;
memset(&c, 0, sizeof(c));
SContour c = {};
l.Add(&c);
}
@ -709,8 +705,7 @@ Vector SPolygon::AnyPoint(void) {
}
bool SPolygon::SelfIntersecting(Vector *intersectsAt) {
SEdgeList el;
ZERO(&el);
SEdgeList el = {};
MakeEdgesInto(&el);
SKdNodeEdges *kdtree = SKdNodeEdges::From(&el);

View File

@ -91,8 +91,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
bool hasDistance = false;
int i;
Entity e;
ZERO(&e);
Entity e = {};
EntReqTable::GetRequestInfo(type, extraPoints,
&et, &points, &hasNormal, &hasDistance);
@ -109,8 +108,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
// And generate entities for the points
for(i = 0; i < points; i++) {
Entity p;
memset(&p, 0, sizeof(p));
Entity p = {};
p.workplane = workplane;
// points start from entity 1, except for datum point case
p.h = h.entity(i+(et ? 1 : 0));
@ -133,8 +131,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
e.point[i] = p.h;
}
if(hasNormal) {
Entity n;
memset(&n, 0, sizeof(n));
Entity n = {};
n.workplane = workplane;
n.h = h.entity(32);
n.group = group;
@ -158,8 +155,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
e.normal = n.h;
}
if(hasDistance) {
Entity d;
memset(&d, 0, sizeof(d));
Entity d = {};
d.workplane = workplane;
d.h = h.entity(64);
d.group = group;
@ -190,8 +186,7 @@ char *Request::DescriptionString(void) {
}
hParam Request::AddParam(IdList<Param,hParam> *param, hParam hp) {
Param pa;
memset(&pa, 0, sizeof(pa));
Param pa = {};
pa.h = hp;
param->Add(&pa);
return hp;

View File

@ -438,6 +438,13 @@ public:
class Entity : public EntityBase {
public:
// Necessary for Entity e = {} to zero-initialize, since
// classes with base classes are not aggregates and
// the default constructor does not initialize members.
Entity() : EntityBase(), forceHidden(), actPoint(), actNormal(),
actDistance(), actVisible(), style(), construction(),
dogd() {};
// An imported entity that was hidden in the source file ends up hidden
// here too.
bool forceHidden;
@ -616,6 +623,9 @@ public:
class Constraint : public ConstraintBase {
public:
// See Entity::Entity().
Constraint() : ConstraintBase(), disp(), dogd() {}
// These define how the constraint is drawn on-screen.
struct {
Vector offset;

View File

@ -7,8 +7,8 @@
#include "solvespace.h"
#include <string>
SolveSpaceUI SolveSpace::SS;
Sketch SolveSpace::SK;
SolveSpaceUI SolveSpace::SS = {};
Sketch SolveSpace::SK = {};
void SolveSpaceUI::Init() {
SS.tangentArcRadius = 10.0;
@ -235,7 +235,7 @@ void SolveSpaceUI::ScheduleShowTW() {
void SolveSpaceUI::DoLater(void) {
if(later.generateAll) GenerateAll();
if(later.showTW) TW.Show();
ZERO(&later);
later = {};
}
double SolveSpaceUI::MmPerUnit(void) {
@ -530,8 +530,7 @@ void SolveSpaceUI::MenuFile(int id) {
case GraphicsWindow::MNU_EXPORT_SURFACES: {
char exportFile[MAX_PATH] = "";
if(!GetSaveFile(exportFile, SRF_EXT, SRF_PATTERN)) break;
StepFileWriter sfw;
ZERO(&sfw);
StepFileWriter sfw = {};
sfw.ExportSurfacesTo(exportFile);
break;
}
@ -714,11 +713,9 @@ void SolveSpaceUI::MenuAnalyze(int id) {
"intersecting.");
break;
}
SEdgeList sel;
ZERO(&sel);
SEdgeList sel = {};
g->polyLoops.MakeEdgesInto(&sel);
SPolygon sp;
ZERO(&sp);
SPolygon sp = {};
sel.AssemblePolygon(&sp, NULL, true);
sp.normal = sp.ComputeNormal();
sp.FixContourDirections();

View File

@ -84,7 +84,6 @@ inline double WRAP_SYMMETRIC(double v, double n) {
// Why is this faster than the library function?
inline double ffabs(double v) { return (v > 0) ? v : (-v); }
#define ZERO(v) memset((v), 0, sizeof(*(v)))
#define CO(v) (v).x, (v).y, (v).z
#define LENGTH_EPS (1e-6)

View File

@ -40,7 +40,7 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
{
SCurve ret;
ret = *this;
ZERO(&(ret.pts));
ret.pts = {};
SCurvePt *p = pts.First();
if(!p) oops();
@ -49,8 +49,7 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
p = pts.NextAfter(p);
for(; p; p = pts.NextAfter(p)) {
List<SInter> il;
ZERO(&il);
List<SInter> il = {};
// Find all the intersections with the two passed shells
if(agnstA)
@ -148,8 +147,7 @@ void SShell::CopyCurvesSplitAgainst(bool opA, SShell *agnst, SShell *into) {
void SSurface::TrimFromEdgeList(SEdgeList *el, bool asUv) {
el->l.ClearTags();
STrimBy stb;
ZERO(&stb);
STrimBy stb = {};
for(;;) {
// Find an edge, any edge; we'll start from there.
SEdge *se;
@ -424,7 +422,7 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
SSurface ret;
// The returned surface is identical, just the trim curves change
ret = *this;
ZERO(&(ret.trim));
ret.trim = {};
// First, build a list of the existing trim curves; update them to use
// the split curves.
@ -443,16 +441,14 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
// Build up our original trim polygon; remember the coordinates could
// be changed if we just flipped the surface normal, and we are using
// the split curves (not the original curves).
SEdgeList orig;
ZERO(&orig);
SEdgeList orig = {};
ret.MakeEdgesInto(into, &orig, AS_UV);
ret.trim.Clear();
// which means that we can't necessarily use the old BSP...
SBspUv *origBsp = SBspUv::From(&orig, &ret);
// And now intersect the other shell against us
SEdgeList inter;
ZERO(&inter);
SEdgeList inter = {};
SSurface *ss;
for(ss = agnst->surface.First(); ss; ss = agnst->surface.NextAfter(ss)) {
@ -504,8 +500,7 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
// the choosing points. If two edges join at a non-choosing point, then
// they must either both be kept or both be discarded (since that would
// otherwise create an open contour).
SPointList choosing;
ZERO(&choosing);
SPointList choosing = {};
SEdge *se;
for(se = orig.l.First(); se; se = orig.l.NextAfter(se)) {
choosing.IncrementTagFor(se->a);
@ -527,12 +522,10 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
// The list of edges to trim our new surface, a combination of edges from
// our original and intersecting edge lists.
SEdgeList final;
ZERO(&final);
SEdgeList final = {};
while(orig.l.n > 0) {
SEdgeList chain;
ZERO(&chain);
SEdgeList chain = {};
FindChainAvoiding(&orig, &chain, &choosing);
// Arbitrarily choose an edge within the chain to classify; they
@ -566,8 +559,7 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
}
while(inter.l.n > 0) {
SEdgeList chain;
ZERO(&chain);
SEdgeList chain = {};
FindChainAvoiding(&inter, &chain, &choosing);
// Any edge in the chain, same as above.
@ -608,8 +600,7 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
// Use our reassembled edges to trim the new surface.
ret.TrimFromEdgeList(&final, true);
SPolygon poly;
ZERO(&poly);
SPolygon poly = {};
final.l.ClearTags();
if(!final.AssemblePolygon(&poly, NULL, true)) {
into->booleanFailed = true;
@ -782,14 +773,13 @@ void SShell::MakeClassifyingBsps(SShell *useCurvesFrom) {
}
void SSurface::MakeClassifyingBsp(SShell *shell, SShell *useCurvesFrom) {
SEdgeList el;
ZERO(&el);
SEdgeList el = {};
MakeEdgesInto(shell, &el, AS_UV, useCurvesFrom);
bsp = SBspUv::From(&el, this);
el.Clear();
ZERO(&edges);
edges = {};
MakeEdgesInto(shell, &edges, AS_XYZ, useCurvesFrom);
}
@ -810,8 +800,7 @@ static int ByLength(const void *av, const void *bv)
return (la < lb) ? 1 : -1;
}
SBspUv *SBspUv::From(SEdgeList *el, SSurface *srf) {
SEdgeList work;
ZERO(&work);
SEdgeList work = {};
SEdge *se;
for(se = el->l.First(); se; se = el->l.NextAfter(se)) {

View File

@ -7,8 +7,7 @@
#include "../solvespace.h"
SBezier SBezier::From(Vector4 p0, Vector4 p1) {
SBezier ret;
ZERO(&ret);
SBezier ret = {};
ret.deg = 1;
ret.weight[0] = p0.w;
ret.ctrl [0] = p0.PerspectiveProject();
@ -18,8 +17,7 @@ SBezier SBezier::From(Vector4 p0, Vector4 p1) {
}
SBezier SBezier::From(Vector4 p0, Vector4 p1, Vector4 p2) {
SBezier ret;
ZERO(&ret);
SBezier ret = {};
ret.deg = 2;
ret.weight[0] = p0.w;
ret.ctrl [0] = p0.PerspectiveProject();
@ -31,8 +29,7 @@ SBezier SBezier::From(Vector4 p0, Vector4 p1, Vector4 p2) {
}
SBezier SBezier::From(Vector4 p0, Vector4 p1, Vector4 p2, Vector4 p3) {
SBezier ret;
ZERO(&ret);
SBezier ret = {};
ret.deg = 3;
ret.weight[0] = p0.w;
ret.ctrl [0] = p0.PerspectiveProject();
@ -274,11 +271,10 @@ void SBezierList::AllIntersectionsWith(SBezierList *sblb, SPointList *spl) {
}
}
void SBezier::AllIntersectionsWith(SBezier *sbb, SPointList *spl) {
SPointList splRaw;
ZERO(&splRaw);
SPointList splRaw = {};
SEdgeList sea, seb;
ZERO(&sea);
ZERO(&seb);
sea = {};
seb = {};
this->MakePwlInto(&sea);
sbb ->MakePwlInto(&seb);
SEdge *se;
@ -393,8 +389,7 @@ bool SBezierList::GetPlaneContainingBeziers(Vector *p, Vector *u, Vector *v,
SBezierLoop SBezierLoop::FromCurves(SBezierList *sbl,
bool *allClosed, SEdge *errorAt)
{
SBezierLoop loop;
ZERO(&loop);
SBezierLoop loop = {};
if(sbl->l.n < 1) return loop;
sbl->l.ClearTags();
@ -502,8 +497,7 @@ SBezierLoopSet SBezierLoopSet::From(SBezierList *sbl, SPolygon *poly,
bool *allClosed, SEdge *errorAt,
SBezierList *openContours)
{
SBezierLoopSet ret;
ZERO(&ret);
SBezierLoopSet ret = {};
*allClosed = true;
while(sbl->l.n > 0) {
@ -610,8 +604,7 @@ void SBezierLoopSetSet::FindOuterFacesFrom(SBezierList *sbl, SPolygon *spxyz,
if(sbls.l.n != spxyz->l.n) return;
// Convert the xyz piecewise linear to uv piecewise linear.
SPolygon spuv;
ZERO(&spuv);
SPolygon spuv = {};
SContour *sc;
for(sc = spxyz->l.First(); sc; sc = spxyz->l.NextAfter(sc)) {
spuv.AddEmptyContour();
@ -671,8 +664,7 @@ void SBezierLoopSetSet::FindOuterFacesFrom(SBezierList *sbl, SPolygon *spxyz,
continue;
}
SBezierLoopSet outerAndInners;
ZERO(&outerAndInners);
SBezierLoopSet outerAndInners = {};
loopsRemaining = true;
loop->tag = USED_LOOP;
outerAndInners.l.Add(loop);
@ -723,12 +715,10 @@ void SBezierLoopSetSet::FindOuterFacesFrom(SBezierList *sbl, SPolygon *spxyz,
}
void SBezierLoopSetSet::AddOpenPath(SBezier *sb) {
SBezierLoop sbl;
ZERO(&sbl);
SBezierLoop sbl = {};
sbl.l.Add(sb);
SBezierLoopSet sbls;
ZERO(&sbls);
SBezierLoopSet sbls = {};
sbls.l.Add(&sbl);
l.Add(&sbls);
@ -745,8 +735,7 @@ void SBezierLoopSetSet::Clear(void) {
SCurve SCurve::FromTransformationOf(SCurve *a,
Vector t, Quaternion q, double scale)
{
SCurve ret;
ZERO(&ret);
SCurve ret = {};
ret.h = a->h;
ret.isExact = a->isExact;
@ -840,8 +829,7 @@ void SCurve::RemoveShortSegments(SSurface *srfA, SSurface *srfB) {
}
STrimBy STrimBy::EntireCurve(SShell *shell, hSCurve hsc, bool backwards) {
STrimBy stb;
ZERO(&stb);
STrimBy stb = {};
stb.curve = hsc;
SCurve *sc = shell->curve.FindById(hsc);

View File

@ -22,8 +22,7 @@ void SShell::MergeCoincidentSurfaces(void) {
// time on other surfaces.
if(si->degm != 1 || si->degn != 1) continue;
SEdgeList sel;
ZERO(&sel);
SEdgeList sel = {};
si->MakeEdgesInto(this, &sel, SSurface::AS_XYZ);
bool mergedThisTime, merged = false;
@ -42,8 +41,7 @@ void SShell::MergeCoincidentSurfaces(void) {
// surfaces if they contain disjoint contours; that just makes
// the bounding box tests less effective, and possibly things
// less robust.
SEdgeList tel;
ZERO(&tel);
SEdgeList tel = {};
sj->MakeEdgesInto(this, &tel, SSurface::AS_XYZ);
if(!sel.ContainsEdgeFrom(&tel)) {
tel.Clear();

View File

@ -227,8 +227,7 @@ void SBezier::SplitAt(double t, SBezier *bef, SBezier *aft) {
}
void SBezier::MakePwlInto(SEdgeList *sel, double chordTol) {
List<Vector> lv;
ZERO(&lv);
List<Vector> lv = {};
MakePwlInto(&lv, chordTol);
int i;
for(i = 1; i < lv.n; i++) {
@ -237,8 +236,7 @@ void SBezier::MakePwlInto(SEdgeList *sel, double chordTol) {
lv.Clear();
}
void SBezier::MakePwlInto(List<SCurvePt> *l, double chordTol) {
List<Vector> lv;
ZERO(&lv);
List<Vector> lv = {};
MakePwlInto(&lv, chordTol);
int i;
for(i = 0; i < lv.n; i++) {
@ -251,8 +249,7 @@ void SBezier::MakePwlInto(List<SCurvePt> *l, double chordTol) {
lv.Clear();
}
void SBezier::MakePwlInto(SContour *sc, double chordTol) {
List<Vector> lv;
ZERO(&lv);
List<Vector> lv = {};
MakePwlInto(&lv, chordTol);
int i;
for(i = 0; i < lv.n; i++) {

View File

@ -254,8 +254,7 @@ void SSurface::AllPointsIntersecting(Vector a, Vector b,
Vector ba = b.Minus(a);
double bam = ba.Magnitude();
List<Inter> inters;
ZERO(&inters);
List<Inter> inters = {};
// All the intersections between the line and the surface; either special
// cases that we can quickly solve in closed form, or general numerical.
@ -426,8 +425,7 @@ bool SShell::ClassifyEdge(int *indir, int *outdir,
Vector p,
Vector edge_n_in, Vector edge_n_out, Vector surf_n)
{
List<SInter> l;
ZERO(&l);
List<SInter> l = {};
srand(0);

View File

@ -7,8 +7,7 @@
#include "../solvespace.h"
SSurface SSurface::FromExtrusionOf(SBezier *sb, Vector t0, Vector t1) {
SSurface ret;
ZERO(&ret);
SSurface ret = {};
ret.degm = sb->deg;
ret.degn = 1;
@ -67,8 +66,7 @@ bool SSurface::IsCylinder(Vector *axis, Vector *center, double *r,
SSurface SSurface::FromRevolutionOf(SBezier *sb, Vector pt, Vector axis,
double thetas, double thetaf)
{
SSurface ret;
ZERO(&ret);
SSurface ret = {};
ret.degm = sb->deg;
@ -117,8 +115,7 @@ SSurface SSurface::FromRevolutionOf(SBezier *sb, Vector pt, Vector axis,
}
SSurface SSurface::FromPlane(Vector pt, Vector u, Vector v) {
SSurface ret;
ZERO(&ret);
SSurface ret = {};
ret.degm = 1;
ret.degn = 1;
@ -138,8 +135,7 @@ SSurface SSurface::FromTransformationOf(SSurface *a,
Vector t, Quaternion q, double scale,
bool includingTrims)
{
SSurface ret;
ZERO(&ret);
SSurface ret = {};
ret.h = a->h;
ret.color = a->color;
@ -403,13 +399,11 @@ void SSurface::MakeSectionEdgesInto(SShell *shell,
}
void SSurface::TriangulateInto(SShell *shell, SMesh *sm) {
SEdgeList el;
ZERO(&el);
SEdgeList el = {};
MakeEdgesInto(shell, &el, AS_UV);
SPolygon poly;
ZERO(&poly);
SPolygon poly = {};
if(el.AssemblePolygon(&poly, NULL, true)) {
int i, start = sm->l.n;
if(degm == 1 && degn == 1) {
@ -528,8 +522,7 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb
SBezierLoop *sbl;
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
SBezier *sb;
List<TrimLine> trimLines;
ZERO(&trimLines);
List<TrimLine> trimLines = {};
for(sb = sbl->l.First(); sb; sb = sbl->l.NextAfter(sb)) {
// Generate the surface of extrusion of this curve, and add
@ -539,8 +532,7 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb
hSSurface hsext = surface.AddAndAssignId(&ss);
// Translate the curve by t0 and t1 to produce two trim curves
SCurve sc;
ZERO(&sc);
SCurve sc = {};
sc.isExact = true;
sc.exact = sb->TransformedBy(t0, Quaternion::IDENTITY, 1.0);
(sc.exact).MakePwlInto(&(sc.pts));
@ -548,7 +540,7 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb
sc.surfB = hsext;
hSCurve hc0 = curve.AddAndAssignId(&sc);
ZERO(&sc);
sc = {};
sc.isExact = true;
sc.exact = sb->TransformedBy(t1, Quaternion::IDENTITY, 1.0);
(sc.exact).MakePwlInto(&(sc.pts));
@ -571,7 +563,7 @@ void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, Rgb
// And form the trim line
Vector pt = sb->Finish();
ZERO(&sc);
sc = {};
sc.isExact = true;
sc.exact = SBezier::From(pt.Plus(t0), pt.Plus(t1));
(sc.exact).MakePwlInto(&(sc.pts));
@ -645,8 +637,7 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
int i, j;
SBezier *sb, *prev;
List<Revolved> hsl;
ZERO(&hsl);
List<Revolved> hsl = {};
for(sb = sbl->l.First(); sb; sb = sbl->l.NextAfter(sb)) {
Revolved revs;
@ -685,7 +676,7 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
// If this input curve generate a surface, then trim that
// surface with the rotated version of the input curve.
if(revs.d[j].v) {
ZERO(&sc);
sc = {};
sc.isExact = true;
sc.exact = sb->TransformedBy(ts, qs, 1.0);
(sc.exact).MakePwlInto(&(sc.pts));
@ -707,7 +698,7 @@ void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
if(revs.d[j].v && revsp.d[j].v) {
SSurface *ss = surface.FindById(revs.d[j]);
ZERO(&sc);
sc = {};
sc.isExact = true;
sc.exact = SBezier::From(ss->ctrl[0][0],
ss->ctrl[0][1],

View File

@ -12,8 +12,7 @@ extern int FLAG;
void SSurface::AddExactIntersectionCurve(SBezier *sb, SSurface *srfB,
SShell *agnstA, SShell *agnstB, SShell *into)
{
SCurve sc;
ZERO(&sc);
SCurve sc = {};
// Important to keep the order of (surfA, surfB) consistent; when we later
// rewrite the identifiers, we rewrite surfA from A and surfB from B.
sc.surfA = h;
@ -48,7 +47,7 @@ void SSurface::AddExactIntersectionCurve(SBezier *sb, SSurface *srfB,
}
if(backwards) sc.pts.Reverse();
split = sc;
ZERO(&sc);
sc = {};
} else {
sb->MakePwlInto(&(sc.pts));
// and split the line where it intersects our existing surfaces
@ -216,8 +215,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
// extrusion, and dp component doesn't matter so zero
p0 = n.ScaledBy(d).Plus(alu.ScaledBy(pm.Dot(alu)));
List<SInter> inters;
ZERO(&inters);
List<SInter> inters = {};
sext->AllPointsIntersecting(
p0, p0.Plus(dp), &inters, false, false, true);
@ -252,10 +250,8 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
// intersect along some number of lines parallel to the axis.
Vector axis = alongt.WithMagnitude(1);
List<SInter> inters;
ZERO(&inters);
List<Vector> lv;
ZERO(&lv);
List<SInter> inters = {};
List<Vector> lv = {};
double a_axis0 = ( ctrl[0][0]).Dot(axis),
a_axis1 = ( ctrl[0][1]).Dot(axis),
@ -313,8 +309,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
// Try intersecting the surfaces numerically, by a marching algorithm.
// First, we find all the intersections between a surface and the
// boundary of the other surface.
SPointList spl;
ZERO(&spl);
SPointList spl = {};
int a;
for(a = 0; a < 2; a++) {
SShell *shA = (a == 0) ? agnstA : agnstB,
@ -322,14 +317,12 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
SSurface *srfA = (a == 0) ? this : b,
*srfB = (a == 0) ? b : this;
SEdgeList el;
ZERO(&el);
SEdgeList el = {};
srfA->MakeEdgesInto(shA, &el, AS_XYZ, NULL);
SEdge *se;
for(se = el.l.First(); se; se = el.l.NextAfter(se)) {
List<SInter> lsi;
ZERO(&lsi);
List<SInter> lsi = {};
srfB->AllPointsIntersecting(se->a, se->b, &lsi,
true, true, false);
@ -369,8 +362,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
}
while(spl.l.n >= 2) {
SCurve sc;
ZERO(&sc);
SCurve sc = {};
sc.surfA = h;
sc.surfB = b->h;
sc.isExact = false;
@ -387,8 +379,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
int maxsteps = max(300, SS.maxSegments*3);
// The curve starts at our starting point.
SCurvePt padd;
ZERO(&padd);
SCurvePt padd = {};
padd.vertex = true;
padd.p = start;
sc.pts.Add(&padd);

View File

@ -33,18 +33,15 @@ void SPolygon::UvTriangulateInto(SMesh *m, SSurface *srf) {
}
// Start with the outer contour
SContour merged;
ZERO(&merged);
SContour merged = {};
top->tag = 1;
top->CopyInto(&merged);
(merged.l.n)--;
// List all of the edges, for testing whether bridges work.
SEdgeList el;
ZERO(&el);
SEdgeList el = {};
top->MakeEdgesInto(&el);
List<Vector> vl;
ZERO(&vl);
List<Vector> vl = {};
// And now find all of its holes. Note that we will also find any
// outer contours that lie entirely within this contour, and any
@ -191,8 +188,7 @@ bool SContour::BridgeToContour(SContour *sc,
return false;
haveEdge:
SContour merged;
ZERO(&merged);
SContour merged = {};
for(i = 0; i < l.n; i++) {
merged.AddPoint(l.elem[i].p);
if(i == thisp) {
@ -221,8 +217,7 @@ bool SContour::IsEar(int bp, double scaledEps) {
int ap = WRAP(bp-1, l.n),
cp = WRAP(bp+1, l.n);
STriangle tr;
ZERO(&tr);
STriangle tr = {};
tr.a = l.elem[ap].p;
tr.b = l.elem[bp].p;
tr.c = l.elem[cp].p;
@ -270,8 +265,7 @@ void SContour::ClipEarInto(SMesh *m, int bp, double scaledEps) {
int ap = WRAP(bp-1, l.n),
cp = WRAP(bp+1, l.n);
STriangle tr;
ZERO(&tr);
STriangle tr = {};
tr.a = l.elem[ap].p;
tr.b = l.elem[bp].p;
tr.c = l.elem[cp].p;
@ -425,12 +419,10 @@ void SSurface::MakeTriangulationGridInto(List<double> *l, double vs, double vf,
}
void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
SEdgeList orig;
ZERO(&orig);
SEdgeList orig = {};
MakeEdgesInto(&orig);
SEdgeList holes;
ZERO(&holes);
SEdgeList holes = {};
normal = Vector::From(0, 0, 1);
FixContourDirections();
@ -438,8 +430,8 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
// Build a rectangular grid, with horizontal and vertical lines in the
// uv plane. The spacing of these lines is adaptive, so calculate that.
List<double> li, lj;
ZERO(&li);
ZERO(&lj);
li = {};
lj = {};
double v = 0;
li.Add(&v);
srf->MakeTriangulationGridInto(&li, 0, 1, true);
@ -475,8 +467,7 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
}
// Add the quad to our mesh
STriangle tr;
ZERO(&tr);
STriangle tr = {};
tr.a = a;
tr.b = b;
tr.c = c;
@ -494,8 +485,7 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
}
holes.CullExtraneousEdges();
SPolygon hp;
ZERO(&hp);
SPolygon hp = {};
holes.AssemblePolygon(&hp, NULL, true);
SContour *sc;

View File

@ -72,8 +72,7 @@ void Style::CreateDefaultStyle(hStyle h) {
isDefaultStyle = false;
}
Style ns;
ZERO(&ns);
Style ns = {};
ns.color = CnfThawColor(d->color, CnfColor(d->cnfPrefix));
ns.width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
ns.widthAs = UNITS_AS_PIXELS;

View File

@ -137,8 +137,7 @@ void System::SolveBySubstitution(void) {
//-----------------------------------------------------------------------------
int System::CalculateRank(void) {
// Actually work with magnitudes squared, not the magnitudes
double rowMag[MAX_UNKNOWNS];
ZERO(&rowMag);
double rowMag[MAX_UNKNOWNS] = {};
double tol = RANK_MAG_TOLERANCE*RANK_MAG_TOLERANCE;
int i, iprev, j;

View File

@ -175,15 +175,13 @@ void TextWindow::ScreenHoverRequest(int link, uint32_t v) {
}
void TextWindow::ScreenSelectConstraint(int link, uint32_t v) {
SS.GW.ClearSelection();
GraphicsWindow::Selection sel;
ZERO(&sel);
GraphicsWindow::Selection sel = {};
sel.constraint.v = v;
SS.GW.selection.Add(&sel);
}
void TextWindow::ScreenSelectRequest(int link, uint32_t v) {
SS.GW.ClearSelection();
GraphicsWindow::Selection sel;
ZERO(&sel);
GraphicsWindow::Selection sel = {};
hRequest hr = { v };
sel.entity = hr.entity(0);
SS.GW.selection.Add(&sel);

View File

@ -62,7 +62,11 @@ void TextWindow::Init(void) {
void TextWindow::ClearSuper(void) {
HideEditControl();
// Cannot use *this = {} here because TextWindow instances
// are 2.4MB long; this causes stack overflows in prologue
// when built with MSVC, even with optimizations.
memset(this, 0, sizeof(*this));
MakeColorTable(fgColors, fgColorTable);
MakeColorTable(bgColors, bgColorTable);

View File

@ -46,31 +46,31 @@ void SolveSpaceUI::PushFromCurrentOnto(UndoStack *uk) {
}
UndoState *ut = &(uk->d[uk->write]);
ZERO(ut);
*ut = {};
for(i = 0; i < SK.group.n; i++) {
Group *src = &(SK.group.elem[i]);
Group dest = *src;
// And then clean up all the stuff that needs to be a deep copy,
// and zero out all the dynamic stuff that will get regenerated.
dest.clean = false;
ZERO(&(dest.solved));
ZERO(&(dest.polyLoops));
ZERO(&(dest.bezierLoops));
ZERO(&(dest.bezierOpens));
ZERO(&(dest.polyError));
ZERO(&(dest.thisMesh));
ZERO(&(dest.runningMesh));
ZERO(&(dest.thisShell));
ZERO(&(dest.runningShell));
ZERO(&(dest.displayMesh));
ZERO(&(dest.displayEdges));
dest.solved = {};
dest.polyLoops = {};
dest.bezierLoops = {};
dest.bezierOpens = {};
dest.polyError = {};
dest.thisMesh = {};
dest.runningMesh = {};
dest.thisShell = {};
dest.runningShell = {};
dest.displayMesh = {};
dest.displayEdges = {};
ZERO(&(dest.remap));
dest.remap = {};
src->remap.DeepCopyInto(&(dest.remap));
ZERO(&(dest.impMesh));
ZERO(&(dest.impShell));
ZERO(&(dest.impEntity));
dest.impMesh = {};
dest.impShell = {};
dest.impEntity = {};
ut->group.Add(&dest);
}
for(i = 0; i < SK.request.n; i++) {
@ -79,7 +79,7 @@ void SolveSpaceUI::PushFromCurrentOnto(UndoStack *uk) {
for(i = 0; i < SK.constraint.n; i++) {
Constraint *src = &(SK.constraint.elem[i]);
Constraint dest = *src;
ZERO(&(dest.dogd));
dest.dogd = {};
ut->constraint.Add(&dest);
}
for(i = 0; i < SK.param.n; i++) {
@ -120,7 +120,7 @@ void SolveSpaceUI::PopOntoCurrentFrom(UndoStack *uk) {
SS.GW.activeGroup = ut->activeGroup;
// No need to free it, since a shallow copy was made above
ZERO(ut);
*ut = {};
// And reset the state everywhere else in the program, since the
// sketch just changed a lot.
@ -141,7 +141,7 @@ void SolveSpaceUI::UndoClearStack(UndoStack *uk) {
(uk->cnt)--;
UndoClearState(&(uk->d[uk->write]));
}
ZERO(uk); // for good measure
*uk = {}; // for good measure
}
void SolveSpaceUI::UndoClearState(UndoState *ut) {
@ -156,6 +156,6 @@ void SolveSpaceUI::UndoClearState(UndoState *ut) {
ut->constraint.Clear();
ut->param.Clear();
ut->style.Clear();
ZERO(ut);
*ut = {};
}

View File

@ -135,8 +135,7 @@ void SolveSpace::DoMessageBox(const char *str, int rows, int cols, bool error)
//HWND h = GetForegroundWindow();
// Register the window class for our dialog.
WNDCLASSEX wc;
memset(&wc, 0, sizeof(wc));
WNDCLASSEX wc = {};
wc.cbSize = sizeof(wc);
wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)MessageProc;
@ -345,8 +344,7 @@ static void PaintTextWnd(HDC hdc)
void SolveSpace::MoveTextScrollbarTo(int pos, int maxPos, int page)
{
SCROLLINFO si;
memset(&si, 0, sizeof(si));
SCROLLINFO si = {};
si.cbSize = sizeof(si);
si.fMask = SIF_DISABLENOSCROLL | SIF_ALL;
si.nMin = 0;
@ -488,8 +486,7 @@ LRESULT CALLBACK TextWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONDOWN:
case WM_MOUSEMOVE: {
// We need this in order to get the WM_MOUSELEAVE
TRACKMOUSEEVENT tme;
ZERO(&tme);
TRACKMOUSEEVENT tme = {};
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = TextWnd;
@ -535,8 +532,7 @@ static bool ProcessKeyDown(WPARAM wParam)
{
if(GraphicsEditControlIsVisible() && wParam != VK_ESCAPE) {
if(wParam == VK_RETURN) {
char s[1024];
memset(s, 0, sizeof(s));
char s[1024] = {};
SendMessage(GraphicsEditControl, WM_GETTEXT, 900, (LPARAM)s);
SS.GW.EditControlDone(s);
return true;
@ -546,8 +542,7 @@ static bool ProcessKeyDown(WPARAM wParam)
}
if(TextEditControlIsVisible() && wParam != VK_ESCAPE) {
if(wParam == VK_RETURN) {
char s[1024];
memset(s, 0, sizeof(s));
char s[1024] = {};
SendMessage(TextEditControl, WM_GETTEXT, 900, (LPARAM)s);
SS.TW.EditControlDone(s);
} else {
@ -638,10 +633,9 @@ static void CreateGlContext(HWND hwnd, HGLRC *glrc)
{
HDC hdc = GetDC(hwnd);
PIXELFORMATDESCRIPTOR pfd;
PIXELFORMATDESCRIPTOR pfd = {};
int pixelFormat;
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
@ -791,8 +785,7 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
int y = HIWORD(lParam);
// We need this in order to get the WM_MOUSELEAVE
TRACKMOUSEEVENT tme;
ZERO(&tme);
TRACKMOUSEEVENT tme = {};
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = GraphicsWnd;
@ -873,9 +866,8 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
//-----------------------------------------------------------------------------
bool SolveSpace::GetOpenFile(char *file, const char *defExtension, const char *selPattern)
{
OPENFILENAME ofn;
OPENFILENAME ofn = {};
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = Instance;
ofn.hwndOwner = GraphicsWnd;
@ -899,9 +891,8 @@ bool SolveSpace::GetOpenFile(char *file, const char *defExtension, const char *s
bool SolveSpace::GetSaveFile(char *file, const char *defExtension, const char *selPattern)
{
OPENFILENAME ofn;
OPENFILENAME ofn = {};
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = Instance;
ofn.hwndOwner = GraphicsWnd;
@ -979,8 +970,7 @@ void SolveSpace::LoadAllFontFiles(void)
HANDLE h = FindFirstFile(dir, &wfd);
while(h != INVALID_HANDLE_VALUE) {
TtfFont tf;
ZERO(&tf);
TtfFont tf = {};
char fullPath[MAX_PATH];
GetWindowsDirectory(fullPath, MAX_PATH - (30 + (UINT)strlen(wfd.cFileName)));
@ -1098,9 +1088,8 @@ HMENU CreateGraphicsWindowMenus(void)
static void CreateMainWindows(void)
{
WNDCLASSEX wc;
WNDCLASSEX wc = {};
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(wc);
// The graphics window, where the sketch is drawn and shown.