diff --git a/drawentity.cpp b/drawentity.cpp index 5000c72..b643d4d 100644 --- a/drawentity.cpp +++ b/drawentity.cpp @@ -95,24 +95,24 @@ void Entity::Draw(void) { void Entity::GenerateEdges(SEdgeList *el, bool includingConstruction) { if(construction && !includingConstruction) return; - SPolyCurveList spcl; - ZERO(&spcl); - GeneratePolyCurves(&spcl); + SBezierList sbl; + ZERO(&sbl); + GenerateBezierCurves(&sbl); int i, j; - for(i = 0; i < spcl.l.n; i++) { - SPolyCurve *spc = &(spcl.l.elem[i]); + for(i = 0; i < sbl.l.n; i++) { + SBezier *sb = &(sbl.l.elem[i]); List lv; ZERO(&lv); - spc->MakePwlInto(&lv); + sb->MakePwlInto(&lv); for(j = 1; j < lv.n; j++) { el->AddEdge(lv.elem[j-1], lv.elem[j]); } lv.Clear(); } - spcl.Clear(); + sbl.Clear(); } double Entity::GetDistance(Point2d mp) { @@ -163,15 +163,15 @@ bool Entity::IsVisible(void) { return true; } -void Entity::GeneratePolyCurves(SPolyCurveList *spcl) { - SPolyCurve spc; +void Entity::GenerateBezierCurves(SBezierList *sbl) { + SBezier sb; switch(type) { case LINE_SEGMENT: { Vector a = SS.GetEntity(point[0])->PointGetNum(); Vector b = SS.GetEntity(point[1])->PointGetNum(); - spc = SPolyCurve::From(a, b); - spcl->l.Add(&spc); + sb = SBezier::From(a, b); + sbl->l.Add(&sb); break; } case CUBIC: { @@ -179,8 +179,8 @@ void Entity::GeneratePolyCurves(SPolyCurveList *spcl) { Vector p1 = SS.GetEntity(point[1])->PointGetNum(); Vector p2 = SS.GetEntity(point[2])->PointGetNum(); Vector p3 = SS.GetEntity(point[3])->PointGetNum(); - spc = SPolyCurve::From(p0, p1, p2, p3); - spcl->l.Add(&spc); + sb = SBezier::From(p0, p1, p2, p3); + sbl->l.Add(&sb); break; } @@ -239,9 +239,9 @@ void Entity::GeneratePolyCurves(SPolyCurveList *spcl) { p2, p2.Plus(t2), NULL); - SPolyCurve spc = SPolyCurve::From(p0, p1, p2); - spc.weight[1] = cos(dtheta/2); - spcl->l.Add(&spc); + SBezier sb = SBezier::From(p0, p1, p2); + sb.weight[1] = cos(dtheta/2); + sbl->l.Add(&sb); } break; } @@ -253,7 +253,7 @@ void Entity::GeneratePolyCurves(SPolyCurveList *spcl) { Vector v = topLeft.Minus(botLeft); Vector u = (v.Cross(n)).WithMagnitude(v.Magnitude()); - SS.fonts.PlotString(font.str, str.str, 0, spcl, botLeft, u, v); + SS.fonts.PlotString(font.str, str.str, 0, sbl, botLeft, u, v); break; } diff --git a/groupmesh.cpp b/groupmesh.cpp index 86bdb23..1ec4361 100644 --- a/groupmesh.cpp +++ b/groupmesh.cpp @@ -3,8 +3,8 @@ #define gs (SS.GW.gs) bool Group::AssembleLoops(void) { - SPolyCurveList spcl; - ZERO(&spcl); + SBezierList sbl; + ZERO(&sbl); int i; for(i = 0; i < SS.entity.n; i++) { @@ -12,19 +12,19 @@ bool Group::AssembleLoops(void) { if(e->group.v != h.v) continue; if(e->construction) continue; - e->GeneratePolyCurves(&spcl); + e->GenerateBezierCurves(&sbl); } bool allClosed; - curveLoops = SPolyCurveLoops::From(&spcl, &poly, - &allClosed, &(polyError.notClosedAt)); - spcl.Clear(); + bezierLoopSet = SBezierLoopSet::From(&sbl, &poly, + &allClosed, &(polyError.notClosedAt)); + sbl.Clear(); return allClosed; } void Group::GenerateLoops(void) { poly.Clear(); - curveLoops.Clear(); + bezierLoopSet.Clear(); if(type == DRAWING_3D || type == DRAWING_WORKPLANE || type == ROTATE || type == TRANSLATE || type == IMPORTED) @@ -36,12 +36,12 @@ void Group::GenerateLoops(void) { // The edges aren't all coplanar; so not a good polygon polyError.how = POLY_NOT_COPLANAR; poly.Clear(); - curveLoops.Clear(); + bezierLoopSet.Clear(); } } else { polyError.how = POLY_NOT_CLOSED; poly.Clear(); - curveLoops.Clear(); + bezierLoopSet.Clear(); } } } diff --git a/sketch.h b/sketch.h index 39eec4a..226e9dc 100644 --- a/sketch.h +++ b/sketch.h @@ -137,7 +137,7 @@ public: } predef; SPolygon poly; - SPolyCurveLoops curveLoops; + SBezierLoopSet bezierLoopSet; static const int POLY_GOOD = 0; static const int POLY_NOT_CLOSED = 1; static const int POLY_NOT_COPLANAR = 2; @@ -397,7 +397,7 @@ public: void LineDrawOrGetDistance(Vector a, Vector b); void DrawOrGetDistance(void); - void GeneratePolyCurves(SPolyCurveList *spcl); + void GenerateBezierCurves(SBezierList *sbl); void GenerateEdges(SEdgeList *el, bool includingConstruction=false); static void DrawAll(void); diff --git a/solvespace.h b/solvespace.h index 0048963..4ad632e 100644 --- a/solvespace.h +++ b/solvespace.h @@ -292,8 +292,8 @@ public: // And the state that the caller must specify, determines where we // render to and how - SPolyCurveList *polyCurves; - Vector origin, u, v; + SBezierList *beziers; + Vector origin, u, v; int Getc(void); int GetBYTE(void); @@ -308,7 +308,7 @@ public: void Handle(int *dx, int x, int y, bool onCurve); void PlotCharacter(int *dx, int c, double spacing); void PlotString(char *str, double spacing, - SPolyCurveList *spcl, Vector origin, Vector u, Vector v); + SBezierList *sbl, Vector origin, Vector u, Vector v); Vector TransformIntPoint(int x, int y); void LineSegment(int x0, int y0, int x1, int y1); @@ -325,7 +325,7 @@ public: void LoadAll(void); void PlotString(char *font, char *str, double spacing, - SPolyCurveList *spcl, Vector origin, Vector u, Vector v); + SBezierList *sbl, Vector origin, Vector u, Vector v); }; class VectorFileWriter { diff --git a/srf/ratpoly.cpp b/srf/ratpoly.cpp index d457e2a..27078d9 100644 --- a/srf/ratpoly.cpp +++ b/srf/ratpoly.cpp @@ -36,8 +36,8 @@ double Bernstein(int k, int deg, double t) oops(); } -SPolyCurve SPolyCurve::From(Vector p0, Vector p1) { - SPolyCurve ret; +SBezier SBezier::From(Vector p0, Vector p1) { + SBezier ret; ZERO(&ret); ret.deg = 1; ret.weight[0] = ret.weight[1] = 1; @@ -46,8 +46,8 @@ SPolyCurve SPolyCurve::From(Vector p0, Vector p1) { return ret; } -SPolyCurve SPolyCurve::From(Vector p0, Vector p1, Vector p2) { - SPolyCurve ret; +SBezier SBezier::From(Vector p0, Vector p1, Vector p2) { + SBezier ret; ZERO(&ret); ret.deg = 2; ret.weight[0] = ret.weight[1] = ret.weight[2] = 1; @@ -57,8 +57,8 @@ SPolyCurve SPolyCurve::From(Vector p0, Vector p1, Vector p2) { return ret; } -SPolyCurve SPolyCurve::From(Vector p0, Vector p1, Vector p2, Vector p3) { - SPolyCurve ret; +SBezier SBezier::From(Vector p0, Vector p1, Vector p2, Vector p3) { + SBezier ret; ZERO(&ret); ret.deg = 3; ret.weight[0] = ret.weight[1] = ret.weight[2] = ret.weight[3] = 1; @@ -69,15 +69,15 @@ SPolyCurve SPolyCurve::From(Vector p0, Vector p1, Vector p2, Vector p3) { return ret; } -Vector SPolyCurve::Start(void) { +Vector SBezier::Start(void) { return ctrl[0]; } -Vector SPolyCurve::Finish(void) { +Vector SBezier::Finish(void) { return ctrl[deg]; } -Vector SPolyCurve::PointAt(double t) { +Vector SBezier::PointAt(double t) { Vector pt = Vector::From(0, 0, 0); double d = 0; @@ -91,12 +91,12 @@ Vector SPolyCurve::PointAt(double t) { return pt; } -void SPolyCurve::MakePwlInto(List *l) { +void SBezier::MakePwlInto(List *l) { l->Add(&(ctrl[0])); MakePwlWorker(l, 0.0, 1.0); } -void SPolyCurve::MakePwlWorker(List *l, double ta, double tb) { +void SBezier::MakePwlWorker(List *l, double ta, double tb) { Vector pa = PointAt(ta); Vector pb = PointAt(tb); @@ -123,7 +123,7 @@ void SPolyCurve::MakePwlWorker(List *l, double ta, double tb) { } } -void SPolyCurve::Reverse(void) { +void SBezier::Reverse(void) { int i; for(i = 0; i < (deg+1)/2; i++) { SWAP(Vector, ctrl[i], ctrl[deg-i]); @@ -131,32 +131,32 @@ void SPolyCurve::Reverse(void) { } } -void SPolyCurveList::Clear(void) { +void SBezierList::Clear(void) { l.Clear(); } -SPolyCurveLoop SPolyCurveLoop::FromCurves(SPolyCurveList *spcl, - bool *allClosed, SEdge *errorAt) +SBezierLoop SBezierLoop::FromCurves(SBezierList *sbl, + bool *allClosed, SEdge *errorAt) { - SPolyCurveLoop loop; + SBezierLoop loop; ZERO(&loop); - if(spcl->l.n < 1) return loop; - spcl->l.ClearTags(); + if(sbl->l.n < 1) return loop; + sbl->l.ClearTags(); - SPolyCurve *first = &(spcl->l.elem[0]); + SBezier *first = &(sbl->l.elem[0]); first->tag = 1; loop.l.Add(first); Vector start = first->Start(); Vector hanging = first->Finish(); - spcl->l.RemoveTagged(); + sbl->l.RemoveTagged(); - while(spcl->l.n > 0 && !hanging.Equals(start)) { + while(sbl->l.n > 0 && !hanging.Equals(start)) { int i; bool foundNext = false; - for(i = 0; i < spcl->l.n; i++) { - SPolyCurve *test = &(spcl->l.elem[i]); + for(i = 0; i < sbl->l.n; i++) { + SBezier *test = &(sbl->l.elem[i]); if((test->Finish()).Equals(hanging)) { test->Reverse(); @@ -166,7 +166,7 @@ SPolyCurveLoop SPolyCurveLoop::FromCurves(SPolyCurveList *spcl, test->tag = 1; loop.l.Add(test); hanging = test->Finish(); - spcl->l.RemoveTagged(); + sbl->l.RemoveTagged(); foundNext = true; break; } @@ -192,18 +192,18 @@ SPolyCurveLoop SPolyCurveLoop::FromCurves(SPolyCurveList *spcl, return loop; } -void SPolyCurveLoop::Reverse(void) { +void SBezierLoop::Reverse(void) { l.Reverse(); } -void SPolyCurveLoop::MakePwlInto(SContour *sc) { +void SBezierLoop::MakePwlInto(SContour *sc) { List lv; ZERO(&lv); int i, j; for(i = 0; i < l.n; i++) { - SPolyCurve *spc = &(l.elem[i]); - spc->MakePwlInto(&lv); + SBezier *sb = &(l.elem[i]); + sb->MakePwlInto(&lv); // Each curve's piecewise linearization includes its endpoints, // which we don't want to duplicate (creating zero-len edges). @@ -216,17 +216,17 @@ void SPolyCurveLoop::MakePwlInto(SContour *sc) { sc->l.elem[sc->l.n - 1] = sc->l.elem[0]; } -SPolyCurveLoops SPolyCurveLoops::From(SPolyCurveList *spcl, SPolygon *poly, - bool *allClosed, SEdge *errorAt) +SBezierLoopSet SBezierLoopSet::From(SBezierList *sbl, SPolygon *poly, + bool *allClosed, SEdge *errorAt) { int i; - SPolyCurveLoops ret; + SBezierLoopSet ret; ZERO(&ret); - while(spcl->l.n > 0) { + while(sbl->l.n > 0) { bool thisClosed; - SPolyCurveLoop loop; - loop = SPolyCurveLoop::FromCurves(spcl, &thisClosed, errorAt); + SBezierLoop loop; + loop = SBezierLoop::FromCurves(sbl, &thisClosed, errorAt); if(!thisClosed) { ret.Clear(); *allClosed = false; @@ -254,7 +254,7 @@ SPolyCurveLoops SPolyCurveLoops::From(SPolyCurveList *spcl, SPolygon *poly, return ret; } -void SPolyCurveLoops::Clear(void) { +void SBezierLoopSet::Clear(void) { int i; for(i = 0; i < l.n; i++) { (l.elem[i]).Clear(); @@ -262,26 +262,26 @@ void SPolyCurveLoops::Clear(void) { l.Clear(); } -SSurface SSurface::FromExtrusionOf(SPolyCurve *spc, Vector t0, Vector t1) { +SSurface SSurface::FromExtrusionOf(SBezier *sb, Vector t0, Vector t1) { SSurface ret; ZERO(&ret); - ret.degm = spc->deg; + ret.degm = sb->deg; ret.degn = 1; int i; for(i = 0; i <= ret.degm; i++) { - ret.ctrl[i][0] = (spc->ctrl[i]).Plus(t0); - ret.weight[i][0] = spc->weight[i]; + ret.ctrl[i][0] = (sb->ctrl[i]).Plus(t0); + ret.weight[i][0] = sb->weight[i]; - ret.ctrl[i][1] = (spc->ctrl[i]).Plus(t1); - ret.weight[i][1] = spc->weight[i]; + ret.ctrl[i][1] = (sb->ctrl[i]).Plus(t1); + ret.weight[i][1] = sb->weight[i]; } return ret; } -SShell SShell::FromExtrusionOf(SPolyCurveList *spcl, Vector t0, Vector t1) { +SShell SShell::FromExtrusionOf(SBezierList *sbl, Vector t0, Vector t1) { SShell ret; ZERO(&ret); diff --git a/srf/surface.h b/srf/surface.h index 6cf59cb..c510db2 100644 --- a/srf/surface.h +++ b/srf/surface.h @@ -18,7 +18,7 @@ public: // Stuff for rational polynomial curves, of degree one to three. These are // our inputs. -class SPolyCurve { +class SBezier { public: int tag; int deg; @@ -33,37 +33,37 @@ public: void Reverse(void); - static SPolyCurve From(Vector p0, Vector p1, Vector p2, Vector p3); - static SPolyCurve From(Vector p0, Vector p1, Vector p2); - static SPolyCurve From(Vector p0, Vector p1); + static SBezier From(Vector p0, Vector p1, Vector p2, Vector p3); + static SBezier From(Vector p0, Vector p1, Vector p2); + static SBezier From(Vector p0, Vector p1); }; -class SPolyCurveList { +class SBezierList { public: - List l; + List l; void Clear(void); }; -class SPolyCurveLoop { +class SBezierLoop { public: - List l; + List l; inline void Clear(void) { l.Clear(); } void Reverse(void); void MakePwlInto(SContour *sc); - static SPolyCurveLoop FromCurves(SPolyCurveList *spcl, - bool *allClosed, SEdge *errorAt); + static SBezierLoop FromCurves(SBezierList *spcl, + bool *allClosed, SEdge *errorAt); }; -class SPolyCurveLoops { +class SBezierLoopSet { public: - List l; + List l; Vector normal; - static SPolyCurveLoops From(SPolyCurveList *spcl, SPolygon *poly, - bool *allClosed, SEdge *errorAt); + static SBezierLoopSet From(SBezierList *spcl, SPolygon *poly, + bool *allClosed, SEdge *errorAt); void Clear(void); }; @@ -73,7 +73,7 @@ class SCurve { public: hSCurve h; - SPolyCurve exact; // or deg = 0 if we don't know the exact form + SBezier exact; // or deg = 0 if we don't know the exact form List pts; hSSurface srfA; hSSurface srfB; @@ -101,7 +101,7 @@ public: List trim; - static SSurface FromExtrusionOf(SPolyCurve *spc, Vector t0, Vector t1); + static SSurface FromExtrusionOf(SBezier *spc, Vector t0, Vector t1); void ClosestPointTo(Vector p, double *u, double *v); Vector PointAt(double u, double v); @@ -117,7 +117,7 @@ public: IdList curve; IdList surface; - static SShell FromExtrusionOf(SPolyCurveList *spcl, Vector t0, Vector t1); + static SShell FromExtrusionOf(SBezierList *spcl, Vector t0, Vector t1); static SShell FromUnionOf(SShell *a, SShell *b); }; diff --git a/ttf.cpp b/ttf.cpp index b2806cf..a41db7b 100644 --- a/ttf.cpp +++ b/ttf.cpp @@ -20,7 +20,7 @@ void TtfFontList::LoadAll(void) { } void TtfFontList::PlotString(char *font, char *str, double spacing, - SPolyCurveList *spcl, + SBezierList *sbl, Vector origin, Vector u, Vector v) { LoadAll(); @@ -30,17 +30,17 @@ void TtfFontList::PlotString(char *font, char *str, double spacing, TtfFont *tf = &(l.elem[i]); if(strcmp(tf->FontFileBaseName(), font)==0) { tf->LoadFontFromFile(false); - tf->PlotString(str, spacing, spcl, origin, u, v); + tf->PlotString(str, spacing, sbl, origin, u, v); return; } } // Couldn't find the font; so draw a big X for an error marker. - SPolyCurve spc; - spc = SPolyCurve::From(origin, origin.Plus(u).Plus(v)); - spcl->l.Add(&spc); - spc = SPolyCurve::From(origin.Plus(v), origin.Plus(u)); - spcl->l.Add(&spc); + SBezier sb; + sb = SBezier::From(origin, origin.Plus(u).Plus(v)); + sbl->l.Add(&sb); + sb = SBezier::From(origin.Plus(v), origin.Plus(u)); + sbl->l.Add(&sb); } @@ -657,10 +657,10 @@ void TtfFont::PlotCharacter(int *dx, int c, double spacing) { } void TtfFont::PlotString(char *str, double spacing, - SPolyCurveList *spcl, + SBezierList *sbl, Vector porigin, Vector pu, Vector pv) { - polyCurves = spcl; + beziers = sbl; u = pu; v = pv; origin = porigin; @@ -689,15 +689,15 @@ Vector TtfFont::TransformIntPoint(int x, int y) { } void TtfFont::LineSegment(int x0, int y0, int x1, int y1) { - SPolyCurve spc = SPolyCurve::From(TransformIntPoint(x0, y0), - TransformIntPoint(x1, y1)); - polyCurves->l.Add(&spc); + SBezier sb = SBezier::From(TransformIntPoint(x0, y0), + TransformIntPoint(x1, y1)); + beziers->l.Add(&sb); } void TtfFont::Bezier(int x0, int y0, int x1, int y1, int x2, int y2) { - SPolyCurve spc = SPolyCurve::From(TransformIntPoint(x0, y0), - TransformIntPoint(x1, y1), - TransformIntPoint(x2, y2)); - polyCurves->l.Add(&spc); + SBezier sb = SBezier::From(TransformIntPoint(x0, y0), + TransformIntPoint(x1, y1), + TransformIntPoint(x2, y2)); + beziers->l.Add(&sb); } diff --git a/undoredo.cpp b/undoredo.cpp index 67bab9a..4648c0b 100644 --- a/undoredo.cpp +++ b/undoredo.cpp @@ -49,7 +49,7 @@ void SolveSpace::PushFromCurrentOnto(UndoStack *uk) { dest.vvMeshClean = false; ZERO(&(dest.solved)); ZERO(&(dest.poly)); - ZERO(&(dest.curveLoops)); + ZERO(&(dest.bezierLoopSet)); ZERO(&(dest.polyError)); ZERO(&(dest.thisMesh)); ZERO(&(dest.runningMesh)); @@ -92,7 +92,7 @@ void SolveSpace::PopOntoCurrentFrom(UndoStack *uk) { for(i = 0; i < group.n; i++) { Group *g = &(group.elem[i]); g->poly.Clear(); - g->curveLoops.Clear(); + g->bezierLoopSet.Clear(); g->thisMesh.Clear(); g->runningMesh.Clear(); g->meshError.interferesAt.Clear();