Add locked-where-dragged constraint to library interface, and

update some copyright dates and bad grammar in comments.

[git-p4: depot-paths = "//depot/solvespace/": change = 2137]
solver
Jonathan Westhues 2010-05-06 18:13:57 -08:00
parent f27b567f5c
commit 7a2941d2ea
5 changed files with 43 additions and 30 deletions

View File

@ -422,6 +422,14 @@ SLVS_C_EQUAL_RADIUS
The circles or arcs entityA and entityB have equal radius. The circles or arcs entityA and entityB have equal radius.
SLVS_C_WHERE_DRAGGED*
The point ptA is locked at its initial numerical guess, and cannot
be moved. This constrains two degrees of freedom in a workplane,
and three in free space. It's therefore possible for this constraint
to overconstrain the sketch, for example if it's applied to a point
with one remaining degree of freedom.
USING THE SOLVER USING THE SOLVER
================ ================
@ -429,5 +437,5 @@ USING THE SOLVER
See the enclosed sample code, example.c. See the enclosed sample code, example.c.
Copyright 2009 Useful Subset, LLC Copyright 2009-2010 Useful Subset, LLC

View File

@ -8,7 +8,7 @@
// //
// http://solvespace.com/ // http://solvespace.com/
// //
// Copyright 2009 Useful Subset, LLC // Copyright 2009-2010 Useful Subset, LLC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
@ -28,7 +28,8 @@ void *CheckMalloc(size_t n)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// An example of a constraint in 3d. We create // An example of a constraint in 3d. We create a single group, with some
// entities and constraints.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Example3d(void) void Example3d(void)
{ {

View File

@ -65,12 +65,12 @@ void Slvs_Solve(Slvs_System *ssys, Slvs_hGroup shg)
#if 1 #if 1
dbp("SolveSpace library initialized (evaluation version only)."); dbp("SolveSpace library initialized (evaluation version only).");
dbp("Built " __DATE__ " " __TIME__ dbp("Built " __DATE__ " " __TIME__
". Copyright 2009 Useful Subset, LLC."); ". Copyright 2009-2010 Useful Subset, LLC.");
HWND h = GetForegroundWindow(); HWND h = GetForegroundWindow();
MessageBox(h, MessageBox(h,
"This is an evaluation copy of SolveSpace. To purchase a license, please " "This is an evaluation copy of SolveSpace. To purchase a license, please "
"contact info@solvespace.com.\r\n\r\n" "contact info@solvespace.com.\r\n\r\n"
"Copyright 2009 Useful Subset, LLC.", "Copyright 2009-2010 Useful Subset, LLC.",
"SolveSpace", MB_OK); "SolveSpace", MB_OK);
#endif #endif
InitHeaps(); InitHeaps();
@ -97,18 +97,18 @@ void Slvs_Solve(Slvs_System *ssys, Slvs_hGroup shg)
ZERO(&e); ZERO(&e);
switch(se->type) { switch(se->type) {
case SLVS_E_POINT_IN_3D: e.type = Entity::POINT_IN_3D; break; case SLVS_E_POINT_IN_3D: e.type = Entity::POINT_IN_3D; break;
case SLVS_E_POINT_IN_2D: e.type = Entity::POINT_IN_2D; break; case SLVS_E_POINT_IN_2D: e.type = Entity::POINT_IN_2D; break;
case SLVS_E_NORMAL_IN_3D: e.type = Entity::NORMAL_IN_3D; break; case SLVS_E_NORMAL_IN_3D: e.type = Entity::NORMAL_IN_3D; break;
case SLVS_E_NORMAL_IN_2D: e.type = Entity::NORMAL_IN_2D; break; case SLVS_E_NORMAL_IN_2D: e.type = Entity::NORMAL_IN_2D; break;
case SLVS_E_DISTANCE: e.type = Entity::DISTANCE; break; case SLVS_E_DISTANCE: e.type = Entity::DISTANCE; break;
case SLVS_E_WORKPLANE: e.type = Entity::WORKPLANE; break; case SLVS_E_WORKPLANE: e.type = Entity::WORKPLANE; break;
case SLVS_E_LINE_SEGMENT: e.type = Entity::LINE_SEGMENT; break; case SLVS_E_LINE_SEGMENT: e.type = Entity::LINE_SEGMENT; break;
case SLVS_E_CUBIC: e.type = Entity::CUBIC; break; case SLVS_E_CUBIC: e.type = Entity::CUBIC; break;
case SLVS_E_CIRCLE: e.type = Entity::CIRCLE; break; case SLVS_E_CIRCLE: e.type = Entity::CIRCLE; break;
case SLVS_E_ARC_OF_CIRCLE: e.type = Entity::ARC_OF_CIRCLE; break; case SLVS_E_ARC_OF_CIRCLE: e.type = Entity::ARC_OF_CIRCLE; break;
default: dbp("bad entity type %d", se->type); return; default: dbp("bad entity type %d", se->type); return;
} }
e.h.v = se->h; e.h.v = se->h;
e.group.v = se->group; e.group.v = se->group;
@ -165,6 +165,7 @@ case SLVS_C_ARC_LINE_TANGENT: t = Constraint::ARC_LINE_TANGENT; break;
case SLVS_C_CUBIC_LINE_TANGENT: t = Constraint::CUBIC_LINE_TANGENT; break; case SLVS_C_CUBIC_LINE_TANGENT: t = Constraint::CUBIC_LINE_TANGENT; break;
case SLVS_C_EQUAL_RADIUS: t = Constraint::EQUAL_RADIUS; break; case SLVS_C_EQUAL_RADIUS: t = Constraint::EQUAL_RADIUS; break;
case SLVS_C_PROJ_PT_DISTANCE: t = Constraint::PROJ_PT_DISTANCE; break; case SLVS_C_PROJ_PT_DISTANCE: t = Constraint::PROJ_PT_DISTANCE; break;
case SLVS_C_WHERE_DRAGGED: t = Constraint::WHERE_DRAGGED; break;
default: dbp("bad constraint type %d", sc->type); return; default: dbp("bad constraint type %d", sc->type); return;
} }

