Language CSG
Examples/LanguageCSG reads a composition written in the The .ebg language at run time: the classic CSG
solid of Basic CSG, a cube rounded off by a ball and drilled through along all three axes. The
source is at Examples/LanguageCSG/main.cpp, and the model is Examples/LanguageCSG/solid.ebg.
Fig. 24 The solid as the viewer first shows it.
The model
solid.ebg gives the solid’s sizes as params, defines the cube, the ball and the three drills, and makes the
object of them:
param r_drill = 0.55
...
object difference(intersection(cube, ball), drills)
See Shapes and Operations for every shape and operation.
Reading it and compiling it
Language::read() reads the file into a model; a model with errors throws them all, with their files, lines and
columns. The model’s object is an Expr, as the expression builder makes one, and compiles into a tape like any other:
Pool pool(hostMemoryResource());
const auto model = Language::read<T>("solid.ebg", pool);
const Tape<T> tape(pool, model.object());
From here on, nothing knows the solid came from a file: the program opens a window on the tape, which renders on the GPU in a GPU build, and the tape runs queries there as any tape does (see Basic CSG).
Editing solid.ebg changes the solid with no compiling: run the program again. ebgstudio (built in
Studio/, see ebgstudio) opens the model in a window that reloads it on every save,
ebgstudio solid.ebg. Language domains goes on to a model with regions, materials and domains.
Building and running
Build it as any example (see About the examples), and run it from its folder, where solid.ebg is:
cd Examples/LanguageCSG
make && ./LanguageCSG.ex # or ./LanguageCSG.ex path/to/model.ebg
See Reading models in C++ for the calls.