samedi 7 septembre 2019

Convert std::array

I have a buch of triangles represented by a vector of 3d vectors (std::vector<Vector3>) and indices, represented in the following way

using int3 = std::array<int, 3>;
std::vector<int3> indices;

I need to convert the indices into a std::vector<size_t> format to interact with a library.

I know how to do this using raw loops, but I would like to here about how to do it using algorithms. I tried something like

std::vector<size_t> indices_converted;
std::transform(std::begin(indices), std::end(indices), std::back_inserter(indices_converted), [](const auto &v) {
});

but is not enough, since I can't insert three values at once into the indices_converted vector.

So, what are your ideas?

Aucun commentaire:

Enregistrer un commentaire