You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
1.7 KiB

#ifndef ALGOIM_POLYSET_HPP
#define ALGOIM_POLYSET_HPP
// algoim::PolySet
#include <cassert>
#include <vector>
#include "booluarray.hpp"
#include "real.hpp"
#include "xarray.hpp"
namespace algoim
{
namespace v2
{
// PolySet implements a simple container to hold one or more Bernstein polynomials
// and their associated masks
template <int N, int E, int L = 0>
struct PolySet {
struct Poly {
uvector<int, N> ext; // Degree/extent of polynomial
size_t offset; // Offset into buffer, storing the xarray<Real,N> polynomial data
booluarray<N, E> mask; // Mask
uvector<int, L> typeTags; // tag a polynomial and its ancestors with the type of P/Q/R
int originShapeIdx; // 记录初始的shapeIdx
};
std::vector<real> buff; // Memory buffer containing polynomial data
std::vector<Poly> items; // Record of contained polynomials
// Access polynomial by index
xarray<real, N> poly(size_t ind)
{
assert(0 <= ind && ind < items.size());
return xarray<real, N>(&buff[items[ind].offset], items[ind].ext);
}
// Access mask by index
booluarray<N, E>& mask(size_t ind)
{
assert(0 <= ind && ind < items.size());
return items[ind].mask;
}
// Add a polynomial/mask pair to the container
void push_back(const xarray<real, N>& p, const booluarray<N, E>& m, const uvector<int, L>& t, int i)
{
items.push_back({p.ext(), buff.size(), m, t, i});
buff.resize(buff.size() + p.size());
poly(items.size() - 1) = p;
}
size_t count() const { return items.size(); }
};
} // namespace v2
} // namespace algoim
#endif