Hacker News new | ask | show | jobs
by tgirod 3538 days ago
I've been using this software quite extensively to design a small 25m2 house I'm building earlier this year. It can be a bit rough around the edges, but it's already quite usable and powerful!

IMO the main issue is that the constraint solver recomputes everything whenever you add/move something, even though past additions are already properly constrained. As a result, the software gets less and less responsive as your design gets more complicated. I don't know if the devs adressed that issue (it's a tough one), but I know it was already on the radar a few months ago.

2 comments

Does it get as bad as OpenSCAD? I found that anything even remotely complex using OpenSCAD brings the machine down to a crawl. And I'm on an overclocked 5930K with 64GB ram ;-)

I'd be very curious to see a couple screenshot of your project! I used Google Sketchup to do landscaping last year around my house; I wonder how this would compare...

sketchup plan: https://goo.gl/photos/Qc5mEnFiFm9UWBvv8 reality: https://goo.gl/photos/Gn66MSc8UPshR3CC8

Here you go!

http://imgur.com/a/LOBge

The design is a bit crude, but the goal was to get the structure's dimensions right. And it worked!

http://imgur.com/a/rCZfk

Try throwing render() around heavy blocks of code. That should speed up successive renders quite a bit.
Have you tried freecad? I think it uses openscad as backend but has a slightly better (and faster) UI.
It uses Open Cascade: https://www.opencascade.com/
I don't know if the devs adressed that issue (it's a tough one)

If these are linear constraints, maybe they can use the "Cassowary" incremental solver.

[1] http://overconstrained.io/

In the current solver, the constraints are linearized. It's not especially complex (just 500 LOC, not counting the symbolic algebra system that feeds it) or clever, but it does the job: https://github.com/solvespace/solvespace/blob/master/src/sys...

We've been planning to evaluate Eigen for a while, but I will also look at Cassowary, thanks!

That being said, depending on the sketch, often the vast majority of the time SolveSpace is calculating after dragging something is spent not in solver, but rather regenerating geometry, and that's harder to optimize.

"Constraint" means something different to Cassowary than it does to us here, and isn't obviously useful. An optimized matrix library (Eigen, BLAS, LAPACK, etc.) would provide a modest speedup without too much work.

So yeah, the constraints in SolveSpace are nonlinear. They're solved by a Newton-ish method, which for underconstrained sketches also minimizes at each step the sum of the squares of the distances that any un-dragged points move (plus some other stuff). The Jacobian matrix is computed by an internal symbolic algebra system, allowing considerable flexibility in the range of user-facing constraints without a combinatorial explosion of hand-coded special cases.

As whitequark notes, the final solution of the constraint equations is a relatively small part of the overall work. The difficulty is mostly in writing them, to handle many useful cases in relatively few lines of code, and to converge reasonably in the Newton's method.

For a dramatic speedup, we could partition the constraint equations into roughly-triangular form, and then solve sub-systems in dependency order. Practical sketches seem to have a lot of such structure, and a visualization of that graph would be an interesting expression of the design intent. (To be clear, this isn't a spreadsheet; you still have to numerically solve systems of multiple equations, just not all of your equations at once.) I wrote an earlier solver that did this in some cases, but SolveSpace doesn't at all.

I don't work on Solvespace and therefore don't know for sure, but I suspect they're not linear. In particular, a significant fraction of all constraints in a CAD system like that are of the form "the distance between these two points must equal x", which is a not linear in any of the positions

I'd love to be wrong about this, because this general problem is one I'd be very interested in being able to solve more efficiently.

2d geometric constraints solvers are usually based on BFGS algorithm (https://en.wikipedia.org/wiki/Broyden–Fletcher–Goldfarb–Shan...). This is what we use in Shapr3D for example (http://www.shapr3d.com)