Skip to content

Commit ebd0be9

Browse files
committed
wip
1 parent 7d656ec commit ebd0be9

File tree

7 files changed

+101
-7
lines changed

7 files changed

+101
-7
lines changed

docs/code-examples/all/annotation_context_connections.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ int main() {
2626
// Log some points with different keypoint IDs
2727
rec.log(
2828
"points",
29-
rerun::Points3D({{0.0f, 0.0f, 0.0f},
30-
{50.0f, 0.0f, 20.0f},
31-
{100.0f, 100.0f, 30.0f},
32-
{0.0f, 50.0f, 40.0f}})
29+
rerun::Points3D(
30+
{{0.0f, 0.0f, 0.0f}, {50.0f, 0.0f, 20.0f}, {100.0f, 100.0f, 30.0f}, {0.0f, 50.0f, 40.0f}
31+
}
32+
)
3333
.with_keypoint_ids({0, 1, 2, 3})
3434
.with_class_ids({0})
3535
);

examples/cpp/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ add_subdirectory(clock)
22
add_subdirectory(custom_collection_adapter)
33
add_subdirectory(dna)
44
add_subdirectory(external_data_loader)
5+
add_subdirectory(incremental)
56
add_subdirectory(log_file)
67
add_subdirectory(minimal)
78
add_subdirectory(shared_recording)
@@ -13,6 +14,7 @@ add_custom_target(examples)
1314
add_dependencies(examples example_clock)
1415
add_dependencies(examples example_custom_collection_adapter)
1516
add_dependencies(examples example_dna)
17+
add_dependencies(examples example_incremental)
1618
add_dependencies(examples example_log_file)
1719
add_dependencies(examples example_minimal)
1820
add_dependencies(examples example_shared_recording)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.16...3.27)
2+
3+
# If you use the example outside of the Rerun SDK you need to specify
4+
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable.
5+
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake.
6+
if(DEFINED RERUN_REPOSITORY)
7+
add_executable(example_incremental main.cpp)
8+
rerun_strict_warning_settings(example_incremental)
9+
else()
10+
project(example_incremental LANGUAGES CXX)
11+
12+
add_executable(example_incremental main.cpp)
13+
14+
# Set the path to the rerun_c build.
15+
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.")
16+
17+
# Download the rerun_sdk
18+
include(FetchContent)
19+
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL})
20+
FetchContent_MakeAvailable(rerun_sdk)
21+
22+
# Rerun requires at least C++17, but it should be compatible with newer versions.
23+
set_property(TARGET example_incremental PROPERTY CXX_STANDARD 17)
24+
endif()
25+
26+
# Link against rerun_sdk.
27+
target_link_libraries(example_incremental PRIVATE rerun_sdk)

examples/cpp/incremental/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--[metadata]
2+
title = "Helix"
3+
tags = ["3d", "api-example"]
4+
description = "Simple example of logging point and line primitives to draw a 3D helix."
5+
thumbnail = "https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png"
6+
thumbnail_dimensions = [480, 285]
7+
channel = "main"
8+
-->
9+
10+
11+
<picture>
12+
<source media="(max-width: 480px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png">
13+
<source media="(max-width: 768px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/768w.png">
14+
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/1024w.png">
15+
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/1200w.png">
16+
<img src="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/full.png" alt="">
17+
</picture>
18+
19+
Simple example of logging point and line primitives to draw a 3D helix.
20+
21+
22+
To build it from a checkout of the repository (requires a Rust toolchain):
23+
```bash
24+
cmake .
25+
cmake --build . --target example_incremental
26+
./examples/cpp/incremental/example_incremental
27+
```

examples/cpp/incremental/main.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <rerun.hpp>
2+
3+
#include <algorithm>
4+
#include <random>
5+
6+
int main() {
7+
const auto rec = rerun::RecordingStream("rerun_example_incremental");
8+
rec.spawn().exit_on_failure();
9+
10+
// TODO(#5264): just log one once clamp-to-edge semantics land.
11+
std::vector<rerun::Color> colors(10, rerun::Color(255, 0, 0));
12+
std::vector<rerun::Radius> radii(10, rerun::Radius(0.1));
13+
14+
// Only log colors and radii once.
15+
rec.set_time_sequence("frame_nr", 0);
16+
rec.log("points", colors, radii);
17+
// Logging timelessly with `RecordingStream::log_timeless` would also work.
18+
// rec.log_timeless("points", colors, radii);
19+
20+
std::default_random_engine gen;
21+
std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
22+
23+
// Then log only the points themselves each frame.
24+
//
25+
// They will automatically re-use the colors and radii logged at the beginning.
26+
for (int i = 0; i < 10; ++i) {
27+
rec.set_time_sequence("frame_nr", i);
28+
29+
std::vector<rerun::Position3D> points(10);
30+
std::generate(points.begin(), points.end(), [&] {
31+
return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
32+
});
33+
rec.log("points", rerun::Points3D(points));
34+
}
35+
}

rerun_cpp/src/rerun/third_party/cxxopts.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,8 @@ namespace cxxopts {
20382038
value->get_implicit_value(),
20392039
std::move(arg_help),
20402040
value->is_container(),
2041-
value->is_boolean()});
2041+
value->is_boolean()
2042+
});
20422043
}
20432044

20442045
inline void Options::add_one_option(

rerun_cpp/tests/mat.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ TEST_CASE("Construct Mat4x4 in different ways", TEST_TAG) {
8282
12.0f,
8383
13.0f,
8484
14.f,
85-
15.0f};
85+
15.0f
86+
};
8687
Mat4x4 m4x4(carray);
8788
ctor_checks(m4x4);
8889
}
@@ -104,7 +105,8 @@ TEST_CASE("Construct Mat4x4 in different ways", TEST_TAG) {
104105
12.0f,
105106
13.0f,
106107
14.f,
107-
15.0f};
108+
15.0f
109+
};
108110
Mat4x4 m4x4(elements.data());
109111
ctor_checks(m4x4);
110112
}

0 commit comments

Comments
 (0)