Commit Graph

1066 Commits (cf4defcd474e0a55cfb5970265b3d1f0e99d16b0)

Author SHA1 Message Date
phkahler eadeac44f0 use VERY_NEGATIVE and VERY_POSITIVE instead of numeric values which is some cases were 1e-10 instead of -1e10 2020-10-28 13:37:54 -04:00
phkahler 6c4b075eef Increase MAX_UNDO to 100 2020-10-28 13:37:54 -04:00
ruevs 7e99ba0096 UI: Fix the Property Browser window scrollbar
- Scrolling with the scrollbar now works properly.

- Do not scroll with the mouse wheel while an edit field is active in
  the property browser.

Fixes: https://github.com/solvespace/solvespace/issues/782
2020-10-28 13:37:30 -04:00
Koen Schmeets 73bbbdef83 Travis: include libomp in macOS .app 2020-10-26 02:26:54 +01:00
ruevs 88b26aabdb Update the year in the About dialog 2020-10-25 19:16:34 -04:00
ruevs 7292c32e6f Performance: inline the Bernstein functions
This is another small profiling driven optimization.
Moving the initialization of `const double *c` as part of the definition
also helps with the generated assembler.
2020-10-25 19:16:22 -04:00
Maximilian Federle 24720a0024 Revert "CMake: use sanitizer flags for internal targets only"
This reverts commit 68b1abf77f.

The warnings are valuable and shouldn't be cast aside.
As of 8f509f1, we special case macOS and don't set -fno-sanitize-recover
to allow CI to succeed.
In the future, this could be made stricter again by only suppressing
known bugs, which ideally should also be fixed or reported upstream.
2020-10-24 17:10:47 +02:00
ruevs 7035071526 Performance optimization of the Vector class
Profiling with MSVC 2019 showed that many of the Vector methods are on
a critical path (not surprising). They are changed to be inline and
unnecessary temporaries are removed.

On the example below generate times decreased from 102s. to 64s.
At the same time the executable size shrank from 5569536	to 5150208 bytes
in release mode (with global optimizations).

This should not stop us from working on optimizing inner loops e.g. https://github.com/solvespace/solvespace/issues/759 .

