Commit Graph

289 Commits (03ecbad981ed6cefa8d126bce5e31152b3dba908)

Author SHA1 Message Date
Jonathan Westhues 03ecbad981 Add beginnings of stuff to represent surfaces as either meshes or
exact surface shells. And add interference checking; I'll be lazy
and just do that on the meshes, by modifying the self-intersection
tester to ignore coplanar triangles (since that can happen in an
assembly).

[git-p4: depot-paths = "//depot/solvespace/": change = 1958]
2009-05-22 02:02:02 -08:00
Jonathan Westhues ddf9364257 Add a separate display mesh and edge list; so if we're working with
a mesh than that's a copy, and if we're working with a shell then
it's the shell's triangulation.

[git-p4: depot-paths = "//depot/solvespace/": change = 1957]
2009-05-21 01:06:26 -08:00
Jonathan Westhues e70bb37061 Fix bug in hidden line removal when an edge, projected into the xy
plane, lies exactly on the boundary of a triangle.

[git-p4: depot-paths = "//depot/solvespace/": change = 1956]
2009-05-20 05:07:56 -08:00
Jonathan Westhues b4dfb1aded Add code to assemble two shells into one, without checking for any
intersections or otherwise trying to make the result not
self-intersecting.

[git-p4: depot-paths = "//depot/solvespace/": change = 1955]
2009-05-19 19:04:36 -08:00
Jonathan Westhues bc6bdfade8 Save the exact surfaces in the exported file, and import and
transform them for assembly.

[git-p4: depot-paths = "//depot/solvespace/": change = 1954]
2009-05-18 23:26:38 -08:00
Jonathan Westhues 1d88f96e13 Make surfaces of revolution with control points on the axis
triangulate correctly; don't screw up generating them, and make
sure that the ratpoly stuff doesn't blow up near the singularity.

[git-p4: depot-paths = "//depot/solvespace/": change = 1953]
2009-05-18 00:18:32 -08:00
Jonathan Westhues 40ed1b7ac1 Generate intersection curves for surfaces of extrusion along a
parallel axis (which are always lines parallel to that axis).

Remove short pwl segments when possible, to avoid short edges that
get misclassified.

[git-p4: depot-paths = "//depot/solvespace/": change = 1952]
2009-05-17 23:26:51 -08:00
Jonathan Westhues d6d198ee40 Add triangulation of surfaces with compound curvature; I just build
a grid of quads, with adaptive spacing. The quads that lie entirely
within the trim polygon are triangulated and knocked out from the
polygon, and then the polygon is triangulated.

That works okay, though rather slow. But there are issues with
surfaces of revolution that touch the axis, since they end up with
a singularity. That will require some thought.

[git-p4: depot-paths = "//depot/solvespace/": change = 1951]
2009-05-08 00:33:04 -08:00
Jonathan Westhues 3581d9b9ec Construct surfaces of revolution from lathe groups, although we're
not triangulating them correctly yet.

[git-p4: depot-paths = "//depot/solvespace/": change = 1950]
2009-04-28 18:42:44 -08:00
Jonathan Westhues ff6eae884e Oops, forgot to clear out the equations (and the entities, though I
don't use them) in the System.

[git-p4: depot-paths = "//depot/solvespace/": change = 1949]
2009-04-24 17:27:45 -08:00
Jonathan Westhues f8dbc89189 Polish a few little things in the constraint solver library stuff.
[git-p4: depot-paths = "//depot/solvespace/": change = 1947]
2009-04-21 22:15:01 -08:00
Jonathan Westhues 9efa922795 Add a solver option to not calculate the failing constraints if
we're inconsistent (singular Jacobian). That's slow, so we should
provide a library interface to disable it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1946]
2009-04-20 23:56:17 -08:00
Jonathan Westhues 1554402b30 Oops, forgot slvs.h.
[git-p4: depot-paths = "//depot/solvespace/": change = 1945]
2009-04-19 23:32:07 -08:00
Jonathan Westhues 4d742a5777 The constraint solver now compiles as a library, and I have a
little test app that links against it. I still need to polish a few
things, but this is more or less as it should be.

