ReconstructMe SDK  2.6.43-0
Real-time 3D reconstruction engine
example_reconstructmesdk_csg.cpp

Content

This is a example shows basic usage of the CSG module for performing boolean set operations on solids.

Boost is only used to generate examples and is not necessary for working with this SDK.

#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(csg_operations) {
// Create a new context
// Create a license object
reme_error_t e = reme_license_authenticate(c, l, "license.txt.sgn");
// Create options to modify the position of the volume
// Compile for OpenCL device using defaults
reme_options_set_int(c, o, "volume.minimum_corner.x", -150);
reme_options_set_int(c, o, "volume.minimum_corner.y", -150);
reme_options_set_int(c, o, "volume.minimum_corner.z", -60);
reme_options_set_int(c, o, "volume.maximum_corner.x", 150);
reme_options_set_int(c, o, "volume.maximum_corner.y", 150);
reme_options_set_int(c, o, "volume.maximum_corner.z", 60);
reme_options_set_int(c, o, "volume.resolution.x", 128);
reme_options_set_int(c, o, "volume.resolution.y", 128);
reme_options_set_int(c, o, "volume.resolution.z", 128);
// We create an artificial sensor to browse the volume content directly.
reme_sensor_create(c, "external", false, &s);
reme_options_set_int(c, o, "depth_stream.image_size.width", 640);
reme_options_set_int(c, o, "depth_stream.image_size.height", 480);
reme_options_set_int(c, o, "depth_stream.intrinsics.width", 640);
reme_options_set_int(c, o, "depth_stream.intrinsics.height", 480);
reme_options_set_real(c, o, "depth_stream.intrinsics.fx", 570);
reme_options_set_real(c, o, "depth_stream.intrinsics.fy", 570);
reme_options_set_real(c, o, "depth_stream.intrinsics.cx", 320);
reme_options_set_real(c, o, "depth_stream.intrinsics.cy", 240);
// Create a new empty volume
// Create CSG module
reme_csg_create(c, v, &csg);
// Surface for rendering the result
float sphere[4] = {0, 0, 0, 50};
float box[6] = { -100, -100, -20, 100, 100, 20};
// Union operation
reme_viewer_t viewer_union;
reme_viewer_create_volume(c, v, s, "This is ReconstructMeSDK - CSG Union", &viewer_union);
reme_viewer_wait(c, viewer_union);
// Subtraction operation
reme_viewer_t viewer_subtraction;
reme_viewer_create_volume(c, v, s, "This is ReconstructMeSDK - CSG Subtraction", &viewer_subtraction);
reme_viewer_wait(c, viewer_subtraction);
// Intersection operation
reme_viewer_t viewer_intersection;
reme_viewer_create_volume(c, v, s, "This is ReconstructMeSDK - CSG Intersection", &viewer_intersection);
reme_viewer_wait(c, viewer_intersection);
// Print pending errors
// Make sure to release all memory acquired
}
BOOST_AUTO_TEST_SUITE_END()