Commit 0d076c9f authored by Jordan P. Lefebvre's avatar Jordan P. Lefebvre
Browse files

WIP. starting on marchingsquares algorithm.

parent 6cf7b9e9
Pipeline #11521 passed with stages
in 4 minutes and 31 seconds
...@@ -5,6 +5,8 @@ ordering.cc ...@@ -5,6 +5,8 @@ ordering.cc
) )
SET(HEADERS SET(HEADERS
ordering.hh ordering.hh
marchingsquares.hh
marchingsquares.i.hh
) )
TRIBITS_ADD_LIBRARY(radixalgorithmlib TRIBITS_ADD_LIBRARY(radixalgorithmlib
......
#ifndef RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_
#define RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_
#include <vector>
namespace radix
{
template <typename data_type, typename sign_type = int>
void marching_squares(const std::vector<data_type>& points,
std::vector<data_type>& out, size_t rows, size_t cols,
data_type isovalue, sign_type negative = 0,
sign_type positive = 1);
} // namespace
/** Include implementation file */
#include "radixalgorithm/marchingsquares.i.hh"
#endif /** RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_ */
#include <vector>
#include "radixbug/bug.hh"
namespace radix
{
template <typename data_type, typename sign_type = int>
void marching_squares(const std::vector<data_type>& points,
std::vector<data_type>& out, size_t rows, size_t cols,
data_type isovalue, sign_type negative,
sign_type positive)
{
radix_check(points.size() == (rows * cols));
out.clear();
out.resize(points.size());
//
// Create a 2d view of the points
auto view = [&points, cols](size_t row, size_t column) {
return points[cols * row + column];
};
for (size_t p_i = 0; p_i < points.size(); ++p_i)
{
// select data as 0 below value or 1 greater than
if (points[p_i] < isovalue)
{
out[p_i] = negative;
}
else
{
out[p_i] = positive;
}
}
}
} // namespace
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment