Skip to content

Commit

Permalink
Update examples with new geom2graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed Mar 2, 2024
1 parent 8b4e507 commit 87dec88
Show file tree
Hide file tree
Showing 19 changed files with 15,897 additions and 30,720 deletions.
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,47 +516,42 @@ LINESTRING(-3.9364031512509543 -1.3260847841305947,10.746096436047983 -5.8054602
## geom2graph
The `geom2graph` tool is the lone C++ tool in the project. It uses GEOS to convert back and forth
between geometries and their graph representations (using a fuzzy tolerance, as well as duplicate
node and overlapping edge detection).
The `geom2graph` tool converts back and forth between geometries and their graph representations
(using an optional fuzzy tolerance, as well as duplicate node and overlapping edge detection).
That means you can go Geometry Collection -> Graph -> Geometry Collection to perform dramatic
geometry simplification!
**Note:** `geom2graph` only works in 2D, and does funky stuff with 3D geometries.
```shell
$ tools/parse-production-rules.py --config examples/fractal-plant-1.json |
tools/interpret-lstring.py --stepsize=3 --angle=22.5 |
tools/project.py --kind=pca --output examples/fractal-plant-1.wkt
$ head -n 5 examples/fractal-plant-1.wkt
LINESTRING (-244.6453794276828 189.4413011320319, -167.1020575851201 132.8459547012428, -142.1107643324939 91.86504131999683, -138.4076504660449 68.15245083114208, -141.2342426714309 56.49010216097916, -144.7714518233552 51.64364454581902, -147.3327589096831 50.08168871752988, -150.2968327207899 49.61879948422376)
LINESTRING (-147.3327589096831 50.08168871752988, -149.894065996011 48.51973288924074)
LINESTRING (-147.3327589096831 50.08168871752988, -149.894065996011 48.51973288924074, -153.4312751479352 43.6732752740806)
LINESTRING (-149.894065996011 48.51973288924074, -152.8581398071178 48.05684365593462)
LINESTRING (0 0, 0 96, 18.36880475352431 140.34621756054185, 35.33936750200145 157.3167803090189, 46.425921892136884 161.90898149739996, 52.425921892136884 161.90898149739996, 55.19756048967074 160.7609312003047, 57.31888083323039 158.63961085674507)
LINESTRING (55.19756048967074 160.7609312003047, 57.9691990872046 159.61288090320943)
LINESTRING (55.19756048967074 160.7609312003047, 57.9691990872046 159.61288090320943, 63.9691990872046 159.61288090320943)
LINESTRING (57.9691990872046 159.61288090320943, 60.090519430764246 157.4915605596498)
LINESTRING (52.425921892136884 161.90898149739996, 55.425921892136884 161.90898149739996, 58.19756048967074 160.7609312003047)
$ ./target/debug/geom2graph \
--tolerance=0.001 \
--input examples/fractal-plant-1.wkt \
--output examples/fractal-plant-1.tgf
$ head -n 5 examples/fractal-plant-1.tgf
0 POINT (-244.6453794276828 189.4413011320319)
1 POINT (-167.1020575851201 132.8459547012428)
2 POINT (-142.1107643324939 91.86504131999683)
3 POINT (-138.4076504660449 68.15245083114208)
4 POINT (-141.2342426714309 56.49010216097916)
0 POINT(0 0)
1 POINT(0 96)
2 POINT(18.36880475352431 140.34621756054185)
3 POINT(35.33936750200145 157.3167803090189)
4 POINT(46.425921892136884 161.90898149739996)
$ tail -n 5 examples/fractal-plant-1.tgf
6254 6259
6254 6265
6255 6259
6255 6266
6255 6267
6258 6260
6260 6261
6260 6262
6262 6263
6262 6264
6049 6050
6055 6056
6055 6062
6056 6058
6056 6057
```
You can go back from a TGF graph to WKT geometries by passing `--graph2geom`.
## format
The `format.py` tool can be used to convert between different equivalent geometry formats (primarily
Expand Down
757 changes: 379 additions & 378 deletions examples/asemic/example.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
376 changes: 188 additions & 188 deletions examples/diffusion-limited-aggregation/organic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8,184 changes: 4,092 additions & 4,092 deletions examples/fractal-plant-1-pca.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8,182 changes: 4,091 additions & 4,091 deletions examples/fractal-plant-1-pca.wkt

Large diffs are not rendered by default.

14,197 changes: 0 additions & 14,197 deletions examples/fractal-plant-1.tgf

This file was deleted.

11 changes: 0 additions & 11 deletions examples/generate-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ comm -23 /tmp/delaunay.wkt /tmp/urquhart.wkt >/tmp/difference.wkt
} >/tmp/combined.wkt
wkt2svg </tmp/combined.wkt >examples/urquhart.svg

echo "Converting the WKT to a graph..."
geom2graph \
--tolerance=0.001 \
--input "$REPO_ROOT/examples/fractal-plant-1.wkt" \
--output "$REPO_ROOT/examples/fractal-plant-1.tgf"

geom2graph \
--tolerance=0.001 \
--input "$REPO_ROOT/examples/maya-tree-2.wkt" \
--output "$REPO_ROOT/examples/maya-tree-2.tgf"

echo "Generating Random L-Systems..."
mkdir -p "$REPO_ROOT/examples/random-lsystems"
for i in $(seq 0 13); do
Expand Down
202 changes: 0 additions & 202 deletions examples/maya-tree-2.flat

This file was deleted.

Loading

0 comments on commit 87dec88

Please sign in to comment.