Commit Graph

52 Commits (44795175ee656297a7e8613515c33225c3aaa5fb)

Author SHA1 Message Date
Jonathan Westhues fd4abd5519 Add a perpendicular constraint; identical to constraining a ninety
degree angle, but shows with a right angle symbol instead of a
numerical angle you can edit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1819]
2008-07-02 01:21:29 -08:00
Jonathan Westhues 48c5018613 Add symmetric about line constraint. This applies only when locked
in a workplane, since it would otherwise be ambiguous.

[git-p4: depot-paths = "//depot/solvespace/": change = 1817]
2008-07-01 22:59:49 -08:00
Jonathan Westhues b77cb053e2 Move `Solve Once Now' to the Edit menu, and call it `Regenerate';
and fix some other problems with the menu labels.

[git-p4: depot-paths = "//depot/solvespace/": change = 1815]
2008-06-30 01:34:03 -08:00
Jonathan Westhues fe75efc6aa Make the point-on-circle constraints work on the infinite cylinder,
not the sphere; that's more logical behaviour out of plane.

[git-p4: depot-paths = "//depot/solvespace/": change = 1803]
2008-06-21 23:32:50 -08:00
Jonathan Westhues 89bb81b35c Force the numerical guess for a normal to be exactly correct when a
same orientation constraint is applied; this makes convergence
easy. And don't hover faces or constraints while dragging
something.

[git-p4: depot-paths = "//depot/solvespace/": change = 1798]
2008-06-18 01:18:51 -08:00
Jonathan Westhues 4c6d350cee Add two more exotic constraints: equal point-line distances, and
point-line distance equal to line segment length. These are
available in both normal and projected versions, with fancy display
for all of these.

[git-p4: depot-paths = "//depot/solvespace/": change = 1793]
2008-06-14 03:16:14 -08:00
Jonathan Westhues 28e3f0abab Don't keep a dimension or group's user-entered numerical value as
an Expr *, since that complicates multiple units and also memory
management. Now it's just a double.

[git-p4: depot-paths = "//depot/solvespace/": change = 1791]
2008-06-14 00:43:38 -08:00
Jonathan Westhues 9bba9425be Add a special constraint type for comments; no equations, just
user-visible text. And make points hoverable/selectable even when
GW.showPoints is false, and zoom to fit before regenerating on file
open, because then we're at the right zoom level (and will use the
right pwl tolerance).

[git-p4: depot-paths = "//depot/solvespace/": change = 1788]
2008-06-12 00:58:58 -08:00
Jonathan Westhues d471872830 Add reference dimensions, add user-programmable lighting, and add a
configuration screen where all this can be specified.

[git-p4: depot-paths = "//depot/solvespace/": change = 1783]
2008-06-10 20:22:52 -08:00
Jonathan Westhues 8498a99588 Add preliminary lathe (solid of revolution) support. I'm generating
just the mesh, no derived entities (but I suppose that I could turn
all points into circles).

And fix some bugs where equations didn't get unique IDs, and make
it possible to lock on to the group's workplane automatically, if
you press W while free in 3d with no workplane selected.

[git-p4: depot-paths = "//depot/solvespace/": change = 1780]
2008-06-06 03:35:28 -08:00
Jonathan Westhues ccbda13a03 Add point-face distance constraints.
[git-p4: depot-paths = "//depot/solvespace/": change = 1778]
2008-06-06 00:46:55 -08:00
Jonathan Westhues 48612bde3d Add undo/redo. This saves the param guesses, constraints, groups,
and requests to a separate list. It's messy, because I have to make
a deep copy (e.g. of the remap list for the groups, or Expr *
stuff) of some things. Others (e.g. the polygon or mesh) will be
regenerated, so they should be discarded, but they must not get
double-freed.

In any case, works superficially. And fix a few memory leaks
unrelated to this, and remove some dead code.

[git-p4: depot-paths = "//depot/solvespace/": change = 1775]
2008-06-04 02:22:30 -08:00
Jonathan Westhues 71391e6a55 Add an interference check for assembled parts. That's easy once the
BSP stuff works. The failures are reported with red stripes and no
depth buffering, and in a message in the text window.

Also improve convergence of point-on-line constraints, and don't
write triangles to export files with limited precision, because
that was making the coplanar tests fail.

[git-p4: depot-paths = "//depot/solvespace/": change = 1774]
2008-06-03 22:39:32 -08:00
Jonathan Westhues ea6db67c7d Improve convergence of constraints involving parallel vectors, by
using the initial numerical guess of whichever vector is already
known to choose our projection planes.

