fayolle / random_CSG_tree

Generate random CSG trees

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List of files:

  • random_tree.py Generate random trees from a list of primitives with parameters (passed as argument). Example:
> python random_tree.py example.fit

Will generate 10 random trees with a max depth of 10 using the primitives (with fitted parameters) read from the file example.fit. It creates two files:

  • expressions.txt that contains a list of random expressions (trees) generated by the program (default name can be changed with the option --trees_out)
  • list_primitives.txt that contains a list of the primitive names used in the expressions (default name can be changed with the option --primitives_out).

Right now the following primitives are supported: plane, sphere, cylinder, torus, cone, ellipsoid. The following operations are supported: union, intersection, negation, difference.

It is possible to change the default number of random trees with the option: --pop_size and the default max depth with the option: --max_depth.

  • tree_from_expression.py Generate a .dot file that can be processed with graphviz. It takes as input an expression generated by the program random_tree and a list of primitive names also generated by random_tree. Example:
> python tree_from_expression.py tree.txt list_primitives.txt graphviz_tree.dot 

The expression in tree.txt is one of the expressions read from the file expressions.txt (created above).

  • create_eval_source.py Generate a C++ source file with a function: double eval(double x, double y, double z) That can be used to evaluate a given expression at a given point. It relies on the C++ files operations.{h,cpp} and primitives.{h,cpp} that implement the default operations and primitives. It takes as input a file with an expression and a list of the primitives (with fitted parameters). Example:
> python create_eval_source.py tree.txt example.fit tree.cpp

The file tree.cpp will contain the C++ source file.

About

Generate random CSG trees

License:MIT License


Languages

Language:C++ 53.8%Language:Python 43.5%Language:C 1.4%Language:Shell 1.3%