Commit Graph

50 Commits (f6bb6809782d7b8f21d6953fd01c654af344fdba)

Author SHA1 Message Date
Jonathan Westhues c153e23f49 Add option to mirror imported geometry, including the shell, mesh,
and parametric entities. Also consolidate the text screen functions
to change group options into a single function for everything.

[git-p4: depot-paths = "//depot/solvespace/": change = 2051]
2009-10-09 04:57:10 -08:00
Jonathan Westhues 274005c02c Make hidden line removal keep all the line styles, and don't apply
that to the constraints.

And fix two crashing bugs, embarrassing, both chasing null pointers.

[git-p4: depot-paths = "//depot/solvespace/": change = 2031]
2009-09-21 22:47:11 -08:00
Jonathan Westhues 7a279c4e3f Fix interference check to not report not-2-manifold edges; those
can occur in assemblies with coincident faces. And turn on smooth
shading, finally.

[git-p4: depot-paths = "//depot/solvespace/": change = 1971]
2009-06-06 01:44:58 -08:00
Jonathan Westhues 842645d61f Put back code to generate emphasized edges from a mesh; so now we
can show edges for both meshes and shells, and export them and
hidden line remove and all the usual stuff.

And fix the zoom to fit on startup, so that it considers hidden
entities too. That avoids the problem where things get generated at
stupid chord tolerance because no entities were visible and the
mesh of course did not yet exist.

[git-p4: depot-paths = "//depot/solvespace/": change = 1961]
2009-05-28 21:40:17 -08:00
Jonathan Westhues 7536ccb054 Put back the "snap to vertex" stuff to remove tee intersections
that the BSP-based Booleans create.

[git-p4: depot-paths = "//depot/solvespace/": change = 1960]
2009-05-27 23:07:54 -08:00
Jonathan Westhues ddbd0ff77b Add ability to represent our surfaces as either a shell or a mesh,
according to the user's preference. I templated the housekeeping
stuff for Boolean operations and step and repeat, so it's
relatively clean.

Still need to add the stuff to make a mesh vertex-to-vertex, and to
export sections of a mesh.

[git-p4: depot-paths = "//depot/solvespace/": change = 1959]
2009-05-24 03:37:07 -08:00
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 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 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 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 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
Jonathan Westhues 69cf8d6484 Change fudging when I select edges to generate a section from the
shell. That seems less prone generating stray lines, though it does
sometimes generate gaps.

[git-p4: depot-paths = "//depot/solvespace/": change = 1876]
2008-09-08 21:19:54 -08:00
Jonathan Westhues fb33edcade Comment out the error when I generate a leaky mesh.
[git-p4: depot-paths = "//depot/solvespace/": change = 1870]
2008-08-15 00:37:32 -08:00
Jonathan Westhues ddf2b30b98 Remove some of the oops() calls that tend to blow because of issues
in the numerical code.

And clean some other stuff, in particular simplifying whenever I
have to take the maximum (or minimum) of three quantities.

[git-p4: depot-paths = "//depot/solvespace/": change = 1855]
2008-02-10 05:34:32 -08:00
Jonathan Westhues 98b0f65cea But still draw the edges when the faces are coplanar, if the faces
are different colors.

[git-p4: depot-paths = "//depot/solvespace/": change = 1842]
2008-07-15 23:08:39 -08:00
Jonathan Westhues 3765175ec3 Don't emphasize edges between coincident plane faces, and check in
beginnings of reference manual.

[git-p4: depot-paths = "//depot/solvespace/": change = 1841]
2008-07-15 21:45:11 -08:00
Jonathan Westhues f70bbb3e7f This BSP split and simplify thing is stupid, but a hard-coded limit
on the number of pieces that we know how to reassemble is even
stupider. Now dynamically allocated.

[git-p4: depot-paths = "//depot/solvespace/": change = 1837]
2008-07-13 04:58:52 -08:00
Jonathan Westhues 88fc69116f Add tangency constraints, for line segments against arcs or cubics.
These are just a convenience, since it would be possible to get the
same result by drawing a construction line.

[git-p4: depot-paths = "//depot/solvespace/": change = 1836]
2008-07-13 04:44:05 -08:00
Jonathan Westhues 7622534b2a Make the piecewise linear stuff for cubics and quadratics adaptive,
based on a chord tolerance. And rewrite the pwl circles to work
against a chord tolerance too (which they really were doing before,
but in funny units).

