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