And add a mechanism to defer showing the text window or
regenerating, in order to simplify dependencies on valid actives.
Also yes/no/cancel when about to abandon an unsaved file, and a
bugfix when rotating a rot/trans point.

[git-p4: depot-paths = "//depot/solvespace/": change = 1772]
2008-06-03 10:28:41 -08:00
Jonathan Westhues 7d4a4fbb76 We now have selective solve; a group (and all the groups afterward)
becomes dirty when the user makes a change, and only the dirty
groups get solved. That's a huge effective speedup.

Also add delete function for groups. That has an interesting issue;
it actually ends up recursing on GenerateAll(), since GenerateAll()
calls ClearSuper(), ClearSuper() might need to recreate a group (if
all the groups were deleted), and that would activate the group,
which calls GenerateAll. The right solution is probably a deferred
execution mechanism, where you can schedule something to happen
before we go idle, but not do it right now.

[git-p4: depot-paths = "//depot/solvespace/": change = 1771]
2008-06-02 03:43:27 -08:00
Jonathan Westhues 236ee16da6 Consolidate the code that determines whether an entity is visible
in one place. And remove the ability to disable the solver, since
that's unlikely to be anything but confusing (and in any case, was
badly implemented). This is in preparation for selective solving,
of only the dirty groups.

[git-p4: depot-paths = "//depot/solvespace/": change = 1769]
2008-06-02 01:31:26 -08:00
Jonathan Westhues 6748160026 Add selectable faces, by associating an hEntity with the triangle's
metadata. And add point-on-face constraints to go with that. Still
needs some cleanup for the user interface.

[git-p4: depot-paths = "//depot/solvespace/": change = 1766]
2008-06-01 19:31:37 -08:00
Jonathan Westhues 04af0944bc Standardize naming of FromXxx (and XxxFrom) static methods to
create a `new' stack-allocated instance of an object; just From,
possibly different versions with different arg types.

[git-p4: depot-paths = "//depot/solvespace/": change = 1763]
2008-06-01 00:45:11 -08:00
Jonathan Westhues 2cb4800fbf Start to describe the selected entities in the text window. Also
more starting work on the selectable faces, and fiddling in an
attempt to remove dependencies when stuff gets deleted.

[git-p4: depot-paths = "//depot/solvespace/": change = 1760]
2008-05-31 16:26:41 -08:00
Jonathan Westhues ecee90965e Change the workplanes a bit. Now the active workplane is per group,
so e.g. a new extrude starts in free space, which is likely what
you want. And default to an in-workplane group, and tweak the
display of workplanes.

[git-p4: depot-paths = "//depot/solvespace/": change = 1748]
2008-05-26 18:22:20 -08:00
Jonathan Westhues b484c26493 Many user interface additions. Now I report when the solver fails,
and in the case of a singular Jacobian, report which constraints
can be removed to fix it. Also a mechanism to hover and select
entities and constraints from the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1746]
2008-05-26 01:56:50 -08:00
Jonathan Westhues 248f74547e Add user interface to specify union/difference for extrudes, and
implement that. Also make solver work only between the first and
last visible group; earlier can just work from previous solve
result, and later don't matter.

There's some issues with the csg code; it will eventually produce
an open mesh, which is very bad. Not sure whether that's a logic
bug, or a numerical issue; still generating absurd triangles pretty
routinely.

[git-p4: depot-paths = "//depot/solvespace/": change = 1741]
2008-05-25 05:11:44 -08:00
Jonathan Westhues 30ad41f4a2 Fix a crash; it was possible to attempt to draw in a workplane
that's in a group that solves after the current group. This means
that the constraint/request gets deleted instantly, and stuff like
auto-constraints on the just-created entities blow up. I now check
that the active workplane comes from the active group or one solved
before it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1729]
2008-05-17 15:48:58 -08:00
Jonathan Westhues b480613763 Add angle constraints. I'm doing these differently from SketchFlat,
as a constraint on the direction cosine, rather than driving the
dot product against a rotated vector to zero. The drawing is the
ugly part; to do that for skew lines, I gave up.

Also add a function to clear non-existent items on the selection
after solving, since that could have caused an oops().

[git-p4: depot-paths = "//depot/solvespace/": change = 1727]
2008-05-17 03:15:14 -08:00
Jonathan Westhues 749e2a0149 Add double-sided extrudes, and user interface for that. Also put
the coordinate system (x, y, z normal vectors) in the bottom left
corner of the screen at all times, and hide group-created
workplanes except when that group is active, and activate that
workplane when the group is activated.

[git-p4: depot-paths = "//depot/solvespace/": change = 1726]
2008-05-17 00:02:39 -08:00
Jonathan Westhues 2ec23ffa3e Fix point-on-circle constraints to work with arcs too, and lock
extrudes normal to workplane if a workplane is active when the
extrusion is created.

[git-p4: depot-paths = "//depot/solvespace/": change = 1724]
2008-05-15 22:34:06 -08:00
Jonathan Westhues aa5c621d82 Add symmetry constraints without an explicit symmetry plane; these
use the horizontal or vertical axes of the active workplane. The
equations that we write from these are very fast (of the form u + v
= 0, or u - v = 0).

[git-p4: depot-paths = "//depot/solvespace/": change = 1720]
2008-05-13 02:38:21 -08:00
Jonathan Westhues 364938f332 Add an arc entity. That's not allowed to exist in free space (since
we need something to force the points into plane, and the workplane
supplies that), but otherwise straightforward. And add diameter and
equal radius constraints for the arc.

[git-p4: depot-paths = "//depot/solvespace/": change = 1718]
2008-05-12 02:01:44 -08:00
Jonathan Westhues e2263c69c8 Find a memory corruption! I was getting a pointer into the entity
list, and then adding a new entity to that list, and then looking
at that pointer again. Not okay; the add operation might have
forced a realloc. I have to watch for that.

And add a "distance ratio" constraint, plus a new kind of group
that comes with its own workplane. The workplane is not solved for;
it's generated explicitly in terms of elements that are already
solved.

[git-p4: depot-paths = "//depot/solvespace/": change = 1716]
2008-05-11 02:40:37 -08:00
Jonathan Westhues 4eed7693be Little changes, more pwls in a circle, and make "same orientation"
constraints work mod 180 degrees, so that it snaps to however the
workplane was drawn (more vertical vs. more horizontal).

[git-p4: depot-paths = "//depot/solvespace/": change = 1714]
2008-05-10 18:57:47 -08:00
Jonathan Westhues 10240cc1df Add parallel and same orientation constraints, that work on line
segments and normals.

[git-p4: depot-paths = "//depot/solvespace/": change = 1713]
2008-05-08 21:33:23 -08:00
Jonathan Westhues e11da119f0 Add point-line distance, point-plane distance, and point-on-circle
constraints. And generate the constraint equations for entities
(e.g., that our unit quaternions have magnitude one). Numerical
troubles there, but it sort of works. Also some stuff to draw
projection lines with projected constraints, and to auto-insert
more constraints as you draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1711]
2008-05-07 23:30:30 -08:00
Jonathan Westhues 328a946cc4 Add a diameter constraint, and add a `distance' entity that I can
remap when I copy circle entities, in order to make the radius
numerical somehow (analogy with the POINT_ and NORMAL_XFRMD) thing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1710]
2008-05-07 00:19:37 -08:00
Jonathan Westhues 6b264a6ba6 Add a convenience command to draw a rectangle (as four line
segments), add the toggle construction command, and color the lines
differently depending on what group you're in.

