2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#ifndef __SOLVESPACE_H
|
|
|
|
#define __SOLVESPACE_H
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
// Debugging functions
|
|
|
|
#define oops() do { dbp("oops at line %d, file %s", __LINE__, __FILE__); \
|
2008-05-17 23:21:02 +00:00
|
|
|
if(1) *(char *)0 = 1; exit(-1); } while(0)
|
2008-03-28 10:00:37 +00:00
|
|
|
#ifndef min
|
|
|
|
#define min(x, y) ((x) < (y) ? (x) : (y))
|
|
|
|
#endif
|
|
|
|
#ifndef max
|
|
|
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
#endif
|
|
|
|
|
2008-06-03 18:28:41 +00:00
|
|
|
#define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))
|
|
|
|
|
2008-05-26 03:39:45 +00:00
|
|
|
inline int WRAP(int v, int n) {
|
2009-01-03 12:27:33 +00:00
|
|
|
// Clamp it to the range [0, n)
|
2008-05-26 03:39:45 +00:00
|
|
|
while(v >= n) v -= n;
|
|
|
|
while(v < 0) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-01-03 12:27:33 +00:00
|
|
|
inline double WRAP_NOT_0(double v, double n) {
|
|
|
|
// Clamp it to the range (0, n]
|
|
|
|
while(v > n) v -= n;
|
|
|
|
while(v <= 0) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-03-19 17:40:11 +00:00
|
|
|
inline double WRAP_SYMMETRIC(double v, double n) {
|
|
|
|
// Clamp it to the range (-n/2, n/2]
|
|
|
|
while(v > n/2) v -= n;
|
|
|
|
while(v <= -n/2) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-01-03 12:27:33 +00:00
|
|
|
|
2009-10-21 04:46:01 +00:00
|
|
|
// Why is this faster than the library function?
|
|
|
|
inline double ffabs(double v) { return (v > 0) ? v : (-v); }
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
#define SWAP(T, a, b) do { T temp = (a); (a) = (b); (b) = temp; } while(0)
|
2008-05-19 09:23:49 +00:00
|
|
|
#define ZERO(v) memset((v), 0, sizeof(*(v)))
|
2008-05-22 10:28:28 +00:00
|
|
|
#define CO(v) (v).x, (v).y, (v).z
|
|
|
|
|
2009-03-08 10:59:57 +00:00
|
|
|
#define LENGTH_EPS (1e-6)
|
2009-01-27 05:48:40 +00:00
|
|
|
#define VERY_POSITIVE (1e10)
|
|
|
|
#define VERY_NEGATIVE (-1e10)
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2008-04-17 06:42:32 +00:00
|
|
|
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
|
|
|
|
2009-04-19 03:55:46 +00:00
|
|
|
typedef unsigned __int64 QWORD;
|
2009-06-10 06:57:27 +00:00
|
|
|
typedef signed __int64 SQWORD;
|
2008-04-18 11:11:48 +00:00
|
|
|
typedef signed long SDWORD;
|
2008-06-30 09:09:17 +00:00
|
|
|
typedef signed short SWORD;
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
#include <stdlib.h>
|
2008-04-17 06:42:32 +00:00
|
|
|
#include <ctype.h>
|
2008-03-25 10:02:13 +00:00
|
|
|
#include <string.h>
|
2008-03-26 09:18:12 +00:00
|
|
|
#include <stdio.h>
|
2008-03-27 09:53:51 +00:00
|
|
|
#include <math.h>
|
2008-04-01 10:48:44 +00:00
|
|
|
#include <windows.h> // required for GL stuff
|
|
|
|
#include <gl/gl.h>
|
|
|
|
#include <gl/glu.h>
|
|
|
|
|
2009-02-09 12:40:48 +00:00
|
|
|
inline double Random(double vmax) {
|
|
|
|
return (vmax*rand()) / RAND_MAX;
|
|
|
|
}
|
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
class Expr;
|
2008-04-22 13:14:15 +00:00
|
|
|
class ExprVector;
|
2008-05-05 06:18:01 +00:00
|
|
|
class ExprQuaternion;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
//================
|
2008-04-14 10:28:32 +00:00
|
|
|
// From the platform-specific code.
|
2008-05-28 10:10:31 +00:00
|
|
|
#define MAX_RECENT 8
|
|
|
|
#define RECENT_OPEN (0xf000)
|
|
|
|
#define RECENT_IMPORT (0xf100)
|
|
|
|
extern char RecentFile[MAX_RECENT][MAX_PATH];
|
|
|
|
void RefreshRecentMenus(void);
|
|
|
|
|
2008-04-18 11:11:48 +00:00
|
|
|
int SaveFileYesNoCancel(void);
|
2009-10-12 10:40:48 +00:00
|
|
|
// SolveSpace native file format
|
2008-05-29 10:10:12 +00:00
|
|
|
#define SLVS_PATTERN "SolveSpace Models (*.slvs)\0*.slvs\0All Files (*)\0*\0\0"
|
|
|
|
#define SLVS_EXT "slvs"
|
2009-10-12 10:40:48 +00:00
|
|
|
// PNG format bitmap
|
2008-06-18 08:35:14 +00:00
|
|
|
#define PNG_PATTERN "PNG (*.png)\0*.png\0All Files (*)\0*\0\0"
|
|
|
|
#define PNG_EXT "png"
|
2009-10-12 10:40:48 +00:00
|
|
|
// Triangle mesh
|
2009-10-12 11:34:43 +00:00
|
|
|
#define MESH_PATTERN "STL Mesh (*.stl)\0*.stl\0" \
|
|
|
|
"Wavefront OBJ Mesh (*.obj)\0*.obj\0" \
|
|
|
|
"All Files (*)\0*\0\0"
|
|
|
|
#define MESH_EXT "stl"
|
2009-10-12 10:40:48 +00:00
|
|
|
// NURBS surfaces
|
2009-06-08 06:50:16 +00:00
|
|
|
#define SRF_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
|
|
|
"All Files(*)\0*\0\0"
|
|
|
|
#define SRF_EXT "step"
|
2009-10-12 10:40:48 +00:00
|
|
|
// 2d vector (lines and curves) format
|
2009-06-11 05:57:23 +00:00
|
|
|
#define VEC_PATTERN "PDF File (*.pdf)\0*.pdf\0" \
|
2009-01-27 05:48:40 +00:00
|
|
|
"Encapsulated PostScript (*.eps;*.ps)\0*.eps;*.ps\0" \
|
|
|
|
"Scalable Vector Graphics (*.svg)\0*.svg\0" \
|
2009-06-11 05:57:23 +00:00
|
|
|
"STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
|
|
|
"DXF File (*.dxf)\0*.dxf\0" \
|
2009-01-27 05:48:40 +00:00
|
|
|
"HPGL File (*.plt;*.hpgl)\0*.plt;*.hpgl\0" \
|
2010-01-14 04:47:17 +00:00
|
|
|
"G Code (*.txt)\0*.txt\0" \
|
2009-01-27 05:48:40 +00:00
|
|
|
"All Files (*)\0*\0\0"
|
2009-06-11 05:57:23 +00:00
|
|
|
#define VEC_EXT "pdf"
|
2009-10-12 10:40:48 +00:00
|
|
|
// 3d vector (wireframe lines and curves) format
|
|
|
|
#define V3D_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
|
|
|
"DXF File (*.dxf)\0*.dxf\0" \
|
|
|
|
"All Files (*)\0*\0\0"
|
|
|
|
#define V3D_EXT "step"
|
|
|
|
// Comma-separated value, like a spreadsheet would use
|
2008-07-20 11:27:22 +00:00
|
|
|
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
|
|
|
|
#define CSV_EXT "csv"
|
2009-10-12 10:40:48 +00:00
|
|
|
// Native license file
|
2008-02-09 13:52:01 +00:00
|
|
|
#define LICENSE_PATTERN \
|
|
|
|
"License File (*.license)\0*.license\0All Files (*)\0*\0\0"
|
|
|
|
#define LICENSE_EXT "license"
|
2008-04-18 11:11:48 +00:00
|
|
|
BOOL GetSaveFile(char *file, char *defExtension, char *selPattern);
|
|
|
|
BOOL GetOpenFile(char *file, char *defExtension, char *selPattern);
|
2008-06-25 05:14:49 +00:00
|
|
|
void GetAbsoluteFilename(char *file);
|
2008-06-30 09:09:17 +00:00
|
|
|
void LoadAllFontFiles(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-02-09 13:52:01 +00:00
|
|
|
void OpenWebsite(char *url);
|
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
void CheckMenuById(int id, BOOL checked);
|
2008-04-18 07:06:37 +00:00
|
|
|
void EnableMenuById(int id, BOOL checked);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
void ShowGraphicsEditControl(int x, int y, char *s);
|
|
|
|
void HideGraphicsEditControl(void);
|
|
|
|
BOOL GraphicsEditControlIsVisible(void);
|
2008-05-27 06:36:59 +00:00
|
|
|
void ShowTextEditControl(int hr, int c, char *s);
|
|
|
|
void HideTextEditControl(void);
|
|
|
|
BOOL TextEditControlIsVisible(void);
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2009-09-23 10:59:59 +00:00
|
|
|
#define CONTEXT_SUBMENU (-1)
|
|
|
|
#define CONTEXT_SEPARATOR (-2)
|
|
|
|
void AddContextMenuItem(char *legend, int id);
|
|
|
|
void CreateContextSubmenu(void);
|
|
|
|
int ShowContextMenu(void);
|
|
|
|
|
2008-04-27 05:00:12 +00:00
|
|
|
void ShowTextWindow(BOOL visible);
|
2008-04-14 10:28:32 +00:00
|
|
|
void InvalidateText(void);
|
2008-04-27 05:00:12 +00:00
|
|
|
void InvalidateGraphics(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
void PaintGraphics(void);
|
2008-06-12 07:31:41 +00:00
|
|
|
void GetGraphicsWindowSize(int *w, int *h);
|
2008-04-27 05:00:12 +00:00
|
|
|
SDWORD GetMilliseconds(void);
|
2009-06-10 06:57:27 +00:00
|
|
|
SQWORD GetUnixTime(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
void dbp(char *str, ...);
|
2008-05-30 07:32:30 +00:00
|
|
|
#define DBPTRI(tri) \
|
|
|
|
dbp("tri: (%.3f %.3f %.3f) (%.3f %.3f %.3f) (%.3f %.3f %.3f)", \
|
|
|
|
CO((tri).a), CO((tri).b), CO((tri).c))
|
|
|
|
|
2008-07-08 08:02:22 +00:00
|
|
|
void SetWindowTitle(char *str);
|
2010-01-16 09:22:44 +00:00
|
|
|
void DoMessageBox(char *str, int rows, int cols, BOOL error);
|
2009-01-02 10:38:36 +00:00
|
|
|
void SetTimerFor(int milliseconds);
|
2008-06-03 18:48:47 +00:00
|
|
|
void ExitNow(void);
|
2008-07-08 08:02:22 +00:00
|
|
|
|
2009-01-02 10:38:36 +00:00
|
|
|
void DrawWithBitmapFont(char *str);
|
|
|
|
void GetBitmapFontExtent(char *str, int *w, int *h);
|
|
|
|
|
2008-06-11 04:22:52 +00:00
|
|
|
void CnfFreezeString(char *str, char *name);
|
|
|
|
void CnfFreezeDWORD(DWORD v, char *name);
|
2008-07-08 07:41:29 +00:00
|
|
|
void CnfFreezeFloat(float v, char *name);
|
2008-06-11 04:22:52 +00:00
|
|
|
void CnfThawString(char *str, int maxLen, char *name);
|
|
|
|
DWORD CnfThawDWORD(DWORD v, char *name);
|
2008-07-08 07:41:29 +00:00
|
|
|
float CnfThawFloat(float v, char *name);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-04-25 10:11:29 +00:00
|
|
|
void *AllocTemporary(int n);
|
2008-07-13 12:58:52 +00:00
|
|
|
void FreeTemporary(void *p);
|
2008-04-25 10:11:29 +00:00
|
|
|
void FreeAllTemporary(void);
|
2008-04-18 07:06:37 +00:00
|
|
|
void *MemRealloc(void *p, int n);
|
|
|
|
void *MemAlloc(int n);
|
|
|
|
void MemFree(void *p);
|
2009-04-20 07:30:09 +00:00
|
|
|
void InitHeaps(void);
|
2008-06-30 09:09:17 +00:00
|
|
|
void vl(void); // debug function to validate heaps
|
|
|
|
|
|
|
|
// End of platform-specific functions
|
|
|
|
//================
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
class Group;
|
2009-02-27 14:05:08 +00:00
|
|
|
class SSurface;
|
2008-03-25 10:02:13 +00:00
|
|
|
#include "dsc.h"
|
2008-04-23 07:29:19 +00:00
|
|
|
#include "polygon.h"
|
2009-01-15 03:55:42 +00:00
|
|
|
#include "srf/surface.h"
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
class Entity;
|
|
|
|
class hEntity;
|
2008-06-23 08:25:17 +00:00
|
|
|
class Param;
|
|
|
|
class hParam;
|
2008-05-29 10:10:12 +00:00
|
|
|
typedef IdList<Entity,hEntity> EntityList;
|
2008-06-23 08:25:17 +00:00
|
|
|
typedef IdList<Param,hParam> ParamList;
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#include "sketch.h"
|
2008-04-12 14:12:26 +00:00
|
|
|
#include "ui.h"
|
2008-04-08 12:54:53 +00:00
|
|
|
#include "expr.h"
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-04-11 11:13:47 +00:00
|
|
|
// Utility functions that are provided in the platform-independent code.
|
|
|
|
void glxVertex3v(Vector u);
|
2009-09-24 15:52:48 +00:00
|
|
|
#define DEFAULT_TEXT_HEIGHT (11.5)
|
2008-05-22 10:28:28 +00:00
|
|
|
#define GLX_CALLBACK __stdcall
|
|
|
|
typedef void GLX_CALLBACK glxCallbackFptr(void);
|
|
|
|
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
2008-04-25 07:04:09 +00:00
|
|
|
void glxFillPolygon(SPolygon *p);
|
2008-06-02 03:31:37 +00:00
|
|
|
void glxFillMesh(int color, SMesh *m, DWORD h, DWORD s1, DWORD s2);
|
2008-05-19 09:23:49 +00:00
|
|
|
void glxDebugPolygon(SPolygon *p);
|
2009-05-24 11:37:07 +00:00
|
|
|
void glxDrawEdges(SEdgeList *l, bool endpointsToo);
|
2008-05-22 10:28:28 +00:00
|
|
|
void glxDebugMesh(SMesh *m);
|
2008-05-05 09:47:23 +00:00
|
|
|
void glxMarkPolygonNormal(SPolygon *p);
|
2009-07-03 20:55:57 +00:00
|
|
|
typedef void glxLineFn(void *data, Vector a, Vector b);
|
2009-09-24 15:52:48 +00:00
|
|
|
void glxWriteText(char *str, double h, Vector t, Vector u, Vector v,
|
2009-07-03 20:55:57 +00:00
|
|
|
glxLineFn *fn, void *fndata);
|
2009-09-24 15:52:48 +00:00
|
|
|
void glxWriteTextRefCenter(char *str, double h, Vector t, Vector u, Vector v,
|
2009-07-03 20:55:57 +00:00
|
|
|
glxLineFn *fn, void *fndata);
|
2009-09-24 15:52:48 +00:00
|
|
|
double glxStrWidth(char *str, double h);
|
|
|
|
double glxStrHeight(double h);
|
2009-09-17 07:32:36 +00:00
|
|
|
void glxLockColorTo(DWORD rgb);
|
2009-09-24 15:52:48 +00:00
|
|
|
void glxFatLine(Vector a, Vector b, double width);
|
2008-04-19 11:09:47 +00:00
|
|
|
void glxUnlockColor(void);
|
2009-09-17 07:32:36 +00:00
|
|
|
void glxColorRGB(DWORD rgb);
|
|
|
|
void glxColorRGBa(DWORD rgb, double a);
|
2008-06-17 19:12:25 +00:00
|
|
|
void glxDepthRangeOffset(int units);
|
|
|
|
void glxDepthRangeLockToFront(bool yes);
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#define arraylen(x) (sizeof((x))/sizeof((x)[0]))
|
2008-03-27 09:53:51 +00:00
|
|
|
#define PI (3.1415926535897931)
|
|
|
|
void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
|
|
|
|
double a21, double a22, double a23, double a24,
|
|
|
|
double a31, double a32, double a33, double a34,
|
|
|
|
double a41, double a42, double a43, double a44);
|
2008-06-25 05:14:49 +00:00
|
|
|
void MakePathRelative(char *base, char *path);
|
|
|
|
void MakePathAbsolute(char *base, char *path);
|
2009-09-18 08:14:15 +00:00
|
|
|
bool StringAllPrintable(char *str);
|
2009-10-12 11:34:43 +00:00
|
|
|
bool StringEndsIn(char *str, char *ending);
|
2010-01-16 09:22:44 +00:00
|
|
|
void Message(char *str, ...);
|
|
|
|
void Error(char *str, ...);
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
class System {
|
|
|
|
public:
|
2009-10-21 04:46:01 +00:00
|
|
|
static const int MAX_UNKNOWNS = 1024;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
EntityList entity;
|
|
|
|
ParamList param;
|
2008-04-20 11:35:10 +00:00
|
|
|
IdList<Equation,hEquation> eq;
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
// A list of parameters that are being dragged; these are the ones that
|
|
|
|
// we should put as close as possible to their initial positions.
|
2009-11-03 18:54:49 +00:00
|
|
|
List<hParam> dragged;
|
2009-04-20 07:30:09 +00:00
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
// In general, the tag indicates the subsys that a variable/equation
|
2008-05-07 07:10:20 +00:00
|
|
|
// has been assigned to; these are exceptions for variables:
|
2008-06-04 10:22:30 +00:00
|
|
|
static const int VAR_SUBSTITUTED = 10000;
|
2009-01-04 12:01:46 +00:00
|
|
|
static const int VAR_DOF_TEST = 10001;
|
2008-05-07 07:10:20 +00:00
|
|
|
// and for equations:
|
|
|
|
static const int EQ_SUBSTITUTED = 20000;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// The system Jacobian matrix
|
2008-04-20 11:35:10 +00:00
|
|
|
struct {
|
2008-04-21 01:26:36 +00:00
|
|
|
// The corresponding equation for each row
|
|
|
|
hEquation eq[MAX_UNKNOWNS];
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// The corresponding parameter for each column
|
|
|
|
hParam param[MAX_UNKNOWNS];
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// We're solving AX = B
|
2008-04-20 11:35:10 +00:00
|
|
|
int m, n;
|
2008-04-21 01:26:36 +00:00
|
|
|
struct {
|
|
|
|
Expr *sym[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
double num[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
} A;
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-05-13 02:35:31 +00:00
|
|
|
double scale[MAX_UNKNOWNS];
|
|
|
|
|
2008-05-12 07:29:50 +00:00
|
|
|
// Some helpers for the least squares solve
|
|
|
|
double AAt[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
double Z[MAX_UNKNOWNS];
|
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
double X[MAX_UNKNOWNS];
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
struct {
|
|
|
|
Expr *sym[MAX_UNKNOWNS];
|
|
|
|
double num[MAX_UNKNOWNS];
|
|
|
|
} B;
|
|
|
|
} mat;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-09-05 11:25:53 +00:00
|
|
|
static const double RANK_MAG_TOLERANCE, CONVERGE_TOLERANCE;
|
2008-07-02 08:18:25 +00:00
|
|
|
int CalculateRank(void);
|
2008-05-12 07:29:50 +00:00
|
|
|
static bool SolveLinearSystem(double X[], double A[][MAX_UNKNOWNS],
|
|
|
|
double B[], int N);
|
|
|
|
bool SolveLeastSquares(void);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2009-04-19 20:37:51 +00:00
|
|
|
bool WriteJacobian(int tag);
|
2008-04-20 11:35:10 +00:00
|
|
|
void EvalJacobian(void);
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
void WriteEquationsExceptFor(hConstraint hc, Group *g);
|
|
|
|
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad);
|
2008-05-07 07:10:20 +00:00
|
|
|
void SolveBySubstitution(void);
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
bool IsDragged(hParam p);
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
bool NewtonSolve(int tag);
|
2009-04-20 07:30:09 +00:00
|
|
|
|
|
|
|
static const int SOLVED_OKAY = 0;
|
|
|
|
static const int DIDNT_CONVERGE = 10;
|
|
|
|
static const int SINGULAR_JACOBIAN = 11;
|
|
|
|
static const int TOO_MANY_UNKNOWNS = 20;
|
2009-04-21 07:56:17 +00:00
|
|
|
int Solve(Group *g, int *dof, List<hConstraint> *bad,
|
|
|
|
bool andFindBad, bool andFindFree);
|
2008-04-20 11:35:10 +00:00
|
|
|
};
|
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
class TtfFont {
|
|
|
|
public:
|
|
|
|
typedef struct {
|
|
|
|
bool onCurve;
|
|
|
|
bool lastInContour;
|
|
|
|
SWORD x;
|
|
|
|
SWORD y;
|
|
|
|
} FontPoint;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FontPoint *pt;
|
|
|
|
int pts;
|
|
|
|
|
|
|
|
int xMax;
|
|
|
|
int xMin;
|
|
|
|
int leftSideBearing;
|
|
|
|
int advanceWidth;
|
|
|
|
} Glyph;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x, y;
|
|
|
|
} IntPoint;
|
|
|
|
|
|
|
|
char fontFile[MAX_PATH];
|
|
|
|
NameStr name;
|
|
|
|
bool loaded;
|
|
|
|
|
|
|
|
// The font itself, plus the mapping from ASCII codes to glyphs
|
|
|
|
int useGlyph[256];
|
|
|
|
Glyph *glyph;
|
|
|
|
int glyphs;
|
|
|
|
|
|
|
|
int maxPoints;
|
|
|
|
int scale;
|
|
|
|
|
|
|
|
// The filehandle, while loading
|
|
|
|
FILE *fh;
|
|
|
|
// Some state while rendering a character to curves
|
|
|
|
static const int NOTHING = 0;
|
|
|
|
static const int ON_CURVE = 1;
|
|
|
|
static const int OFF_CURVE = 2;
|
|
|
|
int lastWas;
|
|
|
|
IntPoint lastOnCurve;
|
|
|
|
IntPoint lastOffCurve;
|
|
|
|
|
|
|
|
// And the state that the caller must specify, determines where we
|
|
|
|
// render to and how
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *beziers;
|
|
|
|
Vector origin, u, v;
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
int Getc(void);
|
|
|
|
int GetBYTE(void);
|
|
|
|
int GetWORD(void);
|
|
|
|
int GetDWORD(void);
|
|
|
|
|
|
|
|
void LoadGlyph(int index);
|
|
|
|
bool LoadFontFromFile(bool nameOnly);
|
|
|
|
char *FontFileBaseName(void);
|
|
|
|
|
|
|
|
void Flush(void);
|
|
|
|
void Handle(int *dx, int x, int y, bool onCurve);
|
|
|
|
void PlotCharacter(int *dx, int c, double spacing);
|
|
|
|
void PlotString(char *str, double spacing,
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
Vector TransformIntPoint(int x, int y);
|
|
|
|
void LineSegment(int x0, int y0, int x1, int y1);
|
|
|
|
void Bezier(int x0, int y0, int x1, int y1, int x2, int y2);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TtfFontList {
|
|
|
|
public:
|
|
|
|
bool loaded;
|
2009-01-13 06:56:05 +00:00
|
|
|
List<TtfFont> l;
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
void LoadAll(void);
|
|
|
|
|
|
|
|
void PlotString(char *font, char *str, double spacing,
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
2008-06-30 09:09:17 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2009-06-11 05:57:23 +00:00
|
|
|
class StepFileWriter {
|
|
|
|
public:
|
|
|
|
void ExportSurfacesTo(char *filename);
|
|
|
|
void WriteHeader(void);
|
|
|
|
int ExportCurve(SBezier *sb);
|
|
|
|
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
2009-10-12 09:28:34 +00:00
|
|
|
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
2009-06-11 05:57:23 +00:00
|
|
|
void WriteWireframe(void);
|
|
|
|
void WriteFooter(void);
|
|
|
|
|
|
|
|
List<int> curves;
|
|
|
|
List<int> advancedFaces;
|
|
|
|
FILE *f;
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
class VectorFileWriter {
|
|
|
|
public:
|
|
|
|
FILE *f;
|
2009-01-27 05:48:40 +00:00
|
|
|
Vector ptMin, ptMax;
|
2009-07-03 20:55:57 +00:00
|
|
|
|
2009-04-15 06:50:06 +00:00
|
|
|
static double MmToPts(double mm);
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
static VectorFileWriter *ForFile(char *file);
|
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
void Output(SBezierLoopSetSet *sblss, SMesh *sm);
|
2009-01-27 05:48:40 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
void BezierAsPwl(SBezier *sb);
|
|
|
|
void BezierAsNonrationalCubic(SBezier *sb, int depth=0);
|
2009-09-22 05:46:30 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
virtual void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb) = 0;
|
|
|
|
virtual void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb) = 0;
|
|
|
|
virtual void Bezier(SBezier *sb) = 0;
|
2009-03-17 16:33:46 +00:00
|
|
|
virtual void Triangle(STriangle *tr) = 0;
|
2009-01-14 05:10:42 +00:00
|
|
|
virtual void StartFile(void) = 0;
|
|
|
|
virtual void FinishAndCloseFile(void) = 0;
|
2010-01-14 05:24:32 +00:00
|
|
|
virtual bool HasCanvasSize(void) = 0;
|
2009-01-14 05:10:42 +00:00
|
|
|
};
|
|
|
|
class DxfFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2009-10-30 10:38:34 +00:00
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class EpsFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
|
|
|
|
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-04-15 06:50:06 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-04-15 06:50:06 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-04-15 06:50:06 +00:00
|
|
|
};
|
|
|
|
class PdfFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
|
|
|
DWORD xref[10];
|
|
|
|
DWORD bodyStart;
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
2009-04-15 06:50:06 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class SvgFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
|
|
|
|
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class HpglFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
|
|
|
static double MmToHpglUnits(double mm);
|
2009-10-30 10:38:34 +00:00
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-14 05:10:42 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-01-14 05:10:42 +00:00
|
|
|
};
|
2009-06-11 05:57:23 +00:00
|
|
|
class Step2dFileWriter : public VectorFileWriter {
|
|
|
|
StepFileWriter sfw;
|
2009-10-30 10:38:34 +00:00
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
2009-06-11 05:57:23 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-06-11 05:57:23 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-06-08 06:50:16 +00:00
|
|
|
};
|
2010-01-14 04:47:17 +00:00
|
|
|
class GCodeFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
|
|
|
SEdgeList sel;
|
|
|
|
void StartPath( DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void FinishPath(DWORD strokeRgb, double lineWidth,
|
|
|
|
bool filled, DWORD fillRgb);
|
|
|
|
void Triangle(STriangle *tr);
|
|
|
|
void Bezier(SBezier *sb);
|
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2010-01-14 04:47:17 +00:00
|
|
|
};
|
2009-06-08 06:50:16 +00:00
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
#ifdef LIBRARY
|
|
|
|
# define ENTITY EntityBase
|
|
|
|
# define CONSTRAINT ConstraintBase
|
|
|
|
#else
|
|
|
|
# define ENTITY Entity
|
|
|
|
# define CONSTRAINT Constraint
|
|
|
|
#endif
|
2009-04-19 05:53:16 +00:00
|
|
|
class Sketch {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2009-04-19 05:53:16 +00:00
|
|
|
// These are user-editable, and define the sketch.
|
2008-04-14 10:28:32 +00:00
|
|
|
IdList<Group,hGroup> group;
|
2009-04-20 07:30:09 +00:00
|
|
|
IdList<CONSTRAINT,hConstraint> constraint;
|
2009-04-19 05:53:16 +00:00
|
|
|
IdList<Request,hRequest> request;
|
2009-09-17 07:32:36 +00:00
|
|
|
IdList<Style,hStyle> style;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
// These are generated from the above.
|
2009-04-20 07:30:09 +00:00
|
|
|
IdList<ENTITY,hEntity> entity;
|
2008-04-14 10:28:32 +00:00
|
|
|
IdList<Param,hParam> param;
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
inline CONSTRAINT *GetConstraint(hConstraint h)
|
2008-04-14 10:28:32 +00:00
|
|
|
{ return constraint.FindById(h); }
|
2009-04-20 07:30:09 +00:00
|
|
|
inline ENTITY *GetEntity (hEntity h) { return entity. FindById(h); }
|
2008-04-14 10:28:32 +00:00
|
|
|
inline Param *GetParam (hParam h) { return param. FindById(h); }
|
2009-04-19 05:53:16 +00:00
|
|
|
inline Request *GetRequest(hRequest h) { return request.FindById(h); }
|
2008-04-20 11:35:10 +00:00
|
|
|
inline Group *GetGroup (hGroup h) { return group. FindById(h); }
|
2009-09-17 07:32:36 +00:00
|
|
|
// Styles are handled a bit differently.
|
2009-04-19 05:53:16 +00:00
|
|
|
};
|
2009-09-17 07:32:36 +00:00
|
|
|
#undef ENTITY
|
|
|
|
#undef CONSTRAINT
|
2009-04-19 05:53:16 +00:00
|
|
|
|
|
|
|
class SolveSpace {
|
|
|
|
public:
|
|
|
|
TextWindow TW;
|
|
|
|
GraphicsWindow GW;
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// The state for undo/redo
|
|
|
|
typedef struct {
|
|
|
|
IdList<Group,hGroup> group;
|
|
|
|
IdList<Request,hRequest> request;
|
|
|
|
IdList<Constraint,hConstraint> constraint;
|
|
|
|
IdList<Param,hParam> param;
|
2009-09-17 07:32:36 +00:00
|
|
|
IdList<Style,hStyle> style;
|
2008-06-04 10:22:30 +00:00
|
|
|
hGroup activeGroup;
|
|
|
|
} UndoState;
|
|
|
|
static const int MAX_UNDO = 16;
|
|
|
|
typedef struct {
|
|
|
|
UndoState d[MAX_UNDO];
|
|
|
|
int cnt;
|
|
|
|
int write;
|
|
|
|
} UndoStack;
|
|
|
|
UndoStack undo;
|
|
|
|
UndoStack redo;
|
|
|
|
void UndoEnableMenus(void);
|
|
|
|
void UndoRemember(void);
|
|
|
|
void UndoUndo(void);
|
|
|
|
void UndoRedo(void);
|
|
|
|
void PushFromCurrentOnto(UndoStack *uk);
|
|
|
|
void PopOntoCurrentFrom(UndoStack *uk);
|
|
|
|
void UndoClearState(UndoState *ut);
|
|
|
|
void UndoClearStack(UndoStack *uk);
|
|
|
|
|
2008-06-11 04:22:52 +00:00
|
|
|
// Little bits of extra configuration state
|
|
|
|
static const int MODEL_COLORS = 8;
|
|
|
|
int modelColor[MODEL_COLORS];
|
2008-06-11 04:30:18 +00:00
|
|
|
Vector lightDir[2];
|
2008-06-11 04:22:52 +00:00
|
|
|
double lightIntensity[2];
|
2009-03-17 16:33:46 +00:00
|
|
|
double ambientIntensity;
|
2008-07-10 05:26:08 +00:00
|
|
|
double chordTol;
|
2008-02-12 13:00:26 +00:00
|
|
|
int maxSegments;
|
2008-06-17 19:12:25 +00:00
|
|
|
double cameraTangent;
|
2009-09-29 11:35:19 +00:00
|
|
|
float gridSpacing;
|
2008-07-08 07:41:29 +00:00
|
|
|
float exportScale;
|
2008-08-14 08:28:25 +00:00
|
|
|
float exportOffset;
|
2009-09-22 05:46:30 +00:00
|
|
|
int fixExportColors;
|
2008-08-11 10:56:08 +00:00
|
|
|
int drawBackFaces;
|
2009-10-01 10:35:11 +00:00
|
|
|
int checkClosedContour;
|
2009-01-02 10:38:36 +00:00
|
|
|
int showToolbar;
|
2009-09-18 08:14:15 +00:00
|
|
|
DWORD backgroundColor;
|
2009-03-18 04:26:04 +00:00
|
|
|
int exportShadedTriangles;
|
2009-04-14 04:19:23 +00:00
|
|
|
int exportPwlCurves;
|
2009-09-03 08:13:09 +00:00
|
|
|
int exportCanvasSizeAuto;
|
|
|
|
struct {
|
|
|
|
float left;
|
|
|
|
float right;
|
|
|
|
float bottom;
|
|
|
|
float top;
|
|
|
|
} exportMargin;
|
|
|
|
struct {
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
float dx;
|
|
|
|
float dy;
|
|
|
|
} exportCanvas;
|
2010-01-14 04:47:17 +00:00
|
|
|
struct {
|
|
|
|
float depth;
|
|
|
|
int passes;
|
|
|
|
float feed;
|
|
|
|
float plungeFeed;
|
|
|
|
} gCode;
|
2008-07-06 07:56:24 +00:00
|
|
|
|
2008-06-14 09:51:25 +00:00
|
|
|
typedef enum {
|
|
|
|
UNIT_MM = 0,
|
|
|
|
UNIT_INCHES,
|
|
|
|
} Unit;
|
|
|
|
Unit viewUnits;
|
|
|
|
char *MmToString(double v);
|
|
|
|
double ExprToMm(Expr *e);
|
2008-07-20 11:27:22 +00:00
|
|
|
double StringToMm(char *s);
|
2010-01-04 00:35:28 +00:00
|
|
|
char *UnitName(void);
|
|
|
|
double MmPerUnit(void);
|
2009-03-08 10:59:57 +00:00
|
|
|
double ChordTolMm(void);
|
2009-09-29 11:35:19 +00:00
|
|
|
bool forceParallelProj;
|
|
|
|
double CameraTangent(void);
|
2008-06-14 09:51:25 +00:00
|
|
|
|
|
|
|
// The platform-dependent code calls this before entering the msg loop
|
2008-06-11 04:22:52 +00:00
|
|
|
void Init(char *cmdLine);
|
2008-02-09 13:52:01 +00:00
|
|
|
void CheckLicenseFromRegistry(void);
|
2008-06-11 04:22:52 +00:00
|
|
|
void Exit(void);
|
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// File load/save routines, including the additional files that get
|
|
|
|
// loaded when we have import groups.
|
2008-04-18 11:11:48 +00:00
|
|
|
FILE *fh;
|
2008-05-28 10:10:31 +00:00
|
|
|
void AfterNewFile(void);
|
|
|
|
static void RemoveFromRecentList(char *file);
|
|
|
|
static void AddToRecentList(char *file);
|
2008-04-24 06:22:16 +00:00
|
|
|
char saveFile[MAX_PATH];
|
2009-12-15 12:26:22 +00:00
|
|
|
bool fileLoadError;
|
2008-04-24 06:22:16 +00:00
|
|
|
bool unsaved;
|
|
|
|
typedef struct {
|
|
|
|
char type;
|
|
|
|
char *desc;
|
|
|
|
char fmt;
|
|
|
|
void *ptr;
|
|
|
|
} SaveTable;
|
|
|
|
static const SaveTable SAVED[];
|
|
|
|
void SaveUsingTable(int type);
|
2008-04-27 10:01:23 +00:00
|
|
|
void LoadUsingTable(char *key, char *val);
|
2008-04-24 06:22:16 +00:00
|
|
|
struct {
|
|
|
|
Group g;
|
|
|
|
Request r;
|
|
|
|
Entity e;
|
|
|
|
Param p;
|
|
|
|
Constraint c;
|
2009-09-17 07:32:36 +00:00
|
|
|
Style s;
|
2008-04-24 06:22:16 +00:00
|
|
|
} sv;
|
2008-04-18 11:11:48 +00:00
|
|
|
static void MenuFile(int id);
|
2008-06-03 18:28:41 +00:00
|
|
|
bool GetFilenameAndSave(bool saveAs);
|
|
|
|
bool OkayToStartNewFile(void);
|
2008-06-02 11:43:27 +00:00
|
|
|
hGroup CreateDefaultDrawingGroup(void);
|
2008-07-08 08:02:22 +00:00
|
|
|
void UpdateWindowTitle(void);
|
2010-02-28 19:23:01 +00:00
|
|
|
void ClearExisting(void);
|
2008-04-24 06:22:16 +00:00
|
|
|
void NewFile(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
bool SaveToFile(char *filename);
|
|
|
|
bool LoadFromFile(char *filename);
|
2009-05-19 07:26:38 +00:00
|
|
|
bool LoadEntitiesFromFile(char *filename, EntityList *le,
|
|
|
|
SMesh *m, SShell *sh);
|
2008-05-29 10:10:12 +00:00
|
|
|
void ReloadAllImported(void);
|
2008-07-06 09:24:31 +00:00
|
|
|
// And the various export options
|
2008-06-18 08:35:14 +00:00
|
|
|
void ExportAsPngTo(char *file);
|
2008-07-06 09:24:31 +00:00
|
|
|
void ExportMeshTo(char *file);
|
2009-10-12 11:34:43 +00:00
|
|
|
void ExportMeshAsStlTo(FILE *f, SMesh *sm);
|
|
|
|
void ExportMeshAsObjTo(FILE *f, SMesh *sm);
|
2009-10-12 10:40:48 +00:00
|
|
|
void ExportViewOrWireframeTo(char *file, bool wireframe);
|
2009-01-14 05:10:42 +00:00
|
|
|
void ExportSectionTo(char *file);
|
2009-10-12 10:40:48 +00:00
|
|
|
void ExportWireframeCurves(SEdgeList *sel, SBezierList *sbl,
|
|
|
|
VectorFileWriter *out);
|
2009-04-14 04:19:23 +00:00
|
|
|
void ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *sm,
|
2009-03-17 16:33:46 +00:00
|
|
|
Vector u, Vector v, Vector n, Vector origin,
|
|
|
|
double cameraTan,
|
|
|
|
VectorFileWriter *out);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-07-20 11:27:22 +00:00
|
|
|
static void MenuAnalyze(int id);
|
2009-11-08 01:11:38 +00:00
|
|
|
|
|
|
|
// Additional display stuff
|
2008-07-20 11:27:22 +00:00
|
|
|
struct {
|
|
|
|
SContour path;
|
|
|
|
hEntity point;
|
|
|
|
} traced;
|
2009-01-25 09:19:59 +00:00
|
|
|
SEdgeList nakedEdges;
|
2010-01-04 00:35:28 +00:00
|
|
|
struct {
|
|
|
|
bool draw;
|
|
|
|
Vector ptA;
|
|
|
|
Vector ptB;
|
|
|
|
} extraLine;
|
2009-11-08 01:11:38 +00:00
|
|
|
struct {
|
|
|
|
BYTE *fromFile;
|
|
|
|
int w, h;
|
|
|
|
int rw, rh;
|
|
|
|
double scale; // pixels per mm
|
|
|
|
Vector origin;
|
|
|
|
} bgImage;
|
2010-01-14 05:24:32 +00:00
|
|
|
struct {
|
|
|
|
bool draw;
|
|
|
|
Vector pt, u, v;
|
|
|
|
} justExportedInfo;
|
2008-07-20 11:27:22 +00:00
|
|
|
|
2009-12-04 08:08:41 +00:00
|
|
|
class Clipboard {
|
|
|
|
public:
|
|
|
|
List<ClipboardRequest> r;
|
|
|
|
List<Constraint> c;
|
|
|
|
|
|
|
|
void Clear(void);
|
|
|
|
bool ContainsEntity(hEntity old);
|
|
|
|
hEntity NewEntityFor(hEntity old);
|
|
|
|
};
|
|
|
|
Clipboard clipboard;
|
|
|
|
|
2008-06-02 09:31:26 +00:00
|
|
|
void MarkGroupDirty(hGroup hg);
|
2008-06-02 11:43:27 +00:00
|
|
|
void MarkGroupDirtyByEntity(hEntity he);
|
2008-06-02 09:31:26 +00:00
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// Consistency checking on the sketch: stuff with missing dependencies
|
|
|
|
// will get deleted automatically.
|
2008-05-17 06:04:55 +00:00
|
|
|
struct {
|
|
|
|
int requests;
|
|
|
|
int groups;
|
|
|
|
int constraints;
|
2009-01-03 12:27:33 +00:00
|
|
|
int nonTrivialConstraints;
|
2008-05-17 06:04:55 +00:00
|
|
|
} deleted;
|
|
|
|
bool GroupExists(hGroup hg);
|
|
|
|
bool PruneOrphans(void);
|
|
|
|
bool EntityExists(hEntity he);
|
|
|
|
bool GroupsInOrder(hGroup before, hGroup after);
|
|
|
|
bool PruneGroups(hGroup hg);
|
|
|
|
bool PruneRequests(hGroup hg);
|
|
|
|
bool PruneConstraints(hGroup hg);
|
2008-04-27 09:03:01 +00:00
|
|
|
|
2008-06-02 09:31:26 +00:00
|
|
|
void GenerateAll(void);
|
2009-01-04 12:01:46 +00:00
|
|
|
void GenerateAll(int first, int last, bool andFindFree=false);
|
|
|
|
void SolveGroup(hGroup hg, bool andFindFree);
|
2009-04-20 07:30:09 +00:00
|
|
|
void MarkDraggedParams(void);
|
2008-04-27 09:03:01 +00:00
|
|
|
void ForceReferences(void);
|
|
|
|
|
2008-07-20 11:27:22 +00:00
|
|
|
bool AllGroupsOkay(void);
|
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
// The system to be solved.
|
|
|
|
System sys;
|
2008-06-03 18:28:41 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
// All the TrueType fonts in memory
|
|
|
|
TtfFontList fonts;
|
|
|
|
|
2008-06-25 05:14:49 +00:00
|
|
|
// Everything has been pruned, so we know there's no dangling references
|
|
|
|
// to entities that don't exist. Before that, we mustn't try to display
|
|
|
|
// the sketch!
|
|
|
|
bool allConsistent;
|
|
|
|
|
2008-06-03 18:28:41 +00:00
|
|
|
struct {
|
|
|
|
bool showTW;
|
|
|
|
bool generateAll;
|
|
|
|
} later;
|
|
|
|
void DoLater(void);
|
2008-02-09 13:52:01 +00:00
|
|
|
|
|
|
|
// For the licensing
|
|
|
|
class Crc {
|
|
|
|
public:
|
|
|
|
static const DWORD POLY = 0xedb88320;
|
|
|
|
DWORD shiftReg;
|
|
|
|
|
|
|
|
void ProcessBit(int bit);
|
|
|
|
void ProcessByte(BYTE b);
|
|
|
|
void ProcessString(char *s);
|
|
|
|
};
|
|
|
|
Crc crc;
|
|
|
|
struct {
|
2009-06-10 06:57:27 +00:00
|
|
|
bool licensed;
|
|
|
|
char line1[512];
|
|
|
|
char line2[512];
|
|
|
|
char users[512];
|
|
|
|
DWORD key;
|
|
|
|
SQWORD firstUse;
|
|
|
|
int trialDaysRemaining;
|
2008-02-09 13:52:01 +00:00
|
|
|
} license;
|
|
|
|
static void MenuHelp(int id);
|
|
|
|
void CleanEol(char *s);
|
|
|
|
void LoadLicenseFile(char *filename);
|
|
|
|
bool LicenseValid(char *line1, char *line2, char *users, DWORD key);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
extern SolveSpace SS;
|
2009-04-19 05:53:16 +00:00
|
|
|
extern Sketch SK;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#endif
|