diff --git a/core/base/approximateTopology/ApproximateTopology.h b/core/base/approximateTopology/ApproximateTopology.h index 192ba6f9e4..148bc804b4 100644 --- a/core/base/approximateTopology/ApproximateTopology.h +++ b/core/base/approximateTopology/ApproximateTopology.h @@ -357,7 +357,7 @@ int ttk::ApproximateTopology::executeApproximateTopology( std::vector vertLockMin(vertexNumber), vertLockMax(vertexNumber); if(preallocateMemory_) { - double tm_prealloc = timer.getElapsedTime(); + const double tm_prealloc = timer.getElapsedTime(); printMsg("Pre-allocating data structures", 0, 0, threadNumber_, ttk::debug::LineMode::REPLACE); for(SimplexId i = 0; i < vertexNumber; ++i) { @@ -400,10 +400,9 @@ int ttk::ApproximateTopology::executeApproximateTopology( initGlobalPolarity(isNew, vertexLinkPolarity, toProcess, fakeScalars, offsets, monotonyOffsets); - double delta = epsilon_ * delta_; + double const delta = epsilon_ * delta_; while(decimationLevel_ > stoppingDecimationLevel_) { - Timer tmIter{}; decimationLevel_--; multiresTriangulation_.setDecimationLevel(decimationLevel_); // double progress = (double)(startingDecimationLevel_ - decimationLevel_) @@ -412,9 +411,9 @@ int ttk::ApproximateTopology::executeApproximateTopology( // progress, timer.getElapsedTime() - tm_allocation, // threadNumber_); - int ret = updateGlobalPolarity(delta, isNew, vertexLinkPolarity, toProcess, - toReprocess, fakeScalars, offsets, - monotonyOffsets); + int const ret = updateGlobalPolarity(delta, isNew, vertexLinkPolarity, + toProcess, toReprocess, fakeScalars, + offsets, monotonyOffsets); if(ret == -1) { std::cout << "Found ERROR - aborting" << std::endl; return -1; @@ -474,7 +473,8 @@ void ttk::ApproximateTopology::computePersistencePairsFromSaddles( const SimplexId nbDecVert = multiresTriangulation_.getDecimatedVertexNumber(); for(SimplexId localId = 0; localId < nbDecVert; localId++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(localId); + const SimplexId globalId + = multiresTriangulation_.localToGlobalVertexId(localId); if(toPropagateMin[globalId]) { getTripletsFromSaddles(globalId, tripletsMin, vertexRepresentativesMin); } @@ -595,7 +595,7 @@ void ttk::ApproximateTopology::tripletsToPersistencePairs( SimplexId r1 = getRep(std::get<1>(t)); SimplexId r2 = getRep(std::get<2>(t)); if(r1 != r2) { - SimplexId s = std::get<0>(t); + SimplexId const s = std::get<0>(t); // Add pair if(splitTree) { @@ -625,7 +625,7 @@ void ttk::ApproximateTopology::tripletsToPersistencePairs( } if(debugLevel_ > 3) { - std::string prefix = splitTree ? "[sad-max]" : "[min-sad]"; + const std::string prefix = splitTree ? "[sad-max]" : "[min-sad]"; std::cout << prefix << " found all pairs in " << tm.getElapsedTime() << " s." << std::endl; } @@ -640,8 +640,6 @@ void ttk::ApproximateTopology::sortVertices( const offsetType *const offsets, const int *const monotonyOffsets) { - Timer tm; - sortedVertices.resize(vertexNumber); // fill with numbers from 0 to vertexNumber - 1 @@ -663,10 +661,6 @@ void ttk::ApproximateTopology::sortVertices( for(size_t i = 0; i < sortedVertices.size(); ++i) { vertsOrder[sortedVertices[i]] = i; } - - // if(debugLevel_ > 2) { - // std::cout << "SORT " << tm.getElapsedTime() << std::endl; - // } } template @@ -706,19 +700,19 @@ int ttk::ApproximateTopology::getMonotonyChangeByOldPointCPApproximate( if(isUpperDynamic != isUpperOld) { // change of monotony SimplexId oldNeighbor = -1; - int oldDecimation = pow(2, decimationLevel_ + 1); + const int oldDecimation = pow(2, decimationLevel_ + 1); multiresTriangulation_.getVertexNeighborAtDecimation( vertexId, i, oldNeighbor, oldDecimation); - double replacementValueDynamic + double const replacementValueDynamic = (0.5 * (double)fakeScalars[oldNeighbor] + .5 * (double)fakeScalars[vertexId]); // depends on epsilon - double deltaDynamic + double const deltaDynamic = fabs((double)fakeScalars[neighborId] - replacementValueDynamic); //===================== SimplexId oldNeighNumber = 0; - SimplexId nnumber + const SimplexId nnumber = multiresTriangulation_.getVertexNeighborNumber(neighborId); for(SimplexId iii = 0; iii < nnumber; iii++) { SimplexId neighborId2 = -1; @@ -849,13 +843,13 @@ ttk::SimplexId ttk::ApproximateTopology::propagateFromSaddles( reps.reserve(CC.size()); for(size_t r = 0; r < CC.size(); r++) { SimplexId neighborId = -1; - SimplexId localId = CC[r]; + const SimplexId localId = CC[r]; multiresTriangulation_.getVertexNeighbor(vertexId, localId, neighborId); // printMsg(" CC " + std::to_string(CC[r]) + " " // + std::to_string(neighborId) + " (" // + std::to_string(fakeScalars[neighborId]) + " , " // + std::to_string(offsets[neighborId]) + ")"); - SimplexId ret = propagateFromSaddles( + SimplexId const ret = propagateFromSaddles( neighborId, vertLock, toPropagate, vertexRepresentatives, saddleCC, isUpdated, globalExtremum, splitTree, fakeScalars, offsets, monotonyOffsets); @@ -882,7 +876,7 @@ ttk::SimplexId ttk::ApproximateTopology::propagateFromSaddles( + std::to_string(saddleCC[vertexId].size())); SimplexId ret = vertexId; - SimplexId neighborNumber + const SimplexId neighborNumber = multiresTriangulation_.getVertexNeighborNumber(vertexId); SimplexId maxNeighbor = vertexId; // std::cout << "neigh number" << neighborNumber << std::endl; @@ -962,7 +956,7 @@ void ttk::ApproximateTopology::updatePropagation( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); + const SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); isUpdatedMin[v] = 0; isUpdatedMax[v] = 0; } @@ -972,7 +966,7 @@ void ttk::ApproximateTopology::updatePropagation( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const v = multiresTriangulation_.localToGlobalVertexId(i); if(toPropagateMin[v]) { propagateFromSaddles(v, vertLockMin, toPropagateMin, vertexRepresentativesMin, saddleCCMin, isUpdatedMin, @@ -1003,7 +997,7 @@ void ttk::ApproximateTopology::updatePropagation( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const v = multiresTriangulation_.localToGlobalVertexId(i); #ifdef TTK_ENABLE_OPENMP const auto tid = omp_get_thread_num(); @@ -1190,7 +1184,7 @@ void ttk::ApproximateTopology::initGlobalPolarity( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); buildVertexLinkPolarityApproximate(globalId, vertexLinkPolarity[globalId], fakeScalars, offsets, monotonyOffsets); toProcess[globalId] = 255; @@ -1211,14 +1205,14 @@ int ttk::ApproximateTopology::updateGlobalPolarity( const offsetType *const offsets, int *monotonyOffsets) const { - Timer tm; const auto nDecVerts = multiresTriangulation_.getDecimatedVertexNumber(); #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(SimplexId localId = 0; localId < nDecVerts; localId++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(localId); + SimplexId const globalId + = multiresTriangulation_.localToGlobalVertexId(localId); if(!isNew[globalId]) { getMonotonyChangeByOldPointCPApproximate( globalId, eps, isNew, toProcess, toReprocess, @@ -1231,7 +1225,7 @@ int ttk::ApproximateTopology::updateGlobalPolarity( #pragma omp parallel for num_threads(threadNumber_) #endif for(int i = 0; i < multiresTriangulation_.getDecimatedVertexNumber(); i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); if(isNew[globalId]) { // new point if(decimationLevel_ > stoppingDecimationLevel_) { buildVertexLinkPolarityApproximate( @@ -1273,7 +1267,7 @@ void ttk::ApproximateTopology::computeCriticalPoints( #pragma omp parallel for num_threads(threadNumber_) #endif for(int i = 0; i < multiresTriangulation_.getDecimatedVertexNumber(); i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); if(toProcess[globalId]) { // nbComputations++; diff --git a/core/base/arrayPreconditioning/ArrayPreconditioning.h b/core/base/arrayPreconditioning/ArrayPreconditioning.h index 1a1a5b1535..227c6a953f 100644 --- a/core/base/arrayPreconditioning/ArrayPreconditioning.h +++ b/core/base/arrayPreconditioning/ArrayPreconditioning.h @@ -32,7 +32,12 @@ namespace ttk { const GVLID &getVertexLocalId, const size_t nVerts, const int burstSize, +#ifdef TTK_ENABLE_MPI std::vector neighbors +#else + const std::vector &neighbors +#endif + = {}) const { // start global timer ttk::Timer globalTimer; diff --git a/core/base/assignmentSolver/AssignmentAuction.h b/core/base/assignmentSolver/AssignmentAuction.h index ae0f94d409..341074fe5a 100644 --- a/core/base/assignmentSolver/AssignmentAuction.h +++ b/core/base/assignmentSolver/AssignmentAuction.h @@ -100,8 +100,8 @@ namespace ttk { template dataType getMaxValue(std::vector> &matrix, bool balancedAsgn) { - unsigned int nRows = matrix.size(); - unsigned int nCols = matrix[0].size(); + unsigned int const nRows = matrix.size(); + unsigned int const nCols = matrix[0].size(); dataType maxValue = std::numeric_limits::lowest(); for(unsigned int i = 0; i < nRows; ++i) { for(unsigned int j = 0; j < nCols; ++j) { @@ -155,13 +155,13 @@ namespace ttk { template void AssignmentAuction::makeBalancedMatrix( std::vector> &matrix) { - unsigned int nRows = matrix.size(); - unsigned int nCols = matrix[0].size(); + unsigned int const nRows = matrix.size(); + unsigned int const nCols = matrix[0].size(); matrix[nRows - 1][nCols - 1] = 0; // Add rows for(unsigned int i = 0; i < nCols - 2; ++i) { - std::vector newLine(matrix[nRows - 1]); + std::vector const newLine(matrix[nRows - 1]); matrix.push_back(newLine); } // Add columns @@ -183,7 +183,7 @@ namespace ttk { unassignedBidders.push(i); while(!unassignedBidders.empty()) { - int bidderId = unassignedBidders.front(); + int const bidderId = unassignedBidders.front(); unassignedBidders.pop(); // Get good with highest value @@ -214,7 +214,7 @@ namespace ttk { bestSecondValue = bestValue; // Update price - double delta = abs(bestValue - bestSecondValue) + epsilon; + double const delta = abs(bestValue - bestSecondValue) + epsilon; double newPrice = goodPrices[bestGoodId] + delta; if(newPrice > std::numeric_limits::max() / 2) { // Avoid price explosion @@ -253,7 +253,8 @@ namespace ttk { dataType bestCost = std::numeric_limits::max(); // Try to avoid price war - double tempPrice = *std::max_element(goodPrices.begin(), goodPrices.end()); + double const tempPrice + = *std::max_element(goodPrices.begin(), goodPrices.end()); std::vector savedPrices; for(unsigned int i = 0; i < goodPrices.size(); ++i) { auto old = goodPrices[i]; @@ -293,8 +294,8 @@ namespace ttk { // Create output matching for(unsigned int bidderId = 0; bidderId < bidderAssignments.size(); ++bidderId) { - int i = bidderId; - int j = bidderAssignments[bidderId]; + int const i = bidderId; + int const j = bidderAssignments[bidderId]; if(this->balancedAssignment or (not this->balancedAssignment and not(i >= this->rowSize - 1 and j >= this->colSize - 1))) { @@ -346,8 +347,8 @@ namespace ttk { dataType d = 0; for(unsigned int bidderId = 0; bidderId < bidderAssignments.size(); ++bidderId) { - int i = bidderId; - int j = bidderAssignments[bidderId]; + int const i = bidderId; + int const j = bidderAssignments[bidderId]; d += cMatrix[i][j]; } return d; diff --git a/core/base/assignmentSolver/AssignmentExhaustive.h b/core/base/assignmentSolver/AssignmentExhaustive.h index 8a11233ed8..c3ba91f0f9 100644 --- a/core/base/assignmentSolver/AssignmentExhaustive.h +++ b/core/base/assignmentSolver/AssignmentExhaustive.h @@ -60,19 +60,19 @@ namespace ttk { queue; std::vector asgn_temp, unasgn_temp; - std::vector done_temp(max_dim, false); - queue.push(std::make_tuple(asgn_temp, unasgn_temp, false, done_temp, -1)); + std::vector const done_temp(max_dim, false); + queue.emplace(asgn_temp, unasgn_temp, false, done_temp, -1); while(!queue.empty()) { auto queueElem = queue.front(); queue.pop(); - std::vector asgn = std::get<0>(queueElem); - std::vector unasgn = std::get<1>(queueElem); - bool toUnasgn = std::get<2>(queueElem); + std::vector const asgn = std::get<0>(queueElem); + std::vector const unasgn = std::get<1>(queueElem); + bool const toUnasgn = std::get<2>(queueElem); std::vector done = std::get<3>(queueElem); - unsigned int maxDone = std::get<4>(queueElem); + unsigned int const maxDone = std::get<4>(queueElem); - unsigned int ind = asgn.size(); + unsigned int const ind = asgn.size(); for(unsigned int j = 0; j < max_dim + 1; ++j) { std::vector new_asgn(asgn); std::vector new_unasgn(unasgn); @@ -95,7 +95,7 @@ namespace ttk { } new_done[j] = true; - unsigned int new_ind = new_asgn.size(); + unsigned int const new_ind = new_asgn.size(); if(new_ind == max_dim) { // A new assignment is made here for(auto &new_unasgn_elem : new_unasgn) @@ -103,14 +103,12 @@ namespace ttk { // std::sort(new_asgn.begin()+min_dim, new_asgn.end()); allAsgn.push_back(new_asgn); } else - queue.push(std::make_tuple( - new_asgn, new_unasgn, false, new_done, new_maxDone)); + queue.emplace(new_asgn, new_unasgn, false, new_done, new_maxDone); } else { if(not toUnasgn and ind < min_dim) { new_asgn.push_back(max_dim); - queue.push(std::make_tuple( - new_asgn, new_unasgn, true, new_done, new_maxDone)); + queue.emplace(new_asgn, new_unasgn, true, new_done, new_maxDone); } } } @@ -145,17 +143,17 @@ namespace ttk { template dataType AssignmentExhaustive::tryAssignment( std::vector &asgn, std::vector &matchings) { - unsigned int nRows = this->costMatrix.size() - 1; - unsigned int nCols = this->costMatrix[0].size() - 1; + unsigned int const nRows = this->costMatrix.size() - 1; + unsigned int const nCols = this->costMatrix[0].size() - 1; // int max_dim = std::max(nRows, nCols); - unsigned int min_dim = std::min(nRows, nCols); - bool transpose = nRows > nCols; + unsigned int const min_dim = std::min(nRows, nCols); + bool const transpose = nRows > nCols; dataType cost = 0; for(unsigned int ind = 0; ind < asgn.size(); ++ind) { - int indMatrix = std::min(ind, min_dim); - int i = (!transpose) ? indMatrix : asgn[ind]; - int j = (!transpose) ? asgn[ind] : indMatrix; + int const indMatrix = std::min(ind, min_dim); + int const i = (!transpose) ? indMatrix : asgn[ind]; + int const j = (!transpose) ? asgn[ind] : indMatrix; cost += this->costMatrix[i][j]; matchings.push_back(std::make_tuple(i, j, this->costMatrix[i][j])); } @@ -165,10 +163,10 @@ namespace ttk { template int AssignmentExhaustive::run( std::vector &matchings) { - int nRows = this->costMatrix.size() - 1; - int nCols = this->costMatrix[0].size() - 1; - int max_dim = std::max(nRows, nCols); - int min_dim = std::min(nRows, nCols); + int const nRows = this->costMatrix.size() - 1; + int const nCols = this->costMatrix[0].size() - 1; + int const max_dim = std::max(nRows, nCols); + int const min_dim = std::min(nRows, nCols); // --- Construct all possible assignments std::vector> allAsgn; @@ -200,7 +198,7 @@ namespace ttk { else { std::stringstream ss; ss << min_dim << "_" << max_dim; - std::string asgnName = ss.str(); + std::string const asgnName = ss.str(); // not found if(not saveAsgn or savedAsgn.find(asgnName) == savedAsgn.end()) { if(saveAsgn) diff --git a/core/base/assignmentSolver/AssignmentMunkres.h b/core/base/assignmentSolver/AssignmentMunkres.h index 8e134b5f87..bf669838c6 100644 --- a/core/base/assignmentSolver/AssignmentMunkres.h +++ b/core/base/assignmentSolver/AssignmentMunkres.h @@ -51,7 +51,7 @@ namespace ttk { for(int row = 0; row < this->rowSize; ++row) M[row].resize(c); - int nbPaths = 1 + this->colSize + this->rowSize; + const int nbPaths = 1 + this->colSize + this->rowSize; path.resize((unsigned long)nbPaths); for(int p = 0; p < nbPaths; ++p) path[p].resize(2); @@ -152,8 +152,8 @@ namespace ttk { inline int copyInputMatrix(std::vector> &saveInput) { auto C = AssignmentSolver::getCostMatrixPointer(); - int rS = this->rowSize; - int cS = this->colSize; + const int rS = this->rowSize; + const int cS = this->colSize; for(int r = 0; r < rS; ++r) for(int c = 0; c < cS; ++c) diff --git a/core/base/assignmentSolver/AssignmentMunkresImpl.h b/core/base/assignmentSolver/AssignmentMunkresImpl.h index ae2909bc89..57fe6611da 100644 --- a/core/base/assignmentSolver/AssignmentMunkresImpl.h +++ b/core/base/assignmentSolver/AssignmentMunkresImpl.h @@ -9,7 +9,7 @@ int ttk::AssignmentMunkres::run( std::vector &matchings) { int step = 1; int iter = 0; - int maxIter = 100000; + const int maxIter = 100000; bool done = false; Timer t; @@ -24,7 +24,8 @@ int ttk::AssignmentMunkres::run( debug::Priority::DETAIL); if(iter > 20 && (iter % (int)std::round((double)maxIter / 5.0) == 0)) { - double progress = std::round(100.0 * (double)iter / (double)maxIter); + double const progress + = std::round(100.0 * (double)iter / (double)maxIter); this->printMsg("Progress", progress / 100.0, t.getElapsedTime()); } @@ -249,8 +250,8 @@ template int ttk::AssignmentMunkres::stepThree(int &step) // ~ 10% perf { for(int r = 0; r < this->rowSize; ++r) { - int start = rowLimitsMinus[r]; - int end = rowLimitsPlus[r]; + const int start = rowLimitsMinus[r]; + const int end = rowLimitsPlus[r]; for(int c = start; c < end; ++c) if(M[r][c] == 1) colCover[c] = true; @@ -291,7 +292,7 @@ int ttk::AssignmentMunkres::stepFour(int &step) // ~ 45% perf else { M[row][col] = 2; - int colOfStarInRow = findStarInRow(row); + const int colOfStarInRow = findStarInRow(row); // If a star was found and it is not in the last row if(colOfStarInRow > -1 && row < this->rowSize - 1) { rowCover[row] = true; @@ -312,8 +313,8 @@ int ttk::AssignmentMunkres::stepFour(int &step) // ~ 45% perf template int ttk::AssignmentMunkres::findStarInRow(int row) { - int start = rowLimitsMinus[row]; - int end = rowLimitsPlus[row]; + const int start = rowLimitsMinus[row]; + const int end = rowLimitsPlus[row]; for(int c = start; c < end; ++c) if(M[row][c] == 1) return c; @@ -328,9 +329,9 @@ int ttk::AssignmentMunkres::findZero(int &row, int &col) { col = -1; while(createdZeros.size() > 0) { - std::pair zero = createdZeros.back(); - int f = zero.first; - int s = zero.second; + const std::pair zero = createdZeros.back(); + const int f = zero.first; + const int s = zero.second; createdZeros.pop_back(); if(!rowCover[f] && !colCover[s]) { row = f; @@ -340,8 +341,8 @@ int ttk::AssignmentMunkres::findZero(int &row, int &col) { } for(int r = 0; r < this->rowSize; ++r) { - int start = rowLimitsMinus[r]; - int end = rowLimitsPlus[r]; + const int start = rowLimitsMinus[r]; + const int end = rowLimitsPlus[r]; if(rowCover[r]) continue; @@ -418,8 +419,8 @@ int ttk::AssignmentMunkres::stepFive(int &step) // ~ 10% perf // erase primes for(int r = 0; r < this->rowSize; ++r) { - int start = rowLimitsMinus[r]; - int end = rowLimitsPlus[r]; + const int start = rowLimitsMinus[r]; + const int end = rowLimitsPlus[r]; for(int c = start; c < end; ++c) if(M[r][c] == 2) M[r][c] = 0; @@ -431,8 +432,8 @@ int ttk::AssignmentMunkres::stepFive(int &step) // ~ 10% perf template int ttk::AssignmentMunkres::findStarInCol(int col) { - int start = colLimitsMinus[col]; - int end = colLimitsPlus[col]; + const int start = colLimitsMinus[col]; + const int end = colLimitsPlus[col]; for(int r = start; r < end; ++r) if(M[r][col] == 1) return r; @@ -444,8 +445,8 @@ int ttk::AssignmentMunkres::findStarInCol(int col) { template int ttk::AssignmentMunkres::findPrimeInRow(int row) { - int start = rowLimitsMinus[row]; - int end = rowLimitsPlus[row]; + const int start = rowLimitsMinus[row]; + const int end = rowLimitsPlus[row]; for(int c = start; c < end; ++c) if(M[row][c] == 2) return c; @@ -467,8 +468,8 @@ int ttk::AssignmentMunkres::stepSix(int &step) // ~ 35% perf if(rowCover[r]) continue; - int start = rowLimitsMinus[r]; - int end = rowLimitsPlus[r]; + const int start = rowLimitsMinus[r]; + const int end = rowLimitsPlus[r]; for(int c = start; c < end; ++c) { if(colCover[c]) @@ -483,8 +484,8 @@ int ttk::AssignmentMunkres::stepSix(int &step) // ~ 35% perf // add and subtract for(int r = 0; r < this->rowSize; ++r) { - int start = rowLimitsMinus[r]; - int end = rowLimitsPlus[r]; + const int start = rowLimitsMinus[r]; + const int end = rowLimitsPlus[r]; for(int c = start; c < end; ++c) { if(rowCover[r]) @@ -512,8 +513,8 @@ template int ttk::AssignmentMunkres::affect( std::vector &matchings, const std::vector> &C) { - int nbC = this->colSize; - int nbR = this->rowSize; + const int nbC = this->colSize; + const int nbR = this->rowSize; matchings.clear(); @@ -544,8 +545,8 @@ int ttk::AssignmentMunkres::affect( template int ttk::AssignmentMunkres::computeAffectationCost( const std::vector> &C) { - int nbC = this->colSize; - int nbR = this->rowSize; + const int nbC = this->colSize; + const int nbR = this->rowSize; dataType total = 0; diff --git a/core/base/assignmentSolver/AssignmentSolver.h b/core/base/assignmentSolver/AssignmentSolver.h index 174a41462d..32df8553e7 100644 --- a/core/base/assignmentSolver/AssignmentSolver.h +++ b/core/base/assignmentSolver/AssignmentSolver.h @@ -65,7 +65,7 @@ namespace ttk { void printTableVector(std::vector> &table) { for(auto vecTemp : table) { - std::stringstream ss; + const std::stringstream ss; for(auto valTemp : vecTemp) { ss << valTemp << " "; } diff --git a/core/base/barycentricSubdivision/BarycentricSubdivision.h b/core/base/barycentricSubdivision/BarycentricSubdivision.h index c522ca5a2c..dda3d24717 100644 --- a/core/base/barycentricSubdivision/BarycentricSubdivision.h +++ b/core/base/barycentricSubdivision/BarycentricSubdivision.h @@ -271,7 +271,7 @@ int ttk::BarycentricSubdivision::subdiviseTriangulation( // subdivise every triangle for(SimplexId i = 0; i < nTriangles_; ++i) { // id of triangle barycenter - SimplexId bary = nVertices_ + nEdges_ + i; + const SimplexId bary = nVertices_ + nEdges_ + i; for(SimplexId j = 0; j < inputTriangl.getTriangleEdgeNumber(i); ++j) { // edge id @@ -279,7 +279,7 @@ int ttk::BarycentricSubdivision::subdiviseTriangulation( inputTriangl.getTriangleEdge(i, j, e); // id of middle of edge e - SimplexId em = nVertices_ + e; + const SimplexId em = nVertices_ + e; // edge vertices SimplexId a{}, b{}; diff --git a/core/base/bottleneckDistance/BottleneckDistance.cpp b/core/base/bottleneckDistance/BottleneckDistance.cpp index 12aa019586..14310fb9e0 100644 --- a/core/base/bottleneckDistance/BottleneckDistance.cpp +++ b/core/base/bottleneckDistance/BottleneckDistance.cpp @@ -17,7 +17,7 @@ int ttk::BottleneckDistance::execute(const ttk::DiagramType &diag0, return -1; } - bool fromParaView = this->PVAlgorithm >= 0; + const bool fromParaView = this->PVAlgorithm >= 0; if(fromParaView) { switch(this->PVAlgorithm) { case 0: @@ -108,10 +108,10 @@ void ttk::BottleneckDistance::buildCostMatrices( || p1.death.type == CriticalType::Local_minimum); bool isMax1 = (p1.birth.type == CriticalType::Local_maximum || p1.death.type == CriticalType::Local_maximum); - bool isSad1 = (p1.birth.type == CriticalType::Saddle1 - && p1.death.type == CriticalType::Saddle2) - || (p1.birth.type == CriticalType::Saddle2 - && p1.death.type == CriticalType::Saddle1); + const bool isSad1 = (p1.birth.type == CriticalType::Saddle1 + && p1.death.type == CriticalType::Saddle2) + || (p1.birth.type == CriticalType::Saddle2 + && p1.death.type == CriticalType::Saddle1); if(p1.birth.type == CriticalType::Local_minimum && p1.death.type == CriticalType::Local_maximum) { isMin1 = false; @@ -130,10 +130,10 @@ void ttk::BottleneckDistance::buildCostMatrices( || p2.death.type == CriticalType::Local_minimum); bool isMax2 = (p2.birth.type == CriticalType::Local_maximum || p2.death.type == CriticalType::Local_maximum); - bool isSad2 = (p2.birth.type == CriticalType::Saddle1 - && p2.death.type == CriticalType::Saddle2) - || (p2.birth.type == CriticalType::Saddle2 - && p2.death.type == CriticalType::Saddle1); + const bool isSad2 = (p2.birth.type == CriticalType::Saddle1 + && p2.death.type == CriticalType::Saddle2) + || (p2.birth.type == CriticalType::Saddle2 + && p2.death.type == CriticalType::Saddle1); if(p2.birth.type == CriticalType::Local_minimum && p2.death.type == CriticalType::Local_maximum) { isMin2 = false; @@ -143,8 +143,8 @@ void ttk::BottleneckDistance::buildCostMatrices( continue; double distance = this->distanceFunction(p1, p2, wasserstein); - double diag1 = this->diagonalDistanceFunction(p1, wasserstein); - double diag2 = this->diagonalDistanceFunction(p2, wasserstein); + const double diag1 = this->diagonalDistanceFunction(p1, wasserstein); + const double diag2 = this->diagonalDistanceFunction(p2, wasserstein); if(distance > diag1 + diag2) distance = std::numeric_limits::max(); @@ -167,7 +167,8 @@ void ttk::BottleneckDistance::buildCostMatrices( } } - double distanceToDiagonal = this->diagonalDistanceFunction(p1, wasserstein); + const double distanceToDiagonal + = this->diagonalDistanceFunction(p1, wasserstein); if(isMin1) { if(reverseMin) minMatrix[minJ++][minI] = distanceToDiagonal; @@ -208,17 +209,18 @@ void ttk::BottleneckDistance::buildCostMatrices( || p3.death.type == CriticalType::Local_minimum); bool isMax2 = (p3.birth.type == CriticalType::Local_maximum || p3.death.type == CriticalType::Local_maximum); - bool isSad2 = (p3.birth.type == CriticalType::Saddle1 - && p3.death.type == CriticalType::Saddle2) - || (p3.birth.type == CriticalType::Saddle2 - && p3.death.type == CriticalType::Saddle1); + const bool isSad2 = (p3.birth.type == CriticalType::Saddle1 + && p3.death.type == CriticalType::Saddle2) + || (p3.birth.type == CriticalType::Saddle2 + && p3.death.type == CriticalType::Saddle1); if(p3.birth.type == CriticalType::Local_minimum && p3.death.type == CriticalType::Local_maximum) { isMin2 = false; isMax2 = true; } - double distanceToDiagonal = this->diagonalDistanceFunction(p3, wasserstein); + const double distanceToDiagonal + = this->diagonalDistanceFunction(p3, wasserstein); if(isMin2) { if(reverseMin) minMatrix[minJ++][minI] = distanceToDiagonal; @@ -311,7 +313,7 @@ double ttk::BottleneckDistance::computeMinimumRelevantPersistence( const ttk::DiagramType &CTDiagram2) const { const auto sp = this->Tolerance; - double s = sp > 0.0 && sp < 100.0 ? sp / 100.0 : 0; + const double s = sp > 0.0 && sp < 100.0 ? sp / 100.0 : 0; std::vector toSort(CTDiagram1.size() + CTDiagram2.size()); for(size_t i = 0; i < CTDiagram1.size(); ++i) { @@ -370,29 +372,31 @@ void ttk::BottleneckDistance::computeMinMaxSaddleNumberAndMapping( } } -static void solvePWasserstein(std::vector> &matrix, - std::vector &matchings, - ttk::AssignmentMunkres &solver) { +namespace { + void solvePWasserstein(std::vector> &matrix, + std::vector &matchings, + ttk::AssignmentMunkres &solver) { - solver.setInput(matrix); - solver.run(matchings); - solver.clearMatrix(); -} + solver.setInput(matrix); + solver.run(matchings); + solver.clearMatrix(); + } -static void solveInfinityWasserstein(const int nbRow, - const int nbCol, - std::vector> &matrix, - std::vector &matchings, - ttk::GabowTarjan &solver) { + void solveInfinityWasserstein(const int nbRow, + const int nbCol, + std::vector> &matrix, + std::vector &matchings, + ttk::GabowTarjan &solver) { - // Copy input matrix. - auto bottleneckMatrix = matrix; + // Copy input matrix. + auto bottleneckMatrix = matrix; - // Solve. - solver.setInput(nbRow, nbCol, &bottleneckMatrix); - solver.run(matchings); - solver.clear(); -} + // Solve. + solver.setInput(nbRow, nbCol, &bottleneckMatrix); + solver.run(matchings); + solver.clear(); + } +} // namespace double ttk::BottleneckDistance::buildMappings( const std::vector &inputMatchings, @@ -475,7 +479,7 @@ double ttk::BottleneckDistance::distanceFunction(const ttk::PersistencePair &a, - std::abs(b.birth.coords[2] + b.death.coords[2]) / 2, w)); - double persDistance = x + y; + const double persDistance = x + y; return Geometry::pow(persDistance + geoDistance, 1.0 / w); } @@ -640,8 +644,8 @@ int ttk::BottleneckDistance::computeBottleneck( double partialDistance{}; for(const auto &mt : matchings) { - int i = transposeOriginal ? std::get<1>(mt) : std::get<0>(mt); - int j = transposeOriginal ? std::get<0>(mt) : std::get<1>(mt); + const int i = transposeOriginal ? std::get<1>(mt) : std::get<0>(mt); + const int j = transposeOriginal ? std::get<0>(mt) : std::get<1>(mt); const auto &t1 = CTDiagram1[i]; const auto &t2 = CTDiagram2[j]; @@ -682,7 +686,6 @@ int ttk::BottleneckDistance::computeBottleneck( : std::max(affectationD, *std::max_element(addedPersistence.begin(), addedPersistence.end())); - std::stringstream msg; this->printMsg("Computed distance:"); this->printMsg("diagMax(" + std::to_string(addedPersistence[2]) + "), diagMin(" + std::to_string(addedPersistence[0]) @@ -704,7 +707,7 @@ int ttk::BottleneckDistance::computeBottleneck( this->costs_ = costs; // display results - std::vector> rows{ + const std::vector> rows{ {" Min-saddle cost", std::to_string(this->costs_[0])}, {" Saddle-saddle cost", std::to_string(this->costs_[1])}, {" Saddle-max cost", std::to_string(this->costs_[2])}, diff --git a/core/base/bottleneckDistance/GabowTarjan.cpp b/core/base/bottleneckDistance/GabowTarjan.cpp index 2ec4b6a4d2..9a3e93e89c 100644 --- a/core/base/bottleneckDistance/GabowTarjan.cpp +++ b/core/base/bottleneckDistance/GabowTarjan.cpp @@ -10,7 +10,7 @@ bool ttk::GabowTarjan::DFS(int v) { // for every adjacent vertex u of v for(unsigned int i = 0; i < Connections[v].size(); ++i) { - int u = Connections[v][i]; + const int u = Connections[v][i]; if(Layers[Pair[u] + 1] == Layers[v + 1] + 1) { if(DFS(Pair[u])) { Pair[u] = v; @@ -46,11 +46,11 @@ bool ttk::GabowTarjan::BFS() { // Search the vertices in the queue while(!vertexQueue.empty()) { - int v = vertexQueue.front(); + const int v = vertexQueue.front(); vertexQueue.pop(); if(Layers[v + 1] > Layers[0]) { for(unsigned int i = 0; i < Connections[v].size(); ++i) { - int u = Connections[v][i]; + const int u = Connections[v][i]; // Check if the vertex has an edge to the match vertex if(Layers[Pair[u] + 1] < 0) { // Set the layer of the vertex (it can be NIL) which is matched to the @@ -100,19 +100,17 @@ double ttk::GabowTarjan::Distance() { // First non added edge is an iterator pointing to the first edge // in Edges which was added to the Connections unsigned int firstNotAddedEdge = 0; - unsigned int nbEdges = (unsigned int)Edges.size(); + const unsigned int nbEdges = (unsigned int)Edges.size(); unsigned int lowerBound = 0; unsigned int upperBound = nbEdges; unsigned int guessEdge = (lowerBound + nbEdges) / 2; - std::map offPairings; - // Repeat till all the vertices are matched while(matching < MaxSize) { // Save initial matching. matching0 = matching; - unsigned int oldGuessEdge = guessEdge; + const unsigned int oldGuessEdge = guessEdge; currentWeight = Edges[guessEdge].weight; while(Edges[guessEdge].weight == currentWeight && guessEdge < nbEdges) @@ -124,8 +122,8 @@ double ttk::GabowTarjan::Distance() { // Add the edges with the current weight (distance) to the connection matrix while(firstNotAddedEdge >= guessEdge) { - int v1 = Edges[firstNotAddedEdge].v1; - int v2 = Edges[firstNotAddedEdge].v2; + const int v1 = Edges[firstNotAddedEdge].v1; + const int v2 = Edges[firstNotAddedEdge].v2; std::vector vec1 = Connections[v1]; vec1.erase(std::remove(vec1.begin(), vec1.end(), v2), vec1.end()); @@ -137,8 +135,8 @@ double ttk::GabowTarjan::Distance() { // Edges[firstNotAddedEdge].weight == currentWeight && firstNotAddedEdge < // nbEdges while(firstNotAddedEdge < guessEdge) { - int v1 = Edges[firstNotAddedEdge].v1; - int v2 = Edges[firstNotAddedEdge].v2; + const int v1 = Edges[firstNotAddedEdge].v1; + const int v2 = Edges[firstNotAddedEdge].v2; Connections[v1].push_back(v2); ++firstNotAddedEdge; @@ -175,8 +173,6 @@ double ttk::GabowTarjan::Distance() { // Check if we did not run out of edges. This should never happen. if(firstNotAddedEdge == nbEdges) { - std::stringstream msg; - ttk::Debug d; this->printMsg("Not enough edges to find the matching!"); // return -1; return currentWeight; @@ -199,14 +195,14 @@ double ttk::GabowTarjan::Distance() { } void ttk::GabowTarjan::printCurrentMatching() { - int size = 2 * MaxSize; + const int size = 2 * MaxSize; std::vector missedPlaces; { std::stringstream msg; msg << "Assignment matrix: " << std::endl; for(int i = 0; i < size; ++i) { - int k = Pair[i]; + const int k = Pair[i]; if(k < 0 || k > size) missedPlaces.push_back(i); for(int j = 0; j < size; ++j) { @@ -220,7 +216,6 @@ void ttk::GabowTarjan::printCurrentMatching() { { std::stringstream msg; - ttk::Debug d; msg << "Missed:" << std::endl; for(unsigned int i = 0; i < missedPlaces.size(); ++i) { msg << missedPlaces.at(i) << " "; @@ -232,7 +227,7 @@ void ttk::GabowTarjan::printCurrentMatching() { int ttk::GabowTarjan::run(std::vector &matchings) { // Compute distance. - double dist = this->Distance(); + const double dist = this->Distance(); this->printMsg("Computed distance " + std::to_string(dist)); // Fill matchings. @@ -242,7 +237,7 @@ int ttk::GabowTarjan::run(std::vector &matchings) { if(Pair[i] == -1) continue; - int j = Pair[i] - MaxSize; + const int j = Pair[i] - MaxSize; if(j <= -1 || (j < (int)Size2 && Pair[j + MaxSize] != (int)i)) { this->printErr("Hopcroft-Karp built an invalid matching."); // return -1; @@ -259,7 +254,7 @@ int ttk::GabowTarjan::run(std::vector &matchings) { if(Pair[j] == -1) continue; - int i = Pair[j] - MaxSize - Size2; + const int i = Pair[j] - MaxSize - Size2; if(i > -1 && (i >= (int)Size1 || Pair[i + MaxSize + Size2] != (int)j)) { this->printErr("Hopcroft-Karp built an invalid matching."); // return -1; diff --git a/core/base/bottleneckDistance/GabowTarjan.h b/core/base/bottleneckDistance/GabowTarjan.h index 0b120088c4..fb6f23d653 100644 --- a/core/base/bottleneckDistance/GabowTarjan.h +++ b/core/base/bottleneckDistance/GabowTarjan.h @@ -53,27 +53,32 @@ namespace ttk { // Connect diagonal points. for(unsigned int i = Size1; i < MaxSize; ++i) - for(unsigned int j = MaxSize + Size2; j < 2 * MaxSize; ++j) - Edges.emplace_back(Edge(i, j, (double)0)); + for(unsigned int j = MaxSize + Size2; j < 2 * MaxSize; ++j) { + const Edge localEdge(i, j, (double)0); + Edges.emplace_back(localEdge); + } // Connect real points. for(unsigned int i = 0; i < Size1; ++i) { unsigned int k = MaxSize; for(unsigned int j = 0; j < Size2; ++j) { auto val = (*C_)[i][j]; - Edges.emplace_back(Edge(i, k++, val)); + const Edge localEdge(i, k++, val); + Edges.emplace_back(localEdge); } } // Connect real points with their diagonal. for(unsigned int i = 0; i < Size1; ++i) { auto val = (*C_)[i][Size2]; - Edges.emplace_back(Edge(i, MaxSize + Size2 + i, val)); + const Edge localEdge(i, MaxSize + Size2 + i, val); + Edges.emplace_back(localEdge); } for(unsigned int j = 0, k = MaxSize; j < Size2; ++j, ++k) { auto val = (*C_)[Size1][j]; - Edges.emplace_back(Edge(Size1 + (k - MaxSize), k, val)); + const Edge localEdge(Size1 + (k - MaxSize), k, val); + Edges.emplace_back(localEdge); } std::sort(Edges.begin(), Edges.end()); diff --git a/core/base/boundingVolumeHierarchy/BoundingVolumeHierarchy.h b/core/base/boundingVolumeHierarchy/BoundingVolumeHierarchy.h index afb89e2e3e..be3d92abe8 100644 --- a/core/base/boundingVolumeHierarchy/BoundingVolumeHierarchy.h +++ b/core/base/boundingVolumeHierarchy/BoundingVolumeHierarchy.h @@ -122,10 +122,10 @@ namespace ttk { maxY = std::max(t.m_maxY, maxY); maxZ = std::max(t.m_maxZ, maxZ); } - int numberTriangles = end - start; + const int numberTriangles = end - start; if(numberTriangles == 1) { const Triangle &t = triangles[start]; - std::vector indices = {t.m_index}; + std::vector const indices = {t.m_index}; float pMin[3] = {t.m_minX, t.m_minY, t.m_minZ}; float pMax[3] = {t.m_maxX, t.m_maxY, t.m_maxZ}; return std::make_shared(indices, 1, pMin, pMax); @@ -147,10 +147,10 @@ namespace ttk { cmaxZ = std::max(t.m_centroid_z, cmaxZ); } // figure out the biggest extent, use that dimension - float diffX = std::abs(cmaxX - cminX); - float diffY = std::abs(cmaxY - cminY); - float diffZ = std::abs(cmaxZ - cminZ); - float maximumExtent = std::max({diffX, diffY, diffZ}); + const float diffX = std::abs(cmaxX - cminX); + const float diffY = std::abs(cmaxY - cminY); + const float diffZ = std::abs(cmaxZ - cminZ); + const float maximumExtent = std::max({diffX, diffY, diffZ}); int axis; float minToCheck, maxToCheck; if(maximumExtent == diffX) { @@ -166,7 +166,7 @@ namespace ttk { minToCheck = cminZ; maxToCheck = cmaxZ; } - size_t half = (start + end) / 2; + size_t const half = (start + end) / 2; // partition triangles into two sets and build children if(minToCheck == maxToCheck) { @@ -253,23 +253,23 @@ namespace ttk { ttk::Geometry::subtractVectors( &vertexCoords[v0], &vertexCoords[v2], v0v2); ttk::Geometry::crossProduct(ray.m_direction, v0v2, pvec); - float det = ttk::Geometry::dotProduct(v0v1, pvec); + const float det = ttk::Geometry::dotProduct(v0v1, pvec); if(det > -kEpsilon && det < kEpsilon) return false; - float invDet = 1.0f / det; + const float invDet = 1.0f / det; ttk::Geometry::subtractVectors(&vertexCoords[v0], ray.m_origin, tvec); - float u = ttk::Geometry::dotProduct(tvec, pvec) * invDet; + const float u = ttk::Geometry::dotProduct(tvec, pvec) * invDet; if(u < 0.0 || u > 1.0) return false; ttk::Geometry::crossProduct(tvec, v0v1, qvec); - float v = ttk::Geometry::dotProduct(ray.m_direction, qvec) * invDet; + const float v = ttk::Geometry::dotProduct(ray.m_direction, qvec) * invDet; if(v < 0.0 || u + v > 1.0) return false; - float t = ttk::Geometry::dotProduct(v0v2, qvec) * invDet; + const float t = ttk::Geometry::dotProduct(v0v2, qvec) * invDet; ray.distance = t; ray.u = u; ray.v = v; @@ -299,7 +299,7 @@ namespace ttk { for(int i = 0; i < node->numTriangles; i++) { bool hasHit = false; - int triIdx = node->indices[i]; + int const triIdx = node->indices[i]; IT v0 = connectivityList[triIdx * 3 + 0]; IT v1 = connectivityList[triIdx * 3 + 1]; diff --git a/core/base/cinemaImaging/CinemaImagingEmbree.cpp b/core/base/cinemaImaging/CinemaImagingEmbree.cpp index 5013643619..be7f4a0d93 100644 --- a/core/base/cinemaImaging/CinemaImagingEmbree.cpp +++ b/core/base/cinemaImaging/CinemaImagingEmbree.cpp @@ -70,7 +70,7 @@ int ttk::CinemaImagingEmbree::renderImage( rtcInitIntersectContext(&context); const auto normalize = [](double out[3], const double in[3]) { - double temp = sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]); + const double temp = sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]); out[0] = in[0] / temp; out[1] = in[1] / temp; out[2] = in[2] / temp; @@ -98,7 +98,7 @@ int ttk::CinemaImagingEmbree::renderImage( size_t pixelIndex = 0; size_t bcIndex = 0; - float nan = std::numeric_limits::quiet_NaN(); + const float nan = std::numeric_limits::quiet_NaN(); if(orthographicProjection) { @@ -126,10 +126,10 @@ int ttk::CinemaImagingEmbree::renderImage( - camUpTrue[2] * camHeightWorldHalf}; for(int y = 0; y < resY; y++) { - double v = ((double)y) * pixelHeightWorld; + const double v = ((double)y) * pixelHeightWorld; for(int x = 0; x < resX; x++) { - double u = ((double)x) * pixelWidthWorld; + const double u = ((double)x) * pixelWidthWorld; // set origin rayhit.ray.org_x = camPosCorner[0] + u * camRight[0] + v * camUpTrue[0]; @@ -151,7 +151,7 @@ int ttk::CinemaImagingEmbree::renderImage( rtcIntersect1(scene, &context, &rayhit); // write depth - bool hitPrimitive = rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID; + const bool hitPrimitive = rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID; if(hitPrimitive) { depthBuffer[pixelIndex] = std::max(0.0f, rayhit.ray.tfar); primitiveIds[pixelIndex] = rayhit.hit.primID; @@ -168,13 +168,14 @@ int ttk::CinemaImagingEmbree::renderImage( } } else { - double factor = (camFactor / 180.0 * 3.141592653589793) / resolution[0]; + const double factor + = (camFactor / 180.0 * 3.141592653589793) / resolution[0]; for(int y = 0; y < resY; y++) { - double v = (y - resY * 0.5) * factor; + const double v = (y - resY * 0.5) * factor; for(int x = 0; x < resX; x++) { - double u = (x - resX * 0.5) * factor; + const double u = (x - resX * 0.5) * factor; // set origin rayhit.ray.org_x = camPos[0]; @@ -196,7 +197,7 @@ int ttk::CinemaImagingEmbree::renderImage( rtcIntersect1(scene, &context, &rayhit); // write depth - bool hitPrimitive = rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID; + const bool hitPrimitive = rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID; if(hitPrimitive) { depthBuffer[pixelIndex] = std::max(0.0f, rayhit.ray.tfar); primitiveIds[pixelIndex] = rayhit.hit.primID; diff --git a/core/base/cinemaImaging/CinemaImagingNative.h b/core/base/cinemaImaging/CinemaImagingNative.h index 425b37fe82..ad41f57bf6 100644 --- a/core/base/cinemaImaging/CinemaImagingNative.h +++ b/core/base/cinemaImaging/CinemaImagingNative.h @@ -62,8 +62,8 @@ int ttk::CinemaImagingNative::renderImage( const bool &orthographicProjection, const double &viewAngle) const { ttk::Timer timer; - int resX = resolution[0]; - int resY = resolution[1]; + int const resX = resolution[0]; + int const resY = resolution[1]; this->printMsg("Rendering Image (" + std::string(orthographicProjection ? "O" : "P") + "|" @@ -75,7 +75,7 @@ int ttk::CinemaImagingNative::renderImage( const double camSize[2] = {aspect * camHeight, camHeight}; const auto normalize = [](double out[3], const double in[3]) { - double temp = sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]); + double const temp = sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]); out[0] = in[0] / temp; out[1] = in[1] / temp; out[2] = in[2] / temp; @@ -97,37 +97,37 @@ int ttk::CinemaImagingNative::renderImage( normalize(camUpTrue, camUpTrue); // Compute pixel size in world coordinates - double pixelWidthWorld = camSize[0] / resolution[0]; - double pixelHeightWorld = camSize[1] / resolution[1]; + double const pixelWidthWorld = camSize[0] / resolution[0]; + double const pixelHeightWorld = camSize[1] / resolution[1]; // Optimization: precompute half of the camera size to reduce the number of // operations in the for loop. Include a half pixel offset (-0.5) to center // vertices at pixel centers - double camWidthWorldHalf = 0.5 * camSize[0] - 0.5 * pixelWidthWorld; - double camHeightWorldHalf = 0.5 * camSize[1] - 0.5 * pixelHeightWorld; + double const camWidthWorldHalf = 0.5 * camSize[0] - 0.5 * pixelWidthWorld; + double const camHeightWorldHalf = 0.5 * camSize[1] - 0.5 * pixelHeightWorld; // Optimization: reorient camera model to bottom left corner to reduce // operations in for loop - double camPosCorner[3] = {camPos[0] - camRight[0] * camWidthWorldHalf - - camUpTrue[0] * camHeightWorldHalf, - camPos[1] - camRight[1] * camWidthWorldHalf - - camUpTrue[1] * camHeightWorldHalf, - camPos[2] - camRight[2] * camWidthWorldHalf - - camUpTrue[2] * camHeightWorldHalf}; - - float nan = std::numeric_limits::quiet_NaN(); + double const camPosCorner[3] = {camPos[0] - camRight[0] * camWidthWorldHalf + - camUpTrue[0] * camHeightWorldHalf, + camPos[1] - camRight[1] * camWidthWorldHalf + - camUpTrue[1] * camHeightWorldHalf, + camPos[2] - camRight[2] * camWidthWorldHalf + - camUpTrue[2] * camHeightWorldHalf}; + + float const nan = std::numeric_limits::quiet_NaN(); if(orthographicProjection) { #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(this->threadNumber_) #endif for(int y = 0; y < resY; y++) { - double v = ((double)y) * pixelHeightWorld; + double const v = ((double)y) * pixelHeightWorld; size_t pixelIndex = y * resX; size_t bcIndex = 2 * pixelIndex; for(int x = 0; x < resX; x++) { - double u = ((double)x) * pixelWidthWorld; + double const u = ((double)x) * pixelWidthWorld; depthBuffer[pixelIndex] = nan; primitiveIds[pixelIndex] = CinemaImaging::INVALID_ID; @@ -135,16 +135,19 @@ int ttk::CinemaImagingNative::renderImage( barycentricCoordinates[bcIndex + 1] = nan; // set origin - float org_x = camPosCorner[0] + u * camRight[0] + v * camUpTrue[0]; - float org_y = camPosCorner[1] + u * camRight[1] + v * camUpTrue[1]; - float org_z = camPosCorner[2] + u * camRight[2] + v * camUpTrue[2]; + float const org_x + = camPosCorner[0] + u * camRight[0] + v * camUpTrue[0]; + float const org_y + = camPosCorner[1] + u * camRight[1] + v * camUpTrue[1]; + float const org_z + = camPosCorner[2] + u * camRight[2] + v * camUpTrue[2]; float ray_origin[3] = {org_x, org_y, org_z}; // set dir - float dir_x = camDir[0]; - float dir_y = camDir[1]; - float dir_z = camDir[2]; + float const dir_x = camDir[0]; + float const dir_y = camDir[1]; + float const dir_z = camDir[2]; float ray_dir[3] = {dir_x, dir_y, dir_z}; @@ -165,18 +168,19 @@ int ttk::CinemaImagingNative::renderImage( } } } else { - double factor = (viewAngle / 180.0 * 3.141592653589793) / resolution[0]; + double const factor + = (viewAngle / 180.0 * 3.141592653589793) / resolution[0]; #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(this->threadNumber_) #endif for(int y = 0; y < resY; y++) { - double v = (y - resY * 0.5) * factor; + double const v = (y - resY * 0.5) * factor; size_t pixelIndex = y * resX; size_t bcIndex = 2 * pixelIndex; for(int x = 0; x < resX; x++) { - double u = (x - resX * 0.5) * factor; + double const u = (x - resX * 0.5) * factor; depthBuffer[pixelIndex] = nan; primitiveIds[pixelIndex] = CinemaImaging::INVALID_ID; @@ -184,15 +188,15 @@ int ttk::CinemaImagingNative::renderImage( barycentricCoordinates[bcIndex + 1] = nan; // set origin - float org_x = camPos[0]; - float org_y = camPos[1]; - float org_z = camPos[2]; + float const org_x = camPos[0]; + float const org_y = camPos[1]; + float const org_z = camPos[2]; float ray_origin[3] = {org_x, org_y, org_z}; // set dir - float dir_x = camDir[0] + u * camRight[0] + v * camUpTrue[0]; - float dir_y = camDir[1] + u * camRight[1] + v * camUpTrue[1]; - float dir_z = camDir[2] + u * camRight[2] + v * camUpTrue[2]; + float const dir_x = camDir[0] + u * camRight[0] + v * camUpTrue[0]; + float const dir_y = camDir[1] + u * camRight[1] + v * camUpTrue[1]; + float const dir_z = camDir[2] + u * camRight[2] + v * camUpTrue[2]; float ray_dir[3] = {dir_x, dir_y, dir_z}; diff --git a/core/base/clusteringMetrics/ClusteringMetrics.cpp b/core/base/clusteringMetrics/ClusteringMetrics.cpp index 67be3dc1e1..e9e6c36a53 100644 --- a/core/base/clusteringMetrics/ClusteringMetrics.cpp +++ b/core/base/clusteringMetrics/ClusteringMetrics.cpp @@ -21,15 +21,15 @@ inline int checkContingencyMatSize(const ttk::ClusteringMetrics *object, return 0; } - size_t nLin = matrix.size(); + const size_t nLin = matrix.size(); if(nLin == 0) { object->printErr("The provided contingency matrix is empty.\n"); return 0; } - size_t nCol = matrix[0].size(); + const size_t nCol = matrix[0].size(); for(size_t i = 0; i < nLin; i++) { - size_t curNCol = matrix[i].size(); + const size_t curNCol = matrix[i].size(); if(curNCol == 0) { object->printErr("Line " + std::to_string(i) + " of the contingency matrix is empty.\n"); @@ -61,7 +61,7 @@ int ttk::ClusteringMetrics::computeContingencyTables( std::map values1ToId, values2ToId; size_t nbVal1 = 0, nbVal2 = 0; for(size_t i = 0; i < nPoint; i++) { - int x1 = clust1[i], x2 = clust2[i]; + const int x1 = clust1[i], x2 = clust2[i]; auto found1 = values1ToId.find(x1), found2 = values2ToId.find(x2); if(found1 == values1ToId.end()) { @@ -75,7 +75,7 @@ int ttk::ClusteringMetrics::computeContingencyTables( } } - size_t nCluster1 = nbVal1, nCluster2 = nbVal2; + const size_t nCluster1 = nbVal1, nCluster2 = nbVal2; contingencyMatrix.resize(nCluster1); for(size_t i = 0; i < nCluster1; i++) contingencyMatrix[i].resize(nCluster2, 0); @@ -83,7 +83,7 @@ int ttk::ClusteringMetrics::computeContingencyTables( sumCol.resize(nCluster2, 0); for(size_t i = 0; i < nPoint; i++) { - int x1 = values1ToId[clust1[i]], x2 = values2ToId[clust2[i]]; + const int x1 = values1ToId[clust1[i]], x2 = values2ToId[clust2[i]]; contingencyMatrix[x1][x2]++; } @@ -109,8 +109,8 @@ int ttk::ClusteringMetrics::computeARI( if(!checkContingencyMatSize(this, contingencyMatrix, nPoint)) return 0; - size_t nCluster1 = contingencyMatrix.size(); - size_t nCluster2 = contingencyMatrix[0].size(); + const size_t nCluster1 = contingencyMatrix.size(); + const size_t nCluster2 = contingencyMatrix[0].size(); double sumNChooseContingency = 0; #ifdef TTK_ENABLE_OPENMP @@ -137,10 +137,11 @@ int ttk::ClusteringMetrics::computeARI( sumNChoose2_2 += nChoose2(sumCol[i]); } - double numerator = sumNChooseContingency - - (sumNChoose2_1 * sumNChoose2_2) / nChoose2(nPoint); - double denominator = 0.5 * (sumNChoose2_1 + sumNChoose2_2) - - (sumNChoose2_1 * sumNChoose2_2) / nChoose2(nPoint); + const double numerator = sumNChooseContingency + - (sumNChoose2_1 * sumNChoose2_2) / nChoose2(nPoint); + const double denominator + = 0.5 * (sumNChoose2_1 + sumNChoose2_2) + - (sumNChoose2_1 * sumNChoose2_2) / nChoose2(nPoint); if(denominator < ttk::Geometry::powIntTen(-DBL_DIG)) ariValue = 1; else @@ -158,8 +159,8 @@ int ttk::ClusteringMetrics::computeNMI( if(!checkContingencyMatSize(this, contingencyMatrix, nPoint)) return 0; - size_t nCluster1 = contingencyMatrix.size(); - size_t nCluster2 = contingencyMatrix[0].size(); + const size_t nCluster1 = contingencyMatrix.size(); + const size_t nCluster2 = contingencyMatrix[0].size(); double mutualInfo = 0; bool invalidCell = false; @@ -177,9 +178,9 @@ int ttk::ClusteringMetrics::computeNMI( continue; } - double logArg = (double)nPoint * contingencyMatrix[i1][i2] - / (sumLin[i1] * sumCol[i2]); - double curAdd = contingencyMatrix[i1][i2] * log2(logArg) / (nPoint); + const double logArg = (double)nPoint * contingencyMatrix[i1][i2] + / (sumLin[i1] * sumCol[i2]); + const double curAdd = contingencyMatrix[i1][i2] * log2(logArg) / (nPoint); mutualInfo += curAdd; } } @@ -188,11 +189,11 @@ int ttk::ClusteringMetrics::computeNMI( double entropy1 = 0, entropy2 = 0; for(size_t i = 0; i < nCluster1; i++) { - double eltLin = (double)sumLin[i] / nPoint; + const double eltLin = (double)sumLin[i] / nPoint; entropy1 -= eltLin * log2(eltLin); } for(size_t i = 0; i < nCluster2; i++) { - double eltCol = (double)sumCol[i] / nPoint; + const double eltCol = (double)sumCol[i] / nPoint; entropy2 -= eltCol * log2(eltCol); } diff --git a/core/base/common/Debug.cpp b/core/base/common/Debug.cpp index db337ecda4..43f29f7d67 100644 --- a/core/base/common/Debug.cpp +++ b/core/base/common/Debug.cpp @@ -39,12 +39,12 @@ int Debug::welcomeMsg(ostream &stream) { } #endif // TTK_ENABLE_MPI - int priorityAsInt = (int)debug::Priority::PERFORMANCE; + const int priorityAsInt = (int)debug::Priority::PERFORMANCE; if((ttk::welcomeMsg_) && (debugLevel_ > priorityAsInt)) { ttk::welcomeMsg_ = false; - string currentPrefix = debugMsgPrefix_; + const string currentPrefix = debugMsgPrefix_; debugMsgPrefix_ = "[Common] "; #include diff --git a/core/base/common/Debug.h b/core/base/common/Debug.h index ac6c9e2ee5..47d4595943 100644 --- a/core/base/common/Debug.h +++ b/core/base/common/Debug.h @@ -279,8 +279,8 @@ namespace ttk { && (globalDebugLevel_ < (int)priority)) return 0; - int nRows = rows.size(); - int nCols = nRows > 0 ? rows[0].size() : 0; + const int nRows = rows.size(); + const int nCols = nRows > 0 ? rows[0].size() : 0; if(nCols < 1) return 0; @@ -293,7 +293,7 @@ namespace ttk { auto formatCell = [](const std::string &value, const size_t &width, const std::string &fillSymbol) { std::string cell = value; - int diff = width - cell.size(); + const int diff = width - cell.size(); for(int i = 0; i < diff; i++) cell += fillSymbol; return cell; diff --git a/core/base/common/MPIUtils.h b/core/base/common/MPIUtils.h index 72cea4a7a9..f646efa033 100644 --- a/core/base/common/MPIUtils.h +++ b/core/base/common/MPIUtils.h @@ -122,7 +122,7 @@ namespace ttk { MPI_Datatype MPI_DT = getMPIType(static_cast
(0)); // we need unique tags for each rankToSend, otherwise messages might become // entangled - int tagMultiplier = rankToSend + 1; + const int tagMultiplier = rankToSend + 1; int valuesTag = 103 * tagMultiplier; if(rankToSend == ttk::MPIrank_) { int neighborNumber = neighbors.size(); @@ -189,7 +189,7 @@ namespace ttk { MPI_Datatype MPI_DT = getMPIType(static_cast
(0)); // we need unique tags for each rankToSend, otherwise messages might become // entangled - int tagMultiplier = rankToSend + 1; + const int tagMultiplier = rankToSend + 1; int valuesTag = 103 * tagMultiplier; if(rankToSend == ttk::MPIrank_) { int neighborNumber = neighbors.size(); @@ -280,7 +280,7 @@ namespace ttk { const IT nVerts, MPI_Comm communicator, const int dimensionNumber) { - int neighborNumber = neighbors.size(); + const int neighborNumber = neighbors.size(); if(!ttk::isRunningWithMPI()) { return -1; } @@ -290,7 +290,7 @@ namespace ttk { MPI_Datatype MPI_GIT = getMPIType(static_cast(0)); // we need unique tags for each rankToSend, otherwise messages might become // entangled - int tagMultiplier = rankToSend + 1; + const int tagMultiplier = rankToSend + 1; int amountTag = 101 * tagMultiplier; int idsTag = 102 * tagMultiplier; int valuesTag = 103 * tagMultiplier; @@ -420,7 +420,7 @@ namespace ttk { auto end = rootVector.begin(); for(int i = 0; i < ttk::MPIsize_; i++) { end = begin + sizes[i]; - std::unordered_set s(begin, end); + const std::unordered_set s(begin, end); setsFromRanks[i] = s; begin = end; } @@ -458,13 +458,13 @@ namespace ttk { MPI_INT, receivedNeighbors.data(), receivedSize, MPI_INT, 0, communicator); // then we turn the vector back into a set - std::unordered_set finalSet( + const std::unordered_set finalSet( receivedNeighbors.begin(), receivedNeighbors.end()); neighborSet = finalSet; // We copy the set as a vector neighbors.clear(); - for(int neighbor : neighborSet) { + for(const int neighbor : neighborSet) { neighbors.push_back(neighbor); } std::sort(neighbors.begin(), neighbors.end()); @@ -589,7 +589,7 @@ namespace ttk { MPI_Bcast(rankBoundingBoxes[r].data(), 6, MPI_DOUBLE, r, ttk::MPIcomm_); } - double epsilon = 0.00001; + const double epsilon = 0.00001; // inflate our own bounding box by epsilon for(int i = 0; i < 6; i++) { if(i % 2 == 0) @@ -628,13 +628,12 @@ namespace ttk { } MPI_Datatype MIT = ttk::getMPIType(ttk::SimplexId{}); std::vector currentRankUnknownIds; - std::vector> allUnknownIds(ttk::MPIsize_); std::unordered_set gIdSet; std::unordered_map gIdToLocalMap; for(int i = 0; i < nVertices; i++) { - int ghostCellVal = ghostCells[i]; - ttk::SimplexId globalId = globalIds[i]; + const int ghostCellVal = ghostCells[i]; + const ttk::SimplexId globalId = globalIds[i]; if(ghostCellVal == 0) { // if the ghost cell value is 0, then this vertex mainly belongs to // this rank @@ -655,7 +654,7 @@ namespace ttk { receivedGlobals.resize(sizeOfCurrentRank); ttk::SimplexId sizeOfNeighbor; std::vector neighborUnknownIds; - for(int neighbor : neighbors) { + for(const int neighbor : neighbors) { // we first send the size and then all needed ids to the neighbor MPI_Sendrecv(&sizeOfCurrentRank, 1, MIT, neighbor, ttk::MPIrank_, &sizeOfNeighbor, 1, MIT, neighbor, neighbor, ttk::MPIcomm_, @@ -670,7 +669,7 @@ namespace ttk { // then we check if the needed globalid values are present in the local // globalid set if so, we send the rank value to the requesting rank - for(ttk::SimplexId gId : neighborUnknownIds) { + for(const ttk::SimplexId gId : neighborUnknownIds) { if(gIdSet.count(gId)) { // add the value to the vector which will be sent gIdsToSend.push_back(gId); @@ -687,8 +686,8 @@ namespace ttk { MPI_Get_count(&status, MIT, &amount); receivedGlobals.resize(amount); - for(ttk::SimplexId receivedGlobal : receivedGlobals) { - ttk::SimplexId localVal = gIdToLocalMap[receivedGlobal]; + for(const ttk::SimplexId receivedGlobal : receivedGlobals) { + const ttk::SimplexId localVal = gIdToLocalMap[receivedGlobal]; rankArray[localVal] = neighbor; } // cleanup @@ -944,7 +943,6 @@ namespace ttk { using IT = decltype(getVertexGlobalId(0)); MPI_Datatype MPI_IT = ttk::getMPIType(static_cast(0)); - ttk::Timer fillAndSortTimer; std::vector> sortingValues; populateVector( sortingValues, nVerts, scalarArray, getVertexGlobalId, getVertexRank); @@ -959,7 +957,6 @@ namespace ttk { std::vector orderedValuesForRank; IT processedValueCounter = 0; - ttk::Timer mergeTimer; IT localSize = sortingValues.size(); IT totalSize; // get the complete size of the dataset by summing up the local sizes @@ -1024,7 +1021,6 @@ namespace ttk { // all ranks do the following MPI_Barrier(ttk::MPIcomm_); - ttk::Timer orderTimer; buildArrayForReceivedData(orderedValuesForRank.size(), orderedValuesForRank.data(), getVertexLocalId, orderArray, ttk::globalThreadNumber_); diff --git a/core/base/common/Os.cpp b/core/base/common/Os.cpp index 6e60e62993..062b4666ca 100644 --- a/core/base/common/Os.cpp +++ b/core/base/common/Os.cpp @@ -176,7 +176,7 @@ namespace ttk { msg = "Could not open directory `"; msg += directoryName; msg += "'..."; - Debug dbg; + const Debug dbg; dbg.printErr(msg); } else { struct dirent *dirEntry; diff --git a/core/base/compactTriangulation/CompactTriangulation.cpp b/core/base/compactTriangulation/CompactTriangulation.cpp index eebecdd255..d01ead65f1 100644 --- a/core/base/compactTriangulation/CompactTriangulation.cpp +++ b/core/base/compactTriangulation/CompactTriangulation.cpp @@ -62,7 +62,7 @@ int CompactTriangulation::reorderVertices(std::vector &vertexMap) { vertexIntervals_[0] = -1; SimplexId vertexCount = 0; for(SimplexId nid = 0; nid < nodeNumber_; nid++) { - for(SimplexId vid : nodeVertices[nid]) { + for(SimplexId const vid : nodeVertices[nid]) { vertexMap[vid] = vertexCount++; } vertexIntervals_[nid + 1] = vertexCount - 1; @@ -120,7 +120,7 @@ int CompactTriangulation::reorderCells(const std::vector &vertexMap, LongSimplexId *cellArr = const_cast(connectivity); for(SimplexId cid = 0; cid < cellNumber; cid++) { - SimplexId cellId = offset[cid]; + SimplexId const cellId = offset[cid]; for(int j = 0; j < verticesPerCell; j++) { cellArr[cellId + j] = vertexMap[cellArr[cellId + j]]; } @@ -134,13 +134,13 @@ int CompactTriangulation::reorderCells(const std::vector &vertexMap, cellIntervals_[0] = -1; std::vector newCellArray(verticesPerCell * cellNumber); for(SimplexId nid = 1; nid <= nodeNumber_; nid++) { - for(SimplexId cid : nodeCells[nid]) { - SimplexId cellId = verticesPerCell * cid; - SimplexId newCellId = verticesPerCell * cellCount; + for(SimplexId const cid : nodeCells[nid]) { + SimplexId const cellId = verticesPerCell * cid; + SimplexId const newCellId = verticesPerCell * cellCount; for(int j = 0; j < verticesPerCell; j++) { newCellArray[newCellId + j] = connectivity[cellId + j]; if(newCellArray[newCellId + j] > vertexIntervals_[nid]) { - SimplexId nodeNum = vertexIndices_[newCellArray[newCellId + j]]; + SimplexId const nodeNum = vertexIndices_[newCellArray[newCellId + j]]; if(externalCells_[nodeNum].empty() || externalCells_[nodeNum].back() != cid) { externalCells_[nodeNum].push_back(cid); @@ -168,7 +168,7 @@ int CompactTriangulation::reorderCells(const std::vector &vertexMap, LongSimplexId *cellArr = const_cast(cellArray); for(SimplexId cid = 0; cid < cellNumber_; cid++) { - SimplexId cellId = (verticesPerCell + 1) * cid; + SimplexId const cellId = (verticesPerCell + 1) * cid; for(int j = 1; j <= verticesPerCell; j++) { cellArr[cellId + j] = vertexMap[cellArr[cellId + j]]; } @@ -182,14 +182,14 @@ int CompactTriangulation::reorderCells(const std::vector &vertexMap, cellIntervals_[0] = -1; std::vector newCellArray((verticesPerCell + 1) * cellNumber_); for(SimplexId nid = 1; nid <= nodeNumber_; nid++) { - for(SimplexId cid : nodeCells[nid]) { - SimplexId cellId = (verticesPerCell + 1) * cid; - SimplexId newCellId = (verticesPerCell + 1) * cellCount; + for(SimplexId const cid : nodeCells[nid]) { + SimplexId const cellId = (verticesPerCell + 1) * cid; + SimplexId const newCellId = (verticesPerCell + 1) * cellCount; newCellArray[newCellId] = verticesPerCell; for(int j = 1; j <= verticesPerCell; j++) { newCellArray[newCellId + j] = cellArray[cellId + j]; if(newCellArray[newCellId + j] > vertexIntervals_[nid]) { - SimplexId nodeNum = vertexIndices_[newCellArray[newCellId + j]]; + SimplexId const nodeNum = vertexIndices_[newCellArray[newCellId + j]]; if(externalCells_[nodeNum].empty() || externalCells_[nodeNum].back() != cid) { externalCells_[nodeNum].push_back(cid); @@ -260,7 +260,7 @@ int CompactTriangulation::buildInternalEdgeMap( } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array edgeIds; // loop through each edge of the cell @@ -306,14 +306,14 @@ int CompactTriangulation::buildExternalEdgeMap( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); boost::unordered_map>> edgeNodes; // loop through the external cell list for(size_t i = 0; i < externalCells_[nodePtr->nid].size(); i++) { std::array edgeIds; - SimplexId cellId = externalCells_[nodePtr->nid][i]; + SimplexId const cellId = externalCells_[nodePtr->nid][i]; // loop through each edge of the cell for(SimplexId j = 0; j < verticesPerCell - 1; j++) { @@ -325,7 +325,7 @@ int CompactTriangulation::buildExternalEdgeMap( if(edgeIds[0] <= vertexIntervals_[nodePtr->nid - 1] && edgeIds[1] > vertexIntervals_[nodePtr->nid - 1] && edgeIds[1] <= vertexIntervals_[nodePtr->nid]) { - SimplexId nid = vertexIndices_[edgeIds[0]]; + SimplexId const nid = vertexIndices_[edgeIds[0]]; edgeNodes[nid].push_back(edgeIds); } } @@ -339,7 +339,7 @@ int CompactTriangulation::buildExternalEdgeMap( if(exnode) { if(exnode->internalEdgeMap_.empty()) buildInternalEdgeMap(exnode, false, true); - for(std::array edgePair : iter->second) { + for(std::array const edgePair : iter->second) { (nodePtr->externalEdgeMap_)[edgePair] = exnode->internalEdgeMap_.at(edgePair) + edgeIntervals_[iter->first - 1]; @@ -347,7 +347,7 @@ int CompactTriangulation::buildExternalEdgeMap( } else { ImplicitCluster tmpCluster(iter->first); buildInternalEdgeMap(&tmpCluster, false, true); - for(std::array edgePair : iter->second) { + for(std::array const edgePair : iter->second) { (nodePtr->externalEdgeMap_)[edgePair] = tmpCluster.internalEdgeMap_.at(edgePair) + edgeIntervals_[iter->first - 1]; @@ -369,7 +369,7 @@ int CompactTriangulation::buildInternalTriangleMap( #endif SimplexId triangleCount = 0, verticesPerCell = 4; - std::vector> localTriangleStars; + std::vector> const localTriangleStars; if(!nodePtr->internalTriangleMap_.empty()) { if(computeInternalTriangleList) { @@ -411,7 +411,7 @@ int CompactTriangulation::buildInternalTriangleMap( } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array triangleIds; // loop through each triangle of the cell @@ -459,12 +459,12 @@ int CompactTriangulation::buildExternalTriangleMap( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); boost::unordered_map>> nodeTriangles; // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array triangleIds; // loop through each triangle of the cell @@ -478,11 +478,11 @@ int CompactTriangulation::buildExternalTriangleMap( if(triangleIds[1] > vertexIntervals_[nodePtr->nid - 1] && triangleIds[1] <= vertexIntervals_[nodePtr->nid]) { - SimplexId nodeNum = vertexIndices_[triangleIds[0]]; + SimplexId const nodeNum = vertexIndices_[triangleIds[0]]; nodeTriangles[nodeNum].push_back(triangleIds); } else if(triangleIds[2] > vertexIntervals_[nodePtr->nid - 1] && triangleIds[2] <= vertexIntervals_[nodePtr->nid]) { - SimplexId nodeNum = vertexIndices_[triangleIds[0]]; + SimplexId const nodeNum = vertexIndices_[triangleIds[0]]; nodeTriangles[nodeNum].push_back(triangleIds); } } @@ -498,7 +498,7 @@ int CompactTriangulation::buildExternalTriangleMap( if(exnode) { if(exnode->internalTriangleMap_.empty()) buildInternalTriangleMap(exnode, false, true); - for(std::array triangleVec : iter->second) { + for(std::array const triangleVec : iter->second) { (nodePtr->externalTriangleMap_)[triangleVec] = exnode->internalTriangleMap_.at(triangleVec) + triangleIntervals_[iter->first - 1]; @@ -506,7 +506,7 @@ int CompactTriangulation::buildExternalTriangleMap( } else { ImplicitCluster tmpCluster(iter->first); buildInternalTriangleMap(&tmpCluster, false, true); - for(std::array triangleVec : iter->second) { + for(std::array const triangleVec : iter->second) { (nodePtr->externalTriangleMap_)[triangleVec] = tmpCluster.internalTriangleMap_.at(triangleVec) + triangleIntervals_[iter->first - 1]; @@ -554,7 +554,7 @@ SimplexId CompactTriangulation::countInternalEdges(SimplexId nodeId) const { } // loop through the external cell list - for(SimplexId cid : externalCells_[nodeId]) { + for(SimplexId const cid : externalCells_[nodeId]) { std::array edgeIds{}; // loop through each edge of the cell @@ -616,7 +616,7 @@ int CompactTriangulation::countInternalTriangles(SimplexId nodeId) const { } // loop through the external cell list - for(SimplexId cid : externalCells_[nodeId]) { + for(SimplexId const cid : externalCells_[nodeId]) { std::array triangleIds{}; // loop through each triangle of the cell @@ -652,7 +652,7 @@ int CompactTriangulation::getClusterCellNeighbors( std::vector> localCellNeighbors( cellIntervals_[nodePtr->nid] - cellIntervals_[nodePtr->nid - 1]); - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); std::vector> localVertexStars; if(nodePtr->vertexStars_.empty()) { @@ -669,7 +669,8 @@ int CompactTriangulation::getClusterCellNeighbors( cid <= cellIntervals_[nodePtr->nid]; cid++) { for(SimplexId j = 1; j < verticesPerCell; j++) { if(cellArray_->getCellVertex(cid, j) > vertexIntervals_[nodePtr->nid]) { - SimplexId nodeId = vertexIndices_[cellArray_->getCellVertex(cid, j)]; + SimplexId const nodeId + = vertexIndices_[cellArray_->getCellVertex(cid, j)]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { ImplicitCluster newNode(nodeId); getClusterVertexStars(&newNode); @@ -690,8 +691,8 @@ int CompactTriangulation::getClusterCellNeighbors( cid <= cellIntervals_[nodePtr->nid]; cid++) { for(SimplexId j = 0; j < 3; j++) { - SimplexId v0 = cellArray_->getCellVertex(cid, j); - SimplexId v1 = cellArray_->getCellVertex(cid, (j + 1) % 3); + SimplexId const v0 = cellArray_->getCellVertex(cid, j); + SimplexId const v1 = cellArray_->getCellVertex(cid, (j + 1) % 3); SimplexId localV0 = v0 - vertexIntervals_[nodePtr->nid - 1] - 1; SimplexId localV1 = v1 - vertexIntervals_[nodePtr->nid - 1] - 1; @@ -763,9 +764,9 @@ int CompactTriangulation::getClusterCellNeighbors( // go triangle by triangle for(SimplexId j = 0; j < 4; j++) { - SimplexId v0 = cellArray_->getCellVertex(cid, j % 4); - SimplexId v1 = cellArray_->getCellVertex(cid, (j + 1) % 4); - SimplexId v2 = cellArray_->getCellVertex(cid, (j + 2) % 4); + SimplexId const v0 = cellArray_->getCellVertex(cid, j % 4); + SimplexId const v1 = cellArray_->getCellVertex(cid, (j + 1) % 4); + SimplexId const v2 = cellArray_->getCellVertex(cid, (j + 2) % 4); SimplexId localV0 = v0 - vertexIntervals_[nodePtr->nid - 1] - 1; SimplexId localV1 = v1 - vertexIntervals_[nodePtr->nid - 1] - 1; @@ -865,7 +866,7 @@ int CompactTriangulation::getClusterCellTriangles( return -1; #endif - SimplexId verticesPerCell = 4; + SimplexId const verticesPerCell = 4; boost::unordered_map>> nodeTriangles; @@ -901,9 +902,9 @@ int CompactTriangulation::getClusterCellTriangles( = nodePtr->internalTriangleMap_.at(triangleVec) + triangleIntervals_[nodePtr->nid - 1]; } else { - std::vector triangleTuple + std::vector const triangleTuple = {i, triangleVec[0], triangleVec[1], triangleVec[2]}; - SimplexId nodeNum = vertexIndices_[triangleVec[0]]; + SimplexId const nodeNum = vertexIndices_[triangleVec[0]]; nodeTriangles[nodeNum].push_back(triangleTuple); } } @@ -914,7 +915,7 @@ int CompactTriangulation::getClusterCellTriangles( if(exnode->internalTriangleMap_.empty()) buildInternalTriangleMap(exnode, false, true); for(std::vector triangleVec : iter->second) { - std::array triangle + std::array const triangle = {triangleVec[1], triangleVec[2], triangleVec[3]}; (nodePtr->tetraTriangles_)[triangleVec[0] - cellIntervals_[nodePtr->nid - 1] - 1] @@ -926,7 +927,7 @@ int CompactTriangulation::getClusterCellTriangles( ImplicitCluster tmpCluster(iter->first); buildInternalTriangleMap(&tmpCluster, false, true); for(std::vector triangleVec : iter->second) { - std::array triangle + std::array const triangle = {triangleVec[1], triangleVec[2], triangleVec[3]}; (nodePtr->tetraTriangles_)[triangleVec[0] - cellIntervals_[nodePtr->nid - 1] - 1] @@ -948,7 +949,7 @@ int CompactTriangulation::getClusterEdgeLinks( return -1; #endif - SimplexId localEdgeNum + SimplexId const localEdgeNum = edgeIntervals_[nodePtr->nid] - edgeIntervals_[nodePtr->nid - 1]; std::vector offsets(localEdgeNum + 1, 0), linksCount(localEdgeNum, 0); @@ -964,9 +965,9 @@ int CompactTriangulation::getClusterEdgeLinks( iter != nodePtr->internalEdgeMap_.end(); iter++) { for(SimplexId j = 0; j < nodePtr->edgeStars_.size(iter->second - 1); j++) { - SimplexId cellId = nodePtr->edgeStars_.get(iter->second - 1, j); + SimplexId const cellId = nodePtr->edgeStars_.get(iter->second - 1, j); for(int k = 0; k < 3; k++) { - SimplexId vertexId = cellArray_->getCellVertex(cellId, k); + SimplexId const vertexId = cellArray_->getCellVertex(cellId, k); if((vertexId != iter->first[0]) && (vertexId != iter->first[1])) { offsets[iter->second]++; break; @@ -988,11 +989,11 @@ int CompactTriangulation::getClusterEdgeLinks( iter != nodePtr->internalEdgeMap_.end(); iter++) { for(SimplexId j = 0; j < nodePtr->edgeStars_.size(iter->second - 1); j++) { - SimplexId cellId = nodePtr->edgeStars_.get(iter->second - 1, j); + SimplexId const cellId = nodePtr->edgeStars_.get(iter->second - 1, j); for(int k = 0; k < 3; k++) { - SimplexId vertexId = cellArray_->getCellVertex(cellId, k); + SimplexId const vertexId = cellArray_->getCellVertex(cellId, k); if((vertexId != iter->first[0]) && (vertexId != iter->first[1])) { - SimplexId localEdgeId = iter->second - 1; + SimplexId const localEdgeId = iter->second - 1; edgeLinkData[offsets[localEdgeId] + linksCount[localEdgeId]] = vertexId; linksCount[localEdgeId]++; @@ -1013,10 +1014,10 @@ int CompactTriangulation::getClusterEdgeLinks( } // set the offsets vector - SimplexId localCellNum + SimplexId const localCellNum = cellIntervals_[nodePtr->nid] - cellIntervals_[nodePtr->nid - 1]; for(SimplexId cid = 0; cid < localCellNum; cid++) { - SimplexId cellId = cid + cellIntervals_[nodePtr->nid - 1] + 1; + SimplexId const cellId = cid + cellIntervals_[nodePtr->nid - 1] + 1; std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cellId, 0), (SimplexId)cellArray_->getCellVertex(cellId, 1), @@ -1042,7 +1043,7 @@ int CompactTriangulation::getClusterEdgeLinks( } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array edgeIds; std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cid, 0), @@ -1075,7 +1076,7 @@ int CompactTriangulation::getClusterEdgeLinks( // fill the flat vector using offsets and count vectors for(SimplexId cid = 0; cid < localCellNum; cid++) { - SimplexId cellId = cid + cellIntervals_[nodePtr->nid - 1] + 1; + SimplexId const cellId = cid + cellIntervals_[nodePtr->nid - 1] + 1; std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cellId, 0), (SimplexId)cellArray_->getCellVertex(cellId, 1), @@ -1085,7 +1086,8 @@ int CompactTriangulation::getClusterEdgeLinks( edgePair[0] = vertexIds[0]; for(SimplexId j = 1; j < 4; j++) { edgePair[1] = vertexIds[j]; - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgePair) - 1; + SimplexId const localEdgeId + = nodePtr->internalEdgeMap_.at(edgePair) - 1; edgeLinkData[offsets[localEdgeId] + linksCount[localEdgeId]] = nodePtr->tetraEdges_.at(cid)[6 - j]; linksCount[localEdgeId]++; @@ -1094,14 +1096,16 @@ int CompactTriangulation::getClusterEdgeLinks( edgePair[0] = vertexIds[1]; for(int j = 2; j < 4; j++) { edgePair[1] = vertexIds[j]; - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgePair) - 1; + SimplexId const localEdgeId + = nodePtr->internalEdgeMap_.at(edgePair) - 1; edgeLinkData[offsets[localEdgeId] + linksCount[localEdgeId]] = nodePtr->tetraEdges_.at(cid)[4 - j]; linksCount[localEdgeId]++; } if(vertexIds[2] <= vertexIntervals_[nodePtr->nid]) { edgePair = {vertexIds[2], vertexIds[3]}; - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgePair) - 1; + SimplexId const localEdgeId + = nodePtr->internalEdgeMap_.at(edgePair) - 1; edgeLinkData[offsets[localEdgeId] + linksCount[localEdgeId]] = nodePtr->tetraEdges_.at(cid)[0]; linksCount[localEdgeId]++; @@ -1111,7 +1115,7 @@ int CompactTriangulation::getClusterEdgeLinks( // loop through the external cell list boost::unordered_map nodeMaps; - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cid, 0), (SimplexId)cellArray_->getCellVertex(cid, 1), @@ -1142,12 +1146,13 @@ int CompactTriangulation::getClusterEdgeLinks( } } } - SimplexId nodeId = vertexIndices_[otherEdge[0]]; + SimplexId const nodeId = vertexIndices_[otherEdge[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); buildInternalEdgeMap(&nodeMaps[nodeId], false, true); } - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgeIds) - 1; + SimplexId const localEdgeId + = nodePtr->internalEdgeMap_.at(edgeIds) - 1; edgeLinkData[offsets[localEdgeId] + linksCount[localEdgeId]] = nodeMaps[nodeId].internalEdgeMap_.at(otherEdge); linksCount[localEdgeId]++; @@ -1171,8 +1176,8 @@ int CompactTriangulation::getClusterEdgeStars( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); - SimplexId localEdgeNum + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const localEdgeNum = edgeIntervals_[nodePtr->nid] - edgeIntervals_[nodePtr->nid - 1]; std::vector offsets(localEdgeNum + 1, 0), starsCount(localEdgeNum); @@ -1198,7 +1203,7 @@ int CompactTriangulation::getClusterEdgeStars( } } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array edgeIds; for(SimplexId j = 0; j < verticesPerCell - 1; j++) { for(SimplexId k = j + 1; k < verticesPerCell; k++) { @@ -1233,14 +1238,14 @@ int CompactTriangulation::getClusterEdgeStars( } for(SimplexId k = j + 1; k < verticesPerCell; k++) { edgeIds[1] = cellArray_->getCellVertex(cid, k); - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgeIds) - 1; + SimplexId const localEdgeId = nodePtr->internalEdgeMap_.at(edgeIds) - 1; edgeStarData[offsets[localEdgeId] + starsCount[localEdgeId]] = cid; starsCount[localEdgeId]++; } } } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array edgeIds; for(SimplexId j = 0; j < verticesPerCell - 1; j++) { for(SimplexId k = j + 1; k < verticesPerCell; k++) { @@ -1248,7 +1253,8 @@ int CompactTriangulation::getClusterEdgeStars( edgeIds[1] = cellArray_->getCellVertex(cid, k); if(edgeIds[0] > vertexIntervals_[nodePtr->nid - 1] && edgeIds[0] <= vertexIntervals_[nodePtr->nid]) { - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edgeIds) - 1; + SimplexId const localEdgeId + = nodePtr->internalEdgeMap_.at(edgeIds) - 1; edgeStarData[offsets[localEdgeId] + starsCount[localEdgeId]] = cid; starsCount[localEdgeId]++; } @@ -1270,7 +1276,7 @@ int CompactTriangulation::getClusterEdgeTriangles( return -1; #endif - SimplexId localEdgeNum + SimplexId const localEdgeNum = edgeIntervals_[nodePtr->nid] - edgeIntervals_[nodePtr->nid - 1]; std::vector offsets(localEdgeNum + 1, 0), trianglesCount(localEdgeNum, 0); @@ -1290,7 +1296,7 @@ int CompactTriangulation::getClusterEdgeTriangles( for(iter = nodePtr->internalTriangleMap_.begin(); iter != nodePtr->internalTriangleMap_.end(); iter++) { std::array edge1 = {iter->first[0], iter->first[1]}; - std::array edge2 = {iter->first[0], iter->first[2]}; + std::array const edge2 = {iter->first[0], iter->first[2]}; offsets[nodePtr->internalEdgeMap_.at(edge1)]++; offsets[nodePtr->internalEdgeMap_.at(edge2)]++; if(iter->first[1] <= vertexIntervals_[nodePtr->nid]) { @@ -1319,7 +1325,7 @@ int CompactTriangulation::getClusterEdgeTriangles( for(iter = nodePtr->internalTriangleMap_.begin(); iter != nodePtr->internalTriangleMap_.end(); iter++) { std::array edge1 = {iter->first[0], iter->first[1]}; - std::array edge2 = {iter->first[0], iter->first[2]}; + std::array const edge2 = {iter->first[0], iter->first[2]}; SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edge1) - 1; edgeTriangleData[offsets[localEdgeId] + trianglesCount[localEdgeId]] = iter->second + triangleIntervals_[nodePtr->nid - 1]; @@ -1344,7 +1350,7 @@ int CompactTriangulation::getClusterEdgeTriangles( std::array edge = {iter->first.at(1), iter->first.at(2)}; if(edge[0] > vertexIntervals_[nodePtr->nid - 1] && edge[0] <= vertexIntervals_[nodePtr->nid]) { - SimplexId localEdgeId = nodePtr->internalEdgeMap_.at(edge) - 1; + SimplexId const localEdgeId = nodePtr->internalEdgeMap_.at(edge) - 1; edgeTriangleData[offsets[localEdgeId] + trianglesCount[localEdgeId]] = iter->second; trianglesCount[localEdgeId]++; @@ -1366,7 +1372,7 @@ int CompactTriangulation::getClusterTetraEdges( return -1; #endif - SimplexId verticesPerCell = 4; + SimplexId const verticesPerCell = 4; nodePtr->tetraEdges_ = std::vector>( cellIntervals_[nodePtr->nid] - cellIntervals_[nodePtr->nid - 1]); boost::unordered_map>> @@ -1381,7 +1387,7 @@ int CompactTriangulation::getClusterTetraEdges( int cnt = 0; // get the internal edge id from the map for(SimplexId k = 1; k < verticesPerCell; k++) { - std::array edgePair + std::array const edgePair = {(SimplexId)cellArray_->getCellVertex(i, 0), (SimplexId)cellArray_->getCellVertex(i, k)}; (nodePtr->tetraEdges_)[i - cellIntervals_[nodePtr->nid - 1] - 1][cnt++] @@ -1401,8 +1407,9 @@ int CompactTriangulation::getClusterTetraEdges( } // group the external edges by node id else { - std::vector edgeTuple{i, cnt++, edgePair[0], edgePair[1]}; - SimplexId nodeNum = vertexIndices_[edgePair[0]]; + std::vector const edgeTuple{ + i, cnt++, edgePair[0], edgePair[1]}; + SimplexId const nodeNum = vertexIndices_[edgePair[0]]; edgeNodes[nodeNum].push_back(edgeTuple); } } @@ -1415,7 +1422,7 @@ int CompactTriangulation::getClusterTetraEdges( if(exnode->internalEdgeMap_.empty()) buildInternalEdgeMap(exnode, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[2], edgeTuple[3]}; + std::array const edgePair = {edgeTuple[2], edgeTuple[3]}; (nodePtr->tetraEdges_)[edgeTuple[0] - cellIntervals_[nodePtr->nid - 1] - 1][edgeTuple[1]] = exnode->internalEdgeMap_.at(edgePair) @@ -1425,7 +1432,7 @@ int CompactTriangulation::getClusterTetraEdges( ImplicitCluster tmpCluster(iter->first); buildInternalEdgeMap(&tmpCluster, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[2], edgeTuple[3]}; + std::array const edgePair = {edgeTuple[2], edgeTuple[3]}; (nodePtr->tetraEdges_)[edgeTuple[0] - cellIntervals_[nodePtr->nid - 1] - 1][edgeTuple[1]] = tmpCluster.internalEdgeMap_.at(edgePair) @@ -1477,8 +1484,8 @@ int CompactTriangulation::getClusterTriangleEdges( } // group the external edges by node id else { - std::vector edgeTuple{i, edgePair[0], edgePair[1]}; - SimplexId nodeNum = vertexIndices_[edgePair[0]]; + std::vector const edgeTuple{i, edgePair[0], edgePair[1]}; + SimplexId const nodeNum = vertexIndices_[edgePair[0]]; edgeNodes[nodeNum].push_back(edgeTuple); } } @@ -1489,7 +1496,8 @@ int CompactTriangulation::getClusterTriangleEdges( if(exnode->internalEdgeMap_.empty()) buildInternalEdgeMap(exnode, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[1], edgeTuple[2]}; + std::array const edgePair + = {edgeTuple[1], edgeTuple[2]}; (nodePtr->triangleEdges_)[edgeTuple[0] - cellIntervals_[nodePtr->nid - 1] - 1][2] = exnode->internalEdgeMap_.at(edgePair) @@ -1499,7 +1507,8 @@ int CompactTriangulation::getClusterTriangleEdges( ImplicitCluster tmpCluster(iter->first); buildInternalEdgeMap(&tmpCluster, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[1], edgeTuple[2]}; + std::array const edgePair + = {edgeTuple[1], edgeTuple[2]}; (nodePtr->triangleEdges_)[edgeTuple[0] - cellIntervals_[nodePtr->nid - 1] - 1][2] = tmpCluster.internalEdgeMap_.at(edgePair) @@ -1530,9 +1539,9 @@ int CompactTriangulation::getClusterTriangleEdges( = nodePtr->internalEdgeMap_.at(edgePair) + edgeIntervals_[nodePtr->nid - 1]; } else { - std::vector edgeTuple{ + std::vector const edgeTuple{ iter->second - 1, edgePair[0], edgePair[1]}; - SimplexId nodeNum = vertexIndices_[edgePair[0]]; + SimplexId const nodeNum = vertexIndices_[edgePair[0]]; edgeNodes[nodeNum].push_back(edgeTuple); } } @@ -1543,7 +1552,8 @@ int CompactTriangulation::getClusterTriangleEdges( if(exnode->internalEdgeMap_.empty()) buildInternalEdgeMap(exnode, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[1], edgeTuple[2]}; + std::array const edgePair + = {edgeTuple[1], edgeTuple[2]}; (nodePtr->triangleEdges_)[edgeTuple[0]][2] = exnode->internalEdgeMap_.at(edgePair) + edgeIntervals_[iter->first - 1]; @@ -1552,7 +1562,8 @@ int CompactTriangulation::getClusterTriangleEdges( ImplicitCluster tmpCluster(iter->first); buildInternalEdgeMap(&tmpCluster, false, true); for(std::vector edgeTuple : iter->second) { - std::array edgePair = {edgeTuple[1], edgeTuple[2]}; + std::array const edgePair + = {edgeTuple[1], edgeTuple[2]}; (nodePtr->triangleEdges_)[edgeTuple[0]][2] = tmpCluster.internalEdgeMap_.at(edgePair) + edgeIntervals_[iter->first - 1]; @@ -1572,7 +1583,7 @@ int CompactTriangulation::getClusterTriangleLinks( return -1; #endif - SimplexId localTriangleNum + SimplexId const localTriangleNum = triangleIntervals_[nodePtr->nid] - triangleIntervals_[nodePtr->nid - 1]; std::vector offsets(localTriangleNum + 1, 0), linksCount(localTriangleNum, 0); @@ -1588,9 +1599,9 @@ int CompactTriangulation::getClusterTriangleLinks( iter != nodePtr->internalTriangleMap_.end(); iter++) { for(SimplexId i = 0; i < nodePtr->triangleStars_.size(iter->second - 1); i++) { - SimplexId cellId = nodePtr->triangleStars_.get(iter->second - 1, i); + SimplexId const cellId = nodePtr->triangleStars_.get(iter->second - 1, i); for(int j = 0; j < 4; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cellId, j); + SimplexId const vertexId = cellArray_->getCellVertex(cellId, j); if((vertexId != iter->first[0]) && (vertexId != iter->first[1]) && (vertexId != iter->first[2])) { offsets[iter->second]++; @@ -1613,9 +1624,9 @@ int CompactTriangulation::getClusterTriangleLinks( iter != nodePtr->internalTriangleMap_.end(); iter++) { for(SimplexId i = 0; i < nodePtr->triangleStars_.size(iter->second - 1); i++) { - SimplexId cellId = nodePtr->triangleStars_.get(iter->second - 1, i); + SimplexId const cellId = nodePtr->triangleStars_.get(iter->second - 1, i); for(int j = 0; j < 4; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cellId, j); + SimplexId const vertexId = cellArray_->getCellVertex(cellId, j); if((vertexId != iter->first[0]) && (vertexId != iter->first[1]) && (vertexId != iter->first[2])) { triangleLinkData[offsets[iter->second - 1] @@ -1643,8 +1654,8 @@ int CompactTriangulation::getClusterTriangleStars( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); - SimplexId localTriangleNum + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const localTriangleNum = triangleIntervals_[nodePtr->nid] - triangleIntervals_[nodePtr->nid - 1]; std::vector offsets(localTriangleNum + 1, 0), starsCount(localTriangleNum, 0); @@ -1673,7 +1684,7 @@ int CompactTriangulation::getClusterTriangleStars( } } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array triangleIds; for(SimplexId j = 0; j < verticesPerCell - 2; j++) { triangleIds[0] = cellArray_->getCellVertex(cid, j); @@ -1713,7 +1724,7 @@ int CompactTriangulation::getClusterTriangleStars( for(SimplexId l = k + 1; l < verticesPerCell; l++) { triangleIds[1] = cellArray_->getCellVertex(cid, k); triangleIds[2] = cellArray_->getCellVertex(cid, l); - SimplexId localTriangleId + SimplexId const localTriangleId = nodePtr->internalTriangleMap_.at(triangleIds) - 1; triangleStarData[offsets[localTriangleId] + starsCount[localTriangleId]] @@ -1724,7 +1735,7 @@ int CompactTriangulation::getClusterTriangleStars( } } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array triangleIds; // loop through each triangle of the cell @@ -1736,7 +1747,7 @@ int CompactTriangulation::getClusterTriangleStars( for(SimplexId l = k + 1; l < verticesPerCell; l++) { triangleIds[1] = cellArray_->getCellVertex(cid, k); triangleIds[2] = cellArray_->getCellVertex(cid, l); - SimplexId localTriangleId + SimplexId const localTriangleId = nodePtr->internalTriangleMap_.at(triangleIds) - 1; triangleStarData[offsets[localTriangleId] + starsCount[localTriangleId]] @@ -1763,7 +1774,7 @@ int CompactTriangulation::getClusterVertexEdges( return -1; #endif - SimplexId localVertexNum + SimplexId const localVertexNum = vertexIntervals_[nodePtr->nid] - vertexIntervals_[nodePtr->nid - 1]; std::vector offsets(localVertexNum + 1, 0), edgesCount(localVertexNum, 0); @@ -1813,7 +1824,7 @@ int CompactTriangulation::getClusterVertexEdges( } for(iter = nodePtr->externalEdgeMap_.begin(); iter != nodePtr->externalEdgeMap_.end(); iter++) { - SimplexId localVertexId + SimplexId const localVertexId = iter->first[1] - vertexIntervals_[nodePtr->nid - 1] - 1; vertexEdgeData[offsets[localVertexId] + edgesCount[localVertexId]] = iter->second; @@ -1834,7 +1845,7 @@ int CompactTriangulation::getClusterVertexLinks( return -1; #endif - SimplexId localVertexNum + SimplexId const localVertexNum = vertexIntervals_[nodePtr->nid] - vertexIntervals_[nodePtr->nid - 1]; std::vector offsets(localVertexNum + 1, 0), linksCount(localVertexNum, 0); @@ -1858,9 +1869,9 @@ int CompactTriangulation::getClusterVertexLinks( } } } - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { for(SimplexId j = 1; j < 3; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cid, j); + SimplexId const vertexId = cellArray_->getCellVertex(cid, j); if(vertexId > vertexIntervals_[nodePtr->nid - 1] && vertexId <= vertexIntervals_[nodePtr->nid]) { offsets[vertexId - vertexIntervals_[nodePtr->nid - 1]]++; @@ -1885,7 +1896,7 @@ int CompactTriangulation::getClusterVertexLinks( (SimplexId)cellArray_->getCellVertex(cid, 2)}; // the first vertex of the cell must be in the cluster std::array edgePair = {vertexIds[1], vertexIds[2]}; - SimplexId nodeId = vertexIndices_[vertexIds[1]]; + SimplexId const nodeId = vertexIndices_[vertexIds[1]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); buildInternalEdgeMap(&nodeMaps[nodeId], false, true); @@ -1914,13 +1925,13 @@ int CompactTriangulation::getClusterVertexLinks( } } } - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cid, 0), (SimplexId)cellArray_->getCellVertex(cid, 1), (SimplexId)cellArray_->getCellVertex(cid, 2)}; std::array edgePair = {vertexIds[0], vertexIds[2]}; - SimplexId nodeId = vertexIndices_[edgePair[0]]; + SimplexId const nodeId = vertexIndices_[edgePair[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); buildInternalEdgeMap(&nodeMaps[nodeId], false, true); @@ -1969,9 +1980,9 @@ int CompactTriangulation::getClusterVertexLinks( } } } - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { for(SimplexId j = 1; j < 4; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cid, j); + SimplexId const vertexId = cellArray_->getCellVertex(cid, j); if(vertexId > vertexIntervals_[nodePtr->nid - 1] && vertexId <= vertexIntervals_[nodePtr->nid]) { offsets[vertexId - vertexIntervals_[nodePtr->nid - 1]]++; @@ -1999,7 +2010,7 @@ int CompactTriangulation::getClusterVertexLinks( // v1: (v2, v3, v4) std::array triangleVec = {vertexIds[1], vertexIds[2], vertexIds[3]}; - SimplexId nodeId = vertexIndices_[vertexIds[1]]; + SimplexId const nodeId = vertexIndices_[vertexIds[1]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); buildInternalTriangleMap(&nodeMaps[nodeId], false, true); @@ -2040,7 +2051,7 @@ int CompactTriangulation::getClusterVertexLinks( } // loop through the external cell list - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { std::array vertexIds = {(SimplexId)cellArray_->getCellVertex(cid, 0), (SimplexId)cellArray_->getCellVertex(cid, 1), @@ -2049,7 +2060,7 @@ int CompactTriangulation::getClusterVertexLinks( // start from v2 std::array triangleVec = {vertexIds[0], vertexIds[2], vertexIds[3]}; - SimplexId nodeId = vertexIndices_[vertexIds[0]]; + SimplexId const nodeId = vertexIndices_[vertexIds[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); buildInternalTriangleMap(&nodeMaps[nodeId], false, true); @@ -2100,8 +2111,8 @@ int CompactTriangulation::getClusterVertexNeighbors( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); - SimplexId localVertexNum + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const localVertexNum = vertexIntervals_[nodePtr->nid] - vertexIntervals_[nodePtr->nid - 1]; std::vector vertexNeighborData, offsets(localVertexNum + 1, 0); @@ -2129,7 +2140,7 @@ int CompactTriangulation::getClusterVertexNeighbors( } // loop through external cells - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { for(SimplexId j = 0; j < verticesPerCell - 1; j++) { for(SimplexId k = j + 1; k < verticesPerCell; k++) { v1 = cellArray_->getCellVertex(cid, j); @@ -2166,8 +2177,8 @@ int CompactTriangulation::getClusterVertexStars( return -1; #endif - SimplexId verticesPerCell = cellArray_->getCellVertexNumber(0); - SimplexId localVertexNum + SimplexId const verticesPerCell = cellArray_->getCellVertexNumber(0); + SimplexId const localVertexNum = vertexIntervals_[nodePtr->nid] - vertexIntervals_[nodePtr->nid - 1]; std::vector offsets(localVertexNum + 1, 0), starsCount(localVertexNum, 0); @@ -2185,9 +2196,9 @@ int CompactTriangulation::getClusterVertexStars( } } } - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { for(SimplexId j = 1; j < verticesPerCell; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cid, j); + SimplexId const vertexId = cellArray_->getCellVertex(cid, j); if(vertexId > vertexIntervals_[nodePtr->nid - 1] && vertexId <= vertexIntervals_[nodePtr->nid]) { offsets[vertexId - vertexIntervals_[nodePtr->nid - 1]]++; @@ -2211,7 +2222,7 @@ int CompactTriangulation::getClusterVertexStars( vertexStarData[offsets[localVertexId] + starsCount[localVertexId]] = cid; starsCount[localVertexId]++; for(SimplexId j = 1; j < verticesPerCell; j++) { - SimplexId vertexId = cellArray_->getCellVertex(cid, j); + SimplexId const vertexId = cellArray_->getCellVertex(cid, j); // see if it is in the current node if(vertexId > vertexIntervals_[nodePtr->nid - 1] && vertexId <= vertexIntervals_[nodePtr->nid]) { @@ -2222,13 +2233,13 @@ int CompactTriangulation::getClusterVertexStars( } } } - for(SimplexId cid : externalCells_[nodePtr->nid]) { + for(SimplexId const cid : externalCells_[nodePtr->nid]) { for(SimplexId j = 0; j < verticesPerCell; j++) { // see if it is in the current node - SimplexId vertexId = cellArray_->getCellVertex(cid, j); + SimplexId const vertexId = cellArray_->getCellVertex(cid, j); if(vertexId > vertexIntervals_[nodePtr->nid - 1] && vertexId <= vertexIntervals_[nodePtr->nid]) { - SimplexId localVertexId + SimplexId const localVertexId = vertexId - vertexIntervals_[nodePtr->nid - 1] - 1; vertexStarData[offsets[localVertexId] + starsCount[localVertexId]] = cid; @@ -2251,7 +2262,7 @@ int CompactTriangulation::getClusterVertexTriangles( return -1; #endif - SimplexId localVertexNum + SimplexId const localVertexNum = vertexIntervals_[nodePtr->nid] - vertexIntervals_[nodePtr->nid - 1]; std::vector offsets(localVertexNum + 1, 0), trianglesCount(localVertexNum, 0); @@ -2296,7 +2307,7 @@ int CompactTriangulation::getClusterVertexTriangles( for(SimplexId j = 0; j < 3; j++) { if(iter->first[j] > vertexIntervals_[nodePtr->nid - 1] && iter->first[j] <= vertexIntervals_[nodePtr->nid]) { - SimplexId localVertexId + SimplexId const localVertexId = iter->first[j] - vertexIntervals_[nodePtr->nid - 1] - 1; vertexTriangleData[offsets[localVertexId] + trianglesCount[localVertexId]] @@ -2310,7 +2321,7 @@ int CompactTriangulation::getClusterVertexTriangles( for(SimplexId j = 0; j < 3; j++) { if(iter->first[j] > vertexIntervals_[nodePtr->nid - 1] && iter->first[j] <= vertexIntervals_[nodePtr->nid]) { - SimplexId localVertexId + SimplexId const localVertexId = iter->first[j] - vertexIntervals_[nodePtr->nid - 1] - 1; vertexTriangleData[offsets[localVertexId] + trianglesCount[localVertexId]] @@ -2336,7 +2347,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, #endif if(getDimensionality() == 2) { - SimplexId localEdgeNum + SimplexId const localEdgeNum = edgeIntervals_[nodePtr->nid] - edgeIntervals_[nodePtr->nid - 1]; if(nodePtr->boundaryEdges_.empty()) { nodePtr->boundaryEdges_ = std::vector(localEdgeNum, false); @@ -2376,7 +2387,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, boost::unordered_map nodeMaps; for(auto iter = nodePtr->externalEdgeMap_.begin(); iter != nodePtr->externalEdgeMap_.end(); iter++) { - SimplexId nodeId = vertexIndices_[iter->first[0]]; + SimplexId const nodeId = vertexIndices_[iter->first[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); getBoundaryCells(&nodeMaps[nodeId]); @@ -2391,7 +2402,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, } } else if(getDimensionality() == 3) { // get the boundary triangles first - SimplexId localTriangleNum + SimplexId const localTriangleNum = triangleIntervals_[nodePtr->nid] - triangleIntervals_[nodePtr->nid - 1]; if(nodePtr->boundaryTriangles_.empty()) { nodePtr->boundaryTriangles_ = std::vector(localTriangleNum, false); @@ -2436,7 +2447,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, boost::unordered_map nodeMaps; for(auto iter = nodePtr->externalTriangleMap_.begin(); iter != nodePtr->externalTriangleMap_.end(); iter++) { - SimplexId nodeId = vertexIndices_[iter->first[0]]; + SimplexId const nodeId = vertexIndices_[iter->first[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); getBoundaryCells(&nodeMaps[nodeId]); @@ -2446,7 +2457,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, - 1]) { if(iter->first[1] > vertexIntervals_[nodePtr->nid - 1] && iter->first[1] <= vertexIntervals_[nodePtr->nid]) { - std::array edgePair + std::array const edgePair = {iter->first[1], iter->first[2]}; (nodePtr ->boundaryEdges_)[nodePtr->internalEdgeMap_.at(edgePair) - 1] @@ -2469,7 +2480,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, iter != nodePtr->internalTriangleMap_.end(); iter++) { if((nodePtr->boundaryTriangles_)[iter->second - 1]) { for(int j = 0; j < 3; j++) { - SimplexId vid = iter->first[j]; + SimplexId const vid = iter->first[j]; if(vid <= vertexIntervals_[nodePtr->nid]) { (nodePtr ->boundaryVertices_)[vid - vertexIntervals_[nodePtr->nid - 1] @@ -2483,7 +2494,7 @@ int CompactTriangulation::getBoundaryCells(ImplicitCluster *const nodePtr, boost::unordered_map nodeMaps; for(auto iter = nodePtr->externalTriangleMap_.begin(); iter != nodePtr->externalTriangleMap_.end(); iter++) { - SimplexId nodeId = vertexIndices_[iter->first[0]]; + SimplexId const nodeId = vertexIndices_[iter->first[0]]; if(nodeMaps.find(nodeId) == nodeMaps.end()) { nodeMaps[nodeId] = ImplicitCluster(nodeId); ; diff --git a/core/base/compactTriangulation/CompactTriangulation.h b/core/base/compactTriangulation/CompactTriangulation.h index a59192a104..ba81407614 100644 --- a/core/base/compactTriangulation/CompactTriangulation.h +++ b/core/base/compactTriangulation/CompactTriangulation.h @@ -241,8 +241,9 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; - SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; + const SimplexId nid + = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; + const SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->tetraEdges_.empty()) { getClusterTetraEdges(exnode); @@ -302,8 +303,9 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; - SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; + const SimplexId nid + = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; + const SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->cellNeighbors_.empty()) { getClusterCellNeighbors(exnode); @@ -325,8 +327,9 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; - SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; + const SimplexId nid + = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; + const SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->cellNeighbors_.empty()) { getClusterCellNeighbors(exnode); @@ -367,8 +370,9 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; - SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; + const SimplexId nid + = vertexIndices_[cellArray_->getCellVertex(cellId, 0)]; + const SimplexId localCellId = cellId - cellIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->tetraTriangles_.empty()) { getClusterCellTriangles(exnode); @@ -473,8 +477,8 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->edgeLinks_.empty()) { getClusterEdgeLinks(exnode); @@ -496,8 +500,8 @@ namespace ttk { return -1; #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->edgeLinks_.empty()) { getClusterEdgeLinks(exnode); @@ -537,8 +541,8 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->edgeStars_.empty()) { getClusterEdgeStars(exnode); @@ -559,9 +563,9 @@ namespace ttk { if((edgeId < 0) || (edgeId > edgeIntervals_.back())) return -1; #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); ImplicitCluster *exnode = searchCache(nid); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; if(exnode->edgeStars_.empty()) { getClusterEdgeStars(exnode); } @@ -599,8 +603,8 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->edgeTriangles_.empty()) { getClusterEdgeTriangles(exnode); @@ -622,8 +626,8 @@ namespace ttk { return -1; #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->edgeTriangles_.empty()) { getClusterEdgeTriangles(exnode); @@ -663,8 +667,8 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localEdgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->internalEdgeList_.empty()) { buildInternalEdgeMap(exnode, true, false); @@ -748,8 +752,9 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->triangleEdges_.empty()) { getClusterTriangleEdges(exnode); @@ -804,8 +809,9 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->triangleLinks_.empty()) { getClusterTriangleLinks(exnode); @@ -827,8 +833,9 @@ namespace ttk { return -1; #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->triangleLinks_.empty()) { getClusterTriangleLinks(exnode); @@ -870,8 +877,9 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->triangleStars_.empty()) { getClusterTriangleStars(exnode); @@ -894,8 +902,9 @@ namespace ttk { return -1; #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->triangleStars_.empty()) { getClusterTriangleStars(exnode); @@ -934,8 +943,9 @@ namespace ttk { } #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localTriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localTriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->internalTriangleList_.empty()) { buildInternalTriangleMap(exnode, true, false); @@ -960,8 +970,8 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexEdges_.empty()) { getClusterVertexEdges(exnode); @@ -982,8 +992,8 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexEdges_.empty()) { getClusterVertexEdges(exnode); @@ -1024,8 +1034,8 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexLinks_.empty()) { getClusterVertexLinks(exnode); @@ -1046,8 +1056,8 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexLinks_.empty()) { getClusterVertexLinks(exnode); @@ -1086,8 +1096,8 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode == nullptr) { return -1; @@ -1112,8 +1122,8 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexNeighbors_.empty()) { getClusterVertexNeighbors(exnode); @@ -1175,8 +1185,8 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexStars_.empty()) { getClusterVertexStars(exnode); @@ -1197,8 +1207,8 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexStars_.empty()) { getClusterVertexStars(exnode); @@ -1237,8 +1247,8 @@ namespace ttk { } #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexTriangles_.empty()) { getClusterVertexTriangles(exnode); @@ -1260,8 +1270,8 @@ namespace ttk { return -1; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); if(exnode->vertexTriangles_.empty()) { getClusterVertexTriangles(exnode); @@ -1292,8 +1302,8 @@ namespace ttk { if((edgeId < 0) || (edgeId > edgeIntervals_.back())) return false; #endif - SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); - SimplexId localedgeId = edgeId - edgeIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(edgeId, SIMPLEX_ID::EDGE_ID); + const SimplexId localedgeId = edgeId - edgeIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); getBoundaryCells(exnode, 1); return (exnode->boundaryEdges_)[localedgeId]; @@ -1312,8 +1322,9 @@ namespace ttk { if((triangleId < 0) || (triangleId > triangleIntervals_.back())) return false; #endif - SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); - SimplexId localtriangleId = triangleId - triangleIntervals_[nid - 1] - 1; + const SimplexId nid = findNodeIndex(triangleId, SIMPLEX_ID::TRIANGLE_ID); + const SimplexId localtriangleId + = triangleId - triangleIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); getBoundaryCells(exnode); return (exnode->boundaryTriangles_)[localtriangleId]; @@ -1325,8 +1336,8 @@ namespace ttk { if((vertexId < 0) || (vertexId >= vertexNumber_)) return false; #endif - SimplexId nid = vertexIndices_[vertexId]; - SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; + const SimplexId nid = vertexIndices_[vertexId]; + const SimplexId localVertexId = vertexId - vertexIntervals_[nid - 1] - 1; ImplicitCluster *exnode = searchCache(nid); getBoundaryCells(exnode, 0); return (exnode->boundaryVertices_)[localVertexId]; @@ -1561,7 +1572,7 @@ namespace ttk { return -1; } - std::vector::const_iterator low + const std::vector::const_iterator low = lower_bound(intervals->begin(), intervals->end(), id); return (low - intervals->begin()); } @@ -1585,7 +1596,8 @@ namespace ttk { cacheMaps_[threadId].erase(caches_[threadId].back().nid); caches_[threadId].pop_back(); } - caches_[threadId].push_front(ImplicitCluster(nodeId)); + const ImplicitCluster localCluster(nodeId); + caches_[threadId].emplace_front(localCluster); cacheMaps_[threadId][nodeId] = caches_[threadId].begin(); } return &(*cacheMaps_[threadId][nodeId]); diff --git a/core/base/compactTriangulationPreconditioning/CompactTriangulationPreconditioning.h b/core/base/compactTriangulationPreconditioning/CompactTriangulationPreconditioning.h index 9d56e7f164..69799f5e27 100644 --- a/core/base/compactTriangulationPreconditioning/CompactTriangulationPreconditioning.h +++ b/core/base/compactTriangulationPreconditioning/CompactTriangulationPreconditioning.h @@ -68,16 +68,13 @@ namespace ttk { // Compute Octree // ----------------------------------------------------------------------- { - // start a local timer for this subprocedure - ttk::Timer localTimer; - #ifndef TTK_ENABLE_KAMIKAZE if(!triangulation) return -1; #endif SimplexId vertexNumber = triangulation->getNumberOfVertices(); - SimplexId cellNumber = triangulation->getNumberOfCells(); + SimplexId const cellNumber = triangulation->getNumberOfCells(); // create the octree Octree preOctree(triangulation, argument); diff --git a/core/base/connectedComponents/ConnectedComponents.h b/core/base/connectedComponents/ConnectedComponents.h index a7e86ab1da..6598487015 100644 --- a/core/base/connectedComponents/ConnectedComponents.h +++ b/core/base/connectedComponents/ConnectedComponents.h @@ -80,7 +80,8 @@ namespace ttk { size++; // add neihbors - size_t nNeighbors = triangulation->getVertexNeighborNumber(cIndex); + size_t const nNeighbors + = triangulation->getVertexNeighborNumber(cIndex); for(size_t i = 0; i < nNeighbors; i++) { TID nIndex{-1}; triangulation->getVertexNeighbor(cIndex, i, nIndex); @@ -110,7 +111,7 @@ namespace ttk { const DT *featureMask = nullptr, const DT backgroundThreshold = 0) const { Timer timer; - std::string msg + std::string const msg = "Initializing IDs" + std::string(featureMask ? (" with BT: " + std::to_string(backgroundThreshold)) @@ -134,7 +135,7 @@ namespace ttk { int *componentIds, const TT *triangulation) const { - TID nVertices = triangulation->getNumberOfVertices(); + TID const nVertices = triangulation->getNumberOfVertices(); Timer timer; const std::string msg = "Computing Connected Components"; diff --git a/core/base/continuousScatterPlot/ContinuousScatterPlot.h b/core/base/continuousScatterPlot/ContinuousScatterPlot.h index c9311035d5..626b1f05e6 100644 --- a/core/base/continuousScatterPlot/ContinuousScatterPlot.h +++ b/core/base/continuousScatterPlot/ContinuousScatterPlot.h @@ -207,14 +207,14 @@ int ttk::ContinuousScatterPlot::execute( Geometry::crossProduct(v13, v12, a); Geometry::crossProduct(v12, v14, b); Geometry::crossProduct(v14, v13, c); - double det = Geometry::dotProduct(v14, a); + const double det = Geometry::dotProduct(v14, a); if(det == 0.) { for(int k = 0; k < 3; ++k) { g0[k] = 0.0; g1[k] = 0.0; } } else { - double invDet = 1.0 / det; + const double invDet = 1.0 / det; for(int k = 0; k < 3; ++k) { g0[k] = (s14[0] * a[k] + s13[0] * b[k] + s12[0] * c[k]) * invDet; g1[k] = (s14[1] * a[k] + s13[1] * b[k] + s12[1] * c[k]) * invDet; @@ -248,7 +248,7 @@ int ttk::ContinuousScatterPlot::execute( int index[4]{0, 1, 2, 3}; bool isInTriangle{}; // True if the tetra is class 0 - bool zCrossProductsSigns[4] + const bool zCrossProductsSigns[4] = {(data[1][0] - data[0][0]) * (data[2][1] - data[0][1]) - (data[1][1] - data[0][1]) * (data[2][0] - data[0][0]) > 0, @@ -400,12 +400,12 @@ int ttk::ContinuousScatterPlot::execute( = Geometry::distance(data[index[0]], imaginaryPosition); double diagonalLength = Geometry::distance(data[index[0]], data[index[1]]); - double r0 = distanceToIntersection / diagonalLength; + const double r0 = distanceToIntersection / diagonalLength; distanceToIntersection = Geometry::distance(data[index[2]], imaginaryPosition); diagonalLength = Geometry::distance(data[index[2]], data[index[3]]); - double r1 = distanceToIntersection / diagonalLength; + const double r1 = distanceToIntersection / diagonalLength; double p0[3]; double p1[3]; diff --git a/core/base/contourAroundPoint/ContourAroundPoint.hpp b/core/base/contourAroundPoint/ContourAroundPoint.hpp index 109c874ba2..f022363965 100644 --- a/core/base/contourAroundPoint/ContourAroundPoint.hpp +++ b/core/base/contourAroundPoint/ContourAroundPoint.hpp @@ -122,7 +122,7 @@ namespace ttk { template double compRadius() { if(_inpFldTriang) { - float x, y, z; + float x = 0, y = 0, z = 0; reinterpret_cast(_inpFldTriang) ->getVertexPoint(0, x, y, z); _radius = std::sqrt(x * x + y * y + z * z); diff --git a/core/base/contourForests/ContourForests.cpp b/core/base/contourForests/ContourForests.cpp index 3b9d9a2a92..f301935cc4 100644 --- a/core/base/contourForests/ContourForests.cpp +++ b/core/base/contourForests/ContourForests.cpp @@ -55,7 +55,7 @@ idPartition ContourForests::vertex2partition(const SimplexId &v) { void ContourForests::initInterfaces() { // We have nbThread_ partition of the same size through all vertices - size_t partitionSize = scalars_->size / parallelParams_.nbPartitions; + const size_t partitionSize = scalars_->size / parallelParams_.nbPartitions; // ------------------ // Seeds @@ -343,7 +343,7 @@ void ContourForests::unifyTree(const char treetype) { for(auto &l : currentTree->treeData_.leaves) { Node *curNode = currentTree->getNode(l); - SimplexId leafVert = curNode->getVertexId(); + const SimplexId leafVert = curNode->getVertexId(); // Condition to keep diff --git a/core/base/contourForests/ContourForestsTemplate.h b/core/base/contourForests/ContourForestsTemplate.h index 803e5c086f..51b9bdb767 100644 --- a/core/base/contourForests/ContourForestsTemplate.h +++ b/core/base/contourForests/ContourForestsTemplate.h @@ -33,7 +33,7 @@ namespace ttk { int ContourForests::build(const triangulationType &mesh) { #ifdef TTK_ENABLE_OPENMP - ParallelGuard pg{parallelParams_.nbThreads}; + const ParallelGuard pg{parallelParams_.nbThreads}; #endif DebugTimer timerTOTAL; @@ -217,7 +217,7 @@ namespace ttk { if(params_->treeType == TreeType::Contour && parallelParams_.partitionNum == -1 && params_->simplifyThreshold) { DebugTimer timerGlobalSimplify; - SimplexId simplified + SimplexId const simplified = globalSimplify(-1, nullVertex, this->storage_, mesh); if(params_->debugLevel >= 1) { printDebug(timerGlobalSimplify, "Simplify Contour tree "); @@ -280,7 +280,7 @@ namespace ttk { std::vector> &vect_baseUF_ST, const triangulationType &mesh) { - std::vector timeSimplify(parallelParams_.nbPartitions, 0); + const std::vector timeSimplify(parallelParams_.nbPartitions, 0); std::vector speedProcess(parallelParams_.nbPartitions * 2, 0); #ifdef TTK_ENABLE_CONTOUR_FORESTS_PARALLEL_SIMPLIFY SimplexId nbPairMerged = 0; @@ -336,7 +336,7 @@ namespace ttk { if(params_->treeType == TreeType::Join || params_->treeType == TreeType::Contour || params_->treeType == TreeType::JoinAndSplit) { - DebugTimer timerSimplify; + DebugTimer timerBuild; parallelData_.trees[i].getJoinTree()->build( vect_baseUF_JT[i], std::get<0>(overlaps), std::get<1>(overlaps), @@ -345,6 +345,7 @@ namespace ttk { speedProcess[i] = partitionSize / timerBuild.getElapsedTime(); #ifdef TTK_ENABLE_CONTOUR_FORESTS_PARALLEL_SIMPLIFY + DebugTimer timerSimplify; timerSimplify.reStart(); const SimplexId tmpMerge = @@ -369,7 +370,7 @@ namespace ttk { if(params_->treeType == TreeType::Split || params_->treeType == TreeType::Contour || params_->treeType == TreeType::JoinAndSplit) { - DebugTimer timerSimplify; + DebugTimer timerBuild; parallelData_.trees[i].getSplitTree()->build( vect_baseUF_ST[i], std::get<1>(overlaps), std::get<0>(overlaps), @@ -379,6 +380,7 @@ namespace ttk { = partitionSize / timerBuild.getElapsedTime(); #ifdef TTK_ENABLE_CONTOUR_FORESTS_PARALLEL_SIMPLIFY + DebugTimer timerSimplify; timerSimplify.reStart(); const SimplexId tmpMerge = @@ -534,7 +536,7 @@ namespace ttk { for(SimplexId e = 0; e < nbEdges; e++) { #ifdef TTK_ENABLE_OPENMP - idPartition part = omp_get_thread_num(); + idPartition const part = omp_get_thread_num(); #else idPartition part = 0; #endif diff --git a/core/base/contourForestsTree/DeprecatedNode.h b/core/base/contourForestsTree/DeprecatedNode.h index dd354ed09b..cd27b69973 100644 --- a/core/base/contourForestsTree/DeprecatedNode.h +++ b/core/base/contourForestsTree/DeprecatedNode.h @@ -139,13 +139,13 @@ namespace ttk { } inline idSuperArc clearDownSuperArcs() { - idSuperArc s = vect_downSuperArcList_.size(); + const idSuperArc s = vect_downSuperArcList_.size(); vect_downSuperArcList_.clear(); return s; } inline idSuperArc clearUpSuperArcs() { - idSuperArc s = vect_upSuperArcList_.size(); + const idSuperArc s = vect_upSuperArcList_.size(); vect_upSuperArcList_.clear(); return s; } diff --git a/core/base/contourForestsTree/MergeTree.cpp b/core/base/contourForestsTree/MergeTree.cpp index 0814b0eed1..a325aa246e 100644 --- a/core/base/contourForestsTree/MergeTree.cpp +++ b/core/base/contourForestsTree/MergeTree.cpp @@ -220,7 +220,7 @@ idSuperArc MergeTree::openSuperArc(const idNode &downNodeId, } #endif - idSuperArc newSuperArcId = treeData_.superArcs.size(); + const idSuperArc newSuperArcId = treeData_.superArcs.size(); treeData_.superArcs.emplace_back(downNodeId, nullNodes, overlapB, overlapA, treeData_.partition, treeData_.partition); treeData_.nodes[downNodeId].addUpSuperArcId(newSuperArcId); @@ -235,7 +235,7 @@ idSuperArc MergeTree::makeSuperArc(const idNode &downNodeId, const bool overlapA, pair *vertexList, SimplexId vertexSize) { - idSuperArc newSuperArcId = treeData_.superArcs.size(); + const idSuperArc newSuperArcId = treeData_.superArcs.size(); if(downNodeId != upNodeId) { treeData_.superArcs.emplace_back(downNodeId, upNodeId, overlapB, overlapA, @@ -526,7 +526,7 @@ idNode MergeTree::makeNode(const SimplexId &vertexId, const SimplexId &term) { return getCorrespondingNodeId(vertexId); } - SimplexId size_base = (SimplexId)treeData_.nodes.size(); + const SimplexId size_base = (SimplexId)treeData_.nodes.size(); treeData_.nodes.emplace_back(vertexId, term); updateCorrespondingNode(vertexId, size_base); @@ -564,7 +564,7 @@ void MergeTree::delNode( } #endif - idSuperArc downArc = mainNode->getDownSuperArcId(0); + const idSuperArc downArc = mainNode->getDownSuperArcId(0); Node *downNode = getNode(treeData_.superArcs[downArc].getDownNodeId()); downNode->removeUpSuperArc(downArc); mainNode->clearDownSuperArcs(); @@ -580,8 +580,8 @@ void MergeTree::delNode( // We delete the upArc, // if there is a down arc, we reattach it to the upNode - idSuperArc upArc = mainNode->getUpSuperArcId(0); - idNode upId = treeData_.superArcs[upArc].getUpNodeId(); + const idSuperArc upArc = mainNode->getUpSuperArcId(0); + const idNode upId = treeData_.superArcs[upArc].getUpNodeId(); Node *upNode = getNode(upId); upNode->removeDownSuperArc(upArc); @@ -723,7 +723,7 @@ idSuperArc MergeTree::insertNode(Node *node, const bool segment) { return isLower(a.first, b.first); }); - SimplexId newNodePos = newNodePosPtr - tmpSA->getVertList(); + const SimplexId newNodePos = newNodePosPtr - tmpSA->getVertList(); getSuperArc(newSA)->setVertList(newNodePosPtr); getSuperArc(newSA)->setVertSize(tmpSA->getVertSize() - newNodePos); @@ -797,7 +797,7 @@ idSuperArc MergeTree::reverseInsertNode(Node *node, const bool segment) { return isLower(a.first, b.first); }); - SimplexId newNodePos = newNodePosPtr - tmpSA->getVertList(); + const SimplexId newNodePos = newNodePosPtr - tmpSA->getVertList(); getSuperArc(newSA)->setVertList(tmpSA->getVertList()); getSuperArc(newSA)->setVertSize(newNodePos); @@ -1244,8 +1244,8 @@ tuple MergeTree::createReceptArc( if(upNode == downNode) { // several degen. nodes adjacent // Prefer down for JT / ST - idSuperArc tmpDown = newDownArc(downNode, ufArray); - idSuperArc tmpUp = newUpArc(upNode, ufArray); + const idSuperArc tmpDown = newDownArc(downNode, ufArray); + const idSuperArc tmpUp = newUpArc(upNode, ufArray); if(tmpDown == nullSuperArc) { upNode = getSuperArc(tmpUp)->getUpNodeId(); diff --git a/core/base/contourTree/ContourTree.cpp b/core/base/contourTree/ContourTree.cpp index 6b301e6155..6895ed8528 100644 --- a/core/base/contourTree/ContourTree.cpp +++ b/core/base/contourTree/ContourTree.cpp @@ -23,11 +23,12 @@ struct MyCmp { } bool operator()(int node1, int node2) { - int vertex1 = (*nodeList_)[node1].getVertexId(); - int vertex2 = (*nodeList_)[node2].getVertexId(); - bool cmp = ((*vertexScalars_)[vertex1] < (*vertexScalars_)[vertex2]) - || ((*vertexScalars_)[vertex1] == (*vertexScalars_)[vertex2] - && (*vertexOffsets_)[vertex1] < (*vertexOffsets_)[vertex2]); + int const vertex1 = (*nodeList_)[node1].getVertexId(); + int const vertex2 = (*nodeList_)[node2].getVertexId(); + bool const cmp + = ((*vertexScalars_)[vertex1] < (*vertexScalars_)[vertex2]) + || ((*vertexScalars_)[vertex1] == (*vertexScalars_)[vertex2] + && (*vertexOffsets_)[vertex1] < (*vertexOffsets_)[vertex2]); if(isAscendingOrder_) return cmp; else @@ -84,7 +85,7 @@ struct _persistencePairCmp { void SuperArc::smooth(const vector &nodeList, const vector> *vertexPositions, bool order) { - int N = getNumberOfBarycenters(); + int const N = getNumberOfBarycenters(); if(N) { /// init /// vector> barycenterList(barycenterList_.size()); @@ -140,7 +141,7 @@ void SuperArc::sortRegularNodes(const vector *vertexScalars, const vector *vertexOffsets, const vector *nodeList, bool order) { - MyCmp cmp(vertexScalars, vertexOffsets, nodeList, order); + MyCmp const cmp(vertexScalars, vertexOffsets, nodeList, order); if(order) std::sort(regularNodeList_.begin(), regularNodeList_.end(), cmp); @@ -274,7 +275,7 @@ int SubLevelSetTree::build() { merge = false; firstUf = nullptr; - SimplexId neighborNumber + SimplexId const neighborNumber = triangulation_->getVertexNeighborNumber(vertexId); for(SimplexId i = 0; i < neighborNumber; i++) { triangulation_->getVertexNeighbor(vertexId, i, nId); @@ -307,13 +308,13 @@ int SubLevelSetTree::build() { vertexSeeds[vertexId] = UnionFind::makeUnion(starSets); - int newNodeId = makeNode(vertexId); + int const newNodeId = makeNode(vertexId); if(merge) { vector seedIds; for(int i = 0; i < (int)starSets.size(); i++) { - int seedId = starSets[i] - &(seeds[0]); + int const seedId = starSets[i] - &(seeds[0]); bool found = false; for(int j = 0; j < (int)seedIds.size(); j++) { if(seedIds[j] == seedId) { @@ -326,18 +327,18 @@ int SubLevelSetTree::build() { } for(int i = 0; i < (int)seedIds.size(); i++) { - int superArcId + int const superArcId = seedSuperArcs[seedIds[i]][seedSuperArcs[seedIds[i]].size() - 1]; closeSuperArc(superArcId, newNodeId); } - int seedId = vertexSeeds[vertexId] - &(seeds[0]); + int const seedId = vertexSeeds[vertexId] - &(seeds[0]); if(!filtrationFront.empty()) seedSuperArcs[seedId].push_back(openSuperArc(newNodeId)); } else if(starSets.size()) { // we're dealing with a degree-2 node - int seedId = starSets[0] - &(seeds[0]); - int superArcId + int const seedId = starSets[0] - &(seeds[0]); + int const superArcId = seedSuperArcs[seedId][seedSuperArcs[seedId].size() - 1]; if(filtrationFront.empty()) { @@ -373,7 +374,8 @@ int SubLevelSetTree::clearArc(const int &vertexId0, const int &vertexId1) { if((vertexId1 < 0) || (vertexId1 >= vertexNumber_)) return -2; - int nodeId0 = vertex2node_[vertexId0], nodeId1 = vertex2node_[vertexId1]; + const int nodeId0 = vertex2node_[vertexId0], + nodeId1 = vertex2node_[vertexId1]; for(int i = 0; i < nodeList_[nodeId0].getNumberOfUpArcs(); i++) { if(nodeList_[arcList_[nodeList_[nodeId0].getUpArcId(i)].getUpNodeId()] @@ -401,16 +403,16 @@ int SubLevelSetTree::clearRegularNode(const int &vertexId) { if((vertexId < 0) || (vertexId >= vertexNumber_)) return -1; - int nodeId = vertex2node_[vertexId]; + int const nodeId = vertex2node_[vertexId]; if(!((nodeList_[nodeId].getNumberOfDownArcs() == 1) && (nodeList_[nodeId].getNumberOfUpArcs() == 1))) return -2; - int downArcId = nodeList_[nodeId].getDownArcId(0), - upArcId = nodeList_[nodeId].getUpArcId(0); + const int downArcId = nodeList_[nodeId].getDownArcId(0), + upArcId = nodeList_[nodeId].getUpArcId(0); - int upNodeId = arcList_[upArcId].getUpNodeId(); + int const upNodeId = arcList_[upArcId].getUpNodeId(); // removes the arcs from the current node nodeList_[nodeId].removeDownArcId(0); @@ -437,7 +439,7 @@ int SubLevelSetTree::clearRoot(const int &vertexId) { if((vertexId < 0) || (vertexId >= vertexNumber_)) return -1; - int nodeId = vertex2node_[vertexId]; + int const nodeId = vertex2node_[vertexId]; if((nodeList_[nodeId].getNumberOfDownArcs() == 1) && (!nodeList_[nodeId].getNumberOfUpArcs())) { @@ -471,12 +473,12 @@ int SubLevelSetTree::exportArcPosToVtk(const int &arcId, myVoxelSize[0] = myVoxelSize[1] = myVoxelSize[2] = 1; } - double offset = myVoxelSize[0]; + double const offset = myVoxelSize[0]; vector v; - int downNodeId = superArcList_[arcId].downNodeId_; - int upNodeId = superArcList_[arcId].upNodeId_; + int const downNodeId = superArcList_[arcId].downNodeId_; + int const upNodeId = superArcList_[arcId].upNodeId_; v = (*vertexPositions_)[nodeList_[downNodeId].vertexId_]; // fix a bug in paraview @@ -617,7 +619,7 @@ int SubLevelSetTree::exportNodePosToVtk(const int &nodeId, myVoxelSize[0] = myVoxelSize[1] = myVoxelSize[2] = 1; } - double offset = myVoxelSize[0]; + double const offset = myVoxelSize[0]; vector v; @@ -778,7 +780,7 @@ int SubLevelSetTree::exportToSvg(const string &fileName, if(!vertexScalars_) return -1; - bool hasLayout = buildPlanarLayout(scaleX, scaleY); + bool const hasLayout = buildPlanarLayout(scaleX, scaleY); // put the root right above the highest saddle double minY = -1, maxY = -1; @@ -823,7 +825,7 @@ int SubLevelSetTree::exportToSvg(const string &fileName, } } - string dotFileName = fileName + ".dot"; + string const dotFileName = fileName + ".dot"; ofstream dotFile(dotFileName.data(), ios::out); @@ -854,8 +856,8 @@ int SubLevelSetTree::exportToSvg(const string &fileName, if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].getDownNodeId(); - int upNodeId = superArcList_[i].getUpNodeId(); + int const downNodeId = superArcList_[i].getDownNodeId(); + int const upNodeId = superArcList_[i].getUpNodeId(); dotFile << " \"f = "; dotFile << (*vertexScalars_)[nodeList_[downNodeId].vertexId_]; @@ -950,7 +952,7 @@ int SubLevelSetTree::exportToSvg(const string &fileName, this->printMsg("Calling GraphViz to generate the SVG file."); this->printMsg("This may take a long time..."); - int cmdRet = system(commandLine.str().data()); + int const cmdRet = system(commandLine.str().data()); if((!cmdRet) || (cmdRet == 256)) { this->printMsg( @@ -1014,8 +1016,8 @@ int SubLevelSetTree::exportToVtk(const string &fileName, // node color for(int i = 0; i < (int)superArcList_.size(); i++) { if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].downNodeId_; - int upNodeId = superArcList_[i].upNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; if(!nodeColorOut[downNodeId]) { o << " "; @@ -1054,8 +1056,8 @@ int SubLevelSetTree::exportToVtk(const string &fileName, int pointId = 0; for(int i = 0; i < (int)superArcList_.size(); i++) { if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].downNodeId_; - int upNodeId = superArcList_[i].upNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; if(!nodePosOut[downNodeId]) { o << " "; @@ -1094,8 +1096,8 @@ int SubLevelSetTree::exportToVtk(const string &fileName, for(int i = 0; i < (int)superArcList_.size(); i++) { if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].downNodeId_; - int upNodeId = superArcList_[i].upNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; if(!nodeMeshOut[downNodeId]) { o << " " << nodeIds[downNodeId][0] << " " @@ -1190,9 +1192,9 @@ int SubLevelSetTree::buildExtremumList(vector &extremumList, for(SimplexId i = 0; i < triangulation_->getNumberOfVertices(); i++) { bool isExtremum = true; - SimplexId neighborNumber = triangulation_->getVertexNeighborNumber(i); + SimplexId const neighborNumber = triangulation_->getVertexNeighborNumber(i); for(SimplexId j = 0; j < neighborNumber; j++) { - SimplexId otherId; + SimplexId otherId = -1; triangulation_->getVertexNeighbor(i, j, otherId); if(isSubLevelSet) { @@ -1326,13 +1328,13 @@ int SubLevelSetTree::getPersistencePairs( for(int i = 0; i < getNumberOfSuperArcs(); ++i) { const SuperArc *a = getSuperArc(i); const Node *n = getNode(a->getDownNodeId()); - int nodeId = n->getVertexId(); + int const nodeId = n->getVertexId(); if(!n->getNumberOfDownSuperArcs()) { // internal, split trees and merges trees have their leaves at the bottom double extremumScalar = 0; double saddleScalar = 0; - int saddleId = getNode(a->getUpNodeId())->getVertexId(); + int const saddleId = getNode(a->getUpNodeId())->getVertexId(); extremumScalar = (*vertexScalars_)[nodeId]; saddleScalar = (*vertexScalars_)[saddleId]; @@ -1340,7 +1342,7 @@ int SubLevelSetTree::getPersistencePairs( pairs[leafId].first.first = nodeId; pairs[leafId].first.second = saddleId; pairs[leafId].second = fabs(saddleScalar - extremumScalar); - float persistence = pairs[leafId].second; + float const persistence = pairs[leafId].second; if(isnan(persistence)) pairs[leafId].second = 0; @@ -1372,11 +1374,11 @@ int SubLevelSetTree::getPersistencePairs( if(!(getNode(a->getUpNodeId())->getNumberOfUpSuperArcs())) break; - int nextArcId = getNode(a->getUpNodeId())->getUpSuperArcId(0); + int const nextArcId = getNode(a->getUpNodeId())->getUpSuperArcId(0); a = getSuperArc(nextArcId); if(a) { - int saddleId = getNode(a->getUpNodeId())->getVertexId(); + int const saddleId = getNode(a->getUpNodeId())->getVertexId(); if(!getNode(a->getUpNodeId())->getNumberOfDownSuperArcs()) break; @@ -1390,7 +1392,7 @@ int SubLevelSetTree::getPersistencePairs( saddleScalar = (*vertexScalars_)[saddleId]; pairs[j].first.second = saddleId; pairs[j].second = fabs(saddleScalar - extremumScalar); - float persistence = pairs[j].second; + float const persistence = pairs[j].second; if(isnan(persistence)) pairs[j].second = 0; break; @@ -1421,15 +1423,15 @@ int SubLevelSetTree::getPersistencePairs( pairs.back().second = fabs((*vertexScalars_)[pairs.back().first.first] - (*vertexScalars_)[pairs.back().first.second]); - float persistence = pairs.back().second; + float const persistence = pairs.back().second; if(isnan(persistence)) pairs.back().second = 0; break; } } - std::string pairtype = isMergeTree ? "(0-1)" : "(1-2)"; - std::string pairextr = isMergeTree ? "min" : "max"; + std::string const pairtype = isMergeTree ? "(0-1)" : "(1-2)"; + std::string const pairextr = isMergeTree ? "min" : "max"; this->printMsg( std::vector>{ @@ -1491,8 +1493,8 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, // 1) set the y coordinate for everyone for(int i = 0; i < (int)superArcList_.size(); i++) { - int downNodeId = superArcList_[i].downNodeId_; - int upNodeId = superArcList_[i].upNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; nodeList_[downNodeId].layoutY_ = ((*vertexScalars_)[nodeList_[downNodeId].vertexId_] - minScalar_) @@ -1515,7 +1517,7 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].downNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; if(!nodeList_[downNodeId].downSuperArcList_.size()) { pair>> n; n.first = (minimumList_ ? true : false); @@ -1534,23 +1536,23 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, // filtration loop do { - int vertexId = front.begin()->second.second.second; + int const vertexId = front.begin()->second.second.second; front.erase(front.begin()); - int nodeId = vertex2node_[vertexId]; + int const nodeId = vertex2node_[vertexId]; // retrieve the number of leaves given by its children for(int i = 0; i < (int)nodeList_[nodeId].downSuperArcList_.size(); i++) { - int arcId = nodeList_[nodeId].downSuperArcList_[i]; - int childId = superArcList_[arcId].downNodeId_; + int const arcId = nodeList_[nodeId].downSuperArcList_[i]; + int const childId = superArcList_[arcId].downNodeId_; node2LeafNumber[nodeId] += node2LeafNumber[childId]; } // add its parents to the front for(int i = 0; i < (int)nodeList_[nodeId].upSuperArcList_.size(); i++) { - int arcId = nodeList_[nodeId].upSuperArcList_[i]; - int parentId = superArcList_[arcId].upNodeId_; + int const arcId = nodeList_[nodeId].upSuperArcList_[i]; + int const parentId = superArcList_[arcId].upNodeId_; if(!inFront[parentId]) { pair>> n; @@ -1577,7 +1579,7 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, for(int i = 0; i < (int)superArcList_.size(); i++) { if(!superArcList_[i].pruned_) { - int upNodeId = superArcList_[i].upNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; if(!nodeList_[upNodeId].upSuperArcList_.size()) { // that's it rootId = upNodeId; @@ -1600,7 +1602,7 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, do { - int nodeId = nodeQueue.front(); + int const nodeId = nodeQueue.front(); nodeQueue.pop(); // get the number of leaves of the first child @@ -1609,8 +1611,8 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, if((nodeList_[nodeId].downSuperArcList_.size()) && (nodeId != subRootId) && (nodeId != rootId)) { - int arcId = nodeList_[nodeId].downSuperArcList_[0]; - int childId = superArcList_[arcId].downNodeId_; + int const arcId = nodeList_[nodeId].downSuperArcList_[0]; + int const childId = superArcList_[arcId].downNodeId_; ratio = node2LeafNumber[childId] / ((double)node2LeafNumber[nodeId]); if(ratio > 1) @@ -1631,8 +1633,8 @@ bool SubLevelSetTree::buildPlanarLayout(const double &scaleX, // pass the right interval to the children and add them to the queue double xOffset = 0; for(int i = 0; i < (int)nodeList_[nodeId].downSuperArcList_.size(); i++) { - int arcId = nodeList_[nodeId].downSuperArcList_[i]; - int childId = superArcList_[arcId].downNodeId_; + int const arcId = nodeList_[nodeId].downSuperArcList_[i]; + int const childId = superArcList_[arcId].downNodeId_; ratio = node2LeafNumber[childId] / ((double)node2LeafNumber[nodeId]); if(ratio > 1) @@ -1755,7 +1757,7 @@ int SubLevelSetTree::moveRegularNode(const Node *n, const Node *newUp) { int arcId = -1; - int nodeId = n - &(nodeList_[0]); + int const nodeId = n - &(nodeList_[0]); // remove n from oldDown and oldUp and update n for(int i = 0; i < oldUp->getNumberOfDownArcs(); i++) { @@ -1813,7 +1815,7 @@ int SubLevelSetTree::moveRegularNode(const Node *n, int SubLevelSetTree::print() const { - stringstream msg; + stringstream const msg; this->printMsg( "Node list (" + std::to_string(getNumberOfNodes()) + " nodes):", @@ -1941,7 +1943,7 @@ int SubLevelSetTree::simplify(const double &simplificationThreshold, // if(!unNormalizedThreshold) return -4; - vector> regularNodeList; + vector> const regularNodeList; int arcToSimplify = -1; double currentScore = 0, minScore; @@ -1956,8 +1958,8 @@ int SubLevelSetTree::simplify(const double &simplificationThreshold, if(!superArcList_[i].pruned_) { - int downNodeId = superArcList_[i].downNodeId_; - int upNodeId = superArcList_[i].upNodeId_; + int const downNodeId = superArcList_[i].downNodeId_; + int const upNodeId = superArcList_[i].upNodeId_; if(!nodeList_[downNodeId].downSuperArcList_.size()) { @@ -1987,8 +1989,8 @@ int SubLevelSetTree::simplify(const double &simplificationThreshold, break; // perform the simplification - int downNodeId = superArcList_[arcToSimplify].downNodeId_; - int upNodeId = superArcList_[arcToSimplify].upNodeId_; + int const downNodeId = superArcList_[arcToSimplify].downNodeId_; + int const upNodeId = superArcList_[arcToSimplify].upNodeId_; int pivotId = upNodeId; int leafId = downNodeId; @@ -1999,9 +2001,9 @@ int SubLevelSetTree::simplify(const double &simplificationThreshold, leafId = downNodeId; } - bool isSimpleSaddle = (nodeList_[pivotId].downSuperArcList_.size() - + nodeList_[pivotId].upSuperArcList_.size() - == 3); + bool const isSimpleSaddle = (nodeList_[pivotId].downSuperArcList_.size() + + nodeList_[pivotId].upSuperArcList_.size() + == 3); int brotherId = 0; @@ -2012,9 +2014,9 @@ int SubLevelSetTree::simplify(const double &simplificationThreshold, } } - int brotherExtremityId = superArcList_[brotherId].downNodeId_; + int const brotherExtremityId = superArcList_[brotherId].downNodeId_; - int parentId = nodeList_[pivotId].upSuperArcList_[0]; + int const parentId = nodeList_[pivotId].upSuperArcList_[0]; // 1) update the parent extremity (only if simple saddles) if(isSimpleSaddle) { @@ -2346,9 +2348,9 @@ int ContourTree::build() { for(int i = 0; i < vertexNumber_; i++) { bool isMin = true, isMax = true; - SimplexId neighborNumber = triangulation_->getVertexNeighborNumber(i); + SimplexId const neighborNumber = triangulation_->getVertexNeighborNumber(i); for(SimplexId j = 0; j < neighborNumber; j++) { - SimplexId nId; + SimplexId nId = -1; triangulation_->getVertexNeighbor(i, j, nId); if(((*vertexScalars_)[nId] > (*vertexScalars_)[i]) @@ -2436,7 +2438,7 @@ int ContourTree::combineTrees() { do { - int initQueueSize = (int)nodeQueue.size(); + int const initQueueSize = (int)nodeQueue.size(); for(int i = 0; i < mergeTree_.getNumberOfNodes(); i++) { mergeNode = mergeTree_.getNode(i); @@ -2483,8 +2485,8 @@ int ContourTree::combineTrees() { n1 = mergeTree_.getNodeUpNeighbor(n0, 0); - int newNode0 = makeNode(n0->getVertexId()), - newNode1 = makeNode(n1->getVertexId()); + const int newNode0 = makeNode(n0->getVertexId()), + newNode1 = makeNode(n1->getVertexId()); // "we move v and its incident edge from JT to the contour tree". makeArc(newNode0, newNode1); @@ -2533,8 +2535,8 @@ int ContourTree::combineTrees() { n1 = splitTree_.getNodeUpNeighbor(n0, 0); - int newNode0 = makeNode(n0->getVertexId()), - newNode1 = makeNode(n1->getVertexId()); + const int newNode0 = makeNode(n0->getVertexId()), + newNode1 = makeNode(n1->getVertexId()); makeArc(newNode1, newNode0); splitTree_.clearArc(n0->getVertexId(), n1->getVertexId()); @@ -2592,11 +2594,11 @@ int ContourTree::finalize() { while(nodeIdQueue.size()) { - int nodeId = nodeIdQueue.front(); + int const nodeId = nodeIdQueue.front(); nodeIdQueue.pop(); for(int i = 0; i < nodeList_[nodeId].getNumberOfUpArcs(); i++) { - int nextNodeId = finalizeSuperArc(nodeId, i); + int const nextNodeId = finalizeSuperArc(nodeId, i); if(!inQueue[nextNodeId]) { nodeIdQueue.push(nextNodeId); @@ -2615,7 +2617,7 @@ int ContourTree::finalizeSuperArc(const int &nodeId, const int &arcId) { if((arcId < 0) || (arcId >= nodeList_[nodeId].getNumberOfUpArcs())) return -2; - int superArcId = openSuperArc(nodeId); + int const superArcId = openSuperArc(nodeId); int currentNodeId = nodeId; @@ -2810,7 +2812,7 @@ int ContourTree::getPersistencePairs( for(unsigned int i = 0; i < mergePairs->size(); ++i) pairs[i] = (*mergePairs)[i]; - unsigned int shift = mergePairs->size(); + unsigned int const shift = mergePairs->size(); for(unsigned int i = 0; i < splitPairs->size(); ++i) pairs[shift + i] = (*splitPairs)[i]; diff --git a/core/base/contourTreeAlignment/CTA_contourtree.cpp b/core/base/contourTreeAlignment/CTA_contourtree.cpp index 1f2abda94e..abda27ff2e 100644 --- a/core/base/contourTreeAlignment/CTA_contourtree.cpp +++ b/core/base/contourTreeAlignment/CTA_contourtree.cpp @@ -57,10 +57,10 @@ ContourTree::ContourTree(float *scalars, if(node->edgeList.size() > 1) node->type = saddleNode; else { - std::shared_ptr edge = arcs[node->edgeList[0]]; - std::shared_ptr neighbor = nodes[edge->node1Idx] == node - ? nodes[edge->node2Idx] - : nodes[edge->node1Idx]; + const std::shared_ptr edge = arcs[node->edgeList[0]]; + const std::shared_ptr neighbor + = nodes[edge->node1Idx] == node ? nodes[edge->node2Idx] + : nodes[edge->node1Idx]; if(neighbor->scalarValue > node->scalarValue) node->type = minNode; else @@ -109,17 +109,17 @@ std::shared_ptr ContourTree::computeRootedTree( // add neighbors to children for(size_t i = 0; i < node->edgeList.size(); i++) { - std::shared_ptr edge = arcs[node->edgeList[i]]; + const std::shared_ptr edge = arcs[node->edgeList[i]]; if(edge == parent) { parentVisited = true; continue; } - std::shared_ptr child = nodes[edge->node1Idx] == node - ? nodes[edge->node2Idx] - : nodes[edge->node1Idx]; + const std::shared_ptr child + = nodes[edge->node1Idx] == node ? nodes[edge->node2Idx] + : nodes[edge->node1Idx]; - std::shared_ptr childTree = computeRootedTree(child, edge, id); + const std::shared_ptr childTree = computeRootedTree(child, edge, id); t->children[i - (parentVisited ? 1 : 0)] = childTree; @@ -156,16 +156,17 @@ std::shared_ptr ContourTree::computeRootedTree_binary( // set type/label t->type = node->type; std::shared_ptr edge = arcs[node->edgeList[0]]; - int nodeIdx = nodes[edge->node1Idx] == node ? edge->node1Idx : edge->node2Idx; + const int nodeIdx + = nodes[edge->node1Idx] == node ? edge->node1Idx : edge->node2Idx; t->nodeRefs = std::vector>(); t->nodeRefs.emplace_back(-1, nodeIdx); t->arcRefs = std::vector>(); // if(parent != nullptr) // t->arcRefs.push_back(std::make_pair(-1,parent->segId)); if(parent != nullptr) { - int arcRef = arcs[node->edgeList[0]] == parent ? node->edgeList[0] - : arcs[node->edgeList[1]] == parent ? node->edgeList[1] - : node->edgeList[2]; + const int arcRef = arcs[node->edgeList[0]] == parent ? node->edgeList[0] + : arcs[node->edgeList[1]] == parent ? node->edgeList[1] + : node->edgeList[2]; t->arcRefs.emplace_back(-1, arcRef); } @@ -184,11 +185,11 @@ std::shared_ptr ContourTree::computeRootedTree_binary( if(edge != parent) { - std::shared_ptr child = nodes[edge->node1Idx] == node - ? nodes[edge->node2Idx] - : nodes[edge->node1Idx]; + const std::shared_ptr child + = nodes[edge->node1Idx] == node ? nodes[edge->node2Idx] + : nodes[edge->node1Idx]; - std::shared_ptr childTree + const std::shared_ptr childTree = computeRootedTree_binary(child, edge, id); children.push_back(childTree); @@ -265,9 +266,9 @@ void ContourTree::computeBranches() { } // find path to global max - int nextIdx = arcs[nodes[minIdx]->edgeList[0]]->node1Idx == minIdx - ? arcs[nodes[minIdx]->edgeList[0]]->node2Idx - : arcs[nodes[minIdx]->edgeList[0]]->node1Idx; + const int nextIdx = arcs[nodes[minIdx]->edgeList[0]]->node1Idx == minIdx + ? arcs[nodes[minIdx]->edgeList[0]]->node2Idx + : arcs[nodes[minIdx]->edgeList[0]]->node1Idx; std::vector maxPath_ = pathToMax(nextIdx, minIdx).second; std::vector maxPath; maxPath.push_back(minIdx); @@ -285,11 +286,11 @@ void ContourTree::computeBranches() { for(size_t i = 1; i < path.size() - 1; i++) { - int idx = path[i]; + const int idx = path[i]; - for(int cE : nodes[idx]->edgeList) { + for(const int cE : nodes[idx]->edgeList) { - int cIdx + const int cIdx = arcs[cE]->node1Idx == idx ? arcs[cE]->node2Idx : arcs[cE]->node1Idx; if(cIdx == path[i - 1]) continue; @@ -333,9 +334,9 @@ std::pair> ContourTree::pathToMax(int root, std::vector bestPath; float bestVal = -FLT_MAX; - for(int cE : nodes[root]->edgeList) { + for(const int cE : nodes[root]->edgeList) { - int nextIdx + const int nextIdx = arcs[cE]->node1Idx == root ? arcs[cE]->node2Idx : arcs[cE]->node1Idx; if(parent == nextIdx) continue; @@ -367,9 +368,9 @@ std::pair> ContourTree::pathToMin(int root, std::vector bestPath; float bestVal = FLT_MAX; - for(int cE : nodes[root]->edgeList) { + for(const int cE : nodes[root]->edgeList) { - int nextIdx + const int nextIdx = arcs[cE]->node1Idx == root ? arcs[cE]->node2Idx : arcs[cE]->node1Idx; if(parent == nextIdx) continue; diff --git a/core/base/contourTreeAlignment/ContourTreeAlignment.cpp b/core/base/contourTreeAlignment/ContourTreeAlignment.cpp index 7f361e4725..abfde3c8ed 100644 --- a/core/base/contourTreeAlignment/ContourTreeAlignment.cpp +++ b/core/base/contourTreeAlignment/ContourTreeAlignment.cpp @@ -16,7 +16,7 @@ void ttk::ContourTreeAlignment::computeBranches() { } // find path to global max - std::shared_ptr nextNode + const std::shared_ptr nextNode = minNode->edgeList[0]->node1.lock() == minNode ? minNode->edgeList[0]->node2.lock() : minNode->edgeList[0]->node1.lock(); @@ -38,11 +38,11 @@ void ttk::ContourTreeAlignment::computeBranches() { for(size_t i = 1; i < path.size() - 1; i++) { - std::shared_ptr currNode = path[i]; + const std::shared_ptr currNode = path[i]; for(const auto &cE : currNode->edgeList) { - std::shared_ptr cN + const std::shared_ptr cN = (cE->node1.lock()) == currNode ? cE->node2.lock() : cE->node1.lock(); if(cN == path[i - 1]) @@ -72,7 +72,7 @@ void ttk::ContourTreeAlignment::computeBranches() { for(const auto &cE : path.back()->edgeList) { - std::shared_ptr cN + const std::shared_ptr cN = cE->node1.lock() == path.back() ? cE->node2.lock() : cE->node1.lock(); if(cN == path[path.size() - 2]) continue; @@ -116,7 +116,7 @@ std::pair>> for(const auto &cE : root->edgeList) { - std::shared_ptr nextNode + const std::shared_ptr nextNode = cE->node1.lock() == root ? cE->node2.lock() : cE->node1.lock(); if(parent == nextNode) continue; @@ -152,7 +152,7 @@ std::pair>> for(const auto &cE : root->edgeList) { - std::shared_ptr nextNode + const std::shared_ptr nextNode = cE->node1.lock() == root ? cE->node2.lock() : cE->node1.lock(); if(parent == nextNode) continue; @@ -190,7 +190,7 @@ bool ttk::ContourTreeAlignment::initialize( // compute initial Alignment from initial contourtree - std::shared_ptr t = ct->rootAtMax(); + const std::shared_ptr t = ct->rootAtMax(); std::queue, std::shared_ptr>> @@ -209,7 +209,7 @@ bool ttk::ContourTreeAlignment::initialize( nodes.push_back(currNode); - q.push(std::make_pair(t, currNode)); + q.emplace(t, currNode); while(!q.empty()) { @@ -241,7 +241,7 @@ bool ttk::ContourTreeAlignment::initialize( nodes.push_back(childNode); arcs.push_back(childEdge); - q.push(std::make_pair(currTree->child1, childNode)); + q.emplace(currTree->child1, childNode); } if(currTree->child2 != nullptr) { @@ -268,7 +268,7 @@ bool ttk::ContourTreeAlignment::initialize( nodes.push_back(childNode); arcs.push_back(childEdge); - q.push(std::make_pair(currTree->child2, childNode)); + q.emplace(currTree->child2, childNode); } } @@ -286,7 +286,7 @@ bool ttk::ContourTreeAlignment::initialize_consistentRoot( // compute initial Alignment from initial contourtree - std::shared_ptr t = ct->rootAtMax(); + const std::shared_ptr t = ct->rootAtMax(); std::queue, std::shared_ptr>> @@ -305,7 +305,7 @@ bool ttk::ContourTreeAlignment::initialize_consistentRoot( nodes.push_back(currNode); - q.push(std::make_pair(t, currNode)); + q.emplace(t, currNode); while(!q.empty()) { @@ -341,7 +341,7 @@ bool ttk::ContourTreeAlignment::initialize_consistentRoot( nodes.push_back(childNode); arcs.push_back(childEdge); - q.push(std::make_pair(currTree->child1, childNode)); + q.emplace(currTree->child1, childNode); } if(currTree->child2 != nullptr) { @@ -372,7 +372,7 @@ bool ttk::ContourTreeAlignment::initialize_consistentRoot( nodes.push_back(childNode); arcs.push_back(childEdge); - q.push(std::make_pair(currTree->child2, childNode)); + q.emplace(currTree->child2, childNode); } } @@ -402,8 +402,9 @@ bool ttk::ContourTreeAlignment::alignTree( std::shared_ptr res = nullptr; float resVal = FLT_MAX; - std::vector> nodes1 = nodes; - std::vector> nodes2 = ct->getGraph().first; + const std::vector> nodes1 = nodes; + const std::vector> nodes2 + = ct->getGraph().first; for(const auto &node1 : nodes1) { @@ -419,7 +420,7 @@ bool ttk::ContourTreeAlignment::alignTree( || (node1->type == ttk::cta::minNode && node2->type == ttk::cta::minNode)) { - std::pair> match + const std::pair> match = getAlignmentBinary(t1, t2); if(match.first < resVal) { @@ -456,7 +457,8 @@ bool ttk::ContourTreeAlignment::alignTree_consistentRoot( std::shared_ptr res = nullptr; float resVal = FLT_MAX; - std::vector> nodes2 = ct->getGraph().first; + const std::vector> nodes2 + = ct->getGraph().first; t1 = this->rootAtNode(alignmentRoot); @@ -471,7 +473,7 @@ bool ttk::ContourTreeAlignment::alignTree_consistentRoot( t2 = ct->rootAtNode(node2); - std::pair> match + const std::pair> match = getAlignmentBinary(t1, t2); if(match.first < resVal) { @@ -558,7 +560,7 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( } values.push_back(res->node2->scalarValue); std::sort(values.begin(), values.end()); - float newMedian = values[values.size() / 2]; + const float newMedian = values[values.size() / 2]; currNode->scalarValue = newMedian; } } @@ -574,9 +576,9 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( nodes.push_back(currNode); - q.push(std::make_tuple( - res, currNode, std::vector>(), - std::vector>())); + q.emplace(res, currNode, + std::vector>(), + std::vector>()); while(!q.empty()) { @@ -642,7 +644,7 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( } values.push_back(res->node2->scalarValue); std::sort(values.begin(), values.end()); - float newMedian = values[values.size() / 2]; + const float newMedian = values[values.size() / 2]; childNode->scalarValue = newMedian; } } @@ -764,8 +766,7 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( nodes.push_back(childNode); arcs.push_back(childEdge); - q.push(std::make_tuple( - currTree->child1, childNode, openEdgesOld1, openEdgesNew1)); + q.emplace(currTree->child1, childNode, openEdgesOld1, openEdgesNew1); } if(currTree->child2 != nullptr) { @@ -820,7 +821,7 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( } values.push_back(res->node2->scalarValue); std::sort(values.begin(), values.end()); - float newMedian = values[values.size() / 2]; + const float newMedian = values[values.size() / 2]; childNode->scalarValue = newMedian; } } @@ -943,8 +944,7 @@ void ttk::ContourTreeAlignment::computeNewAlignmenttree( arcs.push_back(childEdge); // q.push(std::make_pair(currTree->child2,childNode)); - q.push(std::make_tuple( - currTree->child2, childNode, openEdgesOld2, openEdgesNew2)); + q.emplace(currTree->child2, childNode, openEdgesOld2, openEdgesNew2); } } } @@ -977,10 +977,10 @@ std::vector>, std::vector>, std::vector>>> - trees_simplified; + trees_simplified(contourtrees.size()); - for(const auto &ct : contourtrees) { - trees_simplified.push_back(ct->getGraph()); + for(int i = 0; i <= (int)contourtrees.size(); i++) { + trees_simplified[i] = contourtrees[i]->getGraph(); } return trees_simplified; @@ -1028,10 +1028,10 @@ std::pair> t1->size + 1, std::vector(t2->size + 1, -1)); // compute table of distances - float dist = alignTreeBinary(t1, t2, memT, memF); + const float dist = alignTreeBinary(t1, t2, memT, memF); // backtrace through the table to get the alignment - std::shared_ptr res + const std::shared_ptr res = traceAlignmentTree(t1, t2, memT, memF); return std::make_pair(dist, res); @@ -1212,8 +1212,8 @@ float ttk::ContourTreeAlignment::editCost( size_t j = 0; if(t1 && t2) { while(i < t1->region.size() && j < t2->region.size()) { - int vi = t1->region[i]; - int vj = t2->region[j]; + const int vi = t1->region[i]; + const int vj = t2->region[j]; if(vi == vj) { intersectionsize++; i++; @@ -1327,9 +1327,9 @@ std::shared_ptr + memT[id(t1->child1)] [t2->id] /* && t1->type != maxNode && t1->type != minNode */) { - std::shared_ptr resChild1 + const std::shared_ptr resChild1 = traceAlignmentTree(t1->child1, t2, memT, memF); - std::shared_ptr resChild2 + const std::shared_ptr resChild2 = traceNullAlignment(t1->child2, true); auto res = std::make_shared(); res->node1 = t1; @@ -1352,9 +1352,9 @@ std::shared_ptr + memT[id(t1->child2)] [t2->id] /* && t1->type != maxNode && t1->type != minNode */) { - std::shared_ptr resChild1 + const std::shared_ptr resChild1 = traceAlignmentTree(t1->child2, t2, memT, memF); - std::shared_ptr resChild2 + const std::shared_ptr resChild2 = traceNullAlignment(t1->child1, true); auto res = std::make_shared(); res->node1 = t1; @@ -1377,9 +1377,9 @@ std::shared_ptr + memT[t1->id][id( t2->child1)] /* && t2->type != maxNode && t2->type != minNode */) { - std::shared_ptr resChild1 + const std::shared_ptr resChild1 = traceAlignmentTree(t1, t2->child1, memT, memF); - std::shared_ptr resChild2 + const std::shared_ptr resChild2 = traceNullAlignment(t2->child2, false); auto res = std::make_shared(); res->node1 = nullptr; @@ -1402,9 +1402,9 @@ std::shared_ptr + memT[t1->id][id( t2->child2)] /* && t2->type != maxNode && t2->type != minNode */) { - std::shared_ptr resChild1 + const std::shared_ptr resChild1 = traceAlignmentTree(t1, t2->child2, memT, memF); - std::shared_ptr resChild2 + const std::shared_ptr resChild2 = traceNullAlignment(t2->child1, false); auto res = std::make_shared(); res->node1 = nullptr; @@ -1460,11 +1460,11 @@ std::vector> + memT[id(t1->child2)][id(t2->child2)]) { std::vector> res; - std::shared_ptr res1 + const std::shared_ptr res1 = traceAlignmentTree(t1->child1, t2->child1, memT, memF); if(res1 != nullptr) res.push_back(res1); - std::shared_ptr res2 + const std::shared_ptr res2 = traceAlignmentTree(t1->child2, t2->child2, memT, memF); if(res2 != nullptr) res.push_back(res2); @@ -1477,11 +1477,11 @@ std::vector> + memT[id(t1->child2)][id(t2->child1)]) { std::vector> res; - std::shared_ptr res1 + const std::shared_ptr res1 = traceAlignmentTree(t1->child1, t2->child2, memT, memF); if(res1 != nullptr) res.push_back(res1); - std::shared_ptr res2 + const std::shared_ptr res2 = traceAlignmentTree(t1->child2, t2->child1, memT, memF); if(res2 != nullptr) res.push_back(res2); @@ -1740,7 +1740,7 @@ std::shared_ptr if(edge != parent) { - std::shared_ptr child = computeRootedTree( + const std::shared_ptr child = computeRootedTree( edge->node1.lock() == node ? edge->node2.lock() : edge->node1.lock(), edge, id); children.push_back(child); @@ -1789,14 +1789,14 @@ std::shared_ptr std::vector> children; - std::shared_ptr node + const std::shared_ptr node = parent1 ? arc->node2.lock() : arc->node1.lock(); for(const auto &edge : node->edgeList) { if(edge != arc) { - std::shared_ptr child + const std::shared_ptr child = computeRootedDualTree(edge, edge->node1.lock() == node, id); children.push_back(child); t->size += child->size; diff --git a/core/base/contourTreeAlignment/ContourTreeAlignment.h b/core/base/contourTreeAlignment/ContourTreeAlignment.h index 1dd6c667ab..cdb76642e4 100644 --- a/core/base/contourTreeAlignment/ContourTreeAlignment.h +++ b/core/base/contourTreeAlignment/ContourTreeAlignment.h @@ -427,7 +427,7 @@ int ttk::ContourTreeAlignment::execute( Timer timer; - size_t nTrees = nVertices.size(); + const size_t nTrees = nVertices.size(); std::vector scalars(nTrees); for(size_t t = 0; t < nTrees; t++) { @@ -451,10 +451,10 @@ int ttk::ContourTreeAlignment::execute( tableLines.push_back( {"cellId", "vId0", "vId1", "scalar0", "scalar1", "region", "segId"}); for(size_t i = 0; i < nEdges[t]; i++) { - long long vertexId0 = topologies[t][i * 2 + 0]; - long long vertexId1 = topologies[t][i * 2 + 1]; - int regionSize = regionSizes[t][i]; - int segmentationId = segmentationIds[t][i]; + const long long vertexId0 = topologies[t][i * 2 + 0]; + const long long vertexId1 = topologies[t][i * 2 + 1]; + const int regionSize = regionSizes[t][i]; + const int segmentationId = segmentationIds[t][i]; scalarType scalarOfVertexId0 = scalars[t][vertexId0]; scalarType scalarOfVertexId1 = scalars[t][vertexId1]; @@ -662,9 +662,9 @@ int ttk::ContourTreeAlignment::execute( outputBranchIds.push_back(node->branchID); std::vector refs(nTrees, -1); std::vector segRefs(nTrees, -1); - for(std::pair ref : node->nodeRefs) { + for(auto ref : node->nodeRefs) { refs[permutation[ref.first]] = ref.second; - int eId + const int eId = contourtrees[ref.first]->getGraph().first[ref.second]->edgeList[0]; segRefs[permutation[ref.first]] = contourtrees[ref.first]->getGraph().second[eId]->segId; @@ -694,7 +694,7 @@ int ttk::ContourTreeAlignment::execute( } std::vector arcRefs(nTrees, -1); - for(std::pair ref : edge->arcRefs) { + for(auto ref : edge->arcRefs) { arcRefs[permutation[ref.first]] = ref.second; } for(int ref : arcRefs) { diff --git a/core/base/depthImageBasedGeometryApproximation/DepthImageBasedGeometryApproximation.h b/core/base/depthImageBasedGeometryApproximation/DepthImageBasedGeometryApproximation.h index cf88a70eab..2c881db4e7 100644 --- a/core/base/depthImageBasedGeometryApproximation/DepthImageBasedGeometryApproximation.h +++ b/core/base/depthImageBasedGeometryApproximation/DepthImageBasedGeometryApproximation.h @@ -226,15 +226,15 @@ int ttk::DepthImageBasedGeometryApproximation::execute( #pragma omp parallel for num_threads(this->threadNumber_) #endif for(size_t y = 0; y < yl; y++) { - size_t yOffset = y * resolutionST[0]; + size_t const yOffset = y * resolutionST[0]; size_t triangleIndexOffset = y * trianglesPerRow * 3; size_t triangleDistortionOffset = y * trianglesPerRow; for(size_t x = 0; x < xl; x++) { - size_t i0 = x + yOffset; - size_t i1 = i0 + 1; - size_t i2 = i0 + resolutionST[0]; - size_t i3 = i2 + 1; + size_t const i0 = x + yOffset; + size_t const i1 = i0 + 1; + size_t const i2 = i0 + resolutionST[0]; + size_t const i3 = i2 + 1; connectivityList[triangleIndexOffset++] = i0; connectivityList[triangleIndexOffset++] = i2; diff --git a/core/base/dijkstra/Dijkstra.h b/core/base/dijkstra/Dijkstra.h index dd88f08248..847d88090f 100644 --- a/core/base/dijkstra/Dijkstra.h +++ b/core/base/dijkstra/Dijkstra.h @@ -31,11 +31,11 @@ namespace ttk { const std::vector &mask = std::vector()) { // should we process the whole mesh or stop at some point? - bool processAllVertices = bounds.empty(); + bool const processAllVertices = bounds.empty(); // total number of vertices in the mesh - size_t vertexNumber = triangulation.getNumberOfVertices(); + size_t const vertexNumber = triangulation.getNumberOfVertices(); // is there a mask? - bool isMask = !mask.empty(); + bool const isMask = !mask.empty(); // check mask size if(isMask && mask.size() != vertexNumber) { diff --git a/core/base/discreteGradient/DiscreteGradient_Template.h b/core/base/discreteGradient/DiscreteGradient_Template.h index b6a2584f32..76dc862718 100644 --- a/core/base/discreteGradient/DiscreteGradient_Template.h +++ b/core/base/discreteGradient/DiscreteGradient_Template.h @@ -240,7 +240,8 @@ inline void } // a belongs to its lower star - ls[0].emplace_back(CellExt{0, a}); + CellExt const localCellExt{0, a}; + ls[0].emplace_back(localCellExt); // store lower edges const auto nedges = triangulation.getVertexEdgeNumber(a); @@ -291,7 +292,8 @@ inline void } j++; } - ls[2].emplace_back(CellExt{2, triangleId, lowVerts, faces}); + CellExt const localCellExt2{2, triangleId, lowVerts, faces}; + ls[2].emplace_back(localCellExt2); } }; @@ -379,7 +381,8 @@ inline void j++; } - ls[3].emplace_back(CellExt{3, cellId, lowVerts, faces}); + CellExt const localCellExt3{3, cellId, lowVerts, faces}; + ls[3].emplace_back(localCellExt3); } } } diff --git a/core/base/discreteMorseSandwich/DiscreteMorseSandwich.h b/core/base/discreteMorseSandwich/DiscreteMorseSandwich.h index 96290b4697..14d7bd0c35 100644 --- a/core/base/discreteMorseSandwich/DiscreteMorseSandwich.h +++ b/core/base/discreteMorseSandwich/DiscreteMorseSandwich.h @@ -509,7 +509,7 @@ std::vector> const auto followVPath = [this, &mins, &triangulation](const SimplexId v) { std::vector vpath{}; this->dg_.getDescendingPath(Cell{0, v}, vpath, triangulation); - Cell &lastCell = vpath.back(); + const Cell &lastCell = vpath.back(); if(lastCell.dim_ == 0 && this->dg_.isCellCritical(lastCell)) { mins.emplace_back(lastCell.id_); } @@ -558,7 +558,7 @@ std::vector> = [this, dim, &maxs, &triangulation](const SimplexId v) { std::vector vpath{}; this->dg_.getAscendingPath(Cell{dim, v}, vpath, triangulation); - Cell &lastCell = vpath.back(); + const Cell &lastCell = vpath.back(); if(lastCell.dim_ == dim && this->dg_.isCellCritical(lastCell)) { maxs.emplace_back(lastCell.id_); } else if(lastCell.dim_ == dim - 1) { @@ -905,8 +905,6 @@ void ttk::DiscreteMorseSandwich::getSaddleSaddlePairs( } } - Timer tmpar{}; - if(this->Compute2SaddlesChildren) { this->s2Children_.resize(saddles2.size()); } @@ -1258,7 +1256,7 @@ int ttk::DiscreteMorseSandwich::computePersistencePairs( nBoundComp = std::max(nBoundComp, 0); // print Betti numbers - std::vector> rows{ + const std::vector> rows{ {" #Connected components", std::to_string(nConnComp)}, {" #Topological handles", std::to_string(nHandles)}, {" #Cavities", std::to_string(nCavities)}, diff --git a/core/base/distanceField/DistanceField.h b/core/base/distanceField/DistanceField.h index fb11d69874..9782b5cad5 100644 --- a/core/base/distanceField/DistanceField.h +++ b/core/base/distanceField/DistanceField.h @@ -89,8 +89,6 @@ int ttk::DistanceField::execute(const triangulationType *triangulation_) const { SimplexId *origin = static_cast(outputIdentifiers_); SimplexId *seg = static_cast(outputSegmentation_); - Timer t; - std::fill(dist, dist + vertexNumber_, std::numeric_limits::max()); std::fill(origin, origin + vertexNumber_, -1); @@ -110,7 +108,7 @@ int ttk::DistanceField::execute(const triangulationType *triangulation_) const { #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < sources.size(); ++i) { - int ret = Dijkstra::shortestPath( + int const ret = Dijkstra::shortestPath( sources[i], *triangulation_, scalars[i]); if(ret != 0) { this->printErr( diff --git a/core/base/distanceMatrixDistortion/DistanceMatrixDistortion.cpp b/core/base/distanceMatrixDistortion/DistanceMatrixDistortion.cpp index ac891a2b97..7466c948e3 100644 --- a/core/base/distanceMatrixDistortion/DistanceMatrixDistortion.cpp +++ b/core/base/distanceMatrixDistortion/DistanceMatrixDistortion.cpp @@ -47,7 +47,7 @@ int ttk::DistanceMatrixDistortion::execute( #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < n; i++) { for(size_t j = i + 1; j < n; j++) { - double diff = lowDistMatrix[i][j] - highDistMatrix[i][j]; + const double diff = lowDistMatrix[i][j] - highDistMatrix[i][j]; maxi = std::max(maxi, diff * diff); } } @@ -67,11 +67,11 @@ int ttk::DistanceMatrixDistortion::execute( for(size_t i = 0; i < n; i++) { double sum = 0; for(size_t j = 0; j < n; j++) { - double diff = lowDistMatrix[i][j] - highDistMatrix[i][j]; - double diff2 = diff * diff; + const double diff = lowDistMatrix[i][j] - highDistMatrix[i][j]; + const double diff2 = diff * diff; sum += diff2; } - double sumHarmonized = sum / maxi; + const double sumHarmonized = sum / maxi; distorsionVerticesValues[i] = 1 - sumHarmonized / n; totalSum += 1 - sumHarmonized / n; } diff --git a/core/base/eigenField/EigenField.cpp b/core/base/eigenField/EigenField.cpp index b2dca24e36..07e6d6c9cb 100644 --- a/core/base/eigenField/EigenField.cpp +++ b/core/base/eigenField/EigenField.cpp @@ -60,7 +60,7 @@ int ttk::EigenField::execute(const TriangulationType &triangulation, solver.init(); // number of eigenpairs correctly computed - int nconv = solver.compute(Spectra::SortRule::LargestAlge); + int const nconv = solver.compute(Spectra::SortRule::LargestAlge); switch(solver.info()) { case Spectra::CompInfo::NumericalIssue: diff --git a/core/base/fiberSurface/FiberSurface.cpp b/core/base/fiberSurface/FiberSurface.cpp index 566bd17ba3..8b15fac574 100644 --- a/core/base/fiberSurface/FiberSurface.cpp +++ b/core/base/fiberSurface/FiberSurface.cpp @@ -198,7 +198,7 @@ int FiberSurface::computeTriangleIntersection( std::vector> &tetIntersections, std::vector> &tetNewVertices) const { - SimplexId commonVertexNumber = getNumberOfCommonVertices( + SimplexId const commonVertexNumber = getNumberOfCommonVertices( tetId, triangleId0, triangleId1, tetIntersections); // make sure the two triangles are not already adjacent @@ -413,7 +413,7 @@ int FiberSurface::computeTriangleIntersection( return -4; // 3. create the two new vertices A and B - SimplexId vertexIdA = newVertexNumber; + SimplexId const vertexIdA = newVertexNumber; newVertexNumber++; tetNewVertices[tetId].resize(tetNewVertices[tetId].size() + 1); for(int i = 0; i < 3; i++) @@ -433,7 +433,7 @@ int FiberSurface::computeTriangleIntersection( + baryA[2] * tetIntersections[tetId][triangleId].t_[2]; tetNewVertices[tetId].back().isIntersectionPoint_ = true; - SimplexId vertexIdB = newVertexNumber; + SimplexId const vertexIdB = newVertexNumber; newVertexNumber++; tetNewVertices[tetId].resize(tetNewVertices[tetId].size() + 1); for(int i = 0; i < 3; i++) @@ -464,7 +464,7 @@ int FiberSurface::computeTriangleIntersection( // special case where a, b and p+2 are actually aligned // we should detect a colinear triangle and test the opposite diagonal instead // a, b, (pivotVertexId+1)%3 - SimplexId ret = createNewIntersectionTriangle( + SimplexId const ret = createNewIntersectionTriangle( tetId, triangleId, -vertexIdA, -vertexIdB, (pivotVertexId + 2) % 3, tetNewVertices, newTriangleNumber, tetIntersections, &intersection); if(ret == -1) { @@ -609,14 +609,14 @@ int FiberSurface::flipEdges() const { for(SimplexId j = 0; j < (SimplexId)polygonEdgeTriangleLists_[i]->size(); j++) { - SimplexId tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; + SimplexId const tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; if(!inQueue[tetId]) { inQueue[tetId] = true; tetList.push_back(tetId); } - tetTriangles[tetId].push_back(pair(i, j)); + tetTriangles[tetId].emplace_back(i, j); } } @@ -625,7 +625,7 @@ int FiberSurface::flipEdges() const { #endif for(SimplexId i = 0; i < (SimplexId)tetList.size(); i++) { - SimplexId tetId = tetList[i]; + SimplexId const tetId = tetList[i]; if(tetTriangles[tetId].size() >= 2) { @@ -741,7 +741,7 @@ int FiberSurface::flipEdges( SimplexId otherNonCommonVertexId = -1; for(int k = 0; k < 3; k++) { - SimplexId vertexId + SimplexId const vertexId = (*polygonEdgeTriangleLists_[triangles[j].first])[triangles[j] .second] .vertexIds_[k]; @@ -1014,7 +1014,7 @@ bool FiberSurface::isEdgeAngleCollapsible( || (starNeighbors[i].second == source) || (starNeighbors[i].second == destination)) { - double localAngle = Geometry::angle( + double const localAngle = Geometry::angle( (*globalVertexList_)[starNeighbors[i].first].p_.data(), (*globalVertexList_)[pivotVertexId].p_.data(), (*globalVertexList_)[pivotVertexId].p_.data(), @@ -1073,7 +1073,7 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { // this is the case when the tetId of the two triangles is the same. // THAT is not OK - SimplexId initVertexNumber = (*globalVertexList_).size(); + SimplexId const initVertexNumber = (*globalVertexList_).size(); for(SimplexId it = 0; it < (SimplexId)(*globalVertexList_).size(); it++) { // avoid infinite loops @@ -1090,7 +1090,8 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { j++) { for(int k = 0; k < 3; k++) { - SimplexId vertexId = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[k]; + SimplexId const vertexId + = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[k]; vertexTriangleNeighbors[vertexId].resize( vertexTriangleNeighbors[vertexId].size() + 1); @@ -1101,7 +1102,7 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { for(int l = 0; l < 3; l++) { if(l != k) { - SimplexId otherVertexId + SimplexId const otherVertexId = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[l]; if(vertexTriangleNeighbors[vertexId].back().first == -1) { @@ -1143,9 +1144,9 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { // find the smallest edge on this triangle for(int k = 0; k < 3; k++) { - SimplexId vertexId0 + SimplexId const vertexId0 = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[k]; - SimplexId vertexId1 + SimplexId const vertexId1 = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[(k + 1) % 3]; bool areAlreadySnapped = true; @@ -1164,7 +1165,7 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { } if(!areAlreadySnapped) { - double distance + double const distance = Geometry::distance((*globalVertexList_)[vertexId0].p_.data(), (*globalVertexList_)[vertexId1].p_.data()); @@ -1176,10 +1177,10 @@ int FiberSurface::mergeEdges(const double &distanceThreshold) const { } if((minDistance != -1) && (minDistance < distanceThreshold)) { - SimplexId vertexId0 + SimplexId const vertexId0 = (*polygonEdgeTriangleLists_[i])[j].vertexIds_[minimizer]; - SimplexId vertexId1 = (*polygonEdgeTriangleLists_[i])[j] - .vertexIds_[(minimizer + 1) % 3]; + SimplexId const vertexId1 = (*polygonEdgeTriangleLists_[i])[j] + .vertexIds_[(minimizer + 1) % 3]; // find the number of common neighbors vector commonNeighbors; @@ -1558,7 +1559,8 @@ int FiberSurface::snapToBasePoint(const vector> &basePoints, double minDistance = -1; for(SimplexId i = 0; i < (SimplexId)basePoints.size(); i++) { - double distance = Geometry::distance(basePoints[i].data(), v.p_.data()); + double const distance + = Geometry::distance(basePoints[i].data(), v.p_.data()); if((minDistance < 0) || (distance < minDistance)) { minDistance = distance; minimizer = i; @@ -1588,14 +1590,14 @@ int FiberSurface::snapVertexBarycentrics() const { for(SimplexId j = 0; j < (SimplexId)polygonEdgeTriangleLists_[i]->size(); j++) { - SimplexId tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; + SimplexId const tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; if(!inQueue[tetId]) { inQueue[tetId] = true; tetList.push_back(tetId); } - tetTriangles[tetId].push_back(pair(i, j)); + tetTriangles[tetId].emplace_back(i, j); } } @@ -1621,7 +1623,7 @@ int FiberSurface::snapVertexBarycentrics( (*polygonEdgeTriangleLists_[triangles[i].first])[triangles[i].second]); for(int j = 0; j < 3; j++) { - SimplexId vertexId = t->vertexIds_[j]; + SimplexId const vertexId = t->vertexIds_[j]; // check for each triangle of the tet double minimum = -DBL_MAX; @@ -1632,9 +1634,9 @@ int FiberSurface::snapVertexBarycentrics( for(int l = k + 1; l < 3; l++) { for(int m = l + 1; m < 4; m++) { - SimplexId vertexId0 = tetList_[5 * tetId + 1 + k]; - SimplexId vertexId1 = tetList_[5 * tetId + 1 + l]; - SimplexId vertexId2 = tetList_[5 * tetId + 1 + m]; + SimplexId const vertexId0 = tetList_[5 * tetId + 1 + k]; + SimplexId const vertexId1 = tetList_[5 * tetId + 1 + l]; + SimplexId const vertexId2 = tetList_[5 * tetId + 1 + m]; std::array p0{}, p1{}, p2{}; diff --git a/core/base/fiberSurface/FiberSurface.h b/core/base/fiberSurface/FiberSurface.h index 1fdfc25bd8..a292602d83 100644 --- a/core/base/fiberSurface/FiberSurface.h +++ b/core/base/fiberSurface/FiberSurface.h @@ -671,7 +671,7 @@ inline int ttk::FiberSurface::computeCase0( const triangulationType *const triangulation) const { // that one's easy, make just one triangle - SimplexId vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); + SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); // alloc 1 more triangle (*polygonEdgeTriangleLists_[polygonEdgeId]) @@ -815,7 +815,7 @@ inline int ttk::FiberSurface::computeCase1( const double &v2, const triangulationType *const triangulation) const { - SimplexId vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); + SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); // alloc 5 more vertices (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 5); @@ -828,7 +828,8 @@ inline int ttk::FiberSurface::computeCase1( } // alloc 3 more triangles - SimplexId triangleId = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); + SimplexId const triangleId + = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 3); for(int i = 0; i < 3; i++) { @@ -1004,7 +1005,7 @@ inline int ttk::FiberSurface::computeCase2( const double &v2, const triangulationType *const triangulation) const { - SimplexId vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); + SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); // alloc 4 more vertices (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 4); @@ -1017,7 +1018,8 @@ inline int ttk::FiberSurface::computeCase2( } // alloc 2 more triangles - SimplexId triangleId = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); + SimplexId const triangleId + = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 2); for(int i = 0; i < 2; i++) { @@ -1177,7 +1179,7 @@ inline int ttk::FiberSurface::computeCase3( const double &v2, const triangulationType *const triangulation) const { - SimplexId vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); + SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); // alloc 3 more vertices (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 3); @@ -1190,7 +1192,8 @@ inline int ttk::FiberSurface::computeCase3( } // alloc 1 more triangle - SimplexId triangleId = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); + SimplexId const triangleId + = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 1); (*polygonEdgeTriangleLists_[polygonEdgeId])[triangleId].tetId_ = tetId; @@ -1317,7 +1320,7 @@ inline int ttk::FiberSurface::computeCase4( const double &v2, const triangulationType *const triangulation) const { - SimplexId vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); + SimplexId const vertexId = (*polygonEdgeVertexLists_[polygonEdgeId]).size(); // alloc 4 more vertices (*polygonEdgeVertexLists_[polygonEdgeId]).resize(vertexId + 4); @@ -1330,7 +1333,8 @@ inline int ttk::FiberSurface::computeCase4( } // alloc 2 more triangles - SimplexId triangleId = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); + SimplexId const triangleId + = (*polygonEdgeTriangleLists_[polygonEdgeId]).size(); (*polygonEdgeTriangleLists_[polygonEdgeId]).resize(triangleId + 2); for(int i = 0; i < 2; i++) { @@ -1502,7 +1506,7 @@ inline int ttk::FiberSurface::computeContour( do { - SimplexId tetId = tetQueue.front(); + SimplexId const tetId = tetQueue.front(); tetQueue.pop(); if(!visitedTets[tetId]) { @@ -1512,7 +1516,7 @@ inline int ttk::FiberSurface::computeContour( if(createdVertices) { // only propagate if we created a triangle - SimplexId tetNeighborNumber + SimplexId const tetNeighborNumber = triangulation->getCellNeighborNumber(tetId); for(SimplexId i = 0; i < tetNeighborNumber; i++) { @@ -2189,7 +2193,7 @@ inline int ttk::FiberSurface::processTetrahedron( for(SimplexId k = 0; k < (SimplexId)colinearVertices.size(); k++) { if(j != k) { - double distance = Geometry::distance( + double const distance = Geometry::distance( (*polygonEdgeVertexLists_[polygonEdgeId]) [createdVertexList[colinearVertices[j]]] .p_.data(), @@ -2371,7 +2375,7 @@ inline int ttk::FiberSurface::remeshIntersections() const { for(SimplexId j = 0; j < (SimplexId)polygonEdgeTriangleLists_[i]->size(); j++) { - SimplexId tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; + SimplexId const tetId = (*polygonEdgeTriangleLists_[i])[j].tetId_; tetIntersections[tetId].emplace_back(); @@ -2409,7 +2413,7 @@ inline int ttk::FiberSurface::remeshIntersections() const { #pragma omp parallel for num_threads(threadNumber_) #endif for(SimplexId i = 0; i < (SimplexId)tetList.size(); i++) { - SimplexId tetId = tetList[i]; + SimplexId const tetId = tetList[i]; // pre-process by merging nearby vertices...? @@ -2428,13 +2432,15 @@ inline int ttk::FiberSurface::remeshIntersections() const { // if we re-mesh, we add new triangles at the end of the list. // there's no need to check intersections with those. - SimplexId originalTriangleNumber + SimplexId const originalTriangleNumber = (SimplexId)tetIntersections[tetId].size(); for(SimplexId k = 0; k < originalTriangleNumber; k++) { - SimplexId polygonEdgeId0 = tetIntersections[tetId][j].polygonEdgeId_; - SimplexId polygonEdgeId1 = tetIntersections[tetId][k].polygonEdgeId_; + SimplexId const polygonEdgeId0 + = tetIntersections[tetId][j].polygonEdgeId_; + SimplexId const polygonEdgeId1 + = tetIntersections[tetId][k].polygonEdgeId_; if((j != k) && (polygonEdgeId0 != polygonEdgeId1)) { // cases 3, 4 and 6 of the fiber surface table (multiple triangle @@ -2454,7 +2460,7 @@ inline int ttk::FiberSurface::remeshIntersections() const { // compute the intersection std::pair intersection; - bool hasIntersection = Geometry::computeSegmentIntersection( + bool const hasIntersection = Geometry::computeSegmentIntersection( edge0point0.first, edge0point0.second, edge0point1.first, edge0point1.second, edge1point0.first, edge1point0.second, edge1point1.first, edge1point1.second, intersection.first, @@ -2486,7 +2492,7 @@ inline int ttk::FiberSurface::remeshIntersections() const { for(SimplexId i = 0; i < (SimplexId)tetNewVertices.size(); i++) { for(SimplexId j = 0; j < (SimplexId)tetNewVertices[i].size(); j++) { - SimplexId localId = (*globalVertexList_).size(); + SimplexId const localId = (*globalVertexList_).size(); tetNewVertices[i][j].localId_ = localId; (*globalVertexList_).push_back(tetNewVertices[i][j]); } diff --git a/core/base/ftmTree/FTMAtomicVector.h b/core/base/ftmTree/FTMAtomicVector.h index da47acfe3d..80477a73a3 100644 --- a/core/base/ftmTree/FTMAtomicVector.h +++ b/core/base/ftmTree/FTMAtomicVector.h @@ -91,7 +91,7 @@ namespace ttk { reset(); // Remove old content - std::size_t oldSize = std::vector::size(); + std::size_t const oldSize = std::vector::size(); std::vector::clear(); reserve(oldSize); } diff --git a/core/base/ftmTree/FTMNode.h b/core/base/ftmTree/FTMNode.h index 88b26fb1af..a15b07243f 100644 --- a/core/base/ftmTree/FTMNode.h +++ b/core/base/ftmTree/FTMNode.h @@ -125,13 +125,13 @@ namespace ttk { } inline idSuperArc clearDownSuperArcs() { - idSuperArc s = vect_downSuperArcList_.size(); + idSuperArc const s = vect_downSuperArcList_.size(); vect_downSuperArcList_.clear(); return s; } inline idSuperArc clearUpSuperArcs() { - idSuperArc s = vect_upSuperArcList_.size(); + idSuperArc const s = vect_upSuperArcList_.size(); vect_upSuperArcList_.clear(); return s; } diff --git a/core/base/ftmTree/FTMSegmentation.cpp b/core/base/ftmTree/FTMSegmentation.cpp index 886276dcb0..9092b3d97e 100644 --- a/core/base/ftmTree/FTMSegmentation.cpp +++ b/core/base/ftmTree/FTMSegmentation.cpp @@ -122,7 +122,7 @@ void Segments::resize(const vector &sizes) { #endif segments_.reserve(sizes.size()); - for(SimplexId size : sizes) { + for(SimplexId const size : sizes) { segments_.emplace_back(size); } } diff --git a/core/base/ftmTree/FTMStructures.h b/core/base/ftmTree/FTMStructures.h index dbbbd25541..655a02c6ad 100644 --- a/core/base/ftmTree/FTMStructures.h +++ b/core/base/ftmTree/FTMStructures.h @@ -123,7 +123,7 @@ namespace ttk { } void addArc(const idSuperArc arc) { - idSuperArc thisArc = openedArcs.getNext(); + idSuperArc const thisArc = openedArcs.getNext(); openedArcs[thisArc] = arc; } diff --git a/core/base/ftmTree/FTMTreeUtils.cpp b/core/base/ftmTree/FTMTreeUtils.cpp index 6ae49cdc6a..eaf361da94 100644 --- a/core/base/ftmTree/FTMTreeUtils.cpp +++ b/core/base/ftmTree/FTMTreeUtils.cpp @@ -14,7 +14,8 @@ namespace ttk { // Is // -------------------- bool FTMTree_MT::isNodeOriginDefined(idNode nodeId) { - unsigned int origin = (unsigned int)this->getNode(nodeId)->getOrigin(); + unsigned int const origin + = (unsigned int)this->getNode(nodeId)->getOrigin(); return origin != nullNodes && origin < this->getNumberOfNodes(); } @@ -31,7 +32,7 @@ namespace ttk { } bool FTMTree_MT::isFullMerge() { - idNode treeRoot = this->getRoot(); + idNode const treeRoot = this->getRoot(); return (unsigned int)this->getNode(treeRoot)->getOrigin() == treeRoot; } @@ -53,7 +54,7 @@ namespace ttk { } bool FTMTree_MT::isThereOnlyOnePersistencePair() { - idNode treeRoot = this->getRoot(); + idNode const treeRoot = this->getRoot(); unsigned int cptNodeAlone = 0; idNode otherNode = treeRoot; for(unsigned int i = 0; i < this->getNumberOfNodes(); ++i) @@ -63,7 +64,7 @@ namespace ttk { otherNode = i; // unsigned int origin = (unsigned // int)tree->getNode(otherNode)->getOrigin(); - idNode treeRootOrigin = this->getNode(treeRoot)->getOrigin(); + idNode const treeRootOrigin = this->getNode(treeRoot)->getOrigin(); return (otherNode != treeRoot and this->getNumberOfNodes() - cptNodeAlone == 2 and (treeRootOrigin == otherNode or treeRootOrigin == treeRoot)); @@ -103,8 +104,8 @@ namespace ttk { idNode FTMTree_MT::getParentSafe(idNode nodeId) { if(!this->isRoot(nodeId)) { // _ Nodes in merge trees should have only one parent - idSuperArc arcId = this->getNode(nodeId)->getUpSuperArcId(0); - idNode parentNodeId = this->getSuperArc(arcId)->getUpNodeId(); + idSuperArc const arcId = this->getNode(nodeId)->getUpSuperArcId(0); + idNode const parentNodeId = this->getSuperArc(arcId)->getUpNodeId(); return parentNodeId; } return nodeId; @@ -115,7 +116,7 @@ namespace ttk { childrens.clear(); for(idSuperArc i = 0; i < this->getNode(nodeId)->getNumberOfDownSuperArcs(); ++i) { - idSuperArc arcId = this->getNode(nodeId)->getDownSuperArcId(i); + idSuperArc const arcId = this->getNode(nodeId)->getDownSuperArcId(i); childrens.push_back(this->getSuperArc(arcId)->getDownNodeId()); } } @@ -148,7 +149,7 @@ namespace ttk { idNode node, std::tuple, std::vector> &res) { std::vector branchOrigins, nonBranchOrigins; - idNode nodeOrigin = this->getNode(node)->getOrigin(); + idNode const nodeOrigin = this->getNode(node)->getOrigin(); idNode nodeParent = this->getParentSafe(nodeOrigin); while(nodeParent != node) { if(this->isBranchOrigin(nodeParent)) @@ -173,7 +174,7 @@ namespace ttk { std::queue queue; queue.emplace(this->getRoot()); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); if(this->isLeaf(node)) continue; @@ -192,7 +193,7 @@ namespace ttk { ++branchID; std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.emplace(child); } } @@ -225,17 +226,17 @@ namespace ttk { int FTMTree_MT::getTreeDepth() { int maxDepth = 0; std::queue> queue; - queue.push(std::make_tuple(this->getRoot(), 0)); + queue.emplace(this->getRoot(), 0); while(!queue.empty()) { auto tup = queue.front(); queue.pop(); - idNode node = std::get<0>(tup); - int depth = std::get<1>(tup); + idNode const node = std::get<0>(tup); + int const depth = std::get<1>(tup); maxDepth = std::max(maxDepth, depth); std::vector children; this->getChildren(node, children); - for(idNode child : children) - queue.push(std::make_tuple(child, depth + 1)); + for(idNode const child : children) + queue.emplace(child, depth + 1); } return maxDepth; } @@ -243,7 +244,7 @@ namespace ttk { int FTMTree_MT::getNodeLevel(idNode nodeId) { int level = 0; auto root = this->getRoot(); - int noRoot = this->getNumberOfRoot(); + int const noRoot = this->getNumberOfRoot(); if(noRoot != 1) { std::stringstream ss; ss << "problem, there is " << noRoot << " root(s)"; @@ -263,17 +264,17 @@ namespace ttk { void FTMTree_MT::getAllNodeLevel(std::vector &allNodeLevel) { allNodeLevel = std::vector(this->getNumberOfNodes()); std::queue> queue; - queue.push(std::make_tuple(this->getRoot(), 0)); + queue.emplace(this->getRoot(), 0); while(!queue.empty()) { auto tup = queue.front(); queue.pop(); - idNode node = std::get<0>(tup); - int level = std::get<1>(tup); + idNode const node = std::get<0>(tup); + int const level = std::get<1>(tup); allNodeLevel[node] = level; std::vector children; this->getChildren(node, children); - for(idNode child : children) - queue.push(std::make_tuple(child, level + 1)); + for(idNode const child : children) + queue.emplace(child, level + 1); } } @@ -281,7 +282,8 @@ namespace ttk { std::vector> &levelToNode) { std::vector allNodeLevel; this->getAllNodeLevel(allNodeLevel); - int maxLevel = *max_element(allNodeLevel.begin(), allNodeLevel.end()); + int const maxLevel + = *max_element(allNodeLevel.begin(), allNodeLevel.end()); levelToNode = std::vector>(maxLevel + 1); for(unsigned int i = 0; i < allNodeLevel.size(); ++i) { levelToNode[allNodeLevel[i]].push_back(i); @@ -295,7 +297,7 @@ namespace ttk { std::queue queue; queue.push(branchRoot); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); if(branching[node] != branchRoot @@ -305,7 +307,7 @@ namespace ttk { branchSubtree.push_back(node); std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.push(child); } } @@ -341,18 +343,18 @@ namespace ttk { if(this->isRoot(nodeId) and !this->isLeaf(nodeId)) printErr("deletion of root!"); - idNode parentNodeId = this->getParentSafe(nodeId); + idNode const parentNodeId = this->getParentSafe(nodeId); if(!this->isRoot(nodeId)) { // Delete down arc from parent node // _ Nodes in trees should have only one parent - idSuperArc nodeArcId = this->getNode(nodeId)->getUpSuperArcId(0); + idSuperArc const nodeArcId = this->getNode(nodeId)->getUpSuperArcId(0); this->getNode(parentNodeId)->removeDownSuperArc(nodeArcId); } // Delete up arc from child nodes for(idSuperArc i = 0; i < this->getNode(nodeId)->getNumberOfDownSuperArcs(); ++i) { - idSuperArc arcId = this->getNode(nodeId)->getDownSuperArcId(i); - idNode childNodeId = this->getSuperArc(arcId)->getDownNodeId(); + idSuperArc const arcId = this->getNode(nodeId)->getDownSuperArcId(i); + idNode const childNodeId = this->getSuperArc(arcId)->getDownNodeId(); this->getNode(childNodeId)->removeUpSuperArc(arcId); if(!this->isRoot(nodeId)) this->makeSuperArc(childNodeId, parentNodeId); @@ -363,9 +365,10 @@ namespace ttk { } void FTMTree_MT::deleteIthUpArc(idNode nodeId, int arcIth) { - idSuperArc nodeArcId = this->getNode(nodeId)->getUpSuperArcId(arcIth); + idSuperArc const nodeArcId + = this->getNode(nodeId)->getUpSuperArcId(arcIth); // Delete down arc from old parent - idNode parentNodeId = this->getSuperArc(nodeArcId)->getUpNodeId(); + idNode const parentNodeId = this->getSuperArc(nodeArcId)->getUpNodeId(); this->getNode(parentNodeId)->removeDownSuperArc(nodeArcId); // Delete up arc from node this->getNode(nodeId)->removeUpSuperArc(nodeArcId); @@ -382,11 +385,11 @@ namespace ttk { std::queue queue; queue.push(nodeId); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.push(child); this->deleteNode(node); } @@ -420,7 +423,7 @@ namespace ttk { std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) ss << "+" << child << " "; if(!this->isRoot(node)) @@ -441,14 +444,14 @@ namespace ttk { std::queue queue; queue.push(allRoots[i]); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); printNodeSS(node, ss); std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.push(child); } } @@ -515,14 +518,15 @@ namespace ttk { for(long unsigned int j = 0; j < tree->getNode(i)->getNumberOfUpSuperArcs(); ++j) { - ftm::idSuperArc nodeArcId = tree->getNode(i)->getUpSuperArcId(j); + ftm::idSuperArc const nodeArcId + = tree->getNode(i)->getUpSuperArcId(j); auto tParent = tree->getSuperArc(nodeArcId)->getUpNodeId(); if(tParent != lowestParent) { if(tParent == treeRoot) { for(long unsigned int k = 0; k < tree->getNode(i)->getNumberOfDownSuperArcs(); ++k) { - ftm::idSuperArc nodeArcId2 + ftm::idSuperArc const nodeArcId2 = tree->getNode(i)->getDownSuperArcId(k); auto tChildren = tree->getSuperArc(nodeArcId2)->getDownNodeId(); @@ -548,7 +552,8 @@ namespace ttk { for(unsigned int i = 0; i < tree->getNumberOfNodes(); ++i) { for(unsigned int j = 0; j < tree->getNode(i)->getNumberOfUpSuperArcs(); ++j) { - ftm::idSuperArc nodeArcId = tree->getNode(i)->getUpSuperArcId(j); + ftm::idSuperArc const nodeArcId + = tree->getNode(i)->getUpSuperArcId(j); auto tParent = tree->getSuperArc(nodeArcId)->getUpNodeId(); if(tParent == i) { // Delete down arc diff --git a/core/base/ftmTree/FTMTreeUtils.h b/core/base/ftmTree/FTMTreeUtils.h index d6643f33d7..f3dacda04e 100644 --- a/core/base/ftmTree/FTMTreeUtils.h +++ b/core/base/ftmTree/FTMTreeUtils.h @@ -133,7 +133,7 @@ namespace ttk { params->treeType = ftm::Join_Split; // Init tree - MergeTree mergeTree(scalars, params); + MergeTree const mergeTree(scalars, params); return mergeTree; } @@ -171,7 +171,7 @@ namespace ttk { std::vector multiPersOrigins; if(doSplitMultiPersPairs) { multiPersOrigins = tree->getMultiPersOrigins(true); - for(ftm::idNode nodeOrigin : multiPersOrigins) { + for(ftm::idNode const nodeOrigin : multiPersOrigins) { scalarsVector[nodeOrigin] = tree->getValue(tree->getNode(nodeOrigin)->getOrigin()); scalarsVector.push_back(tree->getValue(nodeOrigin)); @@ -189,8 +189,8 @@ namespace ttk { // Add multi persistence nodes origins if(doSplitMultiPersPairs) { - for(ftm::idNode nodeOrigin : multiPersOrigins) { - int nodeCpt = treeNew->getNumberOfNodes(); + for(ftm::idNode const nodeOrigin : multiPersOrigins) { + int const nodeCpt = treeNew->getNumberOfNodes(); treeNew->makeNode(nodeCpt); treeNew->getNode(nodeCpt)->setOrigin(nodeOrigin); treeNew->getNode(nodeOrigin)->setOrigin(nodeCpt); @@ -212,7 +212,7 @@ namespace ttk { std::vector &nodeCorr, bool useBD = true) { // Create new tree - int newNoNodes = tree->getRealNumberOfNodes() * 2; + int const newNoNodes = tree->getRealNumberOfNodes() * 2; MergeTree mTreeNew = createEmptyMergeTree(newNoNodes); ftm::FTMTree_MT *treeNew = &(mTreeNew.tree); std::vector newScalarsVector(newNoNodes, 0); @@ -229,7 +229,7 @@ namespace ttk { for(auto leaf : leaves) queue.push(leaf); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); if(tree->isRoot(node) and tree->isFullMerge()) @@ -257,7 +257,7 @@ namespace ttk { nodeCorr[nodeOrigin] = nodeOriginIndex; nodeCorr[node] = nodeIndex; } else { - int nodeCpt = treeNew->getNumberOfNodes(); + int const nodeCpt = treeNew->getNumberOfNodes(); treeNew->makeNode(nodeCpt); if(!tree->isLeaf(node)) { treeNew->getNode(nodeCpt)->setOrigin(nodeCorr[nodeOrigin]); @@ -279,11 +279,11 @@ namespace ttk { std::vector children; tree->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) treeNew->makeSuperArc(nodeCorr[child], nodeCorr[node]); if(!tree->isRoot(node)) { - ftm::idNode parent = tree->getParentSafe(node); + ftm::idNode const parent = tree->getParentSafe(node); nodeDone[parent] += 1; if(nodeDone[parent] == tree->getNumberOfChildren(parent)) queue.push(parent); diff --git a/core/base/ftmTree/FTMTreeUtils_Template.h b/core/base/ftmTree/FTMTreeUtils_Template.h index bb75004084..119befe4d0 100644 --- a/core/base/ftmTree/FTMTreeUtils_Template.h +++ b/core/base/ftmTree/FTMTreeUtils_Template.h @@ -72,7 +72,8 @@ namespace ttk { auto birthDeath = this->getBirthDeath(nodeId); dataType birth = std::get<0>(birthDeath); dataType death = std::get<1>(birthDeath); - bool parentInconsistent = parentDeath < death or parentBirth > birth; + bool const parentInconsistent + = parentDeath < death or parentBirth > birth; return parentInconsistent; } @@ -92,7 +93,7 @@ namespace ttk { } std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.emplace(child); } return inconsistency; @@ -137,7 +138,7 @@ namespace ttk { } std::vector children; this->getChildren(node, children); - for(idNode child : children) + for(idNode const child : children) queue.emplace(child); } return lowestNode; @@ -217,8 +218,8 @@ namespace ttk { template dataType FTMTree_MT::getMaximumPersistence() { - idNode root = this->getRoot(); - bool fullMerge = this->isFullMerge(); + idNode const root = this->getRoot(); + bool const fullMerge = this->isFullMerge(); // Classic case if(not fullMerge) @@ -236,13 +237,13 @@ namespace ttk { template ftm::idNode FTMTree_MT::getSecondMaximumPersistenceNode() { - idNode root = this->getRoot(); + idNode const root = this->getRoot(); dataType pers = std::numeric_limits::lowest(); ftm::idNode nodeSecMax = -1; for(unsigned int i = 0; i < this->getNumberOfNodes(); ++i) { if(not this->isRoot(i) and not this->isNodeAlone(i) and this->isNodeOriginDefined(i)) { - idNode nodeOrigin = this->getNode(i)->getOrigin(); + idNode const nodeOrigin = this->getNode(i)->getOrigin(); if(not(nodeOrigin == root and this->getNode(nodeOrigin)->getOrigin() == (int)i)) { auto nodePers = this->getNodePersistence(i); @@ -294,8 +295,8 @@ namespace ttk { std::vector> origins(this->getNumberOfNodes()); std::vector birthFound(this->getNumberOfNodes(), false); for(auto pair : pairs) { - idNode nodeBirth = std::get<0>(pair); - idNode nodeDeath = std::get<1>(pair); + idNode const nodeBirth = std::get<0>(pair); + idNode const nodeDeath = std::get<1>(pair); origins[nodeDeath].push_back(nodeBirth); birthFound[nodeBirth] = true; @@ -347,9 +348,9 @@ namespace ttk { std::stringstream FTMTree_MT::printTreeScalars(bool printNodeAlone, bool doPrint) { std::stringstream wholeSS; - std::streamsize sSize = std::cout.precision(); + std::streamsize const sSize = std::cout.precision(); for(unsigned int i = 0; i < this->getNumberOfNodes(); ++i) { - idNode iOrigin + idNode const iOrigin = this->isNodeOriginDefined(i) ? this->getNode(i)->getOrigin() : i; if(printNodeAlone or (not printNodeAlone diff --git a/core/base/ftmTree/FTMTree_CT.cpp b/core/base/ftmTree/FTMTree_CT.cpp index 78f4cc88be..4d81b32bb5 100644 --- a/core/base/ftmTree/FTMTree_CT.cpp +++ b/core/base/ftmTree/FTMTree_CT.cpp @@ -138,7 +138,7 @@ int FTMTree_CT::combine() { continue; } - idNode correspondingNodeId + idNode const correspondingNodeId = yt->getCorrespondingNodeId(currentNode->getVertexId()); if(yt->getNode(correspondingNodeId)->getNumberOfDownSuperArcs() > 1) { @@ -159,7 +159,7 @@ int FTMTree_CT::combine() { // NODES IN CT idNode node1, node2; - SimplexId curVert = currentNode->getVertexId(); + SimplexId const curVert = currentNode->getVertexId(); // NODE1 if(isCorrespondingNode(curVert)) { // already a node in the tree @@ -175,15 +175,15 @@ int FTMTree_CT::combine() { } // j <- GetAdj(XT, i) - idSuperArc curUpArc = currentNode->getUpSuperArcId(0); - idNode parentId = xt->getSuperArc(curUpArc)->getUpNodeId(); + idSuperArc const curUpArc = currentNode->getUpSuperArcId(0); + idNode const parentId = xt->getSuperArc(curUpArc)->getUpNodeId(); const Node *parentNode = xt->getNode(parentId); if(DEBUG) { cout << " parent node :" << parentNode->getVertexId() << endl; } - SimplexId parVert = parentNode->getVertexId(); + SimplexId const parVert = parentNode->getVertexId(); // NODE2 if(isCorrespondingNode(parVert)) { // already a node in the tree @@ -197,7 +197,7 @@ int FTMTree_CT::combine() { // CREATE ARC - idSuperArc processArc = currentNode->getUpSuperArcId(0); + idSuperArc const processArc = currentNode->getUpSuperArcId(0); // create the arc in in the good direction // and add it to crossing if needed @@ -275,7 +275,7 @@ void FTMTree_CT::createCTArcSegmentation(idSuperArc ctArc, const list &xtRegions = xt->getSuperArc(xtArc)->getRegions(); for(const Region ® : xtRegions) { segm_it cur = reg.segmentBegin; - segm_it end = reg.segmentEnd; + segm_it const end = reg.segmentEnd; segm_it tmpBeg = reg.segmentBegin; // each element inside this region for(; cur != end; ++cur) { @@ -313,12 +313,12 @@ void FTMTree_CT::finalizeSegmentation() { } void FTMTree_CT::insertNodes() { - vector sortedJTNodes = jt_.sortedNodes(true); - vector sortedSTNodes = st_.sortedNodes(true); + vector const sortedJTNodes = jt_.sortedNodes(true); + vector const sortedSTNodes = st_.sortedNodes(true); for(const idNode &t : sortedSTNodes) { - SimplexId vertId = st_.getNode(t)->getVertexId(); + SimplexId const vertId = st_.getNode(t)->getVertexId(); if(jt_.isCorrespondingNode(vertId)) { continue; } @@ -327,7 +327,7 @@ void FTMTree_CT::insertNodes() { for(const idNode &t : sortedJTNodes) { - SimplexId vertId = jt_.getNode(t)->getVertexId(); + SimplexId const vertId = jt_.getNode(t)->getVertexId(); if(st_.isCorrespondingNode(vertId)) { continue; } diff --git a/core/base/ftmTree/FTMTree_MT.cpp b/core/base/ftmTree/FTMTree_MT.cpp index 8dd2f81926..2075b36649 100644 --- a/core/base/ftmTree/FTMTree_MT.cpp +++ b/core/base/ftmTree/FTMTree_MT.cpp @@ -158,7 +158,7 @@ void FTMTree_MT::buildSegmentation() { for(SimplexId i = lowerBound; i < upperBound; ++i) { const auto vert = scalars_->sortedVertices[i]; if(isCorrespondingArc(vert)) { - idSuperArc sa = getCorrespondingSuperArcId(vert); + idSuperArc const sa = getCorrespondingSuperArcId(vert); SimplexId vertToAdd; if(mt_data_.visitOrder[vert] != nullVertex) { // Opposite order for Split Tree @@ -305,7 +305,7 @@ void FTMTree_MT::delNode(idNode node) { } #endif - idSuperArc downArc = mainNode->getDownSuperArcId(0); + idSuperArc const downArc = mainNode->getDownSuperArcId(0); Node *downNode = getNode((*mt_data_.superArcs)[downArc].getDownNodeId()); downNode->removeUpSuperArc(downArc); @@ -317,8 +317,8 @@ void FTMTree_MT::delNode(idNode node) { // We delete the upArc of this node, // if there is a down arc, we reattach it to the upNode - idSuperArc upArc = mainNode->getUpSuperArcId(0); - idNode upId = (*mt_data_.superArcs)[upArc].getUpNodeId(); + idSuperArc const upArc = mainNode->getUpSuperArcId(0); + idNode const upId = (*mt_data_.superArcs)[upArc].getUpNodeId(); Node *upNode = getNode(upId); upNode->removeDownSuperArc(upArc); @@ -328,7 +328,7 @@ void FTMTree_MT::delNode(idNode node) { // Have one down arc // Reconnect - idSuperArc downArc = mainNode->getDownSuperArcId(0); + idSuperArc const downArc = mainNode->getDownSuperArcId(0); (*mt_data_.superArcs)[downArc].setUpNodeId(upId); upNode->addDownSuperArcId(downArc); mainNode->clearDownSuperArcs(); @@ -430,7 +430,7 @@ idSuperArc FTMTree_MT::insertNode(Node *node, const bool segm) { if(isCorrespondingNode(node->getVertexId())) { Node *myNode = vertex2Node(node->getVertexId()); // If it has been hidden / replaced we need to re-make it - idSuperArc correspondingArcId = myNode->getUpSuperArcId(0); + idSuperArc const correspondingArcId = myNode->getUpSuperArcId(0); updateCorrespondingArc(myNode->getVertexId(), correspondingArcId); } @@ -484,7 +484,7 @@ idNode FTMTree_MT::makeNode(SimplexId vertexId, SimplexId term) { return getCorrespondingNodeId(vertexId); } - idNode newNodeId = mt_data_.nodes->getNext(); + idNode const newNodeId = mt_data_.nodes->getNext(); (*mt_data_.nodes)[newNodeId].setVertexId(vertexId); (*mt_data_.nodes)[newNodeId].setTermination(term); updateCorrespondingNode(vertexId, newNodeId); @@ -499,7 +499,7 @@ idNode FTMTree_MT::makeNode(const Node *const n, SimplexId) { idSuperArc FTMTree_MT::makeSuperArc(idNode downNodeId, idNode upNodeId) { - idSuperArc newSuperArcId = mt_data_.superArcs->getNext(); + idSuperArc const newSuperArcId = mt_data_.superArcs->getNext(); (*mt_data_.superArcs)[newSuperArcId].setDownNodeId(downNodeId); (*mt_data_.superArcs)[newSuperArcId].setUpNodeId(upNodeId); @@ -559,11 +559,11 @@ void FTMTree_MT::normalizeIds() { std::queue> q; std::stack> qr; for(const idNode n : mt_data_.leaves) { - bool goUp = isJT() || isST() || getNode(n)->getNumberOfUpSuperArcs(); + bool const goUp = isJT() || isST() || getNode(n)->getNumberOfUpSuperArcs(); if(goUp) - q.emplace(make_tuple(n, goUp)); + q.emplace(n, goUp); else - qr.emplace(make_tuple(n, goUp)); + qr.emplace(n, goUp); } while(!qr.empty()) { @@ -598,7 +598,7 @@ void FTMTree_MT::normalizeIds() { getSuperArc(currentArcId)->setNormalizeIds(nIdMin++); } if(!seenUp[currentArcId]) { - q.emplace(make_tuple(getArcParentNode(currentArcId, goUp), goUp)); + q.emplace(getArcParentNode(currentArcId, goUp), goUp); seenUp[currentArcId] = true; } } else { @@ -606,7 +606,7 @@ void FTMTree_MT::normalizeIds() { getSuperArc(currentArcId)->setNormalizeIds(nIdMax--); } if(!seenDown[currentArcId]) { - q.emplace(make_tuple(getArcParentNode(currentArcId, goUp), goUp)); + q.emplace(getArcParentNode(currentArcId, goUp), goUp); seenDown[currentArcId] = true; } } @@ -632,7 +632,7 @@ idSuperArc FTMTree_MT::openSuperArc(idNode downNodeId) { } #endif - idSuperArc newSuperArcId = mt_data_.superArcs->getNext(); + idSuperArc const newSuperArcId = mt_data_.superArcs->getNext(); (*mt_data_.superArcs)[newSuperArcId].setDownNodeId(downNodeId); (*mt_data_.nodes)[downNodeId].addUpSuperArcId(newSuperArcId); @@ -1007,7 +1007,7 @@ SimplexId FTMTree_MT::trunkCTSegmentation(const vector &trunkVerts, #pragma omp taskwait #endif // count added - SimplexId tot = 0; + SimplexId const tot = 0; #ifdef TTK_ENABLE_FTM_TREE_PROCESS_SPEED for(const auto &l : *mt_data_.trunkSegments) { SimplexId arcSize = 0; @@ -1031,7 +1031,7 @@ SimplexId FTMTree_MT::trunkSegmentation(const vector &trunkVerts, const auto chunkSize = getChunkSize(sizeBackBone, nbTasksThreads); const auto chunkNb = getChunkCount(sizeBackBone, nbTasksThreads); // si pas efficace vecteur de la taille de node ici a la place de acc - SimplexId tot = 0; + SimplexId const tot = 0; for(SimplexId chunkId = 0; chunkId < chunkNb; ++chunkId) { #ifdef TTK_ENABLE_OPENMP #pragma omp task firstprivate(chunkId) shared(trunkVerts, tot) \ diff --git a/core/base/ftmTree/FTMTree_MT_Template.h b/core/base/ftmTree/FTMTree_MT_Template.h index 019e12fd1a..a016cb980f 100644 --- a/core/base/ftmTree/FTMTree_MT_Template.h +++ b/core/base/ftmTree/FTMTree_MT_Template.h @@ -51,7 +51,7 @@ namespace ttk { // Build Merge treeString using tasks Timer precomputeTime; - int alreadyDone = leafSearch(mesh); + int const alreadyDone = leafSearch(mesh); printTime(precomputeTime, "leafSearch " + treeString, 3 + alreadyDone); Timer buildTime; @@ -175,7 +175,7 @@ namespace ttk { for(idNode n = 0; n < nbLeaves; ++n) { const idNode l = mt_data_.leaves[n]; - SimplexId v = getNode(l)->getVertexId(); + SimplexId const v = getNode(l)->getVertexId(); // for each node: get vert, create uf and launch mt_data_.storage[n] = AtomicUF{v}; mt_data_.ufs[v] = &mt_data_.storage[n]; @@ -219,8 +219,8 @@ namespace ttk { bool seenFirst = false; // ARC OPENING - idNode startNode = getCorrespondingNodeId(startVert); - idSuperArc currentArc = openSuperArc(startNode); + idNode const startNode = getCorrespondingNodeId(startVert); + idSuperArc const currentArc = openSuperArc(startNode); startUF->addArcToClose(currentArc); #ifdef TTK_ENABLE_FTM_TREE_STATS_TIME (*mt_data_.activeTasksStats)[currentArc].begin @@ -232,7 +232,7 @@ namespace ttk { while(!currentState->empty()) { // Next vertex - SimplexId currentVert = currentState->getNextMinVertex(); + SimplexId const currentVert = currentState->getNextMinVertex(); // ignore duplicate if(!isCorrespondingNull(currentVert) @@ -323,12 +323,13 @@ namespace ttk { // close root const SimplexId closeVert = getSuperArc(currentArc)->getLastVisited(); - bool existCloseNode = isCorrespondingNode(closeVert); - idNode closeNode = (existCloseNode) ? getCorrespondingNodeId(closeVert) - : makeNode(closeVert); + bool const existCloseNode = isCorrespondingNode(closeVert); + idNode const closeNode = (existCloseNode) + ? getCorrespondingNodeId(closeVert) + : makeNode(closeVert); closeSuperArc(currentArc, closeNode); getSuperArc(currentArc)->decrNbSeen(); - idNode rootPos = mt_data_.roots->getNext(); + idNode const rootPos = mt_data_.roots->getNext(); (*mt_data_.roots)[rootPos] = closeNode; #ifdef TTK_ENABLE_FTM_TREE_STATS_TIME @@ -424,8 +425,9 @@ namespace ttk { // Arcs const auto &nbNodes = trunkVerts.size(); for(idNode n = 1; n < nbNodes; ++n) { - idSuperArc na = makeSuperArc(getCorrespondingNodeId(trunkVerts[n - 1]), - getCorrespondingNodeId(trunkVerts[n])); + idSuperArc const na + = makeSuperArc(getCorrespondingNodeId(trunkVerts[n - 1]), + getCorrespondingNodeId(trunkVerts[n])); getSuperArc(na)->setLastVisited(trunkVerts[n]); } @@ -464,7 +466,7 @@ namespace ttk { template void FTMTree_MT::closeAndMergeOnSaddle(const triangulationType *mesh, SimplexId saddleVert) { - idNode closeNode = makeNode(saddleVert); + idNode const closeNode = makeNode(saddleVert); // Union of the UF coming here (merge propagation and closing arcs) const auto &nbNeigh = mesh->getVertexNeighborNumber(saddleVert); @@ -492,7 +494,7 @@ namespace ttk { template void FTMTree_MT::closeOnBackBone(const triangulationType *mesh, SimplexId saddleVert) { - idNode closeNode = makeNode(saddleVert); + idNode const closeNode = makeNode(saddleVert); // Union of the UF coming here (merge propagation and closing arcs) const auto &nbNeigh = mesh->getVertexNeighborNumber(saddleVert); diff --git a/core/base/ftmTree/FTMTree_Template.h b/core/base/ftmTree/FTMTree_Template.h index 954e5766e2..34b5da41e6 100644 --- a/core/base/ftmTree/FTMTree_Template.h +++ b/core/base/ftmTree/FTMTree_Template.h @@ -35,7 +35,7 @@ void ttk::ftm::FTMTree::build(const triangulationType *mesh) { printParams(); #ifdef TTK_ENABLE_OPENMP - ParallelGuard pg{threadNumber_}; + ParallelGuard const pg{threadNumber_}; omp_set_nested(1); #ifdef TTK_ENABLE_OMP_PRIORITY if(omp_get_max_task_priority() < 5) { diff --git a/core/base/ftrGraph/FTRGraphPrivate_Template.h b/core/base/ftrGraph/FTRGraphPrivate_Template.h index 143e3e6acf..d903edabfa 100644 --- a/core/base/ftrGraph/FTRGraphPrivate_Template.h +++ b/core/base/ftrGraph/FTRGraphPrivate_Template.h @@ -263,7 +263,7 @@ void ttk::ftr::FTRGraph::growthFromSeed( #pragma omp critical #endif { - bool alreadyNode = graph_.isNode(upVert); + bool const alreadyNode = graph_.isNode(upVert); hideFromHere = alreadyNode; if(isJoin) { PRINT(upVert << " join " << isJoinLast << " h " << hideFromHere); @@ -288,7 +288,8 @@ void ttk::ftr::FTRGraph::growthFromSeed( comp.lower = lowerComps(star.lower, localProp); } saddleNode = graph_.getNodeId(upVert); - idSuperArc visibleMerged = mergeAtSaddle(saddleNode, localProp, comp.lower); + idSuperArc const visibleMerged + = mergeAtSaddle(saddleNode, localProp, comp.lower); localProp->lessArc(visibleMerged - 1); localGrowth(localProp, star.upper); @@ -637,7 +638,8 @@ void ttk::ftr::FTRGraph::updatePreimage( mesh_.getVertexTriangle(localProp->getCurVertex(), t, curTriangleid); mesh_.getOrderedTriangle(curTriangleid, localProp->goUp(), oTriangle); - vertPosInTriangle curVertPos = getVertPosInTriangle(oTriangle, localProp); + vertPosInTriangle const curVertPos + = getVertPosInTriangle(oTriangle, localProp); // Update DynGraph // We can have an end pos on an unvisited triangle @@ -746,7 +748,8 @@ void ttk::ftr::FTRGraph::lazyUpdatePreimage( mesh_.getVertexTriangle(localProp->getCurVertex(), t, curTriangleid); mesh_.getOrderedTriangle(curTriangleid, localProp->goUp(), oTriangle); - vertPosInTriangle curVertPos = getVertPosInTriangle(oTriangle, localProp); + vertPosInTriangle const curVertPos + = getVertPosInTriangle(oTriangle, localProp); // Update DynGraph // We can have an end pos on an unvisited triangle @@ -878,7 +881,7 @@ bool ttk::ftr::FTRGraph::checkLast( // Using propagation id allows to decrement by the number of time this // propagation has reached the saddle, even if the propagation take care // of several of these arcs (after a Hole-split). - for(idEdge edgeId : starVect) { + for(idEdge const edgeId : starVect) { const idSuperArc edgeArc = dynGraph(localProp).getSubtreeArc(edgeId); if(edgeArc == nullSuperArc) { continue; @@ -920,7 +923,7 @@ bool ttk::ftr::FTRGraph::checkLast( if(oldVal == -1) { // First task to touch this saddle, compute the valence - idVertex totalVal = starVect.size(); + idVertex const totalVal = starVect.size(); valence newVal = 0; if(localProp->goUp()) { valence *const vd = &graph_.valDown_[curSaddle]; diff --git a/core/base/ftrGraph/FTRGraph_Template.h b/core/base/ftrGraph/FTRGraph_Template.h index 39f82f5e04..cddd25b2fe 100644 --- a/core/base/ftrGraph/FTRGraph_Template.h +++ b/core/base/ftrGraph/FTRGraph_Template.h @@ -36,12 +36,12 @@ namespace ttk { template void FTRGraph::build() { - Timer t; + Timer const t; // init some values #ifdef TTK_ENABLE_OPENMP - ParallelGuard pg{params_.threadNumber}; + ParallelGuard const pg{params_.threadNumber}; omp_set_nested(1); #ifdef TTK_ENABLE_OMP_PRIORITY if(omp_get_max_task_priority() < PriorityLevel::Max) { @@ -189,7 +189,7 @@ namespace ttk { const bool addMin = true; const bool addMax = !params_.singleSweep; - ScalarFieldCriticalPoints critPoints; + ScalarFieldCriticalPoints const critPoints; TaskChunk leafChunkParams(scalars_.getSize()); leafChunkParams.grainSize = 10000; @@ -255,7 +255,7 @@ namespace ttk { { for(idNode i = 0; i < nbSeed; i++) { // alterneate min/max, string at the deepest - idVertex l = (i % 2) ? i / 2 : nbSeed - 1 - i / 2; + idVertex const l = (i % 2) ? i / 2 : nbSeed - 1 - i / 2; // increasing order, min first // idVertex l = i; // initialize structure diff --git a/core/base/ftrGraph/FTRSuperArc.h b/core/base/ftrGraph/FTRSuperArc.h index 9c94d35bba..ecc49ef3bf 100644 --- a/core/base/ftrGraph/FTRSuperArc.h +++ b/core/base/ftrGraph/FTRSuperArc.h @@ -81,7 +81,7 @@ namespace ttk { } bool hide() { - bool old = visible_; + bool const old = visible_; visible_ = false; return old; } diff --git a/core/base/ftrGraph/Graph.h b/core/base/ftrGraph/Graph.h index f4e23b1099..051696eb65 100644 --- a/core/base/ftrGraph/Graph.h +++ b/core/base/ftrGraph/Graph.h @@ -265,7 +265,7 @@ namespace ttk { } idSuperArc openArc(const idNode downId, Propagation *p = nullptr) { - idSuperArc newArc = arcs_.getNext(); + idSuperArc const newArc = arcs_.getNext(); arcs_[newArc].setDownNodeId(downId); if(p) { arcs_[newArc].setUfProp(p->getId()); @@ -288,7 +288,7 @@ namespace ttk { } idSuperArc makeHiddenArc(Propagation *const lp) { - idSuperArc newArc = arcs_.getNext(); + idSuperArc const newArc = arcs_.getNext(); arcs_[newArc].hide(); arcs_[newArc].setUfProp(lp->getId()); return newArc; diff --git a/core/base/geometry/Geometry.cpp b/core/base/geometry/Geometry.cpp index 9dc4a2b420..7c0b388be3 100644 --- a/core/base/geometry/Geometry.cpp +++ b/core/base/geometry/Geometry.cpp @@ -280,7 +280,7 @@ int Geometry::computeTriangleAreaFromSides(const T s0, const T s2, T &area) { - double s = (s0 + s1 + s2) / 2.0; + double const s = (s0 + s1 + s2) / 2.0; area = std::sqrt(s * (s - s0) * (s - s1) * (s - s2)); return 0; diff --git a/core/base/harmonicField/HarmonicField.cpp b/core/base/harmonicField/HarmonicField.cpp index 5cf889c9ae..7d4170c3c1 100644 --- a/core/base/harmonicField/HarmonicField.cpp +++ b/core/base/harmonicField/HarmonicField.cpp @@ -114,7 +114,7 @@ int ttk::HarmonicField::execute(const TriangulationType &triangulation, } // unique constraint number - size_t uniqueConstraintNumber = idValues.size(); + size_t const uniqueConstraintNumber = idValues.size(); // graph laplacian of current mesh SpMat lap; diff --git a/core/base/helloWorld/HelloWorld.h b/core/base/helloWorld/HelloWorld.h index 6f4000f2ab..e66158f364 100644 --- a/core/base/helloWorld/HelloWorld.h +++ b/core/base/helloWorld/HelloWorld.h @@ -84,7 +84,7 @@ namespace ttk { this->threadNumber_, ttk::debug::LineMode::REPLACE); // compute the average of each vertex in parallel - size_t nVertices = triangulation->getNumberOfVertices(); + size_t const nVertices = triangulation->getNumberOfVertices(); #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(this->threadNumber_) #endif @@ -93,7 +93,7 @@ namespace ttk { outputData[i] = inputData[i]; // add neighbor values to average - size_t nNeighbors = triangulation->getVertexNeighborNumber(i); + size_t const nNeighbors = triangulation->getVertexNeighborNumber(i); ttk::SimplexId neighborId{-1}; for(size_t j = 0; j < nNeighbors; j++) { triangulation->getVertexNeighbor(i, j, neighborId); diff --git a/core/base/icosphere/Icosphere.h b/core/base/icosphere/Icosphere.h index b9307e22c3..79b3b26bf0 100644 --- a/core/base/icosphere/Icosphere.h +++ b/core/base/icosphere/Icosphere.h @@ -143,7 +143,7 @@ namespace ttk { &processedEdges, DT *vertexCoords, IT &vertexIndex) const { - bool firstIsSmaller = i < j; + bool const firstIsSmaller = i < j; IT a = firstIsSmaller ? i : j; IT b = firstIsSmaller ? j : i; @@ -286,7 +286,7 @@ int ttk::Icosphere::computeIcosphere( // if uneven number of nSubdivisions then copy temp buffer to output buffer if(nSubdivisions > 0 && nSubdivisions % 2 != 0) { - size_t n = nTriangles * 3; + size_t const n = nTriangles * 3; for(size_t i = 0; i < n; i++) connectivityList[i] = connectivityListTemp[i]; } @@ -320,7 +320,7 @@ int ttk::Icosphere::translateIcosphere(DT *vertexCoords, } // connectivity list - size_t vertexIdOffset = icosphereIndex * nVerticesPerIcosphere; + size_t const vertexIdOffset = icosphereIndex * nVerticesPerIcosphere; for(size_t i = 0, limit = nTrianglesPerIcosphere * 3; i < limit;) { connectivityList[connectivityListOffset++] = connectivityList[i++] + vertexIdOffset; @@ -373,7 +373,7 @@ int ttk::Icosphere::computeIcospheres( #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < nSpheres; i++) { - size_t n = nVerticesPerIcosphere * 3; + size_t const n = nVerticesPerIcosphere * 3; size_t offset = i * n; for(size_t j = 0; j < n; j++) normals[offset++] = vertexCoords[j]; diff --git a/core/base/implicitTriangulation/ImplicitTriangulation.cpp b/core/base/implicitTriangulation/ImplicitTriangulation.cpp index 5ec446de28..3fb87429ce 100644 --- a/core/base/implicitTriangulation/ImplicitTriangulation.cpp +++ b/core/base/implicitTriangulation/ImplicitTriangulation.cpp @@ -250,9 +250,9 @@ int ImplicitTriangulation::checkAcceleration() { isAccelerated_ = true; } } else if(dimensionality_ == 2) { - bool isDi = isPowerOfTwo(dimensions_[Di_], msb[Di_]); - bool isDj = isPowerOfTwo(dimensions_[Dj_], msb[Dj_]); - bool allDimensionsArePowerOfTwo = (isDi and isDj); + bool const isDi = isPowerOfTwo(dimensions_[Di_], msb[Di_]); + bool const isDj = isPowerOfTwo(dimensions_[Dj_], msb[Dj_]); + bool const allDimensionsArePowerOfTwo = (isDi and isDj); if(allDimensionsArePowerOfTwo) { mod_[0] = dimensions_[Di_] - 1; diff --git a/core/base/integralLines/IntegralLines.h b/core/base/integralLines/IntegralLines.h index d366dd295a..f93538bb4b 100644 --- a/core/base/integralLines/IntegralLines.h +++ b/core/base/integralLines/IntegralLines.h @@ -484,7 +484,7 @@ inline void ttk::SimplexId &fnext, std::vector &component, const SimplexId *offsets) const { - ttk::SimplexId elementInComponentNumber = component.size(); + ttk::SimplexId const elementInComponentNumber = component.size(); for(ttk::SimplexId k = 0; k < elementInComponentNumber; ++k) { if(direction_ == static_cast(Direction::Forward)) { if(fnext < offsets[component[k]]) { @@ -516,7 +516,7 @@ void ttk::IntegralLines::computeIntegralLine( std::vector> upperComponents; std::vector> lowerComponents; // Computation of the critical type - char criticalType + char const criticalType = this->scalarFieldCriticalPoints_.getCriticalType( v, offsets, triangulation, &upperComponents, &lowerComponents); // End of integral line if an appropriate maxima is reached @@ -550,7 +550,7 @@ void ttk::IntegralLines::computeIntegralLine( && EnableForking) { // For each connected components, the max (or the min) is computed // and a task is created to further the computation of the integral line - ttk::SimplexId numberOfComponents = components->size(); + ttk::SimplexId const numberOfComponents = components->size(); #ifdef TTK_ENABLE_MPI #ifdef TTK_ENABLE_OPENMP #pragma omp atomic update seq_cst @@ -571,10 +571,10 @@ void ttk::IntegralLines::computeIntegralLine( ttk::SimplexId forkIdentifier = triangulation->getVertexGlobalId(vnext); #else - ttk::SimplexId forkIdentifier = vnext; + ttk::SimplexId const forkIdentifier = vnext; #endif triangulation->getVertexPoint(vnext, p1[0], p1[1], p1[2]); - double distanceFork = Geometry::distance(p0, p1, 3); + double const distanceFork = Geometry::distance(p0, p1, 3); int threadNum{0}; #ifdef TTK_ENABLE_OPENMP threadNum = omp_get_thread_num(); @@ -612,7 +612,7 @@ void ttk::IntegralLines::computeIntegralLine( // In case the vertex is not a saddle point, all neighbor vertices // are used for the computation components->clear(); - ttk::SimplexId neighborNumber + ttk::SimplexId const neighborNumber = triangulation->getVertexNeighborNumber(v); components->push_back(std::vector()); ttk::SimplexId id; @@ -655,7 +655,7 @@ void ttk::IntegralLines::prepareForTask( std::vector *seeds) const { for(SimplexId j = 0; j < nbElement; j++) { - SimplexId v{seeds->at(j + startingIndex)}; + SimplexId const v{seeds->at(j + startingIndex)}; int seedIdentifier; #ifdef TTK_ENABLE_MPI seedIdentifier = triangulation->getVertexGlobalId(v); @@ -705,7 +705,7 @@ int ttk::IntegralLines::execute(triangulationType *triangulation) { Timer t; std::vector chunkIntegralLine(chunkSize_); - int taskNumber = (int)seedNumber_ / chunkSize_; + int const taskNumber = (int)seedNumber_ / chunkSize_; #ifdef TTK_ENABLE_OPENMP #ifdef TTK_ENABLE_MPI #pragma omp parallel shared( \ @@ -725,7 +725,7 @@ int ttk::IntegralLines::execute(triangulationType *triangulation) { this->createTask( triangulation, chunkIntegralLine, offsets, chunkSize_); } - int rest = seedNumber_ % chunkSize_; + int const rest = seedNumber_ % chunkSize_; if(rest > 0) { this->prepareForTask( triangulation, chunkIntegralLine, taskNumber * chunkSize_, rest, diff --git a/core/base/jacobiSet/JacobiSet_Template.h b/core/base/jacobiSet/JacobiSet_Template.h index cfdc10479e..8c05b72994 100644 --- a/core/base/jacobiSet/JacobiSet_Template.h +++ b/core/base/jacobiSet/JacobiSet_Template.h @@ -27,7 +27,7 @@ int ttk::JacobiSet::execute(std::vector> &jacobiSet, jacobiSet.clear(); - SimplexId edgeNumber = triangulation.getNumberOfEdges(); + SimplexId const edgeNumber = triangulation.getNumberOfEdges(); std::vector>> threadedCriticalTypes( threadNumber_); @@ -37,7 +37,7 @@ int ttk::JacobiSet::execute(std::vector> &jacobiSet, #endif for(SimplexId i = 0; i < edgeNumber; i++) { - char type = getCriticalType(i, uField, vField, triangulation); + char const type = getCriticalType(i, uField, vField, triangulation); if(type != -2) { // -2: regular vertex @@ -89,7 +89,7 @@ int ttk::JacobiSet::execute(std::vector> &jacobiSet, #pragma omp parallel for num_threads(threadNumber_) #endif for(int i = 0; i < (int)jacobiSet.size(); i++) { - int edgeId = jacobiSet[i].first; + int const edgeId = jacobiSet[i].first; SimplexId vertexId0 = -1, vertexId1 = -1; triangulation.getEdgeVertex(edgeId, 0, vertexId0); triangulation.getEdgeVertex(edgeId, 1, vertexId1); @@ -181,8 +181,8 @@ int ttk::JacobiSet::executeLegacy( #endif // processing here! - SimplexId pivotVertexId = (*edgeList_)[i].first; - SimplexId otherExtremityId = (*edgeList_)[i].second; + SimplexId const pivotVertexId = (*edgeList_)[i].first; + SimplexId const otherExtremityId = (*edgeList_)[i].second; // A) compute the distance field double projectedPivotVertex[2]; @@ -204,7 +204,7 @@ int ttk::JacobiSet::executeLegacy( for(size_t j = 0; j < (*edgeFans_)[i].size() / 4; j++) { for(int k = 0; k < 3; k++) { - SimplexId vertexId = (*edgeFans_)[i][j * 4 + 1 + k]; + SimplexId const vertexId = (*edgeFans_)[i][j * 4 + 1 + k]; // we can compute the distance field (in the rage) double projectedVertex[2]; @@ -228,13 +228,12 @@ int ttk::JacobiSet::executeLegacy( // also, lots of things in there can be done out of the loop // in the loop - char type = threadedCriticalPoints[threadId].getCriticalType( + char const type = threadedCriticalPoints[threadId].getCriticalType( pivotVertexId, sosOffsetsU_, (*edgeFanLinkEdgeLists_)[i]); if(type != -2) { // -2: regular vertex - threadedCriticalTypes[threadId].push_back( - std::pair(i, type)); + threadedCriticalTypes[threadId].emplace_back(i, type); } // update the progress bar of the wrapping code -- to adapt @@ -324,7 +323,7 @@ char ttk::JacobiSet::getCriticalType(const SimplexId &edgeId, rangeNormal[0] = -rangeEdge[1]; rangeNormal[1] = rangeEdge[0]; - SimplexId starNumber = triangulation.getEdgeStarNumber(edgeId); + SimplexId const starNumber = triangulation.getEdgeStarNumber(edgeId); std::vector lowerNeighbors, upperNeighbors; SimplexId neighborNumber = 0; @@ -334,7 +333,7 @@ char ttk::JacobiSet::getCriticalType(const SimplexId &edgeId, SimplexId tetId = -1; triangulation.getEdgeStar(edgeId, i, tetId); - SimplexId vertexNumber = triangulation.getCellVertexNumber(tetId); + SimplexId const vertexNumber = triangulation.getCellVertexNumber(tetId); for(SimplexId j = 0; j < vertexNumber; j++) { SimplexId vertexId = -1; triangulation.getCellVertex(tetId, j, vertexId); @@ -470,7 +469,7 @@ char ttk::JacobiSet::getCriticalType(const SimplexId &edgeId, SimplexId tetId = -1; triangulation.getEdgeStar(edgeId, i, tetId); - SimplexId vertexNumber = triangulation.getCellVertexNumber(tetId); + SimplexId const vertexNumber = triangulation.getCellVertexNumber(tetId); for(SimplexId j = 0; j < vertexNumber; j++) { SimplexId edgeVertexId0 = -1; triangulation.getCellVertex(tetId, j, edgeVertexId0); diff --git a/core/base/kdTree/KDTree.h b/core/base/kdTree/KDTree.h index 76e7a677e5..4637fec9f7 100644 --- a/core/base/kdTree/KDTree.h +++ b/core/base/kdTree/KDTree.h @@ -164,8 +164,8 @@ typename ttk::KDTree::KDTreeMap return data[dimension * i1 + coords_number_] < data[dimension * i2 + coords_number_]; }); - int median_loc = (int)(ptNumber - 1) / 2; - int median_idx = idx[median_loc]; + int const median_loc = (int)(ptNumber - 1) / 2; + int const median_idx = idx[median_loc]; correspondence_map[median_idx] = this; for(int axis = 0; axis < dimension; axis++) { @@ -233,8 +233,8 @@ void ttk::KDTree::buildRecursive( return data[dimension * i1 + coords_number_] < data[dimension * i2 + coords_number_]; }); - int median_loc = (int)(idx_side.size() - 1) / 2; - int median_idx = idx_side[median_loc]; + int const median_loc = (int)(idx_side.size() - 1) / 2; + int const median_idx = idx_side[median_loc]; correspondence_map[median_idx] = this; for(int axis = 0; axis < dimension; axis++) { diff --git a/core/base/lDistance/LDistance.h b/core/base/lDistance/LDistance.h index 639066c606..c33dcb40a9 100644 --- a/core/base/lDistance/LDistance.h +++ b/core/base/lDistance/LDistance.h @@ -88,7 +88,7 @@ int ttk::LDistance::execute(const dataType *const inputData1, if(distanceType == "inf") { status = computeLinf(inputData1, inputData2, outputData, vertexNumber); } else { - int n = stoi(distanceType); + int const n = stoi(distanceType); if(n < 1) return -4; diff --git a/core/base/legacyTopologicalSimplification/LegacyTopologicalSimplification.h b/core/base/legacyTopologicalSimplification/LegacyTopologicalSimplification.h index 6bb9323151..c27a9a169e 100644 --- a/core/base/legacyTopologicalSimplification/LegacyTopologicalSimplification.h +++ b/core/base/legacyTopologicalSimplification/LegacyTopologicalSimplification.h @@ -204,7 +204,8 @@ int ttk::LegacyTopologicalSimplification::getCriticalType( bool isMinima{true}; bool isMaxima{true}; - SimplexId neighborNumber = triangulation.getVertexNeighborNumber(vertex); + SimplexId const neighborNumber + = triangulation.getVertexNeighborNumber(vertex); for(SimplexId i = 0; i < neighborNumber; ++i) { SimplexId neighbor{-1}; triangulation.getVertexNeighbor(vertex, i, neighbor); @@ -296,7 +297,7 @@ int ttk::LegacyTopologicalSimplification::addPerturbation( std::get<2>(perturbation[i]) = i; } - SweepCmp cmp(true); + SweepCmp const cmp(true); sort(perturbation.begin(), perturbation.end(), cmp); for(SimplexId i = 0; i < vertexNumber_; ++i) { @@ -370,7 +371,7 @@ int ttk::LegacyTopologicalSimplification::execute( for(int j = 0; j < 2; ++j) { - bool isIncreasingOrder = !j; + bool const isIncreasingOrder = !j; if(isIncreasingOrder && authorizedMinima.empty()) { continue; @@ -387,13 +388,13 @@ int ttk::LegacyTopologicalSimplification::execute( // add the seeds if(isIncreasingOrder) { - for(SimplexId k : authorizedMinima) { + for(SimplexId const k : authorizedMinima) { authorizedExtrema[k] = true; sweepFront.emplace(outputScalars[k], offsets[k], k); visitedVertices[k] = true; } } else { - for(SimplexId k : authorizedMaxima) { + for(SimplexId const k : authorizedMaxima) { authorizedExtrema[k] = true; sweepFront.emplace(outputScalars[k], offsets[k], k); visitedVertices[k] = true; @@ -407,10 +408,10 @@ int ttk::LegacyTopologicalSimplification::execute( if(front == sweepFront.end()) return -1; - SimplexId vertexId = std::get<2>(*front); + SimplexId const vertexId = std::get<2>(*front); sweepFront.erase(front); - SimplexId neighborNumber + SimplexId const neighborNumber = triangulation.getVertexNeighborNumber(vertexId); for(SimplexId k = 0; k < neighborNumber; ++k) { SimplexId neighbor{-1}; @@ -468,7 +469,7 @@ int ttk::LegacyTopologicalSimplification::execute( debug::Priority::DETAIL); if(!needForMoreIterations) { - for(SimplexId k : minima) { + for(SimplexId const k : minima) { if(!authorizedExtrema[k]) { needForMoreIterations = true; break; @@ -476,7 +477,7 @@ int ttk::LegacyTopologicalSimplification::execute( } } if(!needForMoreIterations) { - for(SimplexId k : maxima) { + for(SimplexId const k : maxima) { if(!authorizedExtrema[k]) { needForMoreIterations = true; break; diff --git a/core/base/localizedTopologicalSimplification/LocalizedTopologicalSimplification.h b/core/base/localizedTopologicalSimplification/LocalizedTopologicalSimplification.h index 356eec41ed..664bb67e1a 100644 --- a/core/base/localizedTopologicalSimplification/LocalizedTopologicalSimplification.h +++ b/core/base/localizedTopologicalSimplification/LocalizedTopologicalSimplification.h @@ -496,7 +496,7 @@ namespace ttk { #pragma omp parallel for schedule(dynamic, 1) num_threads(this->threadNumber_) #endif // TTK_ENABLE_OPENMP for(IT p = 0; p < nPropagations; p++) { - int localStatus = this->computeSimplePropagation( + int const localStatus = this->computeSimplePropagation( propagations[p], propagationMask, segmentation, queueMask, triangulation, inputOrder); @@ -539,7 +539,7 @@ namespace ttk { #pragma omp parallel for schedule(dynamic, 1) num_threads(this->threadNumber_) #endif // TTK_ENABLE_OPENMP for(IT p = 0; p < nPropagations; p++) { - int localStatus + int const localStatus = this->computePersistenceSensitivePropagation( propagations[p], propagationMask, segmentation, queueMask, @@ -685,7 +685,7 @@ namespace ttk { #pragma omp parallel for schedule(dynamic) num_threads(this->threadNumber_) #endif // TTK_ENABLE_OPENMP for(IT p = 0; p < nPropagations; p++) { - int localStatus + int const localStatus = this->computeSegment(segmentation, propagations[p], order, triangulation); @@ -920,7 +920,7 @@ namespace ttk { #pragma omp parallel for schedule(dynamic) num_threads(this->threadNumber_) #endif // TTK_ENABLE_OPENMP for(IT p = 0; p < nPropagations; p++) { - int localStatus = this->computeLocalOrderOfSegment( + int const localStatus = this->computeLocalOrderOfSegment( localOrder, propagations[p], triangulation, segmentation, inputOrder); @@ -1008,7 +1008,7 @@ namespace ttk { this->printMsg("Flattening Scalar Array", 0, 0, this->threadNumber_, debug::LineMode::REPLACE); - std::vector> *> propagationsPair + std::vector> *> const propagationsPair = {&propagationsA, &propagationsB}; for(const auto propagations : propagationsPair) { diff --git a/core/base/lowestCommonAncestor/LowestCommonAncestor.cpp b/core/base/lowestCommonAncestor/LowestCommonAncestor.cpp index 01f779bab5..2fbf81c706 100644 --- a/core/base/lowestCommonAncestor/LowestCommonAncestor.cpp +++ b/core/base/lowestCommonAncestor/LowestCommonAncestor.cpp @@ -43,9 +43,9 @@ int ttk::LowestCommonAncestor::preprocess() { int ttk::LowestCommonAncestor::RMQuery(const int &i, const int &j) const { // Bloc of i - int blocI = i / blocSize_; + int const blocI = i / blocSize_; // Bloc of j - int blocJ = j / blocSize_; + int const blocJ = j / blocSize_; // If i and j are in different blocs if(blocI != blocJ) { // Positions and values of the 3 range minima to compare @@ -79,9 +79,10 @@ int ttk::LowestCommonAncestor::RMQuery(const int &i, const int &j) const { int ttk::LowestCommonAncestor::computeBlocs() { // Size and number of blocs - int sizeOfArray = static_cast(nodeDepth_.size()); + int const sizeOfArray = static_cast(nodeDepth_.size()); blocSize_ = static_cast(log2(sizeOfArray) / 2.0); - int numberOfBlocs = sizeOfArray / blocSize_ + (sizeOfArray % blocSize_ != 0); + int const numberOfBlocs + = sizeOfArray / blocSize_ + (sizeOfArray % blocSize_ != 0); // Define the bloc ranges for(int i = 0; i < numberOfBlocs; i++) { std::pair range; @@ -110,7 +111,7 @@ int ttk::LowestCommonAncestor::computeBlocs() { } } // Allocate the query tables - int numberOfTables = (1 << (blocSize_ - 1)); + int const numberOfTables = (1 << (blocSize_ - 1)); normalizedBlocTable_.resize(numberOfTables); for(int i = 0; i < numberOfTables; i++) { normalizedBlocTable_[i].resize(blocSize_); @@ -205,7 +206,7 @@ int ttk::LowestCommonAncestor::eulerianTransverse() { std::vector isVisited(getNumberOfNodes(), false); nodeStack.push(rootId); while(!nodeStack.empty()) { - int nodeId = nodeStack.top(); + int const nodeId = nodeStack.top(); nodeStack.pop(); nodeOrder_.push_back(nodeId); nodeDepth_.push_back(depth); @@ -215,7 +216,7 @@ int ttk::LowestCommonAncestor::eulerianTransverse() { nodeStack.push(node_[nodeId].getAncestorId()); } // Add successors - int numberOfSuccessors = node_[nodeId].getNumberOfSuccessors(); + int const numberOfSuccessors = node_[nodeId].getNumberOfSuccessors(); for(int i = 0; i < numberOfSuccessors; i++) { nodeStack.push(node_[nodeId].getSuccessorId(i)); } diff --git a/core/base/lowestCommonAncestor/LowestCommonAncestor.h b/core/base/lowestCommonAncestor/LowestCommonAncestor.h index de6d838773..3e66020b0b 100644 --- a/core/base/lowestCommonAncestor/LowestCommonAncestor.h +++ b/core/base/lowestCommonAncestor/LowestCommonAncestor.h @@ -52,7 +52,7 @@ namespace ttk { /// \return Returns the id of the new node inline int addNode() { node_.emplace_back(); - int id = static_cast(node_.size()); + int const id = static_cast(node_.size()); node_[id].setAncestor(id); return id; } diff --git a/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.cpp b/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.cpp index 7ce7624b48..b9ce20b458 100644 --- a/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.cpp +++ b/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.cpp @@ -113,14 +113,14 @@ int MandatoryCriticalPoints::buildMandatoryTree( if(isExtremumSimplified[i]) continue; // New point in the graph - int extremumGraphPoint = mdtTree.addVertex(); + int const extremumGraphPoint = mdtTree.addVertex(); mdtTreePointComponentId.push_back(i); mdtTreePointType.push_back(extremumType); mdtTreePointLowInterval.push_back(extremumInterval[i].first); mdtTreePointUpInterval.push_back(extremumInterval[i].second); // Look for the saddle and connect if there is one - int parentSaddle = mdtExtremumParentSaddle[i]; + int const parentSaddle = mdtExtremumParentSaddle[i]; // If no parent saddle, end the loop if(parentSaddle == -1) break; @@ -129,8 +129,8 @@ int MandatoryCriticalPoints::buildMandatoryTree( saddleGraphVertex[parentSaddle] = mdtTree.addVertex(); mdtTreePointComponentId.push_back(parentSaddle); mdtTreePointType.push_back(saddleType); - int lowerVertex = mandatorySaddleVertices[parentSaddle].first; - int upperVertex = mandatorySaddleVertices[parentSaddle].second; + int const lowerVertex = mandatorySaddleVertices[parentSaddle].first; + int const upperVertex = mandatorySaddleVertices[parentSaddle].second; mdtTreePointLowInterval.push_back(lowerVertexScalars_[lowerVertex]); mdtTreePointUpInterval.push_back(upperVertexScalars_[upperVertex]); } @@ -172,13 +172,13 @@ int MandatoryCriticalPoints::buildMandatoryTree( saddleGraphVertex[i] = mdtTree.addVertex(); mdtTreePointComponentId.push_back(i); mdtTreePointType.push_back(saddleType); - int lowerVertex = mandatorySaddleVertices[i].first; - int upperVertex = mandatorySaddleVertices[i].second; + int const lowerVertex = mandatorySaddleVertices[i].first; + int const upperVertex = mandatorySaddleVertices[i].second; mdtTreePointLowInterval.push_back(lowerVertexScalars_[lowerVertex]); mdtTreePointUpInterval.push_back(upperVertexScalars_[upperVertex]); } // Look for the saddle above and connect if there is one - int parentSaddle = mdtSaddleParentSaddle[i]; + int const parentSaddle = mdtSaddleParentSaddle[i]; // If the parent is different from the saddle itself, create it and // connect if(parentSaddle != i) { @@ -187,8 +187,8 @@ int MandatoryCriticalPoints::buildMandatoryTree( saddleGraphVertex[parentSaddle] = mdtTree.addVertex(); mdtTreePointComponentId.push_back(parentSaddle); mdtTreePointType.push_back(saddleType); - int lowerVertex = mandatorySaddleVertices[parentSaddle].first; - int upperVertex = mandatorySaddleVertices[parentSaddle].second; + int const lowerVertex = mandatorySaddleVertices[parentSaddle].first; + int const upperVertex = mandatorySaddleVertices[parentSaddle].second; mdtTreePointLowInterval.push_back(lowerVertexScalars_[lowerVertex]); mdtTreePointUpInterval.push_back(upperVertexScalars_[upperVertex]); } @@ -198,7 +198,7 @@ int MandatoryCriticalPoints::buildMandatoryTree( mdtTreeEdgeSwitchable.push_back( areSaddlesSwitchables(treeType, parentSaddle, i)); } else { // It is the root, create the global extremum to connect with it - int globalOtherExtremumGraphPoint = mdtTree.addVertex(); + int const globalOtherExtremumGraphPoint = mdtTree.addVertex(); mdtTreePointComponentId.push_back(-1); mdtTreePointType.push_back(otherExtremumType); mdtTreePointLowInterval.push_back(globalOtherExtremumValue); @@ -307,7 +307,7 @@ int MandatoryCriticalPoints::buildPairs( } } // Sort pair by increasing value of d(S,M) (.second) - criticalPointPairComparison pairComparison; + criticalPointPairComparison const pairComparison; std::sort(extremaSaddlePair.begin(), extremaSaddlePair.end(), pairComparison); const std::string treeName = treeType == TreeType::JoinTree @@ -365,7 +365,7 @@ int MandatoryCriticalPoints::computePlanarLayout( // Root down point int downRootPointId = -1; if(mdtTree.getVertex(rootGraphPointId).getNumberOfEdges() == 1) { - int edgeId = mdtTree.getVertex(rootGraphPointId).getEdgeIdx(0); + int const edgeId = mdtTree.getVertex(rootGraphPointId).getEdgeIdx(0); if(mdtTree.getEdge(edgeId).getVertexIdx().first == rootGraphPointId) { downRootPointId = mdtTree.getEdge(edgeId).getVertexIdx().second; } @@ -390,14 +390,14 @@ int MandatoryCriticalPoints::computePlanarLayout( while(!graphPointQueue.empty()) { - int graphPoint = graphPointQueue.front(); + int const graphPoint = graphPointQueue.front(); graphPointQueue.pop(); // Number Of Down Edges - int numberOfEdges = mdtTree.getVertex(graphPoint).getNumberOfEdges(); + int const numberOfEdges = mdtTree.getVertex(graphPoint).getNumberOfEdges(); int numberOfDownEdges = 0; for(int i = 0; i < numberOfEdges; i++) { - int edgeId = mdtTree.getVertex(graphPoint).getEdgeIdx(i); + int const edgeId = mdtTree.getVertex(graphPoint).getEdgeIdx(i); if(mdtTree.getEdge(edgeId).getVertexIdx().first == graphPoint) { numberOfDownEdges++; } @@ -413,7 +413,7 @@ int MandatoryCriticalPoints::computePlanarLayout( int downPointCount = 0; // Interval splitting for down points for(int i = 0; i < numberOfEdges; i++) { - int edgeId = mdtTree.getVertex(graphPoint).getEdgeIdx(i); + int const edgeId = mdtTree.getVertex(graphPoint).getEdgeIdx(i); int downGraphPoint = -1; if(mdtTree.getEdge(edgeId).getVertexIdx().first == graphPoint) { downGraphPoint = mdtTree.getEdge(edgeId).getVertexIdx().second; @@ -446,7 +446,7 @@ int MandatoryCriticalPoints::computePlanarLayout( /* X coordinates */ // Sorting - pairComparison xCoordCmp; + pairComparison const xCoordCmp; std::sort(xOrder.begin(), xOrder.end(), xCoordCmp); // X coordinates for all points except root (global extremum) int pointCount = 0; @@ -489,14 +489,14 @@ int MandatoryCriticalPoints::computeExtremumComponent( // Clear the list componentVertexList.clear(); // Get the super arc id of the vertex - int superArcId = getVertexSuperArcId(seedVertexId, &tree); + int const superArcId = getVertexSuperArcId(seedVertexId, &tree); // Get the sub tree root super arc - int rootSuperArcId = getSubTreeRootSuperArcId(&tree, superArcId, value); + int const rootSuperArcId = getSubTreeRootSuperArcId(&tree, superArcId, value); // Get the list of the sub tree super arc ids std::vector subTreeSuperArcId; getSubTreeSuperArcIds(&tree, rootSuperArcId, subTreeSuperArcId); // Comparison - int sign = (pointType == PointType::Minimum) ? 1 : -1; + int const sign = (pointType == PointType::Minimum) ? 1 : -1; // Compute each super arc for(int i = 0; i < (int)subTreeSuperArcId.size(); i++) { const SuperArc *superArc = tree.getSuperArc(subTreeSuperArcId[i]); @@ -505,30 +505,30 @@ int MandatoryCriticalPoints::computeExtremumComponent( if(subTreeSuperArcId[i] == rootSuperArcId) { // Test the value for each regular node for(int j = 0; j < numberOfRegularNodes; j++) { - int regularNodeId = superArc->getRegularNodeId(j); - double nodeScalar = tree.getNodeScalar(regularNodeId); + int const regularNodeId = superArc->getRegularNodeId(j); + double const nodeScalar = tree.getNodeScalar(regularNodeId); if(!((sign * nodeScalar) > (sign * value))) { - int vertexId = tree.getNode(regularNodeId)->getVertexId(); + int const vertexId = tree.getNode(regularNodeId)->getVertexId(); componentVertexList.push_back(vertexId); } } // Down node - int downNodeId = superArc->getDownNodeId(); - double nodeScalar = tree.getNodeScalar(downNodeId); + int const downNodeId = superArc->getDownNodeId(); + double const nodeScalar = tree.getNodeScalar(downNodeId); if(!((sign * nodeScalar) > (sign * value))) { - int vertexId = tree.getNode(downNodeId)->getVertexId(); + int const vertexId = tree.getNode(downNodeId)->getVertexId(); componentVertexList.push_back(vertexId); } } else { // Take all regular nodes for(int j = 0; j < numberOfRegularNodes; j++) { - int regularNodeId = superArc->getRegularNodeId(j); - int vertexId = tree.getNode(regularNodeId)->getVertexId(); + int const regularNodeId = superArc->getRegularNodeId(j); + int const vertexId = tree.getNode(regularNodeId)->getVertexId(); componentVertexList.push_back(vertexId); } // Take down node - int downNodeId = superArc->getDownNodeId(); - int vertexId = tree.getNode(downNodeId)->getVertexId(); + int const downNodeId = superArc->getDownNodeId(); + int const vertexId = tree.getNode(downNodeId)->getVertexId(); componentVertexList.push_back(vertexId); } } @@ -557,10 +557,10 @@ int MandatoryCriticalPoints::enumerateMandatoryExtrema( // Extremum list in the first tree const std::vector &extremumList = *firstTree.getExtremumList(); // Some tmp variables - size_t extremumNumber = extremumList.size(); + size_t const extremumNumber = extremumList.size(); std::vector vertexId(extremumNumber); std::vector vertexValue(extremumNumber); - std::vector superArcId(extremumNumber); + std::vector const superArcId(extremumNumber); // vector rootSuperArcId(extremumNumber); std::vector subTreeSuperArcId; // vector > // subTreeSuperArcId(extremumNumber); @@ -583,7 +583,8 @@ int MandatoryCriticalPoints::enumerateMandatoryExtrema( // Vertex Value (first tree) firstTree.getVertexScalar(vertexId[i], vertexValue[i]); // Super Arc Id (second tree) - int secondTreeSuperArcId = getVertexSuperArcId(vertexId[i], &secondTree); + int const secondTreeSuperArcId + = getVertexSuperArcId(vertexId[i], &secondTree); // Root Super Arc Id (second tree) of the sub tree containing the vertex and // rooted at the value of the vertex in the first scalar field int rootSuperArcId = -1; @@ -600,13 +601,13 @@ int MandatoryCriticalPoints::enumerateMandatoryExtrema( std::queue superArcQueue; superArcQueue.push(rootSuperArcId); while(isMandatory && (!superArcQueue.empty())) { - int spaId = superArcQueue.front(); + int const spaId = superArcQueue.front(); superArcQueue.pop(); if(isSuperArcAlreadyVisited[spaId]) { isMandatory = false; } else { - int downNodeId = secondTree.getSuperArc(spaId)->getDownNodeId(); - int numberOfDownSuperArcs + int const downNodeId = secondTree.getSuperArc(spaId)->getDownNodeId(); + int const numberOfDownSuperArcs = secondTree.getNode(downNodeId)->getNumberOfDownSuperArcs(); if(numberOfDownSuperArcs > 0) { for(int j = 0; j < numberOfDownSuperArcs; j++) { @@ -628,9 +629,9 @@ int MandatoryCriticalPoints::enumerateMandatoryExtrema( criticalInterval.emplace_back(vertexValue[i], vertexValue[i]); for(int j = 0; j < (int)subTreeSuperArcId.size(); j++) { isSuperArcAlreadyVisited[subTreeSuperArcId[j]] = true; - int downNodeId + int const downNodeId = secondTree.getSuperArc(subTreeSuperArcId[j])->getDownNodeId(); - double downNodeValue = secondTree.getNodeScalar(downNodeId); + double const downNodeValue = secondTree.getNodeScalar(downNodeId); if(pointType == PointType::Minimum) { if(downNodeValue < criticalInterval.back().first) { criticalInterval.back().first = downNodeValue; @@ -791,14 +792,15 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( } if(!saddleFound) { // Get the upper super arc - int upNodeId = upperTree.getSuperArc(upperSuperArcId)->getUpNodeId(); + int const upNodeId + = upperTree.getSuperArc(upperSuperArcId)->getUpNodeId(); upperSuperArcId = upperTree.getNode(upNodeId)->getUpSuperArcId(0); if(upperSuperArcId == -1) { rootReached = true; } } else { if(!multipleSaddleFound) { - int saddleId + int const saddleId = upperTree.getSuperArc(upperSuperArcId)->getDownNodeId(); #ifdef TTK_ENABLE_OPENMP #pragma omp critical @@ -828,14 +830,15 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( } if(!saddleFound) { // Get the upper super arc - int upNodeId = lowerTree.getSuperArc(lowerSuperArcId)->getUpNodeId(); + int const upNodeId + = lowerTree.getSuperArc(lowerSuperArcId)->getUpNodeId(); lowerSuperArcId = lowerTree.getNode(upNodeId)->getUpSuperArcId(0); if(lowerSuperArcId == -1) { rootReached = true; } } else { if(!multipleSaddleFound) { - int saddleId + int const saddleId = lowerTree.getSuperArc(lowerSuperArcId)->getDownNodeId(); #ifdef TTK_ENABLE_OPENMP #pragma omp critical @@ -875,7 +878,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( #pragma omp for #endif for(int i = 0; i < (int)upperSaddleList.size(); i++) { - int superArcId + int const superArcId = upperTree.getNode(upperSaddleList[i])->getUpSuperArcId(0); upperTransverse[superArcId] = i; } @@ -884,7 +887,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( #pragma omp for #endif for(int i = 0; i < (int)lowerSaddleList.size(); i++) { - int superArcId + int const superArcId = lowerTree.getNode(lowerSaddleList[i])->getUpSuperArcId(0); lowerTransverse[superArcId] = i; } @@ -922,7 +925,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( // Upper Tree superArcId = getVertexSuperArcId(mandatoryExtremumVertex[i], &upperTree); while((superArcId != -1) && (upperTransverse[superArcId] == -1)) { - int nodeId = upperTree.getSuperArc(superArcId)->getUpNodeId(); + int const nodeId = upperTree.getSuperArc(superArcId)->getUpNodeId(); superArcId = upperTree.getNode(nodeId)->getUpSuperArcId(0); } if(superArcId != -1) { @@ -939,7 +942,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( // Lower Tree superArcId = getVertexSuperArcId(mandatoryExtremumVertex[i], &lowerTree); while((superArcId != -1) && (lowerTransverse[superArcId] == -1)) { - int nodeId = lowerTree.getSuperArc(superArcId)->getUpNodeId(); + int const nodeId = lowerTree.getSuperArc(superArcId)->getUpNodeId(); superArcId = lowerTree.getNode(nodeId)->getUpSuperArcId(0); } if(superArcId != -1) { @@ -962,12 +965,13 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( int superArcId = upperTree.getNode(upperSaddleList[i])->getUpSuperArcId(0); do { - int nodeId = upperTree.getSuperArc(superArcId)->getUpNodeId(); + int const nodeId = upperTree.getSuperArc(superArcId)->getUpNodeId(); superArcId = upperTree.getNode(nodeId)->getUpSuperArcId(0); } while((superArcId != -1) && (upperTransverse[superArcId] == -1)); if(superArcId != -1) { - int lcaSuccessorSaddleId = extremaNumber + i; - int lcaAncestorSaddleId = extremaNumber + upperTransverse[superArcId]; + int const lcaSuccessorSaddleId = extremaNumber + i; + int const lcaAncestorSaddleId + = extremaNumber + upperTransverse[superArcId]; // Ancestor upperLca.getNode(lcaSuccessorSaddleId).setAncestor(lcaAncestorSaddleId); // Successor @@ -986,12 +990,13 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( int superArcId = lowerTree.getNode(lowerSaddleList[i])->getUpSuperArcId(0); do { - int nodeId = lowerTree.getSuperArc(superArcId)->getUpNodeId(); + int const nodeId = lowerTree.getSuperArc(superArcId)->getUpNodeId(); superArcId = lowerTree.getNode(nodeId)->getUpSuperArcId(0); } while((superArcId != -1) && (lowerTransverse[superArcId] == -1)); if(superArcId != -1) { - int lcaSuccessorSaddleId = extremaNumber + i; - int lcaAncestorSaddleId = extremaNumber + lowerTransverse[superArcId]; + int const lcaSuccessorSaddleId = extremaNumber + i; + int const lcaAncestorSaddleId + = extremaNumber + lowerTransverse[superArcId]; // Ancestor lowerLca.getNode(lcaSuccessorSaddleId).setAncestor(lcaAncestorSaddleId); // Successor @@ -1028,7 +1033,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( localUpperToLowerLinks.resize(upperSaddleList.size()); localMergedExtrema.resize(lowerSaddleList.size()); // Number of iterations (triangular loop without diagonal) - unsigned int kmax = (extremaNumber * (extremaNumber - 1)) / 2; + unsigned int const kmax = (extremaNumber * (extremaNumber - 1)) / 2; // Loop over pairs of extrema #ifdef TTK_ENABLE_OPENMP #pragma omp for @@ -1040,8 +1045,8 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( i = extremaNumber - i - 2; j = extremaNumber - j - 1; } - int uppLCA = upperLca.query(i, j) - extremaNumber; - int lowLCA = lowerLca.query(i, j) - extremaNumber; + int const uppLCA = upperLca.query(i, j) - extremaNumber; + int const lowLCA = lowerLca.query(i, j) - extremaNumber; localLowerToUpperLinks[lowLCA].push_back(uppLCA); localUpperToLowerLinks[uppLCA].push_back(lowLCA); localMergedExtrema[lowLCA].push_back(i); @@ -1125,7 +1130,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( // New component lowComponent.emplace_back(); uppComponent.emplace_back(); - int componentId = static_cast(lowComponent.size()) - 1; + int const componentId = static_cast(lowComponent.size()) - 1; lowComponent[componentId].push_back(i); isLowerVisited[i] = true; // Lists of neighbors @@ -1142,7 +1147,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( // For each neighbors for(unsigned int k = 0; k < (*linkList)[currentList[j]].size(); k++) { // Get the neighbor id; - int neighbor = (*linkList)[currentList[j]][k]; + int const neighbor = (*linkList)[currentList[j]][k]; // Check if it's already visited if(!(*isVisited)[neighbor]) { // If not visited, mark it and add it @@ -1166,7 +1171,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( } // Find pairs of vertices and list of merged extrema - int numberOfComponents = static_cast(lowComponent.size()); + int const numberOfComponents = static_cast(lowComponent.size()); mandatorySaddleVertex.resize(numberOfComponents, std::pair(-1, -1)); std::vector> mandatoryMergedExtrema_tmp; mandatoryMergedExtrema_tmp.resize(numberOfComponents, std::vector()); @@ -1178,8 +1183,8 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( mandatorySaddleVertex[i].first = lowerTree.getNode(nodeId)->getVertexId(); for(unsigned int j = 0; j < lowComponent[i].size(); j++) { // First saddle - int nId = lowerSaddleList[lowComponent[i][j]]; - double nodeScalar = lowerTree.getNodeScalar(nId); + int const nId = lowerSaddleList[lowComponent[i][j]]; + double const nodeScalar = lowerTree.getNodeScalar(nId); double refScalar = 0; lowerTree.getVertexScalar(mandatorySaddleVertex[i].first, refScalar); if(nodeScalar < refScalar) { @@ -1200,8 +1205,8 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( mandatorySaddleVertex[i].second = upperTree.getNode(nodeId)->getVertexId(); for(unsigned int j = 0; j < uppComponent[i].size(); j++) { // First saddle - int nId = upperSaddleList[uppComponent[i][j]]; - double nodeScalar = upperTree.getNodeScalar(nId); + int const nId = upperSaddleList[uppComponent[i][j]]; + double const nodeScalar = upperTree.getNodeScalar(nId); double refScalar = 0; upperTree.getVertexScalar(mandatorySaddleVertex[i].second, refScalar); if(nodeScalar > refScalar) { @@ -1215,7 +1220,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( for(unsigned int i = 0; i < mandatoryMergedExtrema_tmp.size(); i++) { std::sort(mandatoryMergedExtrema_tmp[i].begin(), mandatoryMergedExtrema_tmp[i].end()); - std::vector::iterator newEnd + std::vector::iterator const newEnd = unique(mandatoryMergedExtrema_tmp[i].begin(), mandatoryMergedExtrema_tmp[i].end()); mandatoryMergedExtrema_tmp[i].resize( @@ -1224,7 +1229,7 @@ int MandatoryCriticalPoints::enumerateMandatorySaddles( order.emplace_back(i, mandatoryMergedExtrema_tmp[i].size()); } // Sort by number of merged extrema - mandatorySaddleComparison cmp; + mandatorySaddleComparison const cmp; std::sort(order.begin(), order.end(), cmp); // Reorder for output mandatoryMergedExtrema.clear(); @@ -1308,10 +1313,10 @@ int MandatoryCriticalPoints::getSubTreeRootSuperArcId( // Value of the vertex associated with the node double upNodeValue = tree->getNodeScalar(upNodeId); // While condition - int sign = tree->isJoinTree() ? 1 : -1; + int const sign = tree->isJoinTree() ? 1 : -1; // Climb up the tree while(!((sign * targetValue) < (sign * upNodeValue))) { - int numberOfUpSuperArcs + int const numberOfUpSuperArcs = tree->getNode(upNodeId)->getNumberOfUpSuperArcs(); if(numberOfUpSuperArcs > 0) { superArcId = tree->getNode(upNodeId)->getUpSuperArcId(0); @@ -1330,10 +1335,10 @@ int MandatoryCriticalPoints::findCommonAncestorNodeId( const SubLevelSetTree *tree, const int &vertexId0, const int &vertexId1) const { - int numberOfSuperArcs = tree->getNumberOfSuperArcs(); + int const numberOfSuperArcs = tree->getNumberOfSuperArcs(); std::vector isSuperArcVisited(numberOfSuperArcs, false); - int superArcId0 = getVertexSuperArcId(vertexId0, tree); - int superArcId1 = getVertexSuperArcId(vertexId1, tree); + int const superArcId0 = getVertexSuperArcId(vertexId0, tree); + int const superArcId1 = getVertexSuperArcId(vertexId1, tree); int superArcId = superArcId0; do { isSuperArcVisited[superArcId] = true; @@ -1356,9 +1361,9 @@ void MandatoryCriticalPoints::getSubTreeSuperArcIds( std::queue superArcIdsToCompute; superArcIdsToCompute.push(rootSuperArcId); while(!superArcIdsToCompute.empty()) { - int superArcId = superArcIdsToCompute.front(); - int downNodeId = tree->getSuperArc(superArcId)->getDownNodeId(); - int numberOfUpSuperArcs + int const superArcId = superArcIdsToCompute.front(); + int const downNodeId = tree->getSuperArc(superArcId)->getDownNodeId(); + int const numberOfUpSuperArcs = tree->getNode(downNodeId)->getNumberOfDownSuperArcs(); if(numberOfUpSuperArcs > 0) { for(int i = 0; i < numberOfUpSuperArcs; i++) @@ -1447,7 +1452,7 @@ int MandatoryCriticalPoints::simplify( } if(!saddleSimplified[i]) { for(size_t j = 0; j < mergedExtrema[i].size(); j++) { - int extremaId = mergedExtrema[i][j]; + int const extremaId = mergedExtrema[i][j]; if(!extremumSimplified[extremaId]) { // If the extrema is not already connected, define the parent if(extremumParentSaddle[extremaId] == -1) { diff --git a/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.h b/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.h index 3f9d89fe04..5ef92d0448 100644 --- a/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.h +++ b/core/base/mandatoryCriticalPoints/MandatoryCriticalPoints.h @@ -85,7 +85,7 @@ namespace ttk { } /// Add a vertex, returns it's index int addVertex() { - Vertex newVertex; + Vertex const newVertex; vertexList_.push_back(newVertex); return (int)vertexList_.size() - 1; } @@ -96,7 +96,7 @@ namespace ttk { /// Add an edge between the vertex start and end, returns it's index int addEdge(const int &start, const int &end) { if((start < (int)vertexList_.size()) && (end < (int)vertexList_.size())) { - Edge newEdge(start, end); + Edge const newEdge(start, end); edgeList_.push_back(newEdge); vertexList_[start].edgeIdx_.push_back(edgeList_.size() - 1); vertexList_[end].edgeIdx_.push_back(edgeList_.size() - 1); @@ -690,7 +690,7 @@ namespace ttk { int superArcId = tree->getVertexSuperArcId(vertexId); // If superArcId == -1, it may be a leaf so look for the nearest super arc if(superArcId == -1) { - int nodeId = tree->getVertexNodeId(vertexId); + int const nodeId = tree->getVertexNodeId(vertexId); if(tree->getNode(nodeId)->getNumberOfUpSuperArcs()) { superArcId = tree->getNode(nodeId)->getUpSuperArcId(0); } else if(tree->getNode(nodeId)->getNumberOfDownSuperArcs()) { @@ -1002,7 +1002,7 @@ int ttk::MandatoryCriticalPoints::buildSubTrees( for(int i = 0; i < vertexNumber_; i++) { bool isLowerMin = true; bool isUpperMax = true; - SimplexId neighborNumber = triangulation.getVertexNeighborNumber(i); + SimplexId const neighborNumber = triangulation.getVertexNeighborNumber(i); for(SimplexId j = 0; j < neighborNumber; j++) { SimplexId neighborId{-1}; triangulation.getVertexNeighbor(i, j, neighborId); @@ -1111,19 +1111,19 @@ int ttk::MandatoryCriticalPoints::computeSaddleComponent( idQueue.push(seedVertexId); while(!(idQueue.empty())) { - int vertexId = idQueue.front(); + int const vertexId = idQueue.front(); idQueue.pop(); if(!isVisited[vertexId]) { isVisited[vertexId] = true; - double lowerValue = lowerVertexScalars_[vertexId]; - double upperValue = upperVertexScalars_[vertexId]; + double const lowerValue = lowerVertexScalars_[vertexId]; + double const upperValue = upperVertexScalars_[vertexId]; if((pointType == PointType::JoinSaddle && (!(lowerValue > upInterval)) && (upperValue > lowInterval)) || (pointType == PointType::SplitSaddle && (!(upperValue < lowInterval)) && (lowerValue < upInterval))) { componentVertexList.push_back(vertexId); // Neighbors - SimplexId neighborNumber + SimplexId const neighborNumber = triangulation.getVertexNeighborNumber(vertexId); for(SimplexId i = 0; i < neighborNumber; i++) { SimplexId neighborVertexId; diff --git a/core/base/manifoldCheck/ManifoldCheck.h b/core/base/manifoldCheck/ManifoldCheck.h index 2b47cf7dc1..9634e36330 100644 --- a/core/base/manifoldCheck/ManifoldCheck.h +++ b/core/base/manifoldCheck/ManifoldCheck.h @@ -122,7 +122,7 @@ int ttk::ManifoldCheck::execute(const triangulationType *triangulation) const { return -1; #endif - SimplexId vertexNumber = triangulation->getNumberOfVertices(); + SimplexId const vertexNumber = triangulation->getNumberOfVertices(); if(vertexLinkComponentNumber_) { @@ -138,7 +138,7 @@ int ttk::ManifoldCheck::execute(const triangulationType *triangulation) const { if((edgeLinkComponentNumber_) && (triangulation->getDimensionality() >= 2)) { - SimplexId edgeNumber = triangulation->getNumberOfEdges(); + SimplexId const edgeNumber = triangulation->getNumberOfEdges(); edgeLinkComponentNumber_->resize(edgeNumber); #ifdef TTK_ENABLE_OPENMP @@ -152,7 +152,7 @@ int ttk::ManifoldCheck::execute(const triangulationType *triangulation) const { if((triangleLinkComponentNumber_) && (triangulation->getDimensionality() == 3)) { - SimplexId triangleNumber = triangulation->getNumberOfTriangles(); + SimplexId const triangleNumber = triangulation->getNumberOfTriangles(); triangleLinkComponentNumber_->resize(triangleNumber); #ifdef TTK_ENABLE_OPENMP @@ -176,7 +176,7 @@ template int ttk::ManifoldCheck::vertexManifoldCheck( const triangulationType *triangulation, const SimplexId &vertexId) const { - SimplexId linkSize = triangulation->getVertexLinkNumber(vertexId); + SimplexId const linkSize = triangulation->getVertexLinkNumber(vertexId); if(triangulation->getDimensionality() == 1) return linkSize; @@ -337,7 +337,7 @@ template int ttk::ManifoldCheck::edgeManifoldCheck( const triangulationType *triangulation, const SimplexId &edgeId) const { - SimplexId linkSize = triangulation->getEdgeLinkNumber(edgeId); + SimplexId const linkSize = triangulation->getEdgeLinkNumber(edgeId); if(triangulation->getDimensionality() == 2) return linkSize; diff --git a/core/base/marchingTetrahedra/MarchingTetrahedra.h b/core/base/marchingTetrahedra/MarchingTetrahedra.h index b8451bd511..71fa4d7c23 100644 --- a/core/base/marchingTetrahedra/MarchingTetrahedra.h +++ b/core/base/marchingTetrahedra/MarchingTetrahedra.h @@ -621,7 +621,7 @@ int ttk::MarchingTetrahedra::writeBoundaries_2D( edgeStartIndex[t] = numEdges[t - 1] + edgeStartIndex[t - 1]; } - size_t numTotalEdges = edgeStartIndex[this->threadNumber_]; + size_t const numTotalEdges = edgeStartIndex[this->threadNumber_]; #else // TTK_ENABLE_OPENMP size_t numTotalEdges = numEdges[0]; #endif // TTK_ENABLE_OPENMP @@ -733,7 +733,7 @@ int ttk::MarchingTetrahedra::writeBoundariesDetailed_2D( edgeStartIndex[t] = numEdges[t - 1] + edgeStartIndex[t - 1]; } - size_t numTotalEdges = edgeStartIndex[this->threadNumber_]; + size_t const numTotalEdges = edgeStartIndex[this->threadNumber_]; #else // TTK_ENABLE_OPENMP size_t numTotalEdges = numEdges[0]; #endif // TTK_ENABLE_OPENMP @@ -1007,7 +1007,7 @@ int ttk::MarchingTetrahedra::writeSeparators_3D( triangleStartIndex[t] = numTriangles[t - 1] + triangleStartIndex[t - 1]; } - size_t numTotalTriangles = triangleStartIndex[this->threadNumber_]; + size_t const numTotalTriangles = triangleStartIndex[this->threadNumber_]; #else // TTK_ENABLE_OPENMP size_t numTotalTriangles = numTriangles[0]; #endif // TTK_ENABLE_OPENMP @@ -1089,7 +1089,7 @@ int ttk::MarchingTetrahedra::writeSeparators_3D( vertPos[0], vertPos[1], vertPos[2], vertPos[3], tetCenter); // Create a hashes from all four label combinations - unsigned long long sparseMSIds[6] = { + unsigned long long const sparseMSIds[6] = { mth::getHash(label[0], label[1]), mth::getHash(label[0], label[2]), mth::getHash(label[0], label[3]), mth::getHash(label[1], label[2]), mth::getHash(label[1], label[3]), mth::getHash(label[2], label[3])}; @@ -1319,7 +1319,7 @@ int ttk::MarchingTetrahedra::writeBoundaries_3D( triangleStartIndex[t] = numTriangles[t - 1] + triangleStartIndex[t - 1]; } - size_t numTotalTriangles = triangleStartIndex[this->threadNumber_]; + size_t const numTotalTriangles = triangleStartIndex[this->threadNumber_]; #else // TTK_ENABLE_OPENMP size_t numTotalTriangles = numTriangles[0]; #endif // TTK_ENABLE_OPENMP @@ -1441,7 +1441,7 @@ int ttk::MarchingTetrahedra::writeBoundariesDetailed_3D( triangleStartIndex[t] = numTriangles[t - 1] + triangleStartIndex[t - 1]; } - size_t numTotalTriangles = triangleStartIndex[this->threadNumber_]; + size_t const numTotalTriangles = triangleStartIndex[this->threadNumber_]; #else // TTK_ENABLE_OPENMP size_t numTotalTriangles = numTriangles[0]; #endif // TTK_ENABLE_OPENMP diff --git a/core/base/mergeTreeClustering/BranchMappingDistance.h b/core/base/mergeTreeClustering/BranchMappingDistance.h index 31ba63011f..ceb9d1d932 100644 --- a/core/base/mergeTreeClustering/BranchMappingDistance.h +++ b/core/base/mergeTreeClustering/BranchMappingDistance.h @@ -201,8 +201,8 @@ namespace ttk { std::vector> predecessors1(tree1->getNumberOfNodes()); std::vector> predecessors2(tree2->getNumberOfNodes()); - int rootID1 = tree1->getRoot(); - int rootID2 = tree2->getRoot(); + int const rootID1 = tree1->getRoot(); + int const rootID2 = tree2->getRoot(); std::vector preorder1(tree1->getNumberOfNodes()); std::vector preorder2(tree2->getNumberOfNodes()); @@ -212,14 +212,14 @@ namespace ttk { stack.push(rootID1); int count = tree1->getNumberOfNodes() - 1; while(!stack.empty()) { - int nIdx = stack.top(); + int const nIdx = stack.top(); stack.pop(); preorder1[count] = nIdx; count--; depth1 = std::max((int)predecessors1[nIdx].size(), depth1); std::vector children; tree1->getChildren(nIdx, children); - for(int cIdx : children) { + for(int const cIdx : children) { stack.push(cIdx); predecessors1[cIdx].reserve(predecessors1[nIdx].size() + 1); predecessors1[cIdx].insert(predecessors1[cIdx].end(), @@ -231,14 +231,14 @@ namespace ttk { stack.push(rootID2); count = tree2->getNumberOfNodes() - 1; while(!stack.empty()) { - int nIdx = stack.top(); + int const nIdx = stack.top(); stack.pop(); preorder2[count] = nIdx; count--; depth2 = std::max((int)predecessors2[nIdx].size(), depth2); std::vector children; tree2->getChildren(nIdx, children); - for(int cIdx : children) { + for(int const cIdx : children) { stack.push(cIdx); predecessors2[cIdx].reserve(predecessors2[nIdx].size() + 1); predecessors2[cIdx].insert(predecessors2[cIdx].end(), @@ -250,10 +250,10 @@ namespace ttk { size_t nn1 = tree1->getNumberOfNodes(); size_t nn2 = tree2->getNumberOfNodes(); - size_t dim1 = 1; - size_t dim2 = (nn1 + 1) * dim1; - size_t dim3 = (depth1 + 1) * dim2; - size_t dim4 = (nn2 + 1) * dim3; + size_t const dim1 = 1; + size_t const dim2 = (nn1 + 1) * dim1; + size_t const dim3 = (depth1 + 1) * dim2; + size_t const dim4 = (nn2 + 1) * dim3; std::vector memT((nn1 + 1) * (depth1 + 1) * (nn2 + 1) * (depth2 + 1)); @@ -426,10 +426,10 @@ namespace ttk { // all possible main branches of second tree (child2_mb) Then // try all possible matchings of subtrees if(children1.size() == 2 && children2.size() == 2) { - int child11 = children1[0]; - int child12 = children1[1]; - int child21 = children2[0]; - int child22 = children2[1]; + int const child11 = children1[0]; + int const child12 = children1[1]; + int const child21 = children2[0]; + int const child22 = children2[1]; d = std::min( d, memT[child11 + (l1 + 1) * dim2 + child21 * dim3 @@ -463,8 +463,8 @@ namespace ttk { topo2_.end()); auto f = [&](unsigned r, unsigned c) { - int c1 = r < topo1_.size() ? topo1_[r] : -1; - int c2 = c < topo2_.size() ? topo2_[c] : -1; + int const c1 = r < topo1_.size() ? topo1_[r] : -1; + int const c2 = c < topo2_.size() ? topo2_[c] : -1; return memT[c1 + 1 * dim2 + c2 * dim3 + 1 * dim4]; }; int size = std::max(topo1_.size(), topo2_.size()) + 1; diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index ff44f545c5..d8d9a7f119 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -213,7 +213,7 @@ namespace ttk { double sizeLimitPercent, bool distMinimizer = true) { std::vector> distanceMatrix, distanceMatrix2; - bool useDoubleInput = (trees2.size() != 0); + bool const useDoubleInput = (trees2.size() != 0); getParametrizedDistanceMatrix(trees, distanceMatrix, barycenterMaximumNumberOfPairs, sizeLimitPercent, useDoubleInput); @@ -273,7 +273,8 @@ namespace ttk { void initBarycenterTree(std::vector &trees, ftm::MergeTree &baryTree, bool distMinimizer = true) { - int bestIndex = getBestInitTreeIndex(trees, distMinimizer); + int const bestIndex + = getBestInitTreeIndex(trees, distMinimizer); baryTree = ftm::copyMergeTree(trees[bestIndex], true); limitSizeBarycenter(baryTree, trees); } @@ -293,12 +294,12 @@ namespace ttk { int i) { // Get nodes and scalars to add std::queue> queue; - queue.emplace(std::make_tuple(nodeId2, nodeId1)); + queue.emplace(nodeId2, nodeId1); nodesToProcess.emplace_back(nodeId2, nodeId1, i); while(!queue.empty()) { auto queueTuple = queue.front(); queue.pop(); - ftm::idNode node = std::get<0>(queueTuple); + ftm::idNode const node = std::get<0>(queueTuple); // Get scalars newScalarsVector.push_back( tree2->getValue(tree2->getNode(node)->getOrigin())); @@ -307,7 +308,7 @@ namespace ttk { std::vector children; tree2->getChildren(node, children); for(auto child : children) { - queue.emplace(std::make_tuple(child, nodeCpt + 1)); + queue.emplace(child, nodeCpt + 1); nodesToProcess.emplace_back(child, nodeCpt + 1, i); } nodeCpt += 2; // we will add two nodes (birth and death) @@ -329,11 +330,11 @@ namespace ttk { nodesProcessed.clear(); nodesProcessed.resize(noTrees); for(auto processTuple : nodesToProcess) { - ftm::idNode parent = std::get<1>(processTuple); - ftm::idNode nodeTree1 = tree1->getNumberOfNodes(); - int index = std::get<2>(processTuple); - nodesProcessed[index].push_back( - std::make_tuple(nodeTree1 + 1, std::get<0>(processTuple))); + ftm::idNode const parent = std::get<1>(processTuple); + ftm::idNode const nodeTree1 = tree1->getNumberOfNodes(); + int const index = std::get<2>(processTuple); + nodesProcessed[index].emplace_back( + nodeTree1 + 1, std::get<0>(processTuple)); // Make node and its origin tree1->makeNode(nodeTree1); tree1->makeNode(nodeTree1 + 1); @@ -376,7 +377,7 @@ namespace ttk { std::vector>> &matchings) { ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); - ftm::idNode baryTreeRoot = baryTree->getRoot(); + ftm::idNode const baryTreeRoot = baryTree->getRoot(); // Init matching matrix // m[i][j] contains the node in the barycenter matched to the jth node of @@ -396,11 +397,11 @@ namespace ttk { // Iterate through trees to get the nodes to add in the barycenter std::vector> nodesToAdd(trees.size()); for(unsigned int i = 0; i < trees.size(); ++i) { - ftm::idNode root = trees[i]->getRoot(); + ftm::idNode const root = trees[i]->getRoot(); std::queue queue; queue.emplace(root); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); bool processChildren = true; // if node in trees[i] is not matched @@ -545,7 +546,7 @@ namespace ttk { tempDeath += tTempDeath * alphas[i] / alphaSum; } } - double projec = (tempBirth + tempDeath) / 2; + double const projec = (tempBirth + tempDeath) / 2; // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { @@ -585,7 +586,7 @@ namespace ttk { auto birthDeath = getParametrizedBirthDeath(tree, nodeId); double newBirth = std::get<0>(birthDeath); double newDeath = std::get<1>(birthDeath); - double projec = (newBirth + newDeath) / 2; + double const projec = (newBirth + newDeath) / 2; newBirth = alpha * newBirth + (1 - alpha) * projec; newDeath = alpha * newDeath + (1 - alpha) * projec; @@ -609,7 +610,7 @@ namespace ttk { std::vector>> &matchings) { ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); - bool isJT = baryTree->isJoinTree(); + bool const isJT = baryTree->isJoinTree(); // Init matching matrix // m[i][j] contains the node in trees[j] matched to the node i in the @@ -631,11 +632,11 @@ namespace ttk { // Interpolate scalars std::vector newScalarsVector(baryTree->getNumberOfNodes()); - ftm::idNode root = baryTree->getRoot(); + ftm::idNode const root = baryTree->getRoot(); std::queue queue; queue.emplace(root); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); std::tuple newBirthDeath; if(node < indexAddedNodes) { @@ -643,8 +644,8 @@ namespace ttk { = interpolation(baryMergeTree, node, newScalarsVector, trees, baryMatching[node], alphas); } else { - int i = nodesAddedTree[node]; - ftm::idNode nodeT = baryMatching[node][i]; + int const i = nodesAddedTree[node]; + ftm::idNode const nodeT = baryMatching[node][i]; newBirthDeath = interpolationAdded( trees[i], nodeT, alphas[i], baryMergeTree, node, newScalarsVector); } @@ -687,7 +688,7 @@ namespace ttk { std::vector &alphas, std::vector>> &matchings) { - int indexAddedNodes = baryMergeTree.tree.getNumberOfNodes(); + int const indexAddedNodes = baryMergeTree.tree.getNumberOfNodes(); updateBarycenterTreeStructure(trees, baryMergeTree, matchings); updateBarycenterTreeScalars( trees, baryMergeTree, alphas, indexAddedNodes, matchings); @@ -718,7 +719,7 @@ namespace ttk { mergeTreeDistance.setDistanceSquaredRoot(true); // squared root mergeTreeDistance.setNodePerTask(nodePerTask_); if(useDoubleInput) { - double weight = mixDistancesMinMaxPairWeight(isFirstInput); + double const weight = mixDistancesMinMaxPairWeight(isFirstInput); mergeTreeDistance.setMinMaxPairWeight(weight); } /*if(progressiveBarycenter_){ @@ -842,7 +843,7 @@ namespace ttk { double persistenceThreshold = 50.0; if(iterationNumber != -1) { // Get number of pairs in scaled merge tree - int noPairs = mergeTrees[i].tree.getRealNumberOfNodes(); + int const noPairs = mergeTrees[i].tree.getRealNumberOfNodes(); // Get pairs in original merge tree std::vector> pairs; @@ -850,10 +851,11 @@ namespace ttk { pairs, branchDecomposition_); // Compute new persistence threshold - double multiplier = (progressiveSpeedDivisor_ < 1e-6 - ? 1. - : iterationNumber / progressiveSpeedDivisor_); - int decrement = multiplier * pairs.size() / 10; + double const multiplier + = (progressiveSpeedDivisor_ < 1e-6 + ? 1. + : iterationNumber / progressiveSpeedDivisor_); + int const decrement = multiplier * pairs.size() / 10; int thresholdIndex = pairs.size() - noPairs - std::max(decrement, 2); thresholdIndex = std::max(thresholdIndex, 0); const double persistence = std::get<2>(pairs[thresholdIndex]); @@ -990,7 +992,7 @@ namespace ttk { // --- Persistence scaling if(progressiveBarycenter_) { - unsigned int noTreesUnscaled = persistenceScaling( + unsigned int const noTreesUnscaled = persistenceScaling( trees, scaledMergeTrees, oriTrees, NoIteration, deletedNodes); treesUnscaled = (noTreesUnscaled == oriTrees.size()); } @@ -1060,7 +1062,7 @@ namespace ttk { // --- Postprocessing if(postprocess_) { - std::vector allRealNodes(trees.size()); + std::vector const allRealNodes(trees.size()); for(unsigned int i = 0; i < trees.size(); ++i) { postprocessingPipeline(treesT[i]); } @@ -1104,10 +1106,10 @@ namespace ttk { double percent, bool useBD) { auto metric = getSizeLimitMetric(trees); - unsigned int newNoNodes = metric * percent / 100.0; + unsigned int const newNoNodes = metric * percent / 100.0; keepMostImportantPairs(&(bary.tree), newNoNodes, useBD); - unsigned int noNodesAfter = bary.tree.getRealNumberOfNodes(); + unsigned int const noNodesAfter = bary.tree.getRealNumberOfNodes(); if(bary.tree.isFullMerge() and noNodesAfter > newNoNodes * 1.1 + 1 and noNodesAfter > 3) { std::cout << "metric = " << metric << std::endl; @@ -1158,7 +1160,7 @@ namespace ttk { dataType oldOriginValue = std::get<1>(tup); // Verify that scalars are consistent - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); std::vector newScalarsVector; ftm::getTreeScalars(tree, newScalarsVector); bool isJT = tree->isJoinTree(); diff --git a/core/base/mergeTreeClustering/MergeTreeBase.h b/core/base/mergeTreeClustering/MergeTreeBase.h index b28024334b..2e49b35000 100644 --- a/core/base/mergeTreeClustering/MergeTreeBase.h +++ b/core/base/mergeTreeClustering/MergeTreeBase.h @@ -211,7 +211,7 @@ namespace ttk { maxValue = (maxValue < iValue) ? iValue : maxValue; minValue = (minValue > iValue) ? iValue : minValue; } else { - ftm::idNode parent = tree->getParentSafe(i); + ftm::idNode const parent = tree->getParentSafe(i); dataType parentValue = tree->getValue(parent); dataType tempMax = std::max(iValue, parentValue); dataType tempMin = std::min(iValue, parentValue); @@ -222,7 +222,7 @@ namespace ttk { } } } - double epsilonOri = epsilon; + double const epsilonOri = epsilon; epsilon = (maxValue - minValue) * epsilon / 100; // For Farthest Saddle option @@ -246,7 +246,7 @@ namespace ttk { std::queue queue; queue.emplace(tree->getRoot()); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); nodeStack.emplace(node); std::vector children; @@ -256,10 +256,10 @@ namespace ttk { } // Iterate through nodes while(!nodeStack.empty()) { - ftm::idNode nodeId = nodeStack.top(); + ftm::idNode const nodeId = nodeStack.top(); nodeStack.pop(); if(!tree->isRoot(nodeId) and !tree->isLeaf(nodeId)) { - ftm::idNode parentNodeId = tree->getParentSafe(nodeId); + ftm::idNode const parentNodeId = tree->getParentSafe(nodeId); dataType nodeValue = tree->getValue(nodeId); if(epsilon1UseFarthestSaddle_) nodeValue = tree->getValue(farthestSaddle[nodeId]); @@ -321,9 +321,9 @@ namespace ttk { std::queue queue; queue.emplace(tree->getRoot()); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); - ftm::idNode nodeParent = tree->getParentSafe(node); + ftm::idNode const nodeParent = tree->getParentSafe(node); if(!tree->isRoot(node)) { const double nodePers = tree->getNodePersistence(node); const double nodeParentPers @@ -352,7 +352,7 @@ namespace ttk { std::vector> pairs; tree->getPersistencePairsFromTree(pairs, useBD); n = std::max(n, 2); // keep at least 2 pairs - int index = std::max((int)(pairs.size() - n), 0); + int const index = std::max((int)(pairs.size() - n), 0); dataType threshold = std::get<2>(pairs[index]) * (1.0 - 1e-6) / tree->getMaximumPersistence() * 100.0; persistenceThresholding(tree, threshold); @@ -362,7 +362,7 @@ namespace ttk { void persistenceThresholding(ftm::FTMTree_MT *tree, double persistenceThresholdT, std::vector &deletedNodes) { - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); dataType maxPers = tree->getMaximumPersistence(); dataType threshold = persistenceThresholdT / 100 * maxPers; @@ -384,7 +384,7 @@ namespace ttk { or not tree->isNodeOriginDefined(i))) { tree->deleteNode(i); deletedNodes.push_back(i); - ftm::idNode nodeOrigin = tree->getNode(i)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(i)->getOrigin(); if(tree->isNodeOriginDefined(i) and tree->getNode(nodeOrigin)->getOrigin() == (int)i) { tree->deleteNode(nodeOrigin); @@ -476,11 +476,11 @@ namespace ttk { std::vector> &treeNodeMerged) { ftm::FTMTree_MT *treeNew = tree; - ftm::idNode root = treeNew->getRoot(); + ftm::idNode const root = treeNew->getRoot(); // Manage when there is only one pair if(tree->isThereOnlyOnePersistencePair()) { - ftm::idNode rootOrigin = treeNew->getNode(root)->getOrigin(); + ftm::idNode const rootOrigin = treeNew->getNode(root)->getOrigin(); treeNew->getNode(rootOrigin)->setOrigin(rootOrigin); return treeNew; } @@ -494,9 +494,9 @@ namespace ttk { std::queue queueNodes; queueNodes.emplace(root); while(!queueNodes.empty()) { - ftm::idNode node = queueNodes.front(); + ftm::idNode const node = queueNodes.front(); queueNodes.pop(); - ftm::idNode nodeOrigin = treeNew->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = treeNew->getNode(node)->getOrigin(); if(node == nodeOrigin or treeNew->getNodeLevel(node) > treeNew->getNodeLevel(nodeOrigin)) continue; @@ -519,8 +519,8 @@ namespace ttk { // Process each origin for(auto stackTuple : vecOrigins) { - ftm::idNode nodeOriginT = std::get<0>(stackTuple); - int nodeOriginTID = std::get<1>(stackTuple); + ftm::idNode const nodeOriginT = std::get<0>(stackTuple); + int const nodeOriginTID = std::get<1>(stackTuple); if(nodeDone[nodeOriginT] and nodeDone[tree->getNode(nodeOriginT)->getOrigin()]) continue; @@ -541,7 +541,7 @@ namespace ttk { // Set nodes in the branch as childrens of the node ftm::idNode parentNodeOrigin = treeNew->getParentSafe(nodeOriginT); while(parentNodeOrigin != node) { - ftm::idNode oldParentNodeOrigin + ftm::idNode const oldParentNodeOrigin = treeNew->getParentSafe(parentNodeOrigin); treeNew->setParent(parentNodeOrigin, newParent); parentNodeOrigin = oldParentNodeOrigin; @@ -558,7 +558,7 @@ namespace ttk { // Push childrens of the node to the stack to process them std::vector childrenNode; treeNew->getChildren(newParent, childrenNode); - for(ftm::idNode children : childrenNode) + for(ftm::idNode const children : childrenNode) if(!treeNew->isLeaf(children)) queueNodes.emplace(children); } @@ -572,10 +572,11 @@ namespace ttk { template void dontUseMinMaxPair(ftm::FTMTree_MT *tree) { - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); // Full merge case, search for the origin if(tree->getNode(treeRoot)->getOrigin() == (int)treeRoot) { - ftm::idNode nodeIdToDelete = tree->getMergedRootOrigin(); + ftm::idNode const nodeIdToDelete + = tree->getMergedRootOrigin(); if(nodeIdToDelete != treeRoot and not tree->isNodeIdInconsistent(nodeIdToDelete)) { if(tree->isThereOnlyOnePersistencePair()) @@ -585,7 +586,7 @@ namespace ttk { } // Classic case } else { - ftm::idNode rootOrigin = tree->getNode(treeRoot)->getOrigin(); + ftm::idNode const rootOrigin = tree->getNode(treeRoot)->getOrigin(); if(tree->isThereOnlyOnePersistencePair()) tree->getNode(rootOrigin)->setOrigin(rootOrigin); else @@ -730,7 +731,7 @@ namespace ttk { std::array stats; getTreesStats(trees, stats); auto meanNodes = stats[0]; - unsigned int n = trees.size(); + unsigned int const n = trees.size(); return meanNodes * n; } @@ -788,7 +789,7 @@ namespace ttk { int maxIndex = tree->getMergedRootOrigin(); // Link node of the min max pair with the root - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); dataType oldOriginValue = tree->getValue(tree->getNode(maxIndex)->getOrigin()); tree->getNode(maxIndex)->setOrigin(treeRoot); @@ -800,26 +801,27 @@ namespace ttk { // but not its brothers template void branchDecompositionToTree(ftm::FTMTree_MT *tree) { - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); // Get original tree message - std::stringstream oriPrintTree = tree->printTree(); - std::stringstream oriPrintPairs + std::stringstream const oriPrintTree = tree->printTree(); + std::stringstream const oriPrintPairs = tree->printPairsFromTree(true); - std::stringstream oriPrintMultiPers + std::stringstream const oriPrintMultiPers = tree->printMultiPersPairsFromTree(true); // One pair case if(tree->isThereOnlyOnePersistencePair()) { - ftm::idNode treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); + ftm::idNode const treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); tree->getNode(treeRootOrigin)->setOrigin(treeRoot); return; } // Manage full merge and dontuseMinMaxPair_ - bool isFM = tree->isFullMerge(); + bool const isFM = tree->isFullMerge(); if(isFM) { - ftm::idNode mergedRootOrigin = tree->getMergedRootOrigin(); + ftm::idNode const mergedRootOrigin + = tree->getMergedRootOrigin(); if(not tree->isNodeIdInconsistent(mergedRootOrigin) and mergedRootOrigin != treeRoot) tree->getNode(treeRoot)->setOrigin(mergedRootOrigin); @@ -882,16 +884,16 @@ namespace ttk { for(unsigned int i = 1; i < children.size(); ++i) { if(tree->isMultiPersPair(children[i])) continue; - int index = getIndexNotMultiPers(i - 1, tree, children); + int const index = getIndexNotMultiPers(i - 1, tree, children); if(index >= 0) nodeParent.emplace_back(children[i], children[index]); } - bool multiPersPair + bool const multiPersPair = tree->getNode(nodeOrigin)->getOrigin() != (int)node; if(not multiPersPair) { if(not isFM) { - int index + int const index = getIndexNotMultiPers(children.size() - 1, tree, children); nodeParent.emplace_back(nodeOrigin, children[index]); } else @@ -944,9 +946,9 @@ namespace ttk { std::queue queue; queue.emplace(tree->getRoot()); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); if(!tree->isLeaf(node)) { std::vector children; tree->getChildren(node, children); @@ -955,7 +957,7 @@ namespace ttk { for(auto child : children) { ftm::idNode lowestNode = tree->getLowestNode(child); lowestNodes.push_back(lowestNode); - ftm::idNode lowestNodeOrigin + ftm::idNode const lowestNodeOrigin = tree->getNode(lowestNode)->getOrigin(); if(not tree->isNodeAlone(lowestNodeOrigin) and lowestNodeOrigin != node) @@ -969,7 +971,8 @@ namespace ttk { dataType lowestNodeOriginVal = tree->getValue(lowestNodeOrigin); ftm::idNode branchOriginT = branchOrigin; - ftm::idNode branchRoot = tree->getNode(branchOrigin)->getOrigin(); + ftm::idNode const branchRoot + = tree->getNode(branchOrigin)->getOrigin(); while(branchRoot != branchOriginT) { dataType val = tree->getValue(tree->getParentSafe(branchOriginT)); @@ -1021,24 +1024,24 @@ namespace ttk { &outputMatching) { std::vector> toAdd; for(auto mTuple : outputMatching) { - ftm::idNode node1 = std::get<0>(mTuple); - ftm::idNode node2 = std::get<1>(mTuple); - double cost = std::get<2>(mTuple); - ftm::idNode node1Origin = tree1->getNode(node1)->getOrigin(); - ftm::idNode node2Origin = tree2->getNode(node2)->getOrigin(); - - int node1Level = tree1->getNodeLevel(node1); - int node1OriginLevel = tree1->getNodeLevel(node1Origin); - int node2Level = tree2->getNodeLevel(node2); - int node2OriginLevel = tree2->getNodeLevel(node2Origin); - - ftm::idNode node1Higher + ftm::idNode const node1 = std::get<0>(mTuple); + ftm::idNode const node2 = std::get<1>(mTuple); + double const cost = std::get<2>(mTuple); + ftm::idNode const node1Origin = tree1->getNode(node1)->getOrigin(); + ftm::idNode const node2Origin = tree2->getNode(node2)->getOrigin(); + + int const node1Level = tree1->getNodeLevel(node1); + int const node1OriginLevel = tree1->getNodeLevel(node1Origin); + int const node2Level = tree2->getNodeLevel(node2); + int const node2OriginLevel = tree2->getNodeLevel(node2Origin); + + ftm::idNode const node1Higher = (node1Level > node1OriginLevel) ? node1 : node1Origin; - ftm::idNode node1Lower + ftm::idNode const node1Lower = (node1Level > node1OriginLevel) ? node1Origin : node1; - ftm::idNode node2Higher + ftm::idNode const node2Higher = (node2Level > node2OriginLevel) ? node2 : node2Origin; - ftm::idNode node2Lower + ftm::idNode const node2Lower = (node2Level > node2OriginLevel) ? node2Origin : node2; if(((tree1->isRoot(node1Higher) and tree1->isFullMerge()) @@ -1280,7 +1283,7 @@ namespace ttk { std::array stats; getTreesStats(trees, stats); int avgNodes = stats[0], avgNodesT = stats[1]; - double avgDepth = stats[2]; + double const avgDepth = stats[2]; std::stringstream ss; ss << trees.size() << " trees average [node: " << avgNodes << " / " << avgNodesT << ", depth: " << avgDepth << "]"; @@ -1296,7 +1299,7 @@ namespace ttk { template void printTableVector(std::vector> &table) { - std::streamsize ssize = std::cout.precision(); + std::streamsize const ssize = std::cout.precision(); std::stringstream ss; ss << " "; for(unsigned int j = 0; j < table[0].size(); ++j) @@ -1363,7 +1366,7 @@ namespace ttk { void printPairs( std::vector> &treePairs) { for(auto pair : treePairs) { - std::stringstream ss; + std::stringstream const ss; ss << std::get<0>(pair) << " _ " << std::get<1>(pair) << " _ " << std::get<2>(pair); printMsg(ss.str()); diff --git a/core/base/mergeTreeClustering/MergeTreeClustering.h b/core/base/mergeTreeClustering/MergeTreeClustering.h index 7c7aed7c52..a1521f991e 100644 --- a/core/base/mergeTreeClustering/MergeTreeClustering.h +++ b/core/base/mergeTreeClustering/MergeTreeClustering.h @@ -197,7 +197,7 @@ namespace ttk { for(unsigned int i = 0; i < bestDistance_.size(); ++i) distancesAndIndexes[i] = std::make_tuple(-bestDistance_[i], i); std::sort(distancesAndIndexes.begin(), distancesAndIndexes.end()); - int bestIndex = std::get<1>(distancesAndIndexes[noNewCentroid]); + int const bestIndex = std::get<1>(distancesAndIndexes[noNewCentroid]); centroid = ftm::copyMergeTree(trees[bestIndex], true); limitSizeBarycenter(centroid, trees); ftm::cleanMergeTree(centroid); @@ -448,7 +448,7 @@ namespace ttk { distances[j] = mixDistances(distances[j], distances2[j]); } for(unsigned int j = 0; j < assignedTreesIndex[i].size(); ++j) { - int index = assignedTreesIndex[i][j]; + int const index = assignedTreesIndex[i][j]; bestDistanceT[index] = distances[j]; } } @@ -510,7 +510,7 @@ namespace ttk { void matchingCorrespondence(treesMatchingVector &matchingT, std::vector &nodeCorr, std::vector &assignedTreesIndex) { - for(int i : assignedTreesIndex) { + for(int const i : assignedTreesIndex) { std::vector> newMatching; for(auto tup : matchingT[i]) newMatching.emplace_back( @@ -738,8 +738,8 @@ namespace ttk { // Manage output std::vector cptCentroid(centroids.size(), 0); for(auto asgn : assignmentC) { - int centroid = std::get<0>(asgn); - int tree = std::get<1>(asgn); + int const centroid = std::get<0>(asgn); + int const tree = std::get<1>(asgn); // std::cout << centroid << " " << tree << std::endl; clusteringAssignment[tree] = centroid; outputMatching[centroid][tree] diff --git a/core/base/mergeTreeClustering/MergeTreeDistance.h b/core/base/mergeTreeClustering/MergeTreeDistance.h index eebfa57e80..596615416b 100644 --- a/core/base/mergeTreeClustering/MergeTreeDistance.h +++ b/core/base/mergeTreeClustering/MergeTreeDistance.h @@ -126,10 +126,10 @@ namespace ttk { AssignmentMunkres solverMunkres; AssignmentAuction solverAuction; - int nRows = costMatrix.size() - 1; - int nCols = costMatrix[0].size() - 1; - int max_dim = std::max(nRows, nCols); - int min_dim = std::min(nRows, nCols); + int const nRows = costMatrix.size() - 1; + int const nCols = costMatrix[0].size() - 1; + int const max_dim = std::max(nRows, nCols); + int const min_dim = std::min(nRows, nCols); int assignmentSolverID = assignmentSolverID_; if((min_dim <= 2 and max_dim <= 2) or (min_dim <= 1 and max_dim <= 6)) @@ -164,9 +164,9 @@ namespace ttk { std::vector> &costMatrix) { unsigned int nRows = children1.size(), nCols = children2.size(); for(unsigned int i = 0; i < nRows; ++i) { - int forestTableI = children1[i] + 1; + int const forestTableI = children1[i] + 1; for(unsigned int j = 0; j < nCols; ++j) { - int forestTableJ = children2[j] + 1; + int const forestTableJ = children2[j] + 1; // Cost of assigning i and j costMatrix[i][j] = treeTable[forestTableI][forestTableJ]; if(tree1Level_[children1[i]] != tree2Level_[children2[j]] @@ -177,7 +177,7 @@ namespace ttk { costMatrix[i][nCols] = treeTable[forestTableI][0]; } for(unsigned int j = 0; j < nCols; ++j) { - int forestTableJ = children2[j] + 1; + int const forestTableJ = children2[j] + 1; // Cost of not assigning j costMatrix[nRows][j] = treeTable[0][forestTableJ]; } @@ -196,8 +196,8 @@ namespace ttk { if(std::get<0>(mTuple) >= (int)children1.size() || std::get<1>(mTuple) >= (int)children2.size()) continue; - int tableId1 = children1[std::get<0>(mTuple)] + 1; - int tableId2 = children2[std::get<1>(mTuple)] + 1; + int const tableId1 = children1[std::get<0>(mTuple)] + 1; + int const tableId2 = children2[std::get<1>(mTuple)] + 1; forestAssignment.emplace_back(tableId1, tableId2); } return cost; @@ -307,7 +307,7 @@ namespace ttk { std::vector children; tree1->getChildren(nodeI, children); forestTable[i][0] = 0; - for(ftm::idNode child : children) + for(ftm::idNode const child : children) forestTable[i][0] += treeTable[child + 1][0]; } @@ -331,7 +331,7 @@ namespace ttk { std::vector children; tree2->getChildren(nodeJ, children); forestTable[0][j] = 0; - for(ftm::idNode child : children) + for(ftm::idNode const child : children) forestTable[0][j] += treeTable[0][child + 1]; } @@ -437,23 +437,23 @@ namespace ttk { int startC) { outputMatching.clear(); std::queue> backQueue; - backQueue.emplace(std::make_tuple(startR, startC, true)); + backQueue.emplace(startR, startC, true); while(!backQueue.empty()) { std::tuple elem = backQueue.front(); backQueue.pop(); bool useTreeTable = std::get<2>(elem); - int i = std::get<0>(elem); - int j = std::get<1>(elem); + int const i = std::get<0>(elem); + int const j = std::get<1>(elem); if(useTreeTable) { - int tupleI = std::get<0>(treeBackTable[i][j]); - int tupleJ = std::get<1>(treeBackTable[i][j]); + int const tupleI = std::get<0>(treeBackTable[i][j]); + int const tupleJ = std::get<1>(treeBackTable[i][j]); if(tupleI != 0 && tupleJ != 0) { useTreeTable = (tupleI != i || tupleJ != j); - backQueue.emplace(std::make_tuple(tupleI, tupleJ, useTreeTable)); + backQueue.emplace(tupleI, tupleJ, useTreeTable); if(not useTreeTable) { // We have matched i and j - ftm::idNode tree1Node = tupleI - 1; - ftm::idNode tree2Node = tupleJ - 1; + ftm::idNode const tree1Node = tupleI - 1; + ftm::idNode const tree2Node = tupleJ - 1; double cost = 0; dataType costT = relabelCost(tree1, tree1Node, tree2, tree2Node); @@ -463,11 +463,11 @@ namespace ttk { } } else { for(std::tuple forestBackElem : forestBackTable[i][j]) { - int tupleI = std::get<0>(forestBackElem); - int tupleJ = std::get<1>(forestBackElem); + int const tupleI = std::get<0>(forestBackElem); + int const tupleJ = std::get<1>(forestBackElem); if(tupleI != 0 && tupleJ != 0) { useTreeTable = (tupleI != i && tupleJ != j); - backQueue.emplace(std::make_tuple(tupleI, tupleJ, useTreeTable)); + backQueue.emplace(tupleI, tupleJ, useTreeTable); } } } @@ -486,8 +486,8 @@ namespace ttk { // --------------------- // ----- Init dynamic programming tables // -------------------- - size_t nRows = tree1->getNumberOfNodes() + 1; - size_t nCols = tree2->getNumberOfNodes() + 1; + size_t const nRows = tree1->getNumberOfNodes() + 1; + size_t const nCols = tree2->getNumberOfNodes() + 1; std::vector> treeTable( nRows, std::vector(nCols)); std::vector> forestTable( @@ -500,8 +500,8 @@ namespace ttk { forestBackTable( nRows, std::vector>>(nCols)); - int indR = tree1->getRoot() + 1; - int indC = tree2->getRoot() + 1; + int const indR = tree1->getRoot() + 1; + int const indC = tree2->getRoot() + 1; tree1->getAllNodeLevel(tree1Level_); tree2->getAllNodeLevel(tree2Level_); @@ -725,7 +725,7 @@ namespace ttk { if(processTree1) { if(computeEmptyTree) { - int i = nodeI + 1; + int const i = nodeI + 1; // --- Forest to empty tree distance computeForestToEmptyDistance(tree1, nodeI, i, treeTable, forestTable); @@ -737,7 +737,7 @@ namespace ttk { tree2->getRoot(), treeTable, forestTable, treeBackTable, forestBackTable, nRows, nCols); } else { - int j = nodeJ + 1; + int const j = nodeJ + 1; if(computeEmptyTree) { // --- Empty tree to forest distance computeEmptyToForestDistance(tree2, nodeJ, j, treeTable, forestTable); @@ -747,7 +747,7 @@ namespace ttk { tree2, nodeJ, j, treeTable, forestTable); //}else{ } else if(keepSubtree_ or tree1Level_[nodeI] == tree2Level_[nodeJ]) { - int i = nodeI + 1; + int const i = nodeI + 1; std::vector children1; tree1->getChildren(nodeI, children1); std::vector children2; @@ -830,20 +830,20 @@ namespace ttk { std::vector>>> &forestBackTable, bool firstCall = false) { - ftm::idNode nodeT = -1; + ftm::idNode const nodeT = -1; ftm::FTMTree_MT *treeT = (isTree1) ? tree1 : tree2; std::vector treeChildDone(treeT->getNumberOfNodes(), 0); std::vector treeNodeDone(treeT->getNumberOfNodes(), false); std::queue treeQueue; if(isTree1) - for(ftm::idNode leaf : tree1Leaves) + for(ftm::idNode const leaf : tree1Leaves) treeQueue.emplace(leaf); else if(keepSubtree_) - for(ftm::idNode leaf : tree2Leaves) + for(ftm::idNode const leaf : tree2Leaves) treeQueue.emplace(leaf); else if(tree1Level_[i - 1] < (int)tree2LevelToNode_.size()) - for(ftm::idNode node : tree2LevelToNode_[tree1Level_[i - 1]]) + for(ftm::idNode const node : tree2LevelToNode_[tree1Level_[i - 1]]) treeQueue.emplace(node); if(not isCalled_) // and firstCall) @@ -938,8 +938,8 @@ namespace ttk { while(!taskQueue.empty()) { nodeT = taskQueue.front(); taskQueue.pop(); - int t = nodeT + 1; - ftm::idNode nodeI = i - 1; + int const t = nodeT + 1; + ftm::idNode const nodeI = i - 1; if(isTree1) { parallelTreeDistance_v2( @@ -949,7 +949,7 @@ namespace ttk { //}else{ } else if(keepSubtree_ or tree1Level_[nodeI] == tree2Level_[nodeT]) { - int j = nodeT + 1; + int const j = nodeT + 1; std::vector children1; tree1->getChildren(nodeI, children1); std::vector children2; @@ -969,9 +969,9 @@ namespace ttk { continue; // Manage parent - ftm::idNode nodeTParent = treeT->getParentSafe(nodeT); - int childSize = (isTree1) ? tree1NodeChildSize[nodeTParent] - : tree2NodeChildSize[nodeTParent]; + ftm::idNode const nodeTParent = treeT->getParentSafe(nodeT); + int const childSize = (isTree1) ? tree1NodeChildSize[nodeTParent] + : tree2NodeChildSize[nodeTParent]; int oldTreeChildDone; #ifdef TTK_ENABLE_OPENMP #pragma omp atomic capture @@ -1015,11 +1015,11 @@ namespace ttk { std::vector>> &treeBackTable, std::vector>>> &forestBackTable) { - ftm::idNode nodeT = -1; + ftm::idNode const nodeT = -1; std::vector treeChildDone(tree->getNumberOfNodes(), 0); std::vector treeNodeDone(tree->getNumberOfNodes(), false); std::queue treeQueue; - for(ftm::idNode leaf : treeLeaves) + for(ftm::idNode const leaf : treeLeaves) treeQueue.emplace(leaf); if(not isCalled_) parallelEmptyTreeDistancePara(tree, isTree1, treeLeaves, @@ -1089,7 +1089,7 @@ namespace ttk { #endif while((int)nodeT != -1) { if(isTree1) { - int i = nodeT + 1; + int const i = nodeT + 1; // --- Forest to empty tree distance computeForestToEmptyDistance( tree, nodeT, i, treeTable, forestTable); @@ -1098,7 +1098,7 @@ namespace ttk { computeSubtreeToEmptyDistance( tree, nodeT, i, treeTable, forestTable); } else { - int j = nodeT + 1; + int const j = nodeT + 1; // --- Empty tree to forest distance computeEmptyToForestDistance( tree, nodeT, j, treeTable, forestTable); @@ -1109,7 +1109,7 @@ namespace ttk { } // Manage parent - ftm::idNode nodeTParent = tree->getParentSafe(nodeT); + ftm::idNode const nodeTParent = tree->getParentSafe(nodeT); int oldTreeChildDone; #ifdef TTK_ENABLE_OPENMP #pragma omp atomic capture @@ -1159,12 +1159,12 @@ namespace ttk { void verifyMergeTreeStructure(ftm::FTMTree_MT *tree) { bool problem = false; - bool isJT = tree->isJoinTree(); + bool const isJT = tree->isJoinTree(); std::vector> problemNodes; std::queue queue; queue.emplace(tree->getRoot()); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); if(!tree->isRoot(node)) { @@ -1212,7 +1212,7 @@ namespace ttk { tree2->getPersistencePairsFromTree(pairs2); std::vector> costMatrix( pairs1.size() + 1, std::vector(pairs2.size() + 1)); - std::stringstream ss; + std::stringstream const ss; ss << costMatrix.size() << " _ " << costMatrix[0].size(); printMsg(ss.str()); for(unsigned int i = 0; i < costMatrix.size() - 1; ++i) { diff --git a/core/base/mergeTreeClustering/PathMappingDistance.h b/core/base/mergeTreeClustering/PathMappingDistance.h index cae9a10642..31e5ebeba3 100644 --- a/core/base/mergeTreeClustering/PathMappingDistance.h +++ b/core/base/mergeTreeClustering/PathMappingDistance.h @@ -97,20 +97,20 @@ namespace ttk { int parent1 = predecessors1[curr1][predecessors1[curr1].size() - l1]; int parent2 = predecessors2[curr2][predecessors2[curr2].size() - l2]; - size_t nn1 = tree1->getNumberOfNodes(); - size_t nn2 = tree2->getNumberOfNodes(); - size_t dim1 = 1; - size_t dim2 = (nn1 + 1) * dim1; - size_t dim3 = (depth1 + 1) * dim2; - size_t dim4 = (nn2 + 1) * dim3; + size_t const nn1 = tree1->getNumberOfNodes(); + size_t const nn2 = tree2->getNumberOfNodes(); + size_t const dim1 = 1; + size_t const dim2 = (nn1 + 1) * dim1; + size_t const dim3 = (depth1 + 1) * dim2; + size_t const dim4 = (nn2 + 1) * dim3; //--------------------------------------------------------------------------- // If both trees only have one branch, return edit cost between // the two branches if(tree1->getNumberOfChildren(curr1) == 0 and tree2->getNumberOfChildren(curr2) == 0) { - mapping.emplace_back(std::make_pair( - std::make_pair(curr1, parent1), std::make_pair(curr2, parent2))); + mapping.emplace_back( + std::make_pair(curr1, parent1), std::make_pair(curr2, parent2)); return; } //--------------------------------------------------------------------------- @@ -176,8 +176,8 @@ namespace ttk { + memT[child12 + 1 * dim2 + child22 * dim3 + 1 * dim4] + editCost_Persistence( curr1, parent1, curr2, parent2, tree1, tree2)) { - mapping.emplace_back(std::make_pair( - std::make_pair(curr1, parent1), std::make_pair(curr2, parent2))); + mapping.emplace_back( + std::make_pair(curr1, parent1), std::make_pair(curr2, parent2)); traceMapping_path(tree1, tree2, child11, 1, child21, 1, predecessors1, predecessors2, depth1, depth2, memT, mapping); @@ -190,8 +190,8 @@ namespace ttk { + memT[child12 + 1 * dim2 + child21 * dim3 + 1 * dim4] + editCost_Persistence( curr1, parent1, curr2, parent2, tree1, tree2)) { - mapping.emplace_back(std::make_pair( - std::make_pair(curr1, parent1), std::make_pair(curr2, parent2))); + mapping.emplace_back( + std::make_pair(curr1, parent1), std::make_pair(curr2, parent2)); traceMapping_path(tree1, tree2, child11, 1, child22, 1, predecessors1, predecessors2, depth1, depth2, memT, mapping); @@ -202,12 +202,12 @@ namespace ttk { } } else { auto f = [&](int r, int c) { - size_t c1 + size_t const c1 = r < tree1->getNumberOfChildren(curr1) ? children1[r] : nn1; - size_t c2 + size_t const c2 = c < tree2->getNumberOfChildren(curr2) ? children2[c] : nn2; - int l1_ = c1 == nn1 ? 0 : 1; - int l2_ = c2 == nn2 ? 0 : 1; + int const l1_ = c1 == nn1 ? 0 : 1; + int const l2_ = c2 == nn2 ? 0 : 1; return memT[c1 + l1_ * dim2 + c2 * dim3 + l2_ * dim4]; }; int size = std::max(tree1->getNumberOfChildren(curr1), @@ -248,8 +248,8 @@ namespace ttk { for(auto m : matching) d_ += std::get<2>(m); if(memT[curr1 + l1 * dim2 + curr2 * dim3 + l2 * dim4] == d_) { - mapping.emplace_back(std::make_pair( - std::make_pair(curr1, parent1), std::make_pair(curr2, parent2))); + mapping.emplace_back( + std::make_pair(curr1, parent1), std::make_pair(curr2, parent2)); for(auto m : matching) { int n1 = std::get<0>(m) < tree1->getNumberOfChildren(curr1) ? children1[std::get<0>(m)] @@ -338,8 +338,8 @@ namespace ttk { std::vector> predecessors1(tree1->getNumberOfNodes()); std::vector> predecessors2(tree2->getNumberOfNodes()); - int rootID1 = tree1->getRoot(); - int rootID2 = tree2->getRoot(); + int const rootID1 = tree1->getRoot(); + int const rootID2 = tree2->getRoot(); std::vector preorder1(tree1->getNumberOfNodes()); std::vector preorder2(tree2->getNumberOfNodes()); @@ -349,14 +349,14 @@ namespace ttk { stack.push(rootID1); int count = tree1->getNumberOfNodes() - 1; while(!stack.empty()) { - int nIdx = stack.top(); + int const nIdx = stack.top(); stack.pop(); preorder1[count] = nIdx; count--; depth1 = std::max((int)predecessors1[nIdx].size(), depth1); std::vector children; tree1->getChildren(nIdx, children); - for(int cIdx : children) { + for(int const cIdx : children) { stack.push(cIdx); predecessors1[cIdx].reserve(predecessors1[nIdx].size() + 1); predecessors1[cIdx].insert(predecessors1[cIdx].end(), @@ -368,14 +368,14 @@ namespace ttk { stack.push(rootID2); count = tree2->getNumberOfNodes() - 1; while(!stack.empty()) { - int nIdx = stack.top(); + int const nIdx = stack.top(); stack.pop(); preorder2[count] = nIdx; count--; depth2 = std::max((int)predecessors2[nIdx].size(), depth2); std::vector children; tree2->getChildren(nIdx, children); - for(int cIdx : children) { + for(int const cIdx : children) { stack.push(cIdx); predecessors2[cIdx].reserve(predecessors2[nIdx].size() + 1); predecessors2[cIdx].insert(predecessors2[cIdx].end(), @@ -387,10 +387,10 @@ namespace ttk { size_t nn1 = tree1->getNumberOfNodes(); size_t nn2 = tree2->getNumberOfNodes(); - size_t dim1 = 1; - size_t dim2 = (nn1 + 1) * dim1; - size_t dim3 = (depth1 + 1) * dim2; - size_t dim4 = (nn2 + 1) * dim3; + size_t const dim1 = 1; + size_t const dim2 = (nn1 + 1) * dim1; + size_t const dim3 = (depth1 + 1) * dim2; + size_t const dim4 = (nn2 + 1) * dim3; std::vector memT((nn1 + 1) * (depth1 + 1) * (nn2 + 1) * (depth2 + 1)); @@ -511,10 +511,10 @@ namespace ttk { // try all possible matchings of subtrees if(tree1->getNumberOfChildren(curr1) == 2 && tree2->getNumberOfChildren(curr2) == 2) { - int child11 = children1[0]; - int child12 = children1[1]; - int child21 = children2[0]; - int child22 = children2[1]; + int const child11 = children1[0]; + int const child12 = children1[1]; + int const child21 = children2[0]; + int const child22 = children2[1]; d = std::min( d, memT[child11 + 1 * dim2 + child21 * dim3 + 1 * dim4] + memT[child12 + 1 * dim2 + child22 * dim3 + 1 * dim4] @@ -527,14 +527,14 @@ namespace ttk { curr1, parent1, curr2, parent2, tree1, tree2)); } else { auto f = [&](int r, int c) { - size_t c1 = r < tree1->getNumberOfChildren(curr1) - ? children1[r] - : nn1; - size_t c2 = c < tree2->getNumberOfChildren(curr2) - ? children2[c] - : nn2; - int l1_ = c1 == nn1 ? 0 : 1; - int l2_ = c2 == nn2 ? 0 : 1; + size_t const c1 = r < tree1->getNumberOfChildren(curr1) + ? children1[r] + : nn1; + size_t const c2 = c < tree2->getNumberOfChildren(curr2) + ? children2[c] + : nn2; + int const l1_ = c1 == nn1 ? 0 : 1; + int const l2_ = c2 == nn2 ? 0 : 1; return memT[c1 + l1_ * dim2 + c2 * dim3 + l2_ * dim4]; }; int size = std::max(tree1->getNumberOfChildren(curr1), diff --git a/core/base/mergeTreeDistanceMatrix/MergeTreeDistanceMatrix.h b/core/base/mergeTreeDistanceMatrix/MergeTreeDistanceMatrix.h index 0c8c0134ef..6f2b762515 100644 --- a/core/base/mergeTreeDistanceMatrix/MergeTreeDistanceMatrix.h +++ b/core/base/mergeTreeDistanceMatrix/MergeTreeDistanceMatrix.h @@ -176,7 +176,8 @@ namespace ttk { mergeTreeDistance.setPostprocess(false); mergeTreeDistance.setIsPersistenceDiagram(isPersistenceDiagram_); if(useDoubleInput_) { - double weight = mixDistancesMinMaxPairWeight(isFirstInput); + double const weight + = mixDistancesMinMaxPairWeight(isFirstInput); mergeTreeDistance.setMinMaxPairWeight(weight); mergeTreeDistance.setDistanceSquaredRoot(true); } diff --git a/core/base/mergeTreePrincipalGeodesics/MergeTreeAxesAlgorithmBase.h b/core/base/mergeTreePrincipalGeodesics/MergeTreeAxesAlgorithmBase.h index daebcdbe82..26c76398f1 100644 --- a/core/base/mergeTreePrincipalGeodesics/MergeTreeAxesAlgorithmBase.h +++ b/core/base/mergeTreePrincipalGeodesics/MergeTreeAxesAlgorithmBase.h @@ -66,7 +66,7 @@ namespace ttk { mergeTreeDistance.setDistanceSquaredRoot(true); // squared root mergeTreeDistance.setNodePerTask(nodePerTask_); if(useDoubleInput) { - double weight = mixDistancesMinMaxPairWeight(isFirstInput); + double const weight = mixDistancesMinMaxPairWeight(isFirstInput); mergeTreeDistance.setMinMaxPairWeight(weight); } distance = mergeTreeDistance.computeDistance( @@ -142,7 +142,7 @@ namespace ttk { } // Change the norm of the random vector to be the average norm - double normV = ttk::Geometry::magnitudeFlatten(v); + double const normV = ttk::Geometry::magnitudeFlatten(v); for(unsigned int i = 0; i < barycenter.tree.getNumberOfNodes(); ++i) { if(barycenter.tree.isNodeAlone(i)) continue; @@ -344,7 +344,7 @@ namespace ttk { double barycenterSizeLimitPercent, bool useDoubleInput = false, bool isFirstInput = true) { - unsigned int barycenterMaximumNumberOfPairs = 0; + unsigned int const barycenterMaximumNumberOfPairs = 0; computeOneBarycenter(trees, baryMergeTree, matchings, finalDistances, barycenterSizeLimitPercent, barycenterMaximumNumberOfPairs, useDoubleInput, @@ -564,9 +564,9 @@ namespace ttk { void zeroPadding(std::string &colName, const size_t numberCols, const size_t colIdx) { - std::string max{std::to_string(numberCols - 1)}; - std::string cur{std::to_string(colIdx)}; - std::string zer(max.size() - cur.size(), '0'); + std::string const max{std::to_string(numberCols - 1)}; + std::string const cur{std::to_string(colIdx)}; + std::string const zer(max.size() - cur.size(), '0'); colName.append(zer).append(cur); } @@ -589,7 +589,7 @@ namespace ttk { bool isSecondInput = false) { std::string indexString{}; zeroPadding(indexString, noGeodesics, geodesicNum); - std::string prefix{(isSecondInput ? "T2_" : "")}; + std::string const prefix{(isSecondInput ? "T2_" : "")}; std::string name{prefix + "V" + indexString + "_" + std::to_string(vId) + "_" + std::to_string(vComp)}; return name; diff --git a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.cpp b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.cpp index 3842cc8b73..b05576ef03 100644 --- a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.cpp +++ b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.cpp @@ -5,7 +5,7 @@ namespace ttk { std::vector>> &vS, std::vector>> &v2s, bool doPrint) { - unsigned int geodesicNumber = vS.size() - 1; + unsigned int const geodesicNumber = vS.size() - 1; if(geodesicNumber == 0) return 0.0; if(doPrint) @@ -14,7 +14,7 @@ namespace ttk { std::vector> sumVs; ttk::Geometry::multiAddVectorsFlatten(vS, v2s, sumVs); for(unsigned int i = 0; i < geodesicNumber; ++i) { - double scalarProd + double const scalarProd = ttk::Geometry::dotProduct(sumVs[i], sumVs[geodesicNumber]); cost += scalarProd * scalarProd; if(doPrint and geodesicNumber < 4) { diff --git a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.h b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.h index 1932776f82..4ed0e7394e 100644 --- a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.h +++ b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesics.h @@ -159,7 +159,7 @@ namespace ttk { bool isFirstInput = true) { ftm::FTMTree_MT *barycenterTree = &(barycenter.tree); ftm::FTMTree_MT *extremityTree = &(extremity.tree); - double t = (isV1 ? -1.0 : 1.0); + double const t = (isV1 ? -1.0 : 1.0); std::vector> matching; dataType distance; @@ -173,7 +173,7 @@ namespace ttk { matchingVector.resize(barycenterTree->getNumberOfNodes(), std::numeric_limits::max()); - std::vector> oriV = v; + std::vector> const oriV = v; for(unsigned int i = 0; i < barycenter.tree.getNumberOfNodes(); ++i) { if(barycenter.tree.isNodeAlone(i)) continue; @@ -199,7 +199,7 @@ namespace ttk { } // Compute distance between old and new extremity - double cost = ttk::Geometry::distanceFlatten(v, oriV); + double const cost = ttk::Geometry::distanceFlatten(v, oriV); return cost; } @@ -247,9 +247,9 @@ namespace ttk { std::vector v1_flatten, v2_flatten; ttk::Geometry::flattenMultiDimensionalVector(v1, v1_flatten); ttk::Geometry::flattenMultiDimensionalVector(v2, v2_flatten); - double v1_norm = ttk::Geometry::magnitude(v1_flatten); - double v2_norm = ttk::Geometry::magnitude(v2_flatten); - double beta = v2_norm / (v1_norm + v2_norm); + double const v1_norm = ttk::Geometry::magnitude(v1_flatten); + double const v2_norm = ttk::Geometry::magnitude(v2_flatten); + double const beta = v2_norm / (v1_norm + v2_norm); std::vector v; ttk::Geometry::addVectors(v1_flatten, v2_flatten, v); ttk::Geometry::scaleVector(v, (1 - beta), v1_flatten); @@ -416,7 +416,7 @@ namespace ttk { #pragma omp task shared(best) firstprivate(i, k) { #endif - double kT = (k % 2 == 0 ? k / 2 : k_ - 1 - (int)(k / 2)); + double const kT = (k % 2 == 0 ? k / 2 : k_ - 1 - (int)(k / 2)); double t = 1.0 / (k_ - 1) * kT; dataType distance, distance2; @@ -630,9 +630,9 @@ namespace ttk { * (allMatched[j][1] - allDeathBary[j] + (1 - tss[i][j]) * multDeathV2); } - double divisorV1 + double const divisorV1 = one_min_ti_squared - ti_one_min_ti * ti_one_min_ti / ti_squared; - double divisorV2 + double const divisorV2 = ti_squared - ti_one_min_ti * ti_one_min_ti / one_min_ti_squared; newBirthV1 /= divisorV1; newDeathV1 /= divisorV1; @@ -1009,7 +1009,7 @@ namespace ttk { } // --- Compute global variance - double globalVariance + double const globalVariance = computeVarianceFromDistances(inputToBaryDistances_); // --- Manage maximum number of geodesics @@ -1027,7 +1027,7 @@ namespace ttk { } // --- Init - unsigned int oldNoGeod = allTs_.size(); + unsigned int const oldNoGeod = allTs_.size(); if(not keepState_) { allTs_.resize(numberOfGeodesics_, std::vector(trees.size())); inputToGeodesicsDistances_.resize( @@ -1195,16 +1195,16 @@ namespace ttk { std::vector> &trees2, int geodesicNumber, double globalVariance) { - bool printOriginalVariances = false; - bool printSurfaceVariance = false; - bool printTVariances = true; + bool const printOriginalVariances = false; + bool const printSurfaceVariance = false; + bool const printTVariances = true; if(printOriginalVariances) { // Variance double variance = computeExplainedVariance( barycenter, trees, vS_[geodesicNumber], v2s_[geodesicNumber], allTs_[geodesicNumber]); - double variancePercent = variance / globalVariance * 100.0; + double const variancePercent = variance / globalVariance * 100.0; std::stringstream ssVariance, ssCumul; ssVariance << "Variance explained : " << round(variancePercent * 100.0) / 100.0 << " %"; @@ -1212,7 +1212,8 @@ namespace ttk { // Cumul Variance cumulVariance_ += variance; - double cumulVariancePercent = cumulVariance_ / globalVariance * 100.0; + double const cumulVariancePercent + = cumulVariance_ / globalVariance * 100.0; ssCumul << "Cumulative explained variance : " << round(cumulVariancePercent * 100.0) / 100.0 << " %"; printMsg(ssCumul.str()); @@ -1222,7 +1223,7 @@ namespace ttk { // Surface Variance double surfaceVariance = computeSurfaceExplainedVariance( barycenter, trees, vS_, v2s_, allTs_); - double surfaceVariancePercent + double const surfaceVariancePercent = surfaceVariance / globalVariance * 100.0; std::stringstream ssSurface; ssSurface << "Surface Variance explained : " @@ -1242,7 +1243,7 @@ namespace ttk { tVariance = computeExplainedVarianceT(barycenter, vS_[geodesicNumber], v2s_[geodesicNumber], allTs_[geodesicNumber]); - double tVariancePercent = tVariance / globalVariance * 100.0; + double const tVariancePercent = tVariance / globalVariance * 100.0; std::stringstream ssTVariance, ssCumulT; ssTVariance << "Explained T-Variance : " << round(tVariancePercent * 100.0) / 100.0 << " %"; @@ -1250,7 +1251,8 @@ namespace ttk { // Cumul T-Variance cumulTVariance_ += tVariance; - double cumulTVariancePercent = cumulTVariance_ / globalVariance * 100.0; + double const cumulTVariancePercent + = cumulTVariance_ / globalVariance * 100.0; ssCumulT << "Cumulative explained T-Variance : " << round(cumulTVariancePercent * 100.0) / 100.0 << " %"; printMsg(ssCumulT.str()); diff --git a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.cpp b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.cpp index 139dace861..6625fcf0af 100644 --- a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.cpp +++ b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.cpp @@ -59,7 +59,7 @@ namespace ttk { std::vector &pVec, size_t size, std::vector> &vec) { - std::vector sizes(pVec.size(), size); + std::vector const sizes(pVec.size(), size); pointersToVectors(pVec, sizes, vec); } } // namespace ttk diff --git a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.h b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.h index 9b62ef3c9e..6d2b10a6f8 100644 --- a/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.h +++ b/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.h @@ -119,7 +119,7 @@ namespace ttk { ++cptDivide; } alpha /= cptDivide; - double m = alpha / (1 + alpha); + double const m = alpha / (1 + alpha); return m; } @@ -172,19 +172,20 @@ namespace ttk { if(newBirthV1 > newDeathV1 and newBirthV2 > newDeathV2) { shortener = true; - double divisor + double const divisor = (vNew[node][1] - vNew[node][0]) / (baryDeath - baryBirth); vNew[node][0] /= divisor; vNew[node][1] /= divisor; - double divisor2 + double const divisor2 = (v2New[node][0] - v2New[node][1]) / (baryDeath - baryBirth); v2New[node][0] /= divisor2; v2New[node][1] /= divisor2; } else if(newBirthV1 > newDeathV1 or newBirthV2 > newDeathV2) { - double newT = (baryDeath - vNew[node][1] - baryBirth + vNew[node][0]) - / (vNew[node][0] + v2New[node][0] - - (vNew[node][1] + v2New[node][1])); - double m = getGeodesicVectorMiddle(vNew[node], v2New[node]); + double const newT + = (baryDeath - vNew[node][1] - baryBirth + vNew[node][0]) + / (vNew[node][0] + v2New[node][0] + - (vNew[node][1] + v2New[node][1])); + double const m = getGeodesicVectorMiddle(vNew[node], v2New[node]); if(newBirthV1 > newDeathV1) updateT(newT, m, tMin, tMax, true); if(newBirthV2 > newDeathV2) @@ -225,7 +226,7 @@ namespace ttk { auto parentDeathV2 = 1.0; // - bool extremOutPathIn + bool const extremOutPathIn = ((newDeathV1 > parentDeathV1 and not(newBirthV1 < parentBirthV1) and not(newDeathV2 > parentDeathV2) and newBirthV2 < parentBirthV2) or (not(newDeathV1 > parentDeathV1) and newBirthV1 < parentBirthV1 @@ -273,18 +274,18 @@ namespace ttk { if(((newDeathV1 > parentDeathV1 or newBirthV1 < parentBirthV1) != (newDeathV2 > parentDeathV2 or newBirthV2 < parentBirthV2)) or extremOutPathIn) { - double m = getGeodesicVectorMiddle(vNew[node], v2New[node]); + double const m = getGeodesicVectorMiddle(vNew[node], v2New[node]); if(newDeathV1 > parentDeathV1 or newDeathV2 > parentDeathV2) { - double newT = (deathParent - baryDeath + vNew[node][1]) - / (vNew[node][1] + v2New[node][1]); + double const newT = (deathParent - baryDeath + vNew[node][1]) + / (vNew[node][1] + v2New[node][1]); if(newDeathV1 > parentDeathV1) updateT(newT, m, tMin, tMax, true); if(newDeathV2 > parentDeathV2) updateT(newT, m, tMin, tMax, false); } if(newBirthV1 < parentBirthV1 or newBirthV2 < parentBirthV2) { - double newT = (birthParent - baryBirth + vNew[node][0]) - / (vNew[node][0] + v2New[node][0]); + double const newT = (birthParent - baryBirth + vNew[node][0]) + / (vNew[node][0] + v2New[node][0]); if(newBirthV1 < parentBirthV1) updateT(newT, m, tMin, tMax, true); if(newBirthV2 < parentBirthV2) @@ -306,8 +307,8 @@ namespace ttk { double tMax, const std::string &msg, std::stringstream &ssT) { - double tNew = (t * (tMax - tMin) + tMin); - std::streamsize sSize = std::cout.precision(); + double const tNew = (t * (tMax - tMin) + tMin); + std::streamsize const sSize = std::cout.precision(); ssT << std::setprecision(12) << std::endl << msg << std::endl; ssT << "interBirth : " << birth - vNew[i][0] + tNew * (vNew[i][0] + v2New[i][0]) << " _ " @@ -358,7 +359,7 @@ namespace ttk { } // - Compute new t - double tNew = t * (tMax - tMin) + tMin; + double const tNew = t * (tMax - tMin) + tMin; if(diagonalShortener or nestingShortener) printWrn("[getTNew] shortener"); @@ -396,7 +397,7 @@ namespace ttk { queue.emplace(baryTree->getRoot()); int noNestingShortener = 0, noDiagonalShortener = 0; while(!queue.empty()) { - ftm::idNode i = queue.front(); + ftm::idNode const i = queue.front(); queue.pop(); // - Get node information @@ -419,7 +420,7 @@ namespace ttk { // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ std::stringstream ssT; - std::streamsize sSize2 = std::cout.precision(); + std::streamsize const sSize2 = std::cout.precision(); ssT << std::setprecision(12); ssT << "info" << std::endl; ssT << "birth death : " << birth << " ___ " << death << std::endl; @@ -447,7 +448,7 @@ namespace ttk { // -------------------------------------------------------------------- // - Adjust Diagonal T - bool diagonalShortener + bool const diagonalShortener = adjustDiagonalT(birth, death, i, vNew, v2New, tMin, tMax); noDiagonalShortener += diagonalShortener; @@ -459,7 +460,7 @@ namespace ttk { // - Adjust Nesting T if(normalizedWasserstein_ and !baryTree->notNeedToNormalize(i)) { - bool nestingShortener = adjustNestingT( + bool const nestingShortener = adjustNestingT( barycenter, birth, death, i, vNew, v2New, tMin, tMax); noNestingShortener += nestingShortener; @@ -471,13 +472,13 @@ namespace ttk { } // - Compute interpolation - double tNew = t * (tMax - tMin) + tMin; + double const tNew = t * (tMax - tMin) + tMin; double interBirth = birth - vNew[i][0] + tNew * (vNew[i][0] + v2New[i][0]); double interDeath = death - vNew[i][1] + tNew * (vNew[i][1] + v2New[i][1]); if(normalizedWasserstein_ and !baryTree->notNeedToNormalize(i)) { - double coef = (interParentDeath - interParentBirth); + double const coef = (interParentDeath - interParentBirth); interBirth *= coef; interBirth += interParentBirth; interDeath *= coef; @@ -493,7 +494,7 @@ namespace ttk { printErr("NOT A NUMBER"); } // - Verify points below diagonal - double eps = POINTS_BELOW_DIAG_TOLERANCE; + double const eps = POINTS_BELOW_DIAG_TOLERANCE; if(interpolationVector[nodeBirth] > interpolationVector[nodeDeath] and interpolationVector[nodeBirth] - interpolationVector[nodeDeath] < eps) { @@ -502,7 +503,7 @@ namespace ttk { if(interpolationVector[nodeBirth] > interpolationVector[nodeDeath]) { ++cptBelowDiagonal; printMsg(ssT.str()); - std::streamsize sSize = std::cout.precision(); + std::streamsize const sSize = std::cout.precision(); std::stringstream ss; ss << std::setprecision(12) << interpolationVector[nodeBirth] << " > " << interpolationVector[nodeDeath]; @@ -510,7 +511,7 @@ namespace ttk { std::cout.precision(sSize); } // - Verify nesting condition - bool verifyNesting = !baryTree->notNeedToNormalize(i); + bool const verifyNesting = !baryTree->notNeedToNormalize(i); if(normalizedWasserstein_ and verifyNesting) { if(interpolationVector[nodeBirth] < interParentBirth and (interParentBirth - interpolationVector[nodeBirth]) < eps) @@ -534,7 +535,7 @@ namespace ttk { or interpolationVector[nodeDeath] > interParentDeath)) { ++cptNotNesting; printMsg(ssT.str()); - std::streamsize sSize = std::cout.precision(); + std::streamsize const sSize = std::cout.precision(); std::stringstream ss; ss << std::setprecision(12) << interpolationVector[nodeBirth] << " _ " << interpolationVector[nodeDeath] << " --- " << interParentBirth diff --git a/core/base/mergeTreePrincipalGeodesicsDecoding/MergeTreePrincipalGeodesicsDecoding.h b/core/base/mergeTreePrincipalGeodesicsDecoding/MergeTreePrincipalGeodesicsDecoding.h index 60ca63812e..44f18aca27 100644 --- a/core/base/mergeTreePrincipalGeodesicsDecoding/MergeTreePrincipalGeodesicsDecoding.h +++ b/core/base/mergeTreePrincipalGeodesicsDecoding/MergeTreePrincipalGeodesicsDecoding.h @@ -60,9 +60,9 @@ namespace ttk { template void preprocessBarycenter(ftm::MergeTree &barycenter) { if(not isPersistenceDiagram_) { - bool useMinMax = true; - bool cleanTree = false; - bool pt = 0.0; + bool const useMinMax = true; + bool const cleanTree = false; + bool const pt = 0.0; std::vector nodeCorr; preprocessingPipeline(barycenter, 0.0, 100.0, 100.0, branchDecomposition_, useMinMax, @@ -266,7 +266,7 @@ namespace ttk { getInterpolation(barycenter, vSToUse[i], v2sToUse[i], vSizeToUse, t, geodesicsTrees[i][j]); tGeodesics_[i][j][i] = t; - int i2 = (i + 1) % 2; + int const i2 = (i + 1) % 2; tGeodesics_[i][j][i2] = middle[i2]; } @@ -312,14 +312,14 @@ namespace ttk { #pragma omp parallel for schedule(dynamic) num_threads(this->threadNumber_) #endif for(unsigned int i = 0; i < noSample; ++i) { - double angle = 360.0 / noSample * i; - double pi = M_PI; - double radius = 1.0; + double const angle = 360.0 / noSample * i; + double const pi = M_PI; + double const radius = 1.0; double x = -1 * radius * std::cos(-1 * angle * pi / 180); double y = -1 * radius * std::sin(-1 * angle * pi / 180); // 0: upper-left ; 1: upper-right ; 2: bottom-right ; 3: bottom-left - int quadrant = (x < 0.0 ? (y > 0.0 ? 0 : 3) : (y > 0.0 ? 1 : 2)); + int const quadrant = (x < 0.0 ? (y > 0.0 ? 0 : 3) : (y > 0.0 ? 1 : 2)); if(quadrant == 0 or quadrant == 3) x = (x + 1.0) * middle[0]; if(quadrant == 1 or quadrant == 2) @@ -381,10 +381,10 @@ namespace ttk { #endif for(unsigned int i = 0; i < noSample; ++i) { // 0: left ; 1: up; 2: right ; 3: bottom - int quadrant = i / (noSample / 4); + int const quadrant = i / (noSample / 4); double x = 0.0, y = 0.0; - double offset = (i % (noSample / 4)) / ((noSample / 4.0) - 1.0); + double const offset = (i % (noSample / 4)) / ((noSample / 4.0) - 1.0); switch(quadrant) { case 0: // Left x = 0.0; @@ -451,9 +451,9 @@ namespace ttk { #endif for(unsigned int i = 0; i < k_; ++i) { for(unsigned int j = 0; j < k_; ++j) { - double x = 1.0 / (k_ - 1) * i; - double y = 1.0 / (k_ - 1) * j; - int index = i * k_ + j; + double const x = 1.0 / (k_ - 1) * i; + double const y = 1.0 / (k_ - 1) * j; + int const index = i * k_ + j; // Get Boundary ID if(i == 0 or j == 0 or i == k_ - 1 or j == k_ - 1) { surfaceIsBoundary_[index] = true; diff --git a/core/base/mergeTreeTemporalReductionDecoding/MergeTreeTemporalReductionDecoding.h b/core/base/mergeTreeTemporalReductionDecoding/MergeTreeTemporalReductionDecoding.h index 324e5bb71c..eb6ddd02bd 100644 --- a/core/base/mergeTreeTemporalReductionDecoding/MergeTreeTemporalReductionDecoding.h +++ b/core/base/mergeTreeTemporalReductionDecoding/MergeTreeTemporalReductionDecoding.h @@ -139,9 +139,9 @@ namespace ttk { size_t cpt = 0; while(cpt < coefs.size()) { while(cpt < coefs.size() and std::get<2>(coefs[cpt]) <= index) { - double alpha = std::get<0>(coefs[cpt]); - int index1 = std::get<1>(coefs[cpt]); - int index2 = std::get<2>(coefs[cpt]); + double const alpha = std::get<0>(coefs[cpt]); + int const index1 = std::get<1>(coefs[cpt]); + int const index2 = std::get<2>(coefs[cpt]); ftm::MergeTree tree = computeBarycenter( mTrees[index1], mTrees[index2], alpha); allMT.push_back(tree); diff --git a/core/base/mergeTreeTemporalReductionEncoding/MergeTreeTemporalReductionEncoding.h b/core/base/mergeTreeTemporalReductionEncoding/MergeTreeTemporalReductionEncoding.h index 4960504636..d181333a93 100644 --- a/core/base/mergeTreeTemporalReductionEncoding/MergeTreeTemporalReductionEncoding.h +++ b/core/base/mergeTreeTemporalReductionEncoding/MergeTreeTemporalReductionEncoding.h @@ -57,7 +57,7 @@ namespace ttk { dataType computeL2Distance(std::vector &img1, std::vector &img2, bool emptyFieldDistance = false) { - size_t noPoints = img1.size(); + size_t const noPoints = img1.size(); std::vector secondField = img2; if(emptyFieldDistance) @@ -78,7 +78,7 @@ namespace ttk { std::vector &img2, double alpha) { - size_t noPoints = img1.size(); + size_t const noPoints = img1.size(); std::vector barycenter(noPoints); for(size_t i = 0; i < noPoints; ++i) @@ -207,7 +207,7 @@ namespace ttk { // Compute barycenter printMsg("Compute barycenter", debug::Priority::VERBOSE); - double alpha = computeAlpha(index1, middleIndex, index2); + double const alpha = computeAlpha(index1, middleIndex, index2); ftm::MergeTree barycenter; std::vector barycenterL2; if(not useL2Distance_) @@ -236,13 +236,13 @@ namespace ttk { std::vector, int>> barycentersL2OnPath; for(unsigned int i = 0; i < 2; ++i) { - int toReach = (i == 0 ? index1 : index2); - int offset = (i == 0 ? -1 : 1); + int const toReach = (i == 0 ? index1 : index2); + int const offset = (i == 0 ? -1 : 1); int tIndex = middleIndex + offset; while(tIndex != toReach) { // Compute barycenter - double alphaT = computeAlpha(index1, tIndex, index2); + double const alphaT = computeAlpha(index1, tIndex, index2); ftm::MergeTree barycenterP; std::vector barycenterPL2; if(not useL2Distance_) @@ -355,7 +355,7 @@ namespace ttk { } // --- Compute empty tree distances - unsigned int distMatSize + unsigned int const distMatSize = (not useL2Distance_ ? allMT.size() : images.size()); for(unsigned int i = 0; i < distMatSize; ++i) { dataType distance; diff --git a/core/base/meshGraph/MeshGraph.h b/core/base/meshGraph/MeshGraph.h index faac316799..94c5ccbf64 100644 --- a/core/base/meshGraph/MeshGraph.h +++ b/core/base/meshGraph/MeshGraph.h @@ -197,7 +197,7 @@ int ttk::MeshGraph::execute( for(size_t i = 0; i < nInputPoints; i++) { const CT *coord = &inputPoints[i * 3]; - size_t q = i * 9; // i*3*3 + size_t const q = i * 9; // i*3*3 // a outputPoints[q] = coord[0]; outputPoints[q + 1] = coord[1]; @@ -226,9 +226,9 @@ int ttk::MeshGraph::execute( // Lambda function that linearly interpolates two point locations auto getMidPoint = [&](const size_t &m, const size_t &i, const size_t &j) { - size_t mp = m * 3; - size_t ip = i * 3; - size_t jp = j * 3; + size_t const mp = m * 3; + size_t const ip = i * 3; + size_t const jp = j * 3; for(size_t k = 0; k < 3; k++) outputPoints[mp + k] = (outputPoints[ip + k] + outputPoints[jp + k]) / 2; @@ -242,9 +242,9 @@ int ttk::MeshGraph::execute( n = 0.5 * (0.5 * q0 + 0.5 * n) + 0.5 * (0.5 * n + 0.5 * q2); }; - size_t mi = m * 3; - size_t p0i = p0 * 3; // first point - size_t p1i = p1 * 3; // second point + size_t const mi = m * 3; + size_t const p0i = p0 * 3; // first point + size_t const p1i = p1 * 3; // second point for(size_t i = 0; i < 3; i++) outputPoints[mi + i] @@ -262,26 +262,26 @@ int ttk::MeshGraph::execute( #endif for(size_t i = 0; i < nInputCells; i++) { size_t temp = i * 2; - size_t aInputIndex = (size_t)inputConnectivityArray[temp++]; - size_t bInputIndex = (size_t)inputConnectivityArray[temp]; + size_t const aInputIndex = (size_t)inputConnectivityArray[temp++]; + size_t const bInputIndex = (size_t)inputConnectivityArray[temp]; // already computed points - size_t a = aInputIndex * 3; - size_t a0 = a + 1; - size_t a1 = a + 2; - size_t b = bInputIndex * 3; - size_t b0 = b + 1; - size_t b1 = b + 2; + size_t const a = aInputIndex * 3; + size_t const a0 = a + 1; + size_t const a1 = a + 2; + size_t const b = bInputIndex * 3; + size_t const b0 = b + 1; + size_t const b1 = b + 2; // points to compute - size_t offset = edgePointOffset + i * 7; - size_t m0 = offset; - size_t m1 = offset + 1; - size_t a0m0 = offset + 2; - size_t m0b0 = offset + 3; - size_t b1m1 = offset + 4; - size_t m1a1 = offset + 5; - size_t c = offset + 6; + size_t const offset = edgePointOffset + i * 7; + size_t const m0 = offset; + size_t const m1 = offset + 1; + size_t const a0m0 = offset + 2; + size_t const m0b0 = offset + 3; + size_t const b1m1 = offset + 4; + size_t const m1a1 = offset + 5; + size_t const c = offset + 6; getMidPoint(m0, a0, b0); getMidPoint(m1, a1, b1); @@ -399,9 +399,9 @@ int ttk::MeshGraph::execute2( {"#Subdivisions", std::to_string(nSubdivisions)}}); this->printMsg(debug::Separator::L2); - size_t subdivisionOffset = nInputPoints * 2; - size_t nSubdivisionPoints = nSubdivisions * 2; - size_t outputPointsSubdivisonOffset = nSubdivisionPoints * 3; + size_t const subdivisionOffset = nInputPoints * 2; + size_t const nSubdivisionPoints = nSubdivisions * 2; + size_t const outputPointsSubdivisonOffset = nSubdivisionPoints * 3; // --------------------------------------------------------------------------- // Compute Output Point Locations @@ -423,7 +423,7 @@ int ttk::MeshGraph::execute2( for(size_t i = 0; i < nInputPoints; i++) { const CT *coords = &inputPoints[i * 3]; - size_t q = i * 6; + size_t const q = i * 6; outputPoints[q] = coords[0]; outputPoints[q + 1] = coords[1]; outputPoints[q + 2] = coords[2]; @@ -441,19 +441,19 @@ int ttk::MeshGraph::execute2( // ------------------------------------------------------------------------- // Compute SubPoints // ------------------------------------------------------------------------- - size_t q = subdivisionOffset * 3; - float nSubdivisionsP1 = nSubdivisions + 1; + size_t const q = subdivisionOffset * 3; + float const nSubdivisionsP1 = nSubdivisions + 1; auto computeBezierPoint = [&](const size_t &no0, const size_t &no1, const size_t &subdOffset, const float lambda) { - float lambdaI = 1 - lambda; + float const lambdaI = 1 - lambda; - float lambda_2 = lambda * lambda; - float lambda_3 = lambda * lambda_2; + float const lambda_2 = lambda * lambda; + float const lambda_3 = lambda * lambda_2; - float lambdaI_2 = lambdaI * lambdaI; - float lambdaI_3 = lambdaI * lambdaI_2; + float const lambdaI_2 = lambdaI * lambdaI; + float const lambdaI_3 = lambdaI * lambdaI_2; float m0[3]; float m1[3]; @@ -501,7 +501,7 @@ int ttk::MeshGraph::execute2( Timer t; this->printMsg("Computing mesh cells", 0, debug::LineMode::REPLACE); - size_t cellSize = this->computeOutputCellSize(nSubdivisions); + size_t const cellSize = this->computeOutputCellSize(nSubdivisions); #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) @@ -562,14 +562,14 @@ int ttk::MeshGraph::mapInputPointDataToOutputPointData( #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < nInputPoints; i++) { - size_t q = i * 3; + size_t const q = i * 3; // a, a0, a1 outputPointData[q] = inputPointData[i]; outputPointData[q + 1] = inputPointData[i]; outputPointData[q + 2] = inputPointData[i]; } - size_t edgePointOffset = nInputPoints * 3; + size_t const edgePointOffset = nInputPoints * 3; // Iterate over input cells and assign point data of intermediate points #ifdef TTK_ENABLE_OPENMP @@ -577,20 +577,20 @@ int ttk::MeshGraph::mapInputPointDataToOutputPointData( #endif for(size_t i = 0; i < nInputCells; i++) { size_t temp = i * 2; - size_t aInputIndex = (size_t)inputConnectivityArray[temp++]; - size_t bInputIndex = (size_t)inputConnectivityArray[temp]; + size_t const aInputIndex = (size_t)inputConnectivityArray[temp++]; + size_t const bInputIndex = (size_t)inputConnectivityArray[temp]; - size_t a = aInputIndex * 3; - size_t b = bInputIndex * 3; + size_t const a = aInputIndex * 3; + size_t const b = bInputIndex * 3; - size_t offset = edgePointOffset + i * 7; - size_t m0 = offset; - size_t m1 = offset + 1; - size_t a0m0 = offset + 2; - size_t m0b0 = offset + 3; - size_t b1m1 = offset + 4; - size_t m1a1 = offset + 5; - size_t c = offset + 6; + size_t const offset = edgePointOffset + i * 7; + size_t const m0 = offset; + size_t const m1 = offset + 1; + size_t const a0m0 = offset + 2; + size_t const m0b0 = offset + 3; + size_t const b1m1 = offset + 4; + size_t const m1a1 = offset + 5; + size_t const c = offset + 6; outputPointData[c] = (DT)((outputPointData[a] + outputPointData[b]) / 2); outputPointData[m0] = outputPointData[c]; @@ -611,27 +611,27 @@ int ttk::MeshGraph::mapInputPointDataToOutputPointData( #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < nInputPoints; i++) { - size_t offset = i * 2; + size_t const offset = i * 2; auto &v = inputPointData[i]; outputPointData[offset] = v; outputPointData[offset + 1] = v; } // Intermediate Points - size_t subdivisionOffset = nInputPoints * 2; - size_t nSubdivisionPoints = nSubdivisions * 2; + size_t const subdivisionOffset = nInputPoints * 2; + size_t const nSubdivisionPoints = nSubdivisions * 2; #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < nInputCells; i++) { - size_t q = i * 2; + size_t const q = i * 2; IT c0 = inputConnectivityArray[q]; DT c0V = inputPointData[c0]; - size_t temp = subdivisionOffset + i * nSubdivisionPoints; + size_t const temp = subdivisionOffset + i * nSubdivisionPoints; for(size_t j = 0; j < nSubdivisions; j++) { - size_t q2 = temp + j * 2; + size_t const q2 = temp + j * 2; outputPointData[q2] = c0V; outputPointData[q2 + 1] = c0V; } @@ -656,7 +656,7 @@ int ttk::MeshGraph::mapInputCellDataToOutputCellData( #pragma omp parallel for num_threads(threadNumber_) #endif for(size_t i = 0; i < nInputCells; i++) { - size_t offset = i * 2; + size_t const offset = i * 2; outputCellData[offset] = inputCellData[i]; outputCellData[offset + 1] = inputCellData[i]; } diff --git a/core/base/metricDistortion/MetricDistortion.h b/core/base/metricDistortion/MetricDistortion.h index 04a7a67e6f..8e68b75dac 100644 --- a/core/base/metricDistortion/MetricDistortion.h +++ b/core/base/metricDistortion/MetricDistortion.h @@ -44,7 +44,7 @@ namespace ttk { std::vector &surfaceCurvature, std::vector &metricCurvature, std::vector &diffCurvature) { - unsigned int dim = triangulation->getNumberOfVertices(); + unsigned int const dim = triangulation->getNumberOfVertices(); surfaceCurvature = std::vector(dim, std::nan("")); metricCurvature = std::vector(dim, std::nan("")); diffCurvature = std::vector(dim, std::nan("")); @@ -63,7 +63,7 @@ namespace ttk { triangulation->getCellVertex(i, first, i0); triangulation->getCellVertex(i, second, i1); - std::tuple tup = std::make_tuple(i0, i1); + std::tuple const tup = std::make_tuple(i0, i1); SimplexId ij; triangulation->getCellVertex(i, j, ij); @@ -81,36 +81,37 @@ namespace ttk { for(unsigned int j = 0; j < point2CellPoints[i].size(); ++j) { auto tup = point2CellPoints[i][j]; - int i0 = std::get<0>(tup); - int i1 = std::get<1>(tup); + int const i0 = std::get<0>(tup); + int const i1 = std::get<1>(tup); float p_i0[3], p_i1[3], p_i[3]; triangulation->getVertexPoint(i0, p_i0[0], p_i0[1], p_i0[2]); triangulation->getVertexPoint(i1, p_i1[0], p_i1[1], p_i1[2]); triangulation->getVertexPoint(i, p_i[0], p_i[1], p_i[2]); - double dist_i_i0 = Geometry::distance(&p_i[0], &p_i0[0]); - double dist_i_i1 = Geometry::distance(&p_i[0], &p_i1[0]); - double dist_i0_i1 = Geometry::distance(&p_i0[0], &p_i1[0]); + double const dist_i_i0 = Geometry::distance(&p_i[0], &p_i0[0]); + double const dist_i_i1 = Geometry::distance(&p_i[0], &p_i1[0]); + double const dist_i0_i1 = Geometry::distance(&p_i0[0], &p_i1[0]); double angleSurface; Geometry::computeTriangleAngleFromSides( dist_i_i0, dist_i_i1, dist_i0_i1, angleSurface); sumAngleSurface += angleSurface; if(distanceMatrix.size() != 0) { double angleMetric; - double distMat_i_i0 = distanceMatrix[i][i0]; - double distMat_i_i1 = distanceMatrix[i][i1]; - double distMat_i0_i1 = distanceMatrix[i0][i1]; + double const distMat_i_i0 = distanceMatrix[i][i0]; + double const distMat_i_i1 = distanceMatrix[i][i1]; + double const distMat_i0_i1 = distanceMatrix[i0][i1]; Geometry::computeTriangleAngleFromSides( distMat_i_i0, distMat_i_i1, distMat_i0_i1, angleMetric); sumAngleMetric += angleMetric; } } - unsigned int cornerNoCell = (noTriangle > noQuad ? 2 : 1); - double coef = (point2CellPoints[i].size() <= cornerNoCell - ? 0.5 - : (triangulation->isVertexOnBoundary(i) ? 1 : 2)); + unsigned int const cornerNoCell = (noTriangle > noQuad ? 2 : 1); + double const coef + = (point2CellPoints[i].size() <= cornerNoCell + ? 0.5 + : (triangulation->isVertexOnBoundary(i) ? 1 : 2)); surfaceCurvature[i] = coef * M_PI - sumAngleSurface; // surfaceCurvature[i] *= std::pow(coef, -1); @@ -194,12 +195,12 @@ namespace ttk { triangulation->getVertexPoint(i, p0[0], p0[1], p0[2]); triangulation->getVertexPoint(neighbor, p1[0], p1[1], p1[2]); - double distance = Geometry::distance(&p0[0], &p1[0]); + double const distance = Geometry::distance(&p0[0], &p1[0]); updateIndicators( minDistanceS, maxDistanceS, avgDistanceS, distance, neighborNum); if(distanceMatrix.size() != 0) { - double distanceM = distanceMatrix[i][neighbor]; + double const distanceM = distanceMatrix[i][neighbor]; updateIndicators( minDistanceM, maxDistanceM, avgDistanceM, distanceM, neighborNum); } @@ -224,7 +225,7 @@ namespace ttk { std::vector &surfaceArea, std::vector &metricArea, std::vector &ratioArea) { - unsigned int dim = triangulation->getNumberOfCells(); + unsigned int const dim = triangulation->getNumberOfCells(); surfaceArea = std::vector(dim, std::nan("")); metricArea = std::vector(dim, std::nan("")); ratioArea = std::vector(dim, std::nan("")); @@ -252,9 +253,9 @@ namespace ttk { if(distanceMatrix.size() != 0) { double areaMetric; - double distMat_i0_i1 = distanceMatrix[i0][i1]; - double distMat_i1_i2 = distanceMatrix[i1][i2]; - double distMat_i2_i0 = distanceMatrix[i2][i0]; + double const distMat_i0_i1 = distanceMatrix[i0][i1]; + double const distMat_i1_i2 = distanceMatrix[i1][i2]; + double const distMat_i2_i0 = distanceMatrix[i2][i0]; Geometry::computeTriangleAreaFromSides( distMat_i0_i1, distMat_i1_i2, distMat_i2_i0, areaMetric); metricArea[i] = areaMetric; @@ -272,9 +273,9 @@ namespace ttk { if(distanceMatrix.size() != 0) { double areaMetric; - double distMat_i1_i2 = distanceMatrix[i1][i2]; - double distMat_i2_i3 = distanceMatrix[i2][i3]; - double distMat_i3_i1 = distanceMatrix[i3][i1]; + double const distMat_i1_i2 = distanceMatrix[i1][i2]; + double const distMat_i2_i3 = distanceMatrix[i2][i3]; + double const distMat_i3_i1 = distanceMatrix[i3][i1]; Geometry::computeTriangleAreaFromSides( distMat_i1_i2, distMat_i2_i3, distMat_i3_i1, areaMetric); metricArea[i] += areaMetric; diff --git a/core/base/morphologicalOperators/MorphologicalOperators.h b/core/base/morphologicalOperators/MorphologicalOperators.h index ee5dbaadfe..95d465fe2a 100644 --- a/core/base/morphologicalOperators/MorphologicalOperators.h +++ b/core/base/morphologicalOperators/MorphologicalOperators.h @@ -119,7 +119,7 @@ int ttk::MorphologicalOperators::performElementaryMorphoOp( const DT &pivotLabel, TT *triangulation) const { - SimplexId nVertices = triangulation->getNumberOfVertices(); + SimplexId const nVertices = triangulation->getNumberOfVertices(); std::vector
temp; if(iterations > 1) { @@ -131,9 +131,9 @@ int ttk::MorphologicalOperators::performElementaryMorphoOp( this->threadNumber_); } - std::string msg = std::string(mode == 0 ? "Dilating " : "Eroding ") - + std::to_string(iterations) + "x value " - + std::to_string(pivotLabel); + std::string const msg = std::string(mode == 0 ? "Dilating " : "Eroding ") + + std::to_string(iterations) + "x value " + + std::to_string(pivotLabel); this->printMsg(msg, 0, 0, this->threadNumber_, debug::LineMode::REPLACE); diff --git a/core/base/morseSmaleQuadrangulation/MorseSmaleQuadrangulation.h b/core/base/morseSmaleQuadrangulation/MorseSmaleQuadrangulation.h index 3d26b9dc1e..21651c2635 100644 --- a/core/base/morseSmaleQuadrangulation/MorseSmaleQuadrangulation.h +++ b/core/base/morseSmaleQuadrangulation/MorseSmaleQuadrangulation.h @@ -305,7 +305,7 @@ int ttk::MorseSmaleQuadrangulation::detectCellSeps( = (critPoints % 2 == 0) ? critPoints / 2 - 1 : critPoints / 2; // current point - SimplexId curr{critPointId(i)}; + SimplexId const curr{critPointId(i)}; // get edge id auto ne = newT.getVertexEdgeNumber(curr); @@ -386,7 +386,7 @@ int ttk::MorseSmaleQuadrangulation::detectCellSeps( // look around the saddle points for(size_t i = 0; i < saddles.size(); ++i) { - SimplexId saddle = saddles[i]; + SimplexId const saddle = saddles[i]; auto sadtri = newT.getVertexTriangleNumber(saddle); @@ -398,9 +398,9 @@ int ttk::MorseSmaleQuadrangulation::detectCellSeps( SimplexId tr; newT.getVertexTriangle(saddle, j, tr); - std::set sepIdBeg = sepIdAroundTriangle(tr); + std::set const sepIdBeg = sepIdAroundTriangle(tr); // current iteration id - SimplexId iter = i * sadtri + j; + SimplexId const iter = i * sadtri + j; toProcess.push(tr); @@ -430,7 +430,7 @@ int ttk::MorseSmaleQuadrangulation::detectCellSeps( #endif // TTK_ENABLE_OPENMP // check for saddle at vertices - bool hasSaddle = hasTriangleSaddle(curr); + bool const hasSaddle = hasTriangleSaddle(curr); // check for separatrices on edges auto sepIdEnd = sepIdAroundTriangle(curr); @@ -563,8 +563,8 @@ int ttk::MorseSmaleQuadrangulation::quadrangulate( findSepsVertices(qs, srcs, dsts); // remove duplicates - std::set srcs_set(srcs.begin(), srcs.end()); - std::set dsts_set(dsts.begin(), dsts.end()); + std::set const srcs_set(srcs.begin(), srcs.end()); + std::set const dsts_set(dsts.begin(), dsts.end()); srcs.assign(srcs_set.begin(), srcs_set.end()); dsts.assign(dsts_set.begin(), dsts_set.end()); @@ -692,8 +692,8 @@ int ttk::MorseSmaleQuadrangulation::subdiviseDegenerateQuads( } } // extremum index - LongSimplexId vert2Seps = count_vi > count_vk ? q[0] : q[2]; - LongSimplexId vert1Sep = count_vi > count_vk ? q[2] : q[0]; + LongSimplexId const vert2Seps = count_vi > count_vk ? q[0] : q[2]; + LongSimplexId const vert1Sep = count_vi > count_vk ? q[2] : q[0]; // the two seps from j to vert2Seps std::vector borderseps{}; for(size_t j = 0; j < seps.size(); ++j) { @@ -708,8 +708,8 @@ int ttk::MorseSmaleQuadrangulation::subdiviseDegenerateQuads( // find a midpoint between the two extrema on the triangulation - std::vector boundi{criticalPointsIdentifier_[q[0]]}; - std::vector boundk{criticalPointsIdentifier_[q[2]]}; + std::vector const boundi{criticalPointsIdentifier_[q[0]]}; + std::vector const boundk{criticalPointsIdentifier_[q[2]]}; std::array, 6> outputDists{}; Dijkstra::shortestPath( @@ -748,9 +748,9 @@ int ttk::MorseSmaleQuadrangulation::subdiviseDegenerateQuads( // find two other points - std::vector bounds{criticalPointsIdentifier_[q[0]], - criticalPointsIdentifier_[q[1]], - criticalPointsIdentifier_[q[2]]}; + std::vector const bounds{criticalPointsIdentifier_[q[0]], + criticalPointsIdentifier_[q[1]], + criticalPointsIdentifier_[q[2]]}; auto m0Pos = sepMids_[borderseps[0]]; auto m1Pos = sepMids_[borderseps[1]]; @@ -818,7 +818,7 @@ int ttk::MorseSmaleQuadrangulation::subdivise( } // for each output quad, its barycenter position in outputPoints_ - std::vector cellBary(outputCells_.size()); + std::vector const cellBary(outputCells_.size()); std::array, 4> outputDists{}; @@ -845,7 +845,7 @@ int ttk::MorseSmaleQuadrangulation::subdivise( // find barycenter of current cell (c.f. QuadrangulationSubdivision.cpp) // bound Dijkstra by parent quad vertices - std::vector bounds{ + std::vector const bounds{ criticalPointsIdentifier_[q[0]], criticalPointsIdentifier_[q[1]], criticalPointsIdentifier_[q[2]], criticalPointsIdentifier_[q[3]]}; @@ -901,7 +901,7 @@ int ttk::MorseSmaleQuadrangulation::subdivise( sum[j] = m + n + o + p + std::abs(m - o) + std::abs(n - p); } - size_t verticesInCell + size_t const verticesInCell = verticesNumber_ - std::count( sum.begin(), sum.end(), std::numeric_limits::infinity()); @@ -920,7 +920,7 @@ int ttk::MorseSmaleQuadrangulation::subdivise( baryId = std::min_element(sum.begin(), sum.end()) - sum.begin(); } - LongSimplexId baryPos = outputPointsIds_.size(); + LongSimplexId const baryPos = outputPointsIds_.size(); { float x, y, z; triangulation.getVertexPoint(baryId, x, y, z); @@ -1052,7 +1052,7 @@ int ttk::MorseSmaleQuadrangulation::execute( size_t ndegen = 0; // direct quadrangulation with saddle points - int ret = quadrangulate(ndegen, triangulation); + int const ret = quadrangulate(ndegen, triangulation); if(ret == 0) { subdivise(triangulation); @@ -1077,7 +1077,7 @@ int ttk::MorseSmaleQuadrangulation::execute( } } - std::string s_degen{ + std::string const s_degen{ ndegen > 0 ? "(" + std::to_string(ndegen) + " degenerated) " : ""}; this->printMsg("Produced " + std::to_string(this->outputCells_.size()) diff --git a/core/base/multiresTopology/MultiresTopology.cpp b/core/base/multiresTopology/MultiresTopology.cpp index 52acd1cbe6..4f6822218c 100644 --- a/core/base/multiresTopology/MultiresTopology.cpp +++ b/core/base/multiresTopology/MultiresTopology.cpp @@ -101,7 +101,7 @@ char ttk::MultiresTopology::getCriticalTypeFromLink( const auto nbCC = link.getNbCC(); - int dimensionality = multiresTriangulation_.getDimensionality(); + int const dimensionality = multiresTriangulation_.getDimensionality(); SimplexId downValence = 0, upValence = 0; std::vector CCIds; diff --git a/core/base/multiresTriangulation/MultiresTriangulation.cpp b/core/base/multiresTriangulation/MultiresTriangulation.cpp index 4e866312fa..4d97a2a4d1 100644 --- a/core/base/multiresTriangulation/MultiresTriangulation.cpp +++ b/core/base/multiresTriangulation/MultiresTriangulation.cpp @@ -3145,8 +3145,8 @@ SimplexId and pLocal[2] == gridDecimatedDimensions_[2] - 1) { p2 -= decimation_ - nbvoxels_[2] % decimation_; } - SimplexId globalId = p0 + p1 * gridDimensions_[0] - + p2 * gridDimensions_[0] * gridDimensions_[1]; + SimplexId const globalId = p0 + p1 * gridDimensions_[0] + + p2 * gridDimensions_[0] * gridDimensions_[1]; return globalId; } @@ -3699,7 +3699,7 @@ void MultiresTriangulation::getImpactedVerticesABCDEFGH( SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[1] % previous_decimation) and (p[2] % previous_decimation)) { localNeighborId0 = 1; @@ -3736,7 +3736,7 @@ void MultiresTriangulation::getImpactedVerticesABDC( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[1] % previous_decimation)) { localNeighborId0 = 1; @@ -3758,7 +3758,7 @@ void MultiresTriangulation::getImpactedVerticesEFHG( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[1] % previous_decimation)) { localNeighborId0 = 5; @@ -3780,7 +3780,7 @@ void MultiresTriangulation::getImpactedVerticesAEGC( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[1] % previous_decimation) and (p[2] % previous_decimation)) { localNeighborId0 = 0; @@ -3801,7 +3801,7 @@ void MultiresTriangulation::getImpactedVerticesBFHD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[1] % previous_decimation) and (p[2] % previous_decimation)) { localNeighborId0 = 8; @@ -3822,7 +3822,7 @@ void MultiresTriangulation::getImpactedVerticesAEFB( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[2] % previous_decimation)) { localNeighborId0 = 3; @@ -3843,7 +3843,7 @@ void MultiresTriangulation::getImpactedVerticesGHDC( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[2] % previous_decimation)) { localNeighborId0 = 3; @@ -3864,7 +3864,7 @@ void MultiresTriangulation::getImpactedVerticesAB( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 0; @@ -3877,7 +3877,7 @@ void MultiresTriangulation::getImpactedVerticesCD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 1; @@ -3890,7 +3890,7 @@ void MultiresTriangulation::getImpactedVerticesEF( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 1; @@ -3903,7 +3903,7 @@ void MultiresTriangulation::getImpactedVerticesGH( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 7; @@ -3916,7 +3916,7 @@ void MultiresTriangulation::getImpactedVerticesAC( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 0; @@ -3929,7 +3929,7 @@ void MultiresTriangulation::getImpactedVerticesBD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 2; @@ -3942,7 +3942,7 @@ void MultiresTriangulation::getImpactedVerticesEG( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 4; @@ -3955,7 +3955,7 @@ void MultiresTriangulation::getImpactedVerticesFH( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 5; @@ -3968,7 +3968,7 @@ void MultiresTriangulation::getImpactedVerticesAE( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[2] % previous_decimation) { localNeighborId0 = 4; @@ -3982,7 +3982,7 @@ void MultiresTriangulation::getImpactedVerticesBF( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[2] % previous_decimation) { localNeighborId0 = 7; @@ -3996,7 +3996,7 @@ void MultiresTriangulation::getImpactedVerticesCG( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[2] % previous_decimation) { localNeighborId0 = 2; @@ -4010,7 +4010,7 @@ void MultiresTriangulation::getImpactedVerticesDH( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[2] % previous_decimation) { localNeighborId0 = 5; @@ -4024,7 +4024,7 @@ void MultiresTriangulation::getImpactedVertices2dABCD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if((p[0] % previous_decimation) and (p[1] % previous_decimation)) { localNeighborId0 = 2; @@ -4046,7 +4046,7 @@ void MultiresTriangulation::getImpactedVertices2dAB( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 0; @@ -4060,7 +4060,7 @@ void MultiresTriangulation::getImpactedVertices2dCD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[0] % previous_decimation) { localNeighborId0 = 0; @@ -4074,7 +4074,7 @@ void MultiresTriangulation::getImpactedVertices2dAC( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 0; @@ -4087,7 +4087,7 @@ void MultiresTriangulation::getImpactedVertices2dBD( std::array &p, SimplexId &localNeighborId0, SimplexId &localNeighborId1) const { - int previous_decimation = pow(2, (decimationLevel_ + 1)); + int const previous_decimation = pow(2, (decimationLevel_ + 1)); if(p[1] % previous_decimation) { localNeighborId0 = 2; @@ -4146,9 +4146,9 @@ std::vector if(p[2] == nbvoxels_[2]) vk.erase(vk.begin() + 2); - for(SimplexId i : vi) { - for(SimplexId j : vj) { - for(SimplexId k : vk) { + for(SimplexId const i : vi) { + for(SimplexId const j : vj) { + for(SimplexId const k : vk) { if(i != 0 or j != 0 or k != 0) result.push_back(vertexId + i + j * vshift_[0] + k * vshift_[1]); } @@ -4189,8 +4189,8 @@ std::vector if(p[1] == nbvoxels_[1]) vj.erase(vj.begin() + 2); - for(SimplexId i : vi) { - for(SimplexId j : vj) { + for(SimplexId const i : vi) { + for(SimplexId const j : vj) { if(i != 0 or j != 0) { result.push_back(vertexId + i + j * vshift_[Di_]); } @@ -4313,7 +4313,7 @@ int MultiresTriangulation::getVertexBoundaryIndex( void MultiresTriangulation::findBoundaryRepresentatives( std::vector &boundaryRepresentatives) { - int currentDecimationLevel = decimationLevel_; + int const currentDecimationLevel = decimationLevel_; setDecimationLevel(0); if(dimensionality_ == 3) { // here gridDimension[i] > 1 for all i =0,1,2 boundaryRepresentatives.resize(27, -1); diff --git a/core/base/multiresTriangulation/MultiresTriangulation.h b/core/base/multiresTriangulation/MultiresTriangulation.h index fbbb5a9506..6234be2b78 100644 --- a/core/base/multiresTriangulation/MultiresTriangulation.h +++ b/core/base/multiresTriangulation/MultiresTriangulation.h @@ -1036,7 +1036,7 @@ namespace ttk { inline bool ttk::MultiresTriangulation::areVerticesNeighbors( const SimplexId vertexId0, const SimplexId vertexId1) const { - SimplexId neighborNumber = getVertexNeighborNumber(vertexId0); + const SimplexId neighborNumber = getVertexNeighborNumber(vertexId0); for(SimplexId i = 0; i < neighborNumber; i++) { SimplexId neighborId; getVertexNeighbor(vertexId0, i, neighborId); diff --git a/core/base/octree/Octree.cpp b/core/base/octree/Octree.cpp index 7bf32619a1..d1380404a2 100644 --- a/core/base/octree/Octree.cpp +++ b/core/base/octree/Octree.cpp @@ -16,7 +16,7 @@ Octree::~Octree() = default; // Initialize the octree with the given triangulation and bucket threshold. void Octree::initialize(const AbstractTriangulation *t, const int k) { this->setDebugMsgPrefix("PR Octree"); - OctreeNode root(1); + OctreeNode const root(1); allNodes_[1] = root; capacity_ = k; triangulation_ = t; @@ -24,9 +24,9 @@ void Octree::initialize(const AbstractTriangulation *t, const int k) { // find the minimum and maximum coordinate values float mins[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; float maxs[3] = {FLT_MIN, FLT_MIN, FLT_MIN}; - SimplexId vertexNum = t->getNumberOfVertices(); + SimplexId const vertexNum = t->getNumberOfVertices(); for(int i = 0; i < vertexNum; i++) { - float coord[3]; + float coord[3] = {0, 0, 0}; t->getVertexPoint(i, coord[0], coord[1], coord[2]); for(int j = 0; j < 3; j++) { if(coord[j] < mins[j]) @@ -160,7 +160,7 @@ int Octree::insertCell(SimplexId &cellId) { return -1; } - int dim = triangulation_->getCellVertexNumber(cellId); + int const dim = triangulation_->getCellVertexNumber(cellId); std::array ncenter{}, nsize{}; for(int i = 0; i < dim; i++) { SimplexId vertexId{}; @@ -197,7 +197,7 @@ int Octree::insertCell(SimplexId &cellId) { void Octree::reindex(vector &vertices, vector &nodes, vector &cells) { - int totalCells = triangulation_->getNumberOfCells(); + int const totalCells = triangulation_->getNumberOfCells(); vector cellMap(totalCells, -1); OctreeNode *root = lookupNode(1); @@ -345,7 +345,7 @@ void Octree::subdivide(OctreeNode *node) { computeCenterSize(node->locCode_, ncenter, nsize); - for(int v : node->vertexIds_) { + for(int const v : node->vertexIds_) { childCode = getChildLocation(node->locCode_, v, ncenter); OctreeNode *childNode = lookupNode(childCode); diff --git a/core/base/pathCompression/PathCompression.h b/core/base/pathCompression/PathCompression.h index 65b9fd2434..ccc565d983 100644 --- a/core/base/pathCompression/PathCompression.h +++ b/core/base/pathCompression/PathCompression.h @@ -237,7 +237,7 @@ int ttk::PathCompression::computePathCompression( // find the largest and smallest neighbor for each vertex for(SimplexId i = 0; i < nVertices; i++) { SimplexId neighborId{0}; - SimplexId numNeighbors = triangulation.getVertexNeighborNumber(i); + SimplexId const numNeighbors = triangulation.getVertexNeighborNumber(i); bool hasLargerNeighbor = false; SimplexId &dmi = dscSegmentation[i]; @@ -271,7 +271,7 @@ int ttk::PathCompression::computePathCompression( // compress paths until no changes occur while(lnActiveVertices > 0) { for(size_t i = 0; i < lnActiveVertices; i++) { - SimplexId &v = lActiveVertices[i]; + SimplexId const &v = lActiveVertices[i]; SimplexId &vDsc = dscSegmentation[v]; SimplexId &vAsc = ascSegmentation[v]; @@ -330,7 +330,7 @@ int ttk::PathCompression::computePathCompressionSingle( // find the largest neighbor for each vertex for(SimplexId i = 0; i < nVertices; i++) { SimplexId neighborId{0}; - SimplexId numNeighbors = triangulation.getVertexNeighborNumber(i); + SimplexId const numNeighbors = triangulation.getVertexNeighborNumber(i); bool hasLargerNeighbor = false; SimplexId &mi = segmentation[i]; @@ -364,7 +364,7 @@ int ttk::PathCompression::computePathCompressionSingle( // compress paths until no changes occur while(lnActiveVertices > 0) { for(size_t i = 0; i < lnActiveVertices; i++) { - SimplexId &v = lActiveVertices[i]; + SimplexId const &v = lActiveVertices[i]; SimplexId &vMan = segmentation[v]; // compress paths diff --git a/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.cpp b/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.cpp index 196a9e22de..5f61d96cea 100644 --- a/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.cpp +++ b/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.cpp @@ -200,9 +200,9 @@ int PeriodicImplicitTriangulation::checkAcceleration() { isAccelerated_ = true; } } else if(dimensionality_ == 2) { - bool isDi = isPowerOfTwo(dimensions_[Di_], msb[Di_]); - bool isDj = isPowerOfTwo(dimensions_[Dj_], msb[Dj_]); - bool allDimensionsArePowerOfTwo = (isDi and isDj); + bool const isDi = isPowerOfTwo(dimensions_[Di_], msb[Di_]); + bool const isDj = isPowerOfTwo(dimensions_[Dj_], msb[Dj_]); + bool const allDimensionsArePowerOfTwo = (isDi and isDj); if(allDimensionsArePowerOfTwo) { mod_[0] = dimensions_[Di_] - 1; diff --git a/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.h b/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.h index c196fc75a7..b60c7c0e6d 100644 --- a/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.h +++ b/core/base/periodicImplicitTriangulation/PeriodicImplicitTriangulation.h @@ -1037,8 +1037,8 @@ inline ttk::SimplexId inline ttk::SimplexId ttk::PeriodicImplicitTriangulation::getEdgeLink2dD1(const SimplexId p[2], const int id) const { - SimplexId wrapX = (p[0] < nbvoxels_[Di_]) ? 0 : wrap_[0]; - SimplexId wrapY = (p[1] < nbvoxels_[Dj_]) ? 0 : wrap_[1]; + const SimplexId wrapX = (p[0] < nbvoxels_[Di_]) ? 0 : wrap_[0]; + const SimplexId wrapY = (p[1] < nbvoxels_[Dj_]) ? 0 : wrap_[1]; switch(id) { case 0: return p[0] + p[1] * vshift_[0]; diff --git a/core/base/persistenceDiagram/PersistenceDiagram.cpp b/core/base/persistenceDiagram/PersistenceDiagram.cpp index 6c7191d80c..e7ae8d4c0a 100644 --- a/core/base/persistenceDiagram/PersistenceDiagram.cpp +++ b/core/base/persistenceDiagram/PersistenceDiagram.cpp @@ -22,7 +22,7 @@ CriticalType PersistenceDiagram::getNodeType(FTMTree_MT *tree, upDegree = node->getNumberOfDownSuperArcs(); downDegree = node->getNumberOfUpSuperArcs(); } - int degree = upDegree + downDegree; + int const degree = upDegree + downDegree; // saddle point if(degree > 1) { diff --git a/core/base/persistenceDiagram/PersistenceDiagram.h b/core/base/persistenceDiagram/PersistenceDiagram.h index fdd1e6e9c5..7d9eda53d0 100644 --- a/core/base/persistenceDiagram/PersistenceDiagram.h +++ b/core/base/persistenceDiagram/PersistenceDiagram.h @@ -425,7 +425,7 @@ int ttk::PersistenceDiagram::executePersistentSimplex( const SimplexId *inputOffsets, const triangulationType *triangulation) { - Timer tm{}; + Timer const tm{}; const auto dim = triangulation->getDimensionality(); std::vector pairs{}; @@ -499,7 +499,7 @@ int ttk::PersistenceDiagram::executeDiscreteMorseSandwich( const SimplexId *inputOffsets, const triangulationType *triangulation) { - Timer tm{}; + Timer const tm{}; const auto dim = triangulation->getDimensionality(); dms_.buildGradient(inputScalars, scalarsMTime, inputOffsets, *triangulation); diff --git a/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.cpp b/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.cpp index 64e28742c3..8f2167fa99 100644 --- a/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.cpp +++ b/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.cpp @@ -2,7 +2,7 @@ void ttk::PersistenceDiagramAuction::runAuctionRound(int &n_biddings, const int kdt_index) { - double max_price = getMaximalPrice(); + double const max_price = getMaximalPrice(); double epsilon = epsilon_; if(epsilon_ < 1e-6 * max_price) { // Risks of floating point limits reached... @@ -10,7 +10,7 @@ void ttk::PersistenceDiagramAuction::runAuctionRound(int &n_biddings, } while(unassignedBidders_.size() > 0) { n_biddings++; - int pos = unassignedBidders_.front(); + int const pos = unassignedBidders_.front(); Bidder &b = this->bidders_[pos]; unassignedBidders_.pop(); @@ -50,16 +50,16 @@ void ttk::PersistenceDiagramAuction::runAuctionRound(int &n_biddings, double ttk::PersistenceDiagramAuction::getMaximalPrice() { double max_price = 0; for(size_t i = 0; i < goods_.size(); ++i) { - Good &g = goods_[i]; - double price = g.getPrice(); + Good const &g = goods_[i]; + double const price = g.getPrice(); if(price > max_price) { max_price = price; } } for(size_t i = 0; i < diagonal_goods_.size(); ++i) { - Good &g = diagonal_goods_[i]; - double price = g.getPrice(); + Good const &g = diagonal_goods_[i]; + double const price = g.getPrice(); if(price > max_price) { max_price = price; } @@ -72,15 +72,15 @@ double ttk::PersistenceDiagramAuction::getMatchingsAndDistance( std::vector &matchings, bool get_diagonal_matches) { double wassersteinDistance = 0; for(size_t i = 0; i < bidders_.size(); i++) { - Bidder &b = bidders_[i]; + Bidder const &b = bidders_[i]; if(!b.isDiagonal()) { - int good_id = b.getProperty().id_; + int const good_id = b.getProperty().id_; double cost; if(good_id > -1) { // good is not diagonal cost = b.cost(b.getProperty(), wasserstein_, geometricalFactor_); - MatchingType t = std::make_tuple(i, good_id, cost); + MatchingType const t = std::make_tuple(i, good_id, cost); matchings.emplace_back(t); } else { if(!b.getProperty().isDiagonal()) { @@ -88,7 +88,7 @@ double ttk::PersistenceDiagramAuction::getMatchingsAndDistance( } cost = 2.0 * Geometry::pow(std::abs((b.y_ - b.x_) / 2.0), wasserstein_); if(get_diagonal_matches) { - MatchingType t = std::make_tuple(i, good_id, cost); + MatchingType const t = std::make_tuple(i, good_id, cost); matchings.emplace_back(t); } } @@ -96,10 +96,10 @@ double ttk::PersistenceDiagramAuction::getMatchingsAndDistance( } else { // b is diagonal const Good &g = b.getProperty(); - double cost + double const cost = 2.0 * Geometry::pow(std::abs((g.y_ - g.x_) / 2.0), wasserstein_); if(get_diagonal_matches) { - MatchingType t = std::make_tuple(b.id_, g.id_, cost); + MatchingType const t = std::make_tuple(b.id_, g.id_, cost); matchings.emplace_back(t); } wassersteinDistance += cost; @@ -122,12 +122,12 @@ double ttk::PersistenceDiagramAuction::initLowerBoundCost(const int kdt_index) { std::array coordinates; bidders_[i].GetKDTCoordinates(geometricalFactor_, coordinates); kdt_.getKClosest(1, coordinates, neighbours, costs, kdt_index); - int bestIndex = neighbours[0]->id_; + int const bestIndex = neighbours[0]->id_; bestCost = bidders_[i].cost(goods_[bestIndex], wasserstein_, geometricalFactor_); } else { for(unsigned int j = 0; j < goods_.size(); ++j) { - double cost + double const cost = bidders_[i].cost(goods_[j], wasserstein_, geometricalFactor_); if(cost < bestCost) bestCost = cost; @@ -137,7 +137,7 @@ double ttk::PersistenceDiagramAuction::initLowerBoundCost(const int kdt_index) { // Compare with diagonal good Good g{bidders_[i].x_, bidders_[i].y_, true, -bidders_[i].id_ - 1}; g.projectOnDiagonal(); - double cost = bidders_[i].cost(g, wasserstein_, geometricalFactor_); + double const cost = bidders_[i].cost(g, wasserstein_, geometricalFactor_); if(cost < bestCost) bestCost = cost; @@ -161,7 +161,8 @@ double ttk::PersistenceDiagramAuction::run(std::vector &matchings, this->runAuctionRound(n_biddings, kdt_index); delta = this->getRelativePrecision(); } - double wassersteinDistance = this->getMatchingsAndDistance(matchings, true); + double const wassersteinDistance + = this->getMatchingsAndDistance(matchings, true); return wassersteinDistance; } @@ -233,7 +234,7 @@ int ttk::Bidder::runBidding(GoodDiagram *goods, if(best_good == nullptr) { return -1; } - double old_price = best_good->getPrice(); + double const old_price = best_good->getPrice(); double new_price = old_price + best_val - second_val + epsilon; if(new_price > std::numeric_limits::max() / 2) { new_price = old_price + epsilon; @@ -244,7 +245,7 @@ int ttk::Bidder::runBidding(GoodDiagram *goods, // Assign best_good to bidder and unassign the previous owner of best_good // if need be - int idx_reassigned = best_good->getOwner(); + int const idx_reassigned = best_good->getOwner(); best_good->assign(this->position_in_auction_, new_price); return idx_reassigned; } @@ -267,14 +268,14 @@ int ttk::Bidder::runDiagonalBidding( bool updated_top_pair = false; // Boolean which equals true iff the top pair in the priority // queue is given the good price - bool non_empty_goods = goods->size() > 0; + bool const non_empty_goods = goods->size() > 0; std::pair best_pair; if(non_empty_goods) { while(!updated_top_pair) { std::pair top_pair = diagonal_queue.top(); diagonal_queue.pop(); - double queue_weight = top_pair.second; + double const queue_weight = top_pair.second; const auto &good = (*goods)[top_pair.first]; if(good.getPrice() > queue_weight) { // If the weight in the priority queue is not the good one, update @@ -292,7 +293,7 @@ int ttk::Bidder::runDiagonalBidding( bool updated_second_pair = false; while(!updated_second_pair) { second_pair = diagonal_queue.top(); - double queue_weight = second_pair.second; + double const queue_weight = second_pair.second; const auto &good = (*goods)[second_pair.first]; if(good.getPrice() != queue_weight) { // If the weight in the priority queue is not the good one, update it @@ -339,7 +340,7 @@ int ttk::Bidder::runDiagonalBidding( // There is only one acceptable good for the bidder second_val = best_val; } - double old_price = best_good->getPrice(); + double const old_price = best_good->getPrice(); double new_price = old_price + best_val - second_val + epsilon; if(new_price > std::numeric_limits::max() / 2) { new_price = old_price + epsilon; @@ -351,7 +352,7 @@ int ttk::Bidder::runDiagonalBidding( // Assign best_good to bidder and unassign the previous owner of best_good // if need be - int idx_reassigned = best_good->getOwner(); + int const idx_reassigned = best_good->getOwner(); best_good->assign(this->position_in_auction_, new_price); if(!is_twin) { std::get<1>(best_pair) = new_price; @@ -383,12 +384,12 @@ int ttk::Bidder::runDiagonalKDTBidding( bool updated_top_pair = false; // Boolean which equals true iff the top pair in the priority // queue is given the good price - bool non_empty_goods = goods->size() > 0; + bool const non_empty_goods = goods->size() > 0; std::pair best_pair; if(non_empty_goods) { while(!updated_top_pair) { std::pair top_pair = diagonal_queue.top(); - double queue_weight = top_pair.second; + double const queue_weight = top_pair.second; const auto &good = (*goods)[top_pair.first]; diagonal_queue.pop(); @@ -407,7 +408,7 @@ int ttk::Bidder::runDiagonalKDTBidding( bool updated_second_pair = false; while(!updated_second_pair) { second_pair = diagonal_queue.top(); - double queue_weight = second_pair.second; + double const queue_weight = second_pair.second; const auto &good = (*goods)[second_pair.first]; if(good.getPrice() > queue_weight) { // If the weight in the priority queue is not the good one, update it @@ -454,7 +455,7 @@ int ttk::Bidder::runDiagonalKDTBidding( // There is only one acceptable good for the bidder second_val = best_val; } - double old_price = best_good->getPrice(); + double const old_price = best_good->getPrice(); double new_price = old_price + best_val - second_val + epsilon; if(new_price > std::numeric_limits::max() / 2) { new_price = old_price + epsilon; @@ -466,7 +467,7 @@ int ttk::Bidder::runDiagonalKDTBidding( // Assign best_good to bidder and unassign the previous owner of best_good // if need be - int idx_reassigned = best_good->getOwner(); + int const idx_reassigned = best_good->getOwner(); best_good->assign(this->position_in_auction_, new_price); if(is_twin) { // Update weight in KDTree if the closest good is in it @@ -538,7 +539,7 @@ int ttk::Bidder::runKDTBidding(GoodDiagram *goods, // There is only one acceptable good for the bidder second_val = best_val; } - double old_price = best_good->getPrice(); + double const old_price = best_good->getPrice(); double new_price = old_price + best_val - second_val + epsilon; if(new_price > std::numeric_limits::max() / 2) { new_price = old_price + epsilon; @@ -548,7 +549,7 @@ int ttk::Bidder::runKDTBidding(GoodDiagram *goods, this->setPricePaid(new_price); // Assign best_good to bidder and unassign the previous owner of best_good // if need be - int idx_reassigned = best_good->getOwner(); + int const idx_reassigned = best_good->getOwner(); best_good->assign(this->position_in_auction_, new_price); // Update the price in the KDTree diff --git a/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.h b/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.h index eaa9bcf727..4c679c884f 100644 --- a/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.h +++ b/core/base/persistenceDiagramAuction/PersistenceDiagramAuction.h @@ -54,7 +54,7 @@ namespace ttk { for(int i = 0; i < n_bidders_; i++) { // Add diagonal goods - Bidder &b = bidders_[i]; + Bidder const &b = bidders_[i]; Good g{b.x_, b.y_, true, -b.id_ - 1}; g.projectOnDiagonal(); if(b.diagonal_price_ > 0) { @@ -63,12 +63,12 @@ namespace ttk { g.setPrice(initial_diag_price); } diagonal_goods_.emplace_back(g); - std::pair pair = std::make_pair(i, g.getPrice()); + std::pair const pair = std::make_pair(i, g.getPrice()); diagonal_queue_.push(pair); } for(int i = 0; i < n_goods_; i++) { // Add diagonal bidders - Good &g = goods_[i]; + Good const &g = goods_[i]; Bidder b{g.x_, g.y_, true, -g.id_ - 1}; b.projectOnDiagonal(); b.setPositionInAuction(bidders_.size()); @@ -103,16 +103,16 @@ namespace ttk { for(int i = 0; i < n_bidders_; i++) { // Add diagonal goods - Bidder &b = bidders_[i]; + Bidder const &b = bidders_[i]; Good g{b.x_, b.y_, true, -b.id_ - 1}; g.projectOnDiagonal(); diagonal_goods_.emplace_back(g); - std::pair pair = std::make_pair(i, g.getPrice()); + std::pair const pair = std::make_pair(i, g.getPrice()); diagonal_queue_.push(pair); } for(int i = 0; i < n_goods_; i++) { // Add diagonal bidders - Good &g = goods_[i]; + Good const &g = goods_[i]; Bidder b{g.x_, g.y_, true, -g.id_ - 1}; b.projectOnDiagonal(); b.setPositionInAuction(bidders_.size()); @@ -134,16 +134,16 @@ namespace ttk { this->setGoods(diagram2); for(int i = 0; i < n_bidders_; i++) { // Add diagonal goods - Bidder &b = bidders_[i]; + Bidder const &b = bidders_[i]; Good g{b.x_, b.y_, true, -b.id_ - 1}; g.projectOnDiagonal(); diagonal_goods_.emplace_back(g); - std::pair pair = std::make_pair(i, g.getPrice()); + std::pair const pair = std::make_pair(i, g.getPrice()); diagonal_queue_.push(pair); } for(int i = 0; i < n_goods_; i++) { // Add diagonal bidders - Good &g = goods_[i]; + Good const &g = goods_[i]; Bidder b{g.x_, g.y_, true, -g.id_ - 1}; b.projectOnDiagonal(); b.setPositionInAuction(bidders_.size()); @@ -170,14 +170,14 @@ namespace ttk { void setGoods(const DiagramType &diagram2) { for(size_t i = 0; i < diagram2.size(); i++) { // Add bidder to bidders - Good g{diagram2[i], static_cast(i), lambda_}; + Good const g{diagram2[i], static_cast(i), lambda_}; goods_.emplace_back(g); } n_goods_ = goods_.size(); } void buildKDTree() { - Timer t; + Timer const t; default_kdt_ = KDT{true, wasserstein_}; const int dimension = geometricalFactor_ >= 1 ? (geometricalFactor_ <= 0 ? 3 : 2) : 5; @@ -205,13 +205,13 @@ namespace ttk { void initializeEpsilon() { double max_persistence = 0; for(const auto &b : this->bidders_) { - double persistence = b.getPersistence(); + double const persistence = b.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } } for(const auto &g : this->goods_) { - double persistence = g.getPersistence(); + double const persistence = g.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } @@ -239,18 +239,18 @@ namespace ttk { double getMatchingDistance() { double d = 0; for(size_t i = 0; i < bidders_.size(); i++) { - Bidder &b = bidders_[i]; + Bidder const &b = bidders_[i]; d += b.cost(b.getProperty(), wasserstein_, geometricalFactor_); } return d; } double getRelativePrecision() { - double d = this->getMatchingDistance(); + double const d = this->getMatchingDistance(); if(d < 1e-6 or d <= (lowerBoundCost_ * lowerBoundCostWeight_)) { return 0; } - double denominator = d - bidders_.size() * epsilon_; + double const denominator = d - bidders_.size() * epsilon_; if(denominator <= 0) { return 1; } else { @@ -271,7 +271,7 @@ namespace ttk { } double min_price = std::numeric_limits::max(); for(size_t i = 0; i < diagonal_goods_.size(); i++) { - double price = diagonal_goods_[i].getPrice(); + double const price = diagonal_goods_[i].getPrice(); if(price < min_price) { min_price = price; } diff --git a/core/base/persistenceDiagramClustering/PDBarycenter.cpp b/core/base/persistenceDiagramClustering/PDBarycenter.cpp index 2e220a03cf..fe90c3e8ad 100644 --- a/core/base/persistenceDiagramClustering/PDBarycenter.cpp +++ b/core/base/persistenceDiagramClustering/PDBarycenter.cpp @@ -34,14 +34,14 @@ void ttk::PDBarycenter::runMatching( std::vector> *all_matchings, bool use_kdt, bool actual_distance) { - Timer time_matchings; + Timer const time_matchings; double local_cost = *total_cost; #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) schedule(dynamic, 1) reduction(+:local_cost) #endif for(int i = 0; i < numberOfInputs_; i++) { - double delta_lim = 0.01; + double const delta_lim = 0.01; PersistenceDiagramAuction auction( current_bidder_diagrams_[i], barycenter_goods_[i], wasserstein_, geometrical_factor_, lambda_, delta_lim, kdt, correspondence_kdt_map, @@ -56,7 +56,7 @@ void ttk::PDBarycenter::runMatching( min_diag_price->at(i) = auction.getMinimalDiagonalPrice(); min_price->at(i) = getMinimalPrice(i); std::vector matchings; - double cost = auction.getMatchingsAndDistance(matchings, true); + double const cost = auction.getMatchingsAndDistance(matchings, true); all_matchings->at(i) = matchings; if(actual_distance) { local_cost += sqrt(cost); @@ -64,7 +64,8 @@ void ttk::PDBarycenter::runMatching( local_cost += cost; } - double quotient = epsilon * auction.getAugmentedNumberOfBidders() / cost; + double const quotient + = epsilon * auction.getAugmentedNumberOfBidders() / cost; precision_[i] = quotient < 1 ? 1. / sqrt(1 - quotient) - 1 : 10; if(auction.getRelativePrecision() == 0) precision_[i] = 0; @@ -95,7 +96,7 @@ void ttk::PDBarycenter::runMatchingAuction( geometrical_factor_, lambda_, 0.01, kdt, correspondence_kdt_map, 0, (*min_diag_price)[i], use_kdt); std::vector matchings; - double cost = auction.run(matchings, i); + double const cost = auction.run(matchings, i); all_matchings->at(i) = matchings; if(actual_distance) { local_cost += sqrt(cost); @@ -140,7 +141,7 @@ std::vector> ttk::PDBarycenter::correctMatchings( // 1. Invert the current_bidder_ids_ vector std::vector new_to_old_id(current_bidder_diagrams_[i].size()); for(size_t j = 0; j < current_bidder_ids_[i].size(); j++) { - int new_id = current_bidder_ids_[i][j]; + int const new_id = current_bidder_ids_[i][j]; if(new_id >= 0) { new_to_old_id[new_id] = j; } @@ -149,7 +150,7 @@ std::vector> ttk::PDBarycenter::correctMatchings( std::vector matchings_diagram_i; for(size_t j = 0; j < previous_matchings[i].size(); j++) { MatchingType m = previous_matchings[i][j]; - int new_id = std::get<0>(m); + int const new_id = std::get<0>(m); if(new_id >= 0 && std::get<1>(m) >= 0) { std::get<0>(m) = new_to_old_id[new_id]; matchings_diagram_i.push_back(m); @@ -163,10 +164,10 @@ std::vector> ttk::PDBarycenter::correctMatchings( double ttk::PDBarycenter::updateBarycenter( std::vector> &matchings) { // 1. Initialize variables used in the sequel - Timer t_update; - size_t n_goods = barycenter_goods_[0].size(); + Timer const t_update; + size_t const n_goods = barycenter_goods_[0].size(); - size_t n_diagrams = current_bidder_diagrams_.size(); + size_t const n_diagrams = current_bidder_diagrams_.size(); points_added_ = 0; points_deleted_ = 0; double max_shift = 0; @@ -196,8 +197,8 @@ double ttk::PDBarycenter::updateBarycenter( // 2. Preprocess the matchings for(size_t j = 0; j < matchings.size(); j++) { for(size_t i = 0; i < matchings[j].size(); i++) { - int bidder_id = std::get<0>(matchings[j][i]); - int good_id = std::get<1>(matchings[j][i]); + int const bidder_id = std::get<0>(matchings[j][i]); + int const good_id = std::get<1>(matchings[j][i]); if(good_id < 0 && bidder_id >= 0) { // Future new barycenter point points_to_append.push_back(¤t_bidder_diagrams_[j].at(bidder_id)); @@ -228,30 +229,34 @@ double ttk::PDBarycenter::updateBarycenter( if(count_diag_matchings[i] < n_diagrams) { // Barycenter point i is matched at least to one off-diagonal bidder // 3.1 Compute the arithmetic mean of off-diagonal bidders linked to it - double x_bar = x[i] / (double)(n_diagrams - count_diag_matchings[i]); - double y_bar = y[i] / (double)(n_diagrams - count_diag_matchings[i]); + double const x_bar + = x[i] / (double)(n_diagrams - count_diag_matchings[i]); + double const y_bar + = y[i] / (double)(n_diagrams - count_diag_matchings[i]); // 3.2 Compute the new coordinates of the point (the more linked to the // diagonal it was, the closer to the diagonal it'll be) - double new_x = ((double)(n_diagrams - count_diag_matchings[i]) * x_bar - + (double)count_diag_matchings[i] * (x_bar + y_bar) / 2.) - / (double)n_diagrams; - double new_y = ((double)(n_diagrams - count_diag_matchings[i]) * y_bar - + (double)count_diag_matchings[i] * (x_bar + y_bar) / 2.) - / (double)n_diagrams; + double const new_x + = ((double)(n_diagrams - count_diag_matchings[i]) * x_bar + + (double)count_diag_matchings[i] * (x_bar + y_bar) / 2.) + / (double)n_diagrams; + double const new_y + = ((double)(n_diagrams - count_diag_matchings[i]) * y_bar + + (double)count_diag_matchings[i] * (x_bar + y_bar) / 2.) + / (double)n_diagrams; // TODO Weight by persistence - double new_crit_coord_x + double const new_crit_coord_x = crit_coords_x[i] / (double)(n_diagrams - count_diag_matchings[i]); - double new_crit_coord_y + double const new_crit_coord_y = crit_coords_y[i] / (double)(n_diagrams - count_diag_matchings[i]); - double new_crit_coord_z + double const new_crit_coord_z = crit_coords_z[i] / (double)(n_diagrams - count_diag_matchings[i]); // 3.3 Compute and store how much the point has shifted // TODO adjust shift with geometrical_factor_ - double dx = barycenter_goods_[0].at(i).x_ - new_x; - double dy = barycenter_goods_[0].at(i).y_ - new_y; - double shift = Geometry::pow(std::abs(dx), wasserstein_) - + Geometry::pow(std::abs(dy), wasserstein_); + double const dx = barycenter_goods_[0].at(i).x_ - new_x; + double const dy = barycenter_goods_[0].at(i).y_ - new_y; + double const shift = Geometry::pow(std::abs(dx), wasserstein_) + + Geometry::pow(std::abs(dy), wasserstein_); if(shift > max_shift) { max_shift = shift; } @@ -280,7 +285,7 @@ double ttk::PDBarycenter::updateBarycenter( for(size_t i = 0; i < n_goods; i++) { if(count_diag_matchings[i] == n_diagrams) { points_deleted_ += 1; - double shift + double const shift = 2 * Geometry::pow( barycenter_goods_[0].at(i).getPersistence() / 2., wasserstein_); @@ -297,9 +302,9 @@ double ttk::PDBarycenter::updateBarycenter( for(size_t k = 0; k < points_to_append.size(); k++) { points_added_ += 1; Bidder *b = points_to_append[k]; - double gx + double const gx = (b->x_ + (n_diagrams - 1) * (b->x_ + b->y_) / 2.) / (n_diagrams); - double gy + double const gy = (b->y_ + (n_diagrams - 1) * (b->x_ + b->y_) / 2.) / (n_diagrams); const auto &critical_coordinates = b->GetCriticalCoordinates(); for(size_t j = 0; j < n_diagrams; j++) { @@ -311,7 +316,7 @@ double ttk::PDBarycenter::updateBarycenter( std::get<2>(critical_coordinates)); } barycenter_goods_[j].emplace_back(g); - double shift + double const shift = 2 * Geometry::pow( barycenter_goods_[j].at(g.id_).getPersistence() / 2., wasserstein_); @@ -391,7 +396,7 @@ double ttk::PDBarycenter::enrichCurrentBidderDiagrams( max_diagram_size = current_bidder_diagrams_[i].size(); } } - int max_points_to_add = std::max( + int const max_points_to_add = std::max( min_points_to_add, min_points_to_add + (int)(max_diagram_size / 10)); // 2. Get which points can be added, deduce the new minimal persistence @@ -401,8 +406,8 @@ double ttk::PDBarycenter::enrichCurrentBidderDiagrams( std::vector persistences; for(size_t j = 0; j < bidder_diagrams_[i].size(); j++) { - Bidder b = bidder_diagrams_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_[i].at(j); + double const persistence = b.getPersistence(); if(persistence >= min_persistence && persistence < previous_min_persistence) { candidates_to_be_added[i].push_back(j); @@ -414,9 +419,9 @@ double ttk::PDBarycenter::enrichCurrentBidderDiagrams( return ((persistences[a] > persistences[b]) || ((persistences[a] == persistences[b]) && (a > b))); }); - int size = candidates_to_be_added[i].size(); + int const size = candidates_to_be_added[i].size(); if(size >= max_points_to_add) { - double last_persistence_added + double const last_persistence_added = persistences[idx[i][max_points_to_add - 1]]; if(last_persistence_added > new_min_persistence) { new_min_persistence = last_persistence_added; @@ -430,7 +435,7 @@ double ttk::PDBarycenter::enrichCurrentBidderDiagrams( int compteur_for_adding_points = 0; for(int i = 0; i < numberOfInputs_; i++) { - int size = candidates_to_be_added[i].size(); + int const size = candidates_to_be_added[i].size(); for(int j = 0; j < std::min(max_points_to_add, size); j++) { Bidder b = bidder_diagrams_[i].at(candidates_to_be_added[i][idx[i][j]]); if(b.getPersistence() >= new_min_persistence) { @@ -442,7 +447,7 @@ double ttk::PDBarycenter::enrichCurrentBidderDiagrams( current_bidder_ids_[i][candidates_to_be_added[i][idx[i][j]]] = current_bidder_diagrams_[i].size() - 1; - int to_be_added_to_barycenter + int const to_be_added_to_barycenter = deterministic_ ? compteur_for_adding_points % numberOfInputs_ : rand() % numberOfInputs_; // We add the bidder as a good with probability 1/n_diagrams @@ -467,8 +472,8 @@ double ttk::PDBarycenter::getMaxPersistence() { BidderDiagram &D = bidder_diagrams_[i]; for(size_t j = 0; j < D.size(); j++) { // Add bidder to bidders - Bidder &b = D.at(j); - double persistence = b.getPersistence(); + Bidder const &b = D.at(j); + double const persistence = b.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } @@ -485,8 +490,8 @@ double ttk::PDBarycenter::getMinimalPrice(int i) { return 0; } for(size_t j = 0; j < D.size(); j++) { - Good &b = D.at(j); - double price = b.getPrice(); + Good const &b = D.at(j); + double const price = b.getPrice(); if(price < min_price) { min_price = price; } @@ -503,8 +508,8 @@ double ttk::PDBarycenter::getLowestPersistence() { BidderDiagram &D = bidder_diagrams_[i]; for(size_t j = 0; j < D.size(); j++) { // Add bidder to bidders - Bidder &b = D.at(j); - double persistence = b.getPersistence(); + Bidder const &b = D.at(j); + double const persistence = b.getPersistence(); if(persistence < lowest_persistence && persistence > 0) { lowest_persistence = persistence; } @@ -530,7 +535,7 @@ void ttk::PDBarycenter::setInitialBarycenter(double min_persistence) { int count = 0; for(size_t j = 0; j < CTDiagram->size(); j++) { // Add bidder to bidders - Good g = Good((*CTDiagram)[j], count, lambda_); + Good const g = Good((*CTDiagram)[j], count, lambda_); if(g.getPersistence() >= min_persistence) { goods.emplace_back(g); count++; @@ -568,7 +573,7 @@ typename ttk::PDBarycenter::KDTreePair ttk::PDBarycenter::getKDTree() const { } for(size_t idx = 0; idx < barycenter_goods_.size(); idx++) { - std::vector empty_weights; + std::vector const empty_weights; weights.push_back(empty_weights); for(size_t i = 0; i < barycenter_goods_[idx].size(); i++) { const Good &g = barycenter_goods_[idx].at(i); @@ -589,7 +594,7 @@ std::vector> ttk::PDBarycenter::executeAuctionBarycenter(DiagramType &barycenter) { std::vector> previous_matchings; - double min_persistence = 0; + double const min_persistence = 0; double min_cost = std::numeric_limits::max(); int last_min_cost_obtained = 0; @@ -597,7 +602,7 @@ std::vector> this->setInitialBarycenter( min_persistence); // false for a determinist initialization - double max_persistence = getMaxPersistence(); + double const max_persistence = getMaxPersistence(); std::vector min_diag_price(numberOfInputs_); std::vector min_price(numberOfInputs_); @@ -606,7 +611,7 @@ std::vector> min_price[i] = 0; } - int min_points_to_add = std::numeric_limits::max(); + int const min_points_to_add = std::numeric_limits::max(); this->enrichCurrentBidderDiagrams(2 * max_persistence, min_persistence, min_diag_price, min_price, min_points_to_add, false); @@ -616,7 +621,7 @@ std::vector> double total_cost; while(!finished) { - Timer tm; + Timer const tm; std::pair, std::vector> pair; bool use_kdt = false; @@ -637,13 +642,13 @@ std::vector> barycenter.clear(); for(size_t j = 0; j < barycenter_goods_[0].size(); j++) { - Good &g = barycenter_goods_[0].at(j); + Good const &g = barycenter_goods_[0].at(j); barycenter.emplace_back(PersistencePair{CriticalVertex{0, nt1_, g.x_, {}}, CriticalVertex{0, nt2_, g.y_, {}}, diagramType_, true}); } - bool actual_distance = (numberOfInputs_ == 2); + bool const actual_distance = (numberOfInputs_ == 2); runMatchingAuction(&total_cost, sizes, *pair.first, pair.second, &min_diag_price, &all_matchings, use_kdt, actual_distance); @@ -688,7 +693,7 @@ std::vector> } barycenter.resize(0); for(size_t j = 0; j < barycenter_goods_[0].size(); j++) { - Good &g = barycenter_goods_[0].at(j); + Good const &g = barycenter_goods_[0].at(j); barycenter.emplace_back(PersistencePair{CriticalVertex{0, nt1_, g.x_, {}}, CriticalVertex{0, nt2_, g.y_, {}}, diagramType_, true}); @@ -706,10 +711,10 @@ double ttk::PDBarycenter::computeRealCost() { for(int i = 0; i < numberOfInputs_; i++) { PersistenceDiagramAuction auction( wasserstein_, geometrical_factor_, lambda_, 0.01, true); - GoodDiagram current_barycenter = barycenter_goods_[0]; - BidderDiagram current_bidder_diagram = bidder_diagrams_[i]; + GoodDiagram const current_barycenter = barycenter_goods_[0]; + BidderDiagram const current_bidder_diagram = bidder_diagrams_[i]; auction.BuildAuctionDiagrams(current_bidder_diagram, current_barycenter); - double cost = auction.run(fake_matchings); + double const cost = auction.run(fake_matchings); total_real_cost += cost * cost; } return sqrt(total_real_cost); @@ -724,7 +729,7 @@ bool ttk::PDBarycenter::isPrecisionObjectiveMet(double precision_objective, } } } else if(mode == 1) { // AVERAGE PRECISION - double average_precision + double const average_precision = std::accumulate(precision_.begin(), precision_.end(), 0.0) / numberOfInputs_; if(average_precision > precision_objective) { diff --git a/core/base/persistenceDiagramClustering/PDClustering.cpp b/core/base/persistenceDiagramClustering/PDClustering.cpp index 6032182ef4..e8bacc94be 100644 --- a/core/base/persistenceDiagramClustering/PDClustering.cpp +++ b/core/base/persistenceDiagramClustering/PDClustering.cpp @@ -34,7 +34,7 @@ std::vector ttk::PDClustering::execute( } } int matchings_only = false; - Timer tm; + Timer const tm; { // PARTICULARITIES FOR THE CASE OF ONE UNIQUE CLUSTER if(k_ <= 1) { @@ -285,7 +285,7 @@ std::vector ttk::PDClustering::execute( precision_criterion_ = precision_min_ && precision_sad_ && precision_max_; - bool precision_criterion_reached = precision_criterion_; + bool const precision_criterion_reached = precision_criterion_; this->printMsg("Iteration " + std::to_string(n_iterations_) + " epsilon " + std::to_string(epsilon_[0]) + " " @@ -375,7 +375,7 @@ std::vector ttk::PDClustering::execute( resetDosToOriginalValues(); // display results - std::vector> rows{ + std::vector> const rows{ {" Min-saddle cost", std::to_string(cost_min_)}, {" Saddle-saddle cost", std::to_string(cost_sad_)}, {" Saddle-max cost", std::to_string(cost_max_)}, @@ -419,14 +419,14 @@ std::vector ttk::PDClustering::execute( // if NumberOfClusters > 1, the global pair was duplicated // and needs to be removed from the min-saddle problem // It is the first pair. - int removeFirstPairMin + int const removeFirstPairMin = (k_ > 1 and original_dos[0] and original_dos[2]) ? 1 : 0; int addedFirstPairMax = 0; int addedFirstPairMin = removeFirstPairMin; // min-max Pair if(removeFirstPairMin or (!do_min_ and do_max_)) { - Good &g = centroids_max_[c].at(0); + Good const &g = centroids_max_[c].at(0); const auto &critCoords = g.GetCriticalCoordinates(); final_centroids[c].emplace_back(PersistencePair{ CriticalVertex{0, CriticalType::Local_minimum, g.x_, critCoords}, @@ -434,7 +434,7 @@ std::vector ttk::PDClustering::execute( false}); addedFirstPairMax = 1; } else if(do_min_) { - Good &g = centroids_min_[c].at(0); + Good const &g = centroids_min_[c].at(0); const auto &critCoords = g.GetCriticalCoordinates(); final_centroids[c].emplace_back(PersistencePair{ CriticalVertex{0, CriticalType::Local_minimum, g.x_, critCoords}, @@ -445,7 +445,7 @@ std::vector ttk::PDClustering::execute( if(do_min_) { for(size_t i = addedFirstPairMin; i < centroids_min_[c].size(); ++i) { - Good &g = centroids_min_[c].at(i); + Good const &g = centroids_min_[c].at(i); const auto &critCoords = g.GetCriticalCoordinates(); final_centroids[c].emplace_back(PersistencePair{ CriticalVertex{0, CriticalType::Local_minimum, g.x_, critCoords}, @@ -459,7 +459,7 @@ std::vector ttk::PDClustering::execute( if(do_sad_) { for(size_t i = 0; i < centroids_saddle_[c].size(); ++i) { - Good &g = centroids_saddle_[c].at(i); + Good const &g = centroids_saddle_[c].at(i); const auto &critCoords = g.GetCriticalCoordinates(); final_centroids[c].emplace_back(PersistencePair{ CriticalVertex{0, CriticalType::Saddle1, g.x_, critCoords}, @@ -473,7 +473,7 @@ std::vector ttk::PDClustering::execute( if(do_max_) { for(size_t i = addedFirstPairMax; i < centroids_max_[c].size(); ++i) { - Good &g = centroids_max_[c].at(i); + Good const &g = centroids_max_[c].at(i); const auto &critCoords = g.GetCriticalCoordinates(); ttk::CriticalType saddle_type; if(do_sad_) @@ -508,13 +508,13 @@ void ttk::PDClustering::correctMatchings( &previous_matchings) { for(int c = 0; c < k_; c++) { for(size_t i = 0; i < clustering_[c].size(); i++) { - int diagram_id = clustering_[c][i]; + int const diagram_id = clustering_[c][i]; if(original_dos[0]) { // 1. Invert the current_bidder_ids_ vector std::vector new_to_old_id( current_bidder_diagrams_min_[diagram_id].size(), -1); for(size_t j = 0; j < current_bidder_ids_min_[diagram_id].size(); j++) { - int new_id = current_bidder_ids_min_[diagram_id][j]; + int const new_id = current_bidder_ids_min_[diagram_id][j]; if(new_id >= 0) { new_to_old_id[new_id] = j; } @@ -523,7 +523,7 @@ void ttk::PDClustering::correctMatchings( std::vector matchings_diagram_i; for(size_t j = 0; j < previous_matchings[c][0][i].size(); j++) { MatchingType m = previous_matchings[c][0][i][j]; - int new_id = std::get<0>(m); + int const new_id = std::get<0>(m); if(new_id >= 0 && std::get<1>(m) >= 0) { std::get<0>(m) = new_to_old_id[new_id]; matchings_diagram_i.emplace_back(m); @@ -541,7 +541,7 @@ void ttk::PDClustering::correctMatchings( std::vector new_to_old_id( current_bidder_diagrams_saddle_[diagram_id].size()); for(size_t j = 0; j < current_bidder_ids_sad_[diagram_id].size(); j++) { - int new_id = current_bidder_ids_sad_[diagram_id][j]; + int const new_id = current_bidder_ids_sad_[diagram_id][j]; if(new_id >= 0) { new_to_old_id[new_id] = j; } @@ -551,9 +551,9 @@ void ttk::PDClustering::correctMatchings( std::vector matchings_diagram_i; for(size_t j = 0; j < previous_matchings[c][1][i].size(); j++) { MatchingType m = previous_matchings[c][1][i][j]; - int new_id = std::get<0>(m); + int const new_id = std::get<0>(m); if(new_id >= 0 && std::get<1>(m) >= 0) { - int old_id = new_to_old_id[new_id]; + int const old_id = new_to_old_id[new_id]; if(old_id > 0) { std::get<0>(m) = old_id; matchings_diagram_i.emplace_back(m); @@ -578,7 +578,7 @@ void ttk::PDClustering::correctMatchings( std::vector new_to_old_id( current_bidder_diagrams_max_[diagram_id].size()); for(size_t j = 0; j < current_bidder_ids_max_[diagram_id].size(); j++) { - int new_id = current_bidder_ids_max_[diagram_id][j]; + int const new_id = current_bidder_ids_max_[diagram_id][j]; if(new_id >= 0) { new_to_old_id[new_id] = j; } @@ -588,9 +588,9 @@ void ttk::PDClustering::correctMatchings( std::vector matchings_diagram_i; for(size_t j = 0; j < previous_matchings[c][2][i].size(); j++) { MatchingType m = previous_matchings[c][2][i][j]; - int new_id = std::get<0>(m); + int const new_id = std::get<0>(m); if(new_id >= 0 && std::get<1>(m) >= 0) { - int old_id = new_to_old_id[new_id]; + int const old_id = new_to_old_id[new_id]; if(old_id > 0) { std::get<0>(m) = old_id; matchings_diagram_i.emplace_back(m); @@ -643,8 +643,8 @@ double ttk::PDClustering::getMostPersistent(int type) { if(do_min_ && (type == -1 || type == 0)) { for(size_t i = 0; i < bidder_diagrams_min_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_min_[i].size(); ++j) { - Bidder b = bidder_diagrams_min_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_min_[i].at(j); + double const persistence = b.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } @@ -655,8 +655,8 @@ double ttk::PDClustering::getMostPersistent(int type) { if(do_sad_ && (type == -1 || type == 1)) { for(size_t i = 0; i < bidder_diagrams_saddle_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_saddle_[i].size(); ++j) { - Bidder b = bidder_diagrams_saddle_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_saddle_[i].at(j); + double const persistence = b.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } @@ -667,8 +667,8 @@ double ttk::PDClustering::getMostPersistent(int type) { if(do_max_ && (type == -1 || type == 2)) { for(size_t i = 0; i < bidder_diagrams_max_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_max_[i].size(); ++j) { - Bidder b = bidder_diagrams_max_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_max_[i].at(j); + double const persistence = b.getPersistence(); if(persistence > max_persistence) { max_persistence = persistence; } @@ -686,8 +686,8 @@ double ttk::PDClustering::getLessPersistent(int type) { if(do_min_ && (type == -1 || type == 0)) { for(size_t i = 0; i < bidder_diagrams_min_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_min_[i].size(); ++j) { - Bidder b = bidder_diagrams_min_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_min_[i].at(j); + double const persistence = b.getPersistence(); if(persistence < min_persistence) { min_persistence = persistence; } @@ -698,8 +698,8 @@ double ttk::PDClustering::getLessPersistent(int type) { if(do_sad_ && (type == -1 || type == 1)) { for(size_t i = 0; i < bidder_diagrams_saddle_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_saddle_[i].size(); ++j) { - Bidder b = bidder_diagrams_saddle_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_saddle_[i].at(j); + double const persistence = b.getPersistence(); if(persistence < min_persistence) { min_persistence = persistence; } @@ -710,8 +710,8 @@ double ttk::PDClustering::getLessPersistent(int type) { if(do_max_ && (type == -1 || type == 2)) { for(size_t i = 0; i < bidder_diagrams_max_.size(); ++i) { for(size_t j = 0; j < bidder_diagrams_max_[i].size(); ++j) { - Bidder b = bidder_diagrams_max_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_max_[i].at(j); + double const persistence = b.getPersistence(); if(persistence < min_persistence) { min_persistence = persistence; } @@ -728,8 +728,8 @@ std::vector> ttk::PDClustering::getMinPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[0].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < centroids_with_price_min_[i].size(); ++j) { - Good g = centroids_with_price_min_[i].at(j); - double price = g.getPrice(); + Good const g = centroids_with_price_min_[i].at(j); + double const price = g.getPrice(); if(price < min_prices[0][i]) { min_prices[0][i] = price; } @@ -741,8 +741,8 @@ std::vector> ttk::PDClustering::getMinPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[1].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < centroids_with_price_saddle_[i].size(); ++j) { - Good g = centroids_with_price_saddle_[i].at(j); - double price = g.getPrice(); + Good const g = centroids_with_price_saddle_[i].at(j); + double const price = g.getPrice(); if(price < min_prices[1][i]) { min_prices[1][i] = price; } @@ -754,8 +754,8 @@ std::vector> ttk::PDClustering::getMinPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[2].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < centroids_with_price_max_[i].size(); ++j) { - Good g = centroids_with_price_max_[i].at(j); - double price = g.getPrice(); + Good const g = centroids_with_price_max_[i].at(j); + double const price = g.getPrice(); if(price < min_prices[2][i]) { min_prices[2][i] = price; } @@ -772,8 +772,8 @@ std::vector> ttk::PDClustering::getMinDiagonalPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[0].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < current_bidder_diagrams_min_[i].size(); ++j) { - Bidder b = current_bidder_diagrams_min_[i].at(j); - double price = b.diagonal_price_; + Bidder const b = current_bidder_diagrams_min_[i].at(j); + double const price = b.diagonal_price_; if(price < min_prices[0][i]) { min_prices[0][i] = price; } @@ -788,8 +788,8 @@ std::vector> ttk::PDClustering::getMinDiagonalPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[1].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < current_bidder_diagrams_saddle_[i].size(); ++j) { - Bidder b = current_bidder_diagrams_saddle_[i].at(j); - double price = b.diagonal_price_; + Bidder const b = current_bidder_diagrams_saddle_[i].at(j); + double const price = b.diagonal_price_; if(price < min_prices[1][i]) { min_prices[1][i] = price; } @@ -804,8 +804,8 @@ std::vector> ttk::PDClustering::getMinDiagonalPrices() { for(int i = 0; i < numberOfInputs_; ++i) { min_prices[2].emplace_back(std::numeric_limits::max()); for(size_t j = 0; j < current_bidder_diagrams_max_[i].size(); ++j) { - Bidder b = current_bidder_diagrams_max_[i].at(j); - double price = b.diagonal_price_; + Bidder const b = current_bidder_diagrams_max_[i].at(j); + double const price = b.diagonal_price_; if(price < min_prices[2][i]) { min_prices[2][i] = price; } @@ -821,7 +821,7 @@ std::vector> ttk::PDClustering::getMinDiagonalPrices() { double ttk::PDClustering::computeDistance(const BidderDiagram &D1, const BidderDiagram &D2, const double delta_lim) { - GoodDiagram D2_bis = diagramToCentroid(D2); + GoodDiagram const D2_bis = diagramToCentroid(D2); return computeDistance(D1, D2_bis, delta_lim); } @@ -833,7 +833,7 @@ double ttk::PDClustering::computeDistance(const BidderDiagram &D1, PersistenceDiagramAuction auction( wasserstein_, geometrical_factor_, lambda_, delta_lim, use_kdtree_); auction.BuildAuctionDiagrams(D1, D2_bis); - double cost = auction.run(matchings); + double const cost = auction.run(matchings); return cost; } @@ -843,9 +843,9 @@ double ttk::PDClustering::computeDistance(BidderDiagram *const D1, std::vector matchings; PersistenceDiagramAuction auction( wasserstein_, geometrical_factor_, lambda_, delta_lim, use_kdtree_); - int size1 = D1->size(); + int const size1 = D1->size(); auction.BuildAuctionDiagrams(*D1, *D2); - double cost = auction.run(matchings); + double const cost = auction.run(matchings); // Diagonal Points were added in the original diagram. The following line // removes them. D1->resize(size1); @@ -855,7 +855,7 @@ double ttk::PDClustering::computeDistance(BidderDiagram *const D1, double ttk::PDClustering::computeDistance(const GoodDiagram &D1, const GoodDiagram &D2, const double delta_lim) { - BidderDiagram D1_bis = centroidToDiagram(D1); + BidderDiagram const D1_bis = centroidToDiagram(D1); return computeDistance(D1_bis, D2, delta_lim); } @@ -925,17 +925,17 @@ void ttk::PDClustering::initializeCentroids() { for(int c = 0; c < k_; c++) { if(do_min_) { - GoodDiagram centroid_min + GoodDiagram const centroid_min = diagramToCentroid(current_bidder_diagrams_min_[idx[c]]); centroids_min_.emplace_back(centroid_min); } if(do_sad_) { - GoodDiagram centroid_sad + GoodDiagram const centroid_sad = diagramToCentroid(current_bidder_diagrams_saddle_[idx[c]]); centroids_saddle_.emplace_back(centroid_sad); } if(do_max_) { - GoodDiagram centroid_max + GoodDiagram const centroid_max = diagramToCentroid(current_bidder_diagrams_max_[idx[c]]); centroids_max_.emplace_back(centroid_max); } @@ -944,21 +944,21 @@ void ttk::PDClustering::initializeCentroids() { void ttk::PDClustering::initializeCentroidsKMeanspp() { std::vector indexes_clusters; - int random_idx = deterministic_ ? 0 : rand() % numberOfInputs_; + int const random_idx = deterministic_ ? 0 : rand() % numberOfInputs_; indexes_clusters.emplace_back(random_idx); if(do_min_) { - GoodDiagram centroid_min + GoodDiagram const centroid_min = diagramToCentroid(current_bidder_diagrams_min_[random_idx]); centroids_min_.emplace_back(centroid_min); } if(do_sad_) { - GoodDiagram centroid_sad + GoodDiagram const centroid_sad = diagramToCentroid(current_bidder_diagrams_saddle_[random_idx]); centroids_saddle_.emplace_back(centroid_sad); } if(do_max_) { - GoodDiagram centroid_max + GoodDiagram const centroid_max = diagramToCentroid(current_bidder_diagrams_max_[random_idx]); centroids_max_.emplace_back(centroid_max); } @@ -986,19 +986,19 @@ void ttk::PDClustering::initializeCentroidsKMeanspp() { double distance = 0; if(do_min_) { - GoodDiagram centroid_min + GoodDiagram const centroid_min = centroidWithZeroPrices(centroids_min_[j]); distance += computeDistance( current_bidder_diagrams_min_[i], centroid_min, 0.01); } if(do_sad_) { - GoodDiagram centroid_saddle + GoodDiagram const centroid_saddle = centroidWithZeroPrices(centroids_saddle_[j]); distance += computeDistance( current_bidder_diagrams_saddle_[i], centroid_saddle, 0.01); } if(do_max_) { - GoodDiagram centroid_max + GoodDiagram const centroid_max = centroidWithZeroPrices(centroids_max_[j]); distance += computeDistance( current_bidder_diagrams_max_[i], centroid_max, 0.01); @@ -1029,17 +1029,17 @@ void ttk::PDClustering::initializeCentroidsKMeanspp() { indexes_clusters.emplace_back(candidate_centroid); if(do_min_) { - GoodDiagram centroid_min + GoodDiagram const centroid_min = diagramToCentroid(current_bidder_diagrams_min_[candidate_centroid]); centroids_min_.emplace_back(centroid_min); } if(do_sad_) { - GoodDiagram centroid_sad = diagramToCentroid( + GoodDiagram const centroid_sad = diagramToCentroid( current_bidder_diagrams_saddle_[candidate_centroid]); centroids_saddle_.emplace_back(centroid_sad); } if(do_max_) { - GoodDiagram centroid_max + GoodDiagram const centroid_max = diagramToCentroid(current_bidder_diagrams_max_[candidate_centroid]); centroids_max_.emplace_back(centroid_max); } @@ -1150,25 +1150,27 @@ void ttk::PDClustering::computeDistanceToCentroid() { distanceToCentroid_.resize(numberOfInputs_); for(int i = 0; i < numberOfInputs_; ++i) { - double delta_lim{0.01}; + double const delta_lim{0.01}; double distance{}; auto c = inv_clustering_[i]; if(original_dos[0]) { - GoodDiagram centroid_min = centroidWithZeroPrices(centroids_min_[c]); - BidderDiagram bidder_diag + GoodDiagram const centroid_min + = centroidWithZeroPrices(centroids_min_[c]); + BidderDiagram const bidder_diag = diagramWithZeroPrices(current_bidder_diagrams_min_[i]); distance += computeDistance(bidder_diag, centroid_min, delta_lim); } if(original_dos[1]) { - GoodDiagram centroid_saddle + GoodDiagram const centroid_saddle = centroidWithZeroPrices(centroids_saddle_[c]); - BidderDiagram bidder_diag + BidderDiagram const bidder_diag = diagramWithZeroPrices(current_bidder_diagrams_saddle_[i]); distance += computeDistance(bidder_diag, centroid_saddle, delta_lim); } if(original_dos[2]) { - GoodDiagram centroid_max = centroidWithZeroPrices(centroids_max_[c]); - BidderDiagram bidder_diag + GoodDiagram const centroid_max + = centroidWithZeroPrices(centroids_max_[c]); + BidderDiagram const bidder_diag = diagramWithZeroPrices(current_bidder_diagrams_max_[i]); distance += computeDistance(bidder_diag, centroid_max, delta_lim); } @@ -1254,7 +1256,7 @@ void ttk::PDClustering::invertClusters() { // Fill in the clusters for(int c = 0; c < k_; ++c) { for(size_t j = 0; j < clustering_[c].size(); ++j) { - int idx = clustering_[c][j]; + int const idx = clustering_[c][j]; inv_clustering_[idx] = c; } } @@ -1282,9 +1284,9 @@ void ttk::PDClustering::acceleratedUpdateClusters() { // self.old_clusters = copy.copy(self.clusters) invertClusters(); initializeEmptyClusters(); - bool do_min = original_dos[0]; - bool do_sad = original_dos[1]; - bool do_max = original_dos[2]; + bool const do_min = original_dos[0]; + bool const do_sad = original_dos[1]; + bool const do_max = original_dos[2]; for(int i = 0; i < numberOfInputs_; ++i) { // Step 3 find potential changes of clusters @@ -1420,7 +1422,7 @@ void ttk::PDClustering::acceleratedUpdateClusters() { if(inv_clustering_[idx] < k_ && inv_clustering_[idx] >= 0 && clustering_[inv_clustering_[idx]].size() > 1) { idx_acceptable = true; - int cluster_removal = inv_clustering_[idx]; + int const cluster_removal = inv_clustering_[idx]; // Removing the index to remove clustering_[cluster_removal].erase( std::remove(clustering_[cluster_removal].begin(), @@ -1441,7 +1443,7 @@ void ttk::PDClustering::acceleratedUpdateClusters() { idx = clustering_[cluster_max][0]; } } - int cluster_removal = inv_clustering_[idx]; + int const cluster_removal = inv_clustering_[idx]; clustering_[cluster_removal].erase( std::remove(clustering_[cluster_removal].begin(), clustering_[cluster_removal].end(), idx), @@ -1496,9 +1498,9 @@ std::vector ttk::PDClustering::updateCentroidsPosition( bool precision_sad = true; bool precision_max = true; cost_ = 0; - double sq_dist_min = cost_min_; - double sq_dist_sad = cost_sad_; - double sq_dist_max = cost_max_; + double const sq_dist_min = cost_min_; + double const sq_dist_sad = cost_sad_; + double const sq_dist_max = cost_max_; if(do_min_) { cost_min_ = 0; } @@ -1514,14 +1516,14 @@ std::vector ttk::PDClustering::updateCentroidsPosition( std::vector centroids_with_price_min, centroids_with_price_sad, centroids_with_price_max; int count = 0; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { // Timer time_first_thing; // Find the position of diagrams[idx] in old cluster c - std::vector::iterator i = std::find( + std::vector::iterator const i = std::find( old_clustering_[c].begin(), old_clustering_[c].end(), idx); - int pos = (i == old_clustering_[c].end()) - ? -1 - : std::distance(old_clustering_[c].begin(), i); + int const pos = (i == old_clustering_[c].end()) + ? -1 + : std::distance(old_clustering_[c].begin(), i); if(pos >= 0) { // Diagram was already linked to this centroid before if(do_min_) { @@ -1631,10 +1633,10 @@ std::vector ttk::PDClustering::updateCentroidsPosition( if(do_min_) { std::vector> all_matchings; std::vector sizes; - Timer time_preprocess_bary; + Timer const time_preprocess_bary; std::vector diagrams_c_min; if(barycenter_inputs_reset_flag) { - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c_min.emplace_back(current_bidder_diagrams_min_[idx]); } sizes.resize(diagrams_c_min.size()); @@ -1688,7 +1690,7 @@ std::vector ttk::PDClustering::updateCentroidsPosition( precision_min = barycenter_computer_min_[c].isPrecisionObjectiveMet(deltaLim_, 0); cost_min_ += total_cost; - Timer time_update; + Timer const time_update; if(!only_matchings) { max_shift_c_min = barycenter_computer_min_[c].updateBarycenter(all_matchings); @@ -1704,13 +1706,13 @@ std::vector ttk::PDClustering::updateCentroidsPosition( centroids_with_price_min = barycenter_computer_min_[c].getCurrentBarycenter(); int i = 0; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { current_bidder_diagrams_min_[idx] = diagrams_c_min[i]; centroids_with_price_min_[idx] = centroids_with_price_min[i]; i++; } - GoodDiagram old_centroid = centroids_min_[c]; + GoodDiagram const old_centroid = centroids_min_[c]; centroids_min_[c] = centroidWithZeroPrices( centroids_with_price_min_[clustering_[c][0]]); @@ -1727,7 +1729,7 @@ std::vector ttk::PDClustering::updateCentroidsPosition( std::vector diagrams_c_min; if(barycenter_inputs_reset_flag) { - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c_min.emplace_back(current_bidder_diagrams_saddle_[idx]); } sizes.resize(diagrams_c_min.size()); @@ -1796,12 +1798,12 @@ std::vector ttk::PDClustering::updateCentroidsPosition( centroids_with_price_sad = barycenter_computer_sad_[c].getCurrentBarycenter(); int i = 0; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { current_bidder_diagrams_saddle_[idx] = diagrams_c_min[i]; centroids_with_price_saddle_[idx] = centroids_with_price_sad[i]; i++; } - GoodDiagram old_centroid = centroids_saddle_[c]; + GoodDiagram const old_centroid = centroids_saddle_[c]; centroids_saddle_[c] = centroidWithZeroPrices( centroids_with_price_saddle_[clustering_[c][0]]); if(use_accelerated_) @@ -1811,12 +1813,12 @@ std::vector ttk::PDClustering::updateCentroidsPosition( if(do_max_) { std::vector> all_matchings; - Timer time_preprocess_bary; + Timer const time_preprocess_bary; total_cost = 0; std::vector sizes; std::vector diagrams_c_min; if(barycenter_inputs_reset_flag) { - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c_min.emplace_back(current_bidder_diagrams_max_[idx]); } sizes.resize(diagrams_c_min.size()); @@ -1870,7 +1872,7 @@ std::vector ttk::PDClustering::updateCentroidsPosition( = barycenter_computer_max_[c].isPrecisionObjectiveMet(deltaLim_, 0); cost_max_ += total_cost; - Timer time_update; + Timer const time_update; if(!only_matchings) { max_shift_c_max = barycenter_computer_max_[c].updateBarycenter(all_matchings); @@ -1885,12 +1887,12 @@ std::vector ttk::PDClustering::updateCentroidsPosition( centroids_with_price_max = barycenter_computer_max_[c].getCurrentBarycenter(); int i = 0; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { current_bidder_diagrams_max_[idx] = diagrams_c_min[i]; centroids_with_price_max_[idx] = centroids_with_price_max[i]; i++; } - GoodDiagram old_centroid = centroids_max_[c]; + GoodDiagram const old_centroid = centroids_max_[c]; centroids_max_[c] = centroidWithZeroPrices( centroids_with_price_max_[clustering_[c][0]]); if(use_accelerated_) { @@ -1915,7 +1917,7 @@ std::vector ttk::PDClustering::updateCentroidsPosition( l_[i][c] = 0; } } - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { // Step 6, update the upper bound on the distance to the centroid // thanks to the triangle inequality u_[idx] = Geometry::pow( @@ -1955,8 +1957,8 @@ void ttk::PDClustering::setBidderDiagrams() { } } bidder_diagrams_min_.emplace_back(bidders); - current_bidder_diagrams_min_.emplace_back(BidderDiagram()); - centroids_with_price_min_.emplace_back(GoodDiagram()); + current_bidder_diagrams_min_.emplace_back(); + centroids_with_price_min_.emplace_back(); std::vector ids(bidders.size()); for(size_t j = 0; j < ids.size(); j++) { ids[j] = -1; @@ -1979,8 +1981,8 @@ void ttk::PDClustering::setBidderDiagrams() { } } bidder_diagrams_saddle_.emplace_back(bidders); - current_bidder_diagrams_saddle_.emplace_back(BidderDiagram()); - centroids_with_price_saddle_.emplace_back(GoodDiagram()); + current_bidder_diagrams_saddle_.emplace_back(); + centroids_with_price_saddle_.emplace_back(); std::vector ids(bidders.size()); for(size_t j = 0; j < ids.size(); j++) { ids[j] = -1; @@ -2003,8 +2005,8 @@ void ttk::PDClustering::setBidderDiagrams() { } } bidder_diagrams_max_.emplace_back(bidders); - current_bidder_diagrams_max_.emplace_back(BidderDiagram()); - centroids_with_price_max_.emplace_back(GoodDiagram()); + current_bidder_diagrams_max_.emplace_back(); + centroids_with_price_max_.emplace_back(); std::vector ids(bidders.size()); for(size_t j = 0; j < ids.size(); j++) { ids[j] = -1; @@ -2061,13 +2063,13 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( } } } - int max_points_to_add_min + int const max_points_to_add_min = std::max(min_points_to_add[0], min_points_to_add[0] + (int)(max_diagram_size_min / 10)); - int max_points_to_add_sad + int const max_points_to_add_sad = std::max(min_points_to_add[1], min_points_to_add[1] + (int)(max_diagram_size_sad / 10)); - int max_points_to_add_max + int const max_points_to_add_max = std::max(min_points_to_add[2], min_points_to_add[2] + (int)(max_diagram_size_max / 10)); @@ -2083,8 +2085,8 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( for(int i = 0; i < numberOfInputs_; i++) { std::vector persistences; for(size_t j = 0; j < bidder_diagrams_min_[i].size(); j++) { - Bidder b = bidder_diagrams_min_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_min_[i].at(j); + double const persistence = b.getPersistence(); if(persistence >= min_persistence[0] && persistence <= previous_min_persistence[0]) { candidates_to_be_added_min[i].emplace_back(j); @@ -2097,9 +2099,9 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( return ((persistences[a] > persistences[b]) || ((persistences[a] == persistences[b]) && (a > b))); }); - int size = candidates_to_be_added_min[i].size(); + int const size = candidates_to_be_added_min[i].size(); if(size >= max_points_to_add_min) { - double last_persistence_added_min + double const last_persistence_added_min = persistences[idx_min[i][max_points_to_add_min - 1]]; if(first_enrichment) { // a minima min_point_to_add (=max_point_to_add) // added per diagram @@ -2122,8 +2124,8 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( for(int i = 0; i < numberOfInputs_; i++) { std::vector persistences; for(size_t j = 0; j < bidder_diagrams_saddle_[i].size(); j++) { - Bidder b = bidder_diagrams_saddle_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_saddle_[i].at(j); + double const persistence = b.getPersistence(); if(persistence >= min_persistence[1] && persistence <= previous_min_persistence[1]) { candidates_to_be_added_sad[i].emplace_back(j); @@ -2136,9 +2138,9 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( return ((persistences[a] > persistences[b]) || ((persistences[a] == persistences[b]) && (a > b))); }); - int size = candidates_to_be_added_sad[i].size(); + int const size = candidates_to_be_added_sad[i].size(); if(size >= max_points_to_add_sad) { - double last_persistence_added_sad + double const last_persistence_added_sad = persistences[idx_sad[i][max_points_to_add_sad - 1]]; if(first_enrichment) { // a minima min_point_to_add (=max_point_to_add) // added per diagram @@ -2160,8 +2162,8 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( for(int i = 0; i < numberOfInputs_; i++) { std::vector persistences; for(size_t j = 0; j < bidder_diagrams_max_[i].size(); j++) { - Bidder b = bidder_diagrams_max_[i].at(j); - double persistence = b.getPersistence(); + Bidder const b = bidder_diagrams_max_[i].at(j); + double const persistence = b.getPersistence(); if(persistence >= min_persistence[2] && persistence <= previous_min_persistence[2]) { candidates_to_be_added_max[i].emplace_back(j); @@ -2174,9 +2176,9 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( return ((persistences[a] > persistences[b]) || ((persistences[a] == persistences[b]) && (a > b))); }); - int size = candidates_to_be_added_max[i].size(); + int const size = candidates_to_be_added_max[i].size(); if(size >= max_points_to_add_max) { - double last_persistence_added_max + double const last_persistence_added_max = persistences[idx_max[i][max_points_to_add_max - 1]]; if(first_enrichment) { // a minima min_point_to_add (=max_point_to_add) // added per diagram @@ -2199,11 +2201,11 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( if(do_min_) { int compteur_for_adding_points = 0; for(int i = 0; i < numberOfInputs_; i++) { - int size = candidates_to_be_added_min[i].size(); + int const size = candidates_to_be_added_min[i].size(); for(int j = 0; j < std::min(max_points_to_add_min, size); j++) { Bidder b = bidder_diagrams_min_[i].at( candidates_to_be_added_min[i][idx_min[i][j]]); - double persistence = b.getPersistence(); + double const persistence = b.getPersistence(); if(persistence >= new_min_persistence[0]) { b.id_ = current_bidder_diagrams_min_[i].size(); b.setPositionInAuction(current_bidder_diagrams_min_[i].size()); @@ -2232,7 +2234,7 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( wasserstein_); r_[i] = true; } - int to_be_added_to_barycenter + int const to_be_added_to_barycenter = deterministic_ ? compteur_for_adding_points % numberOfInputs_ : rand() % numberOfInputs_; if(to_be_added_to_barycenter == 0 && add_points_to_barycenter) { @@ -2259,11 +2261,11 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( if(do_sad_) { int compteur_for_adding_points = 0; for(int i = 0; i < numberOfInputs_; i++) { - int size = candidates_to_be_added_sad[i].size(); + int const size = candidates_to_be_added_sad[i].size(); for(int j = 0; j < std::min(max_points_to_add_sad, size); j++) { Bidder b = bidder_diagrams_saddle_[i].at( candidates_to_be_added_sad[i][idx_sad[i][j]]); - double persistence = b.getPersistence(); + double const persistence = b.getPersistence(); if(persistence >= new_min_persistence[1]) { b.id_ = current_bidder_diagrams_saddle_[i].size(); b.setPositionInAuction(current_bidder_diagrams_saddle_[i].size()); @@ -2292,7 +2294,7 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( wasserstein_); r_[i] = true; } - int to_be_added_to_barycenter + int const to_be_added_to_barycenter = deterministic_ ? compteur_for_adding_points % numberOfInputs_ : rand() % numberOfInputs_; if(to_be_added_to_barycenter == 0 && add_points_to_barycenter) { @@ -2315,11 +2317,11 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( if(do_max_) { int compteur_for_adding_points = 0; for(int i = 0; i < numberOfInputs_; i++) { - int size = candidates_to_be_added_max[i].size(); + int const size = candidates_to_be_added_max[i].size(); for(int j = 0; j < std::min(max_points_to_add_max, size); j++) { Bidder b = bidder_diagrams_max_[i].at( candidates_to_be_added_max[i][idx_max[i][j]]); - double persistence = b.getPersistence(); + double const persistence = b.getPersistence(); if(persistence >= new_min_persistence[2]) { b.id_ = current_bidder_diagrams_max_[i].size(); b.setPositionInAuction(current_bidder_diagrams_max_[i].size()); @@ -2348,7 +2350,7 @@ std::vector ttk::PDClustering::enrichCurrentBidderDiagrams( wasserstein_); r_[i] = true; } - int to_be_added_to_barycenter + int const to_be_added_to_barycenter = deterministic_ ? compteur_for_adding_points % numberOfInputs_ : rand() % numberOfInputs_; if(to_be_added_to_barycenter == 0 && add_points_to_barycenter) { @@ -2383,7 +2385,7 @@ void ttk::PDClustering::initializeBarycenterComputers( barycenter_computer_min_.resize(k_); for(int c = 0; c < k_; c++) { std::vector diagrams_c; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c.emplace_back(current_bidder_diagrams_min_[idx]); } barycenter_computer_min_[c] = {}; @@ -2402,7 +2404,7 @@ void ttk::PDClustering::initializeBarycenterComputers( barycenter_computer_sad_.resize(k_); for(int c = 0; c < k_; c++) { std::vector diagrams_c; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c.emplace_back(current_bidder_diagrams_saddle_[idx]); } barycenter_computer_sad_[c] = {}; @@ -2429,7 +2431,7 @@ void ttk::PDClustering::initializeBarycenterComputers( barycenter_computer_max_.resize(k_); for(int c = 0; c < k_; c++) { std::vector diagrams_c; - for(int idx : clustering_[c]) { + for(int const idx : clustering_[c]) { diagrams_c.emplace_back(current_bidder_diagrams_max_[idx]); } barycenter_computer_max_[c] = {}; @@ -2470,7 +2472,7 @@ void ttk::PDClustering::printDistancesToFile() { } for(int c = 0; c < k_; c++) { - for(int i : clustering_[c]) { + for(int const i : clustering_[c]) { approx_file << (u_[i] + l_[i][c]) / 2 << " "; } approx_file << "\n"; @@ -2485,7 +2487,7 @@ void ttk::PDClustering::printRealDistancesToFile() { std::ofstream file("a_real_mat.txt"); if(file.is_open()) { for(int c = 0; c < k_; c++) { - for(int i : clustering_[c]) { + for(int const i : clustering_[c]) { file << distanceToCentroid_[i] << " "; } file << "\n"; @@ -2505,7 +2507,7 @@ void ttk::PDClustering::printPricesToFile(int iteration) { file << "\ncentroid " << i << std::endl; for(size_t j = 0; j < centroids_with_price_max_[i].size(); j++) { - Good g = centroids_with_price_max_[i].at(j); + Good const g = centroids_with_price_max_[i].at(j); file << g.getPrice() << " "; } } @@ -2522,7 +2524,7 @@ double ttk::PDClustering::computeRealCost() { for(int c = 0; c < k_; c++) { double real_cost_cluster = 0; for(int i = 0; i < numberOfInputs_; i++) { - GoodDiagram current_barycenter + GoodDiagram const current_barycenter = centroidWithZeroPrices(centroids_min_[c]); sq_distance = computeDistance(bidder_diagrams_min_[i], current_barycenter, 0.01); @@ -2535,7 +2537,7 @@ double ttk::PDClustering::computeRealCost() { for(int c = 0; c < k_; c++) { double real_cost_cluster = 0; for(int i = 0; i < numberOfInputs_; i++) { - GoodDiagram current_barycenter + GoodDiagram const current_barycenter = centroidWithZeroPrices(centroids_saddle_[c]); sq_distance = computeDistance( bidder_diagrams_saddle_[i], current_barycenter, 0.01); @@ -2548,7 +2550,7 @@ double ttk::PDClustering::computeRealCost() { for(int c = 0; c < k_; c++) { double real_cost_cluster = 0; for(int i = 0; i < numberOfInputs_; i++) { - GoodDiagram current_barycenter + GoodDiagram const current_barycenter = centroidWithZeroPrices(centroids_max_[c]); sq_distance = computeDistance(bidder_diagrams_max_[i], current_barycenter, 0.01); @@ -2602,7 +2604,7 @@ void ttk::PDClustering::computeBarycenterForTwo( std::vector new_to_old_id(current_diagram1.size()); // 1. Invert the current_bidder_ids_ vector for(size_t j = 0; j < ids1.size(); j++) { - int new_id = ids1[j]; + int const new_id = ids1[j]; if(new_id >= 0) { new_to_old_id[new_id] = j; } @@ -2613,17 +2615,17 @@ void ttk::PDClustering::computeBarycenterForTwo( for(size_t i = 0; i < matchings1.size(); i++) { MatchingType &t = matchings1[i]; - int bidderId = std::get<0>(t); - int goodId = std::get<1>(t); + int const bidderId = std::get<0>(t); + int const goodId = std::get<1>(t); if(bidderId >= 0) { - Bidder b = diagram1.at(new_to_old_id[bidderId]); - double bx = b.x_; - double by = b.y_; + Bidder const b = diagram1.at(new_to_old_id[bidderId]); + double const bx = b.x_; + double const by = b.y_; if(goodId >= 0) { - Good g = barycenter.at(goodId); - double gx = g.x_; - double gy = g.y_; + Good const g = barycenter.at(goodId); + double const gx = g.x_; + double const gy = g.y_; barycenter.at(goodId).x_ = (bx + gx) / 2; barycenter.at(goodId).y_ = (by + gy) / 2; // divide by 4 in order to display the cost of the half matching @@ -2635,11 +2637,12 @@ void ttk::PDClustering::computeBarycenterForTwo( double gy = (bx + by) / 2; gx = (gx + bx) / 2; gy = (gy + by) / 2; - double cost = Geometry::pow((gx - bx), wasserstein_) - + Geometry::pow((gy - by), wasserstein_); - MatchingType t2 = std::make_tuple(bidderId, barycenter.size(), cost); - MatchingType t3 = std::make_tuple(-1, barycenter.size(), cost); - Good g = Good(gx, gy, false, barycenter.size()); + double const cost = Geometry::pow((gx - bx), wasserstein_) + + Geometry::pow((gy - by), wasserstein_); + MatchingType const t2 + = std::make_tuple(bidderId, barycenter.size(), cost); + MatchingType const t3 = std::make_tuple(-1, barycenter.size(), cost); + Good const g = Good(gx, gy, false, barycenter.size()); // g.SetCriticalCoordinates(b.coords_[0], b.coords_[1], b.coords_[2]); barycenter.emplace_back(g); matching_to_add.emplace_back(t2); @@ -2647,9 +2650,9 @@ void ttk::PDClustering::computeBarycenterForTwo( } } else { if(goodId >= 0) { - Good g = barycenter.at(goodId); - double gx = (g.x_ + g.y_) / 2; - double gy = (g.x_ + g.y_) / 2; + Good const g = barycenter.at(goodId); + double const gx = (g.x_ + g.y_) / 2; + double const gy = (g.x_ + g.y_) / 2; barycenter.at(goodId).x_ = (gx + g.x_) / 2; barycenter.at(goodId).y_ = (gy + g.y_) / 2; std::get<2>(t) /= 4; @@ -2669,7 +2672,7 @@ void ttk::PDClustering::computeBarycenterForTwo( std::vector new_to_old_id2(current_diagram0.size()); // 1. Invert the current_bidder_ids_ vector for(size_t j = 0; j < ids0.size(); j++) { - int new_id = ids0[j]; + int const new_id = ids0[j]; if(new_id >= 0) { new_to_old_id2[new_id] = j; } @@ -2677,18 +2680,18 @@ void ttk::PDClustering::computeBarycenterForTwo( for(size_t i = 0; i < matchings0.size(); i++) { MatchingType &t = matchings0[i]; - int bidderId = std::get<0>(t); - int goodId = std::get<1>(t); + int const bidderId = std::get<0>(t); + int const goodId = std::get<1>(t); if(bidderId >= 0 and goodId >= 0) { - Bidder b = diagram0.at(new_to_old_id2[bidderId]); - double bx = b.x_; - double by = b.y_; - Good g = barycenter.at(goodId); - double gx = g.x_; - double gy = g.y_; - double cost = Geometry::pow((gx - bx), wasserstein_) - + Geometry::pow((gy - by), wasserstein_); + Bidder const b = diagram0.at(new_to_old_id2[bidderId]); + double const bx = b.x_; + double const by = b.y_; + Good const g = barycenter.at(goodId); + double const gx = g.x_; + double const gy = g.y_; + double const cost = Geometry::pow((gx - bx), wasserstein_) + + Geometry::pow((gy - by), wasserstein_); std::get<2>(t) = cost; } } diff --git a/core/base/persistenceDiagramClustering/PersistenceDiagramBarycenter.cpp b/core/base/persistenceDiagramClustering/PersistenceDiagramBarycenter.cpp index 70095e2905..8cecd95775 100644 --- a/core/base/persistenceDiagramClustering/PersistenceDiagramBarycenter.cpp +++ b/core/base/persistenceDiagramClustering/PersistenceDiagramBarycenter.cpp @@ -27,12 +27,12 @@ void ttk::PersistenceDiagramBarycenter::execute( DiagramType &CTDiagram = intermediateDiagrams[i]; for(size_t j = 0; j < CTDiagram.size(); ++j) { - PersistencePair &t = CTDiagram[j]; + PersistencePair const &t = CTDiagram[j]; - ttk::CriticalType nt1 = t.birth.type; - ttk::CriticalType nt2 = t.death.type; + ttk::CriticalType const nt1 = t.birth.type; + ttk::CriticalType const nt2 = t.death.type; - double dt = t.persistence(); + double const dt = t.persistence(); // if (abs(dt) < zeroThresh) continue; if(dt > 0) { if(nt1 == ttk::CriticalType::Local_minimum @@ -169,7 +169,7 @@ void ttk::PersistenceDiagramBarycenter::execute( if(do_min) { for(size_t j = 0; j < matching_min[i].size(); j++) { MatchingType t = matching_min[i][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); std::get<0>(t) = data_min_idx[i][bidder_id]; if(std::get<1>(t) < 0) { std::get<1>(t) = -1; @@ -181,7 +181,7 @@ void ttk::PersistenceDiagramBarycenter::execute( if(do_sad) { for(size_t j = 0; j < matching_sad[i].size(); j++) { MatchingType t = matching_sad[i][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); std::get<0>(t) = data_sad_idx[i][bidder_id]; if(std::get<1>(t) >= 0) { std::get<1>(t) = std::get<1>(t) + barycenter_min.size(); @@ -195,7 +195,7 @@ void ttk::PersistenceDiagramBarycenter::execute( if(do_max) { for(size_t j = 0; j < matching_max[i].size(); j++) { MatchingType t = matching_max[i][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); std::get<0>(t) = data_max_idx[i][bidder_id]; if(std::get<1>(t) >= 0) { std::get<1>(t) @@ -243,8 +243,8 @@ void ttk::PersistenceDiagramBarycenter::execute( DiagramType &CTDiagram = intermediateDiagrams[i]; for(unsigned j = 0; j < all_matchings[0][i].size(); j++) { MatchingType t = all_matchings[0][i][j]; - int bidder_id = std::get<0>(t); - int bary_id = std::get<1>(t); + int const bidder_id = std::get<0>(t); + int const bary_id = std::get<1>(t); const auto &bidder = CTDiagram[bidder_id]; number_of_matchings_for_point[bary_id] += 1; diff --git a/core/base/persistenceDiagramClustering/PersistenceDiagramClustering.cpp b/core/base/persistenceDiagramClustering/PersistenceDiagramClustering.cpp index a56212eae5..da4b4b239a 100644 --- a/core/base/persistenceDiagramClustering/PersistenceDiagramClustering.cpp +++ b/core/base/persistenceDiagramClustering/PersistenceDiagramClustering.cpp @@ -32,10 +32,10 @@ std::vector ttk::PersistenceDiagramClustering::execute( for(size_t j = 0; j < CTDiagram.size(); ++j) { auto &t = CTDiagram[j]; - ttk::CriticalType nt1 = t.birth.type; - ttk::CriticalType nt2 = t.death.type; + ttk::CriticalType const nt1 = t.birth.type; + ttk::CriticalType const nt2 = t.death.type; - double dt = t.persistence(); + double const dt = t.persistence(); // if (abs(dt) < zeroThresh) continue; if(dt > 0) { if(nt1 == ttk::CriticalType::Local_minimum @@ -132,7 +132,7 @@ std::vector ttk::PersistenceDiagramClustering::execute( std::vector idxInCluster(numberOfInputs_); for(int j = 0; j < numberOfInputs_; ++j) { - size_t c = inv_clustering[j]; + size_t const c = inv_clustering[j]; if(c + 1 > cluster_size.size()) { cluster_size.resize(c + 1); cluster_size[c] = 1; @@ -156,7 +156,7 @@ std::vector ttk::PersistenceDiagramClustering::execute( } } for(int i = 0; i < numberOfInputs_; i++) { - size_t c = inv_clustering[i]; + size_t const c = inv_clustering[i]; if(do_min) { for(size_t j = 0; @@ -164,7 +164,7 @@ std::vector ttk::PersistenceDiagramClustering::execute( j++) { MatchingType t = all_matchings_per_type_and_cluster[c][0][idxInCluster[i]][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); if(bidder_id < (int)data_min[i].size()) { if(bidder_id < 0) { // matching with a diagonal point std::get<0>(t) = -1; @@ -186,7 +186,7 @@ std::vector ttk::PersistenceDiagramClustering::execute( j++) { MatchingType t = all_matchings_per_type_and_cluster[c][1][idxInCluster[i]][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); if(bidder_id < (int)data_sad[i].size()) { if(bidder_id < 0) { // matching with a diagonal point std::get<0>(t) = -1; @@ -209,7 +209,7 @@ std::vector ttk::PersistenceDiagramClustering::execute( j++) { MatchingType t = all_matchings_per_type_and_cluster[c][2][idxInCluster[i]][j]; - int bidder_id = std::get<0>(t); + int const bidder_id = std::get<0>(t); if(bidder_id < (int)data_max[i].size()) { if(bidder_id < 0) { // matching with a diagonal point std::get<0>(t) = -1; diff --git a/core/base/persistenceDiagramDistanceMatrix/PersistenceDiagramDistanceMatrix.cpp b/core/base/persistenceDiagramDistanceMatrix/PersistenceDiagramDistanceMatrix.cpp index 93d029a176..1f20e7f317 100644 --- a/core/base/persistenceDiagramDistanceMatrix/PersistenceDiagramDistanceMatrix.cpp +++ b/core/base/persistenceDiagramDistanceMatrix/PersistenceDiagramDistanceMatrix.cpp @@ -303,7 +303,7 @@ void PersistenceDiagramDistanceMatrix::enrichCurrentBidderDiagrams( for(const auto &diag : current_bidder_diags) { max_diagram_size = std::max(diag.size(), max_diagram_size); } - size_t max_points_to_add = std::max( + size_t const max_points_to_add = std::max( this->MaxNumberOfPairs, this->MaxNumberOfPairs + max_diagram_size / 10); // 2. Get which points can be added, deduce the new minimal persistence std::vector> candidates_to_be_added(nInputs); @@ -314,7 +314,7 @@ void PersistenceDiagramDistanceMatrix::enrichCurrentBidderDiagrams( std::vector persistences; for(size_t j = 0; j < bidder_diags[i].size(); j++) { const auto &b = bidder_diags[i][j]; - double persistence = b.getPersistence(); + double const persistence = b.getPersistence(); if(persistence >= 0.0 && persistence <= prev_min_persistence) { candidates_to_be_added[i].emplace_back(j); idx[i].emplace_back(idx[i].size()); @@ -328,7 +328,7 @@ void PersistenceDiagramDistanceMatrix::enrichCurrentBidderDiagrams( std::sort(idx[i].begin(), idx[i].end(), cmp); const auto size = candidates_to_be_added[i].size(); if(size >= max_points_to_add) { - double last_persistence_added + double const last_persistence_added = persistences[idx[i][max_points_to_add - 1]]; if(last_persistence_added > local_min_persistence) { local_min_persistence = last_persistence_added; diff --git a/core/base/planarGraphLayout/MergeTreeVisualization.h b/core/base/planarGraphLayout/MergeTreeVisualization.h index 353575c560..f858253516 100644 --- a/core/base/planarGraphLayout/MergeTreeVisualization.h +++ b/core/base/planarGraphLayout/MergeTreeVisualization.h @@ -77,12 +77,12 @@ namespace ttk { std::vector &treeSimplexId, std::vector &ttkNotUsed(branching), std::vector> &nodeBranching) { - ftm::idNode treeRoot = tree->getRoot(); - ftm::idNode treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); - float rootY = retVec[treeSimplexId[treeRoot] * 2 + 1]; - float rootOriginY = retVec[treeSimplexId[treeRootOrigin] * 2 + 1]; - float rootYmin = std::min(rootY, rootOriginY); - float rootYmax = std::max(rootY, rootOriginY); + ftm::idNode const treeRoot = tree->getRoot(); + ftm::idNode const treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); + float const rootY = retVec[treeSimplexId[treeRoot] * 2 + 1]; + float const rootOriginY = retVec[treeSimplexId[treeRootOrigin] * 2 + 1]; + float const rootYmin = std::min(rootY, rootOriginY); + float const rootYmax = std::max(rootY, rootOriginY); dataType rootPers = tree->getNodePersistence(treeRoot); std::vector> allNodeSpanX( tree->getNumberOfNodes()); @@ -90,9 +90,9 @@ namespace ttk { tree->getNumberOfNodes()); // Compute gap - float nonImportantPairsGap + float const nonImportantPairsGap = (rootYmax - rootYmin) * 0.05 * nonImportantPairsSpacing_; - float importantPairsGap + float const importantPairsGap = std::max(nonImportantPairsGap, (float)importantPairsSpacing_); // Some functions @@ -112,9 +112,9 @@ namespace ttk { for(auto node : leaves) queue.emplace(node); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); const double nodePers = tree->getNodePersistence(node); retVec[treeSimplexId[nodeOrigin] * 2] = 0; @@ -133,11 +133,11 @@ namespace ttk { // Iterate through each node of the branch int lastIndexImportant = -1; for(size_t i = 0; i < nodeBranchingVector.size(); ++i) { - ftm::idNode nodeBranchingI = nodeBranchingVector[i]; + ftm::idNode const nodeBranchingI = nodeBranchingVector[i]; // Get old node span X - float oldMin = std::get<0>(allNodeSpanX[nodeBranchingI]); - float oldMax = std::get<1>(allNodeSpanX[nodeBranchingI]); + float const oldMin = std::get<0>(allNodeSpanX[nodeBranchingI]); + float const oldMax = std::get<1>(allNodeSpanX[nodeBranchingI]); // Get x spacing float nodeSpacing = 0; @@ -165,13 +165,13 @@ namespace ttk { excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_)) nodeSpacing = nonImportantPairsProximity_; - float newMin = prevX + nodeSpacing; - float shiftX = newMin - oldMin; + float const newMin = prevX + nodeSpacing; + float const shiftX = newMin - oldMin; // Set y coordinate according difference in persistence dataType nodeBranchingIPers = tree->getNodePersistence(nodeBranchingI); - float shiftY = nodeBranchingIPers * branchSpacing_; + float const shiftY = nodeBranchingIPers * branchSpacing_; float diffY = retVec[treeSimplexId[nodeBranchingI] * 2 + 1]; retVec[treeSimplexId[nodeBranchingI] * 2 + 1] = retVec[treeSimplexId[nodeOrigin] * 2 + 1] - shiftY; @@ -181,7 +181,7 @@ namespace ttk { std::queue queueBranching; queueBranching.emplace(nodeBranchingI); while(!queueBranching.empty()) { - ftm::idNode nodeBranchOrigin = queueBranching.front(); + ftm::idNode const nodeBranchOrigin = queueBranching.front(); queueBranching.pop(); retVec[treeSimplexId[nodeBranchOrigin] * 2] += shiftX; if(nodeBranchOrigin != nodeBranchingI) @@ -194,9 +194,9 @@ namespace ttk { // Update node span X allNodeSpanX[nodeBranchingI] = std::make_tuple(oldMin + shiftX, oldMax + shiftX); - float oldMinImp + float const oldMinImp = std::get<0>(allNodeImportantSpanX[nodeBranchingI]); - float oldMaxImp + float const oldMaxImp = std::get<1>(allNodeImportantSpanX[nodeBranchingI]); allNodeImportantSpanX[nodeBranchingI] = std::make_tuple(oldMinImp + shiftX, oldMaxImp + shiftX); @@ -214,9 +214,9 @@ namespace ttk { nodeBranchingVector[i + 1], importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_)) { - float spanMin + float const spanMin = std::get<0>(allNodeSpanX[nodeBranchingVector[0]]); - float spanMax + float const spanMax = std::get<1>(allNodeImportantSpanX [nodeBranchingVector[lastIndexImportant]]); prevX = (spanMin + spanMax) / 2; @@ -227,7 +227,7 @@ namespace ttk { // Update node span X float spanMin = std::get<0>(allNodeSpanX[nodeBranchingVector[0]]); if(lastIndexImportant != -1) { - float spanMaxImp = std::get<1>( + float const spanMaxImp = std::get<1>( allNodeImportantSpanX[nodeBranchingVector[lastIndexImportant]]); allNodeImportantSpanX[nodeOrigin] = std::make_tuple(spanMin, spanMaxImp); @@ -235,7 +235,7 @@ namespace ttk { allNodeImportantSpanX[nodeOrigin] = std::make_tuple(0, 0); spanMin = 0; } - float spanMax = std::get<1>( + float const spanMax = std::get<1>( allNodeSpanX[nodeBranchingVector[nodeBranchingVector.size() - 1]]); allNodeSpanX[nodeOrigin] = std::make_tuple(spanMin, spanMax); } else { @@ -244,8 +244,8 @@ namespace ttk { } // Positioning of this node x coordinate - float spanMin = std::get<0>(allNodeImportantSpanX[nodeOrigin]); - float spanMax = std::get<1>(allNodeImportantSpanX[nodeOrigin]); + float const spanMin = std::get<0>(allNodeImportantSpanX[nodeOrigin]); + float const spanMax = std::get<1>(allNodeImportantSpanX[nodeOrigin]); retVec[treeSimplexId[nodeOrigin] * 2] = (spanMin + spanMax) / 2; } @@ -253,9 +253,9 @@ namespace ttk { for(auto node : leaves) queue.emplace(node); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); retVec[treeSimplexId[node] * 2] = retVec[treeSimplexId[nodeOrigin] * 2]; retVec[treeSimplexId[node] * 2 + 1] = retVec[treeSimplexId[nodeOrigin] * 2 + 1]; @@ -279,7 +279,7 @@ namespace ttk { printMsg("Init internal parameters", debug::Priority::VERBOSE); auto nPoints = tree->getRealNumberOfNodes(); - int outNumberOfPoints = nPoints * 2; + int const outNumberOfPoints = nPoints * 2; retVec.resize(outNumberOfPoints); int cptNode = 0; @@ -300,11 +300,11 @@ namespace ttk { printMsg("Iterate through tree", debug::Priority::VERBOSE); std::queue queue; - ftm::idNode treeRoot = tree->getRoot(); - ftm::idNode treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); + ftm::idNode const treeRoot = tree->getRoot(); + ftm::idNode const treeRootOrigin = tree->getNode(treeRoot)->getOrigin(); queue.emplace(treeRoot); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); // Get and insert point @@ -330,7 +330,7 @@ namespace ttk { std::queue queue2; queue2.emplace(treeRoot); while(!queue2.empty()) { - ftm::idNode node = queue2.front(); + ftm::idNode const node = queue2.front(); queue2.pop(); retVec[treeSimplexId[node] * 2] @@ -410,10 +410,10 @@ namespace ttk { Timer t_move; printMsg("Move nodes given scalars", debug::Priority::VERBOSE); - float rootY = retVec[treeSimplexId[treeRoot] * 2 + 1]; - float rootOriginY = retVec[treeSimplexId[treeRootOrigin] * 2 + 1]; - float rootYmin = std::min(rootY, rootOriginY); - float rootYmax = std::max(rootY, rootOriginY); + float const rootY = retVec[treeSimplexId[treeRoot] * 2 + 1]; + float const rootOriginY = retVec[treeSimplexId[treeRootOrigin] * 2 + 1]; + float const rootYmin = std::min(rootY, rootOriginY); + float const rootYmax = std::max(rootY, rootOriginY); auto rootBirthDeath = tree->getBirthDeath(treeRoot); const double rootBirth = std::get<0>(rootBirthDeath); const double rootDeath = std::get<1>(rootBirthDeath); @@ -448,7 +448,7 @@ namespace ttk { stack.emplace(node); std::vector nodeDone(tree->getNumberOfNodes(), false); while(!stack.empty()) { - ftm::idNode node = stack.top(); + ftm::idNode const node = stack.top(); stack.pop(); nodeDone[node] = true; @@ -457,12 +457,12 @@ namespace ttk { continue; dataType nodePers = tree->getNodePersistence(node); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); // Manage leaf if(tree->isLeaf(node)) { - float nodeDiff = (retVec[treeSimplexId[node] * 2] - - retVec[treeSimplexId[nodeOrigin] * 2]); + float const nodeDiff = (retVec[treeSimplexId[node] * 2] + - retVec[treeSimplexId[nodeOrigin] * 2]); const auto sign = nodeDiff / std::abs(nodeDiff); auto inc = sign * nodePers / rootPers * (rootYmax - rootYmin) / 2; retVec[treeSimplexId[node] * 2] @@ -489,7 +489,7 @@ namespace ttk { // Manage saddle if(not tree->isLeaf(node) and not tree->isRoot(node)) { - float branchY + float const branchY = retVec[treeSimplexId[tree->getNode(branching[node])->getOrigin()] * 2]; retVec[treeSimplexId[node] * 2] = branchY; @@ -525,9 +525,9 @@ namespace ttk { for(auto leaf : leaves) queueCrossing.emplace(leaf); while(!queueCrossing.empty()) { - ftm::idNode node = queueCrossing.front(); + ftm::idNode const node = queueCrossing.front(); queueCrossing.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); // Get saddle nodes in the branch std::tuple, std::vector> @@ -545,8 +545,8 @@ namespace ttk { // Get sizes of sub-branches if they are non-important for(size_t i = 0; i < allBranchOrigins[nodeOrigin].size(); ++i) { - ftm::idNode branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; - bool isSubBranchImportant = tree->isImportantPair( + ftm::idNode const branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; + bool const isSubBranchImportant = tree->isImportantPair( branchNodeOrigin, importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_); @@ -560,10 +560,10 @@ namespace ttk { excludeImportantPairsHigherValues_)) maxSize = std::max(maxSize, allBranchOriginsSize[nodeOrigin]); } - double nonImportantPairsGap + double const nonImportantPairsGap = (rootYmax - rootYmin) * 0.005 * nonImportantPairsSpacing_; double importantPairsGap = (maxSize)*nonImportantPairsGap * 1.05; - bool customimportantPairsSpacing_ + bool const customimportantPairsSpacing_ = importantPairsGap < importantPairsSpacing_; if(customimportantPairsSpacing_) importantPairsGap = importantPairsSpacing_; @@ -572,9 +572,9 @@ namespace ttk { for(auto leaf : leaves) queueCrossing.emplace(leaf); while(!queueCrossing.empty()) { - ftm::idNode node = queueCrossing.front(); + ftm::idNode const node = queueCrossing.front(); queueCrossing.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); // Prepositioning of branches // auto restrictedBounds = getBranchBounds(retVec, treeSimplexId, @@ -583,18 +583,19 @@ namespace ttk { = std::make_tuple(retVec[treeSimplexId[node] * 2], retVec[treeSimplexId[node] * 2], 0, 0); for(size_t i = 0; i < allBranchOrigins[nodeOrigin].size(); ++i) { - ftm::idNode branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; - ftm::idNode branchNode = tree->getNode(branchNodeOrigin)->getOrigin(); + ftm::idNode const branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; + ftm::idNode const branchNode + = tree->getNode(branchNodeOrigin)->getOrigin(); - bool isSubBranchImportant = tree->isImportantPair( + bool const isSubBranchImportant = tree->isImportantPair( branchNodeOrigin, importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_); - bool toLeft = not isSubBranchImportant; + bool const toLeft = not isSubBranchImportant; // float branchNodeOriginXmin = // std::get<0>(allBranchBounds[branchNodeOrigin]); - float branchNodeOriginXmax + float const branchNodeOriginXmax = std::get<1>(allBranchBounds[branchNodeOrigin]); float shift = toLeft ? std::get<0>(restrictedBounds) - branchNodeOriginXmax : @@ -612,22 +613,23 @@ namespace ttk { // Shift a branch if conflict with another one for(size_t i = 1; i < allBranchOrigins[nodeOrigin].size(); ++i) { - ftm::idNode branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; - ftm::idNode branchNode = tree->getNode(branchNodeOrigin)->getOrigin(); + ftm::idNode const branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; + ftm::idNode const branchNode + = tree->getNode(branchNodeOrigin)->getOrigin(); for(size_t j = 0; j < i; ++j) { auto first = allBranchBounds[branchNodeOrigin]; - ftm::idNode previousBranchNodeOrigin + ftm::idNode const previousBranchNodeOrigin = allBranchOrigins[nodeOrigin][j]; auto second = allBranchBounds[previousBranchNodeOrigin]; - bool branchConflict = isConflictingBranchAndBound( + bool const branchConflict = isConflictingBranchAndBound( first, second, tree, previousBranchNodeOrigin, retVec, treeSimplexId); if(isConflictingBounds(first, second) or branchConflict) { // Get left or right orientation given the branch - int lastIndex = nodeBranching[branchNodeOrigin].size() - 1; - bool isLeft + int const lastIndex = nodeBranching[branchNodeOrigin].size() - 1; + bool const isLeft = (retVec [treeSimplexId[nodeBranching[branchNodeOrigin][lastIndex]] * 2] @@ -635,16 +637,16 @@ namespace ttk { < retVec[treeSimplexId[node] * 2]); // Get shift - float branchNodeOriginXmax = std::get<1>(first); - float previousbranchNodeOriginXmin = std::get<0>(second); + float const branchNodeOriginXmax = std::get<1>(first); + float const previousbranchNodeOriginXmin = std::get<0>(second); // float branchNodeOriginXmin = std::get<0>(first); - float previousbranchNodeOriginXmax = std::get<1>(second); + float const previousbranchNodeOriginXmax = std::get<1>(second); float shift = isLeft ? previousbranchNodeOriginXmin - branchNodeOriginXmax : // previousbranchNodeOriginXmax - branchNodeOriginXmin; previousbranchNodeOriginXmax - retVec[treeSimplexId[branchNode] * 2]; - bool isSubBranchImportant = tree->isImportantPair( + bool const isSubBranchImportant = tree->isImportantPair( branchNodeOrigin, importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_); @@ -704,26 +706,26 @@ namespace ttk { for(auto leaf : leaves) queueCrossing.emplace(leaf); while(!queueCrossing.empty()) { - ftm::idNode node = queueCrossing.front(); + ftm::idNode const node = queueCrossing.front(); queueCrossing.pop(); - ftm::idNode nodeOrigin = tree->getNode(node)->getOrigin(); + ftm::idNode const nodeOrigin = tree->getNode(node)->getOrigin(); - bool isBranchImportant = tree->isImportantPair( + bool const isBranchImportant = tree->isImportantPair( nodeOrigin, importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_); if(not isBranchImportant) continue; for(size_t i = 0; i < allBranchOrigins[nodeOrigin].size(); ++i) { - ftm::idNode branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; - bool isSubBranchImportant = tree->isImportantPair( + ftm::idNode const branchNodeOrigin = allBranchOrigins[nodeOrigin][i]; + bool const isSubBranchImportant = tree->isImportantPair( branchNodeOrigin, importantPairs_, excludeImportantPairsLowerValues_, excludeImportantPairsHigherValues_); double shift = 0; if(not isSubBranchImportant) { - double gap = retVec[treeSimplexId[node] * 2] - - std::get<0>(allBranchBounds[nodeOrigin]); + double const gap = retVec[treeSimplexId[node] * 2] + - std::get<0>(allBranchBounds[nodeOrigin]); shift = -(realImportantPairsGap - gap) * nonImportantPairsProximity_; } else { @@ -758,10 +760,10 @@ namespace ttk { res.resize(tree->getRealNumberOfNodes() * 2); int cptNode = 0; std::queue queue; - ftm::idNode treeRoot = tree->getRoot(); + ftm::idNode const treeRoot = tree->getRoot(); queue.emplace(treeRoot); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); // Get and insert point @@ -805,7 +807,7 @@ namespace ttk { std::queue queue; queue.emplace(branchRoot); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); // Skip if we go in the branch in which is branchRoot @@ -877,12 +879,13 @@ namespace ttk { ftm::idNode branchNodeOrigin, std::vector &retVec, std::vector &treeSimplexId) { - float xBranchNodeOrigin = retVec[treeSimplexId[branchNodeOrigin] * 2]; - float xBranchNode + float const xBranchNodeOrigin + = retVec[treeSimplexId[branchNodeOrigin] * 2]; + float const xBranchNode = retVec[treeSimplexId[tree->getNode(branchNodeOrigin)->getOrigin()] * 2]; - float myMin = std::min(xBranchNode, xBranchNodeOrigin); - float myMax = std::max(xBranchNode, xBranchNodeOrigin); + float const myMin = std::min(xBranchNode, xBranchNodeOrigin); + float const myMax = std::max(xBranchNode, xBranchNodeOrigin); auto branchBounds = std::make_tuple(myMin, myMax, 0, 0); return isConflictingBoundsX(first, branchBounds) and isConflictingBoundsY(first, second); @@ -909,7 +912,7 @@ namespace ttk { std::queue queue; queue.emplace(branchRoot); while(!queue.empty()) { - ftm::idNode node = queue.front(); + ftm::idNode const node = queue.front(); queue.pop(); if(branching[node] != branchRoot @@ -976,7 +979,7 @@ namespace ttk { if(excludeString.empty()) return; std::string s{excludeString}; - std::string delimiter = ","; + std::string const delimiter = ","; size_t pos = 0; std::string token; diff --git a/core/base/planarGraphLayout/PlanarGraphLayout.cpp b/core/base/planarGraphLayout/PlanarGraphLayout.cpp index 5fcb182d52..f06817bf39 100644 --- a/core/base/planarGraphLayout/PlanarGraphLayout.cpp +++ b/core/base/planarGraphLayout/PlanarGraphLayout.cpp @@ -37,7 +37,7 @@ int ttk::PlanarGraphLayout::computeDotLayout( Agnode_t *n = agnode(G, const_cast(std::to_string(i).data()), 0); if(n != nullptr) { auto &coord = ND_coord(n); - size_t offset = i * 2; + size_t const offset = i * 2; layout[offset] = coord.x / 72; // points to inches layout[offset + 1] = coord.y / 72; // points to inches } diff --git a/core/base/planarGraphLayout/PlanarGraphLayout.h b/core/base/planarGraphLayout/PlanarGraphLayout.h index 4a2bcceef6..55053adb33 100644 --- a/core/base/planarGraphLayout/PlanarGraphLayout.h +++ b/core/base/planarGraphLayout/PlanarGraphLayout.h @@ -146,7 +146,7 @@ int ttk::PlanarGraphLayout::extractLevel( nodeIndices.push_back(i); // Get edges at level - size_t nEdges2 = nEdges * 2; + size_t const nEdges2 = nEdges * 2; for(size_t i = 0; i < nEdges2; i += 2) { auto n0l = levels[connectivityList[i + 0]]; auto n1l = levels[connectivityList[i + 1]]; @@ -178,11 +178,11 @@ int ttk::PlanarGraphLayout::computeDotString( this->printMsg("Generating DOT String", 0, debug::LineMode::REPLACE); - bool useSequences = pointSequences != nullptr; - bool useSizes = sizes != nullptr; - bool useBranches = branches != nullptr; + bool const useSequences = pointSequences != nullptr; + bool const useSizes = sizes != nullptr; + bool const useBranches = branches != nullptr; - std::string headString = "digraph g {rankdir=LR;"; + std::string const headString = "digraph g {rankdir=LR;"; std::string nodeString = ""; std::string edgeString = ""; std::string rankString = ""; @@ -208,7 +208,7 @@ int ttk::PlanarGraphLayout::computeDotString( // Ranks // --------------------------------------------------------------------------- if(useSequences) { - size_t nSequenceValues = sequenceValueToIndexMap.size(); + size_t const nSequenceValues = sequenceValueToIndexMap.size(); // Sequence Chain { @@ -243,7 +243,7 @@ int ttk::PlanarGraphLayout::computeDotString( // --------------------------------------------------------------------------- { for(auto &edgeIndex : edgeIndices) { - size_t temp = edgeIndex * 2; + size_t const temp = edgeIndex * 2; auto &i0 = connectivityList[temp + 0]; auto &i1 = connectivityList[temp + 1]; edgeString += nl(i0) + "->" + nl(i1); @@ -314,7 +314,7 @@ int ttk::PlanarGraphLayout::computeSlots( // --------------------------------------------------------------------------- std::vector> nodeIndexChildrenIndexMap(nPoints); - size_t nEdges2 = nEdges * 2; + size_t const nEdges2 = nEdges * 2; for(size_t i = 0; i < nEdges2; i += 2) { auto n0 = connectivityList[i + 0]; auto n1 = connectivityList[i + 1]; @@ -340,7 +340,7 @@ int ttk::PlanarGraphLayout::computeSlots( // for each parent adjust position of children for(auto &parent : nodeIndices) { auto &children = nodeIndexChildrenIndexMap[parent]; - size_t nChildren = children.size(); + size_t const nChildren = children.size(); if(nChildren < 1) continue; @@ -348,7 +348,7 @@ int ttk::PlanarGraphLayout::computeSlots( sort(children.begin(), children.end(), comparator); // size of parent - float sizeParent = sizes[parent]; + float const sizeParent = sizes[parent]; // size of child float sizeChildren = 0; @@ -356,12 +356,12 @@ int ttk::PlanarGraphLayout::computeSlots( sizeChildren += sizes[child]; // gap space - float gap = sizeParent - sizeChildren; - float gapDelta = (gap / (nChildren + 1)) / 2; + float const gap = sizeParent - sizeChildren; + float const gapDelta = (gap / (nChildren + 1)) / 2; float y = layout[parent * 2 + 1] + sizeParent * 0.5 - gapDelta; for(auto &child : children) { - float temp = gapDelta + sizes[child] / 2; + float const temp = gapDelta + sizes[child] / 2; layout[child * 2 + 1] = y - temp; y -= 2 * temp; } @@ -393,10 +393,10 @@ int ttk::PlanarGraphLayout::computeLayout( Timer t; // Init Input - bool useSequences = pointSequences != nullptr; - bool useSizes = sizes != nullptr; - bool useBranches = branches != nullptr; - bool useLevels = levels != nullptr; + bool const useSequences = pointSequences != nullptr; + bool const useSizes = sizes != nullptr; + bool const useBranches = branches != nullptr; + bool const useLevels = levels != nullptr; // Print Input { @@ -450,7 +450,7 @@ int ttk::PlanarGraphLayout::computeLayout( // Extract nodes and edges at certain level { - int status = this->extractLevel( + int const status = this->extractLevel( // Output nodeIndices, edgeIndices, @@ -463,7 +463,7 @@ int ttk::PlanarGraphLayout::computeLayout( // Compute Dot String std::string dotString; { - int status = this->computeDotString( + int const status = this->computeDotString( // Output dotString, @@ -476,7 +476,7 @@ int ttk::PlanarGraphLayout::computeLayout( // Compute Dot Layout { - int status = this->computeDotLayout(layout, nodeIndices, dotString); + int const status = this->computeDotLayout(layout, nodeIndices, dotString); if(status != 1) return 0; } diff --git a/core/base/progressiveTopology/ProgressiveTopology.cpp b/core/base/progressiveTopology/ProgressiveTopology.cpp index e9fa44fe2a..2e9534305b 100644 --- a/core/base/progressiveTopology/ProgressiveTopology.cpp +++ b/core/base/progressiveTopology/ProgressiveTopology.cpp @@ -84,7 +84,7 @@ int ttk::ProgressiveTopology::executeCPProgressive( // pre-allocate memory if(preallocateMemory_) { - double tm_prealloc = timer.getElapsedTime(); + double const tm_prealloc = timer.getElapsedTime(); printMsg("Pre-allocating data structures", 0, 0, threadNumber_, ttk::debug::LineMode::REPLACE); for(SimplexId i = 0; i < vertexNumber; ++i) { @@ -313,7 +313,8 @@ void ttk::ProgressiveTopology::computePersistencePairsFromSaddles( const SimplexId nbDecVert = multiresTriangulation_.getDecimatedVertexNumber(); for(SimplexId localId = 0; localId < nbDecVert; localId++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(localId); + SimplexId const globalId + = multiresTriangulation_.localToGlobalVertexId(localId); if(toPropagateMin[globalId]) { getTripletsFromSaddles(globalId, tripletsMin, vertexRepresentativesMin); } @@ -325,7 +326,7 @@ void ttk::ProgressiveTopology::computePersistencePairsFromSaddles( this->printMsg("TRIPLETS", 1.0, timer.getElapsedTime(), this->threadNumber_, debug::LineMode::NEW, debug::Priority::DETAIL); - double tm_pairs = timer.getElapsedTime(); + double const tm_pairs = timer.getElapsedTime(); sortTriplets(tripletsMax, offsets, true); sortTriplets(tripletsMin, offsets, false); @@ -413,7 +414,7 @@ void ttk::ProgressiveTopology::tripletsToPersistencePairs( SimplexId r1 = getRep(std::get<1>(t)); SimplexId r2 = getRep(std::get<2>(t)); if(r1 != r2) { - SimplexId s = std::get<0>(t); + SimplexId const s = std::get<0>(t); // Add pair if(splitTree) { @@ -512,7 +513,8 @@ void ttk::ProgressiveTopology::updateCriticalPoints( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(SimplexId localId = 0; localId < nDecVerts; localId++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(localId); + SimplexId const globalId + = multiresTriangulation_.localToGlobalVertexId(localId); if(isNew[globalId]) { if(decimationLevel_ > stoppingDecimationLevel_ || isResumable_) { buildVertexLinkPolarity( @@ -527,13 +529,13 @@ void ttk::ProgressiveTopology::updateCriticalPoints( this->printMsg("MONOTONY", 1.0, tm.getElapsedTime(), this->threadNumber_, debug::LineMode::NEW, debug::Priority::DETAIL); - double t_critical = tm.getElapsedTime(); + double const t_critical = tm.getElapsedTime(); // second Loop process or reprocess #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) #endif for(int i = 0; i < nDecVerts; i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); if(isNew[globalId]) { // new point if(toProcess[globalId]) { @@ -596,7 +598,8 @@ void ttk::ProgressiveTopology::updateSaddleSeeds( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(SimplexId localId = 0; localId < nDecVerts; localId++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(localId); + SimplexId const globalId + = multiresTriangulation_.localToGlobalVertexId(localId); if(isNew[globalId]) { if(decimationLevel_ > stoppingDecimationLevel_ || isResumable_) { buildVertexLinkPolarity( @@ -611,13 +614,13 @@ void ttk::ProgressiveTopology::updateSaddleSeeds( this->printMsg("MONOTONY", 1.0, tm.getElapsedTime(), this->threadNumber_, debug::LineMode::NEW, debug::Priority::DETAIL); - double t_critical = tm.getElapsedTime(); + double const t_critical = tm.getElapsedTime(); // second Loop process or reprocess #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) #endif for(int i = 0; i < nDecVerts; i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); if(isNew[globalId]) { // new point if(toProcess[globalId]) { @@ -732,9 +735,9 @@ ttk::SimplexId ttk::ProgressiveTopology::propagateFromSaddles( reps.reserve(CC.size()); for(size_t r = 0; r < CC.size(); r++) { SimplexId neighborId = -1; - SimplexId localId = CC[r]; + SimplexId const localId = CC[r]; multiresTriangulation_.getVertexNeighbor(vertexId, localId, neighborId); - SimplexId ret = propagateFromSaddles( + SimplexId const ret = propagateFromSaddles( neighborId, vertLock, toPropagate, vertexRepresentatives, saddleCC, isUpdated, globalExtremum, offsets, splitTree); reps.emplace_back(ret); @@ -757,7 +760,7 @@ ttk::SimplexId ttk::ProgressiveTopology::propagateFromSaddles( } else { SimplexId ret = vertexId; - SimplexId neighborNumber + SimplexId const neighborNumber = multiresTriangulation_.getVertexNeighborNumber(vertexId); SimplexId maxNeighbor = vertexId; for(SimplexId i = 0; i < neighborNumber; i++) { @@ -810,7 +813,7 @@ void ttk::ProgressiveTopology::initCriticalPoints( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); buildVertexLinkPolarity(globalId, vertexLinkPolarity[globalId], offsets); initDynamicLink(globalId, vertexLinkPolarity[globalId], vertexLink[globalId], link[globalId], @@ -848,7 +851,7 @@ void ttk::ProgressiveTopology::initSaddleSeeds( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId globalId = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const globalId = multiresTriangulation_.localToGlobalVertexId(i); buildVertexLinkPolarity(globalId, vertexLinkPolarity[globalId], offsets); initDynamicLink(globalId, vertexLinkPolarity[globalId], vertexLink[globalId], link[globalId], @@ -888,7 +891,7 @@ void ttk::ProgressiveTopology::initPropagation( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const v = multiresTriangulation_.localToGlobalVertexId(i); if(toPropagateMin[v]) { propagateFromSaddles(v, vertLockMin, toPropagateMin, vertexRepresentativesMin, saddleCCMin, isUpdatedMin, @@ -937,7 +940,7 @@ void ttk::ProgressiveTopology::updatePropagation( #pragma omp parallel for num_threads(threadNumber_) #endif // TTK_ENABLE_OPENMP for(size_t i = 0; i < nDecVerts; i++) { - SimplexId v = multiresTriangulation_.localToGlobalVertexId(i); + SimplexId const v = multiresTriangulation_.localToGlobalVertexId(i); if(toPropagateMin[v]) { propagateFromSaddles(v, vertLockMin, toPropagateMin, vertexRepresentativesMin, saddleCCMin, isUpdatedMin, @@ -1094,10 +1097,10 @@ char ttk::ProgressiveTopology::getCriticalTypeFromLink( const auto nbCC = link.getNbCC(); - bool isVertexOnBoundary + bool const isVertexOnBoundary = multiresTriangulation_.getTriangulation()->isVertexOnBoundary(globalId); - int dimensionality = multiresTriangulation_.getDimensionality(); + int const dimensionality = multiresTriangulation_.getDimensionality(); SimplexId downValence = 0, upValence = 0; std::vector CCIds; @@ -1203,7 +1206,7 @@ int ttk::ProgressiveTopology::computeProgressiveCP( int ret = -1; ret = executeCPProgressive(0, offsets); - SimplexId vertexNumber = multiresTriangulation_.getVertexNumber(); + SimplexId const vertexNumber = multiresTriangulation_.getVertexNumber(); criticalPoints->clear(); criticalPoints->reserve(vertexNumber); for(SimplexId i = 0; i < vertexNumber; i++) { diff --git a/core/base/projectionFromTable/ProjectionFromTable.h b/core/base/projectionFromTable/ProjectionFromTable.h index 2b92645111..fde581863d 100644 --- a/core/base/projectionFromTable/ProjectionFromTable.h +++ b/core/base/projectionFromTable/ProjectionFromTable.h @@ -39,7 +39,7 @@ namespace ttk { const yDataType *const tableYValues, const size_t nTableValues, std::vector> &inputPoints) { - unsigned int noPoints = nTableValues; + unsigned int const noPoints = nTableValues; inputPoints = std::vector>( noPoints, std::vector(3, 0.0)); @@ -111,7 +111,7 @@ namespace ttk { tableValues.data(), trianglePoints[1].data(), trianglePoints[2].data(), coef[i][indexes[0]]); - double sumArea + double const sumArea = coef[i][indexes[2]] + coef[i][indexes[1]] + coef[i][indexes[0]]; for(unsigned int j = 0; j < 3; ++j) coef[i][indexes[j]] /= sumArea; diff --git a/core/base/quadrangulationSubdivision/QuadrangulationSubdivision.h b/core/base/quadrangulationSubdivision/QuadrangulationSubdivision.h index e26b2df720..f9d5aaad0c 100644 --- a/core/base/quadrangulationSubdivision/QuadrangulationSubdivision.h +++ b/core/base/quadrangulationSubdivision/QuadrangulationSubdivision.h @@ -221,8 +221,8 @@ ttk::SimplexId ttk::QuadrangulationSubdivision::findEdgeMiddle( Point edgeEuclBary = (outputPoints_[e[0]] + outputPoints_[e[1]]) * 0.5F; for(size_t i = 0; i < vertexDistance_[e[0]].size(); ++i) { - float m = vertexDistance_[e[0]][i]; - float n = vertexDistance_[e[1]][i]; + float const m = vertexDistance_[e[0]][i]; + float const n = vertexDistance_[e[1]][i]; // stay on the shortest path between a and b float sum = m + n; diff --git a/core/base/rangeDrivenOctree/RangeDrivenOctree.cpp b/core/base/rangeDrivenOctree/RangeDrivenOctree.cpp index 1aff8d1143..9957e09b46 100644 --- a/core/base/rangeDrivenOctree/RangeDrivenOctree.cpp +++ b/core/base/rangeDrivenOctree/RangeDrivenOctree.cpp @@ -51,7 +51,7 @@ int RangeDrivenOctree::rangeSegmentQuery( queryResultNumber_ = 0; cellList.clear(); - SimplexId ret = rangeSegmentQuery(p0, p1, rootId_, cellList); + SimplexId const ret = rangeSegmentQuery(p0, p1, rootId_, cellList); if(debugLevel_ >= static_cast(debug::Priority::DETAIL)) { this->printMsg("Query done", 1.0, t.getElapsedTime(), this->threadNumber_, @@ -368,7 +368,7 @@ bool RangeDrivenOctree::segmentIntersection( double P = (p1.second - p0.second) / denP; if(!P) P = DBL_EPSILON; - double bP = p1.second - P * p1.first; + double const bP = p1.second - P * p1.first; if(horizontal) { y = q0.second; diff --git a/core/base/rangeDrivenOctree/RangeDrivenOctree.h b/core/base/rangeDrivenOctree/RangeDrivenOctree.h index 46b5f7775e..a248642ae3 100644 --- a/core/base/rangeDrivenOctree/RangeDrivenOctree.h +++ b/core/base/rangeDrivenOctree/RangeDrivenOctree.h @@ -314,12 +314,12 @@ int ttk::RangeDrivenOctree::buildNode( nodeList_.back().rangeBox_ = rangeBox; nodeList_.back().domainBox_ = domainBox; - float rangeArea = (rangeBox.first.second - rangeBox.first.first) - * (rangeBox.second.second - rangeBox.second.first); + float const rangeArea = (rangeBox.first.second - rangeBox.first.first) + * (rangeBox.second.second - rangeBox.second.first); - float domainVolume = (domainBox[0].second - domainBox[0].first) - * (domainBox[1].second - domainBox[1].first) - * (domainBox[2].second - domainBox[2].first); + float const domainVolume = (domainBox[0].second - domainBox[0].first) + * (domainBox[1].second - domainBox[1].first) + * (domainBox[2].second - domainBox[2].first); if(((SimplexId)cellList.size() > leafMinimumCellNumber_) && (rangeArea > leafMinimumRangeAreaRatio_ * rangeArea_) @@ -334,11 +334,11 @@ int ttk::RangeDrivenOctree::buildNode( childRangeBox{}; std::array, 8> childCellList{}; - float midX + float const midX = domainBox[0].first + (domainBox[0].second - domainBox[0].first) / 2.0; - float midY + float const midY = domainBox[1].first + (domainBox[1].second - domainBox[1].first) / 2.0; - float midZ + float const midZ = domainBox[2].first + (domainBox[2].second - domainBox[2].first) / 2.0; // 0 - - - diff --git a/core/base/rangeMinimumQuery/RangeMinimumQuery.h b/core/base/rangeMinimumQuery/RangeMinimumQuery.h index aa4ecf87cc..507fd95f4f 100644 --- a/core/base/rangeMinimumQuery/RangeMinimumQuery.h +++ b/core/base/rangeMinimumQuery/RangeMinimumQuery.h @@ -63,8 +63,9 @@ int ttk::RangeMinimumQuery::preprocess(const bool silent) { Timer t; // Compute the size of the matrix - int sizeOfArray = static_cast(input_end_ - input_); - int numberOfBlocs = static_cast(log2(sizeOfArray + 1)) + 1; + int const sizeOfArray = static_cast(input_end_ - input_); + int const numberOfBlocs + = static_cast(log2(sizeOfArray + 1)) + 1; // Init the matrix table_.resize(sizeOfArray); @@ -106,7 +107,7 @@ int ttk::RangeMinimumQuery::query(int i, int j) const { #endif // Compute size of blocs (2^k) to use - int k = static_cast(log2(j - i + 1)); + int const k = static_cast(log2(j - i + 1)); // Compute the range minimum if(input_[table_[i][k]] <= input_[table_[j - (1 << k) + 1][k]]) { return table_[i][k]; diff --git a/core/base/reebSpace/ReebSpace.cpp b/core/base/reebSpace/ReebSpace.cpp index 50234b7f14..93f453a280 100644 --- a/core/base/reebSpace/ReebSpace.cpp +++ b/core/base/reebSpace/ReebSpace.cpp @@ -190,13 +190,14 @@ int ttk::ReebSpace::preMergeSheets(const SimplexId &sheetId0, // 1. add the vertices and tets of 0 to 1 for(size_t i = 0; i < originalData_.sheet3List_[sheetId0].vertexList_.size(); i++) { - SimplexId vertexId = originalData_.sheet3List_[sheetId0].vertexList_[i]; + SimplexId const vertexId + = originalData_.sheet3List_[sheetId0].vertexList_[i]; originalData_.sheet3List_[sheetId1].vertexList_.push_back(vertexId); originalData_.vertex2sheet3_[vertexId] = sheetId1; } for(size_t i = 0; i < originalData_.sheet3List_[sheetId0].tetList_.size(); i++) { - SimplexId tetId = originalData_.sheet3List_[sheetId0].tetList_[i]; + SimplexId const tetId = originalData_.sheet3List_[sheetId0].tetList_[i]; originalData_.sheet3List_[sheetId1].tetList_.push_back(tetId); originalData_.tet2sheet3_[tetId] = sheetId1; } @@ -260,7 +261,7 @@ int ttk::ReebSpace::prepareSimplification() { for(size_t j = 0; j < currentData_.sheet1List_[i].sheet0List_.size(); j++) { - SimplexId sheet0Id = currentData_.sheet1List_[i].sheet0List_[j]; + SimplexId const sheet0Id = currentData_.sheet1List_[i].sheet0List_[j]; currentData_.sheet0List_[sheet0Id].pruned_ = true; } } diff --git a/core/base/reebSpace/ReebSpace.h b/core/base/reebSpace/ReebSpace.h index b03c6b318f..6d3a9d70fe 100644 --- a/core/base/reebSpace/ReebSpace.h +++ b/core/base/reebSpace/ReebSpace.h @@ -538,7 +538,7 @@ inline int ttk::ReebSpace::compute2sheets( for(size_t i = 0; i < jacobiEdges.size(); i++) { - SimplexId edgeId = jacobiEdges[i].first; + SimplexId const edgeId = jacobiEdges[i].first; edge2polygonEdgeId[edgeId] = i; jacobi2edges_[i] = edgeId; @@ -554,7 +554,7 @@ inline int ttk::ReebSpace::compute2sheets( .edgeList_.size(); j++) { - SimplexId edgeId + SimplexId const edgeId = originalData_.sheet1List_[originalData_.sheet2List_[i].sheet1Id_] .edgeList_[j]; @@ -572,7 +572,7 @@ inline int ttk::ReebSpace::compute2sheets( #endif for(size_t i = 0; i < jacobiEdges.size(); i++) { - SimplexId edgeId = jacobiEdges[i].first; + SimplexId const edgeId = jacobiEdges[i].first; std::pair rangePoint0, rangePoint1; @@ -753,7 +753,7 @@ inline int ttk::ReebSpace::computeGeometricalMeasures( for(size_t i = 0; i < sheet.tetList_.size(); i++) { - SimplexId tetId = sheet.tetList_[i]; + SimplexId const tetId = sheet.tetList_[i]; std::array, 3> domainBox{}; std::array, 2> rangeBox; std::array, 4> domainPoints{}; @@ -890,7 +890,7 @@ int ttk::ReebSpace::compute1sheetsOnly( if(visitedEdges[jacobiSet[i].first] == false) { - SimplexId sheet1Id = originalData_.sheet1List_.size(); + SimplexId const sheet1Id = originalData_.sheet1List_.size(); originalData_.sheet1List_.resize(originalData_.sheet1List_.size() + 1); originalData_.sheet1List_.back().hasSaddleEdges_ = false; originalData_.sheet1List_.back().pruned_ = false; @@ -900,7 +900,7 @@ int ttk::ReebSpace::compute1sheetsOnly( do { - SimplexId edgeId = edgeQueue.front(); + SimplexId const edgeId = edgeQueue.front(); edgeQueue.pop(); if(!visitedEdges[edgeId]) { @@ -1031,7 +1031,7 @@ int ttk::ReebSpace::compute1sheets( // saddle, non-visited edge // we have a seed here - SimplexId sheet1Id = originalData_.sheet1List_.size(); + SimplexId const sheet1Id = originalData_.sheet1List_.size(); originalData_.sheet1List_.resize(originalData_.sheet1List_.size() + 1); originalData_.sheet1List_.back().hasSaddleEdges_ = false; originalData_.sheet1List_.back().pruned_ = false; @@ -1210,7 +1210,7 @@ int ttk::ReebSpace::compute3sheet( const std::vector>> &tetTriangles, const triangulationType &triangulation) { - SimplexId sheetId = originalData_.sheet3List_.size(); + SimplexId const sheetId = originalData_.sheet3List_.size(); originalData_.sheet3List_.resize(originalData_.sheet3List_.size() + 1); originalData_.sheet3List_.back().pruned_ = false; originalData_.sheet3List_.back().preMerger_ = -1; @@ -1221,7 +1221,7 @@ int ttk::ReebSpace::compute3sheet( do { - SimplexId localVertexId = vertexQueue.front(); + SimplexId const localVertexId = vertexQueue.front(); vertexQueue.pop(); if(originalData_.vertex2sheet3_[localVertexId] == -1) { @@ -1230,7 +1230,7 @@ int ttk::ReebSpace::compute3sheet( originalData_.sheet3List_.back().vertexList_.push_back(localVertexId); originalData_.vertex2sheet3_[localVertexId] = sheetId; - SimplexId vertexStarNumber + SimplexId const vertexStarNumber = triangulation.getVertexStarNumber(localVertexId); for(SimplexId i = 0; i < vertexStarNumber; i++) { @@ -1330,7 +1330,7 @@ int ttk::ReebSpace::compute3sheets( for(size_t k = 0; k < originalData_.sheet2List_[i].triangleList_[j].size(); k++) { - SimplexId tetId + SimplexId const tetId = originalData_.sheet2List_[i].triangleList_[j][k].tetId_; tetTriangles[tetId].emplace_back(); @@ -1345,7 +1345,7 @@ int ttk::ReebSpace::compute3sheets( for(size_t i = 0; i < originalData_.sheet1List_.size(); i++) { for(size_t j = 0; j < originalData_.sheet1List_[i].edgeList_.size(); j++) { - SimplexId edgeId = originalData_.sheet1List_[i].edgeList_[j]; + SimplexId const edgeId = originalData_.sheet1List_[i].edgeList_[j]; SimplexId vertexId0 = -1, vertexId1 = -1; triangulation.getEdgeVertex(edgeId, 0, vertexId0); @@ -1375,10 +1375,11 @@ int ttk::ReebSpace::compute3sheets( for(size_t j = 0; j < originalData_.sheet3List_[i].vertexList_.size(); j++) { - SimplexId vertexId = originalData_.sheet3List_[i].vertexList_[j]; - SimplexId sheetId = originalData_.vertex2sheet3_[vertexId]; + SimplexId const vertexId = originalData_.sheet3List_[i].vertexList_[j]; + SimplexId const sheetId = originalData_.vertex2sheet3_[vertexId]; - SimplexId vertexStarNumber = triangulation.getVertexStarNumber(vertexId); + SimplexId const vertexStarNumber + = triangulation.getVertexStarNumber(vertexId); for(SimplexId k = 0; k < vertexStarNumber; k++) { SimplexId tetId = -1; @@ -1399,7 +1400,7 @@ int ttk::ReebSpace::compute3sheets( if(vertexId != otherVertexId) { - SimplexId otherSheetId + SimplexId const otherSheetId = originalData_.vertex2sheet3_[otherVertexId]; if((sheetId != otherSheetId) && (otherSheetId >= 0)) { @@ -1413,16 +1414,15 @@ int ttk::ReebSpace::compute3sheets( } if(!inThere) { - neighborList[sheetId].push_back( - std::pair(otherSheetId, true)); + neighborList[sheetId].emplace_back(otherSheetId, true); } for(size_t m = 0; m < tetTriangles[tetId].size(); m++) { // see if this guy is a saddle - SimplexId x = tetTriangles[tetId][m][0]; - SimplexId y = tetTriangles[tetId][m][1]; - SimplexId z = tetTriangles[tetId][m][2]; + SimplexId const x = tetTriangles[tetId][m][0]; + SimplexId const y = tetTriangles[tetId][m][1]; + SimplexId const z = tetTriangles[tetId][m][2]; FiberSurface::Triangle *tr = &(originalData_.sheet2List_[x].triangleList_[y][z]); @@ -1445,8 +1445,8 @@ int ttk::ReebSpace::compute3sheets( if(cuttingTriangle) { - SimplexId polygonId = tr->polygonEdgeId_; - SimplexId edgeId = jacobi2edges_[polygonId]; + SimplexId const polygonId = tr->polygonEdgeId_; + SimplexId const edgeId = jacobi2edges_[polygonId]; if(originalData_.edgeTypes_[edgeId] == 1) { // this is a saddle Jacobi edge @@ -1464,8 +1464,8 @@ int ttk::ReebSpace::compute3sheets( } if(!inThere) { - neighborList[sheetId].push_back( - std::pair(otherSheetId, false)); + neighborList[sheetId].emplace_back( + otherSheetId, false); } } } @@ -1510,7 +1510,7 @@ int ttk::ReebSpace::compute3sheets( < originalData_.sheet3List_[neighborId].preMergedSheets_.size(); k++) { - SimplexId subNeighborId + SimplexId const subNeighborId = originalData_.sheet3List_[neighborId].preMergedSheets_[k]; for(size_t l = 0; l < neighborList[i].size(); l++) { @@ -1529,7 +1529,7 @@ int ttk::ReebSpace::compute3sheets( if(!isForbidden) { for(size_t k = 0; k < neighborList[i].size(); k++) { if(!neighborList[i][k].second) { - SimplexId forbiddenNeighbor = neighborList[i][k].first; + SimplexId const forbiddenNeighbor = neighborList[i][k].first; // make sure forbiddenNeighbor is not a valid merger for // neighborId @@ -1583,14 +1583,14 @@ int ttk::ReebSpace::connectSheets(const triangulationType &triangulation) { for(size_t k = 0; k < originalData_.sheet2List_[i].triangleList_[j].size(); k++) { - SimplexId tetId + SimplexId const tetId = originalData_.sheet2List_[i].triangleList_[j][k].tetId_; for(int l = 0; l < 4; l++) { SimplexId vertexId = -1; triangulation.getCellVertex(tetId, l, vertexId); - SimplexId sheet3Id = originalData_.vertex2sheet3_[vertexId]; + SimplexId const sheet3Id = originalData_.vertex2sheet3_[vertexId]; if(sheet3Id >= 0) { connect3sheetTo2sheet(originalData_, sheet3Id, i); @@ -1604,7 +1604,7 @@ int ttk::ReebSpace::connectSheets(const triangulationType &triangulation) { for(SimplexId i = 0; i < vertexNumber_; i++) { if(originalData_.vertex2sheet3_[i] >= 0) { - SimplexId vertexEdgeNumber = triangulation.getVertexEdgeNumber(i); + SimplexId const vertexEdgeNumber = triangulation.getVertexEdgeNumber(i); for(SimplexId j = 0; j < vertexEdgeNumber; j++) { SimplexId edgeId = -1; @@ -1631,7 +1631,8 @@ int ttk::ReebSpace::connectSheets(const triangulationType &triangulation) { } if(originalData_.vertex2sheet3_[otherVertexId] < -1) { - SimplexId sheet1Id = -2 - originalData_.vertex2sheet3_[otherVertexId]; + SimplexId const sheet1Id + = -2 - originalData_.vertex2sheet3_[otherVertexId]; connect3sheetTo1sheet( originalData_, originalData_.vertex2sheet3_[i], sheet1Id); } @@ -1661,7 +1662,7 @@ int ttk::ReebSpace::disconnect3sheetFrom1sheet( newList.reserve(data.sheet1List_[sheet1Id].sheet3List_.size()); for(size_t i = 0; i < data.sheet1List_[sheet1Id].sheet3List_.size(); i++) { - SimplexId other3SheetId = data.sheet1List_[sheet1Id].sheet3List_[i]; + SimplexId const other3SheetId = data.sheet1List_[sheet1Id].sheet3List_[i]; if((other3SheetId != sheet3Id) && (!data.sheet3List_[other3SheetId].pruned_) && (data.sheet3List_[other3SheetId].tetList_.size())) { newList.push_back(data.sheet1List_[sheet1Id].sheet3List_[i]); @@ -1743,13 +1744,14 @@ int ttk::ReebSpace::mergeSheets(const SimplexId &smallerId, // 1. add the vertices and tets of smaller to bigger for(size_t i = 0; i < currentData_.sheet3List_[smallerId].vertexList_.size(); i++) { - SimplexId vertexId = currentData_.sheet3List_[smallerId].vertexList_[i]; + SimplexId const vertexId + = currentData_.sheet3List_[smallerId].vertexList_[i]; currentData_.sheet3List_[biggerId].vertexList_.push_back(vertexId); currentData_.vertex2sheet3_[vertexId] = biggerId; } for(size_t i = 0; i < currentData_.sheet3List_[smallerId].tetList_.size(); i++) { - SimplexId tetId = currentData_.sheet3List_[smallerId].tetList_[i]; + SimplexId const tetId = currentData_.sheet3List_[smallerId].tetList_[i]; currentData_.sheet3List_[biggerId].tetList_.push_back(tetId); currentData_.tet2sheet3_[tetId] = biggerId; } @@ -1766,7 +1768,8 @@ int ttk::ReebSpace::mergeSheets(const SimplexId &smallerId, for(size_t i = 0; i < currentData_.sheet3List_[smallerId].sheet3List_.size(); i++) { - SimplexId otherSheetId = currentData_.sheet3List_[smallerId].sheet3List_[i]; + SimplexId const otherSheetId + = currentData_.sheet3List_[smallerId].sheet3List_[i]; if(otherSheetId != biggerId) { connect3sheetTo3sheet(currentData_, biggerId, otherSheetId); @@ -1776,7 +1779,8 @@ int ttk::ReebSpace::mergeSheets(const SimplexId &smallerId, for(size_t i = 0; i < currentData_.sheet3List_[smallerId].sheet2List_.size(); i++) { - SimplexId otherSheetId = currentData_.sheet3List_[smallerId].sheet2List_[i]; + SimplexId const otherSheetId + = currentData_.sheet3List_[smallerId].sheet2List_[i]; if(otherSheetId != biggerId) { connect3sheetTo2sheet(currentData_, biggerId, otherSheetId); @@ -1786,7 +1790,8 @@ int ttk::ReebSpace::mergeSheets(const SimplexId &smallerId, for(size_t i = 0; i < currentData_.sheet3List_[smallerId].sheet1List_.size(); i++) { - SimplexId otherSheetId = currentData_.sheet3List_[smallerId].sheet1List_[i]; + SimplexId const otherSheetId + = currentData_.sheet3List_[smallerId].sheet1List_[i]; if(otherSheetId != biggerId) { connect3sheetTo1sheet(currentData_, biggerId, otherSheetId); @@ -1796,7 +1801,8 @@ int ttk::ReebSpace::mergeSheets(const SimplexId &smallerId, for(size_t i = 0; i < currentData_.sheet3List_[smallerId].sheet0List_.size(); i++) { - SimplexId otherSheetId = currentData_.sheet3List_[smallerId].sheet0List_[i]; + SimplexId const otherSheetId + = currentData_.sheet3List_[smallerId].sheet0List_[i]; if(otherSheetId != biggerId) { connect3sheetTo0sheet(currentData_, biggerId, otherSheetId); @@ -1849,7 +1855,8 @@ int ttk::ReebSpace::simplifySheet(const SimplexId &sheetId, // see the adjacent 3-sheets for(size_t i = 0; i < currentData_.sheet3List_[sheetId].sheet3List_.size(); i++) { - SimplexId otherSheetId = currentData_.sheet3List_[sheetId].sheet3List_[i]; + SimplexId const otherSheetId + = currentData_.sheet3List_[sheetId].sheet3List_[i]; if((!currentData_.sheet3List_[otherSheetId].pruned_) && (sheetId != otherSheetId)) { @@ -2033,8 +2040,8 @@ int ttk::ReebSpace::simplifySheets( if(currentData_.sheet3List_[i].pruned_) { // find where it merged if(currentData_.sheet3List_[i].vertexList_.size()) { - SimplexId vertexId = currentData_.sheet3List_[i].vertexList_[0]; - SimplexId sheetId = currentData_.vertex2sheet3_[vertexId]; + SimplexId const vertexId = currentData_.sheet3List_[i].vertexList_[0]; + SimplexId const sheetId = currentData_.vertex2sheet3_[vertexId]; if(sheetId != static_cast(i)) { currentData_.sheet3List_[i].simplificationId_ = currentData_.sheet3List_[sheetId].simplificationId_; @@ -2050,7 +2057,7 @@ int ttk::ReebSpace::simplifySheets( SimplexId nonSimplified = 0; for(size_t j = 0; j < currentData_.sheet1List_[i].sheet3List_.size(); j++) { - SimplexId sheet3Id = currentData_.sheet1List_[i].sheet3List_[j]; + SimplexId const sheet3Id = currentData_.sheet1List_[i].sheet3List_[j]; if(!currentData_.sheet3List_[sheet3Id].pruned_) { nonSimplified++; diff --git a/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.cpp b/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.cpp index 28b49bc14f..527a8e950a 100644 --- a/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.cpp +++ b/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.cpp @@ -104,17 +104,17 @@ char ttk::ScalarFieldCriticalPoints::getCriticalType( for(SimplexId i = 0; i < (SimplexId)vertexLink.size(); i++) { - SimplexId neighborId0 = vertexLink[i].first; - SimplexId neighborId1 = vertexLink[i].second; + SimplexId const neighborId0 = vertexLink[i].first; + SimplexId const neighborId1 = vertexLink[i].second; // process the lower link if(offsets[neighborId0] < offsets[vertexId] && offsets[neighborId1] < offsets[vertexId]) { // both vertices are lower, let's add that edge and update the UF - std::map::iterator n0It + std::map::iterator const n0It = global2LowerLink.find(neighborId0); - std::map::iterator n1It + std::map::iterator const n1It = global2LowerLink.find(neighborId1); lowerList[n0It->second] = UnionFind::makeUnion( @@ -127,9 +127,9 @@ char ttk::ScalarFieldCriticalPoints::getCriticalType( && offsets[neighborId1] > offsets[vertexId]) { // both vertices are lower, let's add that edge and update the UF - std::map::iterator n0It + std::map::iterator const n0It = global2UpperLink.find(neighborId0); - std::map::iterator n1It + std::map::iterator const n1It = global2UpperLink.find(neighborId1); upperList[n0It->second] = UnionFind::makeUnion( diff --git a/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.h b/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.h index b3c41193ba..4948ce4a4f 100644 --- a/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.h +++ b/core/base/scalarFieldCriticalPoints/ScalarFieldCriticalPoints.h @@ -246,7 +246,8 @@ int ttk::ScalarFieldCriticalPoints::executeLegacy( std::vector vertexTypes(vertexNumber_, (char)(CriticalType::Regular)); #ifdef TTK_ENABLE_OPENMP - int chunkSize = std::max(1000, (int)vertexNumber_ / (threadNumber_ * 100)); + int const chunkSize + = std::max(1000, (int)vertexNumber_ / (threadNumber_ * 100)); #endif if(triangulation) { @@ -370,7 +371,8 @@ int ttk::ScalarFieldCriticalPoints::getLowerUpperComponents( std::vector> *upperComponents, std::vector> *lowerComponents) const { - SimplexId neighborNumber = triangulation->getVertexNeighborNumber(vertexId); + SimplexId const neighborNumber + = triangulation->getVertexNeighborNumber(vertexId); std::vector lowerNeighbors, upperNeighbors; for(SimplexId i = 0; i < neighborNumber; i++) { @@ -408,13 +410,13 @@ int ttk::ScalarFieldCriticalPoints::getLowerUpperComponents( upperList[i] = &(upperSeeds[i]); } - SimplexId vertexStarSize = triangulation->getVertexStarNumber(vertexId); + SimplexId const vertexStarSize = triangulation->getVertexStarNumber(vertexId); for(SimplexId i = 0; i < vertexStarSize; i++) { SimplexId cellId = 0; triangulation->getVertexStar(vertexId, i, cellId); - SimplexId cellSize = triangulation->getCellVertexNumber(cellId); + SimplexId const cellSize = triangulation->getCellVertexNumber(cellId); for(SimplexId j = 0; j < cellSize; j++) { SimplexId neighborId0 = -1; triangulation->getCellVertex(cellId, j, neighborId0); @@ -422,7 +424,7 @@ int ttk::ScalarFieldCriticalPoints::getLowerUpperComponents( if(neighborId0 != vertexId) { // we are on the link - bool lower0 = offsets[neighborId0] < offsets[vertexId]; + bool const lower0 = offsets[neighborId0] < offsets[vertexId]; // connect it to everybody except himself and vertexId for(SimplexId k = j + 1; k < cellSize; k++) { @@ -432,7 +434,7 @@ int ttk::ScalarFieldCriticalPoints::getLowerUpperComponents( if((neighborId1 != neighborId0) && (neighborId1 != vertexId)) { - bool lower1 = offsets[neighborId1] < offsets[vertexId]; + bool const lower1 = offsets[neighborId1] < offsets[vertexId]; std::vector *neighbors = &lowerNeighbors; std::vector *seeds = &lowerList; @@ -541,8 +543,8 @@ char ttk::ScalarFieldCriticalPoints::getCriticalType( } getLowerUpperComponents(vertexId, offsets, triangulation, isLowerOnBoundary, isUpperOnBoundary, upperComponents, lowerComponents); - ttk::SimplexId lowerComponentNumber = lowerComponents->size(); - ttk::SimplexId upperComponentNumber = upperComponents->size(); + ttk::SimplexId const lowerComponentNumber = lowerComponents->size(); + ttk::SimplexId const upperComponentNumber = upperComponents->size(); if(dimension_ == 1) { if(lowerComponentNumber == 0 && upperComponentNumber != 0) { diff --git a/core/base/scalarFieldSmoother/ScalarFieldSmoother.h b/core/base/scalarFieldSmoother/ScalarFieldSmoother.h index 1e543c0806..abff6da939 100644 --- a/core/base/scalarFieldSmoother/ScalarFieldSmoother.h +++ b/core/base/scalarFieldSmoother/ScalarFieldSmoother.h @@ -109,7 +109,7 @@ int ttk::ScalarFieldSmoother::smooth(const triangulationType *triangulation, return -4; #endif - SimplexId vertexNumber = triangulation->getNumberOfVertices(); + SimplexId const vertexNumber = triangulation->getNumberOfVertices(); std::vector tmpData(vertexNumber * dimensionNumber_, 0); diff --git a/core/base/skeleton/ThreeSkeleton.cpp b/core/base/skeleton/ThreeSkeleton.cpp index 22cb76cd2a..51e04e2214 100644 --- a/core/base/skeleton/ThreeSkeleton.cpp +++ b/core/base/skeleton/ThreeSkeleton.cpp @@ -150,9 +150,9 @@ int ThreeSkeleton::buildCellNeighborsFromVertices( // go triangle by triangle for(SimplexId j = 0; j < nbVertCell; j++) { - SimplexId v0 = cellArray.getCellVertex(cid, j); - SimplexId v1 = cellArray.getCellVertex(cid, (j + 1) % nbVertCell); - SimplexId v2 = cellArray.getCellVertex(cid, (j + 2) % nbVertCell); + SimplexId const v0 = cellArray.getCellVertex(cid, j); + SimplexId const v1 = cellArray.getCellVertex(cid, (j + 1) % nbVertCell); + SimplexId const v2 = cellArray.getCellVertex(cid, (j + 2) % nbVertCell); // perform an intersection of the 3 (sorted) star lists SimplexId pos0 = 0, pos1 = 0, pos2 = 0; diff --git a/core/base/skeleton/TwoSkeleton.cpp b/core/base/skeleton/TwoSkeleton.cpp index 7801217176..a50e7c6167 100644 --- a/core/base/skeleton/TwoSkeleton.cpp +++ b/core/base/skeleton/TwoSkeleton.cpp @@ -100,8 +100,8 @@ int TwoSkeleton::buildCellNeighborsFromVertices( for(SimplexId j = 0; j < nbVertCell; j++) { - SimplexId v0 = cellArray.getCellVertex(cid, j); - SimplexId v1 = cellArray.getCellVertex(cid, (j + 1) % nbVertCell); + SimplexId const v0 = cellArray.getCellVertex(cid, j); + SimplexId const v1 = cellArray.getCellVertex(cid, (j + 1) % nbVertCell); // perform an intersection of the 2 sorted star lists SimplexId pos0 = 0, pos1 = 0; @@ -465,7 +465,7 @@ int TwoSkeleton::buildTriangleEdgeList( std::sort(triangleEdgeList[i].begin(), triangleEdgeList[i].end()); } - SimplexId triangleNumber = localTriangleList->size(); + SimplexId const triangleNumber = localTriangleList->size(); printMsg("Built " + std::to_string(triangleNumber) + " triangle edges", 1, tm.getElapsedTime(), threadNumber_); diff --git a/core/base/topologicalCompression/PersistenceDiagramCompression.h b/core/base/topologicalCompression/PersistenceDiagramCompression.h index b54bd42a1b..f97e7297db 100644 --- a/core/base/topologicalCompression/PersistenceDiagramCompression.h +++ b/core/base/topologicalCompression/PersistenceDiagramCompression.h @@ -26,24 +26,24 @@ int ttk::TopologicalCompression::ReadPersistenceGeometry( } // Prepare array reconstruction. - int nx = 1 + dataExtent_[1] - dataExtent_[0]; - int ny = 1 + dataExtent_[3] - dataExtent_[2]; - int nz = 1 + dataExtent_[5] - dataExtent_[4]; - int vertexNumber = nx * ny * nz; + int const nx = 1 + dataExtent_[1] - dataExtent_[0]; + int const ny = 1 + dataExtent_[3] - dataExtent_[2]; + int const nz = 1 + dataExtent_[5] - dataExtent_[4]; + int const vertexNumber = nx * ny * nz; decompressedData_.resize(vertexNumber); if(ZFPTolerance < 0.0) { // 2.a. (2.) Assign values to points thanks to topology indices. for(int i = 0; i < vertexNumber; ++i) { - int seg = segmentation_[i]; + int const seg = segmentation_[i]; auto end = mapping_.end(); auto it = std::lower_bound( mapping_.begin(), mapping_.end(), std::make_tuple(0, seg), cmp); if(it != end) { std::tuple tt = *it; - double value = std::get<0>(tt); - int sseg = std::get<1>(tt); + double const value = std::get<0>(tt); + int const sseg = std::get<1>(tt); if(seg != sseg) { this->printErr("Decompression mismatch (" + std::to_string(seg) + ", " + std::to_string(sseg) + ")"); @@ -52,7 +52,7 @@ int ttk::TopologicalCompression::ReadPersistenceGeometry( } else { this->printErr("Could not find " + std::to_string(seg) + " index."); std::tuple tt = *it; - double value = std::get<0>(tt); + double const value = std::get<0>(tt); decompressedData_[i] = value; } } @@ -76,8 +76,8 @@ int ttk::TopologicalCompression::ReadPersistenceGeometry( if(SQMethodInt == 0 || SQMethodInt == 3) { for(int i = 0; i < (int)criticalConstraints_.size(); ++i) { std::tuple t = criticalConstraints_[i]; - int id = std::get<0>(t); - double val = std::get<1>(t); + int const id = std::get<0>(t); + double const val = std::get<1>(t); decompressedData_[id] = val; } } @@ -132,14 +132,14 @@ int ttk::TopologicalCompression::PerformSimplification( // Preprocess simplification. for(int i = 0; i < nbConstraints; ++i) { std::tuple t = constraints[i]; - int id = std::get<0>(t); - double val = std::get<1>(t); - int type = std::get<2>(t); + int const id = std::get<0>(t); + double const val = std::get<1>(t); + int const type = std::get<2>(t); array[id] = val; // Smoothe neighborhood (along with offsets). - SimplexId neighborNumber = triangulation.getVertexNeighborNumber(id); + SimplexId const neighborNumber = triangulation.getVertexNeighborNumber(id); for(SimplexId j = 0; j < neighborNumber; ++j) { SimplexId neighbor{-1}; triangulation.getVertexNeighbor(id, j, neighbor); @@ -194,14 +194,14 @@ void ttk::TopologicalCompression::CropIntervals( int numberOfMisses = 0; for(int i = 0; i < vertexNumber; ++i) { - int seg = segmentation[i]; + int const seg = segmentation[i]; auto end = mappings.end(); auto it = lower_bound( mappings.begin(), mappings.end(), std::make_tuple(0, seg), cmp); if(it != end) { std::tuple tt = *it; - double value = std::get<0>(tt); - int sseg = std::get<1>(tt); + double const value = std::get<0>(tt); + int const sseg = std::get<1>(tt); if(seg != sseg) { this->printErr("Decompression mismatch."); } @@ -314,8 +314,8 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( topoIndices.push_back(std::make_tuple(maxValue, maxIndex)); topoIndices.push_back(std::make_tuple(minValue, minIndex)); - double tolerance = 0.01 * tol * (maxValue - minValue); - double maxError = 0.01 * MaximumError * (maxValue - minValue); + double const tolerance = 0.01 * tol * (maxValue - minValue); + double const maxError = 0.01 * MaximumError * (maxValue - minValue); this->printMsg( "Computed min/max", 1.0, t.getElapsedTime(), this->threadNumber_); @@ -339,8 +339,8 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( this->threadNumber_); t.reStart(); - int nbJ = JTPairs.size(); - int nbS = STPairs.size(); + int const nbJ = JTPairs.size(); + int const nbS = STPairs.size(); std::vector critConstraints(2 * nbJ + 2 * nbS); dataType maxEpsilon = 0; @@ -351,17 +351,17 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( // Join for(int i = 0; i < nbJ; ++i) { - SimplexId cp1 = std::get<0>(JTPairs[i]); - SimplexId cp2 = std::get<1>(JTPairs[i]); + SimplexId const cp1 = std::get<0>(JTPairs[i]); + SimplexId const cp2 = std::get<1>(JTPairs[i]); dataType idt1 = inputData[cp1]; dataType idt2 = inputData[cp2]; dataType p1 = std::max(idt2, idt1) - std::min(idt2, idt1); if(p1 > tolerance) { persistentSum2 += (p1 * p1); persistentSum1 += abs(p1); - int type1 = topologicalSimplification.getCriticalType( + int const type1 = topologicalSimplification.getCriticalType( cp1, inputOffsets, triangulation); - int type2 = topologicalSimplification.getCriticalType( + int const type2 = topologicalSimplification.getCriticalType( cp2, inputOffsets, triangulation); if(type1 == 0) { // authorizedSaddles->push_back(cp1); @@ -391,9 +391,9 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( // Split for(int i = nbJ; i < nbJ + nbS; ++i) { - int si = i - nbJ; - SimplexId cp1 = std::get<0>(STPairs[si]); - SimplexId cp2 = std::get<1>(STPairs[si]); + int const si = i - nbJ; + SimplexId const cp1 = std::get<0>(STPairs[si]); + SimplexId const cp2 = std::get<1>(STPairs[si]); dataType idt1 = inputData[cp1]; dataType idt2 = inputData[cp2]; dataType p1 = std::max(idt2, idt1) - std::min(idt2, idt1); @@ -401,9 +401,9 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( persistentSum2 += (p1 * p1); persistentSum1 += abs(p1); // Saddle selection. - int type1 = topologicalSimplification.getCriticalType( + int const type1 = topologicalSimplification.getCriticalType( cp1, inputOffsets, triangulation); - int type2 = topologicalSimplification.getCriticalType( + int const type2 = topologicalSimplification.getCriticalType( cp2, inputOffsets, triangulation); if(type1 == 0) { // authorizedSaddles->push_back(cp1); @@ -435,7 +435,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( { int j = 0; for(int i = 0; i < 2 * nbJ + 2 * nbS; ++i) { - int c = critConstraints[i]; + int const c = critConstraints[i]; if(c != -1) simplifiedConstraints[j++] = c; } @@ -497,7 +497,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( } dataType v1 = std::get<0>(topoIndices[i + 1]); - int i1 = std::get<1>(topoIndices[i + 1]); + int const i1 = std::get<1>(topoIndices[i + 1]); auto diff = (double)(v1 - v0); if(diff == 0) @@ -506,10 +506,10 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( segments.push_back(std::make_tuple(v1, i1)); } else { // Subdivide. - double nSegments = std::ceil(diff / maxError); + double const nSegments = std::ceil(diff / maxError); for(int j = 0, nbs = (int)nSegments; j < nbs; ++j) { dataType sample = v0 + j * maxError; - int int1 = i1; + int const int1 = i1; segments.push_back(std::make_tuple(sample, int1)); } } @@ -537,8 +537,8 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( if(it != end) { std::tuple tt = *it; - int j = it - begin; - int last = (int)segments.size() - 1; + int const j = it - begin; + int const last = (int)segments.size() - 1; if(j < last) { dataType dtv = std::get<0>(tt); if(j > 0) { @@ -546,7 +546,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( } outputData[i] = dtv; - int seg = j; + int const seg = j; segmentation_[i] = seg; } else { segmentation_[i] = last; @@ -565,7 +565,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( affectedSegments.resize(segmentsSize); std::vector oob; for(int i = 0; i < vertexNumber; ++i) { - int seg = segmentation_[i]; + int const seg = segmentation_[i]; if(seg >= segmentsSize && std::find(oob.begin(), oob.end(), seg) == oob.end()) oob.push_back(seg); @@ -591,13 +591,13 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( } else { // Replace for(int i = 0; i < vertexNumber; ++i) { - int seg = segmentation_[i]; + int const seg = segmentation_[i]; if(seg >= segmentsSize) { auto begin = oob.begin(); auto end = oob.end(); auto it = std::lower_bound(begin, end, seg); if(it != end) { - int j = (int)(it - begin); + int const j = (int)(it - begin); segmentation_[i] = empty[j]; affectedSegments[j] = true; } @@ -636,7 +636,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( } for(int i = 0; i < vertexNumber; ++i) { - int seg = segmentation_[i]; + int const seg = segmentation_[i]; if(map2[seg] > 0) segmentation_[i] = map2[seg]; } @@ -653,7 +653,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( already[i] = false; // init for(int i = 0; i < vertexNumber; ++i) { - int vert = segmentation_[i]; + int const vert = segmentation_[i]; if(!already[vert]) { already[vert] = true; dataType dttt = outputData[i]; @@ -677,8 +677,8 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( if(markedVertices[i]) continue; - int seg = segmentation_[i]; - bool newSegment = markedSegments[seg]; + int const seg = segmentation_[i]; + bool const newSegment = markedSegments[seg]; dataType minNewSegment = inputData[i]; dataType maxNewSegment = minNewSegment; @@ -692,7 +692,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( while(!s.empty()) { // Get next element. - int vertex = s.top(); + int const vertex = s.top(); s.pop(); // Mark vertex as processed. @@ -711,7 +711,7 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( } // Get neighbors. - SimplexId neighborNumber + SimplexId const neighborNumber = triangulation.getVertexNeighborNumber(vertex); for(SimplexId j = 0; j < neighborNumber; ++j) { SimplexId neighbor{-1}; @@ -741,9 +741,9 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( // 7. [ZFP]: max constraints, min constraints if(!sqDomain && !sqRange && !ZFPOnly) { for(int i = 0; i < nbCrit; ++i) { - SimplexId id = simplifiedConstraints[i]; + SimplexId const id = simplifiedConstraints[i]; dataType val = inputData[id]; - int type = topologicalSimplification.getCriticalType( + int const type = topologicalSimplification.getCriticalType( id, inputOffsets, triangulation); if(type == -1 // Local_minimum || type == 1 // Local_maximum @@ -765,7 +765,8 @@ int ttk::TopologicalCompression::compressForPersistenceDiagram( + std::to_string(mapping_.size()) + ")"); } - int nSegments = indexLast > -1 ? indexLast + 1 : (int)segments.size() - 1; + int const nSegments + = indexLast > -1 ? indexLast + 1 : (int)segments.size() - 1; this->NbSegments = nSegments; this->NbVertices = vertexNumber; diff --git a/core/base/topologicalCompression/TopologicalCompression.cpp b/core/base/topologicalCompression/TopologicalCompression.cpp index a50c9b0bc0..171d5bb2b1 100644 --- a/core/base/topologicalCompression/TopologicalCompression.cpp +++ b/core/base/topologicalCompression/TopologicalCompression.cpp @@ -21,7 +21,7 @@ int ttk::TopologicalCompression::CompressWithZFP( const double zfpTolerance) const { int n1 = 0, n2 = 0; - bool is2D = nx == 1 || ny == 1 || nz == 1; + bool const is2D = nx == 1 || ny == 1 || nz == 1; if(is2D) { if(nx + ny == 2 || ny + nz == 2 || nx + nz == 2) { this->printErr("One-dimensional arrays not supported."); @@ -166,7 +166,7 @@ int ttk::TopologicalCompression::ReadCompactSegmentation( numberOfBytesRead += sizeof(int); numberOfSegments = Read(fm); - unsigned int numberOfBitsPerSegment = log2(numberOfSegments) + 1; + unsigned int const numberOfBitsPerSegment = log2(numberOfSegments) + 1; #ifndef TTK_ENABLE_KAMIKAZE // avoid left shift with negative operand @@ -221,7 +221,7 @@ int ttk::TopologicalCompression::ReadCompactSegmentation( currentSegment >>= (32 - numberOfBitsPerSegment); } - int nextSegment = currentSegment; + int const nextSegment = currentSegment; if(oldCompressedInt < 0) { oldCompressedInt &= 2147483647; @@ -266,7 +266,7 @@ int ttk::TopologicalCompression::WriteCompactSegmentation( // Compute number of bits per segment // (can be deduced at read-time from numberOfSegments) - unsigned int numberOfBitsPerSegment = log2(numberOfSegments) + 1; + unsigned int const numberOfBitsPerSegment = log2(numberOfSegments) + 1; // [MEDIUM] TODO: support long int if(numberOfBitsPerSegment > 32) @@ -298,7 +298,7 @@ int ttk::TopologicalCompression::WriteCompactSegmentation( compressedInt |= currentSegment; } else { - int cursor = (currentSegment << offset); // 0es after << + int const cursor = (currentSegment << offset); // 0es after << compressedInt |= cursor; offset += numberOfBitsPerSegment; } @@ -316,12 +316,12 @@ int ttk::TopologicalCompression::WriteCompactSegmentation( // Write current segment into last part of current container, // to be continued into next container. { - int currentSegment = segmentation[currentCell]; + int const currentSegment = segmentation[currentCell]; if(offset == 32) { // currentCell++; } else { - int cursor = (currentSegment << offset); + int const cursor = (currentSegment << offset); compressedInt = compressedInt | cursor; maskerRank = 32 - offset; @@ -421,7 +421,7 @@ int ttk::TopologicalCompression::WritePersistenceIndex( // Segmentation values for each particular index. for(int i = 0; i < mappingSize; ++i) { std::tuple t = mapping[i]; - int idv = std::get<1>(t); + int const idv = std::get<1>(t); numberOfBytesWritten += sizeof(int); Write(fm, idv); @@ -436,9 +436,9 @@ int ttk::TopologicalCompression::WritePersistenceIndex( for(int i = 0; i < nbConstraints; ++i) { std::tuple t = constraints[i]; - int idVertex = std::get<0>(t); + int const idVertex = std::get<0>(t); auto value = std::get<1>(t); - int vertexType = std::get<2>(t); + int const vertexType = std::get<2>(t); numberOfBytesWritten += sizeof(int); Write(fm, idVertex); @@ -465,8 +465,8 @@ int ttk::TopologicalCompression::ComputeTotalSizeForPersistenceDiagram( if(!zfpOnly) { // Topological segments. - int numberOfBitsPerSegment = log2(nSegments) + 1; - double nbCharPerSegment = (double)numberOfBitsPerSegment / 8.0; + int const numberOfBitsPerSegment = log2(nSegments) + 1; + double const nbCharPerSegment = (double)numberOfBitsPerSegment / 8.0; totalSize += (sizeof(int) * 2 + std::ceil(nbCharPerSegment * nVertices)); // Geometrical mapping. @@ -486,8 +486,8 @@ int ttk::TopologicalCompression::ComputeTotalSizeForPersistenceDiagram( int ttk::TopologicalCompression::WritePersistenceTopology(FILE *fm) { int numberOfBytesWritten = 0; - int numberOfVertices = getNbVertices(); - int numberOfSegments = getNbSegments(); + int const numberOfVertices = getNbVertices(); + int const numberOfSegments = getNbSegments(); // Test arguments. if(numberOfSegments < 1) @@ -526,9 +526,9 @@ int ttk::TopologicalCompression::WritePersistenceGeometry(FILE *fm, if(zfpTolerance >= 0.0) { #ifdef TTK_ENABLE_ZFP // (1. or 3.) Write zfp-compressed array. - int nx = 1 + dataExtent[1] - dataExtent[0]; - int ny = 1 + dataExtent[3] - dataExtent[2]; - int nz = 1 + dataExtent[5] - dataExtent[4]; + int const nx = 1 + dataExtent[1] - dataExtent[0]; + int const ny = 1 + dataExtent[3] - dataExtent[2]; + int const nz = 1 + dataExtent[5] - dataExtent[4]; std::vector dataVector(toCompress, toCompress + (nx * ny * nz)); numberOfBytesWritten @@ -552,7 +552,7 @@ int ttk::TopologicalCompression::ReadPersistenceTopology(FILE *fm) { int numberOfSegments; int numberOfVertices; - int numberOfBytesRead = ReadCompactSegmentation( + int const numberOfBytesRead = ReadCompactSegmentation( fm, segmentation_, numberOfVertices, numberOfSegments); this->rawFileLength += numberOfBytesRead; @@ -630,24 +630,24 @@ int ttk::TopologicalCompression::WriteToFile(FILE *fp, Write(fp, false); #endif - bool usePersistence + bool const usePersistence = compressionType == (int)ttk::CompressionType::PersistenceDiagram; - bool useOther = compressionType == (int)ttk::CompressionType::Other; + bool const useOther = compressionType == (int)ttk::CompressionType::Other; int numberOfVertices = 1; for(int i = 0; i < 3; ++i) numberOfVertices *= (1 + dataExtent[2 * i + 1] - dataExtent[2 * i]); NbVertices = numberOfVertices; - int totalSize = usePersistence ? ComputeTotalSizeForPersistenceDiagram( - getMapping(), getCriticalConstraints(), zfpOnly, - getNbSegments(), getNbVertices(), zfpTolerance) - : useOther ? ComputeTotalSizeForOther() - : 0; + int const totalSize = usePersistence ? ComputeTotalSizeForPersistenceDiagram( + getMapping(), getCriticalConstraints(), zfpOnly, + getNbSegments(), getNbVertices(), zfpTolerance) + : useOther ? ComputeTotalSizeForOther() + : 0; std::vector bbuf(totalSize); char *buf = bbuf.data(); - size_t len = (size_t)totalSize; + size_t const len = (size_t)totalSize; // #ifndef _MSC_VER // FILE *fm = fmemopen(buf, len, "r+"); @@ -678,7 +678,7 @@ int ttk::TopologicalCompression::WriteToFile(FILE *fp, fclose(fm); // !Close stream to write changes! // #ifdef _MSC_VER fm = fopen(ffn, "rb"); - int ret = fread(buf, len, sizeof(char), fm); + int const ret = fread(buf, len, sizeof(char), fm); fclose(fm); remove(ffn); // #endif @@ -757,10 +757,10 @@ int ttk::TopologicalCompression::WriteMetaData( // 0. SQ type const char *sq = sqMethod; - int sqType = (strcmp(sq, "") == 0) ? 0 - : (strcmp(sq, "r") == 0 || strcmp(sq, "R") == 0) ? 1 - : (strcmp(sq, "d") == 0 || strcmp(sq, "D") == 0) ? 2 - : 3; + int const sqType = (strcmp(sq, "") == 0) ? 0 + : (strcmp(sq, "r") == 0 || strcmp(sq, "R") == 0) ? 1 + : (strcmp(sq, "d") == 0 || strcmp(sq, "D") == 0) ? 2 + : 3; Write(fp, sqType); @@ -855,7 +855,7 @@ int ttk::TopologicalCompression::ReadMetaData(FILE *fm) { ZFPTolerance = Read(fm); // 6. Length of array name - size_t dataArrayNameLength = Read(fm); + size_t const dataArrayNameLength = Read(fm); // 7. Array name (as unsigned chars) dataArrayName_.resize(dataArrayNameLength + 1); diff --git a/core/base/topologicalCompression/TopologicalCompression.h b/core/base/topologicalCompression/TopologicalCompression.h index d76a87f46c..abb88fe604 100644 --- a/core/base/topologicalCompression/TopologicalCompression.h +++ b/core/base/topologicalCompression/TopologicalCompression.h @@ -426,9 +426,9 @@ int ttk::TopologicalCompression::execute( // if (tol < 0 || tol > 100) return -4; #endif - int vertexNumber = triangulation.getNumberOfVertices(); + int const vertexNumber = triangulation.getNumberOfVertices(); - int res = 0; + int const res = 0; if(compressionType_ == (int)ttk::CompressionType::PersistenceDiagram) compressForPersistenceDiagram(vertexNumber, inputData, inputOffsets, outputData, Tolerance, triangulation); @@ -451,7 +451,7 @@ int ttk::TopologicalCompression::ReadFromFile( return -4; } - bool useZlib = Read(fp); + bool const useZlib = Read(fp); unsigned char *dest; std::vector ddest; unsigned long destLen; diff --git a/core/base/trackingFromOverlap/TrackingFromOverlap.h b/core/base/trackingFromOverlap/TrackingFromOverlap.h index 10fc25895c..d13a9e2313 100644 --- a/core/base/trackingFromOverlap/TrackingFromOverlap.h +++ b/core/base/trackingFromOverlap/TrackingFromOverlap.h @@ -81,8 +81,8 @@ namespace ttk { } inline bool operator()(const size_t &i, const size_t &j) { - size_t ic = i * 3; - size_t jc = j * 3; + size_t const ic = i * 3; + size_t const jc = j * 3; return coordinates[ic] == coordinates[jc] ? coordinates[ic + 1] == coordinates[jc + 1] ? coordinates[ic + 2] < coordinates[jc + 2] @@ -101,7 +101,7 @@ namespace ttk { sortedIndices.resize(nPoints); for(size_t i = 0; i < nPoints; i++) sortedIndices[i] = i; - CoordinateComparator c = CoordinateComparator(pointCoordinates); + CoordinateComparator const c = CoordinateComparator(pointCoordinates); sort(sortedIndices.begin(), sortedIndices.end(), c); std::stringstream msg; @@ -116,7 +116,7 @@ namespace ttk { printMsg("Computing branches ... ", debug::Priority::PERFORMANCE); Timer tm; - size_t nT = timeNodesMap.size(); + size_t const nT = timeNodesMap.size(); // Compute max pred and succ for(size_t t = 1; t < nT; t++) { @@ -124,7 +124,7 @@ namespace ttk { auto &nodes1 = timeNodesMap[t]; auto &edges = timeEdgesMap[t - 1]; - size_t nE = edges.size(); + size_t const nE = edges.size(); for(size_t i = 0; i < nE; i += 4) { auto n0Index = edges[i]; @@ -132,9 +132,9 @@ namespace ttk { auto &n0 = nodes0[n0Index]; auto &n1 = nodes1[n1Index]; - sizeType n0MaxSuccSize + sizeType const n0MaxSuccSize = n0.maxSuccID != -1 ? nodes1[n0.maxSuccID].size : 0; - sizeType n1MaxPredSize + sizeType const n1MaxPredSize = n1.maxPredID != -1 ? nodes0[n1.maxPredID].size : 0; if(n0MaxSuccSize < n1.size) n0.maxSuccID = n1Index; @@ -168,7 +168,7 @@ namespace ttk { auto &nodes1 = timeNodesMap[t]; auto &edges = timeEdgesMap[t - 1]; - size_t nE = edges.size(); + size_t const nE = edges.size(); for(size_t i = 0; i < nE; i += 4) { auto n0Index = edges[i]; @@ -187,7 +187,7 @@ namespace ttk { auto &nodes1 = timeNodesMap[t]; auto &edges = timeEdgesMap[t - 1]; - size_t nE = edges.size(); + size_t const nE = edges.size(); for(size_t i = 0; i < nE; i += 4) { auto n0Index = edges[i]; @@ -269,7 +269,7 @@ int ttk::TrackingFromOverlap::computeNodes(const float *pointCoordinates, std::map labelIndexMap; this->computeLabelIndexMap(pointLabels, nPoints, labelIndexMap); - size_t nNodes = labelIndexMap.size(); + size_t const nNodes = labelIndexMap.size(); nodes.resize(nNodes); for(size_t i = 0, q = 0; i < nPoints; i++) { @@ -284,7 +284,7 @@ int ttk::TrackingFromOverlap::computeNodes(const float *pointCoordinates, for(size_t i = 0; i < nNodes; i++) { Node &n = nodes[i]; - float size = (float)n.size; + float const size = (float)n.size; n.x /= size; n.y /= size; n.z /= size; @@ -343,13 +343,13 @@ int ttk::TrackingFromOverlap::computeOverlap(const float *pointCoordinates0, size_t p0CoordIndex = p0 * 3; size_t p1CoordIndex = p1 * 3; - float p0_X = pointCoordinates0[p0CoordIndex++]; - float p0_Y = pointCoordinates0[p0CoordIndex++]; - float p0_Z = pointCoordinates0[p0CoordIndex]; + float const p0_X = pointCoordinates0[p0CoordIndex++]; + float const p0_Y = pointCoordinates0[p0CoordIndex++]; + float const p0_Z = pointCoordinates0[p0CoordIndex]; - float p1_X = pointCoordinates1[p1CoordIndex++]; - float p1_Y = pointCoordinates1[p1CoordIndex++]; - float p1_Z = pointCoordinates1[p1CoordIndex]; + float const p1_X = pointCoordinates1[p1CoordIndex++]; + float const p1_Y = pointCoordinates1[p1CoordIndex++]; + float const p1_Z = pointCoordinates1[p1CoordIndex]; return p0_X == p1_X ? p0_Y == p1_Y ? p0_Z == p1_Z ? 0 : p0_Z < p1_Z ? -1 @@ -367,18 +367,18 @@ int ttk::TrackingFromOverlap::computeOverlap(const float *pointCoordinates0, std::unordered_map> edgesMap; // Iterate over both point sets synchronously using comparison function while(i < nPoints0 && j < nPoints1) { - size_t pointIndex0 = sortedIndices0[i]; - size_t pointIndex1 = sortedIndices1[j]; + size_t const pointIndex0 = sortedIndices0[i]; + size_t const pointIndex1 = sortedIndices1[j]; // Determine point configuration - int c = compare(pointIndex0, pointIndex1); + int const c = compare(pointIndex0, pointIndex1); if(c == 0) { // Points have same coordinates -> track labelType label0 = pointLabels0[pointIndex0]; labelType label1 = pointLabels1[pointIndex1]; - size_t &nodeIndex0 = labelIndexMap0[label0]; - size_t &nodeIndex1 = labelIndexMap1[label1]; + size_t const &nodeIndex0 = labelIndexMap0[label0]; + size_t const &nodeIndex1 = labelIndexMap1[label1]; // Find edge and increase overlap counter auto edges0 = edgesMap.find(nodeIndex0); // Edges from label0 to nodes1 diff --git a/core/base/trackingFromPersistenceDiagrams/TrackingFromPersistenceDiagrams.cpp b/core/base/trackingFromPersistenceDiagrams/TrackingFromPersistenceDiagrams.cpp index b1035c8ea8..8dd1c1b924 100644 --- a/core/base/trackingFromPersistenceDiagrams/TrackingFromPersistenceDiagrams.cpp +++ b/core/base/trackingFromPersistenceDiagrams/TrackingFromPersistenceDiagrams.cpp @@ -96,7 +96,7 @@ int ttk::TrackingFromPersistenceDiagrams::performTracking( auto matchingsSize1 = (int)matchings1.size(); auto matchingsSize2 = (int)matchings2.size(); - int endIndex = numPersistenceDiagramsInput - 2; + int const endIndex = numPersistenceDiagramsInput - 2; for(int i = 0; i < matchingsSize1; ++i) { const auto m1ai0 = std::get<0>(matchings1[i]); @@ -112,8 +112,8 @@ int ttk::TrackingFromPersistenceDiagrams::performTracking( // Detect in trackings and push. bool found = false; for(trackingTuple &tt : trackings) { - int chainStart = std::get<0>(tt); - int chainEnd = std::get<1>(tt); + int const chainStart = std::get<0>(tt); + int const chainEnd = std::get<1>(tt); std::vector &chain = std::get<2>(tt); if(chainEnd == -1) { @@ -125,7 +125,7 @@ int ttk::TrackingFromPersistenceDiagrams::performTracking( && chain.at((unsigned long)chainSize - 1) == m1ai0) { found = true; chain.push_back(m1ai1); - int numEnd = in == endIndex ? endIndex : -1; + int const numEnd = in == endIndex ? endIndex : -1; if(in == endIndex) { chain.push_back(m2aj1); std::get<1>(tt) = numEnd; @@ -143,8 +143,8 @@ int ttk::TrackingFromPersistenceDiagrams::performTracking( if(in == endIndex) { chain.push_back(m2aj1); } - int numEnd = in == endIndex ? endIndex : -1; - trackingTuple tt = std::make_tuple(in - 1, numEnd, chain); + int const numEnd = in == endIndex ? endIndex : -1; + trackingTuple const tt = std::make_tuple(in - 1, numEnd, chain); trackings.push_back(tt); } // Create new. @@ -153,10 +153,10 @@ int ttk::TrackingFromPersistenceDiagrams::performTracking( // End non-matched chains. for(trackingTuple &tt : trackings) { - int chainStart = std::get<0>(tt); - int chainEnd = std::get<1>(tt); + int const chainStart = std::get<0>(tt); + int const chainEnd = std::get<1>(tt); if(chainEnd == -1) { - std::vector &chain = std::get<2>(tt); + std::vector const &chain = std::get<2>(tt); auto chainSize = (int)chain.size(); if(chainStart + chainSize - 1 < in) std::get<1>(tt) = in - 1; @@ -184,7 +184,7 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( // Merge close connected components with threshold. for(size_t k = 0; k < trackings.size(); ++k) { const auto &tk = trackings[k]; - int startK = std::get<0>(tk); + int const startK = std::get<0>(tk); int endK = std::get<1>(tk); if(endK < 0) endK = numPersistenceDiagramsInput - 1; @@ -201,13 +201,13 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( const auto point1Type1 = tuple1.birth.type; const auto point1Type2 = tuple1.death.type; - bool t11Min = point1Type1 == CriticalType::Local_minimum; - bool t11Max = point1Type1 == CriticalType::Local_maximum; - bool t12Min = point1Type2 == CriticalType::Local_minimum; - bool t12Max = point1Type2 == CriticalType::Local_maximum; + bool const t11Min = point1Type1 == CriticalType::Local_minimum; + bool const t11Max = point1Type1 == CriticalType::Local_maximum; + bool const t12Min = point1Type2 == CriticalType::Local_minimum; + bool const t12Max = point1Type2 == CriticalType::Local_maximum; // bool bothEx1 = t11Ex && t12Ex; - bool t1Max = t11Max || t12Max; - bool t1Min = !t1Max && (t11Min || t12Min); + bool const t1Max = t11Max || t12Max; + bool const t1Min = !t1Max && (t11Min || t12Min); x1 = t1Max ? tuple1.death.coords[0] : t1Min ? tuple1.birth.coords[0] : 0; y1 = t1Max ? tuple1.death.coords[1] : t1Min ? tuple1.birth.coords[1] : 0; @@ -215,13 +215,13 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( const auto point2Type1 = tuple2.birth.type; const auto point2Type2 = tuple2.death.type; - bool t21Min = point2Type1 == CriticalType::Local_minimum; - bool t21Max = point2Type1 == CriticalType::Local_maximum; - bool t22Min = point2Type2 == CriticalType::Local_minimum; - bool t22Max = point2Type2 == CriticalType::Local_maximum; + bool const t21Min = point2Type1 == CriticalType::Local_minimum; + bool const t21Max = point2Type1 == CriticalType::Local_maximum; + bool const t22Min = point2Type2 == CriticalType::Local_minimum; + bool const t22Max = point2Type2 == CriticalType::Local_maximum; // bool bothEx2 = t21Ex && t22Ex; - bool t2Max = t21Max || t22Max; - bool t2Min = !t2Max && (t21Min || t22Min); + bool const t2Max = t21Max || t22Max; + bool const t2Min = !t2Max && (t21Min || t22Min); // if (bothEx2) { x2 = t2Max ? tuple2.death.coords[0] : t2Min ? tuple2.birth.coords[0] : 0; @@ -238,15 +238,15 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( // Check every other tracking trajectory. for(size_t m = k + 1; m < trackings.size(); ++m) { const auto &tm = trackings[m]; - int startM = std::get<0>(tm); - int endM = std::get<1>(tm); + int const startM = std::get<0>(tm); + int const endM = std::get<1>(tm); const std::vector &chainM = std::get<2>(tm); if((endK > 0 && startM > endK) || (endM > 0 && startK > endM)) continue; for(int c = 0; c < (int)chainM.size(); ++c) { - bool doMatch1 = startM + c == startK; - bool doMatch2 = startM + c == endK; + bool const doMatch1 = startM + c == startK; + bool const doMatch2 = startM + c == endK; // if (startM + c != startK && startM + c != endK) continue; if(!doMatch1 && !doMatch2) @@ -259,15 +259,15 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( double x3, y3, z3; const auto point3Type1 = tuple3.birth.type; const auto point3Type2 = tuple3.death.type; - bool t31Min = point3Type1 == CriticalType::Local_minimum; - bool t31Max = point3Type1 == CriticalType::Local_maximum; - bool t32Min = point3Type2 == CriticalType::Local_minimum; - bool t32Max = point3Type2 == CriticalType::Local_maximum; + bool const t31Min = point3Type1 == CriticalType::Local_minimum; + bool const t31Max = point3Type1 == CriticalType::Local_maximum; + bool const t32Min = point3Type2 == CriticalType::Local_minimum; + bool const t32Max = point3Type2 == CriticalType::Local_maximum; // bool bothEx3 = t31Ex && t32Ex; // if (!bothEx3) // continue; - bool t3Max = t31Max || t32Max; - bool t3Min = !t3Max && (t31Min || t32Min); + bool const t3Max = t31Max || t32Max; + bool const t3Min = !t3Max && (t31Min || t32Min); x3 = t3Max ? tuple3.death.coords[0] : t3Min ? tuple3.birth.coords[0] @@ -283,7 +283,7 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( bool hasMatched = false; const auto square = [](const double a) { return a * a; }; if(doMatch1 && ((t3Max && t1Max) || (t3Min && t1Min))) { - double dist13 + double const dist13 = std::sqrt(square(x1 - x3) + square(y1 - y3) + square(z1 - z3)); dist = dist13; if(dist13 >= postProcThresh) @@ -292,7 +292,7 @@ int ttk::TrackingFromPersistenceDiagrams::performPostProcess( } if(doMatch2 && ((t3Max && t2Max) || (t3Min && t2Min))) { - double dist23 + double const dist23 = std::sqrt(square(x2 - x3) + square(y2 - y3) + square(z2 - z3)); dist = dist23; if(dist23 >= postProcThresh) diff --git a/core/base/uncertainDataEstimator/UncertainDataEstimator.h b/core/base/uncertainDataEstimator/UncertainDataEstimator.h index 42a72e9094..f3563953d8 100644 --- a/core/base/uncertainDataEstimator/UncertainDataEstimator.h +++ b/core/base/uncertainDataEstimator/UncertainDataEstimator.h @@ -126,7 +126,7 @@ namespace ttk { if(numberOfInputs_ == 0) { /* Initialize */ probability_.resize(numberOfBins_); - double dx + double const dx = (rangeMax_ - rangeMin_) / static_cast(numberOfBins_); for(size_t i = 0; i < static_cast(numberOfBins_); i++) { probability_[i].resize(numberOfVertices_); @@ -379,7 +379,7 @@ int ttk::UncertainDataEstimator::execute() { } // Interval between bins - double dx = (range[1] - range[0]) / (double)BinCount; + double const dx = (range[1] - range[0]) / (double)BinCount; // Bin values for(int b = 0; b < BinCount; b++) { @@ -387,7 +387,7 @@ int ttk::UncertainDataEstimator::execute() { } int idx; - double increment = 1.0 / (double)numberOfInputs_; + double const increment = 1.0 / (double)numberOfInputs_; #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for private(idx) num_threads(threadNumber_) #endif diff --git a/core/vtk/ttkAlgorithm/ttkAlgorithm.cpp b/core/vtk/ttkAlgorithm/ttkAlgorithm.cpp index 4359a16d88..2dfa7da3e1 100644 --- a/core/vtk/ttkAlgorithm/ttkAlgorithm.cpp +++ b/core/vtk/ttkAlgorithm/ttkAlgorithm.cpp @@ -382,7 +382,7 @@ int ttkAlgorithm::RequestDataObject(vtkInformation *ttkNotUsed(request), + " not specified"); return 0; } - std::string outputType + std::string const outputType = outputPortInfo->Get(vtkDataObject::DATA_TYPE_NAME()); if(outputType == "vtkUnstructuredGrid") { diff --git a/core/vtk/ttkAlgorithm/ttkTriangulationFactory.cpp b/core/vtk/ttkAlgorithm/ttkTriangulationFactory.cpp index 2dc3f1b338..30287c5914 100644 --- a/core/vtk/ttkAlgorithm/ttkTriangulationFactory.cpp +++ b/core/vtk/ttkAlgorithm/ttkTriangulationFactory.cpp @@ -221,7 +221,7 @@ RegistryTriangulation } auto triangulation = std::make_unique(); - int hasIndexArray + int const hasIndexArray = pointSet->GetPointData()->HasArray(ttk::compactTriangulationIndex); if(hasIndexArray) { @@ -255,7 +255,7 @@ RegistryTriangulation } // check if cell types are simplices - int cellTypeStatus = checkCellTypes(pointSet); + int const cellTypeStatus = checkCellTypes(pointSet); if(cellTypeStatus == -1) { this->printWrn("Inhomogeneous cell dimensions detected."); this->printWrn( @@ -268,12 +268,12 @@ RegistryTriangulation } // Cells - int nCells = cells->GetNumberOfCells(); + int const nCells = cells->GetNumberOfCells(); if(nCells > 0) { if(!cells->IsStorage64Bit()) { if(cells->CanConvertTo64BitStorage()) { this->printWrn("Converting the cell array to 64-bit storage"); - bool success = cells->ConvertTo64BitStorage(); + bool const success = cells->ConvertTo64BitStorage(); if(!success) { this->printErr( "Error converting the provided cell array to 64-bit storage"); diff --git a/core/vtk/ttkAlgorithm/ttkUtils.cpp b/core/vtk/ttkAlgorithm/ttkUtils.cpp index 3f5c67ca55..fbdf0af8a9 100644 --- a/core/vtk/ttkAlgorithm/ttkUtils.cpp +++ b/core/vtk/ttkAlgorithm/ttkUtils.cpp @@ -24,8 +24,8 @@ int ttkUtils::replaceVariable(const std::string &iString, bool varIndexDefined = false; // Check if varIndex is specified - size_t indexDelimiter0 = iString.find('['); - size_t indexDelimiter1 = iString.find(']'); + size_t const indexDelimiter0 = iString.find('['); + size_t const indexDelimiter1 = iString.find(']'); if(indexDelimiter0 != std::string::npos && indexDelimiter1 != std::string::npos) { if(indexDelimiter0 > indexDelimiter1 @@ -48,9 +48,9 @@ int ttkUtils::replaceVariable(const std::string &iString, return 0; } - size_t n = column->GetNumberOfTuples(); - size_t m = column->GetNumberOfComponents(); - int s = n * m; + size_t const n = column->GetNumberOfTuples(); + size_t const m = column->GetNumberOfComponents(); + int const s = n * m; if(!varIndexDefined) { if(s > 0) { @@ -79,7 +79,7 @@ int ttkUtils::replaceVariables(const std::string &iString, while(oString.find('{') != std::string::npos && oString.find('}') != std::string::npos) { size_t o = oString.find('{'); - size_t c = oString.find('}'); + size_t const c = oString.find('}'); // {...{....{...}...}..} // | | // o c @@ -93,7 +93,7 @@ int ttkUtils::replaceVariables(const std::string &iString, // {...{....{var}...}..} // | | // o c - std::string var = oString.substr(o + 1, c - 1 - o); + std::string const var = oString.substr(o + 1, c - 1 - o); std::string rVar; if(!replaceVariable(var, fieldData, rVar, errorMsg)) @@ -136,7 +136,7 @@ int ttkUtils::stringListToDoubleVector(const std::string &iString, if(!ttkUtils::stringListToVector(iString, stringVector)) return 0; - size_t n = stringVector.size(); + size_t const n = stringVector.size(); v.resize(n); // try { for(size_t i = 0; i < n; i++) @@ -150,17 +150,17 @@ int ttkUtils::stringListToDoubleVector(const std::string &iString, vtkSmartPointer ttkUtils::csvToVtkArray(const std::string &line) { - size_t firstComma = line.find(',', 0); + size_t const firstComma = line.find(',', 0); if(firstComma == std::string::npos) return nullptr; - std::string arrayName = line.substr(0, firstComma); + std::string const arrayName = line.substr(0, firstComma); std::vector valuesAsString; stringListToVector( line.substr(firstComma + 1, std::string::npos), valuesAsString); - size_t nValues = valuesAsString.size(); + size_t const nValues = valuesAsString.size(); if(nValues < 1) return nullptr; @@ -196,17 +196,18 @@ vtkSmartPointer vtkSmartPointer ttkUtils::csvToDoubleArray(const std::string &line) { - size_t firstComma = line.find(',', 0); + size_t const firstComma = line.find(',', 0); if(firstComma == std::string::npos) return nullptr; - std::string arrayName = line.substr(0, firstComma); - std::string valuesAsString = line.substr(firstComma + 1, std::string::npos); + std::string const arrayName = line.substr(0, firstComma); + std::string const valuesAsString + = line.substr(firstComma + 1, std::string::npos); std::vector values; ttkUtils::stringListToDoubleVector(valuesAsString, values); - size_t n = values.size(); + size_t const n = values.size(); auto array = vtkSmartPointer::New(); array->SetName(arrayName.data()); diff --git a/core/vtk/ttkArrayEditor/ttkArrayEditor.cpp b/core/vtk/ttkArrayEditor/ttkArrayEditor.cpp index d397b6f7aa..77c103538d 100644 --- a/core/vtk/ttkArrayEditor/ttkArrayEditor.cpp +++ b/core/vtk/ttkArrayEditor/ttkArrayEditor.cpp @@ -80,7 +80,7 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - std::string associationNames[3] = {"point", "cell", "field"}; + std::string const associationNames[3] = {"point", "cell", "field"}; // Pass Input to Output auto target = vtkDataObject::GetData(inputVector[0], 0); @@ -99,7 +99,7 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), if(this->DataString.length() > 0) { // get target attribute - int targetAssociation + int const targetAssociation = this->TargetAssociation < 0 ? 2 : this->TargetAssociation; auto outputAtt = output->GetAttributesAsFieldData(targetAssociation); if(!outputAtt) { @@ -118,7 +118,7 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), if(!ttkUtils::replaceVariables(this->DataString, output->GetFieldData(), finalExpressionString, errorMsg)) { - std::stringstream msg; + std::stringstream const msg; this->printErr(errorMsg); return 0; } @@ -172,7 +172,7 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), continue; // get target attribute - int targetAssociation + int const targetAssociation = this->TargetAssociation < 0 ? association : this->TargetAssociation; auto outputAtt = output->GetAttributesAsFieldData(targetAssociation); if(!outputAtt) { @@ -203,7 +203,7 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), if(!targetArray) return !this->printErr("Unable to retrieve input array."); - int targetArrayAssociation + int const targetArrayAssociation = this->GetInputArrayAssociation(0, inputVector); this->printMsg("Editing '" + std::string(targetArray->GetName()) + "' " @@ -220,19 +220,19 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), this->TargetArrayType < 0 ? targetArray->GetDataType() : this->TargetArrayType)); - size_t nComponents = this->TargetArrayIndexation[1] >= 0 - ? this->TargetArrayIndexation[1] - : this->TargetArrayIndexation[0] >= 0 - ? targetArray->GetNumberOfValues() - / this->TargetArrayIndexation[0] - : targetArray->GetNumberOfComponents(); - - size_t nTuples = this->TargetArrayIndexation[0] >= 0 - ? this->TargetArrayIndexation[0] - : this->TargetArrayIndexation[1] >= 0 - ? targetArray->GetNumberOfValues() - / this->TargetArrayIndexation[1] - : targetArray->GetNumberOfTuples(); + size_t const nComponents = this->TargetArrayIndexation[1] >= 0 + ? this->TargetArrayIndexation[1] + : this->TargetArrayIndexation[0] >= 0 + ? targetArray->GetNumberOfValues() + / this->TargetArrayIndexation[0] + : targetArray->GetNumberOfComponents(); + + size_t const nTuples = this->TargetArrayIndexation[0] >= 0 + ? this->TargetArrayIndexation[0] + : this->TargetArrayIndexation[1] >= 0 + ? targetArray->GetNumberOfValues() + / this->TargetArrayIndexation[1] + : targetArray->GetNumberOfTuples(); copy->Allocate(nTuples * nComponents); copy->SetNumberOfComponents(nComponents); copy->SetNumberOfTuples(nTuples); @@ -250,9 +250,9 @@ int ttkArrayEditor::RequestData(vtkInformation *ttkNotUsed(request), : this->TargetArrayName.data()); // get target attribute - int targetAssociation = this->TargetAssociation < 0 - ? targetArrayAssociation - : this->TargetAssociation; + int const targetAssociation = this->TargetAssociation < 0 + ? targetArrayAssociation + : this->TargetAssociation; auto outputAtt = output->GetAttributesAsFieldData(targetAssociation); if(!outputAtt) { this->printErr("Target does not have requested attribute type."); diff --git a/core/vtk/ttkArrayPreconditioning/ttkArrayPreconditioning.cpp b/core/vtk/ttkArrayPreconditioning/ttkArrayPreconditioning.cpp index 5fa6b34095..a87744705c 100644 --- a/core/vtk/ttkArrayPreconditioning/ttkArrayPreconditioning.cpp +++ b/core/vtk/ttkArrayPreconditioning/ttkArrayPreconditioning.cpp @@ -51,7 +51,7 @@ int ttkArrayPreconditioning::RequestData(vtkInformation *ttkNotUsed(request), auto output = vtkDataSet::GetData(outputVector); ttk::Timer tm{}; - int keepGoing = checkEmptyMPIInput(input); + int const keepGoing = checkEmptyMPIInput(input); if(keepGoing < 2) { return keepGoing; } @@ -61,7 +61,7 @@ int ttkArrayPreconditioning::RequestData(vtkInformation *ttkNotUsed(request), output->ShallowCopy(input); auto pointData = input->GetPointData(); - size_t nVertices = input->GetNumberOfPoints(); + size_t const nVertices = input->GetNumberOfPoints(); std::vector scalarArrays{}; diff --git a/core/vtk/ttkBlockAggregator/ttkBlockAggregator.cpp b/core/vtk/ttkBlockAggregator/ttkBlockAggregator.cpp index 1b2bec53f4..e3f49b16d9 100644 --- a/core/vtk/ttkBlockAggregator/ttkBlockAggregator.cpp +++ b/core/vtk/ttkBlockAggregator/ttkBlockAggregator.cpp @@ -81,7 +81,7 @@ static int copyObjects(vtkDataObject *source, vtkDataObject *copy) { int ttkBlockAggregator::AggregateBlock(vtkDataObject *dataObject) { ttk::Timer t; - size_t nBlocks = this->AggregatedMultiBlockDataSet->GetNumberOfBlocks(); + size_t const nBlocks = this->AggregatedMultiBlockDataSet->GetNumberOfBlocks(); this->printMsg("Adding object add index " + std::to_string(nBlocks), 0, ttk::debug::LineMode::REPLACE); @@ -115,7 +115,7 @@ int ttkBlockAggregator::RequestData(vtkInformation *ttkNotUsed(request), this->Reset(); // Add all inputs - size_t nInputs = inputVector[0]->GetNumberOfInformationObjects(); + size_t const nInputs = inputVector[0]->GetNumberOfInformationObjects(); for(size_t i = 0; i < nInputs; i++) { auto input = vtkDataObject::GetData(inputVector[0], i); diff --git a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomCamera.cpp b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomCamera.cpp index 3bde67d898..411608f5bf 100644 --- a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomCamera.cpp +++ b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomCamera.cpp @@ -44,7 +44,7 @@ int ttkCinemaDarkroomCamera::SyncWithParaViewCamera() { this->printMsg( "Updating Camera Parameters", 0, 0, 1, ttk::debug::LineMode::REPLACE); - std::string code(R"( + std::string const code(R"( from paraview.simple import GetActiveView from paraview.simple import FindSource diff --git a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomColorMapping.cpp b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomColorMapping.cpp index 92ba4a788a..5d072adf39 100644 --- a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomColorMapping.cpp +++ b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomColorMapping.cpp @@ -41,7 +41,7 @@ int mapScalarsToColor(unsigned char *color, const double value = (double)array[i]; if(std::isnan(value)) { - size_t idx = i * 3; + size_t const idx = i * 3; color[idx + 0] = 255.0 * nanColor[0]; color[idx + 1] = 255.0 * nanColor[1]; color[idx + 2] = 255.0 * nanColor[2]; @@ -59,12 +59,12 @@ int mapScalarsToColor(unsigned char *color, } } - double lambda = (normalizedValue - colorMap[ki * 4]) - / (colorMap[(ki + 1) * 4] - colorMap[ki * 4]); - double lambdaInv = 1 - lambda; + double const lambda = (normalizedValue - colorMap[ki * 4]) + / (colorMap[(ki + 1) * 4] - colorMap[ki * 4]); + double const lambdaInv = 1 - lambda; - size_t idx = i * 3; - size_t idx2 = ki * 4; + size_t const idx = i * 3; + size_t const idx2 = ki * 4; color[idx + 0] = 255.0 * (lambdaInv * colorMap[idx2 + 1] + lambda * colorMap[idx2 + 5]); color[idx + 1] @@ -97,7 +97,7 @@ int ttkCinemaDarkroomColorMapping::RequestData( return 0; } - size_t nPixels = scalarArray->GetNumberOfTuples(); + size_t const nPixels = scalarArray->GetNumberOfTuples(); double range[2]; scalarArray->GetRange(range); @@ -125,7 +125,7 @@ int ttkCinemaDarkroomColorMapping::RequestData( manualColorMap[7] = this->SingleColor[2]; colorMap = &manualColorMap; } else if(this->ColorMap == -2) { - int status = ttkUtils::stringListToDoubleVector( + int const status = ttkUtils::stringListToDoubleVector( this->ManualColorMap, manualColorMap); if(!status || manualColorMap.size() < 8 || manualColorMap.size() % 4 != 0) { this->printErr("Invalid manual color map input."); diff --git a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomNoise.cpp b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomNoise.cpp index 87c616de48..78fca787d8 100644 --- a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomNoise.cpp +++ b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomNoise.cpp @@ -22,7 +22,7 @@ int ttkCinemaDarkroomNoise::RequestData(vtkInformation *ttkNotUsed(request), auto outputImage = vtkImageData::GetData(outputVector); outputImage->ShallowCopy(inputImage); - size_t nPoints = outputImage->GetNumberOfPoints(); + size_t const nPoints = outputImage->GetNumberOfPoints(); auto noise = vtkSmartPointer::New(); noise->SetName("Noise"); @@ -32,7 +32,7 @@ int ttkCinemaDarkroomNoise::RequestData(vtkInformation *ttkNotUsed(request), int dim[3]; outputImage->GetDimensions(dim); - ttk::Timer timer; + ttk::Timer const timer; const std::string msg = "Computing Noise (" + std::to_string(dim[0]) + "x" + std::to_string(dim[1]) + "x" + std::to_string(dim[2]) + ")"; diff --git a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomShader.cpp b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomShader.cpp index 929d8944f4..fa4b55f76d 100644 --- a/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomShader.cpp +++ b/core/vtk/ttkCinemaDarkroom/ttkCinemaDarkroomShader.cpp @@ -202,7 +202,7 @@ int ttkCinemaDarkroomShader::AddTexture(vtkImageData *image, return 0; } - std::string textureName = "tex" + std::to_string(textureIdx); + std::string const textureName = "tex" + std::to_string(textureIdx); auto properties = this->FullScreenQuadActor->GetProperty(); // if texture already exists remove it diff --git a/core/vtk/ttkCinemaImaging/ttkCinemaImaging.cpp b/core/vtk/ttkCinemaImaging/ttkCinemaImaging.cpp index 9e23ce30f7..ee9dc0cc10 100644 --- a/core/vtk/ttkCinemaImaging/ttkCinemaImaging.cpp +++ b/core/vtk/ttkCinemaImaging/ttkCinemaImaging.cpp @@ -78,7 +78,7 @@ int ttkCinemaImaging::RequestData(vtkInformation *ttkNotUsed(request), this->FocalPoint[0], this->FocalPoint[1], this->FocalPoint[2]}; std::vector defaultNearFar{this->NearFar[0], this->NearFar[1]}; double defaultHeight = this->Height; - double defaultAngle = this->Angle; + double const defaultAngle = this->Angle; if(this->AutoFocalPoint || this->AutoNearFar || this->AutoHeight) { @@ -128,7 +128,7 @@ int ttkCinemaImaging::RequestData(vtkInformation *ttkNotUsed(request), auto aInputGrid = vtkSmartPointer::Take(inputGrid->NewInstance()); aInputGrid->ShallowCopy(inputGrid); - int n = aInputGrid->GetNumberOfPoints(); + int const n = aInputGrid->GetNumberOfPoints(); auto aInputGridPD = aInputGrid->GetPointData(); ttkCinemaImaging::EnsureGridData( @@ -212,13 +212,13 @@ int ttkCinemaImaging::RequestDataSingle( const std::vector &ttkNotUsed(defaultNearFar), const double ttkNotUsed(defaultHeight), const double ttkNotUsed(defaultAngle)) { - ttk::Timer globalTimer; + ttk::Timer const globalTimer; auto cells = ttkCinemaImaging::GetCells(inputObject); if(!cells) return 0; - size_t nTriangles = cells->GetNumberOfCells(); + size_t const nTriangles = cells->GetNumberOfCells(); // make sure that cells consists only of triangles { auto offsets = static_cast( @@ -273,7 +273,7 @@ int ttkCinemaImaging::AddFieldDataArray(vtkFieldData *fd, if(!array) return 0; - size_t nComponents = array->GetNumberOfComponents(); + size_t const nComponents = array->GetNumberOfComponents(); auto newArray = vtkSmartPointer::New(); newArray->SetName(name.empty() ? array->GetName() : name.data()); @@ -316,7 +316,7 @@ int ttkCinemaImaging::ComputeDirFromFocalPoint(vtkPointSet *inputGrid) { auto focal = static_cast(ttkUtils::GetVoidPointer( inputGrid->GetPointData()->GetArray("CamFocalPoint"))); - int nTuples = inputGrid->GetNumberOfPoints(); + int const nTuples = inputGrid->GetNumberOfPoints(); auto newArray = vtkSmartPointer::New(); newArray->SetName("CamDirection"); @@ -340,7 +340,7 @@ int ttkCinemaImaging::EnsureGridData(vtkPointData *fd, auto array = vtkDoubleArray::SafeDownCast(fd->GetArray(name.data())); if(!array) { - int nComponents = defaultValues.size(); + int const nComponents = defaultValues.size(); auto newArray = vtkSmartPointer::New(); newArray->SetName(name.data()); @@ -403,7 +403,7 @@ int ttkCinemaImaging::MapPointAndCellData( auto outputImagePD = outputImage->GetPointData(); int dim[3]; outputImage->GetDimensions(dim); - size_t nPixels = dim[0] * dim[1]; + size_t const nPixels = dim[0] * dim[1]; const size_t nInputObjectPDArrays = inputObjectPD->GetNumberOfArrays(); const size_t nInputObjectCDArrays = inputObjectCD->GetNumberOfArrays(); diff --git a/core/vtk/ttkCinemaImaging/ttkCinemaImagingEmbree.cpp b/core/vtk/ttkCinemaImaging/ttkCinemaImagingEmbree.cpp index 86b76a8c3c..680e9d327a 100644 --- a/core/vtk/ttkCinemaImaging/ttkCinemaImagingEmbree.cpp +++ b/core/vtk/ttkCinemaImaging/ttkCinemaImagingEmbree.cpp @@ -55,7 +55,7 @@ int ttk::ttkCinemaImagingEmbree::RenderVTKObject( this->printMsg(ttk::debug::Separator::L2); float *samplingPositions = static_cast(ttkUtils::GetVoidPointer(inputGrid->GetPoints())); - int nSamplingPositions = inputGrid->GetNumberOfPoints(); + int const nSamplingPositions = inputGrid->GetNumberOfPoints(); auto camParameters = inputGrid->GetPointData(); auto camUp = static_cast( ttkUtils::GetVoidPointer(camParameters->GetArray("CamUp"))); @@ -84,7 +84,7 @@ int ttk::ttkCinemaImagingEmbree::RenderVTKObject( outputImage->SetOrigin(0, 0, 0); outputImage->AllocateScalars(VTK_FLOAT, 1); - size_t nPixels = resolution[i * 2] * resolution[i * 2 + 1]; + size_t const nPixels = resolution[i * 2] * resolution[i * 2 + 1]; auto outputImagePD = outputImage->GetPointData(); auto depthBuffer = outputImagePD->GetArray(0); diff --git a/core/vtk/ttkCinemaImaging/ttkCinemaImagingNative.cpp b/core/vtk/ttkCinemaImaging/ttkCinemaImagingNative.cpp index ad3eb9eb0e..fac165500a 100644 --- a/core/vtk/ttkCinemaImaging/ttkCinemaImagingNative.cpp +++ b/core/vtk/ttkCinemaImaging/ttkCinemaImagingNative.cpp @@ -38,7 +38,7 @@ int ttk::ttkCinemaImagingNative::RenderVTKObject( this->printMsg(ttk::debug::Separator::L2); float *samplingPositions = static_cast(ttkUtils::GetVoidPointer(inputGrid->GetPoints())); - int nSamplingPositions = inputGrid->GetNumberOfPoints(); + int const nSamplingPositions = inputGrid->GetNumberOfPoints(); auto camParameters = inputGrid->GetPointData(); auto camUp = static_cast( ttkUtils::GetVoidPointer(camParameters->GetArray("CamUp"))); @@ -59,7 +59,7 @@ int ttk::ttkCinemaImagingNative::RenderVTKObject( ttkUtils::GetVoidPointer(inputObjectCells->GetConnectivityArray())); ttk::Timer test; - BoundingVolumeHierarchy bvh( + BoundingVolumeHierarchy const bvh( static_cast(ttkUtils::GetVoidPointer(inputObject->GetPoints())), inputObjectConnectivityList, inputObjectCells->GetNumberOfCells()); @@ -77,7 +77,7 @@ int ttk::ttkCinemaImagingNative::RenderVTKObject( outputImage->SetOrigin(0, 0, 0); outputImage->AllocateScalars(VTK_FLOAT, 1); - size_t nPixels = resolution[i * 2] * resolution[i * 2 + 1]; + size_t const nPixels = resolution[i * 2] * resolution[i * 2 + 1]; auto outputImagePD = outputImage->GetPointData(); auto depthBuffer = outputImagePD->GetArray(0); diff --git a/core/vtk/ttkCinemaImaging/ttkCinemaImagingVTK.cpp b/core/vtk/ttkCinemaImaging/ttkCinemaImagingVTK.cpp index 0793cd69b4..0efa6eeb0f 100644 --- a/core/vtk/ttkCinemaImaging/ttkCinemaImagingVTK.cpp +++ b/core/vtk/ttkCinemaImaging/ttkCinemaImagingVTK.cpp @@ -74,12 +74,12 @@ int ttk::ttkCinemaImagingVTK::addValuePass( if(!array) continue; - std::string name(array->GetName()); + std::string const name(array->GetName()); double minmax[2]; array->GetRange(minmax); - size_t nComponents = array->GetNumberOfComponents(); + size_t const nComponents = array->GetNumberOfComponents(); for(size_t c = 0; c < nComponents; c++) { auto valuePass = vtkSmartPointer::New(); valuePass->SetInputArrayToProcess(fieldType == 0 @@ -121,7 +121,7 @@ int ttk::ttkCinemaImagingVTK::RenderVTKObject( this->printMsg(ttk::debug::Separator::L2); float *samplingPositions = static_cast(ttkUtils::GetVoidPointer(inputGrid->GetPoints())); - int nSamplingPositions = inputGrid->GetNumberOfPoints(); + int const nSamplingPositions = inputGrid->GetNumberOfPoints(); auto camParameters = inputGrid->GetPointData(); auto camUp = static_cast( ttkUtils::GetVoidPointer(camParameters->GetArray("CamUp"))); @@ -177,7 +177,7 @@ int ttk::ttkCinemaImagingVTK::RenderVTKObject( auto cd = object->GetCellData(); if(pd->GetNumberOfArrays() < 1 && cd->GetNumberOfArrays() > 0) { - size_t nP = object->GetNumberOfPoints(); + size_t const nP = object->GetNumberOfPoints(); auto fakeArray = vtkSmartPointer::New(); fakeArray->SetName("Fake"); @@ -214,8 +214,8 @@ int ttk::ttkCinemaImagingVTK::RenderVTKObject( for(int i = 0; i < nSamplingPositions; i++) { ttk::Timer timer; - int resX = resolution[i * 2]; - int resY = resolution[i * 2 + 1]; + int const resX = resolution[i * 2]; + int const resY = resolution[i * 2 + 1]; this->printMsg("Rendering Image (" + std::string(projectionMode[i] ? "P" : "O") + "|" diff --git a/core/vtk/ttkCinemaProductReader/ttkCinemaProductReader.cpp b/core/vtk/ttkCinemaProductReader/ttkCinemaProductReader.cpp index d83f6c84de..a1bac54a82 100644 --- a/core/vtk/ttkCinemaProductReader/ttkCinemaProductReader.cpp +++ b/core/vtk/ttkCinemaProductReader/ttkCinemaProductReader.cpp @@ -68,8 +68,8 @@ vtkSmartPointer std::ifstream is(pathToFile.data()); char prefix[10] = ""; is.get(prefix, 10); - bool isXML = std::string(prefix).compare("GetNumberOfRows(); - size_t m = inputTable->GetNumberOfColumns(); + size_t const n = inputTable->GetNumberOfRows(); + size_t const m = inputTable->GetNumberOfColumns(); // Determine number of files this->printMsg( {{"#Files", std::to_string(n)}, {"FILE Column", this->FilepathColumnName}}); @@ -141,8 +141,8 @@ int ttkCinemaProductReader::RequestData(vtkInformation *ttkNotUsed(request), // read local file { - std::ifstream infile(path.data()); - bool exists = infile.good(); + std::ifstream const infile(path.data()); + bool const exists = infile.good(); if(!exists) { this->printErr("File does not exist."); return 0; diff --git a/core/vtk/ttkCinemaQuery/ttkCinemaQuery.cpp b/core/vtk/ttkCinemaQuery/ttkCinemaQuery.cpp index ca6d7ab9b8..5537a28eb0 100644 --- a/core/vtk/ttkCinemaQuery/ttkCinemaQuery.cpp +++ b/core/vtk/ttkCinemaQuery/ttkCinemaQuery.cpp @@ -73,8 +73,8 @@ int ttkCinemaQuery::RequestData(vtkInformation *ttkNotUsed(request), for(int i = 0; i < nTables; i++) { auto inTable = inTables[i]; - size_t nc = inTable->GetNumberOfColumns(); - size_t nr = inTable->GetNumberOfRows(); + size_t const nc = inTable->GetNumberOfColumns(); + size_t const nr = inTable->GetNumberOfRows(); std::vector isNumeric(nc); std::vector includeColumns(nc); @@ -217,7 +217,7 @@ int ttkCinemaQuery::RequestData(vtkInformation *ttkNotUsed(request), int csvNColumns = 0; int csvNRows = 0; - int status + int const status = this->execute(sqlTableDefinitions, sqlInsertStatements, finalQueryString, csvResult, csvNColumns, csvNRows); @@ -251,7 +251,7 @@ int ttkCinemaQuery::RequestData(vtkInformation *ttkNotUsed(request), continue; auto inFD = inTable->GetFieldData(); - size_t n = inFD->GetNumberOfArrays(); + size_t const n = inFD->GetNumberOfArrays(); for(size_t i = 0; i < n; i++) { auto iArray = inFD->GetAbstractArray(i); if(!outFD->GetAbstractArray(iArray->GetName())) { diff --git a/core/vtk/ttkCinemaReader/ttkCinemaReader.cpp b/core/vtk/ttkCinemaReader/ttkCinemaReader.cpp index fdd5574d39..8885a89336 100644 --- a/core/vtk/ttkCinemaReader/ttkCinemaReader.cpp +++ b/core/vtk/ttkCinemaReader/ttkCinemaReader.cpp @@ -86,7 +86,7 @@ int ttkCinemaReader::RequestData(vtkInformation *ttkNotUsed(request), auto filepathColumn = vtkStringArray::SafeDownCast( outTable->GetColumnByName(filePathColumnNames[j].data())); if(filepathColumn) { - size_t n = filepathColumn->GetNumberOfValues(); + size_t const n = filepathColumn->GetNumberOfValues(); for(size_t i = 0; i < n; i++) filepathColumn->SetValue( i, this->GetDatabasePath() + "/" + filepathColumn->GetValue(i)); diff --git a/core/vtk/ttkCinemaWriter/ttkCinemaWriter.cpp b/core/vtk/ttkCinemaWriter/ttkCinemaWriter.cpp index 91f1bc87f3..d066d2888f 100644 --- a/core/vtk/ttkCinemaWriter/ttkCinemaWriter.cpp +++ b/core/vtk/ttkCinemaWriter/ttkCinemaWriter.cpp @@ -87,7 +87,7 @@ int ttkCinemaWriter::DeleteDatabase() { this->Modified(); if(this->ValidateDatabasePath() == 0) return 0; - int status = vtkDirectory::DeleteDirectory(this->DatabasePath.data()); + int const status = vtkDirectory::DeleteDirectory(this->DatabasePath.data()); this->printMsg("Deleting CDB: " + this->DatabasePath, 1, t.getElapsedTime()); @@ -139,10 +139,10 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { if(compressor != nullptr) compressor->SetCompressionLevel(this->CompressionLevel); - std::string productExtension = this->Format == FORMAT::VTK - ? xmlWriter->GetDefaultFileExtension() - : this->Format == FORMAT::PNG ? "png" - : "ttk"; + std::string const productExtension = this->Format == FORMAT::VTK + ? xmlWriter->GetDefaultFileExtension() + : this->Format == FORMAT::PNG ? "png" + : "ttk"; // ------------------------------------------------------------------------- // Prepare Field Data @@ -162,7 +162,7 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { // remove temporary columns for(size_t i = 0; i < nFields; i++) { - std::string name(inputFD->GetArrayName(i)); + std::string const name(inputFD->GetArrayName(i)); if(name.substr(0, 4).compare("_ttk") == 0) toIgnore.emplace_back(name); } @@ -243,7 +243,7 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { } catch(boost::interprocess::interprocess_exception &) { } - std::string csvPath = this->DatabasePath + "/data.csv"; + std::string const csvPath = this->DatabasePath + "/data.csv"; struct stat info; // ------------------------------------------------------------------------- @@ -310,8 +310,8 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { // check CSV file integrity std::vector fieldToCSVColumnMap(nFields); - size_t nRows = csvTable->GetNumberOfRows(); - size_t nColumns = csvTable->GetNumberOfColumns(); + size_t const nRows = csvTable->GetNumberOfRows(); + size_t const nColumns = csvTable->GetNumberOfColumns(); { // Check If CSV file is empty if(nColumns == 0) { @@ -322,7 +322,7 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { // Check If CSV file contains columns not present in fields for(size_t i = 0; i < nColumns; i++) { - std::string columnName = csvTable->GetColumnName(i); + std::string const columnName = csvTable->GetColumnName(i); // skip FILE column if(columnName.compare("FILE") == 0) @@ -406,7 +406,7 @@ int ttkCinemaWriter::ProcessDataProduct(vtkDataObject *input) { this->printMsg("Updating data.csv file", 0, ttk::debug::LineMode::REPLACE, ttk::debug::Priority::DETAIL); - size_t rowIndex = csvTable->GetNumberOfRows(); + size_t const rowIndex = csvTable->GetNumberOfRows(); csvTable->InsertNextBlankRow(); for(size_t j = 0; j < nFields; j++) @@ -585,7 +585,7 @@ int ttkCinemaWriter::RequestData(vtkInformation *ttkNotUsed(request), auto inputAsMB = vtkMultiBlockDataSet::SafeDownCast(input); if(this->IterateMultiBlock && inputAsMB) { - size_t n = inputAsMB->GetNumberOfBlocks(); + size_t const n = inputAsMB->GetNumberOfBlocks(); for(size_t i = 0; i < n; i++) if(!this->ProcessDataProduct(inputAsMB->GetBlock(i))) return 0; diff --git a/core/vtk/ttkClusteringMetrics/ttkClusteringMetrics.cpp b/core/vtk/ttkClusteringMetrics/ttkClusteringMetrics.cpp index 530c494167..ded1ac80c3 100644 --- a/core/vtk/ttkClusteringMetrics/ttkClusteringMetrics.cpp +++ b/core/vtk/ttkClusteringMetrics/ttkClusteringMetrics.cpp @@ -83,14 +83,14 @@ int ttkClusteringMetrics::RequestData(vtkInformation *ttkNotUsed(request), this->printMsg(" Second clustering column: " + std::string(intArray2->GetName())); - size_t nbVal1 = inputClustering1->GetNumberOfTuples(); - size_t nbVal2 = inputClustering2->GetNumberOfTuples(); + size_t const nbVal1 = inputClustering1->GetNumberOfTuples(); + size_t const nbVal2 = inputClustering2->GetNumberOfTuples(); if(nbVal1 != nbVal2) { this->printMsg("Error : the two clusterings must have the same size\n"); return 0; } - size_t nbVal = nbVal1; + size_t const nbVal = nbVal1; double nmiValue = 0, ariValue = 0; this->execute(values1, values2, nbVal, nmiValue, ariValue); diff --git a/core/vtk/ttkComponentSize/ttkComponentSize.cpp b/core/vtk/ttkComponentSize/ttkComponentSize.cpp index ccde7b8a3d..bbc59cf23b 100644 --- a/core/vtk/ttkComponentSize/ttkComponentSize.cpp +++ b/core/vtk/ttkComponentSize/ttkComponentSize.cpp @@ -43,7 +43,7 @@ int ttkComponentSize::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { ttk::Timer t; - size_t threadNumber = this->getThreadNumber(); + size_t const threadNumber = this->getThreadNumber(); this->printMsg( "Computing connected components", 0, 0, ttk::debug::LineMode::REPLACE); @@ -54,7 +54,7 @@ int ttkComponentSize::RequestData(vtkInformation *ttkNotUsed(request), connectivityFilter->ColorRegionsOn(); connectivityFilter->Update(); - size_t nRegions = connectivityFilter->GetNumberOfExtractedRegions(); + size_t const nRegions = connectivityFilter->GetNumberOfExtractedRegions(); if(nRegions < 1) { this->printErr("Unable to compute connected components."); return 0; @@ -71,8 +71,8 @@ int ttkComponentSize::RequestData(vtkInformation *ttkNotUsed(request), auto output = vtkDataSet::GetData(outputVector); output->ShallowCopy(connectivityFilter->GetOutput()); - size_t nVertices = output->GetNumberOfPoints(); - size_t nCells = output->GetNumberOfCells(); + size_t const nVertices = output->GetNumberOfPoints(); + size_t const nCells = output->GetNumberOfCells(); auto vertexIds = (vtkIdType *)ttkUtils::GetVoidPointer( output->GetPointData()->GetArray("RegionId")); diff --git a/core/vtk/ttkContinuousScatterPlot/ttkContinuousScatterPlot.cpp b/core/vtk/ttkContinuousScatterPlot/ttkContinuousScatterPlot.cpp index b2ce6aaae2..e96d03e30e 100644 --- a/core/vtk/ttkContinuousScatterPlot/ttkContinuousScatterPlot.cpp +++ b/core/vtk/ttkContinuousScatterPlot/ttkContinuousScatterPlot.cpp @@ -77,7 +77,7 @@ int ttkContinuousScatterPlot::RequestData(vtkInformation *ttkNotUsed(request), } #endif - SimplexId numberOfPixels + SimplexId const numberOfPixels = ScatterplotResolution[0] * ScatterplotResolution[1]; #ifndef TTK_ENABLE_KAMIKAZE // no pixels @@ -94,7 +94,7 @@ int ttkContinuousScatterPlot::RequestData(vtkInformation *ttkNotUsed(request), validPointMask[k].resize(ScatterplotResolution[1], 0); } - SimplexId numberOfPoints = input->GetNumberOfPoints(); + SimplexId const numberOfPoints = input->GetNumberOfPoints(); #ifndef TTK_ENABLE_KAMIKAZE // no points if(numberOfPoints < 1) { @@ -106,8 +106,8 @@ int ttkContinuousScatterPlot::RequestData(vtkInformation *ttkNotUsed(request), std::array scalarMin{0, 0}; std::array scalarMax{0, 0}; for(SimplexId k = 0; k < numberOfPoints; ++k) { - double d1 = inputScalars1->GetTuple1(k); - double d2 = inputScalars2->GetTuple1(k); + double const d1 = inputScalars1->GetTuple1(k); + double const d2 = inputScalars2->GetTuple1(k); if(!k or scalarMin[0] > d1) scalarMin[0] = d1; @@ -194,8 +194,8 @@ int ttkContinuousScatterPlot::RequestData(vtkInformation *ttkNotUsed(request), for(SimplexId i = 0; i < ScatterplotResolution[0]; i++) { for(SimplexId j = 0; j < ScatterplotResolution[1]; j++) { // positions: - double x = imageMin[0] + i * imageDelta[0]; - double y = imageMin[1] + j * imageDelta[1]; + double const x = imageMin[0] + i * imageDelta[0]; + double const y = imageMin[1] + j * imageDelta[1]; pts->SetPoint(id, x, y, 0); // scalars: @@ -204,8 +204,8 @@ int ttkContinuousScatterPlot::RequestData(vtkInformation *ttkNotUsed(request), // density densityScalars->SetTuple1(id, density[i][j]); // original scalar fields - double d1 = scalarMin[0] + i * delta[0]; - double d2 = scalarMin[1] + j * delta[1]; + double const d1 = scalarMin[0] + i * delta[0]; + double const d2 = scalarMin[1] + j * delta[1]; scalars1->SetTuple1(id, d1); scalars2->SetTuple1(id, d2); if(i < ScatterplotResolution[0] - 1 diff --git a/core/vtk/ttkContourAroundPoint/ttkContourAroundPoint.cpp b/core/vtk/ttkContourAroundPoint/ttkContourAroundPoint.cpp index f71d42b463..382d885351 100644 --- a/core/vtk/ttkContourAroundPoint/ttkContourAroundPoint.cpp +++ b/core/vtk/ttkContourAroundPoint/ttkContourAroundPoint.cpp @@ -221,7 +221,7 @@ bool ttkContourAroundPoint::process() { //----------------------------------------------------------------------------// bool ttkContourAroundPoint::postprocess() { - ttk::SimplexId nc = _outContoursNc; + ttk::SimplexId const nc = _outContoursNc; if(nc == 0) // very fine area filter return true; diff --git a/core/vtk/ttkContourForests/ttkContourForests.cpp b/core/vtk/ttkContourForests/ttkContourForests.cpp index 935573b08f..e46ae6f8cf 100644 --- a/core/vtk/ttkContourForests/ttkContourForests.cpp +++ b/core/vtk/ttkContourForests/ttkContourForests.cpp @@ -220,7 +220,7 @@ void ttkContourForests::getSkeletonArcs() { vtkIntArray *typeScalars{}; ttkSimplexIdTypeArray *sizeScalars{}; vtkDoubleArray *spanScalars{}; - int type = static_cast(TreeComponent::Arc); + int const type = static_cast(TreeComponent::Arc); float point1[3]; vector point2(3); @@ -239,14 +239,14 @@ void ttkContourForests::getSkeletonArcs() { a = tree_->getSuperArc(i); if(a->isVisible()) { - SimplexId upNodeId = tree_->getSuperArc(i)->getUpNodeId(); - SimplexId upVertex = tree_->getNode(upNodeId)->getVertexId(); + SimplexId const upNodeId = tree_->getSuperArc(i)->getUpNodeId(); + SimplexId const upVertex = tree_->getNode(upNodeId)->getVertexId(); float coordUp[3]; triangulation_->getVertexPoint( upVertex, coordUp[0], coordUp[1], coordUp[2]); - SimplexId downNodeId = tree_->getSuperArc(i)->getDownNodeId(); - SimplexId downVertex = tree_->getNode(downNodeId)->getVertexId(); + SimplexId const downNodeId = tree_->getSuperArc(i)->getDownNodeId(); + SimplexId const downVertex = tree_->getNode(downNodeId)->getVertexId(); float coordDown[3]; triangulation_->getVertexPoint( downVertex, coordDown[0], coordDown[1], coordDown[2]); @@ -396,13 +396,14 @@ void ttkContourForests::getSkeletonArcs() { } else { vtkNew line{}; - SimplexId downNodeVId + SimplexId const downNodeVId = tree_->getNode(a->getDownNodeId())->getVertexId(); triangulation_->getVertexPoint( downNodeVId, point1[0], point1[1], point1[2]); line->SetPoint1(point1); - SimplexId upNodeVId = tree_->getNode(a->getUpNodeId())->getVertexId(); + SimplexId const upNodeVId + = tree_->getNode(a->getUpNodeId())->getVertexId(); std::array pt{}; triangulation_->getVertexPoint(upNodeVId, pt[0], pt[1], pt[2]); point2[0] = pt[0]; @@ -566,11 +567,11 @@ void ttkContourForests::getSkeletonNodes() { SimplexId identifier{}; for(unsigned i = 0; i < criticalPoints_.size(); ++i) { - SimplexId nodeId = criticalPoints_[i]; + SimplexId const nodeId = criticalPoints_[i]; if(tree_->getNode(nodeId)->isHidden()) continue; - SimplexId vertexId = tree_->getNode(nodeId)->getVertexId(); - CriticalType nodeType = getNodeType(nodeId); + SimplexId const vertexId = tree_->getNode(nodeId)->getVertexId(); + CriticalType const nodeType = getNodeType(nodeId); if((nodeType == CriticalType::Local_minimum and showMin_) or (nodeType == CriticalType::Local_maximum and showMax_) @@ -634,7 +635,7 @@ CriticalType downDegree = tree->getNode(id)->getUpValence(); upDegree = tree->getNode(id)->getDownValence(); } - int degree = upDegree + downDegree; + int const degree = upDegree + downDegree; // saddle point if(degree > 1) { @@ -670,15 +671,15 @@ void ttkContourForests::getCriticalPoints() { auto a = tree_->getSuperArc(i); if(!a->isPruned()) { - SimplexId upId = a->getUpNodeId(); - SimplexId up_vId = tree_->getNode(upId)->getVertexId(); + SimplexId const upId = a->getUpNodeId(); + SimplexId const up_vId = tree_->getNode(upId)->getVertexId(); if(!isCriticalPoint[up_vId]) { isCriticalPoint[up_vId] = true; criticalPoints_.push_back(upId); } - SimplexId downId = a->getDownNodeId(); - SimplexId down_vId = tree_->getNode(downId)->getVertexId(); + SimplexId const downId = a->getDownNodeId(); + SimplexId const down_vId = tree_->getNode(downId)->getVertexId(); if(!isCriticalPoint[down_vId]) { isCriticalPoint[down_vId] = true; criticalPoints_.push_back(downId); @@ -790,7 +791,7 @@ int ttkContourForests::computeBarycenters() { barycenter[k] /= sample.size(); // update the arc - unsigned int nbBar + unsigned int const nbBar = barycenters_[static_cast(treeType_)][i].size(); barycenters_[static_cast(treeType_)][i].resize(nbBar + 1); barycenters_[static_cast(treeType_)][i][nbBar].resize(3); @@ -822,7 +823,7 @@ void ttkContourForests::smoothSkeleton(unsigned int skeletonSmoothing) { } void ttkContourForests::smooth(const SimplexId idArc, bool order) { - int N = barycenters_[static_cast(treeType_)][idArc].size(); + int const N = barycenters_[static_cast(treeType_)][idArc].size(); if(N) { // init // vector> barycenterList(N); @@ -947,8 +948,8 @@ void ttkContourForests::getSegmentation(vtkDataSet *input) { // nodes for(SimplexId it = 0; it < (SimplexId)criticalPoints_.size(); ++it) { - SimplexId nodeId = criticalPoints_[it]; - SimplexId vertexId = tree_->getNode(nodeId)->getVertexId(); + SimplexId const nodeId = criticalPoints_[it]; + SimplexId const vertexId = tree_->getNode(nodeId)->getVertexId(); // RegionType regionType = -1; @@ -959,16 +960,16 @@ void ttkContourForests::getSegmentation(vtkDataSet *input) { for(SimplexId i = 0; i < (SimplexId)tree_->getNumberOfSuperArcs(); ++i) { auto a = tree_->getSuperArc(i); if(a->isVisible()) { - SimplexId upNodeId = tree_->getSuperArc(i)->getUpNodeId(); - CriticalType upNodeType = getNodeType(upNodeId); - SimplexId upVertex = tree_->getNode(upNodeId)->getVertexId(); + SimplexId const upNodeId = tree_->getSuperArc(i)->getUpNodeId(); + CriticalType const upNodeType = getNodeType(upNodeId); + SimplexId const upVertex = tree_->getNode(upNodeId)->getVertexId(); float coordUp[3]; triangulation_->getVertexPoint( upVertex, coordUp[0], coordUp[1], coordUp[2]); - SimplexId downNodeId = tree_->getSuperArc(i)->getDownNodeId(); - CriticalType downNodeType = getNodeType(downNodeId); - SimplexId downVertex = tree_->getNode(downNodeId)->getVertexId(); + SimplexId const downNodeId = tree_->getSuperArc(i)->getDownNodeId(); + CriticalType const downNodeType = getNodeType(downNodeId); + SimplexId const downVertex = tree_->getNode(downNodeId)->getVertexId(); float coordDown[3]; triangulation_->getVertexPoint( downVertex, coordDown[0], coordDown[1], coordDown[2]); @@ -1005,8 +1006,8 @@ void ttkContourForests::getSegmentation(vtkDataSet *input) { for(SimplexId j = 0; j < tree_->getSuperArc(i)->getNumberOfRegularNodes(); ++j) { - SimplexId nodeId = tree_->getSuperArc(i)->getRegularNodeId(j); - SimplexId vertexId = nodeId; + SimplexId const nodeId = tree_->getSuperArc(i)->getRegularNodeId(j); + SimplexId const vertexId = nodeId; // cout << vertexId << ", "; if(tree_->getSuperArc(i)->isMasqued(j)) { // cout << vertexId << ", "; @@ -1040,12 +1041,12 @@ void ttkContourForests::getSegmentation(vtkDataSet *input) { for(SimplexId j = 0; j < tree_->getSuperArc(i)->getNumberOfRegularNodes(); ++j) { - SimplexId nodeId = tree_->getSuperArc(i)->getRegularNodeId(j); + SimplexId const nodeId = tree_->getSuperArc(i)->getRegularNodeId(j); if(tree_->getSuperArc(i)->isMasqued(j)) { // Ignore masqued ones continue; } - SimplexId vertexId = nodeId; + SimplexId const vertexId = nodeId; scalarsRegionType->SetTuple1(vertexId, regionType); } } @@ -1195,8 +1196,8 @@ int ttkContourForests::RequestData(vtkInformation *ttkNotUsed(request), auto result = std::minmax_element(vertexScalars_.begin(), vertexScalars_.end()); - double scalarMin = *result.first; - double scalarMax = *result.second; + double const scalarMin = *result.first; + double const scalarMax = *result.second; deltaScalar_ = (scalarMax - scalarMin); // offsets diff --git a/core/vtk/ttkContourTreeAlignment/ttkContourTreeAlignment.cpp b/core/vtk/ttkContourTreeAlignment/ttkContourTreeAlignment.cpp index 9b85619eb4..d76d664d63 100644 --- a/core/vtk/ttkContourTreeAlignment/ttkContourTreeAlignment.cpp +++ b/core/vtk/ttkContourTreeAlignment/ttkContourTreeAlignment.cpp @@ -58,7 +58,7 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), auto inputMB = vtkMultiBlockDataSet::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT())); - size_t n = inputMB->GetNumberOfBlocks(); + size_t const n = inputMB->GetNumberOfBlocks(); //================================================================================================================== // print input info @@ -281,7 +281,7 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), }; // Points - size_t nOutputVertices = outputVertices.size(); + size_t const nOutputVertices = outputVertices.size(); auto points = vtkSmartPointer::New(); points->SetNumberOfPoints(nOutputVertices); alignmentTree->SetPoints(points); @@ -338,7 +338,7 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), pointData->AddArray(segmentationIDs); // Cells - size_t nOutputEdges = outputEdges.size() / 2; + size_t const nOutputEdges = outputEdges.size() / 2; auto cellArray = vtkSmartPointer::New(); // cellArray->SetCells(nOutputEdges, cells); @@ -389,15 +389,15 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), std::vector> alignmentIDs; for(size_t i = 0; i < n; i++) { - std::vector vertices_i(nVertices[i], -1); + std::vector const vertices_i(nVertices[i], -1); alignmentIDs.push_back(vertices_i); } for(size_t i = 0; i < nOutputEdges; i++) { - int id1 = outputEdges[i * 2]; - int id2 = outputEdges[i * 2 + 1]; - float v1 = scalar->GetValue(id1); - float v2 = scalar->GetValue(id2); + int const id1 = outputEdges[i * 2]; + int const id2 = outputEdges[i * 2 + 1]; + float const v1 = scalar->GetValue(id1); + float const v2 = scalar->GetValue(id2); if(v1 > v2) { downEdges[id1].push_back(i); upEdges[id2].push_back(i); @@ -449,8 +449,8 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), for(size_t i = 0; i < nOutputEdges; i++) { fileJSON << " {"; - int id1 = outputEdges[i * 2]; - int id2 = outputEdges[i * 2 + 1]; + int const id1 = outputEdges[i * 2]; + int const id2 = outputEdges[i * 2 + 1]; fileJSON << "\"node1\": " << id1 << ", \"node2\": " << id2; fileJSON << (i == nOutputEdges - 1 ? "}\n" : "},\n"); } @@ -478,10 +478,10 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), downEdges = std::vector>(nVertices[t]); for(size_t i = 0; i < nEdges[t]; i++) { - int id1 = topologies[t][i * 2 + 0]; - int id2 = topologies[t][i * 2 + 1]; - float v1 = ((float *)scalars[t])[id1]; - float v2 = ((float *)scalars[t])[id2]; + int const id1 = topologies[t][i * 2 + 0]; + int const id2 = topologies[t][i * 2 + 1]; + float const v1 = ((float *)scalars[t])[id1]; + float const v2 = ((float *)scalars[t])[id2]; if(v1 > v2) { downEdges[id1].push_back(i); upEdges[id2].push_back(i); @@ -497,7 +497,7 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), bool first = true; for(size_t k = 0; k < nOutputVertices; k++) { - int i = vertexIDs->GetComponent(k, t); + int const i = vertexIDs->GetComponent(k, t); if(i < 0) continue; fileJSON << (first ? " {" : ",\n {"); @@ -527,8 +527,8 @@ int ttkContourTreeAlignment::RequestData(vtkInformation *ttkNotUsed(request), for(size_t i = 0; i < nEdges[t]; i++) { fileJSON << " {"; - int id1 = alignmentIDs[t][topologies[t][i * 2 + 0]]; - int id2 = alignmentIDs[t][topologies[t][i * 2 + 1]]; + int const id1 = alignmentIDs[t][topologies[t][i * 2 + 0]]; + int const id2 = alignmentIDs[t][topologies[t][i * 2 + 1]]; fileJSON << "\"node1\": " << id1 << ", \"node2\": " << id2; fileJSON << (i == nEdges[t] - 1 ? "}\n" : "},\n"); } diff --git a/core/vtk/ttkDataSetToTable/ttkDataSetToTable.cpp b/core/vtk/ttkDataSetToTable/ttkDataSetToTable.cpp index f4f37be75b..7fd9fffffa 100644 --- a/core/vtk/ttkDataSetToTable/ttkDataSetToTable.cpp +++ b/core/vtk/ttkDataSetToTable/ttkDataSetToTable.cpp @@ -41,9 +41,10 @@ int ttkDataSetToTable::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector *outputVector) { ttk::Timer t; - std::string targetAttributeName = this->DataAssociation == 0 ? "Point" - : this->DataAssociation == 1 ? "Cell" - : "Field"; + std::string const targetAttributeName = this->DataAssociation == 0 ? "Point" + : this->DataAssociation == 1 + ? "Cell" + : "Field"; this->printMsg("Converting " + targetAttributeName + "Data to Table", 0, 0, ttk::debug::LineMode::REPLACE); diff --git a/core/vtk/ttkDepthImageBasedGeometryApproximation/ttkDepthImageBasedGeometryApproximation.cpp b/core/vtk/ttkDepthImageBasedGeometryApproximation/ttkDepthImageBasedGeometryApproximation.cpp index b7a48660cb..64ac0cdc70 100644 --- a/core/vtk/ttkDepthImageBasedGeometryApproximation/ttkDepthImageBasedGeometryApproximation.cpp +++ b/core/vtk/ttkDepthImageBasedGeometryApproximation/ttkDepthImageBasedGeometryApproximation.cpp @@ -55,7 +55,7 @@ int ttkDepthImageBasedGeometryApproximation::RequestData( auto outputMBD = vtkMultiBlockDataSet::GetData(outputVector); // Process each depth image individually - size_t nBlocks = inputMBD->GetNumberOfBlocks(); + size_t const nBlocks = inputMBD->GetNumberOfBlocks(); for(size_t i = 0; i < nBlocks; i++) { // Get vtkImageData auto inputImage = vtkImageData::SafeDownCast(inputMBD->GetBlock(i)); diff --git a/core/vtk/ttkDimensionReduction/ttkDimensionReduction.cpp b/core/vtk/ttkDimensionReduction/ttkDimensionReduction.cpp index 330a628dc9..9571e7b7f4 100644 --- a/core/vtk/ttkDimensionReduction/ttkDimensionReduction.cpp +++ b/core/vtk/ttkDimensionReduction/ttkDimensionReduction.cpp @@ -68,6 +68,7 @@ int ttkDimensionReduction::RequestData(vtkInformation *ttkNotUsed(request), std::vector inputData; std::vector arrays; + arrays.reserve(ScalarFields.size()); for(const auto &s : ScalarFields) arrays.push_back(input->GetColumnByName(s.data())); for(SimplexId i = 0; i < numberOfRows; ++i) { @@ -85,7 +86,7 @@ int ttkDimensionReduction::RequestData(vtkInformation *ttkNotUsed(request), output->ShallowCopy(input); for(int i = 0; i < NumberOfComponents; ++i) { - std::string s = "Component_" + std::to_string(i); + std::string const s = "Component_" + std::to_string(i); vtkNew arr{}; ttkUtils::SetVoidArray(arr, outputData_[i].data(), numberOfRows, 1); arr->SetName(s.data()); diff --git a/core/vtk/ttkDiscreteGradient/ttkDiscreteGradient.cpp b/core/vtk/ttkDiscreteGradient/ttkDiscreteGradient.cpp index 865613a378..d3dda15098 100644 --- a/core/vtk/ttkDiscreteGradient/ttkDiscreteGradient.cpp +++ b/core/vtk/ttkDiscreteGradient/ttkDiscreteGradient.cpp @@ -71,7 +71,7 @@ int ttkDiscreteGradient::fillCriticalPoints( cellIds->SetName("CellId"); cellIds->SetNumberOfTuples(nPoints); - vtkSmartPointer cellScalars{inputScalars->NewInstance()}; + vtkSmartPointer const cellScalars{inputScalars->NewInstance()}; #ifndef TTK_ENABLE_KAMIKAZE if(!cellScalars) { this->printErr("vtkDataArray allocation problem."); @@ -244,7 +244,7 @@ int ttkDiscreteGradient::RequestData(vtkInformation *ttkNotUsed(request), auto triangulation = ttkAlgorithm::GetTriangulation(input); - int keepGoing = checkEmptyMPIInput(triangulation); + int const keepGoing = checkEmptyMPIInput(triangulation); if(keepGoing < 2) { return keepGoing; } diff --git a/core/vtk/ttkDistanceField/ttkDistanceField.cpp b/core/vtk/ttkDistanceField/ttkDistanceField.cpp index 20a0ccd818..b933ef4c71 100644 --- a/core/vtk/ttkDistanceField/ttkDistanceField.cpp +++ b/core/vtk/ttkDistanceField/ttkDistanceField.cpp @@ -41,7 +41,7 @@ int ttkDistanceField::FillOutputPortInformation(int port, int ttkDistanceField::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - ttk::Timer globalTimer; + ttk::Timer const globalTimer; vtkDataSet *domain = vtkDataSet::GetData(inputVector[0]); vtkPointSet *sources = vtkPointSet::GetData(inputVector[1]); diff --git a/core/vtk/ttkDistanceMatrixDistortion/ttkDistanceMatrixDistortion.cpp b/core/vtk/ttkDistanceMatrixDistortion/ttkDistanceMatrixDistortion.cpp index 7afec46700..b1daf722fc 100644 --- a/core/vtk/ttkDistanceMatrixDistortion/ttkDistanceMatrixDistortion.cpp +++ b/core/vtk/ttkDistanceMatrixDistortion/ttkDistanceMatrixDistortion.cpp @@ -105,7 +105,7 @@ int ttkDistanceMatrixDistortion::RequestData( return 0; } - int n = nRowsHigh; + int const n = nRowsHigh; std::vector vectMatHigh(n), vectMatLow(n); // No 2D vectors to avoid copy of data from the VTK layer. diff --git a/core/vtk/ttkEndFor/ttkEndFor.cpp b/core/vtk/ttkEndFor/ttkEndFor.cpp index 095fe89c9b..f3030b6039 100644 --- a/core/vtk/ttkEndFor/ttkEndFor.cpp +++ b/core/vtk/ttkEndFor/ttkEndFor.cpp @@ -66,10 +66,10 @@ int ttkEndFor::RequestData(vtkInformation *request, } // get iteration info - int i = forEach->GetIterationIdx() - 1; - int n = forEach->GetIterationNumber(); + int const i = forEach->GetIterationIdx() - 1; + int const n = forEach->GetIterationNumber(); - bool isRepeatedIteration = this->LastIterationIdx == i && i > 0; + bool const isRepeatedIteration = this->LastIterationIdx == i && i > 0; this->LastIterationIdx = i; if(isRepeatedIteration) diff --git a/core/vtk/ttkExtract/ttkExtract.cpp b/core/vtk/ttkExtract/ttkExtract.cpp index 2005b0adb4..243882f9c3 100644 --- a/core/vtk/ttkExtract/ttkExtract.cpp +++ b/core/vtk/ttkExtract/ttkExtract.cpp @@ -68,7 +68,7 @@ int ttkExtract::FillOutputPortInformation(int port, vtkInformation *info) { info->Remove(ttkAlgorithm::SAME_DATA_TYPE_AS_INPUT_PORT()); if(this->OutputType != -1) { - std::string DTName = this->GetVtkDataTypeName(this->OutputType); + std::string const DTName = this->GetVtkDataTypeName(this->OutputType); if(DTName.length() < 1) { this->printErr("Unsupported output type"); return 0; @@ -116,7 +116,8 @@ int ttkExtract::ExtractBlocks(vtkDataObject *output, std::string indicesString = ""; doubleVectorToString(indicesString, indices); { - std::string outputDataTypeName = this->GetVtkDataTypeName(this->OutputType); + std::string const outputDataTypeName + = this->GetVtkDataTypeName(this->OutputType); std::string extentString = ""; if(this->OutputType == VTK_IMAGE_DATA) { extentString = "[" + std::to_string(this->ImageExtent[0]); @@ -152,13 +153,13 @@ int ttkExtract::ExtractBlocks(vtkDataObject *output, auto outputAsMB = vtkMultiBlockDataSet::SafeDownCast(output); if(extractTuples) { - int nComponents = inputAsMB->GetNumberOfBlocks(); + int const nComponents = inputAsMB->GetNumberOfBlocks(); for(size_t i = 0; i < indices.size(); i++) { auto tuple = vtkSmartPointer::New(); outputAsMB->SetBlock(i, tuple); - size_t tupleIndex = (size_t)indices[i]; + size_t const tupleIndex = (size_t)indices[i]; for(int c = 0; c < nComponents; c++) { auto blockAsMB = vtkMultiBlockDataSet::SafeDownCast(inputAsMB->GetBlock(c)); @@ -183,7 +184,7 @@ int ttkExtract::ExtractBlocks(vtkDataObject *output, } } else { for(size_t i = 0; i < indices.size(); i++) { - size_t blockIndex = (size_t)indices[i]; + size_t const blockIndex = (size_t)indices[i]; if(blockIndex >= inputAsMB->GetNumberOfBlocks()) { this->printErr("Index out of range (" + std::to_string(blockIndex) + "/" + std::to_string(inputAsMB->GetNumberOfBlocks()) @@ -205,7 +206,7 @@ int ttkExtract::ExtractBlocks(vtkDataObject *output, return 0; } - size_t blockIndex = (size_t)indices[0]; + size_t const blockIndex = (size_t)indices[0]; if(blockIndex < inputAsMB->GetNumberOfBlocks()) { auto block = inputAsMB->GetBlock(blockIndex); if(output->GetDataObjectType() != block->GetDataObjectType()) { @@ -249,7 +250,7 @@ int ttkExtract::ExtractRows(vtkDataObject *output, this->printMsg("Extracting rows [" + indicesString + "]", 0, ttk::debug::LineMode::REPLACE); - size_t nValues = indices.size(); + size_t const nValues = indices.size(); auto inputAsT = vtkTable::SafeDownCast(input); auto outputAsT = vtkTable::SafeDownCast(output); if(!inputAsT || !outputAsT) { @@ -257,8 +258,8 @@ int ttkExtract::ExtractRows(vtkDataObject *output, return 0; } - size_t nRows = inputAsT->GetNumberOfRows(); - size_t nCols = inputAsT->GetNumberOfColumns(); + size_t const nRows = inputAsT->GetNumberOfRows(); + size_t const nCols = inputAsT->GetNumberOfColumns(); for(size_t j = 0; j < nValues; j++) if(((size_t)indices[j]) >= nRows || indices[j] < 0) { @@ -374,7 +375,7 @@ int computeMask(signed char *mask, } } - int status = computeMask_
( + int const status = computeMask_
( mask, nValues, values, pivotValuesMin, pivotValuesMax, threadNumber); if(validationMode == ttkExtract::VALIDATION_MODE::UNEQUAL) @@ -406,7 +407,7 @@ int ttkExtract::AddMaskArray(vtkDataObject *output, this->printErr("Unable to retrieve input scalar array."); return 0; } - std::string inputArrayName = inputArray->GetName(); + std::string const inputArrayName = inputArray->GetName(); const int inputArrayAssociation = this->GetInputArrayAssociation(0, input); if(inputArrayAssociation != 0 && inputArrayAssociation != 1) { this->printErr("Geometry extraction requires point or cell data."); @@ -418,9 +419,10 @@ int ttkExtract::AddMaskArray(vtkDataObject *output, std::string expressionValuesString = ""; doubleVectorToString(expressionValuesString, expressionValues); const std::string ValidationModeS[6] = {"<", "<=", "==", "!=", ">=", ">"}; - std::string msg = "Computing Mask: '" + inputArrayName + "' " - + ValidationModeS[static_cast(this->ValidationMode)] - + " [" + expressionValuesString + "]"; + std::string const msg + = "Computing Mask: '" + inputArrayName + "' " + + ValidationModeS[static_cast(this->ValidationMode)] + " [" + + expressionValuesString + "]"; ; this->printMsg(msg, 0, 0, this->threadNumber_, ttk::debug::LineMode::REPLACE); @@ -526,13 +528,13 @@ int createUniqueValueArray(vtkDataArray *uniqueValueArray, if(uniqueValueArray->GetDataType() != valueArray->GetDataType()) return 0; - size_t nValues + size_t const nValues = valueArray->GetNumberOfTuples() * valueArray->GetNumberOfComponents(); auto valueArrayData = ttkUtils::GetPointer
(valueArray); for(size_t i = 0; i < nValues; i++) uniqueValues.insert(valueArrayData[i]); - size_t nUniqueValues = uniqueValues.size(); + size_t const nUniqueValues = uniqueValues.size(); uniqueValueArray->SetNumberOfComponents(1); uniqueValueArray->SetNumberOfTuples(nUniqueValues); @@ -550,14 +552,14 @@ int createUniqueValueArray(vtkDataArray *uniqueValueArray, int ttkExtract::ExtractArrayValues(vtkDataObject *output, vtkDataObject *input, const std::vector &indices) { - size_t nValues = indices.size(); + size_t const nValues = indices.size(); auto inputArray = this->GetInputArrayToProcess(0, input); if(!inputArray) { this->printErr("Unable to retrieve input array."); return 0; } - std::string inputArrayName = inputArray->GetName(); + std::string const inputArrayName = inputArray->GetName(); output->ShallowCopy(input); @@ -602,8 +604,8 @@ int ttkExtract::ExtractArrayValues(vtkDataObject *output, outputArray->SetNumberOfTuples(indices.size()); for(size_t i = 0; i < nValues; i++) { - size_t index = (size_t)indices[i]; - size_t inputArraySize = inputArray->GetNumberOfTuples(); + size_t const index = (size_t)indices[i]; + size_t const inputArraySize = inputArray->GetNumberOfTuples(); if(index < inputArraySize) { outputArray->SetTuple(i, index, inputArray); } else { diff --git a/core/vtk/ttkFTMTree/ttkFTMStructures.h b/core/vtk/ttkFTMTree/ttkFTMStructures.h index aecd0574d1..73ac0fe2af 100644 --- a/core/vtk/ttkFTMTree/ttkFTMStructures.h +++ b/core/vtk/ttkFTMTree/ttkFTMStructures.h @@ -57,7 +57,7 @@ namespace ttk { downDegree = node->getNumberOfUpSuperArcs(); upDegree = node->getNumberOfDownSuperArcs(); } - int degree = upDegree + downDegree; + int const degree = upDegree + downDegree; // saddle point if(degree > 1) { @@ -282,7 +282,7 @@ namespace ttk { arrIdx, static_cast(getNodeType(*tree, nodeId, params))); if(params.advStats) { - idSuperArc saId = getAdjSa(node); + idSuperArc const saId = getAdjSa(node); if(params.segm) { regionSize->SetTuple1(arrIdx, tree->getArcSize(saId)); } @@ -414,7 +414,7 @@ namespace ttk { = tree->getSuperArc(arcId)->getNumberOfRegularNodes(); const double regionSpan = Geometry::distance(coordUp, coordDown); - idSuperArc nid = arc->getNormalizedId(); + idSuperArc const nid = arc->getNormalizedId(); ArcType regionType; // RegionType diff --git a/core/vtk/ttkFTMTree/ttkFTMTree.cpp b/core/vtk/ttkFTMTree/ttkFTMTree.cpp index 7716bdbf12..d5056bb1b5 100644 --- a/core/vtk/ttkFTMTree/ttkFTMTree.cpp +++ b/core/vtk/ttkFTMTree/ttkFTMTree.cpp @@ -503,7 +503,7 @@ int ttkFTMTree::getSegmentation(vtkDataSet *outputSegmentation) { int ttkFTMTree::getSkeletonArcs(vtkUnstructuredGrid *outputSkeletonArcs) { vtkNew skeletonArcs{}; - vtkNew points{}; + vtkNew const points{}; ttk::ftm::ArcData arcData; arcData.init(ftmTree_, params_); diff --git a/core/vtk/ttkFTMTree/ttkFTMTreeUtils.h b/core/vtk/ttkFTMTree/ttkFTMTreeUtils.h index 551c6d1bb1..1a8e5c98cf 100644 --- a/core/vtk/ttkFTMTree/ttkFTMTreeUtils.h +++ b/core/vtk/ttkFTMTree/ttkFTMTreeUtils.h @@ -29,13 +29,13 @@ namespace ttk { // Init Scalars auto scalars = std::make_shared(); - vtkSmartPointer nodesScalar + vtkSmartPointer const nodesScalar = treeNodes->GetPointData()->GetArray("Scalar"); // 1: Scalar scalars->size = nodesScalar->GetNumberOfTuples(); auto scalarsValues = std::make_shared>( nodesScalar->GetNumberOfTuples()); for(int i = 0; i < nodesScalar->GetNumberOfTuples(); ++i) { - int index = (treeNodeIdArray ? treeNodeIdArray->GetTuple1(i) : i); + int const index = (treeNodeIdArray ? treeNodeIdArray->GetTuple1(i) : i); (*scalarsValues)[index] = nodesScalar->GetTuple1(i); } scalars->values = (void *)(scalarsValues->data()); @@ -46,20 +46,20 @@ namespace ttk { MergeTree mergeTree(scalars, scalarsValues, params); // Add Nodes - vtkSmartPointer nodesId + vtkSmartPointer const nodesId = treeNodes->GetPointData()->GetArray("NodeId"); // 0: NodeId - vtkIdType nodesNumTuples = nodesId->GetNumberOfTuples(); + vtkIdType const nodesNumTuples = nodesId->GetNumberOfTuples(); for(vtkIdType i = 0; i < nodesNumTuples; ++i) { mergeTree.tree.makeNode(i); } // Add Arcs - vtkSmartPointer arcsUp + vtkSmartPointer const arcsUp = treeArcs->GetCellData()->GetArray("upNodeId"); // 1: upNodeId - vtkSmartPointer arcsDown + vtkSmartPointer const arcsDown = treeArcs->GetCellData()->GetArray("downNodeId"); // 2: downNodeId - vtkIdType arcsNumTuples = arcsUp->GetNumberOfTuples(); - vtkSmartPointer dummyArcArray + vtkIdType const arcsNumTuples = arcsUp->GetNumberOfTuples(); + vtkSmartPointer const dummyArcArray = treeArcs->GetCellData()->GetArray("isDummyArc"); std::set> added_arcs; // Avoid duplicates for(vtkIdType i = 0; i < arcsNumTuples; ++i) { @@ -105,15 +105,15 @@ namespace ttk { = persistenceDiagram->GetPointData()->GetArray("TreeNodeId"); auto treeNodeId2Array = persistenceDiagram->GetPointData()->GetArray("TreeNodeIdOrigin"); - bool gotNodeArrays = (treeNodeIdArray and treeNodeId2Array); + bool const gotNodeArrays = (treeNodeIdArray and treeNodeId2Array); auto noPairs = birthArray->GetNumberOfTuples(); int noNodes = noPairs * 2; if(gotNodeArrays) { for(vtkIdType i = 0; i < treeNodeIdArray->GetNumberOfTuples(); ++i) { - int val = std::max(treeNodeIdArray->GetTuple1(i), - treeNodeId2Array->GetTuple1(i)) - + 1; + int const val = std::max(treeNodeIdArray->GetTuple1(i), + treeNodeId2Array->GetTuple1(i)) + + 1; noNodes = std::max(noNodes, val); } } @@ -155,9 +155,9 @@ namespace ttk { or (not useSadMaxPairs and ct1 != locMin and ct2 != locMin)) and i != minMaxPairIndex) continue; - int index1 + int const index1 = (gotNodeArrays ? treeNodeId2Array->GetTuple1(pts[0]) : i * 2); - int index2 + int const index2 = (gotNodeArrays ? treeNodeIdArray->GetTuple1(pts[0]) : i * 2 + 1); mergeTree.tree.getNode(index1)->setOrigin(index2); mergeTree.tree.getNode(index2)->setOrigin(index1); @@ -191,7 +191,7 @@ namespace ttk { inputTrees.resize(blocks->GetNumberOfBlocks()); for(size_t i = 0; i < inputTrees.size(); ++i) { if(blocks->GetBlock(0)->IsA("vtkMultiBlockDataSet")) { - vtkSmartPointer vtkBlock + vtkSmartPointer const vtkBlock = vtkSmartPointer::New(); vtkBlock->SetNumberOfBlocks(blocks->GetNumberOfBlocks()); for(unsigned int j = 0; j < blocks->GetNumberOfBlocks(); ++j) @@ -200,7 +200,7 @@ namespace ttk { ->GetBlock(i)); inputTrees[i] = vtkBlock; } else if(blocks->GetBlock(0)->IsA("vtkUnstructuredGrid")) { - vtkSmartPointer vtkBlock + vtkSmartPointer const vtkBlock = vtkSmartPointer::New(); vtkBlock->SetNumberOfBlocks(1); vtkBlock->SetBlock( @@ -257,7 +257,8 @@ namespace ttk { std::vector &treesArcs, std::vector &treesSegmentation, bool useSadMaxPairs = true) { - std::vector useSadMaxPairsVec(inputTrees.size(), useSadMaxPairs); + std::vector const useSadMaxPairsVec( + inputTrees.size(), useSadMaxPairs); return constructTrees(inputTrees, intermediateTrees, treesNodes, treesArcs, treesSegmentation, useSadMaxPairsVec); } diff --git a/core/vtk/ttkFTRGraph/ttkFTRGraph.cpp b/core/vtk/ttkFTRGraph/ttkFTRGraph.cpp index e6d0dcd977..c9354e5681 100644 --- a/core/vtk/ttkFTRGraph/ttkFTRGraph.cpp +++ b/core/vtk/ttkFTRGraph/ttkFTRGraph.cpp @@ -83,7 +83,7 @@ int ttkFTRGraph::addCompleteSkeletonArc(const Graph &graph, arcData.setPointInfo(graph, arcId, pointIds[1], true); } if(pointIds[0] != pointIds[1]) { - vtkIdType nextCellId + vtkIdType const nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); arcData.setArcInfo(graph, arcId, nextCellId); } @@ -100,7 +100,8 @@ int ttkFTRGraph::addCompleteSkeletonArc(const Graph &graph, arcData.setPointInfo(graph, arcId, pointIds[1]); } if(pointIds[0] != pointIds[1]) { - vtkIdType nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); + vtkIdType const nextCellId + = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); arcData.setArcInfo(graph, arcId, nextCellId); } @@ -146,7 +147,8 @@ int ttkFTRGraph::addDirectSkeletonArc(const Graph &graph, arcData.points.emplace(upVertId, pointIds[1]); arcData.setPointInfo(graph, arcId, pointIds[1]); } - vtkIdType nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); + vtkIdType const nextCellId + = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); // Scalar arrays arcData.setArcInfo(graph, arcId, nextCellId); @@ -221,7 +223,7 @@ int ttkFTRGraph::addSampledSkeletonArc(const Graph &graph, arcData.setPointInfo(graph, arcId, pointIds[1], true); if(pointIds[0] != pointIds[1]) { - vtkIdType nextCellId + vtkIdType const nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); arcData.setArcInfo(graph, arcId, nextCellId); } @@ -248,7 +250,8 @@ int ttkFTRGraph::addSampledSkeletonArc(const Graph &graph, arcData.setPointInfo(graph, arcId, pointIds[1]); } if(pointIds[0] != pointIds[1]) { - vtkIdType nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); + vtkIdType const nextCellId + = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds); arcData.setArcInfo(graph, arcId, nextCellId); } @@ -389,7 +392,7 @@ int ttkFTRGraph::getSkeletonArcs(const ttk::ftr::Graph &graph, ttk::ftr::ArcData arcData(nbFinArc); vtkNew arcs{}; - vtkNew points{}; + vtkNew const points{}; for(idSuperArc arcId = 0; arcId < nbArcs; ++arcId) { if(!graph.getArc(arcId).isVisible()) @@ -430,7 +433,7 @@ int ttkFTRGraph::getSkeletonNodes(const Graph &graph, triangulation_->getVertexPoint(vertId, point[0], point[1], point[2]); points->InsertNextPoint(point); - double scalar = inputScalars_->GetTuple1(vertId); + double const scalar = inputScalars_->GetTuple1(vertId); nodeData.addNode(graph, nodeId, scalar); } diff --git a/core/vtk/ttkFTRGraph/ttkFTRGraphStructures.h b/core/vtk/ttkFTRGraph/ttkFTRGraphStructures.h index de8d8044f6..6e8661a613 100644 --- a/core/vtk/ttkFTRGraph/ttkFTRGraphStructures.h +++ b/core/vtk/ttkFTRGraph/ttkFTRGraphStructures.h @@ -143,7 +143,7 @@ namespace ttk { const ttk::ftr::idSuperArc curArcId = graph.getArcId(v); ids->SetTuple1(v, curArcId); - int downNodeType + int const downNodeType = (int)graph.getNode(graph.getArc(curArcId).getDownNodeId()) .getType(); regionType->SetTuple1(v, downNodeType); diff --git a/core/vtk/ttkFiber/ttkFiber.cpp b/core/vtk/ttkFiber/ttkFiber.cpp index 754f02ed27..bfa4aca216 100644 --- a/core/vtk/ttkFiber/ttkFiber.cpp +++ b/core/vtk/ttkFiber/ttkFiber.cpp @@ -47,14 +47,14 @@ int ttkFiber::RequestData(vtkInformation *ttkNotUsed(request), this->printErr("Unable to retrieve input array U."); return 0; } - std::string uArrayName(uArray->GetName()); + std::string const uArrayName(uArray->GetName()); auto vArray = this->GetInputArrayToProcess(1, inputVector); if(!vArray) { this->printErr("Unable to retrieve input array V."); return 0; } - std::string vArrayName(vArray->GetName()); + std::string const vArrayName(vArray->GetName()); this->printMsg("Computing Fiber (" + uArrayName + ": " + std::to_string(UValue) + ", " + vArrayName + ": " diff --git a/core/vtk/ttkFiberSurface/ttkFiberSurface.cpp b/core/vtk/ttkFiberSurface/ttkFiberSurface.cpp index 2932fde216..8b2ef516f6 100644 --- a/core/vtk/ttkFiberSurface/ttkFiberSurface.cpp +++ b/core/vtk/ttkFiberSurface/ttkFiberSurface.cpp @@ -60,7 +60,7 @@ int ttkFiberSurface::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector *outputVector) { using ttk::SimplexId; - ttk::Timer t; + ttk::Timer const t; const auto input = vtkDataSet::GetData(inputVector[0]); const auto polygon = vtkUnstructuredGrid::GetData(inputVector[1]); @@ -114,7 +114,7 @@ int ttkFiberSurface::RequestData(vtkInformation *ttkNotUsed(request), inputPolygon_.clear(); - SimplexId cellNumber = polygon->GetNumberOfCells(); + SimplexId const cellNumber = polygon->GetNumberOfCells(); vtkCellArray *connectivity = polygon->GetCells(); if(connectivity->GetData()->GetNumberOfTuples() < 3 * cellNumber) { diff --git a/core/vtk/ttkForEach/ttkForEach.cpp b/core/vtk/ttkForEach/ttkForEach.cpp index 456f2e853a..1623a46ff4 100644 --- a/core/vtk/ttkForEach/ttkForEach.cpp +++ b/core/vtk/ttkForEach/ttkForEach.cpp @@ -139,7 +139,7 @@ int ttkForEach::RequestData(vtkInformation *request, iterationInformation->SetValue(0, this->IterationIdx); iterationInformation->SetValue(1, this->IterationNumber); - std::string modeStrings[6] = {"B", "R", "G", "V", "A", "BT"}; + std::string const modeStrings[6] = {"B", "R", "G", "V", "A", "BT"}; this->printMsg("[" + modeStrings[static_cast(mode)] + "] Iteration: ( " + std::to_string(this->IterationIdx) + " / " + std::to_string(this->IterationNumber - 1) + " ) ", diff --git a/core/vtk/ttkGeometrySmoother/ttkGeometrySmoother.cpp b/core/vtk/ttkGeometrySmoother/ttkGeometrySmoother.cpp index 6de5d7be42..d162c3820b 100644 --- a/core/vtk/ttkGeometrySmoother/ttkGeometrySmoother.cpp +++ b/core/vtk/ttkGeometrySmoother/ttkGeometrySmoother.cpp @@ -45,7 +45,7 @@ int ttkGeometrySmoother::RequestData(vtkInformation *ttkNotUsed(request), auto triangulation = ttkAlgorithm::GetTriangulation(inputPointSet); - int keepGoing = checkEmptyMPIInput(triangulation); + int const keepGoing = checkEmptyMPIInput(triangulation); if(keepGoing < 2) { return keepGoing; } diff --git a/core/vtk/ttkGridLayout/ttkGridLayout.cpp b/core/vtk/ttkGridLayout/ttkGridLayout.cpp index c1a89c8dad..f885789b07 100644 --- a/core/vtk/ttkGridLayout/ttkGridLayout.cpp +++ b/core/vtk/ttkGridLayout/ttkGridLayout.cpp @@ -67,13 +67,13 @@ int ttkGridLayout::TranslateObject(vtkDataObject *input, auto inputAsID = vtkImageData::SafeDownCast(input); if(inputMB) { - size_t n = inputMB->GetNumberOfBlocks(); + size_t const n = inputMB->GetNumberOfBlocks(); for(size_t i = 0; i < n; i++) if(!this->TranslateObject(inputMB->GetBlock(i), colAxis, rowAxis, dw, dh)) return 0; } else if(inputAsPS) { - size_t nCoords = inputAsPS->GetNumberOfPoints() * 3; + size_t const nCoords = inputAsPS->GetNumberOfPoints() * 3; auto points = inputAsPS->GetPoints(); auto pointCoords = (float *)points->GetVoidPointer(0); for(size_t i = 0; i < nCoords; i += 3) { @@ -103,15 +103,15 @@ int ttkGridLayout::RequestData(vtkInformation *ttkNotUsed(request), auto outputMB = vtkMultiBlockDataSet::GetData(outputVector); // Determine Grid Axis - int colAxis = this->GetColAxis(); - int rowAxis = this->GetRowAxis(); + int const colAxis = this->GetColAxis(); + int const rowAxis = this->GetRowAxis(); // Compute width and height of grid cells double bounds[6]; double maxWidth = 0; double maxHeight = 0; - size_t nBlocks = inputMB->GetNumberOfBlocks(); + size_t const nBlocks = inputMB->GetNumberOfBlocks(); this->printMsg("Translating " + std::to_string(nBlocks) + " object(s)", 0, ttk::debug::LineMode::REPLACE); @@ -131,8 +131,8 @@ int ttkGridLayout::RequestData(vtkInformation *ttkNotUsed(request), return 0; } - double blockWidth = bounds[colAxis * 2 + 1] - bounds[colAxis * 2]; - double blockHeight = bounds[rowAxis * 2 + 1] - bounds[rowAxis * 2]; + double const blockWidth = bounds[colAxis * 2 + 1] - bounds[colAxis * 2]; + double const blockHeight = bounds[rowAxis * 2 + 1] - bounds[rowAxis * 2]; if(maxWidth < blockWidth) maxWidth = blockWidth; if(maxHeight < blockHeight) diff --git a/core/vtk/ttkHelloWorld/ttkHelloWorld.cpp b/core/vtk/ttkHelloWorld/ttkHelloWorld.cpp index 0663f8d4f3..c6204a495f 100644 --- a/core/vtk/ttkHelloWorld/ttkHelloWorld.cpp +++ b/core/vtk/ttkHelloWorld/ttkHelloWorld.cpp @@ -162,7 +162,7 @@ int ttkHelloWorld::RequestData(vtkInformation *ttkNotUsed(request), // Create an output array that has the same data type as the input array // Note: vtkSmartPointers are well documented // (https://vtk.org/Wiki/VTK/Tutorials/SmartPointers) - vtkSmartPointer outputArray + vtkSmartPointer const outputArray = vtkSmartPointer::Take(inputArray->NewInstance()); outputArray->SetName(this->OutputArrayName.data()); // set array name outputArray->SetNumberOfComponents(1); // only one component per tuple diff --git a/core/vtk/ttkIcosphere/ttkIcosphere.cpp b/core/vtk/ttkIcosphere/ttkIcosphere.cpp index 91ad92d4fc..b9a5c88fb4 100644 --- a/core/vtk/ttkIcosphere/ttkIcosphere.cpp +++ b/core/vtk/ttkIcosphere/ttkIcosphere.cpp @@ -38,11 +38,12 @@ int ttkIcosphere::RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **ttkNotUsed(inputVector), vtkInformationVector *outputVector) { // get parameter - size_t nSpheres = this->Centers ? this->Centers->GetNumberOfTuples() : 1; - size_t nSubdivisions = this->GetNumberOfSubdivisions(); - double radius = this->GetRadius(); + size_t const nSpheres + = this->Centers ? this->Centers->GetNumberOfTuples() : 1; + size_t const nSubdivisions = this->GetNumberOfSubdivisions(); + double const radius = this->GetRadius(); - bool useDoublePrecision + bool const useDoublePrecision = this->Centers ? this->Centers->GetDataType() == VTK_DOUBLE : false; // prepare the output buffers diff --git a/core/vtk/ttkIcosphereFromObject/ttkIcosphereFromObject.cpp b/core/vtk/ttkIcosphereFromObject/ttkIcosphereFromObject.cpp index 1811355e18..cfffebce4e 100644 --- a/core/vtk/ttkIcosphereFromObject/ttkIcosphereFromObject.cpp +++ b/core/vtk/ttkIcosphereFromObject/ttkIcosphereFromObject.cpp @@ -41,9 +41,9 @@ int ttkIcosphereFromObject::RequestData(vtkInformation *request, return 0; } - double dx = bounds[1] - bounds[0]; - double dy = bounds[3] - bounds[2]; - double dz = bounds[5] - bounds[4]; + double const dx = bounds[1] - bounds[0]; + double const dy = bounds[3] - bounds[2]; + double const dz = bounds[5] - bounds[4]; this->SetRadius(this->Scale * std::sqrt(dx * dx + dy * dy + dz * dz) / 2.0); this->SetCenter( diff --git a/core/vtk/ttkIcospheresFromPoints/ttkIcospheresFromPoints.cpp b/core/vtk/ttkIcospheresFromPoints/ttkIcospheresFromPoints.cpp index 64e471cd05..c9781be956 100644 --- a/core/vtk/ttkIcospheresFromPoints/ttkIcospheresFromPoints.cpp +++ b/core/vtk/ttkIcospheresFromPoints/ttkIcospheresFromPoints.cpp @@ -35,7 +35,7 @@ int copyArrayData(vtkDataArray *oldArray, auto newData = ttkUtils::GetPointer(newArray); for(size_t i = 0; i < nSpheres; i++) { - size_t sphereIndex = i * nVerticesPerSphere * nComponents; + size_t const sphereIndex = i * nVerticesPerSphere * nComponents; for(size_t j = 0; j < nComponents; j++) { const auto &value = oldData[i * nComponents + j]; size_t newIndex = sphereIndex + j; @@ -54,14 +54,14 @@ int ttkIcospheresFromPoints::RequestData(vtkInformation *request, auto input = vtkPointSet::GetData(inputVector[0], 0); if(!input) return 1; - size_t nPoints = input->GetNumberOfPoints(); + size_t const nPoints = input->GetNumberOfPoints(); if(nPoints < 1) return 1; this->SetCenters(input->GetPoints()->GetData()); // compute spheres - int status + int const status = this->ttkIcosphere::RequestData(request, inputVector, outputVector); if(!status) return 0; @@ -83,13 +83,13 @@ int ttkIcospheresFromPoints::RequestData(vtkInformation *request, if(!oldArray || oldArray->GetName() == nullptr) { continue; } - std::string oldArrayName(oldArray->GetName()); + std::string const oldArrayName(oldArray->GetName()); if(this->GetComputeNormals() && oldArrayName.compare("Normals") == 0) { continue; } auto newArray = vtkSmartPointer::Take(oldArray->NewInstance()); - size_t nComponents = oldArray->GetNumberOfComponents(); + size_t const nComponents = oldArray->GetNumberOfComponents(); newArray->SetName(oldArray->GetName()); newArray->SetNumberOfComponents(nComponents); newArray->SetNumberOfTuples(nVertices * nPoints); diff --git a/core/vtk/ttkIdentifierRandomizer/ttkIdentifierRandomizer.cpp b/core/vtk/ttkIdentifierRandomizer/ttkIdentifierRandomizer.cpp index dfcef188ec..9ea367ac15 100644 --- a/core/vtk/ttkIdentifierRandomizer/ttkIdentifierRandomizer.cpp +++ b/core/vtk/ttkIdentifierRandomizer/ttkIdentifierRandomizer.cpp @@ -128,7 +128,7 @@ int ttkIdentifierRandomizer::RequestData(vtkInformation *ttkNotUsed(request), + "'..."); // allocate the memory for the output scalar field - vtkSmartPointer outputArray + vtkSmartPointer const outputArray = vtkSmartPointer::Take(inputScalarField->NewInstance()); outputArray->SetName(inputScalarField->GetName()); outputArray->SetNumberOfComponents(1); diff --git a/core/vtk/ttkIdentifiers/ttkIdentifiers.cpp b/core/vtk/ttkIdentifiers/ttkIdentifiers.cpp index ede4c46a2a..29ee3d47fd 100644 --- a/core/vtk/ttkIdentifiers/ttkIdentifiers.cpp +++ b/core/vtk/ttkIdentifiers/ttkIdentifiers.cpp @@ -42,9 +42,9 @@ int ttkIdentifiers::RequestData(vtkInformation *ttkNotUsed(request), vtkDataSet *input = vtkDataSet::GetData(inputVector[0]); vtkDataSet *output = vtkDataSet::GetData(outputVector); - Timer t; + Timer const t; - int keepGoing = checkEmptyMPIInput(input); + int const keepGoing = checkEmptyMPIInput(input); if(keepGoing < 2) { return keepGoing; } @@ -59,7 +59,7 @@ int ttkIdentifiers::RequestData(vtkInformation *ttkNotUsed(request), // vtkPolyData, the global identifiers are always stored as vtkDataArrays // automatically during preconditioning - ttk::SimplexId numberOfVertices = triangulation->getNumberOfVertices(); + ttk::SimplexId const numberOfVertices = triangulation->getNumberOfVertices(); vtkNew globalPointIds; globalPointIds->SetNumberOfTuples(numberOfVertices); globalPointIds->SetNumberOfComponents(1); diff --git a/core/vtk/ttkIdentifyByScalarField/ttkIdentifyByScalarField.cpp b/core/vtk/ttkIdentifyByScalarField/ttkIdentifyByScalarField.cpp index 9d2b5aa75a..2355bf1feb 100644 --- a/core/vtk/ttkIdentifyByScalarField/ttkIdentifyByScalarField.cpp +++ b/core/vtk/ttkIdentifyByScalarField/ttkIdentifyByScalarField.cpp @@ -68,7 +68,8 @@ int ttkIdentifyByScalarField::RequestData(vtkInformation *ttkNotUsed(request), if(!inputScalars_) return 0; - int inputArrayAssociation = this->GetInputArrayAssociation(0, inputVector); + int const inputArrayAssociation + = this->GetInputArrayAssociation(0, inputVector); if(inputArrayAssociation > 1 || inputArrayAssociation < 0) { printErr("input array has to be cell data or point data."); @@ -91,7 +92,7 @@ int ttkIdentifyByScalarField::RequestData(vtkInformation *ttkNotUsed(request), this->printMsg("Computing Identifiers", 1, t.getElapsedTime(), 1); - vtkSmartPointer ids + vtkSmartPointer const ids = vtkSmartPointer::New(); ids->SetNumberOfComponents(1); ids->SetNumberOfTuples(numberOfValues); diff --git a/core/vtk/ttkImportEmbeddingFromTable/ttkImportEmbeddingFromTable.cpp b/core/vtk/ttkImportEmbeddingFromTable/ttkImportEmbeddingFromTable.cpp index 7c8915729c..b54e4827d8 100644 --- a/core/vtk/ttkImportEmbeddingFromTable/ttkImportEmbeddingFromTable.cpp +++ b/core/vtk/ttkImportEmbeddingFromTable/ttkImportEmbeddingFromTable.cpp @@ -99,7 +99,7 @@ int ttkImportEmbeddingFromTable::RequestData( return -1; } - vtkSmartPointer points = vtkSmartPointer::New(); + vtkSmartPointer const points = vtkSmartPointer::New(); points->SetNumberOfPoints(numberOfPoints); switch(xarr->GetDataType()) { diff --git a/core/vtk/ttkIntegralLines/ttkIntegralLines.cpp b/core/vtk/ttkIntegralLines/ttkIntegralLines.cpp index 9bc1cbf7c9..fa0ce7bf40 100644 --- a/core/vtk/ttkIntegralLines/ttkIntegralLines.cpp +++ b/core/vtk/ttkIntegralLines/ttkIntegralLines.cpp @@ -217,7 +217,7 @@ int ttkIntegralLines::RequestData(vtkInformation *ttkNotUsed(request), ttk::Triangulation *triangulation = ttkAlgorithm::GetTriangulation(domain); vtkDataArray *inputScalars = this->GetInputArrayToProcess(0, domain); - int keepGoing = checkEmptyMPIInput(triangulation); + int const keepGoing = checkEmptyMPIInput(triangulation); if(keepGoing < 2) { return keepGoing; } diff --git a/core/vtk/ttkJacobiSet/ttkJacobiSet.cpp b/core/vtk/ttkJacobiSet/ttkJacobiSet.cpp index 72e9d16660..d25d7a1d93 100644 --- a/core/vtk/ttkJacobiSet/ttkJacobiSet.cpp +++ b/core/vtk/ttkJacobiSet/ttkJacobiSet.cpp @@ -128,7 +128,7 @@ int ttkJacobiSet::RequestData(vtkInformation *ttkNotUsed(request), std::array p{}; for(size_t i = 0; i < jacobiSet_.size(); i++) { - int edgeId = jacobiSet_[i].first; + int const edgeId = jacobiSet_[i].first; ttk::SimplexId vertexId0 = -1, vertexId1 = -1; triangulation->getEdgeVertex(edgeId, 0, vertexId0); triangulation->getEdgeVertex(edgeId, 1, vertexId1); @@ -177,7 +177,8 @@ int ttkJacobiSet::RequestData(vtkInformation *ttkNotUsed(request), for(int i = 0; i < input->GetPointData()->GetNumberOfArrays(); i++) { const auto scalarField = input->GetPointData()->GetArray(i); - vtkSmartPointer scalarArray{scalarField->NewInstance()}; + vtkSmartPointer const scalarArray{ + scalarField->NewInstance()}; scalarArray->SetNumberOfComponents(scalarField->GetNumberOfComponents()); scalarArray->SetNumberOfTuples(2 * jacobiSet_.size()); @@ -185,7 +186,7 @@ int ttkJacobiSet::RequestData(vtkInformation *ttkNotUsed(request), std::vector value(scalarField->GetNumberOfComponents()); for(size_t j = 0; j < jacobiSet_.size(); j++) { - int edgeId = jacobiSet_[j].first; + int const edgeId = jacobiSet_[j].first; ttk::SimplexId vertexId0 = -1, vertexId1 = -1; triangulation->getEdgeVertex(edgeId, 0, vertexId0); triangulation->getEdgeVertex(edgeId, 1, vertexId1); diff --git a/core/vtk/ttkLDistance/ttkLDistance.cpp b/core/vtk/ttkLDistance/ttkLDistance.cpp index bf2ef51062..bffbca463d 100644 --- a/core/vtk/ttkLDistance/ttkLDistance.cpp +++ b/core/vtk/ttkLDistance/ttkLDistance.cpp @@ -74,10 +74,10 @@ int ttkLDistance::RequestData(vtkInformation *ttkNotUsed(request), #endif // Allocate memory for the output scalar field, based on the first input. - vtkSmartPointer outputScalarField{ + vtkSmartPointer const outputScalarField{ inputScalarField1->NewInstance()}; - ttk::SimplexId numberOfPoints = input->GetNumberOfPoints(); + ttk::SimplexId const numberOfPoints = input->GetNumberOfPoints(); outputScalarField->SetNumberOfTuples(numberOfPoints); outputScalarField->SetName(DistanceFieldName.data()); diff --git a/core/vtk/ttkLDistanceMatrix/ttkLDistanceMatrix.cpp b/core/vtk/ttkLDistanceMatrix/ttkLDistanceMatrix.cpp index b3d37f649c..ade39290bf 100644 --- a/core/vtk/ttkLDistanceMatrix/ttkLDistanceMatrix.cpp +++ b/core/vtk/ttkLDistanceMatrix/ttkLDistanceMatrix.cpp @@ -105,9 +105,9 @@ int ttkLDistanceMatrix::RequestData(vtkInformation * /*request*/, // zero-padd column name to keep Row Data columns ordered const auto zeroPad = [](std::string &colName, const size_t numberCols, const size_t colIdx) { - std::string max{std::to_string(numberCols - 1)}; - std::string cur{std::to_string(colIdx)}; - std::string zer(max.size() - cur.size(), '0'); + std::string const max{std::to_string(numberCols - 1)}; + std::string const cur{std::to_string(colIdx)}; + std::string const zer(max.size() - cur.size(), '0'); colName.append(zer).append(cur); }; diff --git a/core/vtk/ttkManifoldCheck/ttkManifoldCheck.cpp b/core/vtk/ttkManifoldCheck/ttkManifoldCheck.cpp index 605b8932a8..c3baaf7682 100644 --- a/core/vtk/ttkManifoldCheck/ttkManifoldCheck.cpp +++ b/core/vtk/ttkManifoldCheck/ttkManifoldCheck.cpp @@ -69,7 +69,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), printMsg("Preparing VTK output..."); - vtkSmartPointer vertexPointArray + vtkSmartPointer const vertexPointArray = vtkSmartPointer::New(); vertexPointArray->SetName("VertexLinkComponentNumber"); vertexPointArray->SetNumberOfTuples(output->GetNumberOfPoints()); @@ -77,7 +77,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), vertexPointArray->SetTuple1(i, vertexLinkComponentNumber_[i]); output->GetPointData()->AddArray(vertexPointArray); - vtkSmartPointer vertexCellArray + vtkSmartPointer const vertexCellArray = vtkSmartPointer::New(); vertexCellArray->SetName("VertexLinkComponentNumber"); vertexCellArray->SetNumberOfTuples(output->GetNumberOfCells()); @@ -86,7 +86,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), vtkCell *c = output->GetCell(i); SimplexId cellMax = -1; for(int j = 0; j < c->GetNumberOfPoints(); j++) { - SimplexId vertexId = c->GetPointId(j); + SimplexId const vertexId = c->GetPointId(j); if((!j) || (vertexLinkComponentNumber_[vertexId] > cellMax)) { cellMax = vertexLinkComponentNumber_[vertexId]; } @@ -97,7 +97,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), output->GetCellData()->AddArray(vertexCellArray); // edges - vtkSmartPointer edgePointArray + vtkSmartPointer const edgePointArray = vtkSmartPointer::New(); edgePointArray->SetName("EdgeLinkComponentNumber"); edgePointArray->SetNumberOfTuples(output->GetNumberOfPoints()); @@ -105,7 +105,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), edgePointArray->SetTuple1(i, 0); } - vtkSmartPointer edgeCellArray + vtkSmartPointer const edgeCellArray = vtkSmartPointer::New(); edgeCellArray->SetName("EdgeLinkComponentNumber"); edgeCellArray->SetNumberOfTuples(output->GetNumberOfCells()); @@ -121,8 +121,8 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), triangulation->getEdgeVertex(i, 0, vertexId0); triangulation->getEdgeVertex(i, 1, vertexId1); - SimplexId vertexMax0 = edgePointArray->GetTuple1(vertexId0); - SimplexId vertexMax1 = edgePointArray->GetTuple1(vertexId1); + SimplexId const vertexMax0 = edgePointArray->GetTuple1(vertexId0); + SimplexId const vertexMax1 = edgePointArray->GetTuple1(vertexId1); if(edgeLinkComponentNumber_[i] > vertexMax0) edgePointArray->SetTuple1(vertexId0, edgeLinkComponentNumber_[i]); @@ -134,12 +134,12 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), #pragma omp parallel for num_threads(threadNumber_) #endif for(SimplexId i = 0; i < output->GetNumberOfCells(); i++) { - vtkSmartPointer c + vtkSmartPointer const c = vtkSmartPointer::New(); output->GetCell(i, c); SimplexId cellMax = -1; for(int j = 0; j < c->GetNumberOfPoints(); j++) { - SimplexId vertexId0 = c->GetPointId(j); + SimplexId const vertexId0 = c->GetPointId(j); SimplexId vertexId1 = -1; for(int k = 0; k < c->GetNumberOfPoints(); k++) { if(k != j) { @@ -147,7 +147,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), // check if (vertexId0 - vertexId1) is indeed an edge in the // triangulation - SimplexId edgeNumber + SimplexId const edgeNumber = triangulation->getVertexEdgeNumber(vertexId0); for(SimplexId l = 0; l < edgeNumber; l++) { SimplexId edgeId = -1; @@ -176,7 +176,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), output->GetCellData()->AddArray(edgeCellArray); // triangles - vtkSmartPointer trianglePointArray + vtkSmartPointer const trianglePointArray = vtkSmartPointer::New(); trianglePointArray->SetName("TriangleLinkComponentNumber"); trianglePointArray->SetNumberOfTuples(output->GetNumberOfPoints()); @@ -184,7 +184,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), trianglePointArray->SetTuple1(i, 0); } - vtkSmartPointer triangleCellArray + vtkSmartPointer const triangleCellArray = vtkSmartPointer::New(); triangleCellArray->SetName("TriangleLinkComponentNumber"); triangleCellArray->SetNumberOfTuples(output->GetNumberOfCells()); @@ -202,9 +202,9 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), triangulation->getTriangleVertex(i, 1, vertexId1); triangulation->getTriangleVertex(i, 2, vertexId2); - SimplexId vertexMax0 = trianglePointArray->GetTuple1(vertexId0); - SimplexId vertexMax1 = trianglePointArray->GetTuple1(vertexId1); - SimplexId vertexMax2 = trianglePointArray->GetTuple1(vertexId2); + SimplexId const vertexMax0 = trianglePointArray->GetTuple1(vertexId0); + SimplexId const vertexMax1 = trianglePointArray->GetTuple1(vertexId1); + SimplexId const vertexMax2 = trianglePointArray->GetTuple1(vertexId2); if(triangleLinkComponentNumber_[i] > vertexMax0) trianglePointArray->SetTuple1( @@ -221,13 +221,13 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), #pragma omp parallel for num_threads(threadNumber_) #endif for(SimplexId i = 0; i < output->GetNumberOfCells(); i++) { - vtkSmartPointer c + vtkSmartPointer const c = vtkSmartPointer::New(); output->GetCell(i, c); SimplexId cellMax = -1; for(int j = 0; j < c->GetNumberOfPoints(); j++) { - SimplexId vertexId0 = c->GetPointId(j); + SimplexId const vertexId0 = c->GetPointId(j); SimplexId vertexId1 = -1; SimplexId vertexId2 = -1; @@ -241,7 +241,7 @@ int ttkManifoldCheck::RequestData(vtkInformation *ttkNotUsed(request), // check if (vertexId0, vertexId1, vertexId2) is indeed a // triangle in the triangulation - SimplexId triangleNumber + SimplexId const triangleNumber = triangulation->getVertexTriangleNumber(vertexId0); for(SimplexId m = 0; m < triangleNumber; m++) { SimplexId triangleId = -1; diff --git a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp index f3d54c7e1f..aa6b19949a 100644 --- a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp +++ b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp @@ -185,7 +185,7 @@ int ttkMergeTreeClustering::runCompute( std::vector intermediateTrees(numInputs), intermediateTrees2(numInputs2); - bool useSadMaxPairs = (JoinSplitMixtureCoefficient == 0); + bool const useSadMaxPairs = (JoinSplitMixtureCoefficient == 0); IsPersistenceDiagram = constructTrees(inputTrees, intermediateMTrees, treesNodes, treesArcs, treesSegmentation, useSadMaxPairs); @@ -204,7 +204,7 @@ int ttkMergeTreeClustering::runCompute( // ------------------------------------------------------------------------------------ // --- Call base // ------------------------------------------------------------------------------------ - bool AddNodes = true; + bool const AddNodes = true; // Classical distance double distance = 0; @@ -376,8 +376,8 @@ void makeDoubleInputPersistenceDiagramOutput( vtkUnstructuredGrid *treeNodes, int i, std::vector &nodeCorr2) { - int nodeCorrShift = vtkOutputNode->GetNumberOfPoints(); - vtkSmartPointer vtkOutputNode2 + int const nodeCorrShift = vtkOutputNode->GetNumberOfPoints(); + vtkSmartPointer const vtkOutputNode2 = vtkSmartPointer::New(); visuMaker.setVtkOutputNode(vtkOutputNode2); visuMaker.setVtkOutputArc(vtkOutputNode2); @@ -413,7 +413,7 @@ void makeDoubleInputPersistenceDiagramMatching( std::vector> &nodeCorr2, std::vector> &nodeCorrBary2, std::vector> &allBaryPercentMatch2) { - vtkSmartPointer vtkOutputMatching2 + vtkSmartPointer const vtkOutputMatching2 = vtkSmartPointer::New(); visuMakerMatching.setVtkOutputMatching(vtkOutputMatching2); visuMakerMatching.setOutputMatchingBarycenter(outputMatchingBarycenter2); @@ -475,25 +475,25 @@ int ttkMergeTreeClustering::runOutput( // --- Input trees // ------------------------------------------ // Declare vtk objects - vtkSmartPointer vtkOutputNode1 + vtkSmartPointer const vtkOutputNode1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc1 + vtkSmartPointer const vtkOutputArc1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation1 + vtkSmartPointer const vtkOutputSegmentation1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputNode2 + vtkSmartPointer const vtkOutputNode2 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc2 + vtkSmartPointer const vtkOutputArc2 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation2 + vtkSmartPointer const vtkOutputSegmentation2 = vtkSmartPointer::New(); - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); - vtkSmartPointer vtkBlockSegs + vtkSmartPointer const vtkBlockSegs = vtkSmartPointer::New(); // Fill vtk objects @@ -599,7 +599,7 @@ int ttkMergeTreeClustering::runOutput( vtkBlockSegs->SetNumberOfBlocks(2); vtkBlockSegs->SetBlock(0, vtkOutputSegmentation1); vtkBlockSegs->SetBlock(1, vtkOutputSegmentation2); - int segBlockID = 1 + !IsPersistenceDiagram; + int const segBlockID = 1 + !IsPersistenceDiagram; output_clusters->SetBlock(segBlockID, vtkBlockSegs); } } @@ -608,7 +608,7 @@ int ttkMergeTreeClustering::runOutput( // --- Matching // ------------------------------------------ // Declare vtk objects - vtkSmartPointer vtkOutputMatching + vtkSmartPointer const vtkOutputMatching = vtkSmartPointer::New(); // Fill vtk objects @@ -654,16 +654,16 @@ int ttkMergeTreeClustering::runOutput( output_clusters->SetNumberOfBlocks(numInputs); } else { output_clusters->SetNumberOfBlocks((OutputSegmentation ? 3 : 2)); - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); vtkBlockNodes->SetNumberOfBlocks(numInputs); output_clusters->SetBlock(0, vtkBlockNodes); - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); vtkBlockArcs->SetNumberOfBlocks(numInputs); output_clusters->SetBlock(1, vtkBlockArcs); if(OutputSegmentation) { - vtkSmartPointer vtkBlockSegs + vtkSmartPointer const vtkBlockSegs = vtkSmartPointer::New(); vtkBlockSegs->SetNumberOfBlocks(numInputs); output_clusters->SetBlock(2, vtkBlockSegs); @@ -680,9 +680,9 @@ int ttkMergeTreeClustering::runOutput( // Declare vtk objects vtkSmartPointer vtkOutputNode = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc + vtkSmartPointer const vtkOutputArc = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation + vtkSmartPointer const vtkOutputSegmentation = vtkSmartPointer::New(); // Fill vtk objects @@ -761,7 +761,7 @@ int ttkMergeTreeClustering::runOutput( vtkMultiBlockDataSet::SafeDownCast(output_clusters->GetBlock(1)) ->SetBlock(i, vtkOutputArc); if(OutputSegmentation) { - int segBlockID = 1 + !IsPersistenceDiagram; + int const segBlockID = 1 + !IsPersistenceDiagram; vtkMultiBlockDataSet::SafeDownCast( output_clusters->GetBlock(segBlockID)) ->SetBlock(i, vtkOutputSegmentation); @@ -777,11 +777,11 @@ int ttkMergeTreeClustering::runOutput( output_centroids->SetNumberOfBlocks(NumberOfBarycenters); } else { output_centroids->SetNumberOfBlocks(2); - vtkSmartPointer vtkBlockNodes2 + vtkSmartPointer const vtkBlockNodes2 = vtkSmartPointer::New(); vtkBlockNodes2->SetNumberOfBlocks(NumberOfBarycenters); output_centroids->SetBlock(0, vtkBlockNodes2); - vtkSmartPointer vtkBlockArcs2 + vtkSmartPointer const vtkBlockArcs2 = vtkSmartPointer::New(); vtkBlockArcs2->SetNumberOfBlocks(NumberOfBarycenters); output_centroids->SetBlock(1, vtkBlockArcs2); @@ -791,9 +791,9 @@ int ttkMergeTreeClustering::runOutput( // Declare vtk objects vtkSmartPointer vtkOutputNode = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc + vtkSmartPointer const vtkOutputArc = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation + vtkSmartPointer const vtkOutputSegmentation = vtkSmartPointer::New(); // Fill vtk objects @@ -885,14 +885,14 @@ int ttkMergeTreeClustering::runOutput( // Declare vtk objects vtkSmartPointer vtkOutputMatching = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputNode1 + vtkSmartPointer const vtkOutputNode1 = vtkUnstructuredGrid::SafeDownCast( (IsPersistenceDiagram and not OutputSegmentation ? output_clusters->GetBlock(i) : vtkMultiBlockDataSet::SafeDownCast( output_clusters->GetBlock(0)) ->GetBlock(i))); - vtkSmartPointer vtkOutputNode2 + vtkSmartPointer const vtkOutputNode2 = vtkUnstructuredGrid::SafeDownCast( (IsPersistenceDiagram ? output_centroids->GetBlock(c) : vtkMultiBlockDataSet::SafeDownCast( diff --git a/core/vtk/ttkMergeTreeDistanceMatrix/ttkMergeTreeDistanceMatrix.cpp b/core/vtk/ttkMergeTreeDistanceMatrix/ttkMergeTreeDistanceMatrix.cpp index 2eaa187e81..3c27a10eac 100644 --- a/core/vtk/ttkMergeTreeDistanceMatrix/ttkMergeTreeDistanceMatrix.cpp +++ b/core/vtk/ttkMergeTreeDistanceMatrix/ttkMergeTreeDistanceMatrix.cpp @@ -102,7 +102,7 @@ int ttkMergeTreeDistanceMatrix::run( // Construct trees const int numInputs = inputTrees.size(); std::vector> intermediateTrees, intermediateTrees2; - bool useSadMaxPairs = (mixtureCoefficient_ == 0); // only for PD support + bool const useSadMaxPairs = (mixtureCoefficient_ == 0); // only for PD support isPersistenceDiagram_ = constructTrees(inputTrees, intermediateTrees, useSadMaxPairs); if(not isPersistenceDiagram_ @@ -199,9 +199,9 @@ int ttkMergeTreeDistanceMatrix::run( // zero-padd column name to keep Row Data columns ordered const auto zeroPad = [](std::string &colName, const size_t numberCols, const size_t colIdx) { - std::string max{std::to_string(numberCols - 1)}; - std::string cur{std::to_string(colIdx)}; - std::string zer(max.size() - cur.size(), '0'); + std::string const max{std::to_string(numberCols - 1)}; + std::string const cur{std::to_string(colIdx)}; + std::string const zer(max.size() - cur.size(), '0'); colName.append(zer).append(cur); }; @@ -292,7 +292,7 @@ int ttkMergeTreeDistanceMatrix::RequestData( for(auto paramName : paramNames) { auto array = blocks->GetFieldData()->GetArray(paramName.c_str()); if(array) { - double value = array->GetTuple1(0); + double const value = array->GetTuple1(0); setParamValueFromName(paramName, value); printMsg(" - " + paramName + " = " + std::to_string(value)); } else diff --git a/core/vtk/ttkMergeTreePrincipalGeodesics/ttkMergeTreePrincipalGeodesics.cpp b/core/vtk/ttkMergeTreePrincipalGeodesics/ttkMergeTreePrincipalGeodesics.cpp index 22befa52c5..9974f65afc 100644 --- a/core/vtk/ttkMergeTreePrincipalGeodesics/ttkMergeTreePrincipalGeodesics.cpp +++ b/core/vtk/ttkMergeTreePrincipalGeodesics/ttkMergeTreePrincipalGeodesics.cpp @@ -153,7 +153,7 @@ int ttkMergeTreePrincipalGeodesics::runCompute( std::vector> intermediateMTrees, intermediateMTrees2; - bool useSadMaxPairs = (mixtureCoefficient_ == 0); + bool const useSadMaxPairs = (mixtureCoefficient_ == 0); isPersistenceDiagram_ = ttk::ftm::constructTrees( inputTrees, intermediateMTrees, treesNodes, treesArcs, treesSegmentation, useSadMaxPairs); @@ -194,9 +194,9 @@ void ttkMergeTreePrincipalGeodesics::makeBarycenterOutput( ttk::ftm::MergeTree &barycenter, int blockId, vtkMultiBlockDataSet *output_barycenter) { - vtkSmartPointer vtkOutputNodeBary + vtkSmartPointer const vtkOutputNodeBary = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArcBary + vtkSmartPointer const vtkOutputArcBary = vtkSmartPointer::New(); ttkMergeTreeVisualization visuMakerBary; @@ -250,11 +250,11 @@ int ttkMergeTreePrincipalGeodesics::runOutput( or (mixtureCoefficient_ != 0 and mixtureCoefficient_ != 1)); output_barycenter->SetNumberOfBlocks(noBlockBary); if(not isPersistenceDiagram_) { - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); - int noBlock = (inputTrees2.size() == 0 ? 1 : 2); + int const noBlock = (inputTrees2.size() == 0 ? 1 : 2); vtkBlockNodes->SetNumberOfBlocks(noBlock); vtkBlockArcs->SetNumberOfBlocks(noBlock); output_barycenter->SetBlock(0, vtkBlockNodes); @@ -290,8 +290,8 @@ int ttkMergeTreePrincipalGeodesics::runOutput( for(unsigned int i = 0; i < (*allTs[t]).size(); ++i) { vtkNew tArray{}; auto size = (*allTs[t]).size(); - std::string name = (t == 0 ? getTableCoefficientName(size, i) - : getTableCoefficientNormName(size, i)); + std::string const name = (t == 0 ? getTableCoefficientName(size, i) + : getTableCoefficientNormName(size, i)); tArray->SetName(name.c_str()); tArray->SetNumberOfTuples(inputTrees.size()); for(unsigned int j = 0; j < (*allTs[t])[i].size(); ++j) @@ -345,8 +345,8 @@ int ttkMergeTreePrincipalGeodesics::runOutput( for(unsigned int i = 0; i < (*vector).size(); ++i) for(unsigned int k = 0; k < 2; ++k) { vtkNew vectorArray{}; - bool isSecondInput = (v >= 2); - std::string name + bool const isSecondInput = (v >= 2); + std::string const name = getTableVectorName((*vector).size(), i, v % 2, k, isSecondInput); vectorArray->SetName(name.c_str()); vectorArray->SetNumberOfTuples(maxSize); @@ -363,14 +363,14 @@ int ttkMergeTreePrincipalGeodesics::runOutput( // ------------------------------------------ // TODO manage second input // Correlation coefficients - unsigned int noCols = branchesCorrelationMatrix_[0].size(); - unsigned int noRows = branchesCorrelationMatrix_.size(); + unsigned int const noCols = branchesCorrelationMatrix_[0].size(); + unsigned int const noRows = branchesCorrelationMatrix_.size(); for(unsigned int j = 0; j < noCols; ++j) { vtkNew corrArray{}, persArray{}; - std::string name = getTableCorrelationName(noCols, j); + std::string const name = getTableCorrelationName(noCols, j); corrArray->SetName(name.c_str()); corrArray->SetNumberOfTuples(noRows); - std::string name2 = getTableCorrelationPersName(noCols, j); + std::string const name2 = getTableCorrelationPersName(noCols, j); persArray->SetName(name2.c_str()); persArray->SetNumberOfTuples(noRows); for(unsigned int i = 0; i < noRows; ++i) { @@ -394,7 +394,7 @@ int ttkMergeTreePrincipalGeodesics::runOutput( ->getOrigin(); for(unsigned int j = 0; j < inputTrees.size(); ++j) { vtkNew corrArray{}; - std::string name = getTableCorrelationTreeName(inputTrees.size(), j); + std::string const name = getTableCorrelationTreeName(inputTrees.size(), j); corrArray->SetName(name.c_str()); corrArray->SetNumberOfTuples(noRows); for(unsigned int i = 0; i < noRows; ++i) @@ -436,7 +436,7 @@ int ttkMergeTreePrincipalGeodesics::runOutput( intermediateDTrees[i].tree.template getPersistencePairsFromTree( pairs, false); for(unsigned int j = 0; j < pairs.size(); ++j) { - int index = pairs.size() - 1 - j; + int const index = pairs.size() - 1 - j; treesOrder[i][std::get<0>(pairs[j])] = index; treesOrder[i][std::get<1>(pairs[j])] = index; } diff --git a/core/vtk/ttkMergeTreePrincipalGeodesicsDecoding/ttkMergeTreePrincipalGeodesicsDecoding.cpp b/core/vtk/ttkMergeTreePrincipalGeodesicsDecoding/ttkMergeTreePrincipalGeodesicsDecoding.cpp index b74a987b61..3826566a86 100644 --- a/core/vtk/ttkMergeTreePrincipalGeodesicsDecoding/ttkMergeTreePrincipalGeodesicsDecoding.cpp +++ b/core/vtk/ttkMergeTreePrincipalGeodesicsDecoding/ttkMergeTreePrincipalGeodesicsDecoding.cpp @@ -141,7 +141,7 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( for(auto paramName : paramNames) { auto array = tableCoefficients->GetFieldData()->GetArray(paramName.c_str()); if(array) { - double value = array->GetTuple1(0); + double const value = array->GetTuple1(0); setParamValueFromName(paramName, value); } else printMsg(" - " + paramName + " was not found in the field data."); @@ -157,7 +157,7 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( // --- Load tables // ------------------------------------------------------------------------------------ auto tableVNoCols = tableVectors->GetNumberOfColumns() / inputBary.size(); - unsigned int numberOfGeodesics = tableVNoCols / 4; + unsigned int const numberOfGeodesics = tableVNoCols / 4; auto numberOfInputs = tableCoefficients->GetNumberOfRows(); auto baryNoNodes = tableVectors->GetNumberOfRows(); @@ -183,12 +183,13 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( allTs_.resize(numberOfGeodesics, std::vector(numberOfInputs, 0.0)); for(unsigned int i = 0; i < numberOfGeodesics; ++i) for(unsigned int j = 0; j < numberOfInputs; ++j) { - std::string name = getTableCoefficientName(numberOfGeodesics, i); + std::string const name = getTableCoefficientName(numberOfGeodesics, i); allTs_[i][j] = tableCoefficients->GetColumnByName(name.c_str()) ->GetVariantValue(j) .ToDouble(); nonFieldDataNames.push_back(name); - std::string normName = getTableCoefficientNormName(numberOfGeodesics, i); + std::string const normName + = getTableCoefficientNormName(numberOfGeodesics, i); nonFieldDataNames.push_back(normName); } ttk::Geometry::transposeMatrix(allTs_, allTreesTs_); @@ -196,7 +197,7 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( // - aggregate input field data vtkNew fd{}; for(int i = 0; i < tableCoefficients->GetNumberOfColumns(); ++i) { - std::string name{tableCoefficients->GetColumnName(i)}; + std::string const name{tableCoefficients->GetColumnName(i)}; if(std::count(nonFieldDataNames.begin(), nonFieldDataNames.end(), name) == 0) { auto array = tableCoefficients->GetColumn(i); @@ -219,12 +220,12 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( for(unsigned int h = 0; h < inputBary.size(); ++h) { auto &pVS = (h == 0 ? pVS_ : pTrees2Vs_); auto &pV2s = (h == 0 ? pV2s_ : pTrees2V2s_); - bool secondInput = (h == 1); + bool const secondInput = (h == 1); for(unsigned int i = 0; i < numberOfGeodesics; ++i) { for(unsigned int k = 0; k < 2; ++k) { - std::string name1 + std::string const name1 = getTableVectorName(numberOfGeodesics, i, 0, k, secondInput); - std::string name2 + std::string const name2 = getTableVectorName(numberOfGeodesics, i, 1, k, secondInput); pVS[i][k] = ttkUtils::GetPointer(vtkDataArray::SafeDownCast( tableVectors->GetColumnByName(name1.c_str()))); @@ -247,8 +248,9 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( auto baryNodeIdArray = tableCorrelation->GetColumnByName("BaryNodeId"); for(unsigned int j = 0; j < numberOfGeodesics; ++j) { - std::string name = getTableCorrelationName(numberOfGeodesics, j); - std::string name2 = getTableCorrelationPersName(numberOfGeodesics, j); + std::string const name = getTableCorrelationName(numberOfGeodesics, j); + std::string const name2 + = getTableCorrelationPersName(numberOfGeodesics, j); pBranchesCorrelationMatrix_[j] = ttkUtils::GetPointer(vtkDataArray::SafeDownCast( tableCorrelation->GetColumnByName(name.c_str()))); @@ -261,7 +263,7 @@ int ttkMergeTreePrincipalGeodesicsDecoding::RequestData( // later baryMatchings_.resize(numberOfInputs); for(unsigned int i = 0; i < numberOfInputs; ++i) { - std::string name = getTableCorrelationTreeName(numberOfInputs, i); + std::string const name = getTableCorrelationTreeName(numberOfInputs, i); auto array = tableCorrelation->GetColumnByName(name.c_str()); if(array) { baryMatchings_[i].resize(tableCorrNoRows); @@ -320,9 +322,9 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runCompute( if(OutputInputTrees or (ReconstructInputTrees and (computeReconstructionError_ or transferInputTreesInformation_))) { - bool useSadMaxPairs + bool const useSadMaxPairs = (useDoubleInput_ and not processFirstInput) or mixtureCoefficient_ == 0; - bool isInputPD = ttk::ftm::constructTrees( + bool const isInputPD = ttk::ftm::constructTrees( inputTrees, inputDTrees, inputTreesNodes, inputTreesArcs, inputTreesSegmentation, useSadMaxPairs); if(not isInputPD and isPersistenceDiagram_) @@ -332,7 +334,7 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runCompute( //------------------------------------------------------------------------------------ // --- Call base //------------------------------------------------------------------------------------ - std::string preFix{(processFirstInput ? "" : "Second Input ")}; + std::string const preFix{(processFirstInput ? "" : "Second Input ")}; auto &baryToUse = (processFirstInput ? baryDTree[0] : baryDTree[1]); // Geodesics distances @@ -428,15 +430,15 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runOutput( // ------------------------------------------------------------------------------------ auto output = vtkMultiBlockDataSet::GetData(outputVector, 0); - unsigned int noInput = (OutputInputTrees ? inputTrees.size() : 0); - unsigned int noReconst = reconstructedTrees.size(); - unsigned int noBary = (OutputBarycenter ? 1 : 0); - unsigned int noGeod + unsigned int const noInput = (OutputInputTrees ? inputTrees.size() : 0); + unsigned int const noReconst = reconstructedTrees.size(); + unsigned int const noBary = (OutputBarycenter ? 1 : 0); + unsigned int const noGeod = geodesicsTrees.size() * (geodesicsTrees.size() == 0 ? 0 : geodesicsTrees[0].size()); - unsigned int noEllipses = geodesicsEllipses.size(); - unsigned int noRectangle = geodesicsRectangle.size(); - unsigned int noSurface = geodesicsSurface.size(); + unsigned int const noEllipses = geodesicsEllipses.size(); + unsigned int const noRectangle = geodesicsRectangle.size(); + unsigned int const noSurface = geodesicsSurface.size(); printMsg("noInput = " + std::to_string(noInput)); printMsg("noReconst = " + std::to_string(noReconst)); @@ -452,29 +454,29 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runOutput( for(unsigned int i = 0; i < allNo.size(); ++i) steps[i] = (i == 0 ? 0 : steps[i - 1]) + allNo[i]; - unsigned int noTreesTotal = steps[steps.size() - 1]; + unsigned int const noTreesTotal = steps[steps.size() - 1]; - unsigned int noBlocks + unsigned int const noBlocks = 2 - isPersistenceDiagram_ + OutputInputTreesSegmentation; output->SetNumberOfBlocks(noBlocks); - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); vtkBlockNodes->SetNumberOfBlocks(noTreesTotal); output->SetBlock(0, vtkBlockNodes); if(not isPersistenceDiagram_) { - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); vtkBlockArcs->SetNumberOfBlocks(noTreesTotal); output->SetBlock(1, vtkBlockArcs); } if(OutputInputTreesSegmentation) { - vtkSmartPointer vtkBlockSegs + vtkSmartPointer const vtkBlockSegs = vtkSmartPointer::New(); vtkBlockSegs->SetNumberOfBlocks(noTreesTotal); output->SetBlock(2 - isPersistenceDiagram_, vtkBlockSegs); } - int geodesicsTreesOffset = std::max((int)geodesicsTrees.size() - 1, 0); + int const geodesicsTreesOffset = std::max((int)geodesicsTrees.size() - 1, 0); // ------------------------------------------ // --- Trees @@ -522,8 +524,8 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runOutput( } else if(i < steps[3]) { // Geodesics Trees index = i - steps[2]; - int i0 = index / geodesicsTrees[0].size(); - int i1 = index % geodesicsTrees[0].size(); + int const i0 = index / geodesicsTrees[0].size(); + int const i1 = index % geodesicsTrees[0].size(); ttk::ftm::mergeTreeDoubleToTemplate(geodesicsTrees[i0][i1], mt); treeType = 2 + i0; ts = tGeodesics_[i0][i1]; @@ -550,17 +552,18 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runOutput( ts = tSurface_[index]; } - bool isInputTree = (i < steps[0]); - bool isInputTreeAndGotMesh + bool const isInputTree = (i < steps[0]); + bool const isInputTreeAndGotMesh = (isInputTree and inputTrees[i]->GetNumberOfBlocks() >= 3); - bool isReconstructedTree = (i >= steps[0] and i < steps[1]); - bool isInputOrReconstructedTree = (isInputTree or isReconstructedTree); + bool const isReconstructedTree = (i >= steps[0] and i < steps[1]); + bool const isInputOrReconstructedTree + = (isInputTree or isReconstructedTree); - vtkSmartPointer vtkOutputNode + vtkSmartPointer const vtkOutputNode = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc + vtkSmartPointer const vtkOutputArc = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation + vtkSmartPointer const vtkOutputSegmentation = vtkSmartPointer::New(); ttkMergeTreeVisualization visuMaker; @@ -704,29 +707,29 @@ int ttkMergeTreePrincipalGeodesicsDecoding::runOutput( for(unsigned int j = 0; j < ts.size(); ++j) { vtkNew tArray{}; - std::string name = getTableCoefficientName(ts.size(), j); + std::string const name = getTableCoefficientName(ts.size(), j); tArray->SetName(name.c_str()); tArray->InsertNextTuple1(ts[j]); vtkOutputNode->GetFieldData()->AddArray(tArray); vtkNew scaledTArray{}; - std::string name2 = getTableCoefficientNormName(ts.size(), j); + std::string const name2 = getTableCoefficientNormName(ts.size(), j); scaledTArray->SetName(name2.c_str()); scaledTArray->InsertNextTuple1(ts[j] * geodesicsDistances_[j]); vtkOutputNode->GetFieldData()->AddArray(scaledTArray); } - bool isSurfaceTree = (treeType == 5 + geodesicsTreesOffset); + bool const isSurfaceTree = (treeType == 5 + geodesicsTreesOffset); vtkNew isSurfaceArray{}; isSurfaceArray->SetName("isSurface"); isSurfaceArray->InsertNextTuple1(isSurfaceTree); vtkOutputNode->GetFieldData()->AddArray(isSurfaceArray); - bool isBoundary = (isSurfaceTree ? surfaceIsBoundary_[index] : false); + bool const isBoundary = (isSurfaceTree ? surfaceIsBoundary_[index] : false); vtkNew isBoundaryArray{}; isBoundaryArray->SetName("isBoundary"); isBoundaryArray->InsertNextTuple1(isBoundary); vtkOutputNode->GetFieldData()->AddArray(isBoundaryArray); - int boundaryID = (isSurfaceTree ? surfaceBoundaryID_[index] : -1); + int const boundaryID = (isSurfaceTree ? surfaceBoundaryID_[index] : -1); vtkNew BoundaryIDArray{}; BoundaryIDArray->SetName("BoundaryID"); BoundaryIDArray->InsertNextTuple1(boundaryID); diff --git a/core/vtk/ttkMergeTreeTemporalReductionDecoding/ttkMergeTreeTemporalReductionDecoding.cpp b/core/vtk/ttkMergeTreeTemporalReductionDecoding/ttkMergeTreeTemporalReductionDecoding.cpp index bcc7368179..33290ec55d 100644 --- a/core/vtk/ttkMergeTreeTemporalReductionDecoding/ttkMergeTreeTemporalReductionDecoding.cpp +++ b/core/vtk/ttkMergeTreeTemporalReductionDecoding/ttkMergeTreeTemporalReductionDecoding.cpp @@ -123,19 +123,24 @@ int ttkMergeTreeTemporalReductionDecoding::RequestData( resetDataVisualization(); std::vector> coefs; - int totalInputs = inputTrees.size() + table->GetNumberOfRows(); + int const totalInputs = inputTrees.size() + table->GetNumberOfRows(); std::vector interpolatedTrees(totalInputs, false); for(int i = 0; i < table->GetNumberOfRows(); ++i) { - double alpha = vtkDataArray::SafeDownCast(table->GetColumnByName("Alpha")) - ->GetTuple1(i); - int index1R = vtkDataArray::SafeDownCast(table->GetColumnByName("Index1_R")) - ->GetTuple1(i); - int index2R = vtkDataArray::SafeDownCast(table->GetColumnByName("Index2_R")) - ->GetTuple1(i); - int index1 = vtkDataArray::SafeDownCast(table->GetColumnByName("Index1")) - ->GetTuple1(i); - int index2 = vtkDataArray::SafeDownCast(table->GetColumnByName("Index2")) - ->GetTuple1(i); + double const alpha + = vtkDataArray::SafeDownCast(table->GetColumnByName("Alpha")) + ->GetTuple1(i); + int const index1R + = vtkDataArray::SafeDownCast(table->GetColumnByName("Index1_R")) + ->GetTuple1(i); + int const index2R + = vtkDataArray::SafeDownCast(table->GetColumnByName("Index2_R")) + ->GetTuple1(i); + int const index1 + = vtkDataArray::SafeDownCast(table->GetColumnByName("Index1")) + ->GetTuple1(i); + int const index2 + = vtkDataArray::SafeDownCast(table->GetColumnByName("Index2")) + ->GetTuple1(i); coefs.emplace_back(alpha, index1R, index2R, index1, index2); for(int j = index1 + 1; j < index2; ++j) @@ -199,7 +204,7 @@ int ttkMergeTreeTemporalReductionDecoding::runOutput( std::vector> &inputTrees, std::vector> &coefs, std::vector &interpolatedTrees) { - bool OutputSegmentation = false; // TODO + bool const OutputSegmentation = false; // TODO // ------------------------------------------------------------------------------------ // --- Create output // ------------------------------------------------------------------------------------ @@ -244,16 +249,16 @@ int ttkMergeTreeTemporalReductionDecoding::runOutput( mergeTreeToFTMTree(intermediateMTrees, trees); output_sequence->SetNumberOfBlocks((OutputSegmentation ? 3 : 2)); - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); vtkBlockNodes->SetNumberOfBlocks(intermediateMTrees.size()); output_sequence->SetBlock(0, vtkBlockNodes); - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); vtkBlockArcs->SetNumberOfBlocks(intermediateMTrees.size()); output_sequence->SetBlock(1, vtkBlockArcs); if(OutputSegmentation) { - vtkSmartPointer vtkBlockSegs + vtkSmartPointer const vtkBlockSegs = vtkSmartPointer::New(); vtkBlockSegs->SetNumberOfBlocks(intermediateMTrees.size()); output_sequence->SetBlock(2, vtkBlockSegs); @@ -263,11 +268,11 @@ int ttkMergeTreeTemporalReductionDecoding::runOutput( std::vector> nodeCorr(intermediateMTrees.size()); int cptInterpolatedTree = 0; for(size_t i = 0; i < intermediateMTrees.size(); ++i) { - vtkSmartPointer vtkOutputNode1 + vtkSmartPointer const vtkOutputNode1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc1 + vtkSmartPointer const vtkOutputArc1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation1 + vtkSmartPointer const vtkOutputSegmentation1 = vtkSmartPointer::New(); ttkMergeTreeVisualization visuMaker; @@ -363,13 +368,13 @@ int ttkMergeTreeTemporalReductionDecoding::runOutput( output_matchings->SetNumberOfBlocks(intermediateMTrees.size() - 1); for(size_t i = 0; i < intermediateMTrees.size() - 1; ++i) { // Declare vtk objects - vtkSmartPointer vtkOutputMatching + vtkSmartPointer const vtkOutputMatching = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputNode1 + vtkSmartPointer const vtkOutputNode1 = vtkUnstructuredGrid::SafeDownCast( vtkMultiBlockDataSet::SafeDownCast(output_sequence->GetBlock(0)) ->GetBlock(i)); - vtkSmartPointer vtkOutputNode2 + vtkSmartPointer const vtkOutputNode2 = vtkUnstructuredGrid::SafeDownCast( vtkMultiBlockDataSet::SafeDownCast(output_sequence->GetBlock(0)) ->GetBlock(i + 1)); diff --git a/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionEncoding.cpp b/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionEncoding.cpp index 6ee8a62ee5..ee3ec5050c 100644 --- a/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionEncoding.cpp +++ b/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionEncoding.cpp @@ -224,7 +224,7 @@ template int ttkMergeTreeTemporalReductionEncoding::runOutput( vtkInformationVector *outputVector, std::vector> &inputTrees) { - bool OutputSegmentation = (inputTrees[0]->GetNumberOfBlocks() == 3); + bool const OutputSegmentation = (inputTrees[0]->GetNumberOfBlocks() == 3); // ------------------------------------------------------------------------------------ // --- Create output // ------------------------------------------------------------------------------------ @@ -266,16 +266,16 @@ int ttkMergeTreeTemporalReductionEncoding::runOutput( mergeTreeToFTMTree(keyFramesT, keyFramesTree); output_keyFrames->SetNumberOfBlocks((OutputSegmentation ? 3 : 2)); - vtkSmartPointer vtkBlockNodes + vtkSmartPointer const vtkBlockNodes = vtkSmartPointer::New(); vtkBlockNodes->SetNumberOfBlocks(keyFramesT.size()); output_keyFrames->SetBlock(0, vtkBlockNodes); - vtkSmartPointer vtkBlockArcs + vtkSmartPointer const vtkBlockArcs = vtkSmartPointer::New(); vtkBlockArcs->SetNumberOfBlocks(keyFramesT.size()); output_keyFrames->SetBlock(1, vtkBlockArcs); if(OutputSegmentation) { - vtkSmartPointer vtkBlockSegs + vtkSmartPointer const vtkBlockSegs = vtkSmartPointer::New(); vtkBlockSegs->SetNumberOfBlocks(keyFramesT.size()); output_keyFrames->SetBlock(2, vtkBlockSegs); @@ -283,11 +283,11 @@ int ttkMergeTreeTemporalReductionEncoding::runOutput( double prevXMax = 0; for(size_t i = 0; i < keyFramesT.size(); ++i) { - vtkSmartPointer vtkOutputNode1 + vtkSmartPointer const vtkOutputNode1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputArc1 + vtkSmartPointer const vtkOutputArc1 = vtkSmartPointer::New(); - vtkSmartPointer vtkOutputSegmentation1 + vtkSmartPointer const vtkOutputSegmentation1 = vtkSmartPointer::New(); ttkMergeTreeVisualization visuMaker; @@ -354,9 +354,9 @@ int ttkMergeTreeTemporalReductionEncoding::runOutput( for(size_t i = 0; i < removed.size(); ++i) { while(removed[i] > keyFramesIndex[keyFrameCpt]) ++keyFrameCpt; - int index1 = keyFramesIndex[keyFrameCpt - 1]; - int index2 = keyFramesIndex[keyFrameCpt]; - double alpha = computeAlpha(index1, removed[i], index2); + int const index1 = keyFramesIndex[keyFrameCpt - 1]; + int const index2 = keyFramesIndex[keyFrameCpt]; + double const alpha = computeAlpha(index1, removed[i], index2); coef->SetTuple1(i, alpha); index1Id->SetTuple1(i, index1); index2Id->SetTuple1(i, index2); diff --git a/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionUtils.h b/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionUtils.h index 6b3cc8fc34..13086d31d8 100644 --- a/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionUtils.h +++ b/core/vtk/ttkMergeTreeTemporalReductionEncoding/ttkMergeTreeTemporalReductionUtils.h @@ -80,7 +80,7 @@ void makeTemporalSubsamplingOutput( if(displayRemoved) { for(unsigned int i = 0; i < removed.size(); ++i) { - int index = removed[i]; + int const index = removed[i]; // First cell if(i == 0) { vtkIdType pointIds[2]; @@ -191,7 +191,7 @@ void makeTemporalSubsamplingETDOutput( std::array, 2> embedding{}; for(size_t i = 0; i < intermediateMTrees.size() + removed.size(); ++i) { - double y = emptyTreeDistances[i] * DistanceAxisStretch; + double const y = emptyTreeDistances[i] * DistanceAxisStretch; double x = i; if(i >= intermediateMTrees.size()) x = removed[i - intermediateMTrees.size()]; diff --git a/core/vtk/ttkMeshGraph/ttkMeshGraph.cpp b/core/vtk/ttkMeshGraph/ttkMeshGraph.cpp index 040f35668e..47a1a986cc 100644 --- a/core/vtk/ttkMeshGraph/ttkMeshGraph.cpp +++ b/core/vtk/ttkMeshGraph/ttkMeshGraph.cpp @@ -57,8 +57,8 @@ int ttkMeshGraph::RequestData(vtkInformation *ttkNotUsed(request), return -1; } - size_t nInputPoints = input->GetNumberOfPoints(); - size_t nInputCells = input->GetNumberOfCells(); + size_t const nInputPoints = input->GetNumberOfPoints(); + size_t const nInputCells = input->GetNumberOfCells(); auto inputPointSizes = this->GetInputArrayToProcess(0, inputVector); if(!inputPointSizes) { diff --git a/core/vtk/ttkMeshSubdivision/ttkMeshSubdivision.cpp b/core/vtk/ttkMeshSubdivision/ttkMeshSubdivision.cpp index 983290560f..1764f6aa24 100644 --- a/core/vtk/ttkMeshSubdivision/ttkMeshSubdivision.cpp +++ b/core/vtk/ttkMeshSubdivision/ttkMeshSubdivision.cpp @@ -65,7 +65,7 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), tmpGrid->GetNumberOfCells()); // make the call thread-safe - vtkNew threadCell{}; + vtkNew const threadCell{}; tmpGrid->GetCell(0, threadCell); double value = 0; for(int j = 0; j < tmpGrid->GetPointData()->GetNumberOfArrays(); j++) { @@ -241,7 +241,7 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), // make a cell out of that for(int k = 0; k < (int)cell->GetNumberOfPoints(); k++) { - SimplexId vertexId = cell->GetPointId(k); + SimplexId const vertexId = cell->GetPointId(k); if(cell->GetCellDimension() == 2) { // insert the id of the vertex @@ -252,8 +252,8 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), for(size_t l = 0; l < edgeMap.size(); l++) { vtkCell *edge = cell->GetEdge(l); - SimplexId vertexId0 = edge->GetPointId(0); - SimplexId vertexId1 = edge->GetPointId(1); + SimplexId const vertexId0 = edge->GetPointId(0); + SimplexId const vertexId1 = edge->GetPointId(1); if((vertexId == vertexId0) || (vertexId == vertexId1)) { // add the point id to the cell @@ -271,8 +271,8 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), l++) { vtkCell *edge = cell->GetEdge(l); - SimplexId vertexId0 = edge->GetPointId(0); - SimplexId vertexId1 = edge->GetPointId(1); + SimplexId const vertexId0 = edge->GetPointId(0); + SimplexId const vertexId1 = edge->GetPointId(1); if((l != firstEdge) && ((vertexId == vertexId0) || (vertexId == vertexId1))) { @@ -292,8 +292,8 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), for(size_t l = 0; l < edgeMap.size(); l++) { vtkCell *edge = cell->GetEdge(l); - SimplexId vertexId0 = edge->GetPointId(0); - SimplexId vertexId1 = edge->GetPointId(1); + SimplexId const vertexId0 = edge->GetPointId(0); + SimplexId const vertexId1 = edge->GetPointId(1); if((vertexId == vertexId0) || (vertexId == vertexId1)) { // add the point id to the cell @@ -347,8 +347,8 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), // both should be in vtkCell *edge = cell->GetEdge(l); - SimplexId vertexId0 = edge->GetPointId(0); - SimplexId vertexId1 = edge->GetPointId(1); + SimplexId const vertexId0 = edge->GetPointId(0); + SimplexId const vertexId1 = edge->GetPointId(1); // check if this edge belongs to the face identified right before bool vertex0In = false; @@ -378,8 +378,8 @@ int ttkMeshSubdivision::RequestData(vtkInformation *ttkNotUsed(request), l++) { vtkCell *edge = cell->GetEdge(l); - SimplexId vertexId0 = edge->GetPointId(0); - SimplexId vertexId1 = edge->GetPointId(1); + SimplexId const vertexId0 = edge->GetPointId(0); + SimplexId const vertexId1 = edge->GetPointId(1); if((l != firstEdge) && (l != secondEdge) && ((vertexId == vertexId0) || (vertexId == vertexId1))) { diff --git a/core/vtk/ttkMetricDistortion/ttkMetricDistortion.cpp b/core/vtk/ttkMetricDistortion/ttkMetricDistortion.cpp index c7b2eb7275..27afc7f6e8 100644 --- a/core/vtk/ttkMetricDistortion/ttkMetricDistortion.cpp +++ b/core/vtk/ttkMetricDistortion/ttkMetricDistortion.cpp @@ -159,7 +159,7 @@ int ttkMetricDistortion::RequestData(vtkInformation *ttkNotUsed(request), auto noCells = inputSurface->GetNumberOfCells(); vtkTable *distanceMatrixVTK = vtkTable::GetData(inputVector[1]); - bool validDistanceMatrix + bool const validDistanceMatrix = (distanceMatrixVTK and distanceMatrixVTK->GetNumberOfColumns() == noPoints); if(distanceMatrixVTK and not validDistanceMatrix) { @@ -173,7 +173,7 @@ int ttkMetricDistortion::RequestData(vtkInformation *ttkNotUsed(request), printErr("Distance matrix should be square."); return -3; } - int tableDataType + int const tableDataType = (validDistanceMatrix ? distanceMatrixVTK->GetColumn(0)->GetDataType() : VTK_DOUBLE); @@ -226,7 +226,7 @@ int ttkMetricDistortion::RequestData(vtkInformation *ttkNotUsed(request), } for(unsigned int i = 0; i < 3; ++i) { - std::string type{(i == 0 ? "Min" : (i == 1) ? "Max" : "Avg")}; + std::string const type{(i == 0 ? "Min" : (i == 1) ? "Max" : "Avg")}; vtkNew surfaceIDistanceArray{}; surfaceIDistanceArray->SetName((type + "SurfaceEdgeLength").c_str()); surfaceIDistanceArray->SetNumberOfTuples(noPoints); diff --git a/core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.cpp b/core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.cpp index e3c6953574..5a44ca0086 100644 --- a/core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.cpp +++ b/core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.cpp @@ -77,7 +77,8 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars, vtkNew points{}; vtkNew cellDimensions{}; vtkNew cellIds{}; - vtkSmartPointer cellScalars{inputScalars->NewInstance()}; + vtkSmartPointer const cellScalars{ + inputScalars->NewInstance()}; vtkNew isOnBoundary{}; vtkNew PLVertexIdentifiers{}; vtkNew manifoldSizeScalars{}; diff --git a/core/vtk/ttkOFFReader/ttkOFFReader.cpp b/core/vtk/ttkOFFReader/ttkOFFReader.cpp index efeeb772a9..6d49c0daf6 100644 --- a/core/vtk/ttkOFFReader/ttkOFFReader.cpp +++ b/core/vtk/ttkOFFReader/ttkOFFReader.cpp @@ -181,7 +181,7 @@ int ttkOFFReader::RequestData(vtkInformation *ttkNotUsed(request), vertScalars[i]->SetName(name.c_str()); } - vtkNew points{}; + vtkNew const points{}; // read vertices while( diff --git a/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagram.cpp b/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagram.cpp index f887237b3b..d748f4beba 100644 --- a/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagram.cpp +++ b/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagram.cpp @@ -75,7 +75,7 @@ int ttkPersistenceDiagram::dispatch( return 0; } - vtkNew vtu{}; + vtkNew const vtu{}; // convert CTDiagram to vtkUnstructuredGrid DiagramToVTU(vtu, CTDiagram, inputScalarsArray, *this, @@ -143,7 +143,7 @@ int ttkPersistenceDiagram::RequestData(vtkInformation *ttkNotUsed(request), outputMonotonyOffsets->SetName("outputMonotonyffsets"); outputMonotonyOffsets->FillComponent(0, 0); - vtkSmartPointer outputScalars + vtkSmartPointer const outputScalars = vtkSmartPointer::Take(inputScalars->NewInstance()); outputScalars->SetNumberOfComponents(1); outputScalars->SetNumberOfTuples(inputScalars->GetNumberOfTuples()); diff --git a/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagramUtils.cpp b/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagramUtils.cpp index 0f3f6303f8..3cf37c615f 100644 --- a/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagramUtils.cpp +++ b/core/vtk/ttkPersistenceDiagram/ttkPersistenceDiagramUtils.cpp @@ -206,12 +206,12 @@ int DiagramToVTU(vtkUnstructuredGrid *vtu, pairsDim->SetNumberOfTuples(diagram.size()); cd->AddArray(pairsDim); - vtkSmartPointer persistence{inputScalars->NewInstance()}; + vtkSmartPointer const persistence{inputScalars->NewInstance()}; persistence->SetName(ttk::PersistenceName); persistence->SetNumberOfTuples(diagram.size()); cd->AddArray(persistence); - vtkSmartPointer birthScalars{inputScalars->NewInstance()}; + vtkSmartPointer const birthScalars{inputScalars->NewInstance()}; birthScalars->SetName(ttk::PersistenceBirthName); birthScalars->SetNumberOfTuples(diagram.size()); cd->AddArray(birthScalars); diff --git a/core/vtk/ttkPersistenceDiagramApproximation/ttkPersistenceDiagramApproximation.cpp b/core/vtk/ttkPersistenceDiagramApproximation/ttkPersistenceDiagramApproximation.cpp index 90972136b2..1d35d2e77d 100644 --- a/core/vtk/ttkPersistenceDiagramApproximation/ttkPersistenceDiagramApproximation.cpp +++ b/core/vtk/ttkPersistenceDiagramApproximation/ttkPersistenceDiagramApproximation.cpp @@ -97,7 +97,7 @@ int ttkPersistenceDiagramApproximation::dispatch( } // convert CTDiagram to vtkUnstructuredGrid - vtkNew vtu{}; + vtkNew const vtu{}; DiagramToVTU(vtu, CTDiagram, inputScalarsArray, *this, triangulation->getDimensionality(), this->ShowInsideDomain); @@ -167,7 +167,7 @@ int ttkPersistenceDiagramApproximation::RequestData( outputMonotonyOffsets->SetName("outputMonotonyffsets"); outputMonotonyOffsets->FillComponent(0, 0); - vtkSmartPointer outputScalars + vtkSmartPointer const outputScalars = vtkSmartPointer::Take(inputScalars->NewInstance()); outputScalars->SetNumberOfComponents(1); outputScalars->SetNumberOfTuples(inputScalars->GetNumberOfTuples()); @@ -221,7 +221,7 @@ int ttkPersistenceDiagramApproximation::drawBottleneckBounds( vtkNew bounds{}; double *range = inputScalarsArray->GetRange(0); - double delta = (range[1] - range[0]) * Epsilon; + double const delta = (range[1] - range[0]) * Epsilon; // std::cout << "DELTA for BOUNDS " << delta << " " << getEpsilon() << // std::endl; @@ -261,10 +261,10 @@ int ttkPersistenceDiagramApproximation::drawBottleneckBounds( const auto sa = outputScalars[a]; const auto sb = outputScalars[b]; if(sb - sa >= 2 * delta) { - vtkIdType p0 = points->InsertNextPoint(sa - delta, sb - delta, 0); - vtkIdType p1 = points->InsertNextPoint(sa + delta, sb - delta, 0); - vtkIdType p2 = points->InsertNextPoint(sa - delta, sb + delta, 0); - vtkIdType p3 = points->InsertNextPoint(sa + delta, sb + delta, 0); + vtkIdType const p0 = points->InsertNextPoint(sa - delta, sb - delta, 0); + vtkIdType const p1 = points->InsertNextPoint(sa + delta, sb - delta, 0); + vtkIdType const p2 = points->InsertNextPoint(sa - delta, sb + delta, 0); + vtkIdType const p3 = points->InsertNextPoint(sa + delta, sb + delta, 0); vtkNew quad{}; quad->InsertNextId(p0); @@ -305,10 +305,10 @@ int ttkPersistenceDiagramApproximation::drawBottleneckBounds( const auto s2 = inputScalars[diagram[0].death.id]; auto s1 = inputScalars[diagram.back().birth.id]; s1 = s1 > s2 / 2 ? s1 : s2 / 2; - vtkIdType p0 = points->InsertNextPoint(s0, s0, 0); - vtkIdType p1 = points->InsertNextPoint(s0, s0 + 2 * delta, 0); - vtkIdType p2 = points->InsertNextPoint(s1, s1, 0); - vtkIdType p3 = points->InsertNextPoint(s1, s1 + 2 * delta, 0); + vtkIdType const p0 = points->InsertNextPoint(s0, s0, 0); + vtkIdType const p1 = points->InsertNextPoint(s0, s0 + 2 * delta, 0); + vtkIdType const p2 = points->InsertNextPoint(s1, s1, 0); + vtkIdType const p3 = points->InsertNextPoint(s1, s1 + 2 * delta, 0); vtkNew quad{}; quad->InsertNextId(p0); diff --git a/core/vtk/ttkPersistenceDiagramDistanceMatrix/ttkPersistenceDiagramDistanceMatrix.cpp b/core/vtk/ttkPersistenceDiagramDistanceMatrix/ttkPersistenceDiagramDistanceMatrix.cpp index 8bb2e0f2d6..0e1515935f 100644 --- a/core/vtk/ttkPersistenceDiagramDistanceMatrix/ttkPersistenceDiagramDistanceMatrix.cpp +++ b/core/vtk/ttkPersistenceDiagramDistanceMatrix/ttkPersistenceDiagramDistanceMatrix.cpp @@ -48,7 +48,7 @@ int ttkPersistenceDiagramDistanceMatrix::RequestData( vtkInformation * /*request*/, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { - ttk::Memory m; + ttk::Memory const m; // Get input data std::vector inputDiagrams; @@ -110,9 +110,9 @@ int ttkPersistenceDiagramDistanceMatrix::RequestData( // zero-padd column name to keep Row Data columns ordered const auto zeroPad = [](std::string &colName, const size_t numberCols, const size_t colIdx) { - std::string max{std::to_string(numberCols - 1)}; - std::string cur{std::to_string(colIdx)}; - std::string zer(max.size() - cur.size(), '0'); + std::string const max{std::to_string(numberCols - 1)}; + std::string const cur{std::to_string(colIdx)}; + std::string const zer(max.size() - cur.size(), '0'); colName.append(zer).append(cur); }; diff --git a/core/vtk/ttkPersistentGenerators/ttkPersistentGenerators.cpp b/core/vtk/ttkPersistentGenerators/ttkPersistentGenerators.cpp index 46c6b9187a..6f4a3bf856 100644 --- a/core/vtk/ttkPersistentGenerators/ttkPersistentGenerators.cpp +++ b/core/vtk/ttkPersistentGenerators/ttkPersistentGenerators.cpp @@ -72,13 +72,13 @@ int ttkPersistentGenerators::dispatch(vtkPolyData *output, ccId->SetName("ComponentId"); vtkNew iFin{}; iFin->SetName(ttk::PersistenceIsFinite); - vtkSmartPointer pers{inputScalarsArray->NewInstance()}; + vtkSmartPointer const pers{inputScalarsArray->NewInstance()}; pers->SetName(ttk::PersistenceName); vtkNew mask{}; mask->SetName(ttk::MaskScalarFieldName); vtkNew vertsId{}; vertsId->SetName(ttk::VertexScalarFieldName); - vtkSmartPointer sf{inputScalarsArray->NewInstance()}; + vtkSmartPointer const sf{inputScalarsArray->NewInstance()}; sf->SetName(inputScalarsArray->GetName()); vtkNew nbOnBoundary{}; nbOnBoundary->SetNumberOfComponents(1); diff --git a/core/vtk/ttkPlanarGraphLayout/ttkMergeTreeVisualization.h b/core/vtk/ttkPlanarGraphLayout/ttkMergeTreeVisualization.h index 1865a3c721..45a6955d14 100644 --- a/core/vtk/ttkPlanarGraphLayout/ttkMergeTreeVisualization.h +++ b/core/vtk/ttkPlanarGraphLayout/ttkMergeTreeVisualization.h @@ -304,13 +304,14 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { for(unsigned int j = 0; j < cArraysValues[i].size(); ++j) { // Add value depending on type (vtkAbstractArray can not be used here) if(type == 0) { - double doubleValue = (*(std::vector *)&(cArraysValues[i]))[j]; + double const doubleValue + = (*(std::vector *)&(cArraysValues[i]))[j]; customDoubleArrayVtk->SetValue(j, doubleValue); } else if(type == 1) { - int intValue = (*(std::vector *)&(cArraysValues[i]))[j]; + int const intValue = (*(std::vector *)&(cArraysValues[i]))[j]; customIntArrayVtk->SetValue(j, intValue); } else { - std::string stringValue + std::string const stringValue = (*(std::vector *)&(cArraysValues[i]))[j]; customStringArrayVtk->SetValue(j, stringValue); } @@ -326,7 +327,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { std::vector &treeNodeIdRev) { double valueRange[2]; treeNodeIdArray->GetRange(valueRange); - int maxValue = valueRange[1]; + int const maxValue = valueRange[1]; treeNodeIdRev.clear(); treeNodeIdRev.resize(maxValue + 1); for(int i = 0; i < treeNodeIdArray->GetNumberOfValues(); ++i) @@ -409,7 +410,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { std::vector &barycenters) { int numInputs = trees.size(); int NumberOfBarycenters = barycenters.size(); - bool clusteringOutput = (NumberOfBarycenters != 0); + bool const clusteringOutput = (NumberOfBarycenters != 0); NumberOfBarycenters = std::max(NumberOfBarycenters, 1); // to always enter the outer loop if(not clusteringOutput) @@ -451,7 +452,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { vtkIdType pointIds[2]; idNode tree1NodeId = std::get<0>(match); idNode tree2NodeId = std::get<1>(match); - double cost = std::get<2>(match); + double const cost = std::get<2>(match); FTMTree_MT *tree1; FTMTree_MT *tree2 = trees[i]; if(not clusteringOutput) { @@ -462,16 +463,18 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Get first point printMsg("// Get first point", ttk::debug::Priority::VERBOSE); - SimplexId pointToGet1 = clusteringOutput ? nodeCorr2[c][tree1NodeId] - : nodeCorr1[0][tree1NodeId]; + SimplexId const pointToGet1 = clusteringOutput + ? nodeCorr2[c][tree1NodeId] + : nodeCorr1[0][tree1NodeId]; double *point1 = vtkOutputNode2->GetPoints()->GetPoint(pointToGet1); const SimplexId nextPointId1 = pointsM->InsertNextPoint(point1); pointIds[0] = nextPointId1; // Get second point printMsg("// Get second point", ttk::debug::Priority::VERBOSE); - SimplexId pointToGet2 = clusteringOutput ? nodeCorr1[i][tree2NodeId] - : nodeCorr1[1][tree2NodeId]; + SimplexId const pointToGet2 = clusteringOutput + ? nodeCorr1[i][tree2NodeId] + : nodeCorr1[1][tree2NodeId]; double *point2 = vtkOutputNode1->GetPoints()->GetPoint(pointToGet2); const SimplexId nextPointId2 = pointsM->InsertNextPoint(point2); pointIds[1] = nextPointId2; @@ -499,13 +502,13 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Add matching type printMsg("// Add matching type", ttk::debug::Priority::VERBOSE); int thisType = 0; - int tree1NodeDown + int const tree1NodeDown = tree1->getNode(tree1NodeId)->getNumberOfDownSuperArcs(); - int tree1NodeUp + int const tree1NodeUp = tree1->getNode(tree1NodeId)->getNumberOfUpSuperArcs(); - int tree2NodeDown + int const tree2NodeDown = tree2->getNode(tree2NodeId)->getNumberOfDownSuperArcs(); - int tree2NodeUp + int const tree2NodeUp = tree2->getNode(tree2NodeId)->getNumberOfUpSuperArcs(); if(tree1NodeDown != 0 and tree1NodeUp != 0 and tree2NodeDown != 0 and tree2NodeUp != 0) @@ -523,7 +526,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { "// Add mean matched persistence", ttk::debug::Priority::VERBOSE); double tree1Pers = tree1->getNodePersistence(tree1NodeId); double tree2Pers = tree2->getNodePersistence(tree2NodeId); - double meanPersistence = (tree1Pers + tree2Pers) / 2; + double const meanPersistence = (tree1Pers + tree2Pers) / 2; matchPers->InsertNextTuple1(meanPersistence); // Add cost @@ -575,12 +578,12 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { void makeTreesOutput(std::vector &trees, std::vector &barycenters) { int numInputs = trees.size(); - int numInputsOri = numInputs; + int const numInputsOri = numInputs; int NumberOfBarycenters = barycenters.size(); - bool clusteringOutput = (NumberOfBarycenters != 0); + bool const clusteringOutput = (NumberOfBarycenters != 0); NumberOfBarycenters = std::max(NumberOfBarycenters, 1); // to always enter the outer loop - bool embeddedDiagram = not PlanarLayout and isPersistenceDiagram; + bool const embeddedDiagram = not PlanarLayout and isPersistenceDiagram; // TreeNodeIdRev for(int i = 0; i < numInputs; ++i) { @@ -638,7 +641,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Make Trees Output // ---------------------------------------------------------------------- printMsg("--- Make Trees Output", ttk::debug::Priority::VERBOSE); - std::vector treesOri(trees); + std::vector const treesOri(trees); if(ShiftMode == 1) { // Star Barycenter trees.clear(); clusteringAssignment.clear(); @@ -780,7 +783,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Iterate through all clusters // -------------------------------------------------------- printMsg("Iterate through all clusters", ttk::debug::Priority::VERBOSE); - double importantPairsOriginal = importantPairs_; + double const importantPairsOriginal = importantPairs_; for(int c = 0; c < NumberOfBarycenters; ++c) { // Get persistence order @@ -791,7 +794,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { pairsBary; barycenters[c]->getPersistencePairsFromTree(pairsBary, false); for(unsigned int j = 0; j < pairsBary.size(); ++j) { - int index = pairsBary.size() - 1 - j; + int const index = pairsBary.size() - 1 - j; baryPersistenceOrder[std::get<0>(pairsBary[j])] = index; baryPersistenceOrder[std::get<1>(pairsBary[j])] = index; } @@ -810,7 +813,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { continue; noSample += 1; } - double radius = delta_max * 2 * DimensionSpacing; + double const radius = delta_max * 2 * DimensionSpacing; int iSample = 0 + iSampleOffset - 1; if(c < NumberOfBarycenters - 1) @@ -878,10 +881,10 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Get shift printMsg("// Get shift", ttk::debug::Priority::VERBOSE); - double angle = 360.0 / noSample * iSample; - double pi = M_PI; + double const angle = 360.0 / noSample * iSample; + double const pi = M_PI; double diff_x = 0, diff_y = 0; - double alphaShift + double const alphaShift = BarycenterPositionAlpha ? (-radius + 2 * radius * Alpha) * -1 : 0; switch(ShiftMode) { case -1: @@ -978,9 +981,9 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { std::queue queue; queue.emplace(trees[i]->getRoot()); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); - idNode nodeOrigin = trees[i]->getNode(node)->getOrigin(); + idNode const nodeOrigin = trees[i]->getNode(node)->getOrigin(); // Push children to the queue printMsg( @@ -1047,7 +1050,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Bary percentage matching if(ShiftMode == 1) { // Star Barycenter - float percentMatchT = noMatched * 100 / numInputs; + float const percentMatchT = noMatched * 100 / numInputs; allBaryPercentMatch[c][node] = percentMatchT; } @@ -1102,7 +1105,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { } } } - SimplexId nextPointId = points->InsertNextPoint(point); + SimplexId const nextPointId = points->InsertNextPoint(point); treeSimplexId[node] = nextPointId; nodeCorr[i][node] = nextPointId; if(dummyNode) @@ -1110,7 +1113,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { if(isPersistenceDiagram) nodeCorr[i][node] = nextPointId; - idNode nodeBranching + idNode const nodeBranching = ((PlanarLayout and branchDecompositionPlanarLayout_) or isPersistenceDiagram ? node @@ -1125,9 +1128,9 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { vtkIdType pointIds[2]; pointIds[0] = treeSimplexId[node]; - idNode nodeParent = trees[i]->getParentSafe(node); + idNode const nodeParent = trees[i]->getParentSafe(node); // TODO too many dummy cells are created - bool dummyCell + bool const dummyCell = PlanarLayout and not branchDecompositionPlanarLayout_ and (node < treeBranching.size() and treeBranching[node] == nodeParent) @@ -1140,7 +1143,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { double dummyPoint[3] = {point[0], layout[layoutCorr[nodeParent] + 1] + diff_y, 0. + diff_z}; - SimplexId dummyPointId = treeDummySimplexId[nodeParent]; + SimplexId const dummyPointId = treeDummySimplexId[nodeParent]; points->SetPoint(dummyPointId, dummyPoint); vtkIdType dummyPointIds[2]; dummyPointIds[0] = dummyPointId; @@ -1155,7 +1158,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // -------------- // Arc field // -------------- - int toAdd = (dummyCell ? 2 : 1); + int const toAdd = (dummyCell ? 2 : 1); for(int toAddT = 0; toAddT < toAdd; ++toAddT) { // Add arc matching percentage if(ShiftMode == 1) { // Star Barycenter @@ -1178,7 +1181,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Add branch ID if(not isPersistenceDiagram) { - int tBranchID = treeBranchingID[node]; + int const tBranchID = treeBranchingID[node]; branchID->InsertNextTuple1(tBranchID); } @@ -1191,14 +1194,14 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Add arc persistence printMsg( "// Push arc persistence", ttk::debug::Priority::VERBOSE); - idNode nodeToGetPers = nodeBranching; - double persToAdd + idNode const nodeToGetPers = nodeBranching; + double const persToAdd = trees[i]->getNodePersistence(nodeToGetPers); persistenceArc->InsertNextTuple1(persToAdd); // Add arc persistence barycenter and order if(clusteringOutput and ShiftMode != 1) { - idNode nodeToGet = nodeBranching; + idNode const nodeToGet = nodeBranching; if(treeMatching[nodeToGet] < allBaryBranchingID[c].size()) { persistenceBaryArc->InsertTuple1( cellCount, barycenters[c]->getNodePersistence( @@ -1216,7 +1219,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Add isImportantPair bool isImportant = false; - idNode nodeToGetImportance = nodeBranching; + idNode const nodeToGetImportance = nodeBranching; isImportant = trees[i]->isImportantPair( nodeToGetImportance, importantPairs_, excludeImportantPairsLowerValues_, @@ -1224,7 +1227,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { isImportantPairsArc->InsertNextTuple1(isImportant); // Add isDummyArc - bool isDummy = toAdd == 2 and toAddT == 0; + bool const isDummy = toAdd == 2 and toAddT == 0; isDummyArc->InsertNextTuple1(isDummy); // Add isInterpolatedTree @@ -1240,7 +1243,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { - std::get<0>(birthDeath)); // Add isMinMaxPair - bool isMinMaxPair + bool const isMinMaxPair = (trees[i]->isRoot(node) and not trees[i]->isLeaf(node)) or (trees[i]->isRoot(nodeOrigin) and not trees[i]->isLeaf(nodeOrigin)); @@ -1250,7 +1253,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { pairType->InsertNextTuple1(0); // Add isMultiPersPairArc - bool isMultiPersPair + bool const isMultiPersPair = (trees[i]->isMultiPersPair(nodeBranching) or trees[i]->isMultiPersPair( trees[i]->getNode(nodeBranching)->getOrigin())); @@ -1274,7 +1277,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // -------------- // Node field // -------------- - int toAdd = (dummyNode ? 2 : 1); + int const toAdd = (dummyNode ? 2 : 1); for(int toAddT = 0; toAddT < toAdd; ++toAddT) { // Add node id nodeID->InsertNextTuple1(treeSimplexId[node]); @@ -1329,8 +1332,8 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { ? (isPDSadMax or nodeIsRoot ? locMax : saddle1) : (not isPDSadMax or nodeIsRoot ? locMin : saddle2)); if(embeddedDiagram) { - bool nodeSup = trees[i]->getValue(node) - > trees[i]->getValue(nodeOrigin); + bool const nodeSup = trees[i]->getValue(node) + > trees[i]->getValue(nodeOrigin); criticalTypeT = ((nodeSup and toAddT == 1) or (not nodeSup and toAddT == 0) ? (isPDSadMax or nodeIsRoot ? locMax : saddle1) @@ -1389,7 +1392,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { treeIDNode->InsertNextTuple1(i + iSampleOffset); // Add isDummyNode - bool isDummy + bool const isDummy = toAdd == 2 and toAddT == 1 and !trees[i]->isRoot(node); isDummyNode->InsertNextTuple1(isDummy); @@ -1426,9 +1429,10 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { // Add isMultiPersPairArc printMsg("// isMultiPersPairArc", ttk::debug::Priority::VERBOSE); - bool isMultiPersPair = (trees[i]->isMultiPersPair(node) - or trees[i]->isMultiPersPair( - trees[i]->getNode(node)->getOrigin())); + bool const isMultiPersPair + = (trees[i]->isMultiPersPair(node) + or trees[i]->isMultiPersPair( + trees[i]->getNode(node)->getOrigin())); isMultiPersPairNode->InsertNextTuple1(isMultiPersPair); // Add custom arrays @@ -1467,7 +1471,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { for(unsigned int ca = 0; ca < customIntArrays.size(); ++ca) customCellIntArraysValues[ca].push_back(-1); for(unsigned int ca = 0; ca < customStringArrays.size(); ++ca) - customCellStringArraysValues[ca].push_back(""); + customCellStringArraysValues[ca].emplace_back(""); isMultiPersPairArc->InsertNextTuple1(0); clusterIDArc->InsertNextTuple1(clusteringAssignment[i]); @@ -1646,7 +1650,7 @@ class ttkMergeTreeVisualization : public ttk::MergeTreeVisualization { std::queue queue; queue.emplace(tree->getRoot()); while(!queue.empty()) { - idNode node = queue.front(); + idNode const node = queue.front(); queue.pop(); double *point = treeNodes->GetPoints()->GetPoint(nodeCorrT[node]); x_min = std::min(x_min, point[0]); diff --git a/core/vtk/ttkPlanarGraphLayout/ttkPlanarGraphLayout.cpp b/core/vtk/ttkPlanarGraphLayout/ttkPlanarGraphLayout.cpp index 0b8dcdeb70..6f7c78b8da 100644 --- a/core/vtk/ttkPlanarGraphLayout/ttkPlanarGraphLayout.cpp +++ b/core/vtk/ttkPlanarGraphLayout/ttkPlanarGraphLayout.cpp @@ -60,8 +60,8 @@ int ttkPlanarGraphLayout::planarGraphLayoutCall( // Copy input to output output->ShallowCopy(input); - size_t nPoints = output->GetNumberOfPoints(); - size_t nEdges = output->GetNumberOfCells(); + size_t const nPoints = output->GetNumberOfPoints(); + size_t const nEdges = output->GetNumberOfCells(); // Get input arrays auto sequenceArray = this->GetInputArrayToProcess(0, inputVector); diff --git a/core/vtk/ttkPointDataConverter/ttkPointDataConverter.cpp b/core/vtk/ttkPointDataConverter/ttkPointDataConverter.cpp index 6e49f3b755..d78889fc10 100644 --- a/core/vtk/ttkPointDataConverter/ttkPointDataConverter.cpp +++ b/core/vtk/ttkPointDataConverter/ttkPointDataConverter.cpp @@ -54,8 +54,8 @@ int ttkPointDataConverter::convert(vtkDataArray *inputData, vtkDataSet *output) { const auto input_ptr = static_cast(ttkUtils::GetVoidPointer(inputData)); - int n = inputData->GetNumberOfComponents(); - vtkIdType N = inputData->GetNumberOfTuples(); + int const n = inputData->GetNumberOfComponents(); + vtkIdType const N = inputData->GetNumberOfTuples(); vtkNew outputData; outputData->SetName(inputData->GetName()); @@ -106,7 +106,7 @@ int ttkPointDataConverter::RequestData(vtkInformation *ttkNotUsed(request), } auto InputType = inputScalarField->GetDataType(); - bool oldUseNormalization{UseNormalization}; + bool const oldUseNormalization{UseNormalization}; if(OutputType == SupportedType::Float or OutputType == SupportedType::Double) UseNormalization = false; diff --git a/core/vtk/ttkPointDataSelector/ttkPointDataSelector.cpp b/core/vtk/ttkPointDataSelector/ttkPointDataSelector.cpp index 240a8dd45d..dd7a0401aa 100644 --- a/core/vtk/ttkPointDataSelector/ttkPointDataSelector.cpp +++ b/core/vtk/ttkPointDataSelector/ttkPointDataSelector.cpp @@ -38,7 +38,7 @@ int ttkPointDataSelector::FillOutputPortInformation(int port, } void ttkPointDataSelector::FillAvailableFields(vtkDataSet *input) { - int nbScalars = input->GetPointData()->GetNumberOfArrays(); + int const nbScalars = input->GetPointData()->GetNumberOfArrays(); AvailableFields.clear(); AvailableFields.resize(nbScalars); for(int i = 0; i < nbScalars; ++i) { @@ -92,7 +92,7 @@ int ttkPointDataSelector::RequestData(vtkInformation *ttkNotUsed(request), continue; } // check bounds in the range - std::ptrdiff_t pos + std::ptrdiff_t const pos = std::find(AvailableFields.begin(), AvailableFields.end(), scalar) - AvailableFields.begin(); if(pos < RangeId[0] || pos > RangeId[1]) { @@ -112,7 +112,8 @@ int ttkPointDataSelector::RequestData(vtkInformation *ttkNotUsed(request), return 0; } - vtkSmartPointer localFieldCopy{arr->NewInstance()}; + vtkSmartPointer const localFieldCopy{ + arr->NewInstance()}; if(localFieldCopy) { localFieldCopy->DeepCopy(arr); localFieldCopy->SetName(SelectedFieldName.data()); diff --git a/core/vtk/ttkPointMerger/ttkPointMerger.cpp b/core/vtk/ttkPointMerger/ttkPointMerger.cpp index 0d905f1bc7..f8e9acad64 100644 --- a/core/vtk/ttkPointMerger/ttkPointMerger.cpp +++ b/core/vtk/ttkPointMerger/ttkPointMerger.cpp @@ -58,7 +58,7 @@ int ttkPointMerger::RequestData(vtkInformation *ttkNotUsed(request), triangulation->preconditionBoundaryVertices(); } - SimplexId vertexNumber = input->GetNumberOfPoints(); + SimplexId const vertexNumber = input->GetNumberOfPoints(); std::vector candidateVertices; if(BoundaryOnly) { @@ -85,13 +85,13 @@ int ttkPointMerger::RequestData(vtkInformation *ttkNotUsed(request), double distance = -1; std::array p0{}; - SimplexId vertexId0 = candidateVertices[i]; + SimplexId const vertexId0 = candidateVertices[i]; input->GetPoint(vertexId0, p0.data()); for(SimplexId j = 0; j < (SimplexId)candidateVertices.size(); j++) { if(i != j) { std::array p1{}; - SimplexId vertexId1 = candidateVertices[j]; + SimplexId const vertexId1 = candidateVertices[j]; input->GetPoint(vertexId1, p1.data()); distance = ttk::Geometry::distance(p0.data(), p1.data()); if(distance < DistanceThreshold) { @@ -128,7 +128,7 @@ int ttkPointMerger::RequestData(vtkInformation *ttkNotUsed(request), std::array p0{}, p1{}; input->GetPoint(i, p0.data()); input->GetPoint(targetVertexId, p1.data()); - double distance = ttk::Geometry::distance(p0.data(), p1.data()); + double const distance = ttk::Geometry::distance(p0.data(), p1.data()); if((minMergeDistance[targetVertexId] == -1) || (distance < minMergeDistance[targetVertexId])) { minMergeDistance[targetVertexId] = distance; @@ -224,7 +224,7 @@ int ttkPointMerger::RequestData(vtkInformation *ttkNotUsed(request), std::vector newVertexIds; for(int j = 0; j < c->GetNumberOfPoints(); j++) { - SimplexId vertexId = old2new[c->GetPointId(j)]; + SimplexId const vertexId = old2new[c->GetPointId(j)]; bool isIn = false; for(SimplexId k = 0; k < (SimplexId)newVertexIds.size(); k++) { if(newVertexIds[k] == vertexId) { diff --git a/core/vtk/ttkProgramBase/ttkProgramBase.cpp b/core/vtk/ttkProgramBase/ttkProgramBase.cpp index 768a499e1c..6066313ce3 100644 --- a/core/vtk/ttkProgramBase/ttkProgramBase.cpp +++ b/core/vtk/ttkProgramBase/ttkProgramBase.cpp @@ -24,7 +24,7 @@ int ttkProgramBase::load(const std::vector &inputPaths) { for(int i = 0; i < (int)inputPaths.size(); i++) { - string extension + string const extension = inputPaths[i].substr(inputPaths[i].find_last_of('.') + 1); if(extension == "vti") { diff --git a/core/vtk/ttkProgramBase/ttkProgramBase.h b/core/vtk/ttkProgramBase/ttkProgramBase.h index 4f23d20a61..936ed543d4 100644 --- a/core/vtk/ttkProgramBase/ttkProgramBase.h +++ b/core/vtk/ttkProgramBase/ttkProgramBase.h @@ -146,7 +146,7 @@ int ttkProgramBase::save(const int &outputPortId) const { std::stringstream fileName; fileName << outputPath_ << "_port#" << outputPortId << "." << extension; - vtkSmartPointer writer + vtkSmartPointer const writer = vtkSmartPointer::New(); writer->SetFileName(fileName.str().data()); writer->SetInputData(vtkWrapper_->GetOutput(outputPortId)); diff --git a/core/vtk/ttkProjectionFromField/ttkProjectionFromField.cpp b/core/vtk/ttkProjectionFromField/ttkProjectionFromField.cpp index 22ed20ec91..8ad9edef97 100644 --- a/core/vtk/ttkProjectionFromField/ttkProjectionFromField.cpp +++ b/core/vtk/ttkProjectionFromField/ttkProjectionFromField.cpp @@ -45,7 +45,7 @@ int ttkProjectionFromField::projectPersistenceDiagram( // ensure we have the right arrays const auto critCoordinates = vtkFloatArray::SafeDownCast( pointData->GetAbstractArray(ttk::PersistenceCoordinatesName)); - bool embed = critCoordinates == nullptr; + bool const embed = critCoordinates == nullptr; int ret{0}; if(embed) { diff --git a/core/vtk/ttkProjectionFromTable/ttkProjectionFromTable.cpp b/core/vtk/ttkProjectionFromTable/ttkProjectionFromTable.cpp index 2d7e2aada7..cebef6072d 100644 --- a/core/vtk/ttkProjectionFromTable/ttkProjectionFromTable.cpp +++ b/core/vtk/ttkProjectionFromTable/ttkProjectionFromTable.cpp @@ -233,7 +233,7 @@ int ttkProjectionFromTable::RequestData(vtkInformation *ttkNotUsed(request), // Merge data of arrays in surface also in table or add empty data for(int j = 0; j < output->GetPointData()->GetNumberOfArrays(); ++j) { auto outputArray = output->GetPointData()->GetAbstractArray(j); - std::string name = outputArray->GetName(); + std::string const name = outputArray->GetName(); auto array = coefficients->GetColumnByName(name.c_str()); if(array) { outputArray->InsertNextTuple(i, array); @@ -253,7 +253,7 @@ int ttkProjectionFromTable::RequestData(vtkInformation *ttkNotUsed(request), } } - int noPointsOri = output->GetNumberOfPoints() - inputPoints.size(); + int const noPointsOri = output->GetNumberOfPoints() - inputPoints.size(); // Merge data of arrays in table also in surface or add empty data std::set toGet; @@ -261,7 +261,7 @@ int ttkProjectionFromTable::RequestData(vtkInformation *ttkNotUsed(request), auto inputArray = coefficients->GetColumn(j); auto dataArray = vtkDataArray::SafeDownCast(inputArray); auto stringArray = vtkStringArray::SafeDownCast(inputArray); - std::string name = inputArray->GetName(); + std::string const name = inputArray->GetName(); auto array = output->GetPointData()->GetAbstractArray(name.c_str()); if(not array and (dataArray or stringArray)) toGet.insert(name); @@ -278,7 +278,7 @@ int ttkProjectionFromTable::RequestData(vtkInformation *ttkNotUsed(request), // if is surface if(i < noPointsOri) { if(dataArray) { - double val = std::nan(""); + double const val = std::nan(""); dataArray->SetTuple1(i, val); } else if(stringArray) { stringArray->SetValue(i, ""); @@ -300,7 +300,7 @@ int ttkProjectionFromTable::RequestData(vtkInformation *ttkNotUsed(request), isSurfaceArray->SetName("isSurface"); isSurfaceArray->SetNumberOfTuples(output->GetNumberOfPoints()); for(int i = 0; i < output->GetNumberOfPoints(); ++i) { - bool isSurface = (i < noPointsOri); + bool const isSurface = (i < noPointsOri); isSurfaceArray->SetTuple1(i, isSurface); } output->GetPointData()->AddArray(isSurfaceArray); diff --git a/core/vtk/ttkRangePolygon/ttkRangePolygon.cpp b/core/vtk/ttkRangePolygon/ttkRangePolygon.cpp index 8c225bf31f..ddc43d41c9 100644 --- a/core/vtk/ttkRangePolygon/ttkRangePolygon.cpp +++ b/core/vtk/ttkRangePolygon/ttkRangePolygon.cpp @@ -75,15 +75,15 @@ int ttkRangePolygon::processPoints(vtkUnstructuredGrid *input, Timer t; - vtkSmartPointer pointSet = vtkSmartPointer::New(); + vtkSmartPointer const pointSet = vtkSmartPointer::New(); output->SetPoints(pointSet); output->GetPoints()->ShallowCopy(input->GetPoints()); output->GetPointData()->ShallowCopy(input->GetPointData()); - vtkSmartPointer edgeArray + vtkSmartPointer const edgeArray = vtkSmartPointer::New(); - vtkSmartPointer idList = vtkSmartPointer::New(); + vtkSmartPointer const idList = vtkSmartPointer::New(); idList->SetNumberOfIds(2); for(SimplexId i = 0; i < input->GetNumberOfPoints(); i++) { @@ -113,17 +113,17 @@ int ttkRangePolygon::processTriangles(vtkUnstructuredGrid *input, Timer t; - vtkSmartPointer surfaceMaker + vtkSmartPointer const surfaceMaker = vtkSmartPointer::New(); surfaceMaker->SetInputData(input); - vtkSmartPointer surfaceCleaner + vtkSmartPointer const surfaceCleaner = vtkSmartPointer::New(); surfaceCleaner->SetInputConnection(surfaceMaker->GetOutputPort()); - vtkSmartPointer featureEdges + vtkSmartPointer const featureEdges = vtkSmartPointer::New(); featureEdges->SetBoundaryEdges(true); @@ -133,7 +133,7 @@ int ttkRangePolygon::processTriangles(vtkUnstructuredGrid *input, featureEdges->SetColoring(false); featureEdges->SetInputConnection(surfaceCleaner->GetOutputPort()); - vtkSmartPointer triangleMaker + vtkSmartPointer const triangleMaker = vtkSmartPointer::New(); triangleMaker->SetInputConnection(featureEdges->GetOutputPort()); diff --git a/core/vtk/ttkReebSpace/ttkReebSpace.cpp b/core/vtk/ttkReebSpace/ttkReebSpace.cpp index 50409375a2..c848cf908d 100644 --- a/core/vtk/ttkReebSpace/ttkReebSpace.cpp +++ b/core/vtk/ttkReebSpace/ttkReebSpace.cpp @@ -47,7 +47,7 @@ int ttkReebSpace::dispatch(const dataTypeU *const uField, const dataTypeV *const vField, ttk::Triangulation *const triangulation) { - bool VaryingValues = this->setRangeDrivenOctree(UseOctreeAcceleration); + bool const VaryingValues = this->setRangeDrivenOctree(UseOctreeAcceleration); bool VaryingTriangulation = false; if(triangulation->isEmpty()) @@ -145,7 +145,7 @@ int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request), const auto sheet0segmentation = this->get0sheetSegmentation(); int vertexNumber = 0; for(size_t i = 0; i < sheet0segmentation->size(); i++) { - int sheet0Id = (*sheet0segmentation)[i]; + int const sheet0Id = (*sheet0segmentation)[i]; if(sheet0Id != -1) { const ReebSpace::Sheet0 *sheet = this->get0sheet(sheet0Id); if(sheet != nullptr && !sheet->pruned_) { @@ -153,7 +153,7 @@ int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request), } } } - vtkNew sheet0Points{}; + vtkNew const sheet0Points{}; if(!sheet0->GetPoints()) sheet0->SetPoints(sheet0Points); @@ -198,7 +198,7 @@ int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request), vertexNumber = 0; double *p = nullptr; for(size_t i = 0; i < sheet0segmentation->size(); i++) { - int sheet0Id = (*sheet0segmentation)[i]; + int const sheet0Id = (*sheet0segmentation)[i]; if(sheet0Id != -1) { const ReebSpace::Sheet0 *sheet = this->get0sheet(sheet0Id); @@ -250,7 +250,7 @@ int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request), // CellData: edgeId, type, sheetId const auto sheet1segmentation = this->get1sheetSegmentation(); - vtkNew sheet1Points{}; + vtkNew const sheet1Points{}; sheet1->SetPoints(sheet1Points); vtkNew sheet1Edges{}; @@ -301,7 +301,7 @@ int ttkReebSpace::RequestData(vtkInformation *ttkNotUsed(request), for(size_t i = 0; i < sheet1segmentation->size(); i++) { - int sheet1Id = (*sheet1segmentation)[i]; + int const sheet1Id = (*sheet1segmentation)[i]; if(sheet1Id != -1) { diff --git a/core/vtk/ttkRipsComplex/ttkRipsComplex.cpp b/core/vtk/ttkRipsComplex/ttkRipsComplex.cpp index 6dd03e0d5d..a057ce72f3 100644 --- a/core/vtk/ttkRipsComplex/ttkRipsComplex.cpp +++ b/core/vtk/ttkRipsComplex/ttkRipsComplex.cpp @@ -108,6 +108,7 @@ int ttkRipsComplex::RequestData(vtkInformation *ttkNotUsed(request), } std::vector arrays{}; + arrays.reserve(ScalarFields.size()); for(const auto &s : ScalarFields) { arrays.push_back(input->GetColumnByName(s.data())); } diff --git a/core/vtk/ttkScalarFieldCriticalPoints/ttkScalarFieldCriticalPoints.cpp b/core/vtk/ttkScalarFieldCriticalPoints/ttkScalarFieldCriticalPoints.cpp index 5b488357a9..4ceedb7383 100644 --- a/core/vtk/ttkScalarFieldCriticalPoints/ttkScalarFieldCriticalPoints.cpp +++ b/core/vtk/ttkScalarFieldCriticalPoints/ttkScalarFieldCriticalPoints.cpp @@ -57,7 +57,7 @@ int ttkScalarFieldCriticalPoints::RequestData( ttk::Triangulation *triangulation = ttkAlgorithm::GetTriangulation(input); - int keepGoing = checkEmptyMPIInput(triangulation); + int const keepGoing = checkEmptyMPIInput(triangulation); if(keepGoing < 2) { return keepGoing; } @@ -176,7 +176,8 @@ int ttkScalarFieldCriticalPoints::RequestData( for(SimplexId i = 0; i < input->GetPointData()->GetNumberOfArrays(); i++) { vtkDataArray *scalarField = input->GetPointData()->GetArray(i); - vtkSmartPointer scalarArray{scalarField->NewInstance()}; + vtkSmartPointer const scalarArray{ + scalarField->NewInstance()}; scalarArray->SetNumberOfComponents(scalarField->GetNumberOfComponents()); scalarArray->SetNumberOfTuples(criticalPoints_.size()); diff --git a/core/vtk/ttkScalarFieldNormalizer/ttkScalarFieldNormalizer.cpp b/core/vtk/ttkScalarFieldNormalizer/ttkScalarFieldNormalizer.cpp index 251bc60c55..097f7a659a 100644 --- a/core/vtk/ttkScalarFieldNormalizer/ttkScalarFieldNormalizer.cpp +++ b/core/vtk/ttkScalarFieldNormalizer/ttkScalarFieldNormalizer.cpp @@ -57,7 +57,7 @@ int ttkScalarFieldNormalizer::normalize(vtkDataArray *input, double min = 0, max = 0; for(SimplexId i = 0; i < input->GetNumberOfTuples(); i++) { - double value = input->GetTuple1(i); + double const value = input->GetTuple1(i); if((!i) || (value < min)) { min = value; @@ -97,12 +97,13 @@ int ttkScalarFieldNormalizer::RequestData(vtkInformation *ttkNotUsed(request), // get input scalar field vtkDataArray *inputArray = this->GetInputArrayToProcess(0, inputVector); - int keepGoing = ttkAlgorithm::checkEmptyMPIInput(inputArray); + int const keepGoing + = ttkAlgorithm::checkEmptyMPIInput(inputArray); if(keepGoing < 2) { return keepGoing; } - vtkSmartPointer outputArray + vtkSmartPointer const outputArray = vtkSmartPointer::Take(inputArray->NewInstance()); outputArray->SetName(inputArray->GetName()); outputArray->SetNumberOfComponents(1); diff --git a/core/vtk/ttkScalarFieldSmoother/ttkScalarFieldSmoother.cpp b/core/vtk/ttkScalarFieldSmoother/ttkScalarFieldSmoother.cpp index de48a35900..a34cb1c983 100644 --- a/core/vtk/ttkScalarFieldSmoother/ttkScalarFieldSmoother.cpp +++ b/core/vtk/ttkScalarFieldSmoother/ttkScalarFieldSmoother.cpp @@ -48,7 +48,7 @@ int ttkScalarFieldSmoother::RequestData(vtkInformation *ttkNotUsed(request), Triangulation *triangulation = ttkAlgorithm::GetTriangulation(input); - int keepGoing = checkEmptyMPIInput(triangulation); + int const keepGoing = checkEmptyMPIInput(triangulation); if(keepGoing < 2) { return keepGoing; } @@ -70,7 +70,7 @@ int ttkScalarFieldSmoother::RequestData(vtkInformation *ttkNotUsed(request), ForceInputMaskScalarField, 1, ttk::MaskScalarFieldName, input); // preparing the output - vtkSmartPointer outputArray + vtkSmartPointer const outputArray = vtkSmartPointer::Take(inputScalarField->NewInstance()); outputArray->SetName(inputScalarField->GetName()); outputArray->SetNumberOfComponents(1); diff --git a/core/vtk/ttkSphereFromPoint/ttkSphereFromPoint.cpp b/core/vtk/ttkSphereFromPoint/ttkSphereFromPoint.cpp index 2d5a8eb9c4..53085ef13f 100644 --- a/core/vtk/ttkSphereFromPoint/ttkSphereFromPoint.cpp +++ b/core/vtk/ttkSphereFromPoint/ttkSphereFromPoint.cpp @@ -96,7 +96,7 @@ int ttkSphereFromPoint::RequestData(vtkInformation *ttkNotUsed(request), sphereList_.resize(input->GetNumberOfPoints()); } else if((SimplexId)sphereList_.size() < input->GetNumberOfPoints()) { - SimplexId oldSize = sphereList_.size(); + SimplexId const oldSize = sphereList_.size(); sphereList_.resize(input->GetNumberOfPoints()); diff --git a/core/vtk/ttkStableManifoldPersistence/ttkStableManifoldPersistence.cpp b/core/vtk/ttkStableManifoldPersistence/ttkStableManifoldPersistence.cpp index 781c08a945..59bc5d15b8 100644 --- a/core/vtk/ttkStableManifoldPersistence/ttkStableManifoldPersistence.cpp +++ b/core/vtk/ttkStableManifoldPersistence/ttkStableManifoldPersistence.cpp @@ -78,17 +78,17 @@ int ttkStableManifoldPersistence::AttachPersistence(vtkDataSet *output) const { if((ascendingManifoldArray) || (descendingManifoldArray)) isSegmentation = true; - vtkSmartPointer persistenceArray + vtkSmartPointer const persistenceArray = vtkSmartPointer::New(); persistenceArray->SetName(ttk::PersistenceName); - vtkSmartPointer pairTypeArray + vtkSmartPointer const pairTypeArray = vtkSmartPointer::New(); pairTypeArray->SetName(ttk::PersistencePairTypeName); if(!isSegmentation) { - int cellNumber = output->GetNumberOfCells(); + int const cellNumber = output->GetNumberOfCells(); persistenceArray->SetNumberOfTuples(cellNumber); pairTypeArray->SetNumberOfTuples(cellNumber); @@ -103,8 +103,8 @@ int ttkStableManifoldPersistence::AttachPersistence(vtkDataSet *output) const { } else { sourceArray->GetTuple(i, &cellId); } - double persistence = simplex2persistence_[(int)cellId]; - double pairType = simplex2pairType_[(int)cellId]; + double const persistence = simplex2persistence_[(int)cellId]; + double const pairType = simplex2pairType_[(int)cellId]; persistenceArray->SetTuple(i, &persistence); pairTypeArray->SetTuple(i, &pairType); } @@ -119,7 +119,7 @@ int ttkStableManifoldPersistence::AttachPersistence(vtkDataSet *output) const { return -4; } - int vertexNumber = output->GetNumberOfPoints(); + int const vertexNumber = output->GetNumberOfPoints(); persistenceArray->SetNumberOfTuples(vertexNumber); pairTypeArray->SetNumberOfTuples(vertexNumber); @@ -137,8 +137,8 @@ int ttkStableManifoldPersistence::AttachPersistence(vtkDataSet *output) const { ascendingManifoldArray->GetTuple(i, &extremumId); cellId = max2simplex_[(int)extremumId]; } - double persistence = simplex2persistence_[cellId]; - double pairType = simplex2pairType_[cellId]; + double const persistence = simplex2persistence_[cellId]; + double const pairType = simplex2pairType_[cellId]; persistenceArray->SetTuple(i, &persistence); pairTypeArray->SetTuple(i, &pairType); } @@ -191,11 +191,11 @@ int ttkStableManifoldPersistence::BuildSimplex2PersistenceMap( return -2; } - int maximumVertexId = vertexIdArray->GetMaxNorm(); + int const maximumVertexId = vertexIdArray->GetMaxNorm(); std::vector vertex2persistence(maximumVertexId + 1, -1); std::vector vertex2pairType(maximumVertexId + 1, -1); - int cellNumber = persistenceDiagram->GetNumberOfCells(); + int const cellNumber = persistenceDiagram->GetNumberOfCells(); // NOTE: multi-saddle prevent a parallel loop here. for(int i = 0; i < cellNumber; i++) { @@ -208,8 +208,8 @@ int ttkStableManifoldPersistence::BuildSimplex2PersistenceMap( vtkNew c; persistenceDiagram->GetCell(i, c); - int pointId0 = c->GetPointId(0); - int pointId1 = c->GetPointId(1); + int const pointId0 = c->GetPointId(0); + int const pointId1 = c->GetPointId(1); double persistence = -1; persistenceArray->GetTuple(i, &persistence); @@ -232,11 +232,11 @@ int ttkStableManifoldPersistence::BuildSimplex2PersistenceMap( } } - int maximumSimplexId = criticalCellIdArray->GetMaxNorm(); + int const maximumSimplexId = criticalCellIdArray->GetMaxNorm(); simplex2persistence_.resize(maximumSimplexId + 1, -1); simplex2pairType_.resize(maximumSimplexId + 1, -1); - int criticalPointNumber = criticalCellIdArray->GetNumberOfTuples(); + int const criticalPointNumber = criticalCellIdArray->GetNumberOfTuples(); #ifdef TTK_ENABLE_OPENMP #pragma omp parallel for num_threads(threadNumber_) #endif @@ -256,7 +256,7 @@ int ttkStableManifoldPersistence::BuildSimplex2PersistenceMap( // useful if the module is called on the segmentation output of the // morse-smale complex; then, we'll get the dimension right). if(stableManifold->GetNumberOfCells()) { - int cellType = stableManifold->GetCellType(0); + int const cellType = stableManifold->GetCellType(0); int dimension = -1; if((cellType == VTK_TETRA) || (cellType == VTK_VOXEL)) dimension = 3; diff --git a/core/vtk/ttkTableDataSelector/ttkTableDataSelector.cpp b/core/vtk/ttkTableDataSelector/ttkTableDataSelector.cpp index 018659f7c6..3577df0bda 100644 --- a/core/vtk/ttkTableDataSelector/ttkTableDataSelector.cpp +++ b/core/vtk/ttkTableDataSelector/ttkTableDataSelector.cpp @@ -57,7 +57,7 @@ int ttkTableDataSelector::RequestData(vtkInformation *ttkNotUsed(request), } #endif - vtkSmartPointer outputRowData + vtkSmartPointer const outputRowData = vtkSmartPointer::New(); #ifndef TTK_ENABLE_KAMIKAZE if(!outputRowData) { @@ -77,8 +77,8 @@ int ttkTableDataSelector::RequestData(vtkInformation *ttkNotUsed(request), continue; } // check bounds in the range - ptrdiff_t pos = find(AvailableCols.begin(), AvailableCols.end(), col) - - AvailableCols.begin(); + ptrdiff_t const pos = find(AvailableCols.begin(), AvailableCols.end(), col) + - AvailableCols.begin(); if(pos < RangeId[0] || pos > RangeId[1]) { continue; } @@ -104,7 +104,7 @@ int ttkTableDataSelector::RequestData(vtkInformation *ttkNotUsed(request), } void ttkTableDataSelector::FillAvailableCols(vtkTable *input) { - int nbColumns = input->GetNumberOfColumns(); + int const nbColumns = input->GetNumberOfColumns(); AvailableCols.clear(); AvailableCols.resize(nbColumns); for(int i = 0; i < nbColumns; ++i) { diff --git a/core/vtk/ttkTableDistanceMatrix/ttkTableDistanceMatrix.cpp b/core/vtk/ttkTableDistanceMatrix/ttkTableDistanceMatrix.cpp index 4a4e1ba405..e0fca91a38 100644 --- a/core/vtk/ttkTableDistanceMatrix/ttkTableDistanceMatrix.cpp +++ b/core/vtk/ttkTableDistanceMatrix/ttkTableDistanceMatrix.cpp @@ -68,6 +68,7 @@ int ttkTableDistanceMatrix::RequestData(vtkInformation * /*request*/, } std::vector arrays{}; + arrays.reserve(ScalarFields.size()); for(const auto &s : ScalarFields) { arrays.push_back(input->GetColumnByName(s.data())); } @@ -93,9 +94,9 @@ int ttkTableDistanceMatrix::RequestData(vtkInformation * /*request*/, // zero-padd column name to keep Row Data columns ordered const auto zeroPad = [](std::string &colName, const size_t numberCols, const size_t colIdx) { - std::string max{std::to_string(numberCols - 1)}; - std::string cur{std::to_string(colIdx)}; - std::string zer(max.size() - cur.size(), '0'); + std::string const max{std::to_string(numberCols - 1)}; + std::string const cur{std::to_string(colIdx)}; + std::string const zer(max.size() - cur.size(), '0'); colName.append(zer).append(cur); }; diff --git a/core/vtk/ttkTopologicalCompressionReader/ttkTopologicalCompressionReader.cpp b/core/vtk/ttkTopologicalCompressionReader/ttkTopologicalCompressionReader.cpp index b220cbceda..befd0e0cf1 100644 --- a/core/vtk/ttkTopologicalCompressionReader/ttkTopologicalCompressionReader.cpp +++ b/core/vtk/ttkTopologicalCompressionReader/ttkTopologicalCompressionReader.cpp @@ -108,10 +108,10 @@ int ttkTopologicalCompressionReader::RequestData( DataExtent[i] = this->getDataExtent()[i]; DataExtent[3 + i] = this->getDataExtent()[3 + i]; } - int nx = 1 + DataExtent[1] - DataExtent[0]; - int ny = 1 + DataExtent[3] - DataExtent[2]; - int nz = 1 + DataExtent[5] - DataExtent[4]; - int vertexNumber = nx * ny * nz; + int const nx = 1 + DataExtent[1] - DataExtent[0]; + int const ny = 1 + DataExtent[3] - DataExtent[2]; + int const nz = 1 + DataExtent[5] - DataExtent[4]; + int const vertexNumber = nx * ny * nz; ZFPOnly = this->getZFPOnly(); vtkNew mesh{}; @@ -179,9 +179,9 @@ vtkImageData *ttkTopologicalCompressionReader::GetOutput() { } void ttkTopologicalCompressionReader::BuildMesh(vtkImageData *mesh) const { - int nx = 1 + DataExtent[1] - DataExtent[0]; - int ny = 1 + DataExtent[3] - DataExtent[2]; - int nz = 1 + DataExtent[5] - DataExtent[4]; + int const nx = 1 + DataExtent[1] - DataExtent[0]; + int const ny = 1 + DataExtent[3] - DataExtent[2]; + int const nz = 1 + DataExtent[5] - DataExtent[4]; mesh->SetDimensions(nx, ny, nz); mesh->SetSpacing(DataSpacing[0], DataSpacing[1], DataSpacing[2]); mesh->SetOrigin(DataOrigin[0], DataOrigin[1], DataOrigin[2]); diff --git a/core/vtk/ttkTopologicalCompressionWriter/ttkTopologicalCompressionWriter.cpp b/core/vtk/ttkTopologicalCompressionWriter/ttkTopologicalCompressionWriter.cpp index f864f3b1ec..308074a4d4 100644 --- a/core/vtk/ttkTopologicalCompressionWriter/ttkTopologicalCompressionWriter.cpp +++ b/core/vtk/ttkTopologicalCompressionWriter/ttkTopologicalCompressionWriter.cpp @@ -105,7 +105,7 @@ int ttkTopologicalCompressionWriter::Write() { return 0; } - int dt = inputScalarField->GetDataType(); + int const dt = inputScalarField->GetDataType(); auto vp = static_cast(ttkUtils::GetVoidPointer(inputScalarField)); this->setFileName(FileName); diff --git a/core/vtk/ttkTopologicalSimplification/ttkTopologicalSimplification.cpp b/core/vtk/ttkTopologicalSimplification/ttkTopologicalSimplification.cpp index ea32fe55eb..86c4c0c882 100644 --- a/core/vtk/ttkTopologicalSimplification/ttkTopologicalSimplification.cpp +++ b/core/vtk/ttkTopologicalSimplification/ttkTopologicalSimplification.cpp @@ -109,7 +109,7 @@ int ttkTopologicalSimplification::RequestData( outputOrder->DeepCopy(inputOrder); // constraint identifier field - int numberOfConstraints = constraints->GetNumberOfPoints(); + int const numberOfConstraints = constraints->GetNumberOfPoints(); std::vector idSpareStorage{}; auto identifiers = this->GetIdentifierArrayPtr(ForceInputVertexScalarField, 1, diff --git a/core/vtk/ttkTrackingFromFields/ttkTrackingFromFields.cpp b/core/vtk/ttkTrackingFromFields/ttkTrackingFromFields.cpp index 1e0a7934e9..8888b35eac 100644 --- a/core/vtk/ttkTrackingFromFields/ttkTrackingFromFields.cpp +++ b/core/vtk/ttkTrackingFromFields/ttkTrackingFromFields.cpp @@ -49,10 +49,10 @@ int ttkTrackingFromFields::trackWithPersistenceMatching( // 2. call feature tracking with threshold. std::vector> outputMatchings(fieldNumber - 1); - double spacing = Spacing; - std::string algorithm = DistanceAlgorithm; - double tolerance = Tolerance; - std::string wasserstein = WassersteinMetric; + double const spacing = Spacing; + std::string const algorithm = DistanceAlgorithm; + double const tolerance = Tolerance; + std::string const wasserstein = WassersteinMetric; ttk::TrackingFromPersistenceDiagrams tfp{}; tfp.setThreadNumber(this->threadNumber_); @@ -63,8 +63,8 @@ int ttkTrackingFromFields::trackWithPersistenceMatching( wasserstein, tolerance, PX, PY, PZ, PS, PE // Coefficients ); - vtkNew points{}; - vtkNew persistenceDiagram{}; + vtkNew const points{}; + vtkNew const persistenceDiagram{}; vtkNew persistenceScalars{}; vtkNew valueScalars{}; @@ -93,7 +93,7 @@ int ttkTrackingFromFields::trackWithPersistenceMatching( trackingTupleToMerged, PostProcThresh); } - bool useGeometricSpacing = UseGeometricSpacing; + bool const useGeometricSpacing = UseGeometricSpacing; // Build mesh. ttkTrackingFromPersistenceDiagrams::buildMesh( @@ -142,7 +142,7 @@ int ttkTrackingFromFields::RequestData(vtkInformation *ttkNotUsed(request), || currentScalarField->GetName() == nullptr) { continue; } - std::string sfname{currentScalarField->GetName()}; + std::string const sfname{currentScalarField->GetName()}; if(sfname.rfind("_Order") == (sfname.size() - 6)) { continue; } @@ -164,8 +164,8 @@ int ttkTrackingFromFields::RequestData(vtkInformation *ttkNotUsed(request), }); numberOfInputFields = inputScalarFieldsRaw.size(); - int end = EndTimestep <= 0 ? numberOfInputFields - : std::min(numberOfInputFields, EndTimestep); + int const end = EndTimestep <= 0 ? numberOfInputFields + : std::min(numberOfInputFields, EndTimestep); for(int i = StartTimestep; i < end; i += Sampling) { vtkDataArray *currentScalarField = inputScalarFieldsRaw[i]; // Print scalar field names: @@ -174,8 +174,8 @@ int ttkTrackingFromFields::RequestData(vtkInformation *ttkNotUsed(request), } // Input -> persistence filter. - std::string algorithm = DistanceAlgorithm; - int pvalg = PVAlgorithm; + std::string const algorithm = DistanceAlgorithm; + int const pvalg = PVAlgorithm; bool useTTKMethod = false; if(pvalg >= 0) { @@ -215,7 +215,7 @@ int ttkTrackingFromFields::RequestData(vtkInformation *ttkNotUsed(request), } // 0. get data - int fieldNumber = inputScalarFields.size(); + int const fieldNumber = inputScalarFields.size(); std::vector inputFields(fieldNumber); for(int i = 0; i < fieldNumber; ++i) { inputFields[i] = ttkUtils::GetVoidPointer(inputScalarFields[i]); diff --git a/core/vtk/ttkTrackingFromOverlap/ttkTrackingFromOverlap.cpp b/core/vtk/ttkTrackingFromOverlap/ttkTrackingFromOverlap.cpp index 4baa118bab..b29a7c5013 100644 --- a/core/vtk/ttkTrackingFromOverlap/ttkTrackingFromOverlap.cpp +++ b/core/vtk/ttkTrackingFromOverlap/ttkTrackingFromOverlap.cpp @@ -61,8 +61,8 @@ int finalize(vector> &levelTimeNodesMap, vtkDataObject *trackingGraphObject) { auto trackingGraph = vtkUnstructuredGrid::SafeDownCast(trackingGraphObject); - size_t nL = levelTimeNodesMap.size(); - size_t nT = levelTimeNodesMap[0].size(); + size_t const nL = levelTimeNodesMap.size(); + size_t const nT = levelTimeNodesMap[0].size(); auto prepArray = [](vtkAbstractArray *array, const string &name, size_t nComponents, size_t nValues) { @@ -205,7 +205,7 @@ int finalize(vector> &levelTimeNodesMap, for(size_t l = 1; l < nL; l++) { for(size_t t = 0; t < nT; t++) { auto &edges = timeLevelEdgesNMap[t][l - 1]; - size_t temp = t * nL; + size_t const temp = t * nL; for(size_t i = 0, j = edges.size(); i < j;) { cellIds[q0++] = 2; cellIds[q0++] @@ -301,7 +301,7 @@ int ttkTrackingFromOverlap::packInputData( auto inputAsPS = vtkPointSet::SafeDownCast(inputDataObject); bool error = false; if(inputAsMB) { - size_t n = inputAsMB->GetNumberOfBlocks(); + size_t const n = inputAsMB->GetNumberOfBlocks(); // Check if blocks are vtkPointSets or vtkMultiBlockDataSets ... size_t psCounter = 0; @@ -350,7 +350,7 @@ int ttkTrackingFromOverlap::packInputData( // Check Data // ============================================================================= int ttkTrackingFromOverlap::checkData(vtkMultiBlockDataSet *data) { - size_t nL = data->GetNumberOfBlocks(); + size_t const nL = data->GetNumberOfBlocks(); size_t nT = 0; if(nL < 1) { @@ -361,7 +361,7 @@ int ttkTrackingFromOverlap::checkData(vtkMultiBlockDataSet *data) { for(size_t l = 0; l < nL; l++) { auto timesteps = vtkMultiBlockDataSet::SafeDownCast(data->GetBlock(l)); - size_t n = timesteps->GetNumberOfBlocks(); + size_t const n = timesteps->GetNumberOfBlocks(); if(n < 1) { printErr("Input must have at least one " "vtkPointSet."); @@ -379,7 +379,7 @@ int ttkTrackingFromOverlap::checkData(vtkMultiBlockDataSet *data) { if(pointSet == nullptr) { return 0; } - size_t nPoints = pointSet->GetNumberOfPoints(); + size_t const nPoints = pointSet->GetNumberOfPoints(); auto labels = pointSet->GetPointData()->GetAbstractArray( this->GetLabelFieldName().data()); @@ -390,7 +390,7 @@ int ttkTrackingFromOverlap::checkData(vtkMultiBlockDataSet *data) { if(labels == nullptr) continue; - int labelDataType = labels->GetDataType(); + int const labelDataType = labels->GetDataType(); if(this->LabelDataType < 0) this->LabelDataType = labelDataType; if(this->LabelDataType != labelDataType) { @@ -409,8 +409,8 @@ int ttkTrackingFromOverlap::checkData(vtkMultiBlockDataSet *data) { // ============================================================================= int ttkTrackingFromOverlap::packStreamedData(vtkMultiBlockDataSet *streamedData, vtkMultiBlockDataSet *data) const { - size_t nL_PI = this->previousIterationData->GetNumberOfBlocks(); - size_t nL_CI = streamedData->GetNumberOfBlocks(); + size_t const nL_PI = this->previousIterationData->GetNumberOfBlocks(); + size_t const nL_CI = streamedData->GetNumberOfBlocks(); if(nL_PI != nL_CI) { printErr("Number of levels differ over time."); return 0; @@ -420,7 +420,7 @@ int ttkTrackingFromOverlap::packStreamedData(vtkMultiBlockDataSet *streamedData, this->previousIterationData->GetBlock(l)); auto timestepsCI = vtkMultiBlockDataSet::SafeDownCast(streamedData->GetBlock(l)); - size_t nT_CI = timestepsCI->GetNumberOfBlocks(); + size_t const nT_CI = timestepsCI->GetNumberOfBlocks(); auto timesteps = vtkSmartPointer::New(); @@ -444,13 +444,13 @@ int ttkTrackingFromOverlap::storeStreamedData( vtkMultiBlockDataSet *streamedData) { auto temp = vtkSmartPointer::New(); - size_t nL = streamedData->GetNumberOfBlocks(); + size_t const nL = streamedData->GetNumberOfBlocks(); for(size_t l = 0; l < nL; l++) { auto timestepsSD = vtkMultiBlockDataSet::SafeDownCast(streamedData->GetBlock(l)); - size_t nT = timestepsSD->GetNumberOfBlocks(); + size_t const nT = timestepsSD->GetNumberOfBlocks(); - vtkSmartPointer lastTimestep + vtkSmartPointer const lastTimestep = vtkSmartPointer::New(); lastTimestep->SetBlock(0, timestepsSD->GetBlock(nT - 1)); @@ -495,13 +495,13 @@ int ttkTrackingFromOverlap::computeNodes(vtkMultiBlockDataSet *data) { } vector &timeNodesMap = this->levelTimeNodesMap[l]; - size_t timeOffset = timeNodesMap.size(); + size_t const timeOffset = timeNodesMap.size(); timeNodesMap.resize(timeOffset + nT); for(size_t t = 0; t < nT; t++) { getData(data, t, l, this->GetLabelFieldName(), pointSet, labels); - size_t nPoints = pointSet->GetNumberOfPoints(); + size_t const nPoints = pointSet->GetNumberOfPoints(); if(nPoints < 1) continue; @@ -561,15 +561,15 @@ int ttkTrackingFromOverlap::computeTrackingGraphs(vtkMultiBlockDataSet *data) { } vector &timeEdgesTMap = this->levelTimeEdgesTMap[l]; - size_t timeOffset = timeEdgesTMap.size(); + size_t const timeOffset = timeEdgesTMap.size(); timeEdgesTMap.resize(timeOffset + nT - 1); for(size_t t = 1; t < nT; t++) { getData(data, t - 1, l, this->GetLabelFieldName(), pointSet0, labels0); getData(data, t, l, this->GetLabelFieldName(), pointSet1, labels1); - size_t nPoints0 = pointSet0->GetNumberOfPoints(); - size_t nPoints1 = pointSet1->GetNumberOfPoints(); + size_t const nPoints0 = pointSet0->GetNumberOfPoints(); + size_t const nPoints1 = pointSet1->GetNumberOfPoints(); if(nPoints0 < 1 || nPoints1 < 1) continue; @@ -617,7 +617,7 @@ int ttkTrackingFromOverlap::computeNestingTrees(vtkMultiBlockDataSet *data) { debug::Priority::INFO); printMsg("Computing nesting trees", debug::Priority::INFO); - size_t timeOffset = this->timeLevelEdgesNMap.size(); + size_t const timeOffset = this->timeLevelEdgesNMap.size(); this->timeLevelEdgesNMap.resize(timeOffset + nT); for(size_t t = 0; t < nT; t++) { @@ -635,8 +635,8 @@ int ttkTrackingFromOverlap::computeNestingTrees(vtkMultiBlockDataSet *data) { getData(data, t, l - 1, this->GetLabelFieldName(), pointSet0, labels0); getData(data, t, l, this->GetLabelFieldName(), pointSet1, labels1); - size_t nPoints0 = pointSet0->GetNumberOfPoints(); - size_t nPoints1 = pointSet1->GetNumberOfPoints(); + size_t const nPoints0 = pointSet0->GetNumberOfPoints(); + size_t const nPoints1 = pointSet1->GetNumberOfPoints(); if(nPoints0 < 1 || nPoints1 < 1) continue; @@ -667,7 +667,7 @@ int ttkTrackingFromOverlap::computeNestingTrees(vtkMultiBlockDataSet *data) { // ============================================================================= int ttkTrackingFromOverlap::computeBranches() { - size_t nL = this->levelTimeEdgesTMap.size(); + size_t const nL = this->levelTimeEdgesTMap.size(); for(size_t l = 0; l < nL; l++) this->ttk::TrackingFromOverlap::computeBranches( @@ -699,7 +699,7 @@ int ttkTrackingFromOverlap::RequestData(vtkInformation *ttkNotUsed(request), auto iterationInformation = vtkDoubleArray::SafeDownCast( inputObject->GetFieldData()->GetAbstractArray("_ttk_IterationInfo")); - bool useStreamingOverTime = iterationInformation != nullptr; + bool const useStreamingOverTime = iterationInformation != nullptr; double iteration = 0; double nIterations = 0; diff --git a/core/vtk/ttkTrackingFromPersistenceDiagrams/ttkTrackingFromPersistenceDiagrams.cpp b/core/vtk/ttkTrackingFromPersistenceDiagrams/ttkTrackingFromPersistenceDiagrams.cpp index 2d5684bb6d..97a2e1e2d0 100644 --- a/core/vtk/ttkTrackingFromPersistenceDiagrams/ttkTrackingFromPersistenceDiagrams.cpp +++ b/core/vtk/ttkTrackingFromPersistenceDiagrams/ttkTrackingFromPersistenceDiagrams.cpp @@ -61,10 +61,10 @@ int ttkTrackingFromPersistenceDiagrams::buildMesh( for(size_t k = 0; k < trackings.size(); ++k) { const ttk::trackingTuple &tt = trackings[k]; - int numStart = std::get<0>(tt); + int const numStart = std::get<0>(tt); // int numEnd = std::get<1>(tt); const std::vector &chain = std::get<2>(tt); - int chainLength = chain.size(); + int const chainLength = chain.size(); if(chainLength <= 1) { dbg.printErr("Got an unexpected 0-size chain."); @@ -73,8 +73,8 @@ int ttkTrackingFromPersistenceDiagrams::buildMesh( for(int c = 0; c < chainLength - 1; ++c) { const auto &matchings1 = outputMatchings[numStart + c]; - int d1id = numStart + c; - int d2id = d1id + 1; // c % 2 == 0 ? d1id + 1 : d1id; + int const d1id = numStart + c; + int const d2id = d1id + 1; // c % 2 == 0 ? d1id + 1 : d1id; const auto &diagram1 = inputPersistenceDiagrams[d1id]; const auto &diagram2 = inputPersistenceDiagrams[d2id]; @@ -141,10 +141,10 @@ int ttkTrackingFromPersistenceDiagrams::buildMesh( if(doPostProc) { const auto &connected = trackingTupleToMerged[k]; if(!connected.empty()) { - int min = *(connected.begin()); + int const min = *(connected.begin()); const ttk::trackingTuple &ttt = trackings[min]; // int numStart2 = std::get<0>(ttt); - int numEnd2 = std::get<1>(ttt); + int const numEnd2 = std::get<1>(ttt); if((numEnd2 > 0 && numStart + c > numEnd2 + 1) && min < (int)k) { dbg.printMsg("Switched " + std::to_string(k) + " for " + std::to_string(min)); @@ -227,11 +227,11 @@ int ttkTrackingFromPersistenceDiagrams::buildMesh( || point2Type2 == CriticalType::Saddle2 ? CriticalType::Saddle2 : CriticalType::Saddle1; - bool t21Ex = point2Type1 == CriticalType::Local_minimum - || point2Type1 == CriticalType::Local_maximum; - bool t22Ex = point2Type2 == CriticalType::Local_minimum - || point2Type2 == CriticalType::Local_maximum; - bool bothEx2 = t21Ex && t22Ex; + bool const t21Ex = point2Type1 == CriticalType::Local_minimum + || point2Type1 == CriticalType::Local_maximum; + bool const t22Ex = point2Type2 == CriticalType::Local_minimum + || point2Type2 == CriticalType::Local_maximum; + bool const bothEx2 = t21Ex && t22Ex; if(bothEx2) { x2 = point2Type2 == CriticalType::Local_maximum ? pair1.death.coords[0] : pair1.birth.coords[0]; @@ -295,7 +295,7 @@ int ttkTrackingFromPersistenceDiagrams::RequestData( vtkUnstructuredGrid *mesh = vtkUnstructuredGrid::GetData(outputVector, 0); // Number of input files - int numInputs = inputVector[0]->GetNumberOfInformationObjects(); + int const numInputs = inputVector[0]->GetNumberOfInformationObjects(); this->printMsg("Number of inputs: " + std::to_string(numInputs)); // Get input data @@ -309,10 +309,10 @@ int ttkTrackingFromPersistenceDiagrams::RequestData( std::vector> outputMatchings(numInputs - 1); // Input parameters. - double spacing = Spacing; - std::string algorithm = DistanceAlgorithm; - double tolerance = Tolerance; - std::string wasserstein = WassersteinMetric; + double const spacing = Spacing; + std::string const algorithm = DistanceAlgorithm; + double const tolerance = Tolerance; + std::string const wasserstein = WassersteinMetric; // Transform inputs into the right structure. for(int i = 0; i < numInputs; ++i) { @@ -331,7 +331,7 @@ int ttkTrackingFromPersistenceDiagrams::RequestData( outputDiags[2 * i + 0]->ShallowCopy(inputVTUs[i]); outputDiags[2 * i + 1]->ShallowCopy(inputVTUs[i + 1]); - int status = augmentDiagrams( + int const status = augmentDiagrams( outputMatchings[i], outputDiags[2 * i + 0], outputDiags[2 * i + 1]); if(status < 0) return -2; @@ -369,8 +369,8 @@ int ttkTrackingFromPersistenceDiagrams::RequestData( vtkUnstructuredGrid *outputMesh = vtkUnstructuredGrid::SafeDownCast(mesh); - vtkNew points{}; - vtkNew persistenceDiagram{}; + vtkNew const points{}; + vtkNew const persistenceDiagram{}; vtkNew persistenceScalars{}; vtkNew valueScalars{}; @@ -399,7 +399,7 @@ int ttkTrackingFromPersistenceDiagrams::RequestData( trackingTupleToMerged, PostProcThresh); // bool Is3D = true; - bool useGeometricSpacing = UseGeometricSpacing; + bool const useGeometricSpacing = UseGeometricSpacing; // auto spacing = (float) Spacing; // std::vector trackings = *trackingsBase; diff --git a/core/vtk/ttkTriangulationManager/ttkTriangulationManager.cpp b/core/vtk/ttkTriangulationManager/ttkTriangulationManager.cpp index b53a9322b9..994fdcff40 100644 --- a/core/vtk/ttkTriangulationManager/ttkTriangulationManager.cpp +++ b/core/vtk/ttkTriangulationManager/ttkTriangulationManager.cpp @@ -178,7 +178,7 @@ int ttkTriangulationManager::processExplicit( // If all checks pass then log which array is going to be processed. this->printMsg("Compact explicit triangulation..."); int status = 0; // this integer checks if the base code returns an error - ttk::CompactTriangulationPreconditioning worker{}; + ttk::CompactTriangulationPreconditioning const worker{}; ttkTemplateMacro( triangulation.getType(), (status = worker.execute( @@ -264,7 +264,8 @@ int ttkTriangulationManager::processExplicit( // Modify the selected point data arrays with new indices for(vtkDataArray *scalarArray : pointDataArrays) { - vtkSmartPointer updatedField(scalarArray->NewInstance()); + vtkSmartPointer const updatedField( + scalarArray->NewInstance()); updatedField->SetName(scalarArray->GetName()); for(size_t j = 0; j < vertices.size(); j++) { updatedField->InsertTuple(j, scalarArray->GetTuple(vertices[j])); @@ -275,7 +276,8 @@ int ttkTriangulationManager::processExplicit( // Modify the selected cell data arrays with new indices for(vtkDataArray *scalarArray : cellDataArrays) { - vtkSmartPointer updatedField(scalarArray->NewInstance()); + vtkSmartPointer const updatedField( + scalarArray->NewInstance()); updatedField->SetName(scalarArray->GetName()); for(size_t j = 0; j < cells.size(); j++) { updatedField->InsertTuple(j, scalarArray->GetTuple(cells[j])); diff --git a/core/vtk/ttkTriangulationRequest/ttkTriangulationRequest.cpp b/core/vtk/ttkTriangulationRequest/ttkTriangulationRequest.cpp index be331414e2..8f141bd02e 100644 --- a/core/vtk/ttkTriangulationRequest/ttkTriangulationRequest.cpp +++ b/core/vtk/ttkTriangulationRequest/ttkTriangulationRequest.cpp @@ -599,7 +599,7 @@ int ttkTriangulationRequest::RequestData(vtkInformation *ttkNotUsed(request), newArr->SetName(arr->GetName()); newArr->SetNumberOfComponents(1); - for(SimplexId v : vertices) + for(SimplexId const v : vertices) newArr->InsertNextTuple1(arr->GetTuple1(v)); outputPointData->AddArray(newArr); diff --git a/core/vtk/ttkUncertainDataEstimator/ttkUncertainDataEstimator.cpp b/core/vtk/ttkUncertainDataEstimator/ttkUncertainDataEstimator.cpp index f0b395a421..3f053693d1 100644 --- a/core/vtk/ttkUncertainDataEstimator/ttkUncertainDataEstimator.cpp +++ b/core/vtk/ttkUncertainDataEstimator/ttkUncertainDataEstimator.cpp @@ -48,7 +48,7 @@ int ttkUncertainDataEstimator::RequestData(vtkInformation *ttkNotUsed(request), auto mean = vtkDataSet::GetData(outputVector, 2); // Number of input files - int numInputs = inputVector[0]->GetNumberOfInformationObjects(); + int const numInputs = inputVector[0]->GetNumberOfInformationObjects(); this->printMsg(std::vector>{ {"#Inputs", std::to_string(numInputs)}}); @@ -98,9 +98,9 @@ int ttkUncertainDataEstimator::RequestData(vtkInformation *ttkNotUsed(request), return -1; } // Allocate the memory for the output bound scalar fields - vtkSmartPointer outputLowerBoundScalarField{ + vtkSmartPointer const outputLowerBoundScalarField{ inputScalarField[0]->NewInstance()}; - vtkSmartPointer outputUpperBoundScalarField{ + vtkSmartPointer const outputUpperBoundScalarField{ inputScalarField[0]->NewInstance()}; outputLowerBoundScalarField->SetName("lowerBoundField"); outputUpperBoundScalarField->SetName("upperBoundField"); diff --git a/core/vtk/ttkUserInterfaceBase/ttkUserInterfaceBase.cpp b/core/vtk/ttkUserInterfaceBase/ttkUserInterfaceBase.cpp index 604cbc16fa..e3ee06e7dd 100644 --- a/core/vtk/ttkUserInterfaceBase/ttkUserInterfaceBase.cpp +++ b/core/vtk/ttkUserInterfaceBase/ttkUserInterfaceBase.cpp @@ -113,7 +113,7 @@ int ttkUserInterfaceBase::init(int &argc, char **argv) { int ttkUserInterfaceBase::refresh() { // collect the output and update the rendering - int outputPortNumber = vtkWrapper_->GetNumberOfOutputPorts(); + int const outputPortNumber = vtkWrapper_->GetNumberOfOutputPorts(); if((int)visibleOutputs_.size() != outputPortNumber) { visibleOutputs_.resize(outputPortNumber, true); diff --git a/core/vtk/ttkWebSocketIO/ttkWebSocketIO.cpp b/core/vtk/ttkWebSocketIO/ttkWebSocketIO.cpp index f0a0452b04..9b483252cf 100644 --- a/core/vtk/ttkWebSocketIO/ttkWebSocketIO.cpp +++ b/core/vtk/ttkWebSocketIO/ttkWebSocketIO.cpp @@ -177,7 +177,8 @@ int ttkWebSocketIO::ParseVtkDataObjectFromJSON(const std::string &json) { auto nPoints = jsonGetValue(jsonVtkDataSet, "points.coordinates.nTuples"); - vtkSmartPointer points = vtkSmartPointer::New(); + vtkSmartPointer const points + = vtkSmartPointer::New(); points->SetNumberOfPoints(nPoints); jsonArrayToArray(jsonVtkDataSet, "points.coordinates.data", @@ -246,8 +247,9 @@ int ttkWebSocketIO::ParseVtkDataObjectFromJSON(const std::string &json) { // parse point data for(const auto &pda : fdJSON.get_child(fdKey)) { const auto &jsonArray = pda.second; - size_t nComponents = jsonGetValue(jsonArray, "nComponents"); - size_t nTuples = jsonGetValue(jsonArray, "nTuples"); + size_t const nComponents + = jsonGetValue(jsonArray, "nComponents"); + size_t const nTuples = jsonGetValue(jsonArray, "nTuples"); auto array = vtkSmartPointer::Take( vtkDataArray::CreateArray(jsonGetValue(jsonArray, "dataType"))); @@ -462,7 +464,7 @@ int ttkWebSocketIO::SendVtkDataObject(vtkDataObject *object) { {"fieldData", block->GetFieldData()}}; for(auto &attribute : attributes) { - size_t nArrays = attribute.second->GetNumberOfArrays(); + size_t const nArrays = attribute.second->GetNumberOfArrays(); for(size_t i = 0; i < nArrays; i++) { auto array = attribute.second->GetAbstractArray(i);