Also change dynamic memory stuff to use a Win32 heap for everything
(no malloc), and validate that often. I think I've seen it crash,
though I can't reproduce it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1708]
2008-05-06 20:17:29 -08:00
Jonathan Westhues c767d55c71 Now we can add new workplanes. So fix all the mistakes that I
hadn't previously noticed, because I didn't use to have workplanes
with non-zero offsets. And clean up the interface to normals a bit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1707]
2008-05-05 03:17:00 -08:00
Jonathan Westhues 853c6cb59c A big change, to add a concept of normals. These are "oriented
vectors", represented by unit quaternions. This permits me to add
circles, where the normal defines the plane of the circle.

Still many things painful. The interface for editing normals is not
so intuitive, and it's not yet clear how I would e.g. export a
circle entity and recreate it properly, since that entity has a
param not associated with a normal or point.

And the transformed points/normals do not yet support rotations.
That will be necessary soon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1705]
2008-05-04 22:18:01 -08:00
Jonathan Westhues 658b7df50f Make at-midpoint constraint also work to constrain midpoint of a
line segment on a plane. And simplify that code a bit, and improve
display.

[git-p4: depot-paths = "//depot/solvespace/": change = 1702]
2008-04-30 22:53:50 -08:00
Jonathan Westhues 498ffd07ea Add symmetric and at midpoint constraints. The symmetry constraint
turned out straightforward, in great part because the planes are
workplanes (6 DOF, represented by a unit quaternion and a point),
and therefore make it easy to get a vector in the plane, as well as
a normal.

