diff --git a/Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/IncrSAP.cpp b/Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/IncrSAP.cpp index d6fa4539d685..8af23081c2c0 100644 --- a/Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/IncrSAP.cpp +++ b/Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/IncrSAP.cpp @@ -138,19 +138,19 @@ IncrSAP::IncrSAP() IncrSAP::~IncrSAP() { - for(int i = 0 ; i < 3 ; ++i) - for(EndPointList::iterator it = _end_points[i].begin() ; it != _end_points[i].end() ; ++it) + for(auto& _end_point : _end_points) + for(EndPointList::iterator it = _end_point.begin() ; it != _end_point.end() ; ++it) delete (*it); } void IncrSAP::purge(){ - for(int i = 0 ; i < 3 ; ++i){ - for(EndPointList::iterator it = _end_points[i].begin() ; it != _end_points[i].end() ; ++it) + for(auto& _end_point : _end_points){ + for(EndPointList::iterator it = _end_point.begin() ; it != _end_point.end() ; ++it) delete (*it); - _end_points[i].clear(); + _end_point.clear(); } _boxes.clear(); @@ -209,8 +209,8 @@ inline void IncrSAP::addCollisionModel(core::CollisionModel *cm) EndPointID * endPts[6]; for(Size i = 0 ; i < cube_model->getSize() ; ++i){ - for(int j = 0 ; j < 6 ; ++j) - endPts[j] = new EndPointID; + for(auto& endPt : endPts) + endPt = new EndPointID; ISAPBox & new_box = _boxes[old_size + i]; new_box.cube = Cube(cube_model,i); @@ -269,9 +269,9 @@ void IncrSAP::updateEndPoints(){ void IncrSAP::setEndPointsID(){ - for(int dim = 0 ; dim < 3 ; ++dim){ + for(auto& _end_point : _end_points){ int ID = 0; - for(EndPointList::iterator it = _end_points[dim].begin() ; it != _end_points[dim].end() ; ++it){ + for(EndPointList::iterator it = _end_point.begin() ; it != _end_point.end() ; ++it){ (**it).ID = ID; ++ID; } @@ -282,8 +282,8 @@ void IncrSAP::setEndPointsID(){ void IncrSAP::reinitDetection(){ _colliding_elems.clear(); const CompPEndPoint comp; - for(int j = 0 ; j < 3 ; ++j){ - std::sort(_end_points[j].begin(),_end_points[j].end(),comp); + for(auto& _end_point : _end_points){ + std::sort(_end_point.begin(),_end_point.end(),comp); } setEndPointsID(); } @@ -293,8 +293,8 @@ void IncrSAP::reinitDetection(){ void IncrSAP::showEndPoints()const{ for(int j = 0 ; j < 3 ; ++j){ msg_info() <<"dimension "<getLast()<<" index "<getEdgesAroundVertex(p.getIndex()); Vec3 nMean; - for (unsigned int i=0; igetTriangle(t); Vec3 nCur = (x[ptr[1]]-x[ptr[0]]).cross(x[ptr[2]]-x[ptr[0]]); nCur.normalize(); @@ -1216,9 +1215,8 @@ bool LocalMinDistance::testValidity(Point &p, const Vec3 &PQ) const if (trianglesAroundVertex.empty()) { - for (unsigned int i=0; igetEdge(e); Vec3 l = (pt - x[ped[0]]) + (pt - x[ped[1]]); l.normalize(); @@ -1240,9 +1238,8 @@ bool LocalMinDistance::testValidity(Point &p, const Vec3 &PQ) const } } - for (unsigned int i=0; igetEdge(e); Vec3 l = (pt - x[ped[0]]) + (pt - x[ped[1]]); l.normalize(); diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleModelInRegularGrid.cpp b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleModelInRegularGrid.cpp index bdbbdeeb612f..8ea907fdd5c5 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleModelInRegularGrid.cpp +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleModelInRegularGrid.cpp @@ -74,12 +74,12 @@ void TriangleModelInRegularGrid::init() while ( found ) { found = false; - for ( vector::iterator it = topoVec.begin(); it != topoVec.end(); ++it ) + for (const auto& v : topoVec) { - if ( ( *it )->getTo() == _higher_topo ) + if ( v->getTo() == _higher_topo ) { found = true; - _topoMapping = *it; + _topoMapping = v; _higher_topo = _topoMapping->getFrom(); if ( !_higher_topo ) break; const sofa::simulation::Node* node = static_cast< sofa::simulation::Node* > ( _higher_topo->getContext() ); diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleOctreeModel.cpp b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleOctreeModel.cpp index 60da4e262b75..bedad7b2cbf2 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleOctreeModel.cpp +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/TriangleOctreeModel.cpp @@ -104,14 +104,14 @@ void TriangleOctreeModel::computeBoundingTree(int maxDepth) t.n() = cross(*pt[1]-*pt[0],*pt[2]-*pt[0]); t.n().normalize(); - for (int p=0; p<3; p++) + for (auto& p : pt) { for(int c=0; c<3; c++) { - if ((*pt[p])[c] > maxElem[c]) maxElem[c] = (*pt[p])[c]; - if ((*pt[p])[c] < minElem[c]) minElem[c] = (*pt[p])[c]; + if ((*p)[c] > maxElem[c]) maxElem[c] = (*p)[c]; + if ((*p)[c] < minElem[c]) minElem[c] = (*p)[c]; } } diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp index 6384fd8e0fa3..c31ea4aef72a 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp @@ -144,16 +144,15 @@ void CollisionResponse::createNewContacts(const core::collision::ContactManager: { std::stringstream errorStream; - for (DetectionOutputMap::const_iterator outputsIt = outputsMap.begin(), - outputsItEnd = outputsMap.end(); outputsIt != outputsItEnd ; ++outputsIt) + for (const auto& [models, output] : outputsMap) { - const auto contactInsert = contactMap.insert(ContactMap::value_type(outputsIt->first, core::collision::Contact::SPtr())); + const auto contactInsert = contactMap.insert(ContactMap::value_type(models, core::collision::Contact::SPtr())); const ContactMap::iterator contactIt = contactInsert.first; if (contactInsert.second) //insertion success { // new contact - core::CollisionModel* model1 = outputsIt->first.first; - core::CollisionModel* model2 = outputsIt->first.second; + core::CollisionModel* model1 = models.first; + core::CollisionModel* model2 = models.second; dmsg_error_when(model1 == nullptr || model2 == nullptr) << "Contact found with an invalid collision model"; @@ -182,7 +181,7 @@ void CollisionResponse::createNewContacts(const core::collision::ContactManager: setContactTags(model1, model2, contact); contact->f_printLog.setValue(notMuted()); contact->init(); - contact->setDetectionOutputs(outputsIt->second); + contact->setDetectionOutputs(output); ++nbContact; } } @@ -190,7 +189,7 @@ void CollisionResponse::createNewContacts(const core::collision::ContactManager: else { // pre-existing and still active contact - contactIt->second->setDetectionOutputs(outputsIt->second); + contactIt->second->setDetectionOutputs(output); ++nbContact; } } diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp index 02704f64c0b6..bad0827f8b68 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp @@ -43,11 +43,9 @@ RuleBasedContactManager::RuleBasedContactManager() RuleBasedContactManager::~RuleBasedContactManager() { - for(std::map*>::iterator it = variablesData.begin(), - itend = variablesData.end(); it != itend; ++it) + for(const auto& d : variablesData) { - //this->removeData(it->second); - delete it->second; + delete d.second; } } @@ -125,11 +123,11 @@ std::string RuleBasedContactManager::getContactResponse(core::CollisionModel* mo if (!response1.empty()) return response1; else if (!response2.empty()) return response2; - const type::vector& r = rules.getValue(); - for (type::vector::const_iterator it = r.begin(), itend = r.end(); it != itend; ++it) + const type::vector& rulesValue = rules.getValue(); + for (const auto& rule : rulesValue) { - if (it->match(model1, model2) || it->match(model2, model1)) - return replaceVariables(it->response); // rule it matched + if (rule.match(model1, model2) || rule.match(model2, model1)) + return replaceVariables(rule.response); // rule it matched } // no rule matched return replaceVariables(CollisionResponse::getContactResponse(model1, model2)); diff --git a/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp b/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp index f2317f710a71..842cb08c3dcd 100644 --- a/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp @@ -339,9 +339,8 @@ void LCPConstraintSolver::build_Coarse_Compliance(std::vector &constraint_m dmsg_error_when(sizeCoarseSystem==0) <<"no constraint" ; _Wcoarse.resize(sizeCoarseSystem,sizeCoarseSystem); - for (unsigned int i=0; igetComplianceWithConstraintMerge(&_Wcoarse, constraint_merge); } } @@ -752,9 +751,8 @@ int LCPConstraintSolver::nlcp_gaussseidel_unbuilt(SReal *dfree, SReal *f, std::v } - for (unsigned int i=0; iresetForUnbuiltResolution(f, contact_sequence); } @@ -1009,9 +1007,8 @@ int LCPConstraintSolver::lcp_gaussseidel_unbuilt(SReal *dfree, SReal *f, std::ve } - for (unsigned int i=0; iresetForUnbuiltResolution(f, contact_sequence); } diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp index c622b3d4724a..f52609b7bbdf 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp @@ -77,20 +77,24 @@ void FixedProjectiveConstraint::draw(const core::visual::VisualPara if (d_fixAll.getValue()) { - for (unsigned i = 0; i < x.size(); i++) - points.push_back(x[i].getCenter()); + for (const auto& xi : x) + points.push_back(xi.getCenter()); } else { if( x.size() < indices.size() ) { for (unsigned i=0; i::draw(const core::visual::VisualPara if(d_fixAll.getValue()) { - for (unsigned i=0; idrawTool()->drawPoints(vertices, 10, color); diff --git a/Sofa/Component/Engine/Generate/src/sofa/component/engine/generate/MeshTetraStuffing.cpp b/Sofa/Component/Engine/Generate/src/sofa/component/engine/generate/MeshTetraStuffing.cpp index 42be64c93891..4afa0f905d4c 100644 --- a/Sofa/Component/Engine/Generate/src/sofa/component/engine/generate/MeshTetraStuffing.cpp +++ b/Sofa/Component/Engine/Generate/src/sofa/component/engine/generate/MeshTetraStuffing.cpp @@ -92,10 +92,10 @@ void MeshTetraStuffing::doUpdate() { // triangulate quads inT.reserve(inQ.size()*2); - for (unsigned int i=0; i < inQ.size(); ++i) + for (const auto& quad : inQ) { - inT.push_back(Triangle(inQ[i][0], inQ[i][1], inQ[i][2])); - inT.push_back(Triangle(inQ[i][0], inQ[i][2], inQ[i][3])); + inT.push_back(Triangle(quad[0], quad[1], quad[2])); + inT.push_back(Triangle(quad[0], quad[2], quad[3])); } } SeqPoints inTN; @@ -335,15 +335,14 @@ void MeshTetraStuffing::doUpdate() do { nwraps = 0; - for (std::set::const_iterator it = violatedOutsidePoints.begin(), itend = violatedOutsidePoints.end(); it != itend; ++it) + for (const int violatedOutsidePoint : violatedOutsidePoints) { - int p = *it; - if (pInside[p] == 0) continue; // point already wrapped + if (pInside[violatedOutsidePoint] == 0) continue; // point already wrapped Real minDist = 0; int minEdge = -1; for (int e=0; e 0); if (in2 || pViolated[p2]) continue; // only move towards unviolated points @@ -352,8 +351,8 @@ void MeshTetraStuffing::doUpdate() alpha = alphaLong; else alpha = alphaShort; - if (eBDist[p][e] == 0.0 || eBDist[p][e] >= alpha) continue; // this edge is not violated - Real dist = eBDist[p][e] * eBDist[p][e] * getEdgeSize2(e); + if (eBDist[violatedOutsidePoint][e] == 0.0 || eBDist[violatedOutsidePoint][e] >= alpha) continue; // this edge is not violated + Real dist = eBDist[violatedOutsidePoint][e] * eBDist[violatedOutsidePoint][e] * getEdgeSize2(e); if (minEdge == -1 || dist < minDist) { minEdge = e; @@ -362,18 +361,18 @@ void MeshTetraStuffing::doUpdate() } if (minEdge == -1) continue; // no violated edge toward an unviolated point int e = minEdge; - int p2 = getEdgePoint2(p,e); + int p2 = getEdgePoint2(violatedOutsidePoint,e); // Wrap p toward p2 - msg_info() << "Wrapping outside point " << p << " toward " << p2 << " by " << eBDist[p][e]; - outP[p] += (outP[p2]-outP[p]) * (eBDist[p][e]); - snaps.push_back(outP[p]); + msg_info() << "Wrapping outside point " << violatedOutsidePoint << " toward " << p2 << " by " << eBDist[violatedOutsidePoint][e]; + outP[violatedOutsidePoint] += (outP[p2]-outP[violatedOutsidePoint]) * (eBDist[violatedOutsidePoint][e]); + snaps.push_back(outP[violatedOutsidePoint]); ++nwraps; - pInside[p] = 0; // p is now on the surface - pViolated[p] = false; // and now longer violated + pInside[violatedOutsidePoint] = 0; // p is now on the surface + pViolated[violatedOutsidePoint] = false; // and now longer violated for (int e=0; e 0) @@ -405,19 +404,18 @@ void MeshTetraStuffing::doUpdate() } while (nwraps > 0); // then order remaining violated inside points - for (std::set::const_iterator it = violatedInsidePoints.begin(), itend = violatedInsidePoints.end(); it != itend; ++it) + for (const int violatedOutsidePoint : violatedInsidePoints) { - int p = *it; - if (pInside[p] == 0) + if (pInside[violatedOutsidePoint] == 0) { - msg_error() << "Inside point " << p << " already wrapped."; + msg_error() << "Inside point " << violatedOutsidePoint << " already wrapped."; continue; } Real minDist = 0; int minEdge = -1; for (int e=0; e= 0) continue; // only move towards outside points Real alpha; @@ -425,8 +423,8 @@ void MeshTetraStuffing::doUpdate() alpha = alphaLong; else alpha = alphaShort; - if (eBDist[p][e] == 0.0 || eBDist[p][e] >= alpha) continue; // this edges is not violated - Real dist = eBDist[p][e] * eBDist[p][e] * getEdgeSize2(e); + if (eBDist[violatedOutsidePoint][e] == 0.0 || eBDist[violatedOutsidePoint][e] >= alpha) continue; // this edges is not violated + Real dist = eBDist[violatedOutsidePoint][e] * eBDist[violatedOutsidePoint][e] * getEdgeSize2(e); if (minEdge == -1 || dist < minDist) { minEdge = e; @@ -435,21 +433,21 @@ void MeshTetraStuffing::doUpdate() } if (minEdge == -1) // no violated edge { - msg_error() << "Inside point " << p << " has no violated edges."; + msg_error() << "Inside point " << violatedOutsidePoint << " has no violated edges."; continue; } int e = minEdge; - int p2 = getEdgePoint2(p,e); + int p2 = getEdgePoint2(violatedOutsidePoint,e); // Wrap p toward p2 - msg_info() << "Wrapping inside point " << p << " toward " << p2 << " by " << eBDist[p][e]; - outP[p] += (outP[p2]-outP[p]) * (eBDist[p][e]); - snaps.push_back(outP[p]); - pInside[p] = 0; // p is now on the surface - pViolated[p] = false; // and now longer violated + msg_info() << "Wrapping inside point " << violatedOutsidePoint << " toward " << p2 << " by " << eBDist[violatedOutsidePoint][e]; + outP[violatedOutsidePoint] += (outP[p2]-outP[violatedOutsidePoint]) * (eBDist[violatedOutsidePoint][e]); + snaps.push_back(outP[violatedOutsidePoint]); + pInside[violatedOutsidePoint] = 0; // p is now on the surface + pViolated[violatedOutsidePoint] = false; // and now longer violated for (int e=0; e newPid; newPid.resize(outP.size()); - for (unsigned int t=0; t triSet; diff --git a/Sofa/Component/Engine/Select/src/sofa/component/engine/select/MeshBoundaryROI.cpp b/Sofa/Component/Engine/Select/src/sofa/component/engine/select/MeshBoundaryROI.cpp index 7efcaf68acf2..f44b1ecea319 100644 --- a/Sofa/Component/Engine/Select/src/sofa/component/engine/select/MeshBoundaryROI.cpp +++ b/Sofa/Component/Engine/Select/src/sofa/component/engine/select/MeshBoundaryROI.cpp @@ -60,26 +60,26 @@ void MeshBoundaryROI::doUpdate() indices.clear(); std::map edgeCount; - for(size_t i=0;icountEdge(edgeCount,edge); } } } - for(size_t i=0;icountEdge(edgeCount,edge); } @@ -87,13 +87,13 @@ void MeshBoundaryROI::doUpdate() } std::set indexset; // enforce uniqueness since SetIndex is not a set.. - for(auto it=edgeCount.begin();it!=edgeCount.end();++it) + for(const auto & [pointPair, count] : edgeCount) { // consider edge only if it is on the boundary - if(it->second==1) + if (count == 1) { - indexset.insert(it->first.first); - indexset.insert(it->first.second); + indexset.insert(pointPair.first); + indexset.insert(pointPair.second); } } indices.wref().insert(indices.end(), indexset.begin(), indexset.end()); diff --git a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/GridMeshCreator.cpp b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/GridMeshCreator.cpp index 14700c8f86f2..bb08ba1712fd 100644 --- a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/GridMeshCreator.cpp +++ b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/GridMeshCreator.cpp @@ -145,8 +145,8 @@ bool GridMeshCreator::doLoad() } auto my_edges = getWriteOnlyAccessor(d_edges); - for( std::set::const_iterator it=uniqueEdges.begin(),itEnd=uniqueEdges.end(); it!=itEnd; ++it ) - my_edges.push_back( *it ); + for (const auto& uniqueEdge : uniqueEdges) + my_edges.push_back( uniqueEdge ); return true; } diff --git a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshGmshLoader.cpp b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshGmshLoader.cpp index 79bb56941f90..0d922b25e32e 100644 --- a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshGmshLoader.cpp +++ b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshGmshLoader.cpp @@ -128,9 +128,9 @@ void MeshGmshLoader::doClearBuffers() } void MeshGmshLoader::addInGroup(type::vector< sofa::core::loader::PrimitiveGroup>& group,int tag,int /*eid*/) { - for (unsigned i=0;i& group) { int start = 0; - for (unsigned i=0;i >::const_iterator it = materialFaces[ft].begin(), itend = materialFaces[ft].end(); it != itend; ++it) + for (const auto& [materialName, faces] : materialFace) { - std::string materialName = it->first; - const type::vector& faces = it->second; if (faces.empty()) continue; std::ostringstream oname; oname << "material_" << materialName << "_" << fname << "Indices"; diff --git a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshVTKLoader.cpp b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshVTKLoader.cpp index 7a79d41ed965..c5324ce59b0a 100644 --- a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshVTKLoader.cpp +++ b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshVTKLoader.cpp @@ -532,21 +532,21 @@ bool MeshVTKLoader::setInputsMesh() bool MeshVTKLoader::setInputsData() { ///Point Data - for (size_t i = 0 ; i < reader->inputPointDataVector.size() ; i++) + for (const auto& inputPointData : reader->inputPointDataVector) { - const char* dataname = reader->inputPointDataVector[i]->name.c_str(); + const char* dataname = inputPointData->name.c_str(); - BaseData* basedata = reader->inputPointDataVector[i]->createSofaData(); + BaseData* basedata = inputPointData->createSofaData(); this->addData(basedata, dataname); addOutputsToCallback("filename", {basedata}); } ///Cell Data - for (size_t i = 0 ; i < reader->inputCellDataVector.size() ; i++) + for (const auto& inputCellData : reader->inputCellDataVector) { - const char* dataname = reader->inputCellDataVector[i]->name.c_str(); - BaseData* basedata = reader->inputCellDataVector[i]->createSofaData(); + const char* dataname = inputCellData->name.c_str(); + BaseData* basedata = inputCellData->createSofaData(); this->addData(basedata, dataname); addOutputsToCallback("filename", {basedata}); } diff --git a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/STLExporter.cpp b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/STLExporter.cpp index ec119db8075c..6d40a8d70227 100644 --- a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/STLExporter.cpp +++ b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/STLExporter.cpp @@ -137,24 +137,24 @@ bool STLExporter::writeSTL(bool autonumbering) } if(!triangleIndices.empty()) { - for(unsigned int i=0;i& strData, type::vector& objects, type::vector& fields, type::vector& names) { - for (unsigned int i=0 ; i& _idxInRegularGrid = idxInRegularGrid.getValue(); // for all "active" data voxels - for(unsigned i=0; i<_idxInRegularGrid.size(); ++i) + for(const unsigned int idxData : _idxInRegularGrid) { - const int idxData = _idxInRegularGrid[i]; const int I = idxData % resol[0]; const int J = (idxData/resol[0]) % resol[1]; const int K = idxData / (resol[0] * resol[1]); diff --git a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/BarycentricMappingRigid.cpp b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/BarycentricMappingRigid.cpp index 212bd8a786f6..6204d94946cd 100644 --- a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/BarycentricMappingRigid.cpp +++ b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/BarycentricMappingRigid.cpp @@ -80,10 +80,8 @@ void BarycentricMapperHexahedronSetTopology& mapData = *(d_map.beginEdit()); - for ( auto iter = m_invalidIndex.cbegin(); - iter != m_invalidIndex.cend(); ++iter ) + for (const int j : m_invalidIndex) { - const int j = *iter; if ( mapData[j].in_index == sofa::InvalidID ) // compute new mapping { sofa::type::Vec3 coefs; @@ -135,10 +133,9 @@ void BarycentricMapperHexahedronSetTopology ( *changeIt ) )->getArray(); - for ( unsigned int i=0; i 0) { @@ -330,9 +330,9 @@ void SimpleTesselatedTetraTopologicalMapping::removeOutputTetrahedra( const sofa type::vector& tetraSourceData = *(tetraSource.beginEdit()); Index last = tetraSourceData.size() -1; - for (unsigned int i = 0; i < index.size(); ++i) + for (const unsigned int index_i : index) { - swapOutputTetrahedra( index[i], last ); + swapOutputTetrahedra( index_i, last ); Index source = tetraSourceData[last]; if (source != sofa::InvalidID) { @@ -467,9 +467,9 @@ void SimpleTesselatedTetraTopologicalMapping::removeInputPoints( const sofa::typ Index last = pointMappedFromPointData.size() -1; - for (unsigned int i = 0; i < index.size(); ++i) + for (const unsigned int index_i : index) { - swapInputPoints( index[i], last ); + swapInputPoints( index_i, last ); const Index map = pointMappedFromPointData[last]; if (map != sofa::InvalidID) pointSourceData[map] = 0; @@ -516,9 +516,9 @@ void SimpleTesselatedTetraTopologicalMapping::removeInputEdges( const sofa::type Index last = pointMappedFromEdgeData.size() -1; - for (unsigned int i = 0; i < index.size(); ++i) + for (const unsigned int index_i : index) { - swapInputEdges( index[i], last ); + swapInputEdges( index_i, last ); const Index map = pointMappedFromEdgeData[last]; if (map != sofa::InvalidID) pointSourceData[map] = 0; @@ -556,9 +556,9 @@ void SimpleTesselatedTetraTopologicalMapping::removeInputTetrahedra( const sofa: Index last = (int)tetrahedraMappedFromTetraData.size() -1; - for (unsigned int i = 0; i < index.size(); ++i) + for (const unsigned int index_i : index) { - swapInputTetrahedra( index[i], last ); + swapInputTetrahedra( index_i, last ); const fixed_array& map = tetrahedraMappedFromTetraData[last]; for (int j=0; j<8; ++j) if (map[j] != sofa::InvalidID) diff --git a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.cpp b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.cpp index 4d652ee10aa8..d4cc864b3d11 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.cpp +++ b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.cpp @@ -215,10 +215,10 @@ void UniformMass::drawRigid2DImpl(const VisualParams* vparams) len[0] = len[1] = sqrt(d_vertexMass.getValue().inertiaMatrix); len[2] = 0; - for (unsigned int i=0; idrawTool()->drawFrame(center, orient, len*d_showAxisSize.getValue() ); } @@ -250,21 +250,21 @@ void UniformMass::drawRigid3DImpl(const VisualParams* vparams) len[1] = sqrt(m00+m22-m11); len[2] = sqrt(m00+m11-m22); - for (unsigned int i=0; iisSleeping()) - vparams->drawTool()->drawFrame(x[indices[i]].getCenter(), x[indices[i]].getOrientation(), len*d_showAxisSize.getValue(), sofa::type::RGBAColor::gray()); + vparams->drawTool()->drawFrame(x[index].getCenter(), x[index].getOrientation(), len*d_showAxisSize.getValue(), sofa::type::RGBAColor::gray()); else - vparams->drawTool()->drawFrame(x[indices[i]].getCenter(), x[indices[i]].getOrientation(), len*d_showAxisSize.getValue() ); - gravityCenter += (x[indices[i]].getCenter()); + vparams->drawTool()->drawFrame(x[index].getCenter(), x[index].getOrientation(), len*d_showAxisSize.getValue() ); + gravityCenter += (x[index].getCenter()); } if (d_showInitialCenterOfGravity.getValue()) { const VecCoord& x0 = mstate->read(core::ConstVecCoordId::restPosition())->getValue(); - for (unsigned int i=0; idrawTool()->drawFrame(x0[indices[i]].getCenter(), x0[indices[i]].getOrientation(), len*d_showAxisSize.getValue()); + for (const unsigned int index : indices) + vparams->drawTool()->drawFrame(x0[index].getCenter(), x0[index].getOrientation(), len*d_showAxisSize.getValue()); } if(d_showCenterOfGravity.getValue()) @@ -336,12 +336,12 @@ Vec6 UniformMass::getMomentumRigid3DImpl( const MechanicalParams*, type::Vec6d momentum; - for ( unsigned int i=0 ; i::getMomentumVec3DImpl ( const MechanicalParams*, const MassType& m = d_vertexMass.getValue(); type::Vec6d momentum; - for ( unsigned int i=0 ; i::getPotentialEnergyRigidImpl(const core::MechanicalP const ReadAccessor > indices = d_indices; typename Coord::Pos g ( getContext()->getGravity() ); - for (unsigned int i=0; i::addMDxToVectorVecImpl(linearalgebra::BaseVector *res const SReal* g = getContext()->getGravity().ptr(); - for (unsigned int i=0; iadd(offset + indices[i] * derivDim + j, mFact * m * g[j] * (*dx)[indices[i]][0]); + resVect->add(offset + index * derivDim + j, mFact * m * g[j] * (*dx)[index][0]); else - resVect->add(offset + indices[i] * derivDim + j, mFact * m * g[j]); + resVect->add(offset + index * derivDim + j, mFact * m * g[j]); } + } } diff --git a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/EulerImplicitSolver.cpp b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/EulerImplicitSolver.cpp index f0b2cab56cb3..dedd25d0729b 100644 --- a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/EulerImplicitSolver.cpp +++ b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/EulerImplicitSolver.cpp @@ -55,8 +55,8 @@ void EulerImplicitSolver::init() msg_info() << "EulerImplicitSolver: responsible for the following objects with tags " << this->getTags() << " :"; type::vector objs; this->getContext()->get(&objs,this->getTags(),sofa::core::objectmodel::BaseContext::SearchDown); - for (unsigned int i=0; igetClassName() << ' ' << objs[i]->getName(); + for (const auto* obj : objs) + msg_info() << " " << obj->getClassName() << ' ' << obj->getName(); } sofa::core::behavior::OdeSolver::init(); } diff --git a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/VariationalSymplecticSolver.cpp b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/VariationalSymplecticSolver.cpp index 3ebae89c8599..9759e95ccd7a 100644 --- a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/VariationalSymplecticSolver.cpp +++ b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/VariationalSymplecticSolver.cpp @@ -59,8 +59,8 @@ void VariationalSymplecticSolver::init() type::vector objs; this->getContext()->get(&objs,this->getTags(),sofa::core::objectmodel::BaseContext::SearchDown); std::stringstream tmp; - for (unsigned int i=0;igetClassName() << ' ' << objs[i]->getName() << msgendl; + for (const auto* obj : objs) + tmp << " " << obj->getClassName() << ' ' << obj->getName() << msgendl; msg_info() << "Responsible for the following objects with tags " << this->getTags() << " :" << tmp.str(); } diff --git a/Sofa/Component/Playback/src/sofa/component/playback/ReadState.cpp b/Sofa/Component/Playback/src/sofa/component/playback/ReadState.cpp index a949dcf4bb96..b433e6f6c827 100644 --- a/Sofa/Component/Playback/src/sofa/component/playback/ReadState.cpp +++ b/Sofa/Component/Playback/src/sofa/component/playback/ReadState.cpp @@ -86,8 +86,10 @@ void ReadStateCreator::addReadState(sofa::core::behavior::BaseMechanicalState *m { rs = sofa::core::objectmodel::New(); gnode->addObject(rs); - for (core::objectmodel::TagSet::iterator it=this->subsetsToManage.begin(); it != this->subsetsToManage.end(); ++it) - rs->addTag(*it); + for (const auto& subset : this->subsetsToManage) + { + rs->addTag(subset); + } } std::ostringstream ofilename; diff --git a/Sofa/Component/Playback/src/sofa/component/playback/ReadTopology.cpp b/Sofa/Component/Playback/src/sofa/component/playback/ReadTopology.cpp index cf50a2f72d3a..739af276e228 100644 --- a/Sofa/Component/Playback/src/sofa/component/playback/ReadTopology.cpp +++ b/Sofa/Component/Playback/src/sofa/component/playback/ReadTopology.cpp @@ -82,8 +82,10 @@ void ReadTopologyCreator::addReadTopology(core::topology::BaseMeshTopology* topo { rt = sofa::core::objectmodel::New(); gnode->addObject(rt); - for (core::objectmodel::TagSet::iterator it=this->subsetsToManage.begin(); it != this->subsetsToManage.end(); ++it) - rt->addTag(*it); + for (const auto& subset : this->subsetsToManage) + { + rt->addTag(subset); + } } std::ostringstream ofilename; diff --git a/Sofa/Component/Playback/src/sofa/component/playback/WriteState.cpp b/Sofa/Component/Playback/src/sofa/component/playback/WriteState.cpp index 7cfa8f6c7445..06ab7863b864 100644 --- a/Sofa/Component/Playback/src/sofa/component/playback/WriteState.cpp +++ b/Sofa/Component/Playback/src/sofa/component/playback/WriteState.cpp @@ -96,9 +96,10 @@ void WriteStateCreator::addWriteState(sofa::core::behavior::BaseMechanicalState ws->d_writeX.setValue(recordX); ws->d_writeV.setValue(recordV); ws->d_writeF.setValue(recordF); - for (core::objectmodel::TagSet::iterator it=this->subsetsToManage.begin(); it != this->subsetsToManage.end(); ++it) - ws->addTag(*it); - + for (const auto& subset : this->subsetsToManage) + { + ws->addTag(subset); + } } std::ostringstream ofilename; ofilename << sceneName << "_" << counterWriteState << "_" << ms->getName() << "_mstate" << extension ; diff --git a/Sofa/Component/Playback/src/sofa/component/playback/WriteTopology.cpp b/Sofa/Component/Playback/src/sofa/component/playback/WriteTopology.cpp index 2b94bcbf9308..7bb4d3600966 100644 --- a/Sofa/Component/Playback/src/sofa/component/playback/WriteTopology.cpp +++ b/Sofa/Component/Playback/src/sofa/component/playback/WriteTopology.cpp @@ -94,8 +94,10 @@ void WriteTopologyCreator::addWriteTopology(core::topology::BaseMeshTopology* to gnode->addObject(wt); wt->f_writeContainers.setValue(recordContainers); wt->f_writeShellContainers.setValue(recordShellContainers); - for (core::objectmodel::TagSet::iterator it=this->subsetsToManage.begin(); it != this->subsetsToManage.end(); ++it) - wt->addTag(*it); + for (const auto& subset : this->subsetsToManage) + { + wt->addTag(subset); + } } std::ostringstream ofilename; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl index 29742f59754f..01d44928705b 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl @@ -466,9 +466,9 @@ void HexahedralFEMForceField::accumulateForceLarge( WDataRefVecDeriv& Displacement D; for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = hexahedronInf[i].rotatedInitialElements[k][j] - deformed[k][j]; + D[index+j] = hexahedronInf[i].rotatedInitialElements[k][j] - deformed[k][j]; } Displacement F; //forces @@ -567,9 +567,9 @@ void HexahedralFEMForceField::accumulateForcePolar(WDataRefVecDeriv& Displacement D; for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = hexahedronInf[i].rotatedInitialElements[k][j] - deformed[k][j]; + D[index+j] = hexahedronInf[i].rotatedInitialElements[k][j] - deformed[k][j]; } //forces diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl index a07b0a395745..a82e6df7406e 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl @@ -233,9 +233,9 @@ void HexahedralFEMForceFieldAndMass::addMDx(const core::MechanicalPar for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - actualDx[indice+j] = _dx[hexahedra[i][k]][j]; + actualDx[index+j] = _dx[hexahedra[i][k]][j]; } actualF = _elementMasses.getValue()[i] * actualDx; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl index 0cf9f338b260..989bc6a7876e 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl @@ -775,9 +775,9 @@ void HexahedronFEMForceField::accumulateForceSmall ( WDataRefVecDeriv Displacement D; for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = _rotatedInitialElements[i][k][j] - nodes[k][j]; + D[index+j] = _rotatedInitialElements[i][k][j] - nodes[k][j]; } auto& stiffnesses = *sofa::helper::getWriteOnlyAccessor(_elementStiffnesses); @@ -878,9 +878,9 @@ void HexahedronFEMForceField::accumulateForceLarge( WDataRefVecDeriv Displacement D; for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = _rotatedInitialElements[i][k][j] - deformed[k][j]; + D[index+j] = _rotatedInitialElements[i][k][j] - deformed[k][j]; } auto& stiffnesses = *sofa::helper::getWriteOnlyAccessor(_elementStiffnesses); @@ -1073,9 +1073,9 @@ void HexahedronFEMForceField::accumulateForcePolar( WDataRefVecDeriv Displacement D; for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = _rotatedInitialElements[i][k][j] - deformed[k][j]; + D[index+j] = _rotatedInitialElements[i][k][j] - deformed[k][j]; } //forces diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.inl index b2ae4ec2ba53..326f6ff8dda1 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.inl @@ -192,9 +192,9 @@ void HexahedronFEMForceFieldAndMass::addMDx(const core::MechanicalPar for(int k=0 ; k<8 ; ++k ) { - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - actualDx[indice+j] = _dx[(*it)[k]][j]; + actualDx[index+j] = _dx[(*it)[k]][j]; } diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.inl b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.inl index d36a55713dea..a0f73d9b64c8 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.inl +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.inl @@ -959,9 +959,9 @@ void NonUniformHexahedralFEMForceFieldAndMass::addMBKdx(const core::M { Deriv x_2 = Ret * dx[hexahedra[i][k]]; - const int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - rdx[indice+j] = x_2[j]; + rdx[index+j] = x_2[j]; } rdf = this->_elementMasses.getValue()[i] * rdx * mFactor - hexahedronInf[i].stiffness * rdx * kFactor; diff --git a/Sofa/Component/StateContainer/src/sofa/component/statecontainer/MechanicalObject.cpp b/Sofa/Component/StateContainer/src/sofa/component/statecontainer/MechanicalObject.cpp index 4ad26ec6ffb3..8de57022975c 100644 --- a/Sofa/Component/StateContainer/src/sofa/component/statecontainer/MechanicalObject.cpp +++ b/Sofa/Component/StateContainer/src/sofa/component/statecontainer/MechanicalObject.cpp @@ -57,10 +57,10 @@ void MechanicalObject::applyRotation (const type::Quat { helper::WriteAccessor< Data > x = *this->write(core::VecCoordId::position()); - for (unsigned int i = 0; i < x.size(); i++) + for (RigidCoord<3, SReal>& xi : x) { - x[i].getCenter() = q.rotate(x[i].getCenter()); - x[i].getOrientation() = q * x[i].getOrientation(); + xi.getCenter() = q.rotate(xi.getCenter()); + xi.getOrientation() = q * xi.getOrientation(); } } diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 9d79657dd649..a8616acbe7ee 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -74,15 +74,14 @@ void MeshTopology::EdgeUpdate::updateFromVolume() unsigned int edgeIndex; const SeqTetrahedra& tetrahedra = topology->getTetrahedra(); // do not use seqTetrahedra directly as it might not be up-to-date - for (unsigned int i = 0; i < tetrahedra.size(); ++i) + for (const auto& t : tetrahedra) { - const Tetra &t=tetrahedra[i]; std::map::iterator ite; Edge e; - for (unsigned int j=0; j<6; ++j) + for (const auto j : edgesInTetrahedronArray) { - unsigned int v1=t[edgesInTetrahedronArray[j][0]]; - unsigned int v2=t[edgesInTetrahedronArray[j][1]]; + unsigned int v1 = t[j[0]]; + unsigned int v2 = t[j[1]]; // sort vertices in lexicographics order if (v1::iterator ite; Edge e; - for (unsigned int j=0; j<12; ++j) + for (const auto j : edgesInHexahedronArray) { - unsigned int v1=h[edgesInHexahedronArray[j][0]]; - unsigned int v2=h[edgesInHexahedronArray[j][1]]; + unsigned int v1 = h[j[0]]; + unsigned int v2 = h[j[1]]; // sort vertices in lexicographics order if (v1seqEdges.beginEdit(); seqEdges.clear(); const SeqTriangles& triangles = topology->getTriangles(); // do not use seqTriangles directly as it might not be up-to-date - for (unsigned int i = 0; i < triangles.size(); ++i) + for (const auto& t : triangles) { - const Triangle &t=triangles[i]; std::map::iterator ite; Edge e; for (unsigned int j=0; j<3; ++j) @@ -192,9 +189,8 @@ void MeshTopology::EdgeUpdate::updateFromSurface() } const SeqQuads& quads = topology->getQuads(); // do not use seqQuads directly as it might not be up-to-date - for (unsigned int i = 0; i < quads.size(); ++i) + for (const auto& t : quads) { - const Quad &t=quads[i]; std::map::iterator ite; Edge e; for (unsigned int j=0; j<4; ++j) @@ -252,10 +248,10 @@ void MeshTopology::TriangleUpdate::doUpdate() for (unsigned int i = 0; i < tetrahedra.size(); ++i) { const Tetra &t=topology->seqTetrahedra.getValue()[i]; - for (TriangleID j=0; j<4; ++j) + for (const auto j : sofa::core::topology::trianglesOrientationInTetrahedronArray) { for (PointID k=0; k<3; ++k) - v[k] = t[sofa::core::topology::trianglesOrientationInTetrahedronArray[j][k]]; + v[k] = t[j[k]]; // sort v such that v[0] is the smallest one while ((v[0]>v[1]) || (v[0]>v[2])) @@ -307,10 +303,8 @@ void MeshTopology::QuadUpdate::doUpdate() unsigned int v[4],val; unsigned int quadIndex; /// create the m_edge array at the same time than it fills the m_edgesInHexahedron array - for (unsigned int i = 0; i < hexahedra.size(); ++i) + for (const auto& h : hexahedra) { - const Hexa &h=hexahedra[i]; - // Quad 0 : v[0]=h[0]; v[1]=h[3]; v[2]=h[2]; v[3]=h[1]; // sort v such that v[0] is the smallest one @@ -2445,17 +2439,17 @@ const sofa::type::vector MeshTopology::getConnectedElement(Index elem) elemNextFront = this->getElementAroundElements(elemOnFront); // for each elementID on the propagation front // Second Step - Avoid backward direction - for (unsigned int i = 0; i MeshTopology::getElementAroundElement(Index elem elemAV = this->getEdgesAroundVertex(getEdge(elem)[i]); - for (unsigned int j = 0; j MeshTopology::getElementAroundElements(sofa::typ } - for (unsigned int i = 0; i elemTmp2 = this->getElementAroundElement(elems[i]); + sofa::type::vector elemTmp2 = this->getElementAroundElement(elem); elemTmp.insert(elemTmp.end(), elemTmp2.begin(), elemTmp2.end()); } - for (unsigned int i = 0; i MeshTopology::getElementAroundElements(sofa::typ if (!find) { - for (unsigned int j = 0; j::computeTaskForceLarge(RDataRefV sofa::type::Vec<24, Real> D; for(int k=0 ; k<8 ; ++k ) { - int indice = k*3; + const int index = k*3; for(int j=0 ; j<3 ; ++j ) - D[indice+j] = this->_rotatedInitialElements[elementId][k][j] - deformed[k][j]; + D[index+j] = this->_rotatedInitialElements[elementId][k][j] - deformed[k][j]; } if(updateStiffnessMatrices) diff --git a/applications/projects/runSofa/Main.cpp b/applications/projects/runSofa/Main.cpp index 0cc622d85a22..017b1e2b3816 100644 --- a/applications/projects/runSofa/Main.cpp +++ b/applications/projects/runSofa/Main.cpp @@ -397,9 +397,10 @@ int main(int argc, char** argv) sofa::gui::batch::init(); auto& pluginManager = PluginManager::getInstance(); - - for (unsigned int i=0; i