2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
#ifndef __SKETCH_H
|
|
|
|
#define __SKETCH_H
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class hEntity;
|
|
|
|
class hPoint;
|
|
|
|
class hRequest;
|
|
|
|
class hParam;
|
2008-04-01 10:48:44 +00:00
|
|
|
class hGroup;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Entity;
|
|
|
|
|
|
|
|
// All of the hWhatever handles are a 32-bit ID, that is used to represent
|
|
|
|
// some data structure in the sketch.
|
2008-04-08 12:54:53 +00:00
|
|
|
class hGroup {
|
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
// bits 10: 0 -- group index
|
|
|
|
DWORD v;
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
2008-03-28 10:00:37 +00:00
|
|
|
class hRequest {
|
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
// bits 10: 0 -- request index
|
|
|
|
DWORD v;
|
|
|
|
};
|
|
|
|
class hEntity {
|
|
|
|
public:
|
|
|
|
// bits 10: 0 -- entity index
|
|
|
|
// 21:11 -- request index
|
|
|
|
DWORD v;
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-04-08 12:54:53 +00:00
|
|
|
class hParam {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-08 12:54:53 +00:00
|
|
|
// bits 7: 0 -- param index
|
2008-04-09 08:39:01 +00:00
|
|
|
// 18: 8 -- entity index
|
|
|
|
// 29:19 -- request index
|
|
|
|
DWORD v;
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
|
|
|
class hPoint {
|
2008-04-09 08:39:01 +00:00
|
|
|
// bits 7: 0 -- point index
|
|
|
|
// 18: 8 -- entity index
|
|
|
|
// 29:19 -- request index
|
2008-04-08 12:54:53 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
DWORD v;
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A set of requests. Every request must have an associated group. A group
|
|
|
|
// may have an associated 2-d coordinate system, in which cases lines or
|
|
|
|
// curves that belong to the group are automatically constrained into that
|
|
|
|
// plane; otherwise they are free in 3-space.
|
|
|
|
class Group {
|
|
|
|
public:
|
|
|
|
static const hGroup HGROUP_REFERENCES;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
hGroup h;
|
|
|
|
|
|
|
|
hEntity csys; // or Entity::NO_CSYS, if it's not locked in a 2d csys
|
2008-04-08 12:54:53 +00:00
|
|
|
NameStr name;
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
// A user request for some primitive or derived operation; for example a
|
|
|
|
// line, or a
|
|
|
|
class Request {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
// Some predefined requests, that are present in every sketch.
|
2008-04-08 12:54:53 +00:00
|
|
|
static const hRequest HREQUEST_REFERENCE_XY;
|
|
|
|
static const hRequest HREQUEST_REFERENCE_YZ;
|
|
|
|
static const hRequest HREQUEST_REFERENCE_ZX;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// Types of requests
|
|
|
|
static const int CSYS_2D = 0;
|
2008-04-08 12:54:53 +00:00
|
|
|
static const int LINE_SEGMENT = 1;
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
int type;
|
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
hRequest h;
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
hGroup group;
|
|
|
|
|
|
|
|
NameStr name;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
inline hEntity entity(int i)
|
|
|
|
{ hEntity r; r.v = ((this->h.v) << 11) | i; return r; }
|
|
|
|
|
|
|
|
void AddParam(Entity *e, int index);
|
|
|
|
void Generate(void);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Entity {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
static const hEntity NO_CSYS;
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
static const int CSYS_2D = 100;
|
|
|
|
static const int LINE_SEGMENT = 101;
|
|
|
|
int type;
|
|
|
|
|
|
|
|
hEntity h;
|
|
|
|
|
|
|
|
Expr *expr[16];
|
|
|
|
|
|
|
|
inline hParam param(int i)
|
|
|
|
{ hParam r; r.v = ((this->h.v) << 8) | i; return r; }
|
|
|
|
inline hPoint point(int i)
|
|
|
|
{ hPoint r; r.v = ((this->h.v) << 8) | i; return r; }
|
|
|
|
|
|
|
|
void Draw(void);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Param {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
hParam h;
|
|
|
|
double val;
|
|
|
|
bool known;
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
void ForceTo(double v);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Point {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
// The point ID is equal to the initial param ID.
|
|
|
|
hPoint h;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
int type;
|
|
|
|
static const int IN_FREE_SPACE = 0; // three params, x y z
|
|
|
|
static const int IN_2D_CSYS = 1; // two params, u v, plus csys
|
|
|
|
static const int BY_EXPR = 2; // three Expr *, could be anything
|
2008-04-08 12:54:53 +00:00
|
|
|
|
|
|
|
hEntity csys;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
inline hEntity entity(void)
|
|
|
|
{ hEntity r; r.v = (h.v >> 8); return r; }
|
|
|
|
inline hParam param(int i)
|
|
|
|
{ hParam r; r.v = h.v + i; return r; }
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// The point, in base coordinates. This may be a single parameter, or
|
|
|
|
// it may be a more complex expression if our point is locked in a
|
|
|
|
// 2d csys.
|
|
|
|
Expr *x(void);
|
|
|
|
Expr *y(void);
|
|
|
|
Expr *z(void);
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
void ForceTo(Vector v);
|
|
|
|
void GetInto(Vector *v);
|
|
|
|
};
|
2008-04-08 12:54:53 +00:00
|
|
|
|
|
|
|
#endif
|