View File

@ -9,7 +9,7 @@
// //
// http://solvespace.com/ // http://solvespace.com/
// //
// Copyright 2009 Useful Subset, LLC // Copyright 2009-2010 Useful Subset, LLC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __SLVS_H #ifndef __SLVS_H
@ -36,23 +36,23 @@ typedef struct {
} Slvs_Param; } Slvs_Param;
#define SLVS_E_POINT_IN_3D 50000 #define SLVS_E_POINT_IN_3D 50000
#define SLVS_E_POINT_IN_2D 50001 #define SLVS_E_POINT_IN_2D 50001
#define SLVS_E_NORMAL_IN_3D 60000 #define SLVS_E_NORMAL_IN_3D 60000
#define SLVS_E_NORMAL_IN_2D 60001 #define SLVS_E_NORMAL_IN_2D 60001
#define SLVS_E_DISTANCE 70000 #define SLVS_E_DISTANCE 70000
// The special point, normal, and distance types used for parametric step // The special point, normal, and distance types used for parametric step
// and repeat, extrude, and assembly are currently not exposed. Please // and repeat, extrude, and assembly are currently not exposed. Please
// contact us if you are interested in using these. // contact us if you are interested in using these.
#define SLVS_E_WORKPLANE 80000 #define SLVS_E_WORKPLANE 80000
#define SLVS_E_LINE_SEGMENT 80001 #define SLVS_E_LINE_SEGMENT 80001
#define SLVS_E_CUBIC 80002 #define SLVS_E_CUBIC 80002
#define SLVS_E_CIRCLE 80003 #define SLVS_E_CIRCLE 80003
#define SLVS_E_ARC_OF_CIRCLE 80004 #define SLVS_E_ARC_OF_CIRCLE 80004
typedef struct { typedef struct {
Slvs_hEntity h; Slvs_hEntity h;
@ -99,6 +99,7 @@ typedef struct {
#define SLVS_C_CUBIC_LINE_TANGENT 100028 #define SLVS_C_CUBIC_LINE_TANGENT 100028
#define SLVS_C_EQUAL_RADIUS 100029 #define SLVS_C_EQUAL_RADIUS 100029
#define SLVS_C_PROJ_PT_DISTANCE 100030 #define SLVS_C_PROJ_PT_DISTANCE 100030
#define SLVS_C_WHERE_DRAGGED 100031
typedef struct { typedef struct {
Slvs_hConstraint h; Slvs_hConstraint h;
@ -141,7 +142,7 @@ typedef struct {
// If a parameter corresponds to a point (distance, normal, etc.) being // If a parameter corresponds to a point (distance, normal, etc.) being
// dragged, then specify it here. This will cause the solver to favor // dragged, then specify it here. This will cause the solver to favor
// that parameter, and attempt to change it as little as possible even // that parameter, and attempt to change it as little as possible even
// if that require it to change other parameters more. // if that requires it to change other parameters more.
// //
// Unused members of this array should be set to zero. // Unused members of this array should be set to zero.
Slvs_hParam dragged[4]; Slvs_hParam dragged[4];
@ -149,7 +150,7 @@ typedef struct {
// If the solver fails, then it can determine which constraints are // If the solver fails, then it can determine which constraints are
// causing the problem. But this is a relatively slow process (for // causing the problem. But this is a relatively slow process (for
// a system with n constraints, about n times as long as just solving). // a system with n constraints, about n times as long as just solving).
// If calculateFaileds is set, then the solver will do so, otherwise // If calculateFaileds is true, then the solver will do so, otherwise
// not. // not.
int calculateFaileds; int calculateFaileds;

View File

@ -1,6 +1,8 @@
add checked/unchecked checkbox and radio button add checked/unchecked checkbox and radio button
fix bug with rotation in plane where green line stays displayed fix bug with rotation in plane where green line stays displayed
expose transformed point stuff in library expose transformed point stuff in library
group option to make dimensions always reference?
more tangencies
----- -----
rounding, as a special group rounding, as a special group