-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace generic resource embedder with const array
this avoids pulling in iostream and float parsing
- Loading branch information
Showing
8 changed files
with
47 additions
and
116 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
set(current_dir ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
function(generate_points_file infile outfile) | ||
file(READ "${infile}" contents) | ||
string(REGEX REPLACE "([^ \n]+) +([^ \n]+)\n" "{\\1, \\2},\n" POINTS | ||
"${contents}") | ||
|
||
configure_file("${current_dir}/points_file.cpp.in" "${outfile}" @ONLY) | ||
|
||
set_property( | ||
DIRECTORY | ||
APPEND | ||
PROPERTY CMAKE_CONFIGURE_DEPENDS "${infile}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// WARNING This file is auto-generated during configuration by the cmake | ||
// function generate_points_file. Do not manually edit as changes will be lost | ||
|
||
#include <cstddef> | ||
|
||
namespace ear { | ||
namespace points_file { | ||
extern const double points[][2] = { | ||
@POINTS@ | ||
}; | ||
extern const size_t num_points = sizeof(points) / sizeof(points[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
#include "hoa.hpp" | ||
#include "ear/helpers/assert.hpp" | ||
#include "resources.hpp" | ||
#include "points_file.hpp" | ||
|
||
Eigen::Matrix<double, Eigen::Dynamic, 3> ear::hoa::load_points() { | ||
std::stringstream points_file; | ||
Eigen::Matrix<double, Eigen::Dynamic, 3> points(points_file::num_points, 3); | ||
|
||
ear_assert(getEmbeddedFile("Design_5200_100_random.dat", points_file), | ||
"could not find embedded file Design_5200_100_random.dat, this is " | ||
"probably a compilation error"); | ||
size_t len = 5200; | ||
|
||
Eigen::Matrix<double, Eigen::Dynamic, 3> points(len, 3); | ||
for (size_t i = 0; i < len; i++) { | ||
double phi, theta; | ||
points_file >> phi >> theta; | ||
for (size_t i = 0; i < points_file::num_points; i++) { | ||
double phi = points_file::points[i][0], theta = points_file::points[i][1]; | ||
points(i, 0) = std::sin(theta) * std::cos(phi); | ||
points(i, 1) = std::sin(theta) * std::sin(phi); | ||
points(i, 2) = std::cos(theta); | ||
} | ||
|
||
ear_assert(points_file.good(), | ||
"failure when reading HOA points from embedded file"); | ||
|
||
return points; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include <cstddef> | ||
|
||
namespace ear { | ||
namespace points_file { | ||
// defined in autogenerated .cpp file from | ||
// resources/Design_5200_100_random.dat | ||
extern const double points[][2]; | ||
extern const size_t num_points; | ||
} // namespace points_file | ||
} // namespace ear |