Skip to content

Commit 59b295c

Browse files
committed
Add properties_output_size function to wrapper c
1 parent 4e2cb71 commit 59b295c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/world_builder/wrapper_c.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ extern "C" {
3434
void create_world(void **ptr_ptr_world, const char *world_builder_file, const bool *has_output_dir, const char *output_dir, const unsigned long random_number_seed);
3535

3636

37+
38+
/**
39+
* Return the size of the output vector returned by the properties function for a given properties vector.
40+
*
41+
* @param properties The properties paramter from the properties function. See the documentation of that
42+
* function for more info.
43+
* @param n_properties number of properties
44+
* @return unsigned int Return the size of the output vector returned by the properties function for a given properties vector.
45+
*/
46+
unsigned int properties_output_size(void *ptr_ptr_world,
47+
const unsigned int properties[][3],
48+
const unsigned int n_properties);
49+
3750
/**
3851
* @brief This function returns 2D properties.
3952
*

source/world_builder/wrapper_c.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ extern "C" {
5353
*ptr_ptr_world = reinterpret_cast<void *>(a);
5454
}
5555

56+
unsigned int properties_output_size(void *ptr_ptr_world,const unsigned int properties_[][3],
57+
const unsigned int n_properties)
58+
{
59+
WorldBuilder::World *a =
60+
reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world);
61+
std::vector<std::array<unsigned int, 3>> properties(n_properties);
62+
for (size_t i = 0; i < n_properties; ++i)
63+
{
64+
properties[i][0] = properties_[i][0];
65+
properties[i][1] = properties_[i][1];
66+
properties[i][2] = properties_[i][2];
67+
}
68+
return a->properties_output_size(properties);
69+
}
70+
5671
void properties_2d(void *ptr_ptr_world, const double x, const double z,
5772
const double depth, const unsigned int properties_[][3],
5873
const unsigned int n_properties, double values[])

0 commit comments

Comments
 (0)