[git-p4: depot-paths = "//depot/solvespace/": change = 1944]
2009-04-19 23:30:09 -08:00
Jonathan Westhues 11e4c7f5d9 Oops, don't just crash when the MAX_UNKNOWNS limit is exceeded.
[git-p4: depot-paths = "//depot/solvespace/": change = 1943]
2009-04-19 12:37:51 -08:00
Jonathan Westhues a4dc518a89 A monster change; move the parameter, entity, group, and constraint
tables from SolveSpace to their own class. This is intended to
simplify use of the constraint solver in a library.

[git-p4: depot-paths = "//depot/solvespace/": change = 1942]
2009-04-18 21:53:16 -08:00
Jonathan Westhues b293c0ef41 Split the Entity and Constraint classes into Xxx and XxxBase, with
the fundamental geometric stuff in XxxBase. Next I hope to make the
constraint solver use only the XxxBase types.

[git-p4: depot-paths = "//depot/solvespace/": change = 1941]
2009-04-18 20:28:21 -08:00
Jonathan Westhues bab13b821f Little optimizations in the solver; don't write the Jacobian
redundantly, more zero partial avoidance, slight speedup to linear
system solve.

[git-p4: depot-paths = "//depot/solvespace/": change = 1940]
2009-04-18 19:55:46 -08:00
Jonathan Westhues 16de9a485a Oops, don't export construction lines. And we can't do exact curves
with cutter radius offset, and 2 pixels is a better default chord 
tolerance than 1.

[git-p4: depot-paths = "//depot/solvespace/": change = 1939]
2009-04-15 20:42:51 -08:00
Jonathan Westhues 3ca2a6b80b Add direct PDF export. The only curves in PDF are nonrational
cubics, so add routines to approximate a rational Bezier of any
degree in that form. And use those for EPS and SVG when applicable,
so now even stuff like ellipses gets exported smooth.

[git-p4: depot-paths = "//depot/solvespace/": change = 1938]
2009-04-14 22:50:06 -08:00
Jonathan Westhues b5c8aade21 Add exact export of arcs for EPS, DXF, SVG, and of nonrational
polynomial curves for SVG.

[git-p4: depot-paths = "//depot/solvespace/": change = 1937]
2009-04-14 18:55:18 -08:00
Jonathan Westhues 775653a75d Add beginnings of exact curve export. We take the trim curves in
our specified section plane; we then split them according to the
start and endpoints of each STrimBy, using de Castejau's algorithm.
These sections get projected (possibly in perspective, which I do
correctly) into 2d and exported.

Except, for now they just get pwl'd in the export files. That's the
fallback, since it works for any file format. But that's the place
to add special cases for circles etc., or to export them exactly.
DXF supports the latter, but very painfully since I would need to
write a later-versioned file, which requires thousands of lines of
baggage. I'll probably stick with arcs.

[git-p4: depot-paths = "//depot/solvespace/": change = 1936]
2009-04-13 20:19:23 -08:00
Jonathan Westhues 22afc5ea15 The hidden line removal unnecessarily splits our edges, which
bloats the output file size. So reassemble the edges whenever
possible.

[git-p4: depot-paths = "//depot/solvespace/": change = 1935]
2009-04-07 20:54:07 -08:00
Jonathan Westhues 71adc0bf54 Split ratpoly.cpp; now that contains only the mathematical stuff,
and curve.cpp and surface.cpp contain the rest.

Also get rid of the meshError stuff; will just use the nakedEdges
mechanism for that. And I won't run the interference test
continuously, have added a menu item for that.

[git-p4: depot-paths = "//depot/solvespace/": change = 1934]
2009-03-28 22:05:28 -08:00
Jonathan Westhues 7f3dd91bd9 Add a special case for line-cylinder intersection, solving in
closed form. This is a fairly good speedup, and handles tangency
well.

But that shows that tangency has other problems; need to classify
edges correctly (whether they point to a coincident surface) in
curved surfaces too. I need to tweak SShell::ClassifyPoint().

[git-p4: depot-paths = "//depot/solvespace/": change = 1933]
2009-03-19 09:40:11 -08:00
Jonathan Westhues d4b842a242 Generate additional edges wherever a front- and back-facing
triangle join. And add controls to show and hide the solid model
edges (independently of the shaded mesh), and to suppress the
shaded triangles from SVG/EPS output.

