Skip to content

Commit

Permalink
Add properties_output_size function to wrapper c
Browse files Browse the repository at this point in the history
  • Loading branch information
MFraters committed Oct 26, 2024
1 parent 4e2cb71 commit 59b295c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/world_builder/wrapper_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ extern "C" {
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);



/**
* Return the size of the output vector returned by the properties function for a given properties vector.
*
* @param properties The properties paramter from the properties function. See the documentation of that

Check warning on line 41 in include/world_builder/wrapper_c.h

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "paramter" should be "parameter".
* function for more info.
* @param n_properties number of properties
* @return unsigned int Return the size of the output vector returned by the properties function for a given properties vector.
*/
unsigned int properties_output_size(void *ptr_ptr_world,
const unsigned int properties[][3],
const unsigned int n_properties);

/**
* @brief This function returns 2D properties.
*
Expand Down
15 changes: 15 additions & 0 deletions source/world_builder/wrapper_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ extern "C" {
*ptr_ptr_world = reinterpret_cast<void *>(a);
}

unsigned int properties_output_size(void *ptr_ptr_world,const unsigned int properties_[][3],
const unsigned int n_properties)
{
WorldBuilder::World *a =
reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world);
std::vector<std::array<unsigned int, 3>> properties(n_properties);
for (size_t i = 0; i < n_properties; ++i)
{
properties[i][0] = properties_[i][0];
properties[i][1] = properties_[i][1];
properties[i][2] = properties_[i][2];
}
return a->properties_output_size(properties);
}

void properties_2d(void *ptr_ptr_world, const double x, const double z,
const double depth, const unsigned int properties_[][3],
const unsigned int n_properties, double values[])
Expand Down

0 comments on commit 59b295c

Please sign in to comment.