Part: modernize C++: use range-based for loop
This commit is contained in:
@@ -1537,12 +1537,12 @@ bool TopoShape::analyze(bool runBopCheck, std::ostream& str) const
|
||||
for (int i = 1; i <= compsOfShape.Extent();++i)
|
||||
shapes.push_back(compsOfShape(i));
|
||||
|
||||
for (std::vector<TopoDS_Shape>::iterator xp = shapes.begin(); xp != shapes.end(); ++xp) {
|
||||
if (!aChecker.IsValid(*xp)) {
|
||||
const Handle(BRepCheck_Result)& result = aChecker.Result(*xp);
|
||||
for (const auto & shape : shapes) {
|
||||
if (!aChecker.IsValid(shape)) {
|
||||
const Handle(BRepCheck_Result)& result = aChecker.Result(shape);
|
||||
if (result.IsNull())
|
||||
continue;
|
||||
const BRepCheck_ListOfStatus& status = result->StatusOnShape(*xp);
|
||||
const BRepCheck_ListOfStatus& status = result->StatusOnShape(shape);
|
||||
|
||||
BRepCheck_ListIteratorOfListOfStatus it(status);
|
||||
while (it.More()) {
|
||||
@@ -1776,14 +1776,14 @@ TopoDS_Shape TopoShape::cut(const std::vector<TopoDS_Shape>& shapes, Standard_Re
|
||||
mkCut.SetRunParallel(true);
|
||||
TopTools_ListOfShape shapeArguments,shapeTools;
|
||||
shapeArguments.Append(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
if (it->IsNull())
|
||||
for (const auto & shape : shapes) {
|
||||
if (shape.IsNull())
|
||||
throw Base::ValueError("Tool shape is null");
|
||||
if (tolerance > 0.0)
|
||||
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(shape).Shape());
|
||||
else
|
||||
shapeTools.Append(*it);
|
||||
shapeTools.Append(shape);
|
||||
}
|
||||
|
||||
mkCut.SetArguments(shapeArguments);
|
||||
@@ -1816,14 +1816,14 @@ TopoDS_Shape TopoShape::common(const std::vector<TopoDS_Shape>& shapes, Standard
|
||||
mkCommon.SetRunParallel(true);
|
||||
TopTools_ListOfShape shapeArguments,shapeTools;
|
||||
shapeArguments.Append(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
if (it->IsNull())
|
||||
for (const auto & shape : shapes) {
|
||||
if (shape.IsNull())
|
||||
throw Base::ValueError("Tool shape is null");
|
||||
if (tolerance > 0.0)
|
||||
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(shape).Shape());
|
||||
else
|
||||
shapeTools.Append(*it);
|
||||
shapeTools.Append(shape);
|
||||
}
|
||||
|
||||
mkCommon.SetArguments(shapeArguments);
|
||||
@@ -1857,14 +1857,14 @@ TopoDS_Shape TopoShape::fuse(const std::vector<TopoDS_Shape>& shapes, Standard_R
|
||||
mkFuse.SetRunParallel(true);
|
||||
TopTools_ListOfShape shapeArguments,shapeTools;
|
||||
shapeArguments.Append(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
if (it->IsNull())
|
||||
for (const auto & shape : shapes) {
|
||||
if (shape.IsNull())
|
||||
throw NullShapeException("Tool shape is null");
|
||||
if (tolerance > 0.0)
|
||||
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(shape).Shape());
|
||||
else
|
||||
shapeTools.Append(*it);
|
||||
shapeTools.Append(shape);
|
||||
}
|
||||
mkFuse.SetArguments(shapeArguments);
|
||||
mkFuse.SetTools(shapeTools);
|
||||
@@ -1916,14 +1916,14 @@ TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes,
|
||||
mkSection.Approximation(approximate);
|
||||
TopTools_ListOfShape shapeArguments,shapeTools;
|
||||
shapeArguments.Append(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
if (it->IsNull())
|
||||
for (const auto & shape : shapes) {
|
||||
if (shape.IsNull())
|
||||
throw Base::ValueError("Tool shape is null");
|
||||
if (tolerance > 0.0)
|
||||
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
|
||||
shapeTools.Append(BRepBuilderAPI_Copy(shape).Shape());
|
||||
else
|
||||
shapeTools.Append(*it);
|
||||
shapeTools.Append(shape);
|
||||
}
|
||||
|
||||
mkSection.SetArguments(shapeArguments);
|
||||
@@ -1948,8 +1948,8 @@ TopoDS_Compound TopoShape::slices(const Base::Vector3d& dir, const std::vector<d
|
||||
{
|
||||
std::vector< std::list<TopoDS_Wire> > wire_list;
|
||||
CrossSection cs(dir.x, dir.y, dir.z, this->_Shape);
|
||||
for (std::vector<double>::const_iterator jt = d.begin(); jt != d.end(); ++jt) {
|
||||
wire_list.push_back(cs.slice(*jt));
|
||||
for (double jt : d) {
|
||||
wire_list.push_back(cs.slice(jt));
|
||||
}
|
||||
|
||||
std::vector< std::list<TopoDS_Wire> >::const_iterator ft;
|
||||
@@ -1959,9 +1959,9 @@ TopoDS_Compound TopoShape::slices(const Base::Vector3d& dir, const std::vector<d
|
||||
|
||||
for (ft = wire_list.begin(); ft != wire_list.end(); ++ft) {
|
||||
const std::list<TopoDS_Wire>& w = *ft;
|
||||
for (std::list<TopoDS_Wire>::const_iterator wt = w.begin(); wt != w.end(); ++wt) {
|
||||
if (!wt->IsNull())
|
||||
builder.Add(comp, *wt);
|
||||
for (const auto & wt : w) {
|
||||
if (!wt.IsNull())
|
||||
builder.Add(comp, wt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3112,8 +3112,8 @@ TopoDS_Shape TopoShape::replaceShape(const std::vector< std::pair<TopoDS_Shape,T
|
||||
TopoDS_Shape TopoShape::removeShape(const std::vector<TopoDS_Shape>& s) const
|
||||
{
|
||||
BRepTools_ReShape reshape;
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = s.begin(); it != s.end(); ++it)
|
||||
reshape.Remove(*it);
|
||||
for (const auto & it : s)
|
||||
reshape.Remove(it);
|
||||
return reshape.Apply(this->_Shape, TopAbs_SHAPE);
|
||||
}
|
||||
|
||||
@@ -3367,8 +3367,7 @@ void TopoShape::getFacesFromDomains(const std::vector<Domain>& domains,
|
||||
Standard_Real x2, y2, z2;
|
||||
Standard_Real x3, y3, z3;
|
||||
|
||||
for (std::vector<Domain>::const_iterator it = domains.begin(); it != domains.end(); ++it) {
|
||||
const Domain& domain = *it;
|
||||
for (const auto & domain : domains) {
|
||||
for (std::vector<Facet>::const_iterator jt = domain.facets.begin(); jt != domain.facets.end(); ++jt) {
|
||||
x1 = domain.points[jt->I1].x;
|
||||
y1 = domain.points[jt->I1].y;
|
||||
@@ -3431,8 +3430,8 @@ void TopoShape::getFacesFromDomains(const std::vector<Domain>& domains,
|
||||
|
||||
std::vector<Base::Vector3d> meshPoints;
|
||||
meshPoints.resize(vertices.size());
|
||||
for (std::set<MeshVertex>::iterator it = vertices.begin(); it != vertices.end(); ++it)
|
||||
meshPoints[it->i] = it->toPoint();
|
||||
for (const auto & vertex : vertices)
|
||||
meshPoints[vertex.i] = vertex.toPoint();
|
||||
points.swap(meshPoints);
|
||||
}
|
||||
|
||||
@@ -3487,18 +3486,18 @@ void TopoShape::setFaces(const std::vector<Base::Vector3d> &Points,
|
||||
gp_XYZ p(v.x, v.y, v.z);
|
||||
return BRepBuilderAPI_MakeVertex(p);
|
||||
};
|
||||
for (std::vector<Facet>::const_iterator it = Topo.begin(); it != Topo.end(); ++it) {
|
||||
if (it->I1 < ctPoints) {
|
||||
if (Vertexes[it->I1].IsNull())
|
||||
Vertexes[it->I1] = CreateVertex(Points[it->I1]);
|
||||
for (const auto& it : Topo) {
|
||||
if (it.I1 < ctPoints) {
|
||||
if (Vertexes[it.I1].IsNull())
|
||||
Vertexes[it.I1] = CreateVertex(Points[it.I1]);
|
||||
}
|
||||
if (it->I2 < ctPoints) {
|
||||
if (Vertexes[it->I2].IsNull())
|
||||
Vertexes[it->I2] = CreateVertex(Points[it->I2]);
|
||||
if (it.I2 < ctPoints) {
|
||||
if (Vertexes[it.I2].IsNull())
|
||||
Vertexes[it.I2] = CreateVertex(Points[it.I2]);
|
||||
}
|
||||
if (it->I3 < ctPoints) {
|
||||
if (Vertexes[it->I3].IsNull())
|
||||
Vertexes[it->I3] = CreateVertex(Points[it->I3]);
|
||||
if (it.I3 < ctPoints) {
|
||||
if (Vertexes[it.I3].IsNull())
|
||||
Vertexes[it.I3] = CreateVertex(Points[it.I3]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3524,18 +3523,18 @@ void TopoShape::setFaces(const std::vector<Base::Vector3d> &Points,
|
||||
auto key = std::make_pair(p1, p2);
|
||||
return Edges[key];
|
||||
};
|
||||
for (std::vector<Facet>::const_iterator it = Topo.begin(); it != Topo.end(); ++it) {
|
||||
CreateEdge(it->I1, it->I2);
|
||||
CreateEdge(it->I2, it->I3);
|
||||
CreateEdge(it->I3, it->I1);
|
||||
for (const auto& it : Topo) {
|
||||
CreateEdge(it.I1, it.I2);
|
||||
CreateEdge(it.I2, it.I3);
|
||||
CreateEdge(it.I3, it.I1);
|
||||
}
|
||||
|
||||
for (std::vector<Facet>::const_iterator it = Topo.begin(); it != Topo.end(); ++it) {
|
||||
if (it->I1 >= ctPoints || it->I2 >= ctPoints || it->I3 >= ctPoints)
|
||||
for (const auto& it : Topo) {
|
||||
if (it.I1 >= ctPoints || it.I2 >= ctPoints || it.I3 >= ctPoints)
|
||||
continue;
|
||||
x1 = Points[it->I1].x; y1 = Points[it->I1].y; z1 = Points[it->I1].z;
|
||||
x2 = Points[it->I2].x; y2 = Points[it->I2].y; z2 = Points[it->I2].z;
|
||||
x3 = Points[it->I3].x; y3 = Points[it->I3].y; z3 = Points[it->I3].z;
|
||||
x1 = Points[it.I1].x; y1 = Points[it.I1].y; z1 = Points[it.I1].z;
|
||||
x2 = Points[it.I2].x; y2 = Points[it.I2].y; z2 = Points[it.I2].z;
|
||||
x3 = Points[it.I3].x; y3 = Points[it.I3].y; z3 = Points[it.I3].z;
|
||||
|
||||
p1.SetCoord(x1,y1,z1);
|
||||
p2.SetCoord(x2,y2,z2);
|
||||
@@ -3544,9 +3543,9 @@ void TopoShape::setFaces(const std::vector<Base::Vector3d> &Points,
|
||||
// Avoid very tiny edges as this may result into broken faces. The tolerance is Approximation
|
||||
// because Confusion might be too tight.
|
||||
if ((!(p1.IsEqual(p2, Precision::Approximation()))) && (!(p1.IsEqual(p3, Precision::Approximation())))) {
|
||||
const TopoDS_Edge& e1 = GetEdge(it->I1, it->I2);
|
||||
const TopoDS_Edge& e2 = GetEdge(it->I2, it->I3);
|
||||
const TopoDS_Edge& e3 = GetEdge(it->I3, it->I1);
|
||||
const TopoDS_Edge& e1 = GetEdge(it.I1, it.I2);
|
||||
const TopoDS_Edge& e2 = GetEdge(it.I2, it.I3);
|
||||
const TopoDS_Edge& e3 = GetEdge(it.I3, it.I1);
|
||||
if (e1.IsNull() || e2.IsNull() || e3.IsNull())
|
||||
continue;
|
||||
|
||||
@@ -3795,8 +3794,8 @@ TopoDS_Shape TopoShape::defeaturing(const std::vector<TopoDS_Shape>& s) const
|
||||
BRepAlgoAPI_Defeaturing defeat;
|
||||
defeat.SetRunParallel(true);
|
||||
defeat.SetShape(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = s.begin(); it != s.end(); ++it)
|
||||
defeat.AddFaceToRemove(*it);
|
||||
for (const auto & it : s)
|
||||
defeat.AddFaceToRemove(it);
|
||||
defeat.Build();
|
||||
if (!defeat.IsDone()) {
|
||||
// error treatment
|
||||
|
||||
Reference in New Issue
Block a user