[git-p4: depot-paths = "//depot/solvespace/": change = 1932]
2009-03-17 20:26:04 -08:00
Jonathan Westhues 1a845c3432 Add hidden line and surface removal, and vector shaded surface
export. So I calculate lighting for each triangle in the mesh, make
a BSP, and then traverse it in-order and output those as SVG or
EPS. And I test edges against the mesh, removing those portions of
the edge that overlap a triangle in front of them (using the
kd-tree to accelerate).

[git-p4: depot-paths = "//depot/solvespace/": change = 1931]
2009-03-17 08:33:46 -08:00
Jonathan Westhues ed9f448398 Oops, need to remap plane face entities when stepping and repeating
shells.

[git-p4: depot-paths = "//depot/solvespace/": change = 1930]
2009-03-15 21:11:06 -08:00
Jonathan Westhues acadc0a918 Many changes:
* Rewrite surface handles in curves, so that Booleans beyond
      the first don't screw up.

    * If an intersection curve is identical to an existing curve
      (as happens when faces are coincident), take the piecewise
      linearization of the existing curve; this stops us from
      screwing up when different shells are pwl'd at different
      chord tols.

    * Hook up the plane faces again.

    * Remove coincident (parallel or anti-parallel) edges from the
      coincident-face edge lists when doing Booleans; those may
      happen if two faces are coincident with ours.

    * Miscellaneous bugfixes.

It doesn't seem to screw up very much now, although tangent edges
(and insufficient pwl resolution) may still cause problems.

[git-p4: depot-paths = "//depot/solvespace/": change = 1929]
2009-03-15 15:04:45 -08:00
Jonathan Westhues adc910185c Add plane-plane intersection as a special case (to generate the
trimmed line), and plane-line intersection. Terminate the Bezier
surface subdivision on a chord tolerance, and that seems okay now.
And print info about the graphics adapter in the text window, could
be useful.

Also have a cylinder-detection routine that works; should special
case those surfaces in closed form since they are common, but not
doing it yet.

[git-p4: depot-paths = "//depot/solvespace/": change = 1928]
2009-03-14 12:01:20 -08:00
Jonathan Westhues 8c648af4de Fix bug with text window, where it scrolled up of its own intiative
when resized.