And on that subject, replace the previous hack for parallel vector
constraints with a better hack: pivot on the initial numerical
guess, to choose which components of the cross product to drive to
zero. Ugly, but I think that will be as robust as I can get.

[git-p4: depot-paths = "//depot/solvespace/": change = 1699]
2008-04-30 00:14:32 -08:00
Jonathan Westhues 70bf14530d Add point on line constraints, in 2d and 3d. The 3d equations do
not have much motivation behind them, but they seem to work. And
make sure that we don't solve multiple times without repainting in
between, and tweak the text window a bit more.

[git-p4: depot-paths = "//depot/solvespace/": change = 1696]
2008-04-28 01:40:02 -08:00
Jonathan Westhues 598d456d8d Tear apart the text window, mostly to beautify things. The
foreground and background colours are now specified separately, and
it's possible to insert half-line spaces. So now I have a window
that lets me show/hide groups, and select the active one.

[git-p4: depot-paths = "//depot/solvespace/": change = 1695]
2008-04-27 23:18:39 -08:00
Jonathan Westhues 49ec1346d7 Add the first `derived' group, that generates entities based on
other entities. This requires a new point type, for a point that's
defined as a transformation of some other point. All works nicely,
I think. There's ugliness because entities are no longer guaranteed
to have a parent request.

Also speed up display of the text window, by caching brushes
instead of recreating for each character (!), and add a bit more
user interface in the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1692]
2008-04-27 01:03:01 -08:00
Jonathan Westhues bfc7109e0c Standardize the behaviour of constraints, by assigning them a
workplane: a free constraint works in three-space (e.g. true
distance), and a constraint in a workplane works in that plane
(e.g. projected distance). And make the solver go automatically,
though solver itself has lots of pieces missing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1691]
2008-04-26 21:00:12 -08:00
Jonathan Westhues 15476d4732 A great renaming. 2d coordinate systems are now called workplanes,
and the associated entities are now just points.

[git-p4: depot-paths = "//depot/solvespace/": change = 1690]
2008-04-26 19:26:27 -08:00
Jonathan Westhues a8001adf33 Add horizontal and vertical constraints. Those have their own 2d/3d
issues, when the points are not all in the same coordinate system.
All painful, of course. Also add continuous line drawing, and
auto-constraining of line segments as I draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1683]
2008-04-22 23:29:19 -08:00
Jonathan Westhues 1bf7e3deaf Add an ExprVector class, for a 3-vector whose members are
expressions. That simplifies a few things considerably. And some
little UI tweaks.

[git-p4: depot-paths = "//depot/solvespace/": change = 1682]
2008-04-22 05:14:15 -08:00
Jonathan Westhues fa71238def Some graphics tweaks, to the order in which stuff gets drawn, to
determine what goes in front (e.g. put a drawn line in front of the
reference plane, even if the z order would want the opposite), and
some tweaks to the mouse behaviour, and a function to modify
constraints like dimensions so that the are initially satisfied.

[git-p4: depot-paths = "//depot/solvespace/": change = 1681]
2008-04-22 02:53:42 -08:00
Jonathan Westhues 1f77024771 Add an equal length constraint for line segments.
[git-p4: depot-paths = "//depot/solvespace/": change = 1680]
2008-04-21 21:00:49 -08:00
Jonathan Westhues 2926fa95d9 Start to add some constraint stuff. I now have point-coincident,
and point-in-plane. These work, but the equation is still stupid,
solving everything at once and not substituting trivial equations.

[git-p4: depot-paths = "//depot/solvespace/": change = 1677]
2008-04-21 00:16:38 -08:00
Jonathan Westhues b78b10ac1a Ultra-rough beginnings of a solver. Write the constraint equations,
take the partial derivatives, and run the Newton's method. This
seems to sort of work with a single distance constraint.

[git-p4: depot-paths = "//depot/solvespace/": change = 1675]
2008-04-20 03:35:10 -08:00
Jonathan Westhues cc03fe40aa Big structural change; eliminate the Point type in SolveSpace. The
points are now entities like any others; so a line segment request
will generate three entities, the line segment and its endpoints. I
think that's cleaner.

When I do step and repeats (and imports, and other similar), I'll
need a consistent way to assign those entity ids. That assignment
must not change if the sketch is edited. I don't have a clean way
to do that; best thought right now is to keep a record of what maps
have been used previously, and not pick a new map as long as it's
possible to use one that was used previously.

This all means that more crap gets pushed in to the Entity
structure, so that they can keep track of what solver variables
define them. Still seems better, though. I'm closer to ready
to start solving.

[git-p4: depot-paths = "//depot/solvespace/": change = 1673]
2008-04-19 03:09:47 -08:00