Fix failure to solve when auto-constraining new arc, and make all

paths absolute immediately.

[git-p4: depot-paths = "//depot/solvespace/": change = 1795]
solver
Jonathan Westhues 2008-06-16 00:35:05 -08:00
parent 3b4aa2c2b2
commit b5c87291ea
3 changed files with 25 additions and 7 deletions

View File

@ -405,14 +405,17 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
SS.GetParam(hr.param(0))->val = 0; SS.GetParam(hr.param(0))->val = 0;
break; break;
case MNU_ARC: case MNU_ARC: {
if(!SS.GW.LockedInWorkplane()) { if(!SS.GW.LockedInWorkplane()) {
Error("Can't draw arc in 3d; select a workplane first."); Error("Can't draw arc in 3d; select a workplane first.");
ClearPending(); ClearPending();
break; break;
} }
hr = AddRequest(Request::ARC_OF_CIRCLE); hr = AddRequest(Request::ARC_OF_CIRCLE);
SS.GetEntity(hr.entity(1))->PointForceTo(v); // This fudge factor stops us from immediately failing to solve
// because of the arc's implicit (equal radius) tangent.
Vector adj = SS.GW.projRight.WithMagnitude(2/SS.GW.scale);
SS.GetEntity(hr.entity(1))->PointForceTo(v.Minus(adj));
SS.GetEntity(hr.entity(2))->PointForceTo(v); SS.GetEntity(hr.entity(2))->PointForceTo(v);
SS.GetEntity(hr.entity(3))->PointForceTo(v); SS.GetEntity(hr.entity(3))->PointForceTo(v);
ConstrainPointByHovered(hr.entity(2)); ConstrainPointByHovered(hr.entity(2));
@ -423,7 +426,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
pending.point = hr.entity(3); pending.point = hr.entity(3);
pending.description = "click to place point"; pending.description = "click to place point";
break; break;
}
case MNU_CUBIC: case MNU_CUBIC:
hr = AddRequest(Request::CUBIC); hr = AddRequest(Request::CUBIC);
SS.GetEntity(hr.entity(1))->PointForceTo(v); SS.GetEntity(hr.entity(1))->PointForceTo(v);

View File

@ -221,9 +221,9 @@ public:
class SKdTree { class SKdTree {
public: public:
static const int BY_X = 1; static const int BY_X = 0;
static const int BY_Y = 2; static const int BY_Y = 1;
static const int BY_Z = 3; static const int BY_Z = 2;
int which; int which;
double c; double c;

View File

@ -923,8 +923,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
// Create the heap that we use to store Exprs and other temp stuff. // Create the heap that we use to store Exprs and other temp stuff.
FreeAllTemporary(); FreeAllTemporary();
// A filename may have been specified on the command line; if so, then
// strip any quotation marks, and make it absolute.
char file[MAX_PATH] = "";
if(strlen(lpCmdLine)+1 < MAX_PATH) {
char *s = lpCmdLine;
while(*s == ' ' || *s == '"') s++;
strcpy(file, s);
s = strrchr(file, '"');
if(s) *s = '\0';
}
char absoluteFile[MAX_PATH] = "";
if(*file != '\0') {
GetFullPathName(file, sizeof(absoluteFile), absoluteFile, NULL);
}
// Call in to the platform-independent code, and let them do their init // Call in to the platform-independent code, and let them do their init
SS.Init(lpCmdLine); SS.Init(absoluteFile);
ShowWindow(TextWnd, SW_SHOWNOACTIVATE); ShowWindow(TextWnd, SW_SHOWNOACTIVATE);
ShowWindow(GraphicsWnd, SW_SHOW); ShowWindow(GraphicsWnd, SW_SHOW);