2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
#ifndef __SKETCH_H
|
|
|
|
#define __SKETCH_H
|
|
|
|
|
2008-04-12 16:28:48 +00:00
|
|
|
class hGroup;
|
2008-03-28 10:00:37 +00:00
|
|
|
class hRequest;
|
2008-04-12 16:28:48 +00:00
|
|
|
class hEntity;
|
2008-03-28 10:00:37 +00:00
|
|
|
class hParam;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Entity;
|
2008-04-12 16:28:48 +00:00
|
|
|
class Param;
|
2008-04-09 08:39:01 +00:00
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
class hConstraint;
|
2008-04-14 10:28:32 +00:00
|
|
|
class hEquation;
|
|
|
|
class Equation;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// 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-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- group index
|
2008-04-09 08:39:01 +00:00
|
|
|
DWORD v;
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
inline hEntity entity(int i);
|
|
|
|
inline hParam param(int i);
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation equation(int i);
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
2008-03-28 10:00:37 +00:00
|
|
|
class hRequest {
|
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- request index
|
2008-04-09 08:39:01 +00:00
|
|
|
DWORD v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
inline hEntity entity(int i);
|
2008-04-19 11:09:47 +00:00
|
|
|
inline hParam param(int i);
|
2008-04-21 08:16:38 +00:00
|
|
|
|
|
|
|
inline bool IsFromReferences(void);
|
2008-04-09 08:39:01 +00:00
|
|
|
};
|
|
|
|
class hEntity {
|
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- entity index
|
|
|
|
// 31:16 -- request index
|
2008-04-09 08:39:01 +00:00
|
|
|
DWORD v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
inline bool isFromRequest(void);
|
2008-04-13 10:57:41 +00:00
|
|
|
inline hRequest request(void);
|
2008-05-11 10:40:37 +00:00
|
|
|
inline hGroup group(void);
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hEquation equation(int i);
|
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-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- param index
|
|
|
|
// 31:16 -- request index
|
2008-04-09 08:39:01 +00:00
|
|
|
DWORD v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
inline hRequest request(void);
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
|
|
|
|
class EntityId {
|
2008-04-27 09:03:01 +00:00
|
|
|
public:
|
2008-04-27 03:26:27 +00:00
|
|
|
DWORD v; // entity ID, starting from 0
|
|
|
|
};
|
|
|
|
class EntityMap {
|
2008-04-27 09:03:01 +00:00
|
|
|
public:
|
2008-04-27 03:26:27 +00:00
|
|
|
int tag;
|
|
|
|
|
|
|
|
EntityId h;
|
|
|
|
hEntity input;
|
|
|
|
int copyNumber;
|
|
|
|
// (input, copyNumber) gets mapped to ((Request)xxx).entity(h.v)
|
|
|
|
};
|
|
|
|
|
2008-04-18 07:06:37 +00:00
|
|
|
// A set of requests. Every request must have an associated group.
|
2008-04-08 12:54:53 +00:00
|
|
|
class Group {
|
|
|
|
public:
|
|
|
|
static const hGroup HGROUP_REFERENCES;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-09 08:39:01 +00:00
|
|
|
hGroup h;
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
static const int DRAWING_3D = 5000;
|
|
|
|
static const int DRAWING_WORKPLANE = 5001;
|
2008-06-06 11:35:28 +00:00
|
|
|
static const int EXTRUDE = 5100;
|
|
|
|
static const int LATHE = 5101;
|
2008-06-21 10:18:20 +00:00
|
|
|
static const int SWEEP = 5102;
|
2008-06-23 08:25:17 +00:00
|
|
|
static const int HELICAL_SWEEP = 5103;
|
2008-06-06 11:35:28 +00:00
|
|
|
static const int ROTATE = 5200;
|
|
|
|
static const int TRANSLATE = 5201;
|
|
|
|
static const int IMPORTED = 5300;
|
2008-04-24 06:22:16 +00:00
|
|
|
int type;
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
hGroup opA;
|
2008-06-21 10:18:20 +00:00
|
|
|
hGroup opB;
|
2008-04-23 07:29:19 +00:00
|
|
|
bool visible;
|
2008-06-02 09:31:26 +00:00
|
|
|
bool clean;
|
2008-05-27 02:22:20 +00:00
|
|
|
hEntity activeWorkplane;
|
2008-06-14 08:43:38 +00:00
|
|
|
double valA;
|
2008-06-23 08:25:17 +00:00
|
|
|
double valB;
|
|
|
|
double valC;
|
2008-05-30 06:09:41 +00:00
|
|
|
DWORD color;
|
2008-04-23 07:29:19 +00:00
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
static const int SOLVED_OKAY = 0;
|
|
|
|
static const int DIDNT_CONVERGE = 10;
|
|
|
|
static const int SINGULAR_JACOBIAN = 11;
|
|
|
|
struct {
|
|
|
|
int how;
|
|
|
|
SList<hConstraint> remove;
|
|
|
|
} solved;
|
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
// For drawings in 2d
|
2008-05-11 10:40:37 +00:00
|
|
|
static const int WORKPLANE_BY_POINT_ORTHO = 6000;
|
|
|
|
static const int WORKPLANE_BY_LINE_SEGMENTS = 6001;
|
2008-06-23 08:25:17 +00:00
|
|
|
// For extrudes, translates, and rotates
|
2008-05-27 06:36:59 +00:00
|
|
|
static const int ONE_SIDED = 7000;
|
|
|
|
static const int TWO_SIDED = 7001;
|
2008-06-23 08:25:17 +00:00
|
|
|
// For helical sweeps
|
|
|
|
static const int RIGHT_HANDED = 8000;
|
|
|
|
static const int LEFT_HANDED = 8001;
|
2008-05-17 08:02:39 +00:00
|
|
|
int subtype;
|
|
|
|
|
2008-06-12 04:36:33 +00:00
|
|
|
bool skipFirst; // for step and repeat ops
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
struct {
|
|
|
|
Quaternion q;
|
|
|
|
hEntity origin;
|
|
|
|
hEntity entityB;
|
|
|
|
hEntity entityC;
|
|
|
|
bool swapUV;
|
|
|
|
bool negateU;
|
|
|
|
bool negateV;
|
2008-06-01 08:29:59 +00:00
|
|
|
} predef;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2008-05-21 03:58:14 +00:00
|
|
|
SPolygon poly;
|
2008-06-12 04:36:33 +00:00
|
|
|
static const int POLY_GOOD = 0;
|
|
|
|
static const int POLY_NOT_CLOSED = 1;
|
|
|
|
static const int POLY_NOT_COPLANAR = 2;
|
2008-05-02 10:54:22 +00:00
|
|
|
struct {
|
2008-06-12 04:36:33 +00:00
|
|
|
int how;
|
2008-05-02 10:54:22 +00:00
|
|
|
SEdge notClosedAt;
|
2008-06-12 04:36:33 +00:00
|
|
|
Vector notCoplanarAt;
|
2008-05-02 10:54:22 +00:00
|
|
|
} polyError;
|
2008-06-12 04:36:33 +00:00
|
|
|
|
2008-06-21 10:18:20 +00:00
|
|
|
SMesh thisMesh;
|
|
|
|
SMesh runningMesh;
|
2008-06-04 06:39:32 +00:00
|
|
|
struct {
|
|
|
|
SMesh interferesAt;
|
|
|
|
bool yes;
|
|
|
|
} meshError;
|
2008-04-25 07:04:09 +00:00
|
|
|
|
2008-05-25 13:11:44 +00:00
|
|
|
static const int COMBINE_AS_UNION = 0;
|
|
|
|
static const int COMBINE_AS_DIFFERENCE = 1;
|
2008-06-03 18:28:41 +00:00
|
|
|
static const int COMBINE_AS_ASSEMBLE = 2;
|
2008-05-25 13:11:44 +00:00
|
|
|
int meshCombine;
|
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
IdList<EntityMap,EntityId> remap;
|
2008-06-12 04:36:33 +00:00
|
|
|
static const int REMAP_PRIME = 19477;
|
|
|
|
int remapCache[REMAP_PRIME];
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
char impFile[MAX_PATH];
|
2008-06-25 05:14:49 +00:00
|
|
|
char impFileRel[MAX_PATH];
|
2008-05-29 10:10:12 +00:00
|
|
|
SMesh impMesh;
|
|
|
|
EntityList impEntity;
|
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
NameStr name;
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
|
2008-06-02 05:38:12 +00:00
|
|
|
void Activate(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
char *DescriptionString(void);
|
2008-04-23 07:29:19 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
static void AddParam(ParamList *param, hParam hp, double v);
|
|
|
|
void Generate(EntityList *entity, ParamList *param);
|
2008-04-27 03:26:27 +00:00
|
|
|
// When a request generates entities from entities, and the source
|
|
|
|
// entities may have come from multiple requests, it's necessary to
|
|
|
|
// remap the entity ID so that it's still unique. We do this with a
|
|
|
|
// mapping list.
|
2008-06-01 08:29:59 +00:00
|
|
|
static const int REMAP_LAST = 1000;
|
|
|
|
static const int REMAP_TOP = 1001;
|
|
|
|
static const int REMAP_BOTTOM = 1002;
|
2008-06-02 03:31:37 +00:00
|
|
|
static const int REMAP_PT_TO_LINE = 1003;
|
|
|
|
static const int REMAP_LINE_TO_FACE = 1004;
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity Remap(hEntity in, int copyNumber);
|
2008-06-23 08:25:17 +00:00
|
|
|
void MakeExtrusionLines(EntityList *el, hEntity in);
|
|
|
|
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
|
2008-06-01 00:26:41 +00:00
|
|
|
void TagEdgesFromLineSegments(SEdgeList *sle);
|
2008-06-23 08:25:17 +00:00
|
|
|
void CopyEntity(EntityList *el,
|
2008-06-06 07:50:08 +00:00
|
|
|
Entity *ep, int timesApplied, int remap,
|
2008-06-01 08:29:59 +00:00
|
|
|
hParam dx, hParam dy, hParam dz,
|
2008-05-11 06:09:46 +00:00
|
|
|
hParam qw, hParam qvx, hParam qvy, hParam qvz,
|
2008-06-01 08:29:59 +00:00
|
|
|
bool asTrans, bool asAxisAngle);
|
2008-05-11 06:09:46 +00:00
|
|
|
|
2008-06-01 08:29:59 +00:00
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
2008-05-11 06:09:46 +00:00
|
|
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-06-21 10:18:20 +00:00
|
|
|
// Assembling piecewise linear sections into polygons
|
2008-06-02 09:31:26 +00:00
|
|
|
void GeneratePolygon(void);
|
2008-06-21 10:18:20 +00:00
|
|
|
// And the mesh stuff
|
|
|
|
SMesh *PreviousGroupMesh(void);
|
|
|
|
void GetTrajectory(hGroup hg, SContour *traj, SPolygon *section);
|
|
|
|
void AddQuadWithNormal(STriMeta meta, Vector out,
|
|
|
|
Vector a, Vector b, Vector c, Vector d);
|
2008-06-21 22:49:57 +00:00
|
|
|
void GenerateMeshForStepAndRepeat(void);
|
2008-06-23 08:25:17 +00:00
|
|
|
void GenerateMeshForSweep(bool helical,
|
|
|
|
Vector axisp, Vector axis, Vector onHelix);
|
2008-06-02 09:31:26 +00:00
|
|
|
void GenerateMesh(void);
|
2008-04-25 07:04:09 +00:00
|
|
|
void Draw(void);
|
|
|
|
|
2008-04-23 07:29:19 +00:00
|
|
|
SPolygon GetPolygon(void);
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
static void MenuGroup(int id);
|
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
|
2008-04-20 11:35:10 +00:00
|
|
|
// line, or a step and repeat.
|
2008-04-08 12:54:53 +00:00
|
|
|
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-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-18 07:06:37 +00:00
|
|
|
hRequest h;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// Types of requests
|
2008-04-27 03:26:27 +00:00
|
|
|
static const int WORKPLANE = 100;
|
2008-04-18 11:11:48 +00:00
|
|
|
static const int DATUM_POINT = 101;
|
|
|
|
static const int LINE_SEGMENT = 200;
|
2008-04-25 12:07:17 +00:00
|
|
|
static const int CUBIC = 300;
|
2008-05-05 06:18:01 +00:00
|
|
|
static const int CIRCLE = 400;
|
2008-05-12 10:01:44 +00:00
|
|
|
static const int ARC_OF_CIRCLE = 500;
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
int type;
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity workplane; // or Entity::FREE_IN_3D
|
2008-04-08 12:54:53 +00:00
|
|
|
hGroup group;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
bool construction;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
static hParam AddParam(ParamList *param, hParam hp);
|
|
|
|
void Generate(EntityList *entity, ParamList *param);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
|
|
|
char *DescriptionString(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-18 11:11:48 +00:00
|
|
|
int tag;
|
|
|
|
hEntity h;
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
static const hEntity FREE_IN_3D;
|
2008-05-08 07:30:30 +00:00
|
|
|
static const hEntity NO_ENTITY;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
|
|
|
static const int POINT_IN_3D = 2000;
|
|
|
|
static const int POINT_IN_2D = 2001;
|
2008-05-11 06:09:46 +00:00
|
|
|
static const int POINT_N_TRANS = 2010;
|
|
|
|
static const int POINT_N_ROT_TRANS = 2011;
|
2008-05-11 10:40:37 +00:00
|
|
|
static const int POINT_N_COPY = 2012;
|
2008-05-27 09:52:36 +00:00
|
|
|
static const int POINT_N_ROT_AA = 2013;
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
static const int NORMAL_IN_3D = 3000;
|
2008-05-05 11:17:00 +00:00
|
|
|
static const int NORMAL_IN_2D = 3001;
|
2008-05-11 06:09:46 +00:00
|
|
|
static const int NORMAL_N_COPY = 3010;
|
|
|
|
static const int NORMAL_N_ROT = 3011;
|
2008-05-27 09:52:36 +00:00
|
|
|
static const int NORMAL_N_ROT_AA = 3012;
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-05-07 08:19:37 +00:00
|
|
|
static const int DISTANCE = 4000;
|
2008-05-11 06:09:46 +00:00
|
|
|
static const int DISTANCE_N_COPY = 4001;
|
2008-05-07 08:19:37 +00:00
|
|
|
|
2008-06-02 03:31:37 +00:00
|
|
|
static const int FACE_NORMAL_PT = 5000;
|
|
|
|
static const int FACE_XPROD = 5001;
|
|
|
|
static const int FACE_N_ROT_TRANS = 5002;
|
2008-06-21 22:49:57 +00:00
|
|
|
static const int FACE_N_TRANS = 5003;
|
|
|
|
static const int FACE_N_ROT_AA = 5004;
|
2008-06-01 00:26:41 +00:00
|
|
|
|
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
static const int WORKPLANE = 10000;
|
|
|
|
static const int LINE_SEGMENT = 11000;
|
|
|
|
static const int CUBIC = 12000;
|
|
|
|
static const int CIRCLE = 13000;
|
2008-05-12 10:01:44 +00:00
|
|
|
static const int ARC_OF_CIRCLE = 14000;
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
int type;
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
// When it comes time to draw an entity, we look here to get the
|
|
|
|
// defining variables.
|
|
|
|
hEntity point[4];
|
2008-05-05 06:18:01 +00:00
|
|
|
hEntity normal;
|
2008-05-07 08:19:37 +00:00
|
|
|
hEntity distance;
|
|
|
|
// The only types that have their own params are points, normals,
|
|
|
|
// and directions.
|
2008-05-11 06:09:46 +00:00
|
|
|
hParam param[7];
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
// Transformed points/normals/distances have their numerical base
|
2008-05-05 06:18:01 +00:00
|
|
|
Vector numPoint;
|
|
|
|
Quaternion numNormal;
|
2008-05-07 08:19:37 +00:00
|
|
|
double numDistance;
|
2008-06-13 04:41:27 +00:00
|
|
|
|
|
|
|
// An imported entity that was hidden in the source file ends up hidden
|
|
|
|
// here too.
|
|
|
|
bool forceHidden;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
// All points/normals/distances have their numerical value; this is
|
|
|
|
// a convenience, to simplify the import/assembly code, so that the
|
|
|
|
// part is entirely described by the entities.
|
|
|
|
Vector actPoint;
|
|
|
|
Quaternion actNormal;
|
|
|
|
double actDistance;
|
2008-06-12 04:36:33 +00:00
|
|
|
// and the shown state also gets saved here, for later import
|
|
|
|
bool actVisible;
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
hGroup group;
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity workplane; // or Entity::FREE_IN_3D
|
|
|
|
|
2008-05-07 04:17:29 +00:00
|
|
|
bool construction;
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
// For entities that are derived by a transformation, the number of
|
|
|
|
// times to apply the transformation.
|
|
|
|
int timesApplied;
|
|
|
|
|
2008-06-21 22:49:57 +00:00
|
|
|
Quaternion GetAxisAngleQuaternion(int param0);
|
|
|
|
ExprQuaternion GetAxisAngleQuaternionExprs(int param0);
|
2008-06-02 09:31:26 +00:00
|
|
|
bool IsVisible(void);
|
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
bool IsCircle(void);
|
2008-05-12 10:01:44 +00:00
|
|
|
Expr *CircleGetRadiusExpr(void);
|
|
|
|
double CircleGetRadiusNum(void);
|
|
|
|
void ArcGetAngles(double *thetaa, double *thetab, double *dtheta);
|
2008-05-08 07:30:30 +00:00
|
|
|
|
2008-05-09 05:33:23 +00:00
|
|
|
bool HasVector(void);
|
|
|
|
ExprVector VectorGetExprs(void);
|
2008-05-11 10:40:37 +00:00
|
|
|
Vector VectorGetNum(void);
|
2008-05-09 05:33:23 +00:00
|
|
|
Vector VectorGetRefPoint(void);
|
2008-05-07 04:17:29 +00:00
|
|
|
|
2008-05-07 08:19:37 +00:00
|
|
|
// For distances
|
|
|
|
double DistanceGetNum(void);
|
|
|
|
Expr *DistanceGetExpr(void);
|
|
|
|
void DistanceForceTo(double v);
|
|
|
|
|
2008-05-05 11:17:00 +00:00
|
|
|
bool IsWorkplane(void);
|
|
|
|
// The plane is points P such that P dot (xn, yn, zn) - d = 0
|
|
|
|
void WorkplaneGetPlaneExprs(ExprVector *n, Expr **d);
|
2008-04-27 03:26:27 +00:00
|
|
|
ExprVector WorkplaneGetOffsetExprs(void);
|
2008-05-05 11:17:00 +00:00
|
|
|
Vector WorkplaneGetOffset(void);
|
|
|
|
Entity *Normal(void);
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-06-02 03:31:37 +00:00
|
|
|
bool IsFace(void);
|
|
|
|
ExprVector FaceGetNormalExprs(void);
|
|
|
|
Vector FaceGetNormalNum(void);
|
|
|
|
ExprVector FaceGetPointExprs(void);
|
2008-06-06 08:46:55 +00:00
|
|
|
Vector FaceGetPointNum(void);
|
2008-06-02 03:31:37 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
bool IsPoint(void);
|
|
|
|
// Applies for any of the point types
|
2008-05-05 06:18:01 +00:00
|
|
|
Vector PointGetNum(void);
|
2008-04-22 13:14:15 +00:00
|
|
|
ExprVector PointGetExprs(void);
|
2008-04-27 05:00:12 +00:00
|
|
|
void PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v);
|
2008-04-19 11:44:44 +00:00
|
|
|
void PointForceTo(Vector v);
|
|
|
|
bool PointIsFromReferences(void);
|
2008-05-11 06:09:46 +00:00
|
|
|
// These apply only the POINT_N_ROT_TRANS, which has an assoc rotation
|
|
|
|
Quaternion PointGetQuaternion(void);
|
|
|
|
void PointForceQuaternionTo(Quaternion q);
|
2008-04-21 08:16:38 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
bool IsNormal(void);
|
|
|
|
// Applies for any of the normal types
|
|
|
|
Quaternion NormalGetNum(void);
|
|
|
|
ExprQuaternion NormalGetExprs(void);
|
|
|
|
void NormalForceTo(Quaternion q);
|
|
|
|
|
2008-05-05 11:17:00 +00:00
|
|
|
Vector NormalU(void);
|
|
|
|
Vector NormalV(void);
|
|
|
|
Vector NormalN(void);
|
|
|
|
ExprVector NormalExprsU(void);
|
|
|
|
ExprVector NormalExprsV(void);
|
|
|
|
ExprVector NormalExprsN(void);
|
2008-04-19 11:09:47 +00:00
|
|
|
|
|
|
|
// Routines to draw and hit-test the representation of the entity
|
|
|
|
// on-screen.
|
2008-04-12 14:12:26 +00:00
|
|
|
struct {
|
2008-04-25 07:04:09 +00:00
|
|
|
bool drawing;
|
|
|
|
Point2d mp;
|
|
|
|
double dmin;
|
|
|
|
SEdgeList *edges;
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector refp;
|
2008-04-25 07:04:09 +00:00
|
|
|
} dogd; // state for drawing or getting distance (for hit testing)
|
2008-04-12 14:12:26 +00:00
|
|
|
void LineDrawOrGetDistance(Vector a, Vector b);
|
2008-04-25 07:04:09 +00:00
|
|
|
void LineDrawOrGetDistanceOrEdge(Vector a, Vector b);
|
2008-06-06 07:50:08 +00:00
|
|
|
void DrawOrGetDistance(void);
|
2008-04-25 07:04:09 +00:00
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
static void DrawAll(void);
|
|
|
|
void Draw(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
double GetDistance(Point2d mp);
|
2008-04-25 07:04:09 +00:00
|
|
|
void GenerateEdges(SEdgeList *el);
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector GetReferencePos(void);
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
|
|
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
|
|
|
|
2008-06-13 04:41:27 +00:00
|
|
|
void CalculateNumerical(bool forExport);
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
char *DescriptionString(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-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-09 08:39:01 +00:00
|
|
|
hParam h;
|
2008-04-18 07:21:17 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
double val;
|
|
|
|
bool known;
|
2008-05-07 07:10:20 +00:00
|
|
|
|
|
|
|
// Used only in the solver
|
|
|
|
hParam substd;
|
2008-05-11 06:09:46 +00:00
|
|
|
|
|
|
|
static const hParam NO_PARAM;
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
class hConstraint {
|
|
|
|
public:
|
|
|
|
DWORD v;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation equation(int i);
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Constraint {
|
|
|
|
public:
|
2008-05-26 09:56:50 +00:00
|
|
|
static const hConstraint NO_CONSTRAINT;
|
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
static const int POINTS_COINCIDENT = 20;
|
|
|
|
static const int PT_PT_DISTANCE = 30;
|
2008-06-06 08:46:55 +00:00
|
|
|
static const int PT_PLANE_DISTANCE = 31;
|
|
|
|
static const int PT_LINE_DISTANCE = 32;
|
|
|
|
static const int PT_FACE_DISTANCE = 33;
|
|
|
|
static const int PT_IN_PLANE = 41;
|
|
|
|
static const int PT_ON_LINE = 42;
|
|
|
|
static const int PT_ON_FACE = 43;
|
2008-05-08 07:30:30 +00:00
|
|
|
static const int EQUAL_LENGTH_LINES = 50;
|
2008-05-11 10:40:37 +00:00
|
|
|
static const int LENGTH_RATIO = 51;
|
2008-06-14 11:16:14 +00:00
|
|
|
static const int EQ_LEN_PT_LINE_D = 52;
|
|
|
|
static const int EQ_PT_LN_DISTANCES = 53;
|
2008-05-08 07:30:30 +00:00
|
|
|
static const int SYMMETRIC = 60;
|
2008-05-13 10:38:21 +00:00
|
|
|
static const int SYMMETRIC_HORIZ = 61;
|
|
|
|
static const int SYMMETRIC_VERT = 62;
|
2008-05-08 07:30:30 +00:00
|
|
|
static const int AT_MIDPOINT = 70;
|
|
|
|
static const int HORIZONTAL = 80;
|
|
|
|
static const int VERTICAL = 81;
|
|
|
|
static const int DIAMETER = 90;
|
|
|
|
static const int PT_ON_CIRCLE = 100;
|
2008-05-09 05:33:23 +00:00
|
|
|
static const int SAME_ORIENTATION = 110;
|
2008-05-17 11:15:14 +00:00
|
|
|
static const int ANGLE = 120;
|
|
|
|
static const int PARALLEL = 121;
|
2008-05-12 10:01:44 +00:00
|
|
|
static const int EQUAL_RADIUS = 130;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2008-06-12 08:58:58 +00:00
|
|
|
static const int COMMENT = 1000;
|
|
|
|
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-14 10:28:32 +00:00
|
|
|
hConstraint h;
|
2008-04-18 07:21:17 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
int type;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
hGroup group;
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity workplane;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
|
|
|
// These are the parameters for the constraint.
|
2008-06-14 08:43:38 +00:00
|
|
|
double valA;
|
2008-04-19 11:09:47 +00:00
|
|
|
hEntity ptA;
|
|
|
|
hEntity ptB;
|
|
|
|
hEntity ptC;
|
2008-04-14 10:28:32 +00:00
|
|
|
hEntity entityA;
|
|
|
|
hEntity entityB;
|
2008-05-17 11:15:14 +00:00
|
|
|
bool otherAngle;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2008-06-09 09:03:21 +00:00
|
|
|
bool reference; // a ref dimension, that generates no eqs
|
|
|
|
|
2008-06-12 08:58:58 +00:00
|
|
|
NameStr comment; // since comments are represented as constraints
|
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
// These define how the constraint is drawn on-screen.
|
|
|
|
struct {
|
|
|
|
Vector offset;
|
|
|
|
} disp;
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
char *DescriptionString(void);
|
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
static void AddConstraint(Constraint *c, bool rememberForUndo);
|
2008-05-17 23:48:58 +00:00
|
|
|
static void AddConstraint(Constraint *c);
|
2008-04-14 10:28:32 +00:00
|
|
|
static void MenuConstrain(int id);
|
|
|
|
|
|
|
|
struct {
|
2008-04-25 07:04:09 +00:00
|
|
|
bool drawing;
|
|
|
|
Point2d mp;
|
|
|
|
double dmin;
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector refp;
|
2008-04-14 10:28:32 +00:00
|
|
|
} dogd; // state for drawing or getting distance (for hit testing)
|
2008-04-21 08:16:38 +00:00
|
|
|
void LineDrawOrGetDistance(Vector a, Vector b);
|
2008-04-21 10:12:04 +00:00
|
|
|
void DrawOrGetDistance(Vector *labelPos);
|
2008-05-07 08:19:37 +00:00
|
|
|
double EllipticalInterpolation(double rx, double ry, double theta);
|
2008-06-11 04:22:52 +00:00
|
|
|
char *Label(void);
|
2008-05-07 08:19:37 +00:00
|
|
|
void DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu);
|
2008-05-08 07:30:30 +00:00
|
|
|
void DoProjectedPoint(Vector *p);
|
2008-06-14 11:16:14 +00:00
|
|
|
void DoEqualLenTicks(Vector a, Vector b, Vector gn);
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
double GetDistance(Point2d mp);
|
2008-04-21 10:12:04 +00:00
|
|
|
Vector GetLabelPos(void);
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector GetReferencePos(void);
|
2008-04-14 10:28:32 +00:00
|
|
|
void Draw(void);
|
|
|
|
|
|
|
|
bool HasLabel(void);
|
|
|
|
|
|
|
|
void Generate(IdList<Equation,hEquation> *l);
|
2008-06-11 04:22:52 +00:00
|
|
|
void GenerateReal(IdList<Equation,hEquation> *l);
|
2008-04-20 11:35:10 +00:00
|
|
|
// Some helpers when generating symbolic constraint equations
|
2008-04-22 10:53:42 +00:00
|
|
|
void ModifyToSatisfy(void);
|
2008-04-20 11:35:10 +00:00
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
2008-04-27 05:00:12 +00:00
|
|
|
static Expr *Distance(hEntity workplane, hEntity pa, hEntity pb);
|
2008-04-28 09:40:02 +00:00
|
|
|
static Expr *PointLineDistance(hEntity workplane, hEntity pt, hEntity ln);
|
2008-04-30 08:14:32 +00:00
|
|
|
static Expr *PointPlaneDistance(ExprVector p, hEntity plane);
|
|
|
|
static Expr *VectorsParallel(int eq, ExprVector a, ExprVector b);
|
2008-05-01 06:53:50 +00:00
|
|
|
static ExprVector PointInThreeSpace(hEntity workplane, Expr *u, Expr *v);
|
2008-04-23 07:29:19 +00:00
|
|
|
|
|
|
|
static void ConstrainCoincident(hEntity ptA, hEntity ptB);
|
2008-05-08 07:30:30 +00:00
|
|
|
static void Constrain(int type, hEntity ptA, hEntity ptB, hEntity entityA);
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class hEquation {
|
|
|
|
public:
|
|
|
|
DWORD v;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Equation {
|
|
|
|
public:
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-14 10:28:32 +00:00
|
|
|
hEquation h;
|
2008-04-18 07:21:17 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
Expr *e;
|
|
|
|
};
|
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline hEntity hGroup::entity(int i)
|
|
|
|
{ hEntity r; r.v = 0x80000000 | (v << 16) | i; return r; }
|
|
|
|
inline hParam hGroup::param(int i)
|
|
|
|
{ hParam r; r.v = 0x80000000 | (v << 16) | i; return r; }
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation hGroup::equation(int i)
|
2008-05-16 06:34:06 +00:00
|
|
|
{ hEquation r; r.v = (v << 16) | 0x80000000 | i; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline bool hRequest::IsFromReferences(void) {
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_YZ.v) return true;
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_ZX.v) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
inline hEntity hRequest::entity(int i)
|
|
|
|
{ hEntity r; r.v = (v << 16) | i; return r; }
|
|
|
|
inline hParam hRequest::param(int i)
|
|
|
|
{ hParam r; r.v = (v << 16) | i; return r; }
|
|
|
|
|
|
|
|
inline bool hEntity::isFromRequest(void)
|
|
|
|
{ if(v & 0x80000000) return false; else return true; }
|
|
|
|
inline hRequest hEntity::request(void)
|
|
|
|
{ hRequest r; r.v = (v >> 16); return r; }
|
2008-05-11 10:40:37 +00:00
|
|
|
inline hGroup hEntity::group(void)
|
|
|
|
{ hGroup r; r.v = (v >> 16) & 0x3fff; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hEquation hEntity::equation(int i)
|
2008-05-11 06:09:46 +00:00
|
|
|
{ if(i != 0) oops(); hEquation r; r.v = v | 0x40000000; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline hRequest hParam::request(void)
|
|
|
|
{ hRequest r; r.v = (v >> 16); return r; }
|
|
|
|
|
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
inline hEquation hConstraint::equation(int i)
|
|
|
|
{ hEquation r; r.v = (v << 16) | i; return r; }
|
|
|
|
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
#endif
|