Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SolveSpace crashes on lathe #1279

Open
suhr opened this issue Aug 9, 2022 · 6 comments
Open

SolveSpace crashes on lathe #1279

suhr opened this issue Aug 9, 2022 · 6 comments

Comments

@suhr
Copy link

suhr commented Aug 9, 2022

On Linux, SolveSpace just crashes when lathe tool is used. On Windows, it hangs first, and might crash later.

This is the terminal output on Linux:

Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
Vector::WithMagnitude(1) of zero vector!
trim was empty
trim was empty
trim was empty
trim was empty
trim was empty
trim was empty
trim was empty
trim was empty
trim was emptytrim was empty

trim was empty
trim was empty
trim was empty
trim was empty
trim was empty
File ./src/srf/surfinter.cpp, line 103, function AddExactIntersectionCurve:
Assertion failed: !(sb->Start()).Equals(sb->Finish()).
Message: Unexpected zero-length edge.
trim was empty

How to reproduce

Open keycap.slvs.zip, select a normal and a point and invoke Lathe.

System information

SolveSpace version: 3.1
Operating system: both Windows and NixOS

Additional information

The sketch contains an arc of a quite large circle. But it's required to make a rounded keycap.

@phkahler
Copy link
Member

First I've attached a somewhat fixed version of the file:
keycap.zip
.
I made 2 changes. One is I raised the horizontal line in the 2D sketch and added a new vertical line near the center. This prevents the lathe group from having 2 surfaces tangent to the hex flat surface - a classic tanget-surfaces issue with solvespace. But I also had to leave a flat spot in the middle (which you don't want). You can drag that point radially in the attached sketch to see that at small radius we get a NURBS failure. I'm not sure what's causing that - it could be related to the first failure or something different.

A better work around may be to add height to the hex shape and let the lathe cut the entire top off, so there is no tangency between the lathe-arc and the flat surface.

@ruevs so one duplicate NURBS issue, but also maybe a new one? We should be able to make an even simpler test case for this, but this is a relatively small sketch.

@phkahler phkahler added the NURBS label Aug 10, 2022
@ruevs
Copy link
Member

ruevs commented Aug 10, 2022

I'm not on a PC but looking at the assert I was pretty sure the problem in the original model is a duplicate of #1058.

@phkahler I'll take a look at your model later on a PC and update the tracking issue with both.

@suhr
Copy link
Author

suhr commented Aug 10, 2022

I sort of workarouned this by forcing NURBS to use triangles and decreasing chord tolerance.

@phkahler
Copy link
Member

It's not #1058 because that is due to overlapping surfaces caused by doing lathe on a full circle to create a sphere. This sketch only has entities on the right side of the lathe axis. My first thought was the point on the axis producing NURBS patches with a degenerate edge, but it still happens if we move that point off-axis.

Thought: what would happen if we just skipped adding the zero-length exact intersection curve rather than crashing? Also not sure that test is as robust as it looks (control points are not checked).

@ruevs
Copy link
Member

ruevs commented Aug 27, 2022

I think it is still the same problem since the sphere is tangential to the plane and the thickness approaches zero toward the center.

@ruevs
Copy link
Member

ruevs commented Apr 7, 2023

On the forum a user posted one more reproduction case.

To reproduce open "volumechambredecombustion4.slvs" from the attached archive and lathe "g005-sketch-in-plane" in such a way as to produce the shape in "volumechambredecombustion.slvs".
AnotherLatheZeroLengthEdge.zip

LatheBug

The call stack is as usual:

solvespace.exe!SolveSpace::Platform::FatalError(const std::string & message) Line 182
solvespace.exe!SolveSpace::AssertFailure(const char * file, unsigned int line, const char * function, const char * condition, const char * message) Line 15
solvespace.exe!SolveSpace::SSurface::AddExactIntersectionCurve(SolveSpace::SBezier * sb, SolveSpace::SSurface * srfB, SolveSpace::SShell * agnstA, SolveSpace::SShell * agnstB, SolveSpace::SShell * into) Line 103
solvespace.exe!SolveSpace::SSurface::IntersectAgainst(SolveSpace::SSurface * b, SolveSpace::SShell * agnstA, SolveSpace::SShell * agnstB, SolveSpace::SShell * into) Line 344
solvespace.exe!SolveSpace::SShell::MakeIntersectionCurvesAgainst(SolveSpace::SShell * agnst, SolveSpace::SShell * into) Line 718
solvespace.exe!SolveSpace::SShell::MakeFromBoolean(SolveSpace::SShell * a, SolveSpace::SShell * b, SolveSpace::SSurface::CombineAs type) Line 808
solvespace.exe!SolveSpace::SShell::MakeFromUnionOf(SolveSpace::SShell * a, SolveSpace::SShell * b) Line 13
solvespace.exe!SolveSpace::Group::GenerateForBoolean<SolveSpace::SShell>(SolveSpace::SShell * prevs, SolveSpace::SShell * thiss, SolveSpace::SShell * outs, SolveSpace::Group::CombineAs how) Line 194
solvespace.exe!SolveSpace::Group::GenerateShellAndMesh() Line 407
solvespace.exe!SolveSpace::SolveSpaceUI::GenerateAll(SolveSpace::SolveSpaceUI::Generate type, bool andFindFree, bool genForBBox) Line 277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants