Index of /OpenSCAD/simplifycsg
Name Last modified Size Description
Parent Directory -
Makefile 2025-08-04 20:54 115
Makefile-flatten 2025-08-04 20:54 8.7K
README.txt 2025-08-06 18:53 1.9K
flatten 2025-08-07 11:33 1.2M
flatten-arm 2025-08-07 11:35 941K
flatten-ast.h 2025-08-07 11:33 31K
flatten-comp.h 2025-08-07 11:33 15K
flatten-main.c 2025-08-04 20:54 6.7K
flatten.c 2025-08-04 20:54 14K
flatten.g 2025-08-07 11:51 31K
flatten.h 2025-08-07 11:33 44K
flatten.zip 2025-08-07 11:51 1.0M
flex.c 2025-08-04 20:54 9.2K
flex.h 2025-08-04 20:54 9.4K
gencomp.c 2025-08-04 20:54 12K
parser.h 2025-08-04 20:54 842
regen.c 2025-08-04 20:54 11K
regexp-lexer.c 2025-08-04 20:54 43K
regexp-lexer.h 2025-08-04 20:54 1.3K
takeon-checks.c 2025-08-04 20:54 24K
takeon-output.c 2025-08-04 20:54 32K
takeon.c 2025-08-04 20:54 24K
test-out.csg 2025-08-06 18:41 60K
test.csg 2025-08-04 20:54 412K
uparse-main.c 2025-08-04 20:54 9.7K
uparse.c 2025-08-04 20:54 60K
4th Aug 2025
This is a work-in-progress version of a utility I'm writing that will remove
most of the redundant code that is output to a .csg file from OpenSCAD.
It's really just a demonstration of how it might be done, as it would make more
sense to perform this simplification in OpenSCAD itself rather than externally.
The significant file is flatten.g which is the combined grammar for CSG files and
code to perform the simplification. Everything else in this directory is a copy
of my parser generator. If the code were added to OpenSCAD it would use the
internal AST of OpenSCAD rather than parsing the output to recreate an AST.
(And if anyone wanted an actual utility like this, I'ld recommend converting
flatten.g into the format of whatever more well-known parser generator you
prefer to use, for better portability. The main logic of the optimisation
is all contained in the single function 'optimised_csg')
This current version now also merges cascaded multmatrix() calls together. This
final optimisation has reduced the original 5752 lines of test.csg to a mere
499 lines in test-out.csg! It is my hope is that a simplified csg file might
form a basis for restructuring a model should you want to do that. And it's
easier to read.
(btw I generally replace tabs in csg files with a single space per tab, just to
reduce the indentation and make files easier to read on-screen, and this code
outputs the modified csg file in that fashion. But that is not a necessary part
of the program and could be removed.).
There is a statically-linked intel (x86-64) binary of flatten in this directory
if compiling from source is too daunting (though it shouldn't be - just copy the
files and type 'make'. The zip file here contains all the other files.)
flatten-arm is the same binary, also compiled statically, for arm aarch64
(specifically raspberry pi).
Graham <gtoal@gtoal.com>