12/27/2023 0 Comments Learn openscadSo I ended up creating a hybrid of Surface_mesh corefinement and Nef operations, reverting to the slow safety of Nefs when we detect it’s likely unsafe to use corefinement ( openscad#4087). For that I had to introduce Surface_mesh (after trying w/ less efficient Polyhedron_3) into OpenSCAD.Ĭorefinement works great in some cases, crashes (sometimes in unrecoverable ways) or politely fails in others (for instance it dislikes non-manifold inputs, or inputs that share edges / vertices). CGAL’s other hidden gem: corefinement functionsĪs some of the extremely friendly and helpful OpenSCAD project maintainers ❤️ pointed out on IRC, there was another option in stock: faster operations using the Polygon Mesh Processing CGAL package (authored by and its “corefinement” functions. I’ve paused this track for now but might explore it again. not true when unioning a swarm of cubes), many other things needed to be taken into account. That search neededs to be bounded (otherwise would be in quadratic time of # of operands randomizing the operands would kind of work well enough), the bounding box operations need to be lighter than the geometry itself (e.g. in a grid of overlapping tiles you can skip a tile to do a fast-union but two consecutive tiles would need a proper union. Searching for good operands to union together is important for many models, e.g. This worked great for some models, but ran into weird performance for others. So I started exploring the “fast-union” route ( openscad#3636), in which I’d literally concatenated meshes if I could determine that they can’t actually intersect with each other based on their bounding boxes. Just concatenating meshes, huh?īut surely I thought, if we just need to assemble a grid of my interlocking patterns without any intersection, it’s just a matter of concatenating the meshes, no special operations needed.Įven for unions, many geometrical operations are required when overlaps / intersections require creating new points, new edges, so as to maintain the topological soundness ( manifoldness) of solids so they can be 3D-printed later, etc. More specifically, OpenSCAD is using 3D boolean operations on Nef Polyhedra, which provides extrely robust and accurate results, two welcome properties in the 3D printing hobby, but also is extremely complex and slow to run (especially with those exact underlying number abstractions). That amazing library allows for completely generic numeric types, and the type OpenSCAD is using is some voodoo magic “exact” numeric type based on the GNU Multiple Precision Arithmetic Library (GMP). CGAL Nef Polyhedra + GMP = so precise it hurts (performance)Īs it turns out, OpenSCAD is using the Computational Geometry Algorithms Library (CGAL) for its CSG operations. Slow enough to prevent me from doing what I wanted, which was to generate large, varying scalemail patterns:īut something was off: my slicer software (Cura) was able to handle 10x10 grids of my scalemail pattern without breaking a sweat, so why was OpenSCAD so slow? So after investigating alternatives (wasn’t keen to get locked in a certain popular but proprietary CAD software with huge a learning curve and high prices after its 1 year hobbyist licenses), I dove into OpenSCAD’s codebase and tried to understand what it was up to. Last year I grew fond of it to design ever more complex models, but started running into limitations: while interactive rendering was fine, the final rendering (creating the STL files to give to the 3D printing slicer) was horrendously slow. A simple declarative programming language defines Constructive Solid Geometry (CSG) operations like unions, intersections, differences, which can be parameterized with loops and variables. It’s essentially a CAD software for programmers with a minimalist UI. OpenSCAD is a popular open-source design tool for 3D printing afficionados (and others). Rewriting trees to increase laziness and parallelizability.What about multithreading? Or skipping operations altogether? □.CGAL’s other hidden gem: corefinement functions.CGAL Nef Polyhedra + GMP = so precise it hurts (performance).Note: opinions expressed here are my own. Make your models more ambitious and report issues / successes here! TL DR: OpenSCAD users: download a nightly build & enable fast-csg in settings for 10x faster render (YMMV).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |