This module provides methods to interact and manipulate parameters, options and information that are not performance relevant in a generic way. ReconstructMe SDK uses Google Protocol Buffer to represent available options. Such a specification is a plain text file that describes the available fields. For example the options to drive the Poisson surface reconstruction are
message poisson_options {
optional int32 depth = 1 [default = 8];
optional int32 solver_divide = 2 [default = 8];
optional int32 iso_divide = 3 [default = 8];
optional int32 minimum_samples_per_node = 4 [default = 1];
optional float scale = 5 [default = 1];
optional bool enable_clipping = 6 [default = false];
}
To modify and access the above fields you have two possibilities.
- Lazy Dynamic Approach
The following code snippet uses the dynamic API that relies on reflection of available fields.
In case the options specification contains repeated fields such as the OpenCL informations below
package LibOpenCLBridge;
message opencl_info {
enum device_type {
CPU = 0;
GPU = 1;
}
message device {
optional string name = 1 [default = "Unknown device name"];
optional string vendor = 2 [default = "Unknown device vendor"];
optional device_type type = 3;
}
repeated device devices = 1;
}
use the repeated methods to access the fields.
int num_devices = 0;
printf("Found %i OpenCL compatible devices\n", num_devices);
const char *value;
int length;
for (int i = 0; i < num_devices; i += 1) {
printf("----\n");
printf("Device '%s' \n", value);
printf(" - by '%s' \n", value);
printf(" - type %s \n", value);
}
- Type Safe Approach
Alternatively you can compile a getter/setter object for the programming language of your choice and use the built-in serialization mechanism to get a nice way to interop between different languages. Such compilers exist for all modern languanges such as C, C++, Java and .NET. See https://developers.google.com/protocol-buffers/ for details. Here's an example of the type safe approach in C++ using the compile settings.
poisson_options po;
po.set_depth(9);
std::string msg;
po.SerializeToString(&msg);
const void *m;
int length;
po.ParseFromArray(m, length);
std::cout << po.DebugString() << std::endl;
Handle referencing an options object.
A reme_options_t references a specific options class. Internally ReconstructMe SDK uses Google's protocol buffers to represent options and parameters. Protocol buffers a language-neutral, platform-neutral, extensible mechanism for serializing structured data.
In order to manipulate these protocol buffer options you have two options:
Destroy a previously created options object.
- Parameters
-
c | A pointer to a valid context object |
o | A mutable pointer to a valid options handle to destroy |
- Return values
-
Get a specific repeated options field.
This method uses a reflection like mechanism to get the specified field value. Use the '.' character to separate nested fields. If any field encountered is repeated the first element is used.
- Parameters
-
c | A valid context object |
o | A valid options object |
field_name | Name of the field to manipulate |
value | Mutable pointer to receive the option value |
length | Length of option value in characters. |
- Return values
-
- Examples:
- example_reconstructmesdk_options_lazy.cpp.
Get a specific repeated options field.
This method uses a reflection like mechanism to get the specified field value. Use the '.' character to separate nested fields. The repeated_index only affects the last part of the field description. Any parent repeated messages are accessed with index zero.
- Parameters
-
c | A valid context object |
o | A valid options object |
field_name | Name of the field to manipulate |
repeated_index | When the target field is repeated the command applies to the i-th field. |
value | Mutable pointer to receive the option value |
length | Length of option value in characters. |
- Return values
-
Return the number of elements in a repeated field.
- Parameters
-
c | A valid context object |
o | A valid options object |
field_name | Name of the field to manipulate |
length | Number of elements in repeated field. If field is not repeated, returns 1. |
- Return values
-
- Examples:
- example_reconstructmesdk_options_lazy.cpp.
Bind options object to a nested message.
- Parameters
-
c | A valid context object |
o | A valid options object |
field_name | Name of the field containing the nested message |
o_nested | A valid options object recieving the binding. |
- Return values
-
Bind options object to a nested repeated message.
- Parameters
-
c | A valid context object |
o | A valid options object |
field_name | Name of the field containing the nested message |
repeated_index | When the target message is repeated the command applies to the i-th field. |
o_nested | A valid options object recieving the binding. |
- Return values
-
- Examples:
- example_reconstructmesdk_options_lazy.cpp.
Save options in a human readable file format.
This method uses protobuf's text format serializer to write in the content of the file. The output is similar to json.
- Parameters
-
c | A valid context object |
o | A valid options object |
filename | Path to file. |
- Return values
-
Get options as string using a human readable serialization.
This method uses protobuf's text format serializer to write in the content of the file. The output is similar to json.
- Parameters
-
c | A valid context object |
o | A valid options object |
message | A mutable pointer that will receive the content of the message |
length | A pointer that will receive the length of the serialized message in bytes |
- Return values
-
Set options by reading a binary options representation.
This method uses protobuf's standard serialization format (binary) to read in the desired options value.
- Parameters
-
c | A valid context object |
o | A valid options object |
message | A valid pointer to the serialized message |
length | The length of the serialized message in bytes. |
- Return values
-
- Examples:
- example_reconstructmesdk_options_type_safe.cpp.
Get options by serializing them in a binary options representation.
This method uses protobuf's standard serialization format (binary) to serialize the current state of option values.
- Parameters
-
c | A valid context object |
o | A valid options object |
message | A mutable pointer that will receive the address of the serialized message |
length | A pointer that will receive the length of the serialized message in bytes |
- Return values
-
- Examples:
- example_reconstructmesdk_options_type_safe.cpp.