Also make "assemble" combine type do a union after interference
checking; was previously just copying, which meant that coplanar
faces could break subsequent operations.

And make right-clicking effectively toggle shift key, instead of
forcing it on; so you can pan or rotate with either right or middle
button.

[git-p4: depot-paths = "//depot/solvespace/": change = 1829]
2008-07-09 21:26:08 -08:00
Jonathan Westhues b2f2f90a27 Add DXF export. The complexity comes from all the different ways to
specify the plane from which we want to grab the triangles. Shared
edges are then removed with the same code used to check for
watertight meshes, and the remaining edges are assembled into
polygons.

[git-p4: depot-paths = "//depot/solvespace/": change = 1823]
2008-07-07 22:30:13 -08:00
Jonathan Westhues cad77c9c47 Add routines to remove T intersections from the mesh, which are
introduced by the bsp routines. It's usually, though not always,
possible to generate a watertight mesh. The occasions where it's
not look ugly, floating point issues, no quick fix.

And use those to generate a list of edges where two different faces
meet, which I can emphasize for cosmetic reasons (and some UI to
specify whether to do that, and with what color).

And make the right mouse button rotate the model, since that was
previously doing nothing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1821]
2008-07-05 23:56:24 -08:00
Jonathan Westhues 8a70efed05 Make sliver triangle tests work on the minimum altitude, not on
area.

[git-p4: depot-paths = "//depot/solvespace/": change = 1816]
2008-07-01 20:32:24 -08:00
Jonathan Westhues bc5b43de85 Split the BSP stuff off the mesh stuff, and the text screens
themselves of the text window utility functions.

[git-p4: depot-paths = "//depot/solvespace/": change = 1806]
2008-06-23 00:37:12 -08:00
Jonathan Westhues a5189f7f1a Make step and repeats step the mesh, as well as the entities. This
requires new entitiy types for the faces, by translation or by
axis-angle rotation.

[git-p4: depot-paths = "//depot/solvespace/": change = 1802]
2008-06-21 14:49:57 -08:00
Jonathan Westhues 5a22982e05 Add sweeps. The user specifies a trajectory and a section, in two
separate groups. The section is swept normal to the trajectory,
producing a mesh. I'm doing the triangles only now, not copying
over any entities.

Also fix a bug in the PNG export; rows are 4-aligned, so that was
breaking when the width of the image wasn't divisible by four. Also
fix a bug in lathes, where it generated overlapping triangles for
one segment.

And change the groups to record both "this mesh", the contribution
due to the extrude/lathe/whatever, and the "running mesh", that we
get after applying the requested Boolean op between "this mesh" and
the previous group's "running mesh". I'll use that to make step and
repeats step the mesh too.

[git-p4: depot-paths = "//depot/solvespace/": change = 1801]
2008-06-21 02:18:20 -08:00
Jonathan Westhues e67ea9ca0f Add perspective, by a user-specified factor. So I have to apply
that perspective in the gl matrices, and also everywhere that I
check mouse pointer positions against the model, and for the zoom
to fit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1796]
2008-06-17 11:12:25 -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 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 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 f803806029 Don't initialize the SEdges with ... = { ... }; use a special
function for that.

[git-p4: depot-paths = "//depot/solvespace/": change = 1759]
2008-05-30 00:01:19 -08:00
Jonathan Westhues eb8a43d22b Fix stupidity in the triangle simplification; I didn't handle the
case where you bolt a triangle onto a convex poly, and both
remaining edges of the tri are coincident with the neighbours from
the poly. That was a big source of zero-area triangles.

And tweak some colors a bit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1758]
2008-05-29 23:32:30 -08:00
Jonathan Westhues 69eb2273ac Add color. Now each triangle has metadata, which are preserved in
csg ops; so the union of a red part and a blue part has both red
and blue faces. And some user interface to pick the color in the
text window.

The metadata also include a face, which will be an entity; I can
use that to constrain against. But none of that is yet implemented.

[git-p4: depot-paths = "//depot/solvespace/": change = 1757]
2008-05-29 22:09:41 -08:00
Jonathan Westhues d5a8c431da Oops, Boolean 0 - B was equal to B with the normals flipped, not
zero.

