RE: modernize C++: use range-based for loop
This commit is contained in:
@@ -245,8 +245,8 @@ private:
|
||||
}
|
||||
|
||||
int index=0;
|
||||
for (std::vector<Base::Vector3f>::iterator it = pts.begin(); it != pts.end(); ++it) {
|
||||
clPoints(index++) = gp_Pnt(it->x, it->y, it->z);
|
||||
for (const auto & pt : pts) {
|
||||
clPoints(index++) = gp_Pnt(pt.x, pt.y, pt.z);
|
||||
}
|
||||
|
||||
Reen::BSplineParameterCorrection pc(uOrder,vOrder,uPoles,vPoles);
|
||||
|
||||
@@ -654,14 +654,14 @@ bool ParameterCorrection::GetUVParameters(double fSizeFactor)
|
||||
_pvcUVParam->Init(gp_Pnt2d(0.0, 0.0));
|
||||
int ii=0;
|
||||
if (clBBox.MaxX - clBBox.MinX >= clBBox.MaxY - clBBox.MinY) {
|
||||
for (std::vector<Base::Vector2d>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->x-tx)/fDeltaX, (It2->y-ty)/fDeltaY);
|
||||
for (const auto & pt : vcProjPts) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((pt.x-tx)/fDeltaX, (pt.y-ty)/fDeltaY);
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<Base::Vector2d>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->y-ty)/fDeltaY, (It2->x-tx)/fDeltaX);
|
||||
for (const auto & pt : vcProjPts) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((pt.y-ty)/fDeltaY, (pt.x-tx)/fDeltaX);
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
@@ -1101,9 +1101,9 @@ bool BSplineParameterCorrection::SolveWithSmoothing(double fWeight)
|
||||
|
||||
math_Matrix MTM(0, ulDim-1, 0, ulDim-1);
|
||||
int rowIndex=0;
|
||||
for (QFuture< std::vector<double> >::const_iterator it = future.begin(); it != future.end(); ++it) {
|
||||
for (const auto & it : future) {
|
||||
int colIndex=0;
|
||||
for (std::vector<double>::const_iterator jt = it->begin(); jt != it->end(); ++jt, colIndex++)
|
||||
for (std::vector<double>::const_iterator jt = it.begin(); jt != it.end(); ++jt, colIndex++)
|
||||
MTM(rowIndex, colIndex) = *jt;
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
@@ -111,15 +111,15 @@ CmdApproxPlane::CmdApproxPlane()
|
||||
void CmdApproxPlane::activated(int)
|
||||
{
|
||||
std::vector<App::GeoFeature*> obj = Gui::Selection().getObjectsOfType<App::GeoFeature>();
|
||||
for (std::vector<App::GeoFeature*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
for (const auto& it : obj) {
|
||||
std::vector<Base::Vector3d> aPoints;
|
||||
std::vector<Base::Vector3d> aNormals;
|
||||
|
||||
std::vector<App::Property*> List;
|
||||
(*it)->getPropertyList(List);
|
||||
for (std::vector<App::Property*>::iterator jt = List.begin(); jt != List.end(); ++jt) {
|
||||
if ((*jt)->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
|
||||
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(*jt)->getComplexData();
|
||||
it->getPropertyList(List);
|
||||
for (const auto& jt : List) {
|
||||
if (jt->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
|
||||
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(jt)->getComplexData();
|
||||
if (data) {
|
||||
data->getPoints(aPoints, aNormals, 0.01f);
|
||||
if (!aPoints.empty())
|
||||
@@ -137,8 +137,8 @@ void CmdApproxPlane::activated(int)
|
||||
|
||||
std::vector<Base::Vector3f> aData;
|
||||
aData.reserve(aPoints.size());
|
||||
for (std::vector<Base::Vector3d>::iterator jt = aPoints.begin(); jt != aPoints.end(); ++jt)
|
||||
aData.push_back(Base::toVector<float>(*jt));
|
||||
for (const auto& jt : aPoints)
|
||||
aData.push_back(Base::toVector<float>(jt));
|
||||
MeshCore::PlaneFit fit;
|
||||
fit.AddPoints(aData);
|
||||
float sigma = fit.Fit();
|
||||
@@ -506,9 +506,9 @@ void CmdMeshBoundary::activated(int)
|
||||
TopoDS_Shape shape;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
|
||||
for (auto bt = bounds.begin(); bt != bounds.end(); ++bt) {
|
||||
for (const auto& bt : bounds) {
|
||||
BRepBuilderAPI_MakePolygon mkPoly;
|
||||
for (std::vector<Base::Vector3f>::reverse_iterator it = bt->rbegin(); it != bt->rend(); ++it) {
|
||||
for (auto it = bt.rbegin(); it != bt.rend(); ++it) {
|
||||
mkPoly.Add(gp_Pnt(it->x,it->y,it->z));
|
||||
}
|
||||
if (mkPoly.IsDone()) {
|
||||
@@ -594,8 +594,8 @@ void CmdViewTriangulation::activated(int)
|
||||
addModule(App,"ReverseEngineering");
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "View triangulation"));
|
||||
try {
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
App::DocumentObjectT objT(*it);
|
||||
for (const auto & it : obj) {
|
||||
App::DocumentObjectT objT(it);
|
||||
QString document = QString::fromStdString(objT.getDocumentPython());
|
||||
QString object = QString::fromStdString(objT.getObjectPython());
|
||||
|
||||
|
||||
@@ -104,13 +104,13 @@ void Segmentation::accept()
|
||||
finder.FindSegments(segm);
|
||||
|
||||
std::vector<MeshCore::MeshSurfaceSegmentPtr> segmSurf;
|
||||
for (std::vector<MeshCore::MeshSurfaceSegmentPtr>::iterator it = segm.begin(); it != segm.end(); ++it) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = (*it)->GetSegments();
|
||||
for (const auto& it : segm) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
|
||||
|
||||
// For each planar segment compute a plane and use this then for a more accurate 2nd segmentation
|
||||
if (strcmp((*it)->GetType(), "Plane") == 0) {
|
||||
for (std::vector<MeshCore::MeshSegment>::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
|
||||
std::vector<MeshCore::PointIndex> indexes = kernel.GetFacetPoints(*jt);
|
||||
if (strcmp(it->GetType(), "Plane") == 0) {
|
||||
for (const auto& jt : data) {
|
||||
std::vector<MeshCore::PointIndex> indexes = kernel.GetFacetPoints(jt);
|
||||
MeshCore::PlaneFit fit;
|
||||
fit.AddPoints(kernel.GetPoints(indexes));
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
@@ -140,17 +140,17 @@ void Segmentation::accept()
|
||||
std::vector<App::DocumentObject*> failures;
|
||||
algo.SetFacetFlag(MeshCore::MeshFacet::TMP0);
|
||||
|
||||
for (std::vector<MeshCore::MeshSurfaceSegmentPtr>::iterator it = segmSurf.begin(); it != segmSurf.end(); ++it) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = (*it)->GetSegments();
|
||||
for (const auto& it : segmSurf) {
|
||||
const std::vector<MeshCore::MeshSegment>& data = it->GetSegments();
|
||||
std::shared_ptr<MeshCore::MeshDistanceGenericSurfaceFitSegment> genSegm = std::dynamic_pointer_cast
|
||||
<MeshCore::MeshDistanceGenericSurfaceFitSegment>(*it);
|
||||
<MeshCore::MeshDistanceGenericSurfaceFitSegment>(it);
|
||||
|
||||
bool isPlanar = (strcmp(genSegm->GetType(), "Plane") == 0);
|
||||
for (std::vector<MeshCore::MeshSegment>::const_iterator jt = data.begin(); jt != data.end(); ++jt) {
|
||||
for (const auto& jt : data) {
|
||||
// reset flag for facets of segment
|
||||
algo.ResetFacetsFlag(*jt, MeshCore::MeshFacet::TMP0);
|
||||
algo.ResetFacetsFlag(jt, MeshCore::MeshFacet::TMP0);
|
||||
|
||||
Mesh::MeshObject* segment = mesh->meshFromSegment(*jt);
|
||||
Mesh::MeshObject* segment = mesh->meshFromSegment(jt);
|
||||
Mesh::Feature* feaSegm = static_cast<Mesh::Feature*>(group->addObject("Mesh::Feature", "Segment"));
|
||||
Mesh::MeshObject* feaMesh = feaSegm->Mesh.startEditing();
|
||||
feaMesh->swap(*segment);
|
||||
@@ -158,12 +158,12 @@ void Segmentation::accept()
|
||||
delete segment;
|
||||
|
||||
std::stringstream label;
|
||||
label << feaSegm->Label.getValue() << " (" << (*it)->GetType() << ")";
|
||||
label << feaSegm->Label.getValue() << " (" << it->GetType() << ")";
|
||||
feaSegm->Label.setValue(label.str());
|
||||
|
||||
if (createCompound) {
|
||||
std::list<std::vector<Base::Vector3f> > bounds;
|
||||
algo.GetFacetBorders(*jt, bounds);
|
||||
algo.GetFacetBorders(jt, bounds);
|
||||
|
||||
// Handle planar segments
|
||||
if (isPlanar) {
|
||||
@@ -174,10 +174,10 @@ void Segmentation::accept()
|
||||
Handle(Geom_Plane) hPlane(new Geom_Plane(loc, dir));
|
||||
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (auto bt = bounds.begin(); bt != bounds.end(); ++bt) {
|
||||
for (const auto & bound : bounds) {
|
||||
// project the points onto the surface
|
||||
std::vector<gp_Pnt> polygon;
|
||||
std::transform(bt->begin(), bt->end(), std::back_inserter(polygon), [&hPlane](const Base::Vector3f& v) {
|
||||
std::transform(bound.begin(), bound.end(), std::back_inserter(polygon), [&hPlane](const Base::Vector3f& v) {
|
||||
gp_Pnt p(v.x, v.y, v.z);
|
||||
return GeomAPI_ProjectPointOnSurf(p, hPlane).NearestPoint();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user