Mesh: modernize C++: use range-based for loop
This commit is contained in:
@@ -82,17 +82,17 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx,
|
||||
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (std::set<FacetIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (std::set<FacetIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
|
||||
const MeshFacet &rclF = f_beg[*pJ];
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
|
||||
if (!rclF.IsFlag(MeshFacet::MARKED)) {
|
||||
bool bLF = CheckDistToFacet(rclF);
|
||||
bFound = bFound || bLF;
|
||||
rclF.SetFlag(MeshFacet::MARKED);
|
||||
aclTestedFacet.push_back(f_beg+*pJ);
|
||||
aclTestedFacet.push_back(f_beg+pJ);
|
||||
}
|
||||
}
|
||||
ulVisited += rclISet.size();
|
||||
@@ -109,11 +109,10 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx,
|
||||
}
|
||||
|
||||
// reset marked facets, points
|
||||
for (std::vector<MeshFacetArray::_TConstIterator>::iterator pF = aclTestedFacet.begin();
|
||||
pF != aclTestedFacet.end(); ++pF)
|
||||
(*pF)->ResetFlag(MeshFacet::MARKED);
|
||||
for (std::set<PointIndex>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
|
||||
_rclPAry[*pR].ResetFlag(MeshPoint::MARKED);
|
||||
for (auto & pF : aclTestedFacet)
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
for (PointIndex pR : _aclResult)
|
||||
_rclPAry[pR].ResetFlag(MeshPoint::MARKED);
|
||||
|
||||
|
||||
// copy points in result container
|
||||
@@ -175,17 +174,17 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFa
|
||||
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (std::set<PointIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (std::set<FacetIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
|
||||
const MeshFacet &rclF = f_beg[*pJ];
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
|
||||
if (!rclF.IsFlag(MeshFacet::MARKED)) {
|
||||
bool bLF = AccumulateNeighbours(rclF, *pJ);
|
||||
bool bLF = AccumulateNeighbours(rclF, pJ);
|
||||
bFound = bFound || bLF;
|
||||
rclF.SetFlag(MeshFacet::MARKED);
|
||||
aclTestedFacet.push_back(f_beg+*pJ);
|
||||
aclTestedFacet.push_back(f_beg+pJ);
|
||||
}
|
||||
}
|
||||
ulVisited += rclISet.size();
|
||||
@@ -193,17 +192,17 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFa
|
||||
}
|
||||
|
||||
// reset marked facets
|
||||
for (std::vector<MeshFacetArray::_TConstIterator>::iterator pF = aclTestedFacet.begin(); pF != aclTestedFacet.end(); ++pF)
|
||||
(*pF)->ResetFlag(MeshFacet::MARKED);
|
||||
for (auto & pF : aclTestedFacet)
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
|
||||
// copy points in result container
|
||||
raclResultPoints.resize(_aclPointsResult.size());
|
||||
std::copy(_aclPointsResult.begin(), _aclPointsResult.end(), raclResultPoints.begin());
|
||||
|
||||
// facet points
|
||||
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI) {
|
||||
if (InnerPoint(_rclPAry[*pI]))
|
||||
raclResultPoints.push_back(_rclPAry[*pI]);
|
||||
for (PointIndex pI : _aclResult) {
|
||||
if (InnerPoint(_rclPAry[pI]))
|
||||
raclResultPoints.push_back(_rclPAry[pI]);
|
||||
}
|
||||
|
||||
return ulVisited;
|
||||
@@ -213,8 +212,7 @@ bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetInd
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
PointIndex ulPIdx = rclF._aulPoints[i];
|
||||
for (PointIndex ulPIdx : rclF._aulPoints) {
|
||||
_aclOuter.insert(ulPIdx);
|
||||
_aclResult.insert(ulPIdx);
|
||||
|
||||
@@ -231,12 +229,12 @@ bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetInd
|
||||
bFound = TriangleCutsSphere(rclF);
|
||||
|
||||
if (bFound) {
|
||||
std::vector<Base::Vector3f> &rclT = _aclSampledFacets[ulFIdx];
|
||||
const std::vector<Base::Vector3f> &rclT = _aclSampledFacets[ulFIdx];
|
||||
std::vector<Base::Vector3f> clTmp;
|
||||
clTmp.reserve(rclT.size());
|
||||
for (std::vector<Base::Vector3f>::iterator pI = rclT.begin(); pI != rclT.end(); ++pI) {
|
||||
if (InnerPoint(*pI))
|
||||
clTmp.push_back(*pI);
|
||||
for (const auto & pI : rclT) {
|
||||
if (InnerPoint(pI))
|
||||
clTmp.push_back(pI);
|
||||
}
|
||||
_aclPointsResult.insert(_aclPointsResult.end(), clTmp.begin(), clTmp.end());
|
||||
}
|
||||
@@ -249,8 +247,8 @@ bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints)
|
||||
{
|
||||
// add facets from current level
|
||||
_aclResult.insert(_aclOuter.begin(), _aclOuter.end());
|
||||
for (std::set<PointIndex>::iterator pI = _aclOuter.begin(); pI != _aclOuter.end(); ++pI)
|
||||
_rclPAry[*pI].SetFlag(MeshPoint::MARKED);
|
||||
for (PointIndex pI : _aclOuter)
|
||||
_rclPAry[pI].SetFlag(MeshPoint::MARKED);
|
||||
|
||||
if (_aclResult.size() < ulMinPoints) {
|
||||
_fMaxDistanceP2 *= float(ulMinPoints) / float(_aclResult.size());
|
||||
@@ -287,15 +285,15 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacet
|
||||
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (std::set<PointIndex>::iterator pI = aclTmp.begin(); pI != aclTmp.end(); ++pI) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[*pI];
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (std::set<PointIndex>::const_iterator pJ = rclISet.begin(); pJ != rclISet.end(); ++pJ) {
|
||||
const MeshFacet &rclF = f_beg[*pJ];
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (Base::DistanceP2(_clCenter, _rclPAry[rclF._aulPoints[i]]) < _fMaxDistanceP2) {
|
||||
aulFacetSet.insert(*pJ);
|
||||
for (PointIndex ptIndex : rclF._aulPoints) {
|
||||
if (Base::DistanceP2(_clCenter, _rclPAry[ptIndex]) < _fMaxDistanceP2) {
|
||||
aulFacetSet.insert(pJ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +303,7 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacet
|
||||
|
||||
bFound = bFound || bLF;
|
||||
rclF.SetFlag(MeshFacet::MARKED);
|
||||
aclTestedFacet.push_back(f_beg+*pJ);
|
||||
aclTestedFacet.push_back(f_beg+pJ);
|
||||
}
|
||||
}
|
||||
ulVisited += rclISet.size();
|
||||
@@ -313,10 +311,10 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacet
|
||||
}
|
||||
|
||||
// reset marked facets, points
|
||||
for (std::vector<MeshFacetArray::_TConstIterator>::iterator pF = aclTestedFacet.begin(); pF != aclTestedFacet.end(); ++pF)
|
||||
(*pF)->ResetFlag(MeshFacet::MARKED);
|
||||
for (std::set<PointIndex>::iterator pR = _aclResult.begin(); pR != _aclResult.end(); ++pR)
|
||||
_rclPAry[*pR].ResetFlag(MeshPoint::MARKED);
|
||||
for (auto & pF : aclTestedFacet)
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
for (PointIndex pR : _aclResult)
|
||||
_rclPAry[pR].ResetFlag(MeshPoint::MARKED);
|
||||
|
||||
// copy points in result container
|
||||
raclResultPoints.resize(_aclResult.size());
|
||||
|
||||
Reference in New Issue
Block a user