[git-p4: depot-paths = "//depot/solvespace/": change = 1755]
2008-05-28 02:37:54 -08:00
Jonathan Westhues 4375c01c51 Add step and repeat translate, with multiple copies; that all works
nicely. And to do that, I've added the user interface to show an
edit control in the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1749]
2008-05-26 22:36:59 -08:00
Jonathan Westhues dd70cb55a2 Make it work when I insert against a NULL bsp3.
[git-p4: depot-paths = "//depot/solvespace/": change = 1747]
2008-05-26 16:34:26 -08:00
Jonathan Westhues 727ac126fb Some ugly hacks; discard zero-area triangles, randomize the
triangle list before adding to the BSP, and check if a point in
plane lies in multiple triangles and choose the one with the
biggest normal magnitude (i.e., area) when testing normal
direction.

[git-p4: depot-paths = "//depot/solvespace/": change = 1745]
2008-05-25 22:23:05 -08:00
Jonathan Westhues d750344653 Even if one vertex is collinear, the other one could be reflex;
triangle merging code was screwing up.

[git-p4: depot-paths = "//depot/solvespace/": change = 1744]
2008-05-25 20:27:34 -08:00
Jonathan Westhues c58dbf1676 When a triangle gets split when it's added, retriangulate in an
effort to reduce the number of pieces.

[git-p4: depot-paths = "//depot/solvespace/": change = 1743]
2008-05-25 19:39:45 -08:00
Jonathan Westhues 05b50e0af8 Various tweaks, including a numerical improvement, to make the
epsilon in the csg stuff meaningfully apply everywhere to the
length.

[git-p4: depot-paths = "//depot/solvespace/": change = 1742]
2008-05-25 06:36:03 -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 1909d4c520 The rule for when to keep coplanar surfaces was very wrong; fix it.
[git-p4: depot-paths = "//depot/solvespace/": change = 1740]
2008-05-24 16:37:11 -08:00
Jonathan Westhues 0ad8644df4 As we break things against the BSP, keep an arbitrary convex
polygon, not just triangles. This helps to avoid needless
splitting. Also test if an entire triangle got inserted in multiple
pieces; if yes, back things out, and just insert the triangle.

Also remove the extra partition stuff, since it didn't seem to help
consistently, and this does.

Still could do some better merging, in the case where an inserted
triangle does not get fully inserted, but we can find a better
triangulation than what the BSP naturally gives.

[git-p4: depot-paths = "//depot/solvespace/": change = 1739]
2008-05-24 15:10:00 -08:00
Jonathan Westhues 097d0ddfa9 Add a workaround for OpenGL, which likes to tesselate with
zero-area triangles, apparently. And make the number of line
segments used to approximate a triangle depend on its scale on
screen.

[git-p4: depot-paths = "//depot/solvespace/": change = 1738]
2008-05-24 05:23:25 -08:00
Jonathan Westhues 70ccbebc8f Add extra split planes (not coplanar with any triangle) to the BSP
while building it. That may improve performance, by building a more
balanced tree and actually reducing splitting. Not dramatic
improvements, though; half the triangles for some parts, but no
change or slightly worse for others.

[git-p4: depot-paths = "//depot/solvespace/": change = 1737]
2008-05-24 04:23:25 -08:00
Jonathan Westhues 4d7ffc85f9 Make coplanar faces work properly, by implementing a 2d BSP on each
set of coplanar faces. The polygon count still gets stupid fast;
I'm thinking I can fix that by adding some extra test planes at the
top of the 3d BSP, to quickly cull out stuff that doesn't intersect
us.

[git-p4: depot-paths = "//depot/solvespace/": change = 1736]
2008-05-24 02:34:06 -08:00
Jonathan Westhues de46118324 Add code to extrude a triangle mesh, and to perform Boolean ops on
a triangle mesh in a BSP. That works, although it splits too often,
the initial triangulations are not good quality, and coplanar faces
are not yet handled. I'll do the coplanar thing tomorrow.

[git-p4: depot-paths = "//depot/solvespace/": change = 1735]
2008-05-23 02:05:07 -08:00
Jonathan Westhues c079497762 And add mesh.cpp, which I had forgotten.
[git-p4: depot-paths = "//depot/solvespace/": change = 1734]
2008-05-22 02:28:50 -08:00