From 89b9a7ae0f928882ed12c22a07fa5bb2f64d49a7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 14 Aug 2023 19:45:24 +0200 Subject: [PATCH] FEM: modernize C++: use range-based for loop --- src/Mod/Fem/App/FemMesh.cpp | 113 ++++++++---------- src/Mod/Fem/App/FemMeshPyImp.cpp | 56 ++++----- src/Mod/Fem/App/FemPostFilter.cpp | 7 +- src/Mod/Fem/App/FemVTKTools.cpp | 103 ++++++++-------- src/Mod/Fem/App/PropertyPostDataObject.cpp | 4 +- src/Mod/Fem/Gui/AppFemGuiPy.cpp | 6 +- src/Mod/Fem/Gui/Command.cpp | 9 +- src/Mod/Fem/Gui/PropertyFemMeshItem.cpp | 32 ++--- src/Mod/Fem/Gui/TaskCreateNodeSet.cpp | 4 +- src/Mod/Fem/Gui/TaskFemConstraintContact.cpp | 76 ++++++------ .../Fem/Gui/TaskFemConstraintDisplacement.cpp | 44 ++++--- src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp | 44 ++++--- .../Gui/TaskFemConstraintFluidBoundary.cpp | 55 ++++----- src/Mod/Fem/Gui/TaskFemConstraintForce.cpp | 44 ++++--- src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp | 44 ++++--- .../Gui/TaskFemConstraintPlaneRotation.cpp | 43 +++---- src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp | 38 +++--- src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp | 38 +++--- .../Fem/Gui/TaskFemConstraintTemperature.cpp | 36 +++--- .../Fem/Gui/TaskFemConstraintTransform.cpp | 50 ++++---- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 8 +- src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp | 11 +- .../Gui/ViewProviderFemConstraintContact.cpp | 4 +- .../ViewProviderFemConstraintDisplacement.cpp | 5 +- .../Gui/ViewProviderFemConstraintFixed.cpp | 5 +- ...ViewProviderFemConstraintFluidBoundary.cpp | 14 +-- .../Gui/ViewProviderFemConstraintForce.cpp | 10 +- .../Gui/ViewProviderFemConstraintHeatflux.cpp | 4 +- ...ViewProviderFemConstraintPlaneRotation.cpp | 5 +- .../Gui/ViewProviderFemConstraintPressure.cpp | 4 +- .../Gui/ViewProviderFemConstraintSpring.cpp | 4 +- .../ViewProviderFemConstraintTemperature.cpp | 5 +- .../ViewProviderFemConstraintTransform.cpp | 14 +-- src/Mod/Fem/Gui/ViewProviderFemMesh.cpp | 28 ++--- src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp | 10 +- .../Fem/Gui/ViewProviderFemPostFunction.cpp | 7 +- src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp | 10 +- 37 files changed, 460 insertions(+), 534 deletions(-) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index e055f343fa..ceaf0bd50d 100644 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -251,8 +251,8 @@ void FemMesh::copyMeshData(const FemMesh& mesh) SMESHDS_Group* newGroupDS = dynamic_cast(newGroupObj->GetGroupDS()); if (newGroupDS) { SMDS_MeshGroup& smdsGroup = ((SMESHDS_Group*)newGroupDS)->SMDSGroup(); - for (unsigned i = 0; i < groupElems.size(); ++i) - smdsGroup.Add(groupElems[i]); + for (auto it : groupElems) + smdsGroup.Add(it); } } } @@ -808,8 +808,8 @@ std::map FemMesh::getccxVolumesByFace(const TopoDS_Face &face) const std::map >::iterator it = elem_order.find(num_of_nodes); if (it != elem_order.end()) { const std::vector& order = it->second; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) { - int vid = vol->GetNode(*jt)->GetID(); + for (int jt : order) { + int vid = vol->GetNode(jt)->GetID(); apair.second.push_back(vid); } } @@ -890,8 +890,7 @@ std::set FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const } #pragma omp parallel for schedule(dynamic) - for (size_t i = 0; i < nodes.size(); ++i) { - const SMDS_MeshNode* aNode = nodes[i]; + for (auto aNode : nodes) { double xyz[3]; aNode->GetXYZ(xyz); Base::Vector3d vec(xyz[0], xyz[1], xyz[2]); @@ -942,8 +941,7 @@ std::set FemMesh::getNodesByFace(const TopoDS_Face &face) const } #pragma omp parallel for schedule(dynamic) - for (size_t i = 0; i < nodes.size(); ++i) { - const SMDS_MeshNode* aNode = nodes[i]; + for (auto aNode : nodes) { double xyz[3]; aNode->GetXYZ(xyz); Base::Vector3d vec(xyz[0], xyz[1], xyz[2]); @@ -992,8 +990,7 @@ std::set FemMesh::getNodesByEdge(const TopoDS_Edge &edge) const } #pragma omp parallel for schedule(dynamic) - for (size_t i = 0; i < nodes.size(); ++i) { - const SMDS_MeshNode* aNode = nodes[i]; + for (auto aNode : nodes) { double xyz[3]; aNode->GetXYZ(xyz); Base::Vector3d vec(xyz[0], xyz[1], xyz[2]); @@ -1041,8 +1038,7 @@ std::set FemMesh::getNodesByVertex(const TopoDS_Vertex &vertex) const } #pragma omp parallel for schedule(dynamic) - for (size_t i = 0; i < nodes.size(); ++i) { - const SMDS_MeshNode* aNode = nodes[i]; + for (auto aNode : nodes) { double xyz[3]; aNode->GetXYZ(xyz); Base::Vector3d vec(xyz[0], xyz[1], xyz[2]); @@ -2077,8 +2073,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group std::map::iterator it = volTypeMap.find(numNodes); if (it != volTypeMap.end()) { const std::vector& order = elemOrderMap[it->second]; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) - apair.second.push_back(aVol->GetNode(*jt)->GetID()); + for (int jt : order) + apair.second.push_back(aVol->GetNode(jt)->GetID()); elementsMapVol[it->second].insert(apair); } } @@ -2098,8 +2094,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group std::map::iterator it = faceTypeMap.find(numNodes); if (it != faceTypeMap.end()) { const std::vector& order = elemOrderMap[it->second]; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) - apair.second.push_back(aFace->GetNode(*jt)->GetID()); + for (int jt : order) + apair.second.push_back(aFace->GetNode(jt)->GetID()); elementsMapFac[it->second].insert(apair); } } @@ -2107,16 +2103,16 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group if (elemParam == 2) { // we're going to fill the elementsMapFac with the facesOnly std::set facesOnly = getFacesOnly(); - for (std::set::iterator itfa = facesOnly.begin(); itfa != facesOnly.end(); ++itfa) { + for (int itfa : facesOnly) { std::pair > apair; - apair.first = *itfa; - const SMDS_MeshElement* aFace = myMesh->GetMeshDS()->FindElement(*itfa); + apair.first = itfa; + const SMDS_MeshElement* aFace = myMesh->GetMeshDS()->FindElement(itfa); int numNodes = aFace->NbNodes(); std::map::iterator it = faceTypeMap.find(numNodes); if (it != faceTypeMap.end()) { const std::vector& order = elemOrderMap[it->second]; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) - apair.second.push_back(aFace->GetNode(*jt)->GetID()); + for (int jt : order) + apair.second.push_back(aFace->GetNode(jt)->GetID()); elementsMapFac[it->second].insert(apair); } } @@ -2137,8 +2133,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group std::map::iterator it = edgeTypeMap.find(numNodes); if (it != edgeTypeMap.end()) { const std::vector& order = elemOrderMap[it->second]; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) - apair.second.push_back(aEdge->GetNode(*jt)->GetID()); + for (int jt : order) + apair.second.push_back(aEdge->GetNode(jt)->GetID()); elementsMapEdg[it->second].insert(apair); } } @@ -2146,16 +2142,16 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group if (elemParam == 2) { // we're going to fill the elementsMapEdg with the edgesOnly std::set edgesOnly = getEdgesOnly(); - for (std::set::iterator ited = edgesOnly.begin(); ited != edgesOnly.end(); ++ited) { + for (int ited : edgesOnly) { std::pair > apair; - apair.first = *ited; - const SMDS_MeshElement* aEdge = myMesh->GetMeshDS()->FindElement(*ited); + apair.first = ited; + const SMDS_MeshElement* aEdge = myMesh->GetMeshDS()->FindElement(ited); int numNodes = aEdge->NbNodes(); std::map::iterator it = edgeTypeMap.find(numNodes); if (it != edgeTypeMap.end()) { const std::vector& order = elemOrderMap[it->second]; - for (std::vector::const_iterator jt = order.begin(); jt != order.end(); ++jt) - apair.second.push_back(aEdge->GetNode(*jt)->GetID()); + for (int jt : order) + apair.second.push_back(aEdge->GetNode(jt)->GetID()); elementsMapEdg[it->second].insert(apair); } } @@ -2197,11 +2193,11 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group anABAQUS_Output << "*Node, NSET=Nall" << std::endl; // This way we get sorted output. // See http://forum.freecad.org/viewtopic.php?f=18&t=12646&start=40#p103004 - for (VertexMap::iterator it = vertexMap.begin(); it != vertexMap.end(); ++it) { - anABAQUS_Output << it->first << ", " - << it->second.x << ", " - << it->second.y << ", " - << it->second.z << std::endl; + for (const auto& it : vertexMap) { + anABAQUS_Output << it.first << ", " + << it.second.x << ", " + << it.second.y << ", " + << it.second.z << std::endl; } anABAQUS_Output << std::endl << std::endl;; @@ -2209,16 +2205,15 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group // write volumes to file std::string elsetname; if (!elementsMapVol.empty()) { - for (ElementsMap::iterator it = elementsMapVol.begin(); it != elementsMapVol.end(); ++it) { + for (const auto& it : elementsMapVol) { anABAQUS_Output << "** Volume elements" << std::endl; - anABAQUS_Output << "*Element, TYPE=" << it->first << ", ELSET=Evolumes" << std::endl; - for (NodesMap::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) { - anABAQUS_Output << jt->first; + anABAQUS_Output << "*Element, TYPE=" << it.first << ", ELSET=Evolumes" << std::endl; + for (const auto& jt : it.second) { + anABAQUS_Output << jt.first; // Calculix allows max 16 entries in one line, a hexa20 has more ! int ct = 0; // counter bool first_line = true; - for (std::vector::iterator kt = jt->second.begin(); kt != jt->second.end(); - ++kt, ++ct) { + for (auto kt = jt.second.begin(); kt != jt.second.end(); ++kt, ++ct) { if (ct < 15) { anABAQUS_Output << ", " << *kt; } @@ -2239,14 +2234,13 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group // write faces to file if (!elementsMapFac.empty()) { - for (ElementsMap::iterator it = elementsMapFac.begin(); it != elementsMapFac.end(); ++it) { + for (const auto& it : elementsMapFac) { anABAQUS_Output << "** Face elements" << std::endl; - anABAQUS_Output << "*Element, TYPE=" << it->first << ", ELSET=Efaces" << std::endl; - for (NodesMap::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) { - anABAQUS_Output << jt->first; - for (std::vector::iterator kt = jt->second.begin(); kt != jt->second.end(); - ++kt) { - anABAQUS_Output << ", " << *kt; + anABAQUS_Output << "*Element, TYPE=" << it.first << ", ELSET=Efaces" << std::endl; + for (const auto& jt : it.second) { + anABAQUS_Output << jt.first; + for (int kt : jt.second) { + anABAQUS_Output << ", " << kt; } anABAQUS_Output << std::endl; } @@ -2260,14 +2254,13 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group // write edges to file if (!elementsMapEdg.empty()) { - for (ElementsMap::iterator it = elementsMapEdg.begin(); it != elementsMapEdg.end(); ++it) { + for (const auto& it : elementsMapEdg) { anABAQUS_Output << "** Edge elements" << std::endl; - anABAQUS_Output << "*Element, TYPE=" << it->first << ", ELSET=Eedges" << std::endl; - for (NodesMap::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) { - anABAQUS_Output << jt->first; - for (std::vector::iterator kt = jt->second.begin(); kt != jt->second.end(); - ++kt) { - anABAQUS_Output << ", " << *kt; + anABAQUS_Output << "*Element, TYPE=" << it.first << ", ELSET=Eedges" << std::endl; + for (const auto& jt : it.second) { + anABAQUS_Output << jt.first; + for (int kt : jt.second) { + anABAQUS_Output << ", " << kt; } anABAQUS_Output << std::endl; } @@ -2293,12 +2286,12 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group anABAQUS_Output << std::endl << "** Group data" << std::endl; std::list groupIDs = myMesh->GetGroupIds(); - for (std::list::iterator it = groupIDs.begin(); it != groupIDs.end(); ++it) { + for (int it : groupIDs) { // get and write group info and group definition // TODO group element type code has duplicate code of // PyObject* FemMeshPy::getGroupElementType() - SMDSAbs_ElementType aElementType = myMesh->GetGroup(*it)->GetGroupDS()->GetType(); + SMDSAbs_ElementType aElementType = myMesh->GetGroup(it)->GetGroupDS()->GetType(); const char* groupElementType = ""; switch(aElementType) { case SMDSAbs_All : groupElementType = "All"; break; @@ -2310,8 +2303,8 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group case SMDSAbs_Ball : groupElementType = "Ball"; break; default : groupElementType = "Unknown"; break; } - const char* groupName = myMesh->GetGroup(*it)->GetName(); - anABAQUS_Output << "** GroupID: " << (*it) << " --> GroupName: " << groupName + const char* groupName = myMesh->GetGroup(it)->GetName(); + anABAQUS_Output << "** GroupID: " << (it) << " --> GroupName: " << groupName << " --> GroupElementType: " << groupElementType << std::endl; if (aElementType == SMDSAbs_Node) { @@ -2323,13 +2316,13 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group // get and write group elements std::set ids; - SMDS_ElemIteratorPtr aElemIter = myMesh->GetGroup(*it)->GetGroupDS()->GetElements(); + SMDS_ElemIteratorPtr aElemIter = myMesh->GetGroup(it)->GetGroupDS()->GetElements(); while (aElemIter->more()) { const SMDS_MeshElement* aElement = aElemIter->next(); ids.insert(aElement->GetID()); } - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - anABAQUS_Output << *it << std::endl; + for (int it : ids) { + anABAQUS_Output << it << std::endl; } // write newline after each group diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index 10afaea6c6..38f7899491 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -811,8 +811,8 @@ PyObject* FemMeshPy::getNodesBySolid(PyObject *args) } Py::List ret; std::set resultSet = getFemMeshPtr()->getNodesBySolid(fc); - for (std::set::const_iterator it = resultSet.begin();it!=resultSet.end();++it) - ret.append(Py::Long(*it)); + for (int it : resultSet) + ret.append(Py::Long(it)); return Py::new_reference_to(ret); @@ -838,8 +838,8 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args) } Py::List ret; std::set resultSet = getFemMeshPtr()->getNodesByFace(fc); - for (std::set::const_iterator it = resultSet.begin();it!=resultSet.end();++it) - ret.append(Py::Long(*it)); + for (int it : resultSet) + ret.append(Py::Long(it)); return Py::new_reference_to(ret); @@ -865,8 +865,8 @@ PyObject* FemMeshPy::getNodesByEdge(PyObject *args) } Py::List ret; std::set resultSet = getFemMeshPtr()->getNodesByEdge(fc); - for (std::set::const_iterator it = resultSet.begin();it!=resultSet.end();++it) - ret.append(Py::Long(*it)); + for (int it : resultSet) + ret.append(Py::Long(it)); return Py::new_reference_to(ret); @@ -892,8 +892,8 @@ PyObject* FemMeshPy::getNodesByVertex(PyObject *args) } Py::List ret; std::set resultSet = getFemMeshPtr()->getNodesByVertex(fc); - for (std::set::const_iterator it = resultSet.begin();it!=resultSet.end();++it) - ret.append(Py::Long(*it)); + for (int it : resultSet) + ret.append(Py::Long(it)); return Py::new_reference_to(ret); @@ -957,8 +957,8 @@ PyObject* FemMeshPy::getNodeElements(PyObject* args) std::list elemList = getFemMeshPtr()->getNodeElements(id, elemType); Py::Tuple result(elemList.size()); int index = 0; - for (std::list::iterator it = elemList.begin(); it != elemList.end(); ++it) { - result.setItem(index++, Py::Long(*it)); + for (int it : elemList) { + result.setItem(index++, Py::Long(it)); } return Py::new_reference_to(result); @@ -1021,8 +1021,8 @@ PyObject* FemMeshPy::getGroupElements(PyObject *args) Py::Tuple tuple(ids.size()); int index = 0; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : ids) { + tuple.setItem(index++, Py::Long(it)); } return Py::new_reference_to(tuple); @@ -1092,8 +1092,8 @@ PyObject* FemMeshPy::addGroupElements(PyObject *args) // Downcast Py_ssize_t to int to be compatible with SMESH functions std::set int_ids; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) - int_ids.insert(Py_SAFE_DOWNCAST(*it, Py_ssize_t, int)); + for (Py_ssize_t it : ids) + int_ids.insert(Py_SAFE_DOWNCAST(it, Py_ssize_t, int)); try { @@ -1166,8 +1166,8 @@ PyObject* FemMeshPy::getIdByElementType(PyObject *args) Py::Tuple tuple(ids.size()); int index = 0; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : ids) { + tuple.setItem(index++, Py::Long(it)); } return Py::new_reference_to(tuple); @@ -1214,8 +1214,8 @@ Py::Tuple FemMeshPy::getEdges() const Py::Tuple tuple(ids.size()); int index = 0; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : ids) { + tuple.setItem(index++, Py::Long(it)); } return tuple; @@ -1226,8 +1226,8 @@ Py::Tuple FemMeshPy::getEdgesOnly() const std::set resultSet = getFemMeshPtr()->getEdgesOnly(); Py::Tuple tuple(resultSet.size()); int index = 0; - for (std::set::iterator it = resultSet.begin(); it != resultSet.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : resultSet) { + tuple.setItem(index++, Py::Long(it)); } return tuple; @@ -1249,8 +1249,8 @@ Py::Tuple FemMeshPy::getFaces() const Py::Tuple tuple(ids.size()); int index = 0; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : ids) { + tuple.setItem(index++, Py::Long(it)); } return tuple; @@ -1261,8 +1261,8 @@ Py::Tuple FemMeshPy::getFacesOnly() const std::set resultSet = getFemMeshPtr()->getFacesOnly(); Py::Tuple tuple(resultSet.size()); int index = 0; - for (std::set::iterator it = resultSet.begin(); it != resultSet.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : resultSet) { + tuple.setItem(index++, Py::Long(it)); } return tuple; @@ -1299,8 +1299,8 @@ Py::Tuple FemMeshPy::getVolumes() const Py::Tuple tuple(ids.size()); int index = 0; - for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : ids) { + tuple.setItem(index++, Py::Long(it)); } return tuple; @@ -1352,8 +1352,8 @@ Py::Tuple FemMeshPy::getGroups() const Py::Tuple tuple(groupIDs.size()); int index = 0; - for (std::list::iterator it = groupIDs.begin(); it != groupIDs.end(); ++it) { - tuple.setItem(index++, Py::Long(*it)); + for (int it : groupIDs) { + tuple.setItem(index++, Py::Long(it)); } return tuple; diff --git a/src/Mod/Fem/App/FemPostFilter.cpp b/src/Mod/Fem/App/FemPostFilter.cpp index 19b5a6abe1..b57a286558 100644 --- a/src/Mod/Fem/App/FemPostFilter.cpp +++ b/src/Mod/Fem/App/FemPostFilter.cpp @@ -101,10 +101,9 @@ vtkDataObject* FemPostFilter::getInputData() //get the pipeline and use the pipelinedata std::vector objs = getDocument()->getObjectsOfType(FemPostPipeline::getClassTypeId()); - for (std::vector::iterator it = objs.begin(); it != objs.end(); - ++it) { - if (static_cast(*it)->holdsPostObject(this)) - return static_cast(*it)->Data.getValue(); + for (auto it : objs) { + if (static_cast(it)->holdsPostObject(this)) + return static_cast(it)->Data.getValue(); } } diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 4f3a04d1d2..1b572bba94 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -589,9 +589,9 @@ App::DocumentObject* getObjectByType(const Base::Type type) } if (obj->getTypeId() == FemAnalysis::getClassTypeId()) { std::vector fem = (static_cast(obj))->Group.getValues(); - for (std::vector::iterator it = fem.begin(); it != fem.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(type)) - return static_cast(*it);// return the first of that type + for (const auto & it : fem) { + if (it->getTypeId().isDerivedFrom(type)) + return static_cast(it);// return the first of that type } } return nullptr; @@ -833,14 +833,13 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer dataset, Base::Console().Log(" NodeNumbers have been filled with values.\n"); // vectors - for (std::map::iterator it = vectors.begin(); it != vectors.end(); - ++it) { + for (const auto & it : vectors) { int dim = 3;// Fixme: currently 3D only, here we could run into trouble, // FreeCAD only supports dim 3D, I do not know about VTK - vtkDataArray* vector_field = vtkDataArray::SafeDownCast(pd->GetArray(it->second.c_str())); + vtkDataArray* vector_field = vtkDataArray::SafeDownCast(pd->GetArray(it.second.c_str())); if (vector_field && vector_field->GetNumberOfComponents() == dim) { App::PropertyVectorList* vector_list = - static_cast(result->getPropertyByName(it->first.c_str())); + static_cast(result->getPropertyByName(it.first.c_str())); if (vector_list) { std::vector vec(nPoints); for (vtkIdType i = 0; i < nPoints; ++i) { @@ -851,31 +850,30 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer dataset, // PropertyVectorList will not show up in PropertyEditor vector_list->setValues(vec); Base::Console().Log(" A PropertyVectorList has been filled with values: %s\n", - it->first.c_str()); + it.first.c_str()); } else { Base::Console().Error("static_cast((result->" "getPropertyByName(\"%s\")) failed.\n", - it->first.c_str()); + it.first.c_str()); continue; } } else Base::Console().Message(" PropertyVectorList NOT found in vkt file data: %s\n", - it->first.c_str()); + it.first.c_str()); } // scalars - for (std::map::iterator it = scalars.begin(); it != scalars.end(); - ++it) { - vtkDataArray* vec = vtkDataArray::SafeDownCast(pd->GetArray(it->second.c_str())); + for (const auto & scalar : scalars) { + vtkDataArray* vec = vtkDataArray::SafeDownCast(pd->GetArray(scalar.second.c_str())); if (nPoints && vec && vec->GetNumberOfComponents() == 1) { App::PropertyFloatList* field = - static_cast(result->getPropertyByName(it->first.c_str())); + static_cast(result->getPropertyByName(scalar.first.c_str())); if (!field) { Base::Console().Error("static_cast((result->" "getPropertyByName(\"%s\")) failed.\n", - it->first.c_str()); + scalar.first.c_str()); continue; } @@ -891,11 +889,11 @@ void FemVTKTools::importFreeCADResult(vtkSmartPointer dataset, } field->setValues(values); Base::Console().Log(" A PropertyFloatList has been filled with vales: %s\n", - it->first.c_str()); + scalar.first.c_str()); } else Base::Console().Message(" PropertyFloatList NOT found in vkt file data %s\n", - it->first.c_str()); + scalar.first.c_str()); } // stats @@ -933,15 +931,14 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, double factor = 1.0; // vectors - for (std::map::iterator it = vectors.begin(); it != vectors.end(); - ++it) { + for (const auto & it : vectors) { const int dim = 3;//Fixme, detect dim, but FreeCAD PropertyVectorList ATM only has DIM of 3 App::PropertyVectorList* field = nullptr; - if (res->getPropertyByName(it->first.c_str())) + if (res->getPropertyByName(it.first.c_str())) field = - static_cast(res->getPropertyByName(it->first.c_str())); + static_cast(res->getPropertyByName(it.first.c_str())); else - Base::Console().Error(" PropertyVectorList not found: %s\n", it->first.c_str()); + Base::Console().Error(" PropertyVectorList not found: %s\n", it.first.c_str()); if (field && field->getSize() > 0) { //if (nPoints != field->getSize()) @@ -951,7 +948,7 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmartPointer data = vtkSmartPointer::New(); data->SetNumberOfComponents(dim); data->SetNumberOfTuples(nPoints); - data->SetName(it->second.c_str()); + data->SetName(it.second.c_str()); // we need to set values for the unused points. // TODO: ensure that the result bar does not include the used 0 if it is not @@ -963,39 +960,37 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, } } - if (it->first.compare("DisplacementVectors") == 0) + if (it.first.compare("DisplacementVectors") == 0) factor = 0.001;// to get meter else factor = 1.0; SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator(); - for (std::vector::const_iterator jt = vel.begin(); jt != vel.end(); - ++jt) { + for (const auto & jt : vel) { const SMDS_MeshNode* node = aNodeIter->next(); - double tuple[] = {jt->x * factor, jt->y * factor, jt->z * factor}; + double tuple[] = {jt.x * factor, jt.y * factor, jt.z * factor}; data->SetTuple(node->GetID() - 1, tuple); } grid->GetPointData()->AddArray(data); Base::Console().Log( " The PropertyVectorList %s was exported to VTK vector list: %s\n", - it->first.c_str(), - it->second.c_str()); + it.first.c_str(), + it.second.c_str()); } else if (field) { Base::Console().Log(" PropertyVectorList NOT exported to vtk: %s size is: %i\n", - it->first.c_str(), + it.first.c_str(), field->getSize()); } } // scalars - for (std::map::iterator it = scalars.begin(); it != scalars.end(); - ++it) { + for (const auto & scalar : scalars) { App::PropertyFloatList* field = nullptr; - if (res->getPropertyByName(it->first.c_str())) - field = static_cast(res->getPropertyByName(it->first.c_str())); + if (res->getPropertyByName(scalar.first.c_str())) + field = static_cast(res->getPropertyByName(scalar.first.c_str())); else - Base::Console().Error("PropertyFloatList %s not found \n", it->first.c_str()); + Base::Console().Error("PropertyFloatList %s not found \n", scalar.first.c_str()); if (field && field->getSize() > 0) { //if (nPoints != field->getSize()) @@ -1004,7 +999,7 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, const std::vector& vec = field->getValues(); vtkSmartPointer data = vtkSmartPointer::New(); data->SetNumberOfValues(nPoints); - data->SetName(it->second.c_str()); + data->SetName(scalar.second.c_str()); // we need to set values for the unused points. // TODO: ensure that the result bar does not include the used 0 if it is not part @@ -1015,41 +1010,41 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, } } - if ((it->first.compare("MaxShear") == 0) - || (it->first.compare("NodeStressXX") == 0) - || (it->first.compare("NodeStressXY") == 0) - || (it->first.compare("NodeStressXZ") == 0) - || (it->first.compare("NodeStressYY") == 0) - || (it->first.compare("NodeStressYZ") == 0) - || (it->first.compare("NodeStressZZ") == 0) - || (it->first.compare("PrincipalMax") == 0) - || (it->first.compare("PrincipalMed") == 0) - || (it->first.compare("PrincipalMin") == 0) - || (it->first.compare("vonMises") == 0) - || (it->first.compare("NetworkPressure") == 0) ) + if ((scalar.first.compare("MaxShear") == 0) + || (scalar.first.compare("NodeStressXX") == 0) + || (scalar.first.compare("NodeStressXY") == 0) + || (scalar.first.compare("NodeStressXZ") == 0) + || (scalar.first.compare("NodeStressYY") == 0) + || (scalar.first.compare("NodeStressYZ") == 0) + || (scalar.first.compare("NodeStressZZ") == 0) + || (scalar.first.compare("PrincipalMax") == 0) + || (scalar.first.compare("PrincipalMed") == 0) + || (scalar.first.compare("PrincipalMin") == 0) + || (scalar.first.compare("vonMises") == 0) + || (scalar.first.compare("NetworkPressure") == 0) ) factor = 1e6; // to get Pascal - else if (it->first.compare("DisplacementLengths") == 0) + else if (scalar.first.compare("DisplacementLengths") == 0) factor = 0.001; // to get meter else factor = 1.0; SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator(); - for (size_t i = 0; i < vec.size(); ++i) { + for (double i : vec) { const SMDS_MeshNode* node = aNodeIter->next(); // for the MassFlowRate the last vec entries can be a nullptr, thus check this if (node) - data->SetValue(node->GetID() - 1, vec[i] * factor); + data->SetValue(node->GetID() - 1, i * factor); } grid->GetPointData()->AddArray(data); Base::Console().Log( " The PropertyFloatList %s was exported to VTK scalar list: %s\n", - it->first.c_str(), - it->second.c_str()); + scalar.first.c_str(), + scalar.second.c_str()); } else if (field) { Base::Console().Log(" PropertyFloatList NOT exported to vtk: %s size is: %i\n", - it->first.c_str(), + scalar.first.c_str(), field->getSize()); } } diff --git a/src/Mod/Fem/App/PropertyPostDataObject.cpp b/src/Mod/Fem/App/PropertyPostDataObject.cpp index 1b3e77afce..c69446fceb 100644 --- a/src/Mod/Fem/App/PropertyPostDataObject.cpp +++ b/src/Mod/Fem/App/PropertyPostDataObject.cpp @@ -70,8 +70,8 @@ void PropertyPostDataObject::scaleDataObject(vtkDataObject *dataObject, double s for (vtkIdType i = 0; i < points->GetNumberOfPoints(); i++) { double xyz[3]; points->GetPoint(i, xyz); - for (int j = 0; j < 3; j++) - xyz[j] *= s; + for (double & j : xyz) + j *= s; points->SetPoint(i, xyz); } }; diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp index 2f0601f7ff..e7ce6212c4 100755 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -118,9 +118,9 @@ private: fi.setFile(fileName); QString ext = fi.completeSuffix().toLower(); QList views = Gui::getMainWindow()->findChildren(); - for (QList::Iterator it = views.begin(); it != views.end(); ++it) { - if ((*it)->fileName() == fileName) { - (*it)->setFocus(); + for (auto view : views) { + if (view->fileName() == fileName) { + view->setFocus(); return Py::None(); } } diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 75ed4dac15..6e91e2c7d8 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -950,8 +950,8 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) SbViewVolume vv = cam->getViewVolume(); Gui::ViewVolumeProjection proj(vv); Base::Polygon2d polygon; - for (std::vector::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it) - polygon.Add(Base::Vector2d((*it)[0], (*it)[1])); + for (auto it : clPoly) + polygon.Add(Base::Vector2d(it[0], it[1])); std::vector docObj = @@ -2364,12 +2364,11 @@ void CmdFemPostPipelineFromResult::activated(int) const std::vector obj = app->getObjectsOfType(App::DocumentObject::getClassTypeId()); - for (std::vector::const_iterator it = obj.begin(); it != obj.end(); - ++it) { + for (auto it : obj) { doCommand(Gui, "Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False", app->getName(), - (*it)->getNameInDocument()); + it->getNameInDocument()); } // we need single result object to attach the pipeline to diff --git a/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp b/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp index 1be3e60c54..68c30011df 100644 --- a/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp +++ b/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp @@ -92,8 +92,8 @@ QVariant PropertyFemMeshItem::value(const App::Property*) const int ctG = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctN += mesh->NbNodes(); ctE += mesh->NbEdges(); @@ -152,8 +152,8 @@ int PropertyFemMeshItem::countNodes() const { int ctN = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctN += mesh->NbNodes(); } @@ -165,8 +165,8 @@ int PropertyFemMeshItem::countEdges() const { int ctE = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctE += mesh->NbEdges(); } @@ -178,8 +178,8 @@ int PropertyFemMeshItem::countFaces() const { int ctF = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctF += mesh->NbFaces(); } @@ -191,8 +191,8 @@ int PropertyFemMeshItem::countPolygons() const { int ctP = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctP += mesh->NbPolygons(); } @@ -204,8 +204,8 @@ int PropertyFemMeshItem::countVolumes() const { int ctV = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctV += mesh->NbVolumes(); } @@ -217,8 +217,8 @@ int PropertyFemMeshItem::countPolyhedrons() const { int ctH = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctH += mesh->NbPolyhedrons(); } @@ -230,8 +230,8 @@ int PropertyFemMeshItem::countGroups() const { int ctG = 0; const std::vector& props = getPropertyData(); - for (std::vector::const_iterator pt = props.begin(); pt != props.end(); ++pt) { - Fem::PropertyFemMesh* prop = static_cast(*pt); + for (auto pt : props) { + Fem::PropertyFemMesh* prop = static_cast(pt); const SMESH_Mesh* mesh = prop->getValue().getSMesh(); ctG += mesh->NbGroup(); } diff --git a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp index 4e69796b26..650d7aaeba 100644 --- a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp @@ -148,8 +148,8 @@ void TaskCreateNodeSet::DefineNodesCallback(void* ud, SoEventCallback* n) SbViewVolume vv = cam->getViewVolume(); Gui::ViewVolumeProjection proj(vv); Base::Polygon2d polygon; - for (std::vector::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it) - polygon.Add(Base::Vector2d((*it)[0], (*it)[1])); + for (auto it : clPoly) + polygon.Add(Base::Vector2d(it[0], it[1])); taskBox->DefineNodes(polygon, proj, role == Gui::SelectionRole::Inner ? true : false); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp index cf938685ed..c7e09b6498 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp @@ -166,14 +166,13 @@ void TaskFemConstraintContact::addToSelectionSlave() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { QMessageBox::warning( @@ -181,19 +180,18 @@ void TaskFemConstraintContact::addToSelectionSlave() Gui::Selection().clearSelection(); return; } - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if (subNames[subIt].substr(0, 4) != "Face") { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); return; } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -206,8 +204,8 @@ void TaskFemConstraintContact::addToSelectionSlave() if (addMe) { QSignalBlocker block(ui->lw_referencesSlave); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_referencesSlave->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_referencesSlave->addItem(makeRefText(obj, subName)); } } } @@ -229,23 +227,21 @@ void TaskFemConstraintContact::removeFromSelectionSlave() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -300,33 +296,31 @@ void TaskFemConstraintContact::addToSelectionMaster() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { QMessageBox::warning( this, tr("Selection error"), tr("Only one master face for a contact constraint!")); Gui::Selection().clearSelection(); return; } - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if (subNames[subIt].substr(0, 4) != "Face") { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); return; } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -339,8 +333,8 @@ void TaskFemConstraintContact::addToSelectionMaster() if (addMe) { QSignalBlocker block(ui->lw_referencesMaster); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_referencesMaster->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_referencesMaster->addItem(makeRefText(obj, subName)); } } } @@ -362,23 +356,21 @@ void TaskFemConstraintContact::removeFromSelectionMaster() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index 35ea9040f0..419d5312d1 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -308,23 +308,21 @@ void TaskFemConstraintDisplacement::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -337,14 +335,14 @@ void TaskFemConstraintDisplacement::addToSelection() // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subNames[subIt].find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) searchStr = "Vertex"; - else if (subNames[subIt].find("Edge") != std::string::npos) + else if (subName.find("Edge") != std::string::npos) searchStr = "Edge"; else searchStr = "Face"; - for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { - if (SubElements[iStr].find(searchStr) == std::string::npos) { + for (const auto & SubElement : SubElements) { + if (SubElement.find(searchStr) == std::string::npos) { QString msg = tr( "Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); @@ -355,8 +353,8 @@ void TaskFemConstraintDisplacement::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -378,23 +376,21 @@ void TaskFemConstraintDisplacement::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp index 60f5a475dc..ec2ed3fbce 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp @@ -113,24 +113,22 @@ void TaskFemConstraintFixed::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - std::vector subNames = it->getSubNames(); + std::vector subNames = it.getSubNames(); App::DocumentObject* obj = - ConstraintView->getObject()->getDocument()->getObject(it->getFeatName()); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + ConstraintView->getObject()->getDocument()->getObject(it.getFeatName()); + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -143,14 +141,14 @@ void TaskFemConstraintFixed::addToSelection() // limit constraint such that only vertexes or faces or edges can be used depending // on what was selected first std::string searchStr; - if (subNames[subIt].find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) searchStr = "Vertex"; - else if (subNames[subIt].find("Edge") != std::string::npos) + else if (subName.find("Edge") != std::string::npos) searchStr = "Edge"; else searchStr = "Face"; - for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { - if (SubElements[iStr].find(searchStr) == std::string::npos) { + for (const auto & SubElement : SubElements) { + if (SubElement.find(searchStr) == std::string::npos) { QString msg = tr( "Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); @@ -161,8 +159,8 @@ void TaskFemConstraintFixed::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -184,23 +182,21 @@ void TaskFemConstraintFixed::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 893eb178e1..9579402dd8 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -205,9 +205,9 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( Fem::FemMeshObject* pcMesh = nullptr; if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); - for (std::vector::iterator it = fem.begin(); it != fem.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) - pcMesh = static_cast(*it); + for (auto it : fem) { + if (it->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) + pcMesh = static_cast(it); } } else { @@ -241,9 +241,9 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( pcSolver = nullptr; // this is an private object of type Fem::FemSolverObject* if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); - for (std::vector::iterator it = fem.begin(); it != fem.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) - pcSolver = static_cast(*it); + for (auto it : fem) { + if (it->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) + pcSolver = static_cast(it); } } @@ -790,22 +790,21 @@ void TaskFemConstraintFluidBoundary::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < subNames.size(); ++subIt) {// for every selected sub element + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -818,15 +817,15 @@ void TaskFemConstraintFluidBoundary::addToSelection() // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subNames[subIt].find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) searchStr = "Vertex"; - else if (subNames[subIt].find("Edge") != std::string::npos) + else if (subName.find("Edge") != std::string::npos) searchStr = "Edge"; else searchStr = "Face"; - for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { - if (SubElements[iStr].find(searchStr) == std::string::npos) { + for (const auto & SubElement : SubElements) { + if (SubElement.find(searchStr) == std::string::npos) { QString msg = tr( "Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); @@ -837,8 +836,8 @@ void TaskFemConstraintFluidBoundary::addToSelection() if (addMe) { QSignalBlocker block(ui->listReferences); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->listReferences->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->listReferences->addItem(makeRefText(obj, subName)); } } } @@ -860,23 +859,21 @@ void TaskFemConstraintFluidBoundary::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index 1ff2784840..0c031e23af 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -136,23 +136,21 @@ void TaskFemConstraintForce::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -165,15 +163,15 @@ void TaskFemConstraintForce::addToSelection() // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subNames[subIt].find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) searchStr = "Vertex"; - else if (subNames[subIt].find("Edge") != std::string::npos) + else if (subName.find("Edge") != std::string::npos) searchStr = "Edge"; else searchStr = "Face"; - for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { - if (SubElements[iStr].find(searchStr) == std::string::npos) { + for (const auto & SubElement : SubElements) { + if (SubElement.find(searchStr) == std::string::npos) { QString msg = tr( "Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); @@ -184,8 +182,8 @@ void TaskFemConstraintForce::addToSelection() if (addMe) { QSignalBlocker block(ui->listReferences); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->listReferences->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->listReferences->addItem(makeRefText(obj, subName)); } } } @@ -207,23 +205,21 @@ void TaskFemConstraintForce::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp index f8938004d2..805f242062 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp @@ -214,18 +214,17 @@ void TaskFemConstraintHeatflux::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); if (!subNames.empty()) { - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) { - if (subNames[subIt].substr(0, 4) != "Face") { + for (const auto & subName : subNames) { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning( this, tr("Selection error"), tr("Selection must only consist of faces!")); return; @@ -236,15 +235,14 @@ void TaskFemConstraintHeatflux::addToSelection() // fix me, if an object is selected completely, getSelectionEx does not return any // SubElements } - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -257,8 +255,8 @@ void TaskFemConstraintHeatflux::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -281,18 +279,17 @@ void TaskFemConstraintHeatflux::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); if (!subNames.empty()) { - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) { - if (subNames[subIt].substr(0, 4) != "Face") { + for (const auto & subName : subNames) { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning( this, tr("Selection error"), tr("Selection must only consist of faces!")); return; @@ -303,14 +300,13 @@ void TaskFemConstraintHeatflux::removeFromSelection() // fix me, if an object is selected completely, getSelectionEx does not return any // SubElements } - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp index 1dc9303e0e..e9306a2ab6 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp @@ -130,29 +130,26 @@ void TaskFemConstraintPlaneRotation::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); - it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning( this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); if (subNames.size() == 1) { - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if ((subNames[subIt].substr(0, 4) != "Face")) { + if ((subName.substr(0, 4) != "Face")) { QMessageBox::warning( this, tr("Selection error"), tr("Only faces can be picked")); return; } Part::Feature* feat = static_cast(obj); - TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str()); - if ((subNames[subIt].substr(0, 4) == "Face")) { + TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subName.c_str()); + if ((subName.substr(0, 4) == "Face")) { if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) { QMessageBox::warning( this, tr("Selection error"), tr("Only planar faces can be picked")); @@ -160,11 +157,11 @@ void TaskFemConstraintPlaneRotation::addToSelection() } } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection + subName)) {// for every sub element in selection // that matches one in old list if (obj == Objects[std::distance( @@ -177,8 +174,8 @@ void TaskFemConstraintPlaneRotation::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -210,23 +207,21 @@ void TaskFemConstraintPlaneRotation::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp index 36088495cd..107dcffa99 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp @@ -130,28 +130,26 @@ void TaskFemConstraintPressure::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if (subNames[subIt].substr(0, 4) != "Face") { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); return; } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -164,8 +162,8 @@ void TaskFemConstraintPressure::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -187,23 +185,21 @@ void TaskFemConstraintPressure::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp index 80f31eda1d..432caa4dd2 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp @@ -137,28 +137,26 @@ void TaskFemConstraintSpring::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if (subNames[subIt].substr(0, 4) != "Face") { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); return; } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -171,8 +169,8 @@ void TaskFemConstraintSpring::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -194,23 +192,21 @@ void TaskFemConstraintSpring::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp index ac5c9a9c05..f99897d4ce 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp @@ -156,24 +156,22 @@ void TaskFemConstraintTemperature::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - std::vector subNames = it->getSubNames(); + std::vector subNames = it.getSubNames(); App::DocumentObject* obj = - ConstraintView->getObject()->getDocument()->getObject(it->getFeatName()); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + ConstraintView->getObject()->getDocument()->getObject(it.getFeatName()); + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -186,8 +184,8 @@ void TaskFemConstraintTemperature::addToSelection() if (addMe) { QSignalBlocker block(ui->lw_references); Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_references->addItem(makeRefText(obj, subName)); } } } @@ -209,23 +207,21 @@ void TaskFemConstraintTemperature::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp index 7a07e7f30d..f7841b3221 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp @@ -124,9 +124,9 @@ TaskFemConstraintTransform::TaskFemConstraintTransform( } std::vector nDispl = pcConstraint->NameDispl.getValues(); - for (std::size_t i = 0; i < nDispl.size(); i++) { - ui->lw_dis_rect->addItem(makeText(nDispl[i])); - ui->lw_dis_cylin->addItem(makeText(nDispl[i])); + for (auto i : nDispl) { + ui->lw_dis_rect->addItem(makeText(i)); + ui->lw_dis_cylin->addItem(makeText(i)); } if (!Objects.empty()) { @@ -290,31 +290,29 @@ void TaskFemConstraintTransform::addToSelection() std::vector ObjDispl = pcConstraint->RefDispl.getValues(); std::vector SubElemDispl = pcConstraint->RefDispl.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { QMessageBox::warning( this, tr("Selection error"), tr("Only one face for transform constraint!")); Gui::Selection().clearSelection(); return; } - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto & subName : subNames) {// for every selected sub element bool addMe = true; - if (subNames[subIt].substr(0, 4) != "Face") { + if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); return; } - if (subNames[subIt].substr(0, 4) == "Face") { + if (subName.substr(0, 4) == "Face") { if (ui->rb_cylin->isChecked()) { Part::Feature* feat = static_cast(obj); - TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str()); + TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subName.c_str()); BRepAdaptor_Surface surface(TopoDS::Face(ref)); if (surface.GetType() != GeomAbs_Cylinder) { QMessageBox::warning(this, @@ -325,11 +323,11 @@ void TaskFemConstraintTransform::addToSelection() } } for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( @@ -346,10 +344,10 @@ void TaskFemConstraintTransform::addToSelection() &TaskFemConstraintTransform::setSelection); for (std::size_t i = 0; i < ObjDispl.size(); i++) { if ((makeRefText(ObjDispl[i], SubElemDispl[i])) - == (makeRefText(obj, subNames[subIt]))) { + == (makeRefText(obj, subName))) { Objects.push_back(obj); - SubElements.push_back(subNames[subIt]); - ui->lw_Rect->addItem(makeRefText(obj, subNames[subIt])); + SubElements.push_back(subName); + ui->lw_Rect->addItem(makeRefText(obj, subName)); connect(ui->lw_Rect, &QListWidget::currentItemChanged, this, @@ -418,23 +416,21 @@ void TaskFemConstraintTransform::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); - ++it) {// for every selected object - if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { + for (const auto & it : selection) {// for every selected object + if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } - const std::vector& subNames = it->getSubNames(); - App::DocumentObject* obj = it->getObject(); + const std::vector& subNames = it.getSubNames(); + const App::DocumentObject* obj = it.getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); - ++subIt) {// for every selected sub element + for (const auto& subName : subNames) {// for every selected sub element for (std::vector::iterator itr = - std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subNames[subIt])) {// for every sub element in selection that + subName)) {// for every sub element in selection that // matches one in old list if (obj == Objects[std::distance( diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 2db8d5ac52..c9aefa7136 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -268,8 +268,8 @@ void TaskPostBox::updateEnumerationList(App::PropertyEnumeration& prop, QComboBo { QStringList list; std::vector vec = prop.getEnumVector(); - for (std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { - list.push_back(QString::fromStdString(*it)); + for (auto it : vec) { + list.push_back(QString::fromStdString(it)); } int index = prop.getValue(); @@ -299,8 +299,8 @@ QDialogButtonBox::StandardButtons TaskDlgPost::getStandardButtons() const //check if we only have gui task boxes bool guionly = true; - for (std::vector::const_iterator it = m_boxes.begin(); it != m_boxes.end(); ++it) - guionly = guionly && (*it)->isGuiTaskOnly(); + for (auto it : m_boxes) + guionly = guionly && it->isGuiTaskOnly(); if (!guionly) return QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 84a609e406..58a783f428 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -511,12 +511,11 @@ void ViewProviderFemConstraint::updateRotation(const SoNode *node, const int idx QObject *ViewProviderFemConstraint::findChildByName(const QObject *parent, const QString &name) { - for (QObjectList::const_iterator o = parent->children().begin(); o != parent->children().end(); - o++) { - if ((*o)->objectName() == name) - return *o; - if (!(*o)->children().empty()) { - QObject *result = findChildByName(*o, name); + for (auto o : parent->children()) { + if (o->objectName() == name) + return o; + if (!o->children().empty()) { + QObject *result = findChildByName(o, name); if (result) return result; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp index fde96d0528..c76a19fc42 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp @@ -114,9 +114,9 @@ void ViewProviderFemConstraintContact::updateData(const App::Property* prop) // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (const auto & point : points) { //Define base and normal directions - SbVec3f base(p->x, p->y, p->z); + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z);//normal ///Visual indication diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index ef14cd64b4..c51af50c7c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -190,9 +190,8 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dirx(1, 0, 0); //OvG: Make relevant to global axes SbVec3f diry(0, 1, 0); //OvG: Make relevant to global axes SbVec3f dirz(0, 0, 1); //OvG: Make relevant to global axes diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index 27dd430773..739f73094a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -141,9 +141,8 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1, 0), dir); #ifdef USE_MULTIPLE_COPY diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp index 7006c96ee6..bccfb8824e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp @@ -170,9 +170,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0, 1, 0), dir); - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid base = base + dir * scaledlength; //OvG: Scaling #ifdef USE_MULTIPLE_COPY @@ -214,9 +213,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro #endif int idx = 0; - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); if (forceDirection.GetAngle(normal) < M_PI_2) base = base + dir * scaledlength; //OvG: Scaling #ifdef USE_MULTIPLE_COPY @@ -265,8 +263,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1, 0), dir); #ifdef USE_MULTIPLE_COPY diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 2772ac94e4..30de5d22d0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -149,9 +149,8 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0,1,0), dir); - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); if (forceDirection.GetAngle(normal) < M_PI_2)// Move arrow so it doesn't disappear inside the solid base = base + dir * scaledlength; //OvG: Scaling @@ -191,9 +190,8 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) #endif int idx = 0; - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); if (forceDirection.GetAngle(normal) < M_PI_2) base = base + dir * scaledlength; //OvG: Scaling #ifdef USE_MULTIPLE_COPY diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp index 203eb59e55..1013a2021c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp @@ -115,9 +115,9 @@ void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop) // Note: Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (const auto & point : points) { //Define base and normal directions - SbVec3f base(p->x, p->y, p->z); + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z);//normal ///Temperature indication diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp index 3417d00cfc..8b7dd27409 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp @@ -115,10 +115,9 @@ void ViewProviderFemConstraintPlaneRotation::updateData(const App::Property* pro // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { + for (const auto & point : points) { //Define base and normal directions - SbVec3f base(p->x, p->y, p->z); + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z);//normal /* Note: diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp index 0037bb8c8a..fd8ebf3c65 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp @@ -128,8 +128,8 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); double rev; if (pcConstraint->Reversed.getValue()) { diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp index 549cbf8bc3..5a9f07f0ae 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp @@ -128,8 +128,8 @@ void ViewProviderFemConstraintSpring::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1.0, 0), dir); #ifdef USE_MULTIPLE_COPY diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp index f08e9907cc..8833bb26f8 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp @@ -114,10 +114,9 @@ void ViewProviderFemConstraintTemperature::updateData(const App::Property* prop) // Note: Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { + for (const auto & point : points) { //Define base and normal directions - SbVec3f base(p->x, p->y, p->z); + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z);//normal ///Temperature indication diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp index ee38e81efa..41220aa6dc 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp @@ -120,11 +120,10 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); - SbVec3f basex(p->x, p->y, p->z); - SbVec3f basey(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); + SbVec3f basex(point.x, point.y, point.z); + SbVec3f basey(point.x, point.y, point.z); double x_axis_x = 1; double x_axis_y = 0; @@ -280,9 +279,8 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) pShapeSep->addChild(sepAx); } - for (std::vector::const_iterator p = points.begin(); p != points.end(); - p++) { - SbVec3f base(p->x, p->y, p->z); + for (const auto & point : points) { + SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); base = base + dir * scaledlengthA; //OvG: Scaling SbRotation rot(SbVec3f(0, 1, 0), dir); diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index 8b4f534a31..b2cfa0481b 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -513,8 +513,8 @@ void ViewProviderFemMesh::setColorByNodeId(const std::map &Node long endId = (--NodeColorMap.end())->first; std::vector colorVec(endId+1,App::Color(0,1,0)); - for(std::map::const_iterator it=NodeColorMap.begin();it!=NodeColorMap.end();++it) - colorVec[it->first] = it->second; + for(const auto & it : NodeColorMap) + colorVec[it.first] = it.second; setColorByNodeIdHelper(colorVec); @@ -566,8 +566,8 @@ void ViewProviderFemMesh::setDisplacementByNodeId(const std::map vecVec(endId-startId+2,Base::Vector3d()); - for(std::map::const_iterator it=NodeDispMap.begin();it!=NodeDispMap.end();++it) - vecVec[it->first-startId] = it->second; + for(const auto & it : NodeDispMap) + vecVec[it.first-startId] = it.second; setDisplacementByNodeIdHelper(vecVec,startId); } @@ -983,18 +983,18 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, } unsigned int max =0, avg = 0; - for(std::vector::iterator it=Grid.begin();it!=Grid.end();++it){ - for(unsigned int l=0; l< it->size();l++){ - if(! it->operator[](l)->hide){ - for(unsigned int i=l+1; isize(); i++){ - if(it->operator[](l)->isSameFace(*(it->operator[](i))) ){ + for(const auto& it : Grid){ + for(size_t l=0; l< it.size();l++){ + if(! it[l]->hide){ + for(size_t i=l+1; iisSameFace(*(it[i])) ){ break; } } } } - if(it->size() > max)max=it->size(); - avg += it->size(); + if(it.size() > max)max=it.size(); + avg += it.size(); } avg = avg/Grid.size(); @@ -1024,9 +1024,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, for (int l = 0; l < FaceSize; l++) { if (!facesHelper[l].hide) { - for (int i = 0; i < 8; i++) { - if (facesHelper[l].Nodes[i]) - mapNodeIndex[facesHelper[l].Nodes[i]] = 0; + for (auto Node : facesHelper[l].Nodes) { + if (Node) + mapNodeIndex[Node] = 0; else break; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp index 6b975ed907..26d182107a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp @@ -287,16 +287,16 @@ Py::List ViewProviderFemMeshPy::getVisibleElementFaces() const // sorting out double faces through higher order elements and null entries long elementOld = 0, faceOld = 0; - for (std::vector::const_iterator it = visElmFc.begin(); it != visElmFc.end(); ++it) { - if (*it == 0) + for (unsigned long it : visElmFc) { + if (it == 0) continue; - long element = *it >> 3; - long face = (*it & 7) + 1; + long element = it >> 3; + long face = (it & 7) + 1; if (element == elementOld && face == faceOld) continue; - trans.push_back(*it); + trans.push_back(it); elementOld = element; faceOld = face; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index 4a19663fc5..9d08b817dd 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -123,13 +123,12 @@ void ViewProviderFemPostFunctionProvider::updateData(const App::Property* prop) void ViewProviderFemPostFunctionProvider::updateSize() { std::vector vec = claimChildren(); - for (std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { - - if (!(*it)->isDerivedFrom(Fem::FemPostFunction::getClassTypeId())) + for (auto it : vec) { + if (!it->isDerivedFrom(Fem::FemPostFunction::getClassTypeId())) continue; ViewProviderFemPostFunction* vp = static_cast( - Gui::Application::Instance->getViewProvider(*it)); + Gui::Application::Instance->getViewProvider(it)); vp->AutoScaleFactorX.setValue(SizeX.getValue()); vp->AutoScaleFactorY.setValue(SizeY.getValue()); vp->AutoScaleFactorZ.setValue(SizeZ.getValue()); diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index 615d69f5c2..c4013fa85a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -873,11 +873,11 @@ void ViewProviderFemPostObject::hide() std::vector ObjectsList = doc->getObjects(); App::DocumentObject *firstVisiblePostObject = nullptr; // step through the objects - for (auto it = ObjectsList.begin(); it != ObjectsList.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { - if (!firstVisiblePostObject && (*it)->Visibility.getValue() - && !(*it)->isDerivedFrom(Fem::FemPostDataAtPointFilter::getClassTypeId())) { - firstVisiblePostObject = *it; + for (auto it : ObjectsList) { + if (it->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (!firstVisiblePostObject && it->Visibility.getValue() + && !it->isDerivedFrom(Fem::FemPostDataAtPointFilter::getClassTypeId())) { + firstVisiblePostObject = it; break; } }