MeshPart: modernize C++: use range-based for loop
This commit is contained in:
@@ -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<FaceSplitEdge>::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<FaceSplitEdge> &vSplitEdges)
|
||||
void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
|
||||
std::vector<FaceSplitEdge> &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<LineSeg>::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<PolyLine>::const_iterator it = rPolyLines.begin();it!=rPolyLines.end();++it) {
|
||||
for (std::vector<Base::Vector3f>::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<MeshCore::FacetIndex>::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<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
|
||||
MeshCore::PointIndex ulPt1 = std::max<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i+1)%3]);
|
||||
pEdgeToFace[std::pair<MeshCore::PointIndex, MeshCore::PointIndex>(ulPt0, ulPt1)].push_front(*pI);
|
||||
pEdgeToFace[std::pair<MeshCore::PointIndex, MeshCore::PointIndex>(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<MeshCore::FacetIndex>::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<Standard_Real, SplitEdge>::iterator itS =
|
||||
rParamSplitEdges.begin(); itS != rParamSplitEdges.end(); ++itS) {
|
||||
rSplitEdges.push_back( itS->second );
|
||||
for (const auto & itS : rParamSplitEdges) {
|
||||
rSplitEdges.push_back( itS.second );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
|
||||
if(fliped.empty())
|
||||
break;
|
||||
|
||||
for(std::set<MeshCore::FacetIndex>::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<CurvePr
|
||||
{
|
||||
MeshTopoAlgorithm cTopAlg(*pMesh);
|
||||
|
||||
for (std::vector<CurveProjector::FaceSplitEdge>::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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,9 +192,8 @@ public:
|
||||
std::vector< std::vector<MeshCore::FacetIndex> > 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<SMESH_Hypothesis*>::iterator it = hypoth.begin(); it != hypoth.end(); ++it)
|
||||
delete *it;
|
||||
for (auto it : hypoth)
|
||||
delete it;
|
||||
|
||||
return meshdata;
|
||||
#endif // HAVE_SMESH
|
||||
|
||||
@@ -128,38 +128,38 @@ void CmdMeshPartTrimByPlane::activated(int)
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Trim with plane"));
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::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<Mesh::Feature*>(*it)->Mesh.startEditing();
|
||||
Mesh::MeshObject* mesh = static_cast<Mesh::Feature*>(it)->Mesh.startEditing();
|
||||
|
||||
Base::Vector3f plnBase = Base::convertTo<Base::Vector3f>(base);
|
||||
Base::Vector3f plnNormal = Base::convertTo<Base::Vector3f>(normal);
|
||||
|
||||
if (role == Gui::SelectionRole::Inner) {
|
||||
mesh->trimByPlane(plnBase, plnNormal);
|
||||
static_cast<Mesh::Feature*>(*it)->Mesh.finishEditing();
|
||||
static_cast<Mesh::Feature*>(it)->Mesh.finishEditing();
|
||||
}
|
||||
else if (role == Gui::SelectionRole::Outer) {
|
||||
mesh->trimByPlane(plnBase, -plnNormal);
|
||||
static_cast<Mesh::Feature*>(*it)->Mesh.finishEditing();
|
||||
static_cast<Mesh::Feature*>(it)->Mesh.finishEditing();
|
||||
}
|
||||
else if (role == Gui::SelectionRole::Split) {
|
||||
Mesh::MeshObject copy(*mesh);
|
||||
mesh->trimByPlane(plnBase, plnNormal);
|
||||
static_cast<Mesh::Feature*>(*it)->Mesh.finishEditing();
|
||||
static_cast<Mesh::Feature*>(it)->Mesh.finishEditing();
|
||||
|
||||
copy.trimByPlane(plnBase, -plnNormal);
|
||||
App::Document* doc = (*it)->getDocument();
|
||||
App::Document* doc = it->getDocument();
|
||||
Mesh::Feature* fea = static_cast<Mesh::Feature*>(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<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
|
||||
const Mesh::MeshObject* mesh = static_cast<Mesh::Feature*>(*it)->Mesh.getValuePtr();
|
||||
for (auto it : docObj) {
|
||||
const Mesh::MeshObject* mesh = static_cast<Mesh::Feature*>(it)->Mesh.getValuePtr();
|
||||
std::vector<Mesh::MeshObject::TPolylines> polylines;
|
||||
mesh->crossSections(sections, polylines);
|
||||
|
||||
@@ -282,8 +282,8 @@ void CmdMeshPartCrossSections::activated(int iMsg)
|
||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType
|
||||
(Mesh::Feature::getClassTypeId());
|
||||
Base::BoundBox3d bbox;
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
bbox.Add(static_cast<Mesh::Feature*>(*it)->Mesh.getBoundingBox());
|
||||
for (auto it : obj) {
|
||||
bbox.Add(static_cast<Mesh::Feature*>(it)->Mesh.getBoundingBox());
|
||||
}
|
||||
dlg = new MeshPartGui::TaskCrossSections(bbox);
|
||||
}
|
||||
|
||||
@@ -145,10 +145,10 @@ public:
|
||||
algo.CutWithPlane(p, n, grid, polylines, epsilon, connectEdges);
|
||||
|
||||
std::list<TopoDS_Wire> 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<gp_Pnt>(*jt));
|
||||
for (auto jt : polyline) {
|
||||
mkPoly.Add(Base::convertTo<gp_Pnt>(jt));
|
||||
}
|
||||
|
||||
if (mkPoly.IsDone())
|
||||
@@ -286,8 +286,8 @@ void CrossSections::apply()
|
||||
double eps = ui->spinEpsilon->value();
|
||||
|
||||
#if 1 // multi-threaded sections
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
const Mesh::MeshObject& mesh = static_cast<Mesh::Feature*>(*it)->Mesh.getValue();
|
||||
for (auto it : obj) {
|
||||
const Mesh::MeshObject& mesh = static_cast<Mesh::Feature*>(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<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 & 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<Part::Feature*>
|
||||
(doc->addObject("Part::Feature",s.c_str()));
|
||||
@@ -570,26 +569,26 @@ std::vector<double> CrossSections::getPlanes() const
|
||||
void CrossSections::makePlanes(Plane type, const std::vector<double>& d, double bound[4])
|
||||
{
|
||||
std::vector<Base::Vector3f> points;
|
||||
for (std::vector<double>::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;
|
||||
}
|
||||
|
||||
|
||||
@@ -198,8 +198,8 @@ void ViewProviderCurveOnMesh::setPoints(const std::vector<SbVec3f>& pts)
|
||||
pcCoords->point.setNum(pts.size());
|
||||
SbVec3f* coords = pcCoords->point.startEditing();
|
||||
int index = 0;
|
||||
for (std::vector<SbVec3f>::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<SbVec3f> pts;
|
||||
pts.reserve(points.size());
|
||||
for (auto it = points.begin(); it != points.end(); ++it) {
|
||||
pts.push_back(Base::convertTo<SbVec3f>(*it));
|
||||
for (const auto& it : points) {
|
||||
pts.push_back(Base::convertTo<SbVec3f>(it));
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
@@ -457,8 +457,8 @@ std::vector<SbVec3f> CurveOnMeshHandler::getVertexes() const
|
||||
{
|
||||
std::vector<SbVec3f> pts;
|
||||
pts.reserve(d_ptr->pickedPoints.size());
|
||||
for (std::vector<Private::PickedPoint>::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<SbVec3f>::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<SbVec3f>& points, TopoDS_Wire& wire)
|
||||
{
|
||||
BRepBuilderAPI_MakePolygon mkPoly;
|
||||
for (std::vector<SbVec3f>::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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user