11 const std::vector<std::array<SimplexId, 2>> &edgeList,
14 std::vector<SimplexId> offsets(vertexNumber + 1);
16 std::vector<SimplexId> edgesId(vertexNumber);
23 for(
const auto &e : edgeList) {
29 for(
size_t i = 1; i < offsets.size(); ++i) {
30 offsets[i] += offsets[i - 1];
34 std::vector<SimplexId> data(offsets.back());
37 for(
size_t i = 0; i < edgeList.size(); ++i) {
38 const auto &e{edgeList[i]};
39 data[offsets[e[0]] + edgesId[e[0]]] = i;
41 data[offsets[e[1]] + edgesId[e[1]]] = i;
46 vertexEdges.
setData(std::move(data), std::move(offsets));
48 printMsg(
"Built " + std::to_string(vertexNumber) +
" vertex edges", 1,
61 const std::vector<std::array<SimplexId, 3>> &cellEdges,
62 const std::vector<std::array<SimplexId, 2>> &edgeList,
65#ifndef TTK_ENABLE_KAMIKAZE
66 if(vertexStars.
empty())
77 std::vector<SimplexId> offsets(vertexNumber + 1);
79 std::vector<SimplexId> links(vertexStars.
dataSize());
84#ifdef TTK_ENABLE_OPENMP
85#pragma omp parallel for num_threads(threadNumber_)
87 for(
SimplexId i = 0; i < vertexNumber; i++) {
90 offsets[i] = vertexStars.
offset(i);
94 for(
size_t k = 0; k < cellEdges[vertexStars.
get(i, j)].size(); k++) {
95 const auto e = cellEdges[vertexStars.
get(i, j)][k];
96 if(i != edgeList[e][0] && i != edgeList[e][1]) {
97 links[offsets[i] + j] = e;
105 offsets[vertexNumber] = vertexStars.
offset(vertexNumber);
107 vertexLinks.
setData(std::move(links), std::move(offsets));
109 printMsg(
"Built " + std::to_string(vertexNumber) +
" vertex links", 1,
118 const std::vector<std::array<SimplexId, 4>> &cellTriangles,
119 const std::vector<std::array<SimplexId, 3>> &triangleList,
122#ifndef TTK_ENABLE_KAMIKAZE
123 if(vertexStars.
empty())
125 if(cellTriangles.empty())
127 if(triangleList.empty())
134 std::vector<SimplexId> offsets(vertexNumber + 1);
136 std::vector<SimplexId> links(vertexStars.
dataSize());
141#ifdef TTK_ENABLE_OPENMP
142#pragma omp parallel for num_threads(threadNumber_)
144 for(
SimplexId i = 0; i < vertexNumber; i++) {
147 offsets[i] = vertexStars.
offset(i);
151 for(
size_t k = 0; k < cellTriangles[vertexStars.
get(i, j)].size(); k++) {
152 const auto t = cellTriangles[vertexStars.
get(i, j)][k];
153 if(i != triangleList[t][0] && i != triangleList[t][1]
154 && i != triangleList[t][2]) {
155 links[offsets[i] + j] = t;
163 offsets[vertexNumber] = vertexStars.
offset(vertexNumber);
165 vertexLinks.
setData(std::move(links), std::move(offsets));
167 printMsg(
"Built " + std::to_string(vertexNumber) +
" vertex links", 1,
176 const std::vector<std::array<SimplexId, 2>> &edgeList)
const {
178 std::vector<SimplexId> offsets(vertexNumber + 1);
180 std::vector<SimplexId> neighborsId(vertexNumber);
187 for(
const auto &e : edgeList) {
193 for(
size_t i = 1; i < offsets.size(); ++i) {
194 offsets[i] += offsets[i - 1];
198 std::vector<SimplexId> neighbors(offsets.back());
201 for(
const auto &e : edgeList) {
202 neighbors[offsets[e[0]] + neighborsId[e[0]]] = e[1];
204 neighbors[offsets[e[1]] + neighborsId[e[1]]] = e[0];
209 vertexNeighbors.
setData(std::move(neighbors), std::move(offsets));
211 printMsg(
"Built " + std::to_string(vertexNumber) +
" vertex neighbors", 1,
230 std::vector<SimplexId> offsets(vertexNumber + 1);
232 std::vector<SimplexId> cellIds(vertexNumber);
234 const auto cellNumber = cellArray.
getNbCells();
237 for(
SimplexId i = 0; i < cellNumber; ++i) {
239 for(
SimplexId j = 0; j < nbVertCell; ++j) {
245 for(
size_t i = 1; i < offsets.size(); ++i) {
246 offsets[i] += offsets[i - 1];
250 std::vector<SimplexId> data(offsets.back());
253 for(
SimplexId i = 0; i < cellNumber; ++i) {
255 for(
SimplexId j = 0; j < nbVertCell; ++j) {
257 data[offsets[v] + cellIds[v]] = i;
263 vertexStars.
setData(std::move(data), std::move(offsets));
265 printMsg(
"Built " + std::to_string(vertexNumber) +
" vertex stars", 1,
CellArray generic array of cells
LongSimplexId getCellVertex(const LongSimplexId cellId, const SimplexId localVertId) const
LongSimplexId getNbCells() const
Get the number of cells in the array.
SimplexId getCellVertexNumber(const LongSimplexId cellId) const
void setDebugMsgPrefix(const std::string &prefix)
Replacement for std::vector<std::vector<SimplexId>>
size_t dataSize() const
Returns the size of the data_ member.
SimplexId get(SimplexId id, SimplexId local) const
Returns the data inside the sub-vectors.
void setData(std::vector< SimplexId > &&data, std::vector< SimplexId > &&offsets)
Set internal data from pre-existing vectors.
SimplexId size(SimplexId id) const
Get the size of a particular sub-vector.
SimplexId offset(SimplexId id) const
Get the offset of a particular sub-vector.
bool empty() const
If the underlying buffers are empty.
int buildVertexEdges(const SimplexId &vertexNumber, const std::vector< std::array< SimplexId, 2 > > &edgeList, FlatJaggedArray &vertexEdges) const
int buildVertexStars(const SimplexId &vertexNumber, const CellArray &cellArray, FlatJaggedArray &vertexStars) const
int buildVertexLinks(const FlatJaggedArray &vertexStars, const std::vector< std::array< SimplexId, 3 > > &cellEdges, const std::vector< std::array< SimplexId, 2 > > &edgeList, FlatJaggedArray &vertexLinks) const
int buildVertexNeighbors(const SimplexId &vertexNumber, FlatJaggedArray &vertexNeighbors, const std::vector< std::array< SimplexId, 2 > > &edgeList) const
int SimplexId
Identifier type for simplices of any dimension.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)