[Test model](https://github.com/solvespace/solvespace/files/5414683/PrismConeNURBSNormalsTangents300.zip)
2020-10-23 20:08:43 -04:00
Maximilian Federle 68b1abf77f CMake: use sanitizer flags for internal targets only
Previously sanitizer flags were set unconditionally for
all code, including that of external libraries.
Set them only for targets in src/, tests/ and exposed/.

Unfortunately, the linker equivalent to add_compile_options,
add_link_options, is only available for CMake version >= 3.13.
So add the sanitizer flags manually to each target's linker options.
2020-10-23 19:39:36 +02:00
phkahler c674bc8fb9 Add OpenMP parallel for to SShell::CopyCurvesSplitAgainst 2020-10-23 12:53:54 -04:00
phkahler 0f1ece2b8e Resovle a huge performance regression introduced by commit ab10e38 while still fixing the NURBS issues resolved by that commit with only modest speed penalty. The performance is significantly improved by using bounding box tests on curves prior to doing complex intersection testing. 2020-10-23 12:52:27 -04:00
ruevs 0761339ec9 STEP Export: include colors and alpha
Make the color export work in KiCAD and Horison EDA which do not support
transparency.

Fixes: https://github.com/solvespace/solvespace/issues/452
https://github.com/solvespace/solvespace/pull/763
2020-10-22 09:59:35 +03:00
ruevs 32e695bfee STEP Export: include colors and alpha
The implementation may be sub-optimal, since the colour and alpha is
defined for each NURBS surface instead of on group level, but the STEP
export currently does not represent group structure at all and I am not
familiar with the format in order to change this.

Fixes: https://github.com/solvespace/solvespace/issues/452
2020-10-21 17:19:12 -04:00
phkahler ab10e38d44 Add vertexes to curve intersection list in addition to surface intersections.
Sometimes a vertex can be used to split a curve where surface intersections can't. Those unsplit curves can cause boolean failures.
2020-10-20 12:37:18 -04:00
Koen Schmeets 3af8127e8f macOS: add NSOpenGLPFADoubleBuffer to NSOpenGLPixelFormatAttribute 2020-10-20 10:59:58 -04:00
Koen Schmeets 8e7416f3fd
Travis: Build improvements and fixes (#751)
- Add OpenMP to macOS build
- Use as many cores as possible in CI
- Update travis osx image to xcode12.2
- Ignore .vscode folder
- In `.travis/sign-macos.sh`, only create keychain when `CI` variable is present
- Only run macOS deploy stage when a tag is pushed
2020-10-20 09:39:26 +02:00
phkahler b28499ea48 initial support (disabled) for keepout regions in IDF files. 2020-10-19 18:26:45 -04:00
phkahler b12bcc5889 Fix some IDF file curves. 2020-10-19 18:26:45 -04:00
Koen Schmeets 0548702043 macOS CI fixes 2020-10-19 09:36:52 -04:00
phkahler 408128a138 Avoid zero tangnet vectors on degenerate NURBS edges. Fixes #652 2020-10-18 14:54:00 -04:00
ruevs 6558cb9ebe Fix crash in solvespace-cli
`window` is a `nullptr` with guinone.cpp - avoid dereferencing it.

Fixes: https://github.com/solvespace/solvespace/issues/567
2020-10-16 17:44:58 -04:00
ruevs 3ea8ebfaf5 Win32: Fix "File|Open...", "Save" and "Save As" when a command line argument is used.
`GetSaveFileNameA` `OPENFILENAMEA` does not like UNC ( "\\\\?\\C:\\..." ) file prefixes in `lpstrFile`.
Work around it by not `Expand`-ing parameters passed on the command line too early.

The only user visible change is that "File|Open Recent" will show items as they
were passed instead of expanded to full path for example:
"..\..\NURBSTests\Intersection2.slvs"

Fixes: https://github.com/solvespace/solvespace/issues/622
2020-10-16 17:44:27 -04:00
phkahler d72eba8039 Create intersection curves from existing ones.
When a plane coinsides with a seam we need to copy that trim curve. The existing curve belongs to the original shell surfaces and an intersection is otherwise not found. Fixes #540.
2020-10-10 02:02:34 -04:00
julien581 c514ddad54 Fix for https://github.com/solvespace/solvespace/issues/248 2020-10-03 15:27:14 -04:00
phkahler c021df33c0 Fix issue 684 as whitequark suggested via WM_KEYDOWN->WMCHAR change. 2020-10-01 13:55:40 -04:00
Johannes Rehnman 3ce8c29982 Allow DXF import of 3D arcs and circles
Extrusion direction (normal) of arcs and circles were not taken into
account when importing.

- Add method for calculating a quaternion from extrusion direction
  according to DXF arbitrary axis algorithm
- Add required workplanes for arcs not on XY origin plane
- Adjust addDimRadial and addDimDiametric to include normal when
  creating associated circle request
2020-10-01 12:59:43 -04:00
phkahler 8cf9d68ecf IDF file Linking.
Can read PCB outlines and cutouts, as well as Pin and Mounting holes. A simple PPCB model sans components is added to the assembly.
2020-09-30 14:20:35 -04:00
phkahler 0a061b6f9e NFC: Performance. For step-and-repeat groups, create the copies first (in parallel) and then combine them using unions of equal size shells to reduce the total time spent on booleans. 2020-09-22 16:30:03 -04:00
phkahler d49c8a1aef add debug message showing the name of a group whose linked file can't be found. 2020-09-22 15:28:17 -04:00
phkahler 39f419e28c Flip sign of exportCanvas dx and dy. Fixes issue #523 2020-09-20 19:54:26 -04:00
phkahler 704bb4a3be Fix view centering and directions or cli thumbnail function. 2020-09-19 15:03:01 -04:00
Christoph Dittmann 34328c9756 solvespace-cli: Fix --view
This fixes issues #499. The --view option changes projUp and
projRight. For --view to affect the camera, the camera needs to be
initialized using these values.
2020-09-18 21:15:53 -04:00
phkahler 6e515b6735 Fix 699: Allow dragging linked objects in an assembly. 2020-09-17 17:55:04 -04:00
phkahler 094eff755b Fix 197 Update the state of checkboxes in menus after failed workplace activation. 2020-09-17 11:34:22 -04:00
phkahler 668fe6f493 Make the redundant constraint timeout a configuration value and add the config UI elements to edit that value. 2020-09-16 16:39:43 -04:00
phkahler 615708440f Fix #131. Prevent UI freeze by having a timeout when finding which constraints can be removed to fix jacobian. 2020-09-16 16:39:43 -04:00
phkahler e74185b639 Fix #696. Account for multiple coincident edges when looking for naked edges. 2020-09-14 12:07:17 -04:00
phkahler d8f5a8da32 Fix issue #296.
We need to recognize two consecutive bridges as a non-ear.
2020-09-08 18:54:02 -04:00
phkahler 705249627a Fix #693 issues.
This set of changes covers all triangulation errors in issue 693. A point coincident with a triangle vertex is OK and needed for bridges, but sometimes the middle point has edges cutting through the triangle that make it a non-ear. We fix that and a couple of off-by-one error (that fixes one of the test cases).
2020-09-08 18:54:02 -04:00
phkahler 0413c1b926 NFC:Triangulation - don't add zero-length bridges to avoid list. 2020-09-08 18:54:02 -04:00
phkahler b208cd8cae NFC, Performance: Use OpenMP for boolean function MakeItersectionCurvesAgainst.
This is the last long-running single-threaded part of the boolean code. On one test model this took Regenerate form 27 seconds down to 18s. The critical sections needed a name (into) because that object must not be modified while in use in different places.
2020-09-06 12:43:24 -04:00
nabijaczleweli 360b347ad7 Export backgrounds in vector files
VectorFileWriter::Background() is an empty impl, except that it writes
  * a rectangle the size of the output for EPS and PDF, and
  * a <style> element setting background-color for SVG

Ref: #525
2020-09-05 20:58:07 -04:00
nabijaczleweli 028b613f10 Add ExportBackgroundColor config to GUI and CLI 2020-09-05 20:58:07 -04:00
phkahler d3da2c8b22 Performance: Don't call std::inplace_merge for IdList::AddAndAssignID() via Add() because it is redundant. 2020-08-29 15:34:48 -04:00
phkahler 6894b0c9c3 NFC: remove a critical section, runs faster. 2020-08-19 17:55:42 -04:00
phkahler d974615d0e NFC replace 2 nested loops with 1 loop and a lookup for speed improvement. 2020-08-19 17:55:42 -04:00
phkahler bc4924ae47 Don't duplicate points when connecting contours with zero length bridge. Fixes #303 2020-08-14 16:39:09 -04:00
phkahler 04b332dfd0 Ratpoly - Less noise in terminal. Comment out expected dbg print and try harder to converge. 2020-08-13 16:56:18 -04:00
Paul 4cceaa5310 NURBS boolean improvement.
The 3-plane intersection code fails to converge when a curve joins two tangent NURBS patches. This adds a new function for intersecting exact curves with a surface to avoid those failures. Fixes simplified test model for issue #315.
2020-08-13 16:56:18 -04:00
phkahler f9529916c4 Fix issue161 and 174. Use the same logic for selction and dragging, but ignore entites that are inherently undraggable.
This allows the selection to reach through entities to their corresponding ones on the underlying sketch which can be dragged if they are not fully constrained. This is decided in a new function Entity::CanBeDragged().
2020-08-09 19:55:33 -04:00
phkahler 575ddb5aaa Add a pass in triangulation to create convex triangle fans. These triangles will have smaller bounding boxes and look better. 2020-08-07 15:47:01 -04:00
phkahler b3eb589240 Fix issue659 - Problems constraining to ends of Helix.
Create a new copy type for faces that includes the translation aspect of helical extrusions. Also swap the end remappings when the shell is inside out - this was also affecting some Revolve extrusions.
2020-08-07 15:16:47 -04:00
whitequark a2962207dd Improve text screen for a selected entity.
* Add a link to its request, unless it's the first entity in that
    request (which would just select the same entity again).
  * Add a link to its group.
  * Add a link to its workplane.
  * Add a link to its style; and hide the style row for entities that
    aren't stylable.
  * Show constraints and measurements (reference constraints) in
    separate lists.
  * For curve entities, show constraints that apply to the points
    related to the curve, not just to the curve itself.
2020-08-07 18:06:42 +00:00
whitequark afa9e2890e Improve text screen for a selected constraint.
* Show the type of a constraint.
  * Show the workplane a constraint is in, for constraints which can
    be both projected to workplane or be free in 3d space.
  * Clearly distinguish reference from non-reference constraints.
  * Add a checkbox for toggling the reference option.
  * When showing requests a constraint applies to, highlight on hover
    the specific entity being constrained, not just the first one.
2020-08-07 18:06:42 +00:00
phkahler fef6a39a17 Don't init srand(0) because rand isn't used any more. 2020-08-03 15:41:47 -04:00
phkahler 3c2f82b7f1 Remove the Random() function and use a fixed table of arbitrary vectors in raycast.cpp
This also fixes issue #666.
2020-08-03 10:30:54 -04:00
phkahler fd2dfe87f6 Fix #656 by making SSurface::SplitInHalf thread safe.
SSurface::SplitInHalf was modifying the surface and then restoring it at the end. Make temporary copy instead.
2020-08-01 11:52:20 -04:00
whitequark d8b76ef7f1 Drop backtrace generation.
This has been completely broken since 2018 (commit a93283df), and no
one noticed, so it probably wasn't useful. Instead of fixing it, just
drop the feature and a bunch of odd nonportable code.
2020-07-28 14:56:55 +00:00
whitequark bbf402bfe3 Fix "Sketch → In Workplane" not updating the UI immediately. 2020-07-28 14:10:19 +00:00
whitequark 56e2592e2a Make "Toggle Reference" remember undo state.
Turning a reference dimension into a constraint one can make
the sketch unsolvable, which suggests Edit → Undo, which would undo
either too much or nothing at all.
2020-07-28 13:12:14 +00:00
phkahler e0fa99bad4 remove another redundant pass checking earness 2020-07-22 10:27:01 -04:00
phkahler 2640034124 NFC: Remove a redundant pass over all verticies in ear triangulation. 2020-07-22 10:27:01 -04:00
whitequark b0fc1912ea Create mimalloc heaps only when necessary.
The mimalloc temporary heap is a thread-local object that uses RAII
to manage heap lifetimes even in threads that are created implicitly,
e.g. by OpenMP. However, not all threads are necessarily created by
the application; graphics drivers may create their own threads, and
this can lead to deadlocks when combined with library unloading.

Fixes #657.
2020-07-22 11:05:01 +00:00
phkahler 188b2e26ce Implement #524 Allow flat colors. Adds an edit control for Ambient lighting. 2020-07-18 02:15:41 +00:00
phkahler c75b2e473e Fix #647 Helix mesh defects.
Use the grid spacing algorithm for helical curve PWL creation.
This makes the grid and trim curves have similar spacing.
2020-07-12 19:09:26 -04:00
наб c4ca4be91e Replace {Alloc,FreeAll}Temporary() with mimalloc
The heaps are wrapped in a RAIIish thread_local handler,
since being affined affined to a single thread for allocations is
required by the API

Ref: #642
2020-07-12 02:37:07 +00:00
наб cbac182edf Add and build mimalloc at 07c6e60a5a3bd7de09e4a170cd97bafba59cfafd 2020-07-12 02:37:07 +00:00
phkahler 9802b5d1ee Better helical triangulation - issue 489.
Resolve issue #489 helix has stairsteps.
Force helix axis line to 8 segments.
Grid triangulation to use a minimum of 4 segments for degree>1.
Adds twist dependence for grid triangulation with degree=1.
Added a max_dt parameter for PWL creation and use that for helical edges.
2020-07-11 14:29:18 -04:00
whitequark 211ae8c446 Show area of closed contour with SI units.
Similar to the way that Analyze → Measure Area... works.

Fixes #639.
2020-06-23 02:39:57 +00:00
whitequark 35c6af4929 Show center of mass using the same format as for constraints. 2020-06-23 01:16:58 +00:00
whitequark 586b0477d2 Delete all entities on a workplane request that is being deleted.
Fixes #628.
2020-06-23 01:05:51 +00:00
whitequark d238f985fb GTK: filter events more precisely.
Turns out that GDK_MOD2_MASK, at least on some systems, corresponds
to NumLock. Use the function provided by GDK to handle this.

Fixes #634.
2020-06-21 01:59:30 +00:00
whitequark 0da4a6b78a Use C++11 [[noreturn]] attribute instead of GNU-specific one. 2020-06-19 01:04:01 +00:00
phkahler 3d51b3949b Change default chord tolerance (to 0.1%) and maximum segments (to 20).
See the discussion in #627 for details.
2020-06-14 05:20:23 +00:00
phkahler c876104714 Make sure circles have at least 16 segments.
Before this commit, with the highest chord tolerance settings, circles
would render as octagons, which confused a lot of people. See #295.
2020-06-14 05:13:50 +00:00
phkahler e83e48392e Change criteria for short edge removal 2020-06-11 21:23:01 -04:00
phkahler 94a3cfdeb7 Fix SSurface::EdgeNormalsWithinSurface() to handle non-orthogonal u,v derivatives correctly. 2020-06-06 02:31:01 +00:00
whitequark 225f82a292 Get rid of the FPS counter.
The counter was added solely as a debug feature in commit e7c8c1c8,
which introduced the new Canvas system. It doesn't work all that well
and brings little value, so let's get rid of the visual noise.
2020-05-31 17:04:03 +00:00
phkahler 89e6559e2d Bring some parallelism to boolean code 2020-05-22 22:32:02 -04:00
whitequark c89a2e4f62 Use a thread-safe temporary arena on every platform.
This commit continues the work started in commits 521473ee and
e84fd464 that parallelizes certain geometric operations. This commit
cleans up the temporary arena implementations and makes them
thread-safe.

Also, in commit 521473ee, a call to FreeAllTemporary() was added
during initialization to create the heap on Windows. This is now
not necessary as the heap is created transparently on the first call
to AllocTemporary().
2020-05-22 18:06:22 +00:00
whitequark 72d9978cac Eliminate a trailing dot before the SI prefix if there are no decimals.
Fixes #617.
2020-05-21 11:22:37 +00:00
whitequark 51f62362a1 Simplify MmToString. NFC. 2020-05-21 11:22:37 +00:00
ruevs 70ec7cc257 Improve triangle mesh (splitting of quads based on angle).
When checking the dot product of the tangents `tu` and `tv` to decide
in which direction to split a quad compare it to to LENGTH_EPS instead
of zero to avoid alternating triangle "orientations" when the tangents
are orthogonal (revolve, lathe etc.).
This improves the quality of the resulting triangle mesh.
2020-05-12 18:39:25 -04:00
phkahler 23dfd97285 Fix use-after-free in Lathe, Revolve, and Helix. Issue #611. 2020-05-12 16:12:09 -04:00
whitequark 0be42a8b29 Rename our isnan() function to IsReasonable().
Commit ea6db67 added an unusual isnan macro:

  #define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))

Commit 8bc322e adds a preprocessor guard that looks like it would
cause the isnan function from math.h to be preferred, but doesn't
actually do that on many platforms, e.g. glibc:

  #ifndef isnan
  #   define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))
  #endif

This commit renames our isnan() to make it clear that it differs
from the standard library operation, and makes it a function.

Fixes #603.
2020-05-12 14:08:21 +00:00
Maximilian Federle 771086fa50
Use C++ instead of C versions of standard library headers.
We use std::fabs, but <math.h> doesn't provide it; it worked by accident.
Include <cmath> that provides std::fabs, and switch all other headers to
their C++ variants, too.
2020-05-12 13:49:19 +00:00
phkahler e84fd4649b
Use omp critical to simplify parallel triangulation. NFC. 2020-05-11 18:57:02 +00:00
phkahler c355a4730a Split quads based on angle. 2020-05-11 13:54:04 -04:00
ruevs 1930602e0a UI: split "union assemble" and "difference intersection" on two lines. 2020-05-10 17:11:19 -04:00
ruevs 9b07aaf262 UI: Fix the logic for switching between union/assemble and difference/intersection
The logic that is flipping the extrusions was working by chance.
2020-05-10 17:11:19 -04:00
ruevs 6245c63f2e Intersection boolen in triangle mesh mode is properly implemented
In addition the union operation in tiangle mesh mode is changed
to keep coplanar faces the same way as the NURBS union does.

Finalizes: https://github.com/solvespace/solvespace/issues/35
2020-05-10 17:11:19 -04:00
ruevs 3888909d02 NURBS: Add intersection boolean operation.
The NURBS operation is properly implemented.

ToDo: The mesh operation in SMesh::MakeFromIntersectionOf
is still done as C=A-(A-B).

Implements: https://github.com/solvespace/solvespace/issues/35
2020-05-10 17:11:19 -04:00
ruevs cd30e04134 Expand "edit newly added dimensions" to edit "Length Ratio" and "Length Difference" 2020-05-10 11:50:51 +00:00
ruevs 01af666696
Fix typo. NFC. 2020-05-10 11:35:21 +00:00
whitequark d857e3e9cd Various header cleanups. NFC.
* Don't use a reserved identifier in include guards.
  * Use fabs() from <cmath> instead of our own ffabs().
    This shouldn't make any difference with modern toolchains.
  * Convert a few preprocessor macros to constexprs.
2020-05-10 09:24:12 +00:00
whitequark e00d4867e1 Refactor dbp. NFC.
After this commit, dbp() is renamed to DebugPrint() and moved to
platform.cpp, next to other similar functions. The existing short
name is provided by a preprocessor macro, similar to ssassert().

This leaves just the (rather hacky) temporary heap in util*.cpp.
2020-05-10 08:54:12 +00:00
whitequark 9951da8965 macOS: ignore spurious `-psn_` command line argument.
Fixes #602.
2020-05-10 08:30:01 +00:00
whitequark 1442ee5ec3 Refactor InitPlatform.
This commit performs three related cleanups:
  * The slvs library no longer uses explicit platform initialization
    (which drags in the side effects of InitPlatform that are not
    desirable in a library). Instead, it just ensures that it has
    the temporary heap, which is what it was callingInitPlatform for.
  * InitPlatform is simplified and moved to platform.cpp, next to
    other path related functions.
  * InitPlatform is renamed to InitCli and is called from InitGui
    implementations. GUI toolkits sometimes have options they use
    internally (that's the case for for GTK and Cocoa at least),
    and we shouldn't try to parse those as a file to open.
2020-05-10 08:29:25 +00:00
whitequark 9c1804b1b5 Get rid of MemAlloc/MemFree.
After commit 521473ee there's no point in keeping these around.
Instead, use the same heap in containers as the C++ standard library.
2020-05-10 06:11:53 +00:00
whitequark 521473ee4b Win32: use CRT heap instead of our own.
Historically SolveSpace used its own heap on Windows since it gave
better control and debugging options, but a lot of development these
days happens on Linux, where that heap was a stub around malloc/free,
and also Windows debugging tools got a lot better.

In terms of immediate benefit, this commit fixes heap corruption
on Windows introduced in commits b4e1ce44 and 47e82798, caused
by allocating with HEAP_NO_SERIALIZE in parallel from OpenMP threads.
Without HEAP_NO_SERIALIZE there's no performance benefit to keeping
our own heap, either.

The vl() function is also removed because for development there are
better tools now, and the only place where it was permanently called
from became a no-op, since temporary heap always validates after
FreeAllTemporary() recreates it.
2020-05-10 05:35:42 +00:00
whitequark 47e82798da CMake: detect OpenMP and use if available.
This is a missing part of commit b4e1ce44.
2020-05-09 19:46:16 +00:00
phkahler b4e1ce44e8 Use OpenMP for triangulation 2020-05-09 13:54:52 -04:00
phkahler 7baf58588b No message if cached points to don't converge. Quiet the terminal. 2020-05-08 22:18:30 -04:00
phkahler a7e0a174e3 Don't create redundant edges in UvGridTriangulate into. 2020-05-08 13:24:36 -04:00
phkahler a52d88bc3d Less work in AssembleContour 2020-05-06 18:38:58 -04:00
phkahler 88a0e55f35 Eliminate infinite loop AssemblePolygon 2020-05-06 18:38:58 -04:00
phkahler 7366a6c53d
Bernstein polynomials with no branching. (#591) 2020-05-02 14:56:50 -04:00
phkahler f36ac500a1
Add rotated face from point entity type. Fixes issue 585, problems constraining to Revolve and Helix ends. (#586) 2020-04-24 17:37:55 -04:00
phkahler 700b5d6719
Allow Revolve and Helix end surface selection and constraints. (#584) 2020-04-22 19:55:18 -04:00
phkahler 45eb246865
Eliminate some entity copies in lathe groups. Eliminates a crash due to copy numbers going over 1000. May break some older files with constaints on lathed entities. (#582) 2020-04-21 00:44:27 -04:00
phkahler b55dac7620
Don't create extra copies of entities in Revolve and Helix groups.
Might break some older files with those groups that depend on these
extra entities.

Fixes #549.
2020-04-21 01:24:33 +00:00
Ryan Pavlik e51fdf6fba Use handles instead of pointers in GenerateAll(). NFC. 2020-04-20 18:37:03 +00:00
Tim 72635df56e
Add menu options for line styles / view / configuration.
This is to make them a bit easier to find, since the natural place
to look for config options is somewhere like File->Preferences or
Edit->Settings.
2020-04-01 21:25:18 +00:00
Tim 647171017a
Fix more segfaults in mouse.cpp lambdas (#574)
This changes all the lambdas to have explicit captures, since the use of
implicit captures has led to some memory errors, especially segfaults in
the right-click menu.

I'm not 100% sure that the code is correct anyway - it really needs auditing
to ensure all referenced values are still valid when the menu item is clicked
(e.g. can you change stuff with keyboard shortcuts while the context menu is
visible?), but it should at least be *more* correct!
2020-03-29 01:46:34 +00:00
Tim 485fd012b4
Fix segfault in Remove Spline Point context menu
This was incorrectly capturing `r` by reference and using it after it left
its scope. Changed to  capture by value, and also explicitly capture `this`
in case we were accidentally capturing any other scope variables by reference.

Fixes #571
2020-03-28 15:28:12 +00:00
phkahler f7b6f6930e
Nurbs (#473)
* Limit u,v range between 0 and 1 in Newton. Fixes issue #471
* Change the math for projecting a point onto a plane to work better with non-orthogonal U,V derivatives in several places. Fixes #472.
2020-03-27 15:40:58 -04:00
Roc a6c34bb44d
Fix a crash when trying to show an error with bad separator.
For example, a single dot or colon at the end of the error string.
2020-03-12 23:03:26 +00:00
nabijaczleweli 6017ecdacc Fix two trivial implicit double to int conversion warnings. NFC 2020-03-08 16:33:55 +00:00
ruevs fcb2757d5d Win32: Drastically reduce stack usage at startup. NFC?
See:
https://github.com/solvespace/solvespace/issues/92#issuecomment-567831112

The problem was first introduced here:
dabd57847e

and later "fixed" here:
f324477dd0
by setting the stack size to /STACK:33554432

Solvespace now starts up even with /STACK:554432

According to this:
https://en.cppreference.com/w/cpp/language/value_initialization
```
"2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; "
```
So removing the `{}` should leave both the `System` and `TextWindow` class instances properly initialized.
2020-02-24 08:41:45 +00:00
ruevs 8ef3cacc33 Fix a bug with 3Dconnexion: SpaceMouse
A warning found with /W4 by MSVC 2019 (Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314)
is an actual bug. How does the SpaceMouse (I do not have one) work at all when the global `hSpaceWareDriverClass` is NULL?!

.\src\platform\guiwin.cpp(1392,34): warning C4459: declaration of 'hSpaceWareDriverClass' hides global declaration
.\src\platform\guiwin.cpp(1389,13): message : see declaration of 'SolveSpace::Platform::hSpaceWareDriverClass'
2020-02-20 14:03:31 +00:00
ruevs f6a774d7bf Fix some trivial warnings found by MSVC. NFC.
Found with /W4 by MSVC 2019 (Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314)

A bunch of implicit casts 'double' to 'float' and one 'int64_t' to 'unsigned'.

.\src\platform\guiwin.cpp(1237): warning C4701: potentially uninitialized local variable 'cursorName' used
.\src\platform\guiwin.cpp(1237): warning C4703: potentially uninitialized local pointer variable 'cursorName' used

.\src\solvespace.cpp(805,30): warning C4456: declaration of 'gs' hides previous local declaration
.\src\solvespace.cpp(715,17): message : see declaration of 'gs'

.\src\solvespace.cpp(849,47): warning C4456: declaration of 'e' hides previous local declaration
.\src\solvespace.cpp(847,29): message : see declaration of 'e'

.\src\render\render.h(288,51): warning C4458: declaration of 'camera' hides class member
.\src\render\render.h(271,17): message : see declaration of 'SolveSpace::SurfaceRenderer::camera'

.\src\render\render.h(289,57): warning C4458: declaration of 'lighting' hides class member
.\src\render\render.h(272,17): message : see declaration of 'SolveSpace::SurfaceRenderer::lighting'
2020-02-20 14:03:31 +00:00
Koen Schmeets 3ed1719de2
Fix immediate editing of reference constraints.
Before this commit, if immediate editing of constraints was enabled,
then when adding a reference constraint, an editor was incorrectly
opened.
2020-02-05 05:34:33 +00:00
ruevs 16c5fa6889 Fix eight trivial "implicit conversion 'double' to 'int'" warnings. NFC. 2019-12-17 19:35:44 +00:00
whitequark 64c0f62b92 Win32: mark all remaining functions as Unicode. NFC.
Some were missing the *W suffix.
2019-12-06 15:21:51 +00:00
Koen Schmeets 0472b9ea60 macOS: fix tooltips not closing on Catalina. 2019-11-27 12:51:27 +00:00
Koen Schmeets dcdfdec564 Add an option to edit dimension immediately after adding. 2019-11-26 22:34:53 +00:00
Koen Schmeets 58f23aa061 macOS: force show property browser when opening preferences from menu. 2019-11-26 20:31:14 +00:00
Koen Schmeets 552fe354aa Fix commit 07992cecaa. 2019-11-26 14:34:30 +00:00
whitequark 0501f0c99e Don't call GL functions in OpenGl3Renderer::GetIdent.
GetIdent is called from an UI event callback, at which point there
might well not be an active GL context. Before this commit, that
would return a NULL pointer and result in a crash.
2019-11-26 11:23:37 +00:00
whitequark 07992cecaa Remove unused offscreen GL renderer.
This was used for Gtk 2 and old macOS, but all of those use direct
rendering now.
2019-11-26 11:23:37 +00:00
whitequark 14e095c93a Don't show unusable fonts in font selector.
Before this commit, certain fonts (e.g. Terminus) would appear in
the selector but cause a crash (assertion failure) if they are used.
After this commit, we make sure all preconditions are met before
showing a font there.

Also, improve error reporting to always print font filename.
2019-11-23 16:17:01 +00:00
whitequark e74137dc67 Fix misuse of glTexImage2D (again).
This was originally changed in 74aa80b6, but the fix broke stipping
because it incorrectly changed the logic. Revert that, and just make
the textures smaller instead.
2019-11-23 15:56:57 +00:00
Ryan Pavlik 2fe17a46c2 Remove prototype for an unimplemented function. 2019-11-23 15:35:51 +00:00
Ryan Pavlik 38f42871c7 Remove an integer cast. 2019-11-23 15:35:39 +00:00
Ryan Pavlik 93184c54ac Use standard std::count_if. NFC. 2019-11-23 15:35:29 +00:00
whitequark 8c750cef9c Freeze the scrollbar while editor is open in property browser.
Before this commit, the scrollbar would move freely, without changing
the position of the viewport. It would be reset after editing is
finished.
2019-11-23 15:34:52 +00:00
whitequark f0359556d8 Recompute property browser viewport on resize.
Before this commit, resizing the property browser would cut off
the rows at the bottom, or else add black space, until next refresh.

This could be perhaps more elegantly done by adding an onResize event
but given that each of them would be followed by onRender anyway, it
seems there's no benefit to adding onResize.
2019-11-23 15:04:31 +00:00
whitequark 54015b6777 Call glGetError() after glFinish(), not glFlush().
As I understand it, both glGetError() and glFinish() are serializing
and blockig, so it makes more sense to call them at the same time.
glFlush() does not block.
2019-11-23 14:50:19 +00:00
Thomas Roughton 9b61f988be macOS: Don't use offscreen rendering.
Since Catalina or earlier this no longer causes artifacts when Cocoa
controls are overlaid on a GL layer. Conversely, offscreen rendering
is very slow, especially on HiDPI screens.

Co-Authored-By: Koen Schmeets <hello@koenschmeets.nl>
2019-11-23 14:50:18 +00:00
Ryan A. Pavlik e386d405d6 Make some arguments const/const references, where possible. NFC.
Found and suggested by clang-tidy.May help performance by reducing copies,
depending on frequency of call, etc.
2019-11-23 14:07:31 +00:00
whitequark 65d0bdffdb Split Canvas::FinishFrame out of Canvas::FlushFrame.
When drawing the graphics window, we flush it twice: once to draw
the geometry, and another time to draw the UI overlay (toolbar,
selection marquee, and FPS counter). Calling glFinish() each time
is (on most platforms) just pointlessly slow, but on macOS Catalina,
without offscreen rendering, it causes the toolbar to flicker.

Instead of calling glFinish() twice per frame in that case, call
glFlush() twice and then glFinish() once we really are done.
2019-11-23 13:35:16 +00:00
ruevs ec3056773e Simplify UNION and DIFFERENCE boolean operations.
Union and difference are optimized by replacing the expression
  (!inShell && !inFace)
which is equivqlent to
  (!inShell && !inSame && !inOpp)
with
  outSide
which is equivalent, since SShell::Class::OUTSIDE is the only remaining possibility.
2019-11-23 13:22:15 +00:00
Koen Schmeets 0dcc8f3369 Fix Xcode auto-fixable issues 2019-11-23 13:08:22 +00:00
whitequark 74aa80b645 Fix misuse of glTexImage2D.
Per the OpenGL documentation:
> GL_INVALID_VALUE may be generated if level is greater than
> log2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE.

Although we always passed `log2(max) + 1` as `level`, for some reason
none of the GL implementations we run on ever returned an error.
It also appears there is a bug in ANGLE that crashes the process
instead in this case if the C++ runtime performs bound checks on
vector::operator[]=.
2019-11-22 02:11:10 +00:00
phkahler 5d78f993ce Make helix origin create a line even if it's in a different group.
Helix should always make a line for the axis.
2019-09-20 01:09:58 +00:00
phkahler 162897eca7 Reimplement DivPivoting as DivProjected.
The old implementation was an approximation, whereas the new one is exact.
2019-09-20 01:09:25 +00:00
EvilSpirit 7f9117b2bf Calculate area of selected faces, if any. 2019-09-11 10:38:10 +00:00
EvilSpirit 915f55aabc Show volume of current group alongside total volume. 2019-09-11 10:38:10 +00:00
Ryan Pavlik a0e992374d Clean up virtual, override, default, and void params. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik ae417fc14c Use emplace_back. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik 34dccbf935 Don't call static methods through an instance. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik b1e280e75f Fix undefined behavior in IdList::end(). 2019-09-11 09:44:30 +00:00
Ryan Pavlik bedea1ef3c Avoid undefined behavior from out-of-range access. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik b8ee0e941b Remove extraneous semicolon. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik 78819ffca3 Fix "virtual function without virtual destructor" warning. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik c959af1149 Fix a comment. NFC.
Found by clang-tidy.
2019-09-10 06:44:34 +00:00
Ryan Pavlik 3e566d7e67 Remove std::move from trivially-copyable types. NFC.
Found by clang-tidy
2019-09-10 06:44:34 +00:00
Ryan Pavlik c0904e2ba8 Use IsEmpty() or .empty() to check if a container is empty. NFC.
Most found by clang-tidy.
2019-09-10 04:22:21 +00:00
Ryan Pavlik 61c0167ad7 Fix TTF iteration in case of an empty list. 2019-09-10 04:22:07 +00:00
Ryan Pavlik 15838dc5a1 For loop cleanup. NFC. 2019-09-10 04:21:57 +00:00
Ryan Pavlik 231dff6cd9 Add and use List::Last(). NFC. 2019-09-10 04:20:38 +00:00
whitequark c5f3cd151a Use the same @todo hot comment style everywhere. 2019-09-10 04:07:42 +00:00
Ryan Pavlik d514a26f92 Fix use-after-free in revolve and helix.
Pointers get invalidated if a list has to be re-allocated.
CopyEntity can do that.
2019-09-10 04:07:42 +00:00
Ryan A. Pavlik a4c0022815 Fix a warning about a virtual destructor. 2019-09-10 03:33:05 +00:00
Ryan A. Pavlik 43b2261e9c CLI/testsuite: do not crash if a dialog is displayed. 2019-09-10 03:23:31 +00:00
phkahler 22e4011cb6 use std::vector in helix operations instead of fixed length array. Remove limit on number of sections. Delete definition of Revolved struct. 2019-08-25 14:30:37 +00:00
phkahler e22c522c81 use std::vector in lathe operations instead of fixed length array 2019-08-25 14:30:37 +00:00
phkahler 2dd50d0f3a Only allow lathe, revolve and helix for 2d sketches. 2019-08-25 14:30:37 +00:00
Ryan Pavlik 13820bf27d Revert "IdList::RemoveTagged switch to std::remove_if from iteration. NFC."
This reverts commit 0bb6a348e3.
2019-08-20 23:28:43 +00:00
Ryan Pavlik b284e80785 Improve NextAfter. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 533ca618eb Fix a manual manipulation of List::n. NFC.
This broke encapsulation and thus caused problems for any deeper changes
to List.
2019-08-20 15:57:11 +00:00
Ryan Pavlik dd738dd1fc Add Last(). NFC.
Counterpart of First().  standard library calls this "back()".
2019-08-20 15:57:11 +00:00
Ryan Pavlik 610e35f6dd Improve Clear(). NFC.
Was getting segfaults near here with another patch since removed from the branch.
Moving these assignments after the memfree means they still have
useful data when debugging a crash in memfree.
2019-08-20 15:57:11 +00:00
Ryan Pavlik b9d035c805 Improve MoveSelfInto. NFC.
std::swap is an idiomatic way to do a move.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 9fd09ddd8a Add IdList::AllocForOneMore() based on List. NFC.
Also modifies a sizeof call.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0bfbbe2bf3 Improve implementation hiding in IdList/List. NFC.
Allows distancing users from the internal "elem" member.

Add Get() and operator[].
Replace direct references to elem.
Make elem and elemsAllocated private in IdList/List.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 482f0e8de9 Replace qsort with std::sort and lambda. NFC.
Removes static variable usage, permits hiding of the underlying pointer
(std::sort uses iterators intead), type safety, etc.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 1b97a006e9 Add and use List<T>::IsEmpty, range-for, etc. NFC.
Changes resemble those already made to IdList.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0bb6a348e3 IdList::RemoveTagged switch to std::remove_if from iteration. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 3ea077b70f Reduce scopes and placate clang-tidy. NFC.
Pointing out one potential issue with an assert.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 60fdac141d Simplify IdList::Add(). NFC.
Offloads most of the work onto standard algorithms to make it
more self-evidently correct.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 3340392bf0 Add and use LowerBound methods in IdList. NFC.
Clearer and less error-prone to use standard-supplied algorithms.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0c941aedb1 Revise IdList::Tag to reduce code duplication. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 5ada4dbd9c Add and use IdList::IsEmpty. NFC.
Removes consuming code from the implementation details, easing swap of
the underlying container, etc.
2019-08-20 15:57:11 +00:00
Ryan Pavlik b5f36a4f01 Provide cbegin(), cend() in containers. NFC.
Allows forcing const iteration.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 86f20cc7e5 Convert many loops to range-for or std algorithms. NFC.
Also add comments about indexing and when we don't use range-for.
2019-08-20 15:57:11 +00:00
whitequark 97c8cb7d71 Make sure changing color of a group does not reset alpha. 2019-08-12 08:52:51 +00:00
nabijaczleweli d9081b0b08 VRML: add support for transparency. 2019-08-09 23:32:24 +00:00
nabijaczleweli 837628ea3e Add VRML (WRL) triangle mesh export.
Transparency is not supported.
2019-08-09 21:30:33 +00:00
phkahler 986da7d224 Implement helical extrusion groups. 2019-07-31 04:16:56 +00:00
whitequark b3f739f2c4 Improve layout for reference axes with very vertically small windows. 2019-07-12 11:23:28 +00:00
Ryan Pavlik b2af9cee6c Use the fact that handles are now less-than comparable. NFC. 2019-07-10 15:40:21 +00:00
Ryan Pavlik 5efb09e6d4 Use the new equality/inequality operators of handles to reduce references to .v. NFC. 2019-07-10 15:40:21 +00:00
Ryan Pavlik 7bd4b149f7 Traits work for handles to permit sharing functionality and operators. NFC. 2019-07-10 15:40:21 +00:00
phkahler 346f004e51 Brighter blue and yellow in text window for higher contrast/readability. 2019-07-09 00:48:06 +00:00
whitequark 02d7f0c0aa Auto-recover files corrupted by the bug in commit bd84bc1a. 2019-06-25 00:48:57 +00:00
whitequark 49a7f863b8 Fix off-by-1 in Group::Remap.
This was introduced in bd84bc1a and caused crashes with:
  Assertion failed: hm.v != t->h.v.
2019-06-24 22:59:34 +00:00
phkahler 5df53fc59e Implement revolve groups. 2019-06-03 17:32:38 +00:00
whitequark 3d80062b66 GTK: delete all gtkmm objects before destrying Gtk::Main.
Otherwise this results in harmless but annoying spam on applciation
shutdown.

See https://gitlab.gnome.org/GNOME/gtkmm/issues/22.
2019-05-31 23:07:04 +00:00
whitequark 359697990a Update q3d submodule. 2019-05-31 23:07:04 +00:00