[git-p4: depot-paths = "//depot/solvespace/": change = 1927]
2009-03-11 04:22:32 -08:00
Jonathan Westhues bc70089dd0 Add code to subdivide (with de Castljau's algorithm) a surface, and
use that for surface-line intersections. That has major problems
with the heuristic on when to stop and do Newton polishing.

There's also an issue with all the Newton stuff when surfaces join
tangent.

And update the wishlist to reflect current needs.

[git-p4: depot-paths = "//depot/solvespace/": change = 1925]
2009-03-08 02:59:57 -08:00
Jonathan Westhues c128018c55 Remove idiotic tolerance in Point2d::WithMagnitude(). What was I
thinking?

[git-p4: depot-paths = "//depot/solvespace/": change = 1922]
2009-03-01 21:52:08 -08:00
Jonathan Westhues 77cace05ce When clipping ears to triangulate a curved surface, clip the ear
that minimizes the chord tolerance.

[git-p4: depot-paths = "//depot/solvespace/": change = 1921]
2009-02-27 06:05:08 -08:00
Jonathan Westhues 2023667311 Add Newton iterations to intersect a line with a surface at a
point, and to intersect three surfaces at a point. So now when we
split an edge, we can refine the split point to lie exactly on the
trim curve, so I can do certain Booleans on curved surfaces.

But surface-line intersection is globally broken, since I don't
correctly detect the number of intersections or provide a good
first guess. I maybe should test by bounding boxes and subdivision.

[git-p4: depot-paths = "//depot/solvespace/": change = 1920]
2009-02-27 05:04:36 -08:00
Jonathan Westhues 3da1e1d390 Compute surface intersections in a way that is closer to what I
will do for real; now handling the special cases of plane against a
surface of extrusion. Still need to fix up line-surface
intersection to work for curved things, but then some simple curved
cases should work (as well as plane-plane).

[git-p4: depot-paths = "//depot/solvespace/": change = 1919]
2009-02-23 02:06:02 -08:00
Jonathan Westhues 9ade574d36 Fix triangulation issues when a polygon has more than two edges at
a vertex.

[git-p4: depot-paths = "//depot/solvespace/": change = 1916]
2009-02-18 03:15:33 -08:00
Jonathan Westhues 577cdf2255 More coincident fixing; test for edge-on-edge, fix some gross
stupidity.

[git-p4: depot-paths = "//depot/solvespace/": change = 1915]
2009-02-17 03:17:12 -08:00
Jonathan Westhues c6b429b9ce Additional poking at Booleans. At least this is a halfway rational
way to think about the cases; I'm classifying the regions to the
left and right of each edge, and keeping the edges if those regions
(2d, surfaces) classify different.

Still screws up with edge-on-edge intersections; but if I make the
surface intersection stuff handle that, then might be more
straightforward to use that info.

[git-p4: depot-paths = "//depot/solvespace/": change = 1914]
2009-02-16 04:05:08 -08:00
Jonathan Westhues 90842131ff Make Boolean union work when the shells have coincident plane
faces. Still on planes only, no curved surface intersections.

[git-p4: depot-paths = "//depot/solvespace/": change = 1912]
2009-02-09 04:40:48 -08:00
Jonathan Westhues d0ab8270d9 Fix stupidity in Point2d::DistanceToLine, and classify line
segments in Boolean against the shell, not the intersection
polygon. (We just cast a ray, and use the surface-line intersection
function that already existed.) That's slow, but can be
accelerated later.

[git-p4: depot-paths = "//depot/solvespace/": change = 1911]
2009-02-01 05:01:28 -08:00
Jonathan Westhues 9ffe95ea65 More work on Booleans. This works only for planes, and only for
non-coincident faces. There's also a problem when I don't generate
the full intersection polygon of shell B against a given surface in
shell A; I need to modify the code to not require that.

[git-p4: depot-paths = "//depot/solvespace/": change = 1910]
2009-01-31 21:13:43 -08:00
Jonathan Westhues db8859ec31 Test for self-intersecting mesh too when we test for naked edges.
[git-p4: depot-paths = "//depot/solvespace/": change = 1909]
2009-01-27 23:09:01 -08:00
Jonathan Westhues 715a554637 So that's why projection into the surface kept failing; was using
the magnitude of the wrong derivative! Fix that, good.

[git-p4: depot-paths = "//depot/solvespace/": change = 1908]
2009-01-27 01:22:18 -08:00
Jonathan Westhues a754018a44 More poking at Booleans; generate the unsplit intersection curves
for planes against planes.

[git-p4: depot-paths = "//depot/solvespace/": change = 1907]
2009-01-26 23:59:58 -08:00
Jonathan Westhues 95bded27ee Add eps, hpgl, and svg output (simple, all just for polylines). And
fix convergence tolerance so that points projected into a rational
polynomial surface end up much closer than LENGTH_EPS.

[git-p4: depot-paths = "//depot/solvespace/": change = 1906]
2009-01-26 21:48:40 -08:00
Jonathan Westhues 07ddd62a3a Preparatory work for Boolean. Make the u and v coordinates of the
trim curves for all surfaces lie between 0 and 1. And add routines
to merge the curves and surfaces from two shells into one, and to
split the trim curves into their piecewise linear segments and then
reassemble them into trim curves.

[git-p4: depot-paths = "//depot/solvespace/": change = 1905]
2009-01-25 03:52:29 -08:00
Jonathan Westhues daba7bf90b Oops, wasn't setting line width for the tool tips on the toolbar;
and with the naked edge stuff I just added, that was wrong.

[git-p4: depot-paths = "//depot/solvespace/": change = 1904]
2009-01-25 03:25:40 -08:00
Jonathan Westhues 2e4ec6dd04 Add sin and cos to the expression entry (for dimensions etc.), with
the same precedence as sqrt. Add the code to find naked edges, and
draw them highlighted on the model. And make the direction of trim
curves consistent, always ccw with normal toward viewer; so there's
no need to fix the directions before triangulating.

[git-p4: depot-paths = "//depot/solvespace/": change = 1903]
2009-01-25 01:19:59 -08:00
Jonathan Westhues bb4b767e99 Tear everything apart, moving away from meshes and toward shells.
Add stubs for functions to perform Booleans, and get rid of mesh
stuff, including the kd tree accelerated snap to vertex (which
should not be required if the shell triangulation performs as it
should).

Also check that a sketch is not self-intersecting before extruding
it or whatever. This is dead slow, needs n*log(n) implementation.

[git-p4: depot-paths = "//depot/solvespace/": change = 1902]
2009-01-22 19:30:30 -08:00