diff --git a/src/Mod/MeshPart/App/CurveProjector.cpp b/src/Mod/MeshPart/App/CurveProjector.cpp index deb0d5eff3..bd92273d32 100644 --- a/src/Mod/MeshPart/App/CurveProjector.cpp +++ b/src/Mod/MeshPart/App/CurveProjector.cpp @@ -67,7 +67,8 @@ using MeshCore::MeshFacetGrid; using MeshCore::MeshFacet; CurveProjector::CurveProjector(const TopoDS_Shape &aShape, const MeshKernel &pMesh) -: _Shape(aShape), _Mesh(pMesh) + : _Shape(aShape) + , _Mesh(pMesh) { } @@ -78,9 +79,9 @@ void CurveProjector::writeIntersectionPointsToFile(const char *name) Base::ofstream str(fi, std::ios::out | std::ios::binary); str.precision(4); str.setf(std::ios::fixed | std::ios::showpoint); - for (result_type::const_iterator it1 = mvEdgeSplitPoints.begin();it1!=mvEdgeSplitPoints.end();++it1) { - for (std::vector::const_iterator it2 = it1->second.begin();it2!=it1->second.end();++it2) { - str << it2->p1.x << " " << it2->p1.y << " " << it2->p1.z << std::endl; + for (const auto & it1 : mvEdgeSplitPoints) { + for (const auto & it2 : it1.second) { + str << it2.p1.x << " " << it2.p1.y << " " << it2.p1.z << std::endl; } } str.close(); @@ -93,9 +94,9 @@ void CurveProjector::writeIntersectionPointsToFile(const char *name) //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CurveProjectorShape::CurveProjectorShape(const TopoDS_Shape &aShape, const MeshKernel &pMesh) -: CurveProjector(aShape,pMesh) + : CurveProjector(aShape, pMesh) { - Do(); + CurveProjectorShape::Do(); } void CurveProjectorShape::Do() @@ -110,8 +111,8 @@ void CurveProjectorShape::Do() } -void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge, - std::vector &vSplitEdges) +void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge, + std::vector &vSplitEdges) { Standard_Real fFirst, fLast; Handle(Geom_Curve) hCurve = BRep_Tool::Curve( aEdge,fFirst,fLast ); @@ -641,16 +642,16 @@ void CurveProjectorWithToolMesh::makeToolMesh( const TopoDS_Edge& aEdge,std::vec Base::Vector3f lp(FLOAT_MAX,0,0), ln, p1, p2, p3, p4,p5,p6; float ToolSize = 0.2f; - for (std::vector::iterator It2=LineSegs.begin(); It2!=LineSegs.end();++It2) + for (const auto & It2 : LineSegs) { if(lp.x != FLOAT_MAX) { p1 = lp + (ln * (-ToolSize)); p2 = lp + (ln * ToolSize); p3 = lp; - p4 = (*It2).p; - p5 = (*It2).p + ((*It2).n * (-ToolSize)); - p6 = (*It2).p + ((*It2).n * ToolSize); + p4 = It2.p; + p5 = It2.p + (It2.n * (-ToolSize)); + p6 = It2.p + (It2.n * ToolSize); cVAry.emplace_back(p3,p2,p6); cVAry.emplace_back(p3,p6,p4); @@ -659,8 +660,8 @@ void CurveProjectorWithToolMesh::makeToolMesh( const TopoDS_Edge& aEdge,std::vec } - lp = (*It2).p; - ln = (*It2).n; + lp = It2.p; + ln = It2.n; } } @@ -713,9 +714,10 @@ void MeshProjection::splitMeshByShape ( const TopoDS_Shape &aShape, float fMaxDi Base::ofstream str(fi, std::ios::out | std::ios::binary); str.precision(4); str.setf(std::ios::fixed | std::ios::showpoint); - for (std::vector::const_iterator it = rPolyLines.begin();it!=rPolyLines.end();++it) { - for (std::vector::const_iterator jt = it->points.begin();jt != it->points.end();++jt) - str << jt->x << " " << jt->y << " " << jt->z << std::endl; + for (const auto & it : rPolyLines) { + for (const auto& jt : it.points) { + str << jt.x << " " << jt.y << " " << jt.z << std::endl; + } } str.close(); } @@ -1021,12 +1023,12 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist auFInds.erase(std::unique(auFInds.begin(), auFInds.end()), auFInds.end()); // facet to edge - for ( std::vector::iterator pI = auFInds.begin(); pI != auFInds.end(); ++pI ) { - const MeshFacet& rF = rclFAry[*pI]; + for (MeshCore::FacetIndex index : auFInds) { + const MeshFacet& rF = rclFAry[index]; for (int i = 0; i < 3; i++) { MeshCore::PointIndex ulPt0 = std::min(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); MeshCore::PointIndex ulPt1 = std::max(rF._aulPoints[i], rF._aulPoints[(i+1)%3]); - pEdgeToFace[std::pair(ulPt0, ulPt1)].push_front(*pI); + pEdgeToFace[std::pair(ulPt0, ulPt1)].push_front(index); } } @@ -1065,8 +1067,8 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist // continue; Base::Vector3f cEdgeNormal; - for ( std::list::const_iterator itF = auFaces.begin(); itF != auFaces.end(); ++itF ) { - cFI.Set( *itF ); + for (MeshCore::FacetIndex itF : auFaces) { + cFI.Set( itF ); cEdgeNormal += cFI->GetNormal(); } @@ -1144,8 +1146,7 @@ void MeshProjection::projectEdgeToEdge( const TopoDS_Edge &aEdge, float fMaxDist } // sorted by parameter - for (std::map::iterator itS = - rParamSplitEdges.begin(); itS != rParamSplitEdges.end(); ++itS) { - rSplitEdges.push_back( itS->second ); + for (const auto & itS : rParamSplitEdges) { + rSplitEdges.push_back( itS.second ); } } diff --git a/src/Mod/MeshPart/App/MeshAlgos.cpp b/src/Mod/MeshPart/App/MeshAlgos.cpp index 3c133a8652..11c608cad9 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.cpp +++ b/src/Mod/MeshPart/App/MeshAlgos.cpp @@ -101,8 +101,8 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize) if(fliped.empty()) break; - for(std::set::iterator It= fliped.begin();It!=fliped.end();++It) - alg.CollapseFacet(*It); + for(MeshCore::FacetIndex It : fliped) + alg.CollapseFacet(It); fliped.clear(); } @@ -448,9 +448,9 @@ void MeshAlgos::cutByCurve(MeshCore::MeshKernel* pMesh,const std::vector::const_iterator it = vSplitEdges.begin();it!=vSplitEdges.end();++it) + for (const auto & it : vSplitEdges) { - cTopAlg.SplitFacet( it->ulFaceIndex, it->p1, it->p2 ); + cTopAlg.SplitFacet( it.ulFaceIndex, it.p1, it.p2 ); } } diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index ff29561a86..218f5d353e 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -192,9 +192,8 @@ public: std::vector< std::vector > meshSegments; std::size_t numMeshFaces = 0; - for (std::size_t i = 0; i < domains.size(); ++i) { + for (const auto& domain : domains) { std::size_t numDomainFaces = 0; - const Part::TopoShape::Domain& domain = domains[i]; for (std::size_t j = 0; j < domain.facets.size(); ++j) { const Part::TopoShape::Facet& tria = domain.facets[j]; x1 = domain.points[tria.I1].x; @@ -525,8 +524,8 @@ Mesh::MeshObject* Mesher::createMesh() const mesh->ShapeToMesh(aNull); mesh->Clear(); delete mesh; - for (std::list::iterator it = hypoth.begin(); it != hypoth.end(); ++it) - delete *it; + for (auto it : hypoth) + delete it; return meshdata; #endif // HAVE_SMESH diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index 1d2178cb2b..4da4af0e89 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -128,38 +128,38 @@ void CmdMeshPartTrimByPlane::activated(int) openCommand(QT_TRANSLATE_NOOP("Command", "Trim with plane")); std::vector docObj = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); - for (std::vector::iterator it = docObj.begin(); it != docObj.end(); ++it) { + for (auto it : docObj) { Base::Vector3d normal(0,0,1); plnPlacement.getRotation().multVec(normal, normal); Base::Vector3d base = plnPlacement.getPosition(); - Mesh::MeshObject* mesh = static_cast(*it)->Mesh.startEditing(); + Mesh::MeshObject* mesh = static_cast(it)->Mesh.startEditing(); Base::Vector3f plnBase = Base::convertTo(base); Base::Vector3f plnNormal = Base::convertTo(normal); if (role == Gui::SelectionRole::Inner) { mesh->trimByPlane(plnBase, plnNormal); - static_cast(*it)->Mesh.finishEditing(); + static_cast(it)->Mesh.finishEditing(); } else if (role == Gui::SelectionRole::Outer) { mesh->trimByPlane(plnBase, -plnNormal); - static_cast(*it)->Mesh.finishEditing(); + static_cast(it)->Mesh.finishEditing(); } else if (role == Gui::SelectionRole::Split) { Mesh::MeshObject copy(*mesh); mesh->trimByPlane(plnBase, plnNormal); - static_cast(*it)->Mesh.finishEditing(); + static_cast(it)->Mesh.finishEditing(); copy.trimByPlane(plnBase, -plnNormal); - App::Document* doc = (*it)->getDocument(); + App::Document* doc = it->getDocument(); Mesh::Feature* fea = static_cast(doc->addObject("Mesh::Feature")); - fea->Label.setValue((*it)->Label.getValue()); + fea->Label.setValue(it->Label.getValue()); Mesh::MeshObject* feamesh = fea->Mesh.startEditing(); feamesh->swap(copy); fea->Mesh.finishEditing(); } - (*it)->purgeTouched(); + it->purgeTouched(); } commitCommand(); } @@ -217,8 +217,8 @@ void CmdMeshPartSection::activated(int) Py::Callable makeWire(partModule.getAttr("makePolygon")); Py::Module appModule(PyImport_ImportModule("FreeCAD"), true); Py::Callable addObject(appModule.getAttr("ActiveDocument").getAttr("addObject")); - for (std::vector::iterator it = docObj.begin(); it != docObj.end(); ++it) { - const Mesh::MeshObject* mesh = static_cast(*it)->Mesh.getValuePtr(); + for (auto it : docObj) { + const Mesh::MeshObject* mesh = static_cast(it)->Mesh.getValuePtr(); std::vector polylines; mesh->crossSections(sections, polylines); @@ -282,8 +282,8 @@ void CmdMeshPartCrossSections::activated(int iMsg) std::vector obj = Gui::Selection().getObjectsOfType (Mesh::Feature::getClassTypeId()); Base::BoundBox3d bbox; - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - bbox.Add(static_cast(*it)->Mesh.getBoundingBox()); + for (auto it : obj) { + bbox.Add(static_cast(it)->Mesh.getBoundingBox()); } dlg = new MeshPartGui::TaskCrossSections(bbox); } diff --git a/src/Mod/MeshPart/Gui/CrossSections.cpp b/src/Mod/MeshPart/Gui/CrossSections.cpp index 32fae8cb93..034016f204 100644 --- a/src/Mod/MeshPart/Gui/CrossSections.cpp +++ b/src/Mod/MeshPart/Gui/CrossSections.cpp @@ -145,10 +145,10 @@ public: algo.CutWithPlane(p, n, grid, polylines, epsilon, connectEdges); std::list wires; - for (auto it = polylines.begin(); it != polylines.end(); ++it) { + for (const auto & polyline : polylines) { BRepBuilderAPI_MakePolygon mkPoly; - for (auto jt = it->begin(); jt != it->end(); ++jt) { - mkPoly.Add(Base::convertTo(*jt)); + for (auto jt : polyline) { + mkPoly.Add(Base::convertTo(jt)); } if (mkPoly.IsDone()) @@ -286,8 +286,8 @@ void CrossSections::apply() double eps = ui->spinEpsilon->value(); #if 1 // multi-threaded sections - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - const Mesh::MeshObject& mesh = static_cast(*it)->Mesh.getValue(); + for (auto it : obj) { + const Mesh::MeshObject& mesh = static_cast(it)->Mesh.getValue(); MeshCore::MeshKernel kernel(mesh.getKernel()); kernel.Transform(mesh.getTransform()); @@ -305,16 +305,15 @@ void CrossSections::apply() BRep_Builder builder; builder.MakeCompound(comp); - for (auto ft = future.begin(); ft != future.end(); ++ft) { - const std::list& w = *ft; - for (std::list::const_iterator wt = w.begin(); wt != w.end(); ++wt) { - if (!wt->IsNull()) - builder.Add(comp, *wt); + for (const auto & w : future) { + for (const auto & wt : w) { + if (!wt.IsNull()) + builder.Add(comp, wt); } } - App::Document* doc = (*it)->getDocument(); - std::string s = (*it)->getNameInDocument(); + App::Document* doc = it->getDocument(); + std::string s = it->getNameInDocument(); s += "_cs"; Part::Feature* section = static_cast (doc->addObject("Part::Feature",s.c_str())); @@ -570,26 +569,26 @@ std::vector CrossSections::getPlanes() const void CrossSections::makePlanes(Plane type, const std::vector& d, double bound[4]) { std::vector points; - for (std::vector::const_iterator it = d.begin(); it != d.end(); ++it) { + for (double it : d) { Base::Vector3f v[4]; switch (type) { case XY: - v[0].Set(bound[0],bound[2],*it); - v[1].Set(bound[1],bound[2],*it); - v[2].Set(bound[1],bound[3],*it); - v[3].Set(bound[0],bound[3],*it); + v[0].Set(bound[0],bound[2],it); + v[1].Set(bound[1],bound[2],it); + v[2].Set(bound[1],bound[3],it); + v[3].Set(bound[0],bound[3],it); break; case XZ: - v[0].Set(bound[0],*it,bound[2]); - v[1].Set(bound[1],*it,bound[2]); - v[2].Set(bound[1],*it,bound[3]); - v[3].Set(bound[0],*it,bound[3]); + v[0].Set(bound[0],it,bound[2]); + v[1].Set(bound[1],it,bound[2]); + v[2].Set(bound[1],it,bound[3]); + v[3].Set(bound[0],it,bound[3]); break; case YZ: - v[0].Set(*it,bound[0],bound[2]); - v[1].Set(*it,bound[1],bound[2]); - v[2].Set(*it,bound[1],bound[3]); - v[3].Set(*it,bound[0],bound[3]); + v[0].Set(it,bound[0],bound[2]); + v[1].Set(it,bound[1],bound[2]); + v[2].Set(it,bound[1],bound[3]); + v[3].Set(it,bound[0],bound[3]); break; } diff --git a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp index ae1f13f2fb..b8d5be943e 100644 --- a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp @@ -198,8 +198,8 @@ void ViewProviderCurveOnMesh::setPoints(const std::vector& pts) pcCoords->point.setNum(pts.size()); SbVec3f* coords = pcCoords->point.startEditing(); int index = 0; - for (std::vector::const_iterator it = pts.begin(); it != pts.end(); ++it) { - coords[index] = *it; + for (auto it : pts) { + coords[index] = it; index++; } pcCoords->point.finishEditing(); @@ -262,8 +262,8 @@ public: { std::vector pts; pts.reserve(points.size()); - for (auto it = points.begin(); it != points.end(); ++it) { - pts.push_back(Base::convertTo(*it)); + for (const auto& it : points) { + pts.push_back(Base::convertTo(it)); } return pts; } @@ -457,8 +457,8 @@ std::vector CurveOnMeshHandler::getVertexes() const { std::vector pts; pts.reserve(d_ptr->pickedPoints.size()); - for (std::vector::const_iterator it = d_ptr->pickedPoints.begin(); it != d_ptr->pickedPoints.end(); ++it) - pts.push_back(it->point); + for (const auto & it : d_ptr->pickedPoints) + pts.push_back(it.point); return pts; } @@ -476,9 +476,9 @@ Handle(Geom_BSplineCurve) CurveOnMeshHandler::approximateSpline(const std::vecto { TColgp_Array1OfPnt pnts(1,points.size()); Standard_Integer index = 1; - for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { + for (const auto& it : points) { float x,y,z; - it->getValue(x,y,z); + it.getValue(x,y,z); pnts(index++) = gp_Pnt(x,y,z); } @@ -536,9 +536,9 @@ void CurveOnMeshHandler::displaySpline(const Handle(Geom_BSplineCurve)& spline) bool CurveOnMeshHandler::makePolyline(const std::vector& points, TopoDS_Wire& wire) { BRepBuilderAPI_MakePolygon mkPoly; - for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { + for (const auto& it : points) { float x,y,z; - it->getValue(x,y,z); + it.getValue(x,y,z); mkPoly.Add(gp_Pnt(x,y,z)); }