Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blueprint to Signed Distance Fields example #5635

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions examples/python/signed_distance_fields/README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot see any reason why this example isnt available in the app? We should add a channel here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One reason is that is quite confusing. I think a README would be a pre-requisite for adding it to the app. Maybe also make it a bit prettier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not doing that in this pr

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ thumbnail = "https://static.rerun.io/signed-distance-fields/0b0a200e0a5ec2b16e5f
thumbnail_dimensions = [480, 480]
-->


<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/signed_distance_fields/99f6a886ed6f41b6a8e9023ba917a98668eaee70/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/signed_distance_fields/99f6a886ed6f41b6a8e9023ba917a98668eaee70/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/signed_distance_fields/99f6a886ed6f41b6a8e9023ba917a98668eaee70/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/signed_distance_fields/99f6a886ed6f41b6a8e9023ba917a98668eaee70/1200w.png">
<img src="https://static.rerun.io/signed_distance_fields/99f6a886ed6f41b6a8e9023ba917a98668eaee70/full.png" alt="Signed Distance Fields example screenshot">
<img src="https://static.rerun.io/signed_distance_fields/1380524f963af0cbd615989a6e382ca86148f6da/full.png" alt="Signed Distance Fields example screenshot">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/signed_distance_fields/1380524f963af0cbd615989a6e382ca86148f6da/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/signed_distance_fields/1380524f963af0cbd615989a6e382ca86148f6da/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/signed_distance_fields/1380524f963af0cbd615989a6e382ca86148f6da/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/signed_distance_fields/1380524f963af0cbd615989a6e382ca86148f6da/1200w.png">
</picture>

Generate Signed Distance Fields for arbitrary meshes using both traditional methods and the one described in the [DeepSDF paper](https://arxiv.org/abs/1901.05103), and visualize the results using the Rerun SDK.
Expand Down
16 changes: 15 additions & 1 deletion examples/python/signed_distance_fields/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import numpy as np
import numpy.typing as npt
import rerun as rr # pip install rerun-sdk
import rerun.blueprint as rrb
import trimesh
from download_dataset import AVAILABLE_MESHES, ensure_mesh_downloaded
from trimesh import Trimesh
Expand Down Expand Up @@ -194,7 +195,20 @@ def main() -> None:
rr.script_add_args(parser)
args = parser.parse_args()

rr.script_setup(args, "rerun_example_signed_distance_fields")
rr.script_setup(
args,
"rerun_example_signed_distance_fields",
blueprint=rrb.Horizontal(
rrb.Vertical(
rrb.Horizontal(
rrb.Spatial3DView(name="Input Mesh", origin="/world/mesh"),
rrb.TensorView(name="SDF", origin="/tensor"),
),
rrb.TextLogView(name="Execution Log"),
),
rrb.Spatial3DView(name="Distance Field Samples", origin="/world/sdf"),
),
)

mesh_path = args.mesh_path
if mesh_path is None:
Expand Down
6 changes: 4 additions & 2 deletions scripts/ci/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def examples_with_thumbnails() -> Generator[Example, None, None]:
def single_language(lang: str) -> Generator[Example, None, None]:
for path in Path(f"examples/{lang}").iterdir():
if (path / "README.md").exists():
readme = (path / "README.md").read_text()
readme = (path / "README.md").read_text(encoding="utf-8")
fm = load_frontmatter(readme)
if fm is not None and fm.get("thumbnail"):
yield Example(path, readme, fm)
Expand Down Expand Up @@ -64,7 +64,9 @@ def work(example: Example):
assert end != -1

(example.path / "README.md").write_text(
example.readme[:start] + f"thumbnail_dimensions = [{width}, {height}]" + example.readme[end:]
example.readme[:start] + f"thumbnail_dimensions = [{width}, {height}]" + example.readme[end:],
encoding="utf-8",
newline="\n",
)

print(f"✔ {example.path}")
Expand Down
Loading