2009-01-10 08:18:54 +00:00
|
|
|
|
|
|
|
#ifndef __SURFACE_H
|
|
|
|
#define __SURFACE_H
|
|
|
|
|
2009-01-15 03:55:42 +00:00
|
|
|
// Utility function
|
|
|
|
double Bernstein(int k, int deg, double t);
|
|
|
|
|
|
|
|
class hSSurface {
|
|
|
|
public:
|
|
|
|
DWORD v;
|
|
|
|
};
|
|
|
|
|
|
|
|
class hSCurve {
|
|
|
|
public:
|
|
|
|
DWORD v;
|
|
|
|
};
|
2009-01-10 08:18:54 +00:00
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
// Stuff for rational polynomial curves, of degree one to three. These are
|
|
|
|
// our inputs.
|
|
|
|
class SPolyCurve {
|
|
|
|
public:
|
2009-01-17 05:28:49 +00:00
|
|
|
int tag;
|
2009-01-14 05:10:42 +00:00
|
|
|
int deg;
|
|
|
|
Vector ctrl[4];
|
|
|
|
double weight[4];
|
|
|
|
|
|
|
|
Vector EvalAt(double t);
|
2009-01-15 03:55:42 +00:00
|
|
|
Vector Start(void);
|
|
|
|
Vector Finish(void);
|
|
|
|
void MakePwlInto(List<Vector> *l);
|
|
|
|
void MakePwlWorker(List<Vector> *l, double ta, double tb);
|
2009-01-14 05:10:42 +00:00
|
|
|
|
2009-01-17 05:28:49 +00:00
|
|
|
void Reverse(void);
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
static SPolyCurve From(Vector p0, Vector p1, Vector p2, Vector p3);
|
2009-01-15 03:55:42 +00:00
|
|
|
static SPolyCurve From(Vector p0, Vector p1, Vector p2);
|
2009-01-14 05:10:42 +00:00
|
|
|
static SPolyCurve From(Vector p0, Vector p1);
|
|
|
|
};
|
|
|
|
|
|
|
|
class SPolyCurveList {
|
|
|
|
public:
|
|
|
|
List<SPolyCurve> l;
|
2009-01-15 03:55:42 +00:00
|
|
|
|
|
|
|
void Clear(void);
|
2009-01-14 05:10:42 +00:00
|
|
|
};
|
|
|
|
|
2009-01-17 05:28:49 +00:00
|
|
|
class SPolyCurveLoop {
|
|
|
|
public:
|
|
|
|
List<SPolyCurve> l;
|
|
|
|
|
|
|
|
bool IsClockwiseProjdToNormal(Vector n);
|
|
|
|
|
|
|
|
static SPolyCurveLoop FromCurves(SPolyCurveList *spcl, bool *notClosed);
|
|
|
|
};
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
|
|
|
|
// Stuff for the surface trim curves: piecewise linear
|
2009-01-10 08:18:54 +00:00
|
|
|
class SCurve {
|
|
|
|
public:
|
|
|
|
hSCurve h;
|
|
|
|
|
2009-01-17 05:28:49 +00:00
|
|
|
SPolyCurve exact; // or deg = 0 if we don't know the exact form
|
|
|
|
List<Vector> pts;
|
2009-01-10 08:18:54 +00:00
|
|
|
hSSurface srfA;
|
|
|
|
hSSurface srfB;
|
|
|
|
};
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
// A segment of a curve by which a surface is trimmed: indicates which curve,
|
|
|
|
// by its handle, and the starting and ending points of our segment of it.
|
|
|
|
// The vector out points out of the surface; it, the surface outer normal,
|
|
|
|
// and a tangent to the beginning of the curve are all orthogonal.
|
2009-01-10 08:18:54 +00:00
|
|
|
class STrimBy {
|
|
|
|
public:
|
|
|
|
hSCurve curve;
|
|
|
|
Vector start;
|
|
|
|
Vector finish;
|
2009-01-14 05:10:42 +00:00
|
|
|
Vector out;
|
2009-01-10 08:18:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SSurface {
|
|
|
|
public:
|
|
|
|
hSSurface h;
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
int degm, degn;
|
2009-01-10 08:18:54 +00:00
|
|
|
Vector ctrl[4][4];
|
2009-01-14 05:10:42 +00:00
|
|
|
double weight[4][4];
|
2009-01-17 05:28:49 +00:00
|
|
|
Vector out00; // outer normal at ctrl[0][0]
|
2009-01-10 08:18:54 +00:00
|
|
|
|
2009-01-15 03:55:42 +00:00
|
|
|
List<STrimBy> trim;
|
2009-01-17 05:28:49 +00:00
|
|
|
|
|
|
|
static SSurface FromExtrusionOf(SPolyCurve *spc, Vector t0, Vector t1);
|
|
|
|
|
|
|
|
void TriangulateInto(SMesh *sm);
|
2009-01-10 08:18:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SShell {
|
|
|
|
public:
|
2009-01-14 05:10:42 +00:00
|
|
|
IdList<SCurve,hSCurve> curve;
|
2009-01-10 08:18:54 +00:00
|
|
|
IdList<SSurface,hSSurface> surface;
|
2009-01-17 05:28:49 +00:00
|
|
|
|
|
|
|
static SShell FromExtrusionOf(SPolyCurveList *spcl, Vector t0, Vector t1);
|
|
|
|
|
|
|
|
static SShell FromUnionOf(SShell *a, SShell *b);
|
2009-01-10 08:18:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|