tutorials:rgg-code-structure
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:rgg-code-structure [2024/10/11 12:48] – [init] tim | tutorials:rgg-code-structure [2025/01/10 11:16] (current) – gaetan | ||
---|---|---|---|
Line 76: | Line 76: | ||
==== Queries ==== | ==== Queries ==== | ||
- | In GroIMP the project graph is considered to hold almost all information on the simulation. Therefore it can also be seen as a knowledge graph. To retrieve this knowledge rgg uses the [[tutorials: | + | In GroIMP the project graph is considered to hold almost all information on the simulation. Therefore it can also be seen as a knowledge graph. To retrieve this knowledge rgg uses the [[tutorials: |
As shown in the example below in '' | As shown in the example below in '' | ||
Line 108: | Line 108: | ||
===== XL Blocks ===== | ===== XL Blocks ===== | ||
- | While using XL rules mainly two operators | + | While using XL queries |
Line 150: | Line 150: | ||
l[angle]=a; | l[angle]=a; | ||
} | } | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Working with several Files ==== | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | In GroIMP it is possible to split your code into several files and folders to improve the structure and keep an overview. | ||
+ | <color # | ||
+ | |||
+ | |||
+ | To use function from another file this file needs to be imported similar to a java class or package. | ||
+ | Yet in the case of GroIMP all files are imported by their name without the directories, | ||
+ | <code java> | ||
+ | import parameters.YourModule; | ||
+ | </ | ||
+ | |||
+ | |||
+ | To get this a bit clearer lets assume our parameters.rgg file contains the following code: | ||
+ | <code java> | ||
+ | public static int length = 1; | ||
+ | public static float diameter = 0.1; | ||
+ | module Leaf() ==> leaf3d(1); | ||
+ | module Shoot() extends F(1); | ||
+ | </ | ||
+ | |||
+ | To import one specific object once, you can simply do '' | ||
+ | <code java> | ||
+ | protected void init () | ||
+ | [ | ||
+ | Axiom ==> parameters.Leaf(); | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | If you want to use your module several times you can also import it one in the beginning and then reuse it: | ||
+ | |||
+ | <code java> | ||
+ | import parameters.Leaf; | ||
+ | protected void init () | ||
+ | [ | ||
+ | Axiom ==> Leaf()[RL(180) Leaf()]; | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | Finally you can import all modules with the * operator: | ||
+ | <code java> | ||
+ | import parameters.*; | ||
+ | protected void init () | ||
+ | [ | ||
+ | Axiom ==> Shoot() Leaf()[RL(180) Leaf()]; | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | This can also be done with the static variables using static import: | ||
+ | <code java> | ||
+ | |||
+ | import static parameters.*; | ||
+ | protected void init () | ||
+ | [ | ||
+ | Axiom ==> F(length, | ||
] | ] | ||
</ | </ | ||
tutorials/rgg-code-structure.1728643711.txt.gz · Last modified: 2024/10/11 12:48 by tim