Mesh: Apply clang-format
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
#include "Tools.h"
|
||||
@@ -31,33 +31,37 @@
|
||||
|
||||
using namespace MeshCore;
|
||||
|
||||
MeshSearchNeighbours::MeshSearchNeighbours (const MeshKernel &rclM, float fSampleDistance)
|
||||
: _rclMesh(rclM)
|
||||
, _rclFAry(rclM.GetFacets())
|
||||
, _rclPAry(rclM.GetPoints())
|
||||
, _clPt2Fa(rclM)
|
||||
, _fSampleDistance(fSampleDistance)
|
||||
MeshSearchNeighbours::MeshSearchNeighbours(const MeshKernel& rclM, float fSampleDistance)
|
||||
: _rclMesh(rclM)
|
||||
, _rclFAry(rclM.GetFacets())
|
||||
, _rclPAry(rclM.GetPoints())
|
||||
, _clPt2Fa(rclM)
|
||||
, _fSampleDistance(fSampleDistance)
|
||||
{
|
||||
MeshAlgorithm(_rclMesh).ResetFacetFlag(MeshFacet::MARKED);
|
||||
MeshAlgorithm(_rclMesh).ResetPointFlag(MeshPoint::MARKED);
|
||||
}
|
||||
|
||||
void MeshSearchNeighbours::Reinit (float fSampleDistance)
|
||||
void MeshSearchNeighbours::Reinit(float fSampleDistance)
|
||||
{
|
||||
_fSampleDistance = fSampleDistance;
|
||||
MeshAlgorithm(_rclMesh).ResetFacetFlag(MeshFacet::MARKED);
|
||||
MeshAlgorithm(_rclMesh).ResetPointFlag(MeshPoint::MARKED);
|
||||
}
|
||||
|
||||
unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx, float fDistance, unsigned long ulMinPoints, std::vector<Base::Vector3f> &raclResultPoints)
|
||||
unsigned long
|
||||
MeshSearchNeighbours::NeighboursFromFacet(FacetIndex ulFacetIdx,
|
||||
float fDistance,
|
||||
unsigned long ulMinPoints,
|
||||
std::vector<Base::Vector3f>& raclResultPoints)
|
||||
{
|
||||
bool bAddPoints = false;
|
||||
|
||||
_fMaxDistanceP2 = fDistance * fDistance;
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
|
||||
unsigned long ulVisited = 1;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
|
||||
_aclResult.clear();
|
||||
_aclOuter.clear();
|
||||
@@ -81,16 +85,16 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx,
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
const std::set<FacetIndex>& rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
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();
|
||||
@@ -102,22 +106,27 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx,
|
||||
bAddPoints = true;
|
||||
bFound = ExpandRadius(ulMinPoints);
|
||||
}
|
||||
else
|
||||
else {
|
||||
nCtExpandRadius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// reset marked facets, points
|
||||
for (auto & pF : aclTestedFacet)
|
||||
for (auto& pF : aclTestedFacet) {
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
for (PointIndex pR : _aclResult)
|
||||
}
|
||||
for (PointIndex pR : _aclResult) {
|
||||
_rclPAry[pR].ResetFlag(MeshPoint::MARKED);
|
||||
}
|
||||
|
||||
|
||||
// copy points in result container
|
||||
raclResultPoints.resize(_aclResult.size());
|
||||
size_t i = 0;
|
||||
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
|
||||
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end();
|
||||
++pI, i++) {
|
||||
raclResultPoints[i] = _rclPAry[*pI];
|
||||
}
|
||||
|
||||
if (bAddPoints) {
|
||||
// sort points, remove points lying furthest from center
|
||||
@@ -128,10 +137,11 @@ unsigned long MeshSearchNeighbours::NeighboursFromFacet (FacetIndex ulFacetIdx,
|
||||
return ulVisited;
|
||||
}
|
||||
|
||||
void MeshSearchNeighbours::SampleAllFacets ()
|
||||
void MeshSearchNeighbours::SampleAllFacets()
|
||||
{
|
||||
if (_aclSampledFacets.size() == _rclMesh.CountFacets())
|
||||
return; // already sampled, do nothing
|
||||
if (_aclSampledFacets.size() == _rclMesh.CountFacets()) {
|
||||
return; // already sampled, do nothing
|
||||
}
|
||||
|
||||
_aclSampledFacets.resize(_rclMesh.CountFacets());
|
||||
MeshFacetIterator clFIter(_rclMesh);
|
||||
@@ -144,18 +154,21 @@ void MeshSearchNeighbours::SampleAllFacets ()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints)
|
||||
unsigned long
|
||||
MeshSearchNeighbours::NeighboursFromSampledFacets(FacetIndex ulFacetIdx,
|
||||
float fDistance,
|
||||
std::vector<Base::Vector3f>& raclResultPoints)
|
||||
{
|
||||
SampleAllFacets();
|
||||
|
||||
_fMaxDistanceP2 = fDistance * fDistance;
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
|
||||
_akSphere.Center = Wm4::Vector3<float>(_clCenter.x, _clCenter.y, _clCenter.z);
|
||||
_akSphere.Radius = fDistance;
|
||||
|
||||
unsigned long ulVisited = 1;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
|
||||
_aclResult.clear();
|
||||
_aclOuter.clear();
|
||||
@@ -173,16 +186,16 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFa
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
const std::set<FacetIndex>& rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
const MeshFacet& rclF = f_beg[pJ];
|
||||
|
||||
if (!rclF.IsFlag(MeshFacet::MARKED)) {
|
||||
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();
|
||||
@@ -190,8 +203,9 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFa
|
||||
}
|
||||
|
||||
// reset marked facets
|
||||
for (auto & pF : aclTestedFacet)
|
||||
for (auto& pF : aclTestedFacet) {
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
}
|
||||
|
||||
// copy points in result container
|
||||
raclResultPoints.resize(_aclPointsResult.size());
|
||||
@@ -199,40 +213,45 @@ unsigned long MeshSearchNeighbours::NeighboursFromSampledFacets (FacetIndex ulFa
|
||||
|
||||
// facet points
|
||||
for (PointIndex pI : _aclResult) {
|
||||
if (InnerPoint(_rclPAry[pI]))
|
||||
if (InnerPoint(_rclPAry[pI])) {
|
||||
raclResultPoints.push_back(_rclPAry[pI]);
|
||||
}
|
||||
}
|
||||
|
||||
return ulVisited;
|
||||
}
|
||||
|
||||
bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetIndex ulFIdx)
|
||||
bool MeshSearchNeighbours::AccumulateNeighbours(const MeshFacet& rclF, FacetIndex ulFIdx)
|
||||
{
|
||||
int k = 0;
|
||||
int k = 0;
|
||||
|
||||
for (PointIndex ulPIdx : rclF._aulPoints) {
|
||||
_aclOuter.insert(ulPIdx);
|
||||
_aclResult.insert(ulPIdx);
|
||||
|
||||
if (Base::DistanceP2(_clCenter, _rclPAry[ulPIdx]) < _fMaxDistanceP2)
|
||||
if (Base::DistanceP2(_clCenter, _rclPAry[ulPIdx]) < _fMaxDistanceP2) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
bool bFound = false;
|
||||
if (k == 3) { // add all sample points
|
||||
_aclPointsResult.insert(_aclPointsResult.end(), _aclSampledFacets[ulFIdx].begin(), _aclSampledFacets[ulFIdx].end());
|
||||
_aclPointsResult.insert(_aclPointsResult.end(),
|
||||
_aclSampledFacets[ulFIdx].begin(),
|
||||
_aclSampledFacets[ulFIdx].end());
|
||||
bFound = true;
|
||||
}
|
||||
else { // add points inner radius
|
||||
bFound = TriangleCutsSphere(rclF);
|
||||
|
||||
if (bFound) {
|
||||
const 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 (const auto & pI : rclT) {
|
||||
if (InnerPoint(pI))
|
||||
for (const auto& pI : rclT) {
|
||||
if (InnerPoint(pI)) {
|
||||
clTmp.push_back(pI);
|
||||
}
|
||||
}
|
||||
_aclPointsResult.insert(_aclPointsResult.end(), clTmp.begin(), clTmp.end());
|
||||
}
|
||||
@@ -241,30 +260,36 @@ bool MeshSearchNeighbours::AccumulateNeighbours (const MeshFacet &rclF, FacetInd
|
||||
return bFound;
|
||||
}
|
||||
|
||||
bool MeshSearchNeighbours::ExpandRadius (unsigned long ulMinPoints)
|
||||
bool MeshSearchNeighbours::ExpandRadius(unsigned long ulMinPoints)
|
||||
{
|
||||
// add facets from current level
|
||||
_aclResult.insert(_aclOuter.begin(), _aclOuter.end());
|
||||
for (PointIndex pI : _aclOuter)
|
||||
for (PointIndex pI : _aclOuter) {
|
||||
_rclPAry[pI].SetFlag(MeshPoint::MARKED);
|
||||
}
|
||||
|
||||
if (_aclResult.size() < ulMinPoints) {
|
||||
_fMaxDistanceP2 *= float(ulMinPoints) / float(_aclResult.size());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacetIdx, float fDistance, std::vector<Base::Vector3f> &raclResultPoints, std::vector<FacetIndex> &raclResultFacets)
|
||||
unsigned long
|
||||
MeshSearchNeighbours::NeighboursFacetFromFacet(FacetIndex ulFacetIdx,
|
||||
float fDistance,
|
||||
std::vector<Base::Vector3f>& raclResultPoints,
|
||||
std::vector<FacetIndex>& raclResultFacets)
|
||||
{
|
||||
std::set<FacetIndex> aulFacetSet;
|
||||
|
||||
_fMaxDistanceP2 = fDistance * fDistance;
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
_clCenter = _rclMesh.GetFacet(ulFacetIdx).GetGravityPoint();
|
||||
|
||||
unsigned long ulVisited = 1;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
unsigned long ulVisited = 1;
|
||||
std::vector<MeshFacetArray::_TConstIterator> aclTestedFacet;
|
||||
|
||||
_aclResult.clear();
|
||||
_aclOuter.clear();
|
||||
@@ -284,10 +309,10 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacet
|
||||
std::set<PointIndex> aclTmp;
|
||||
aclTmp.swap(_aclOuter);
|
||||
for (PointIndex pI : aclTmp) {
|
||||
const std::set<FacetIndex> &rclISet = _clPt2Fa[pI];
|
||||
const std::set<FacetIndex>& rclISet = _clPt2Fa[pI];
|
||||
// search all facets hanging on this point
|
||||
for (FacetIndex pJ : rclISet) {
|
||||
const MeshFacet &rclF = f_beg[pJ];
|
||||
const MeshFacet& rclF = f_beg[pJ];
|
||||
|
||||
for (PointIndex ptIndex : rclF._aulPoints) {
|
||||
if (Base::DistanceP2(_clCenter, _rclPAry[ptIndex]) < _fMaxDistanceP2) {
|
||||
@@ -301,7 +326,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();
|
||||
@@ -309,16 +334,20 @@ unsigned long MeshSearchNeighbours::NeighboursFacetFromFacet (FacetIndex ulFacet
|
||||
}
|
||||
|
||||
// reset marked facets, points
|
||||
for (auto & pF : aclTestedFacet)
|
||||
for (auto& pF : aclTestedFacet) {
|
||||
pF->ResetFlag(MeshFacet::MARKED);
|
||||
for (PointIndex pR : _aclResult)
|
||||
}
|
||||
for (PointIndex pR : _aclResult) {
|
||||
_rclPAry[pR].ResetFlag(MeshPoint::MARKED);
|
||||
}
|
||||
|
||||
// copy points in result container
|
||||
raclResultPoints.resize(_aclResult.size());
|
||||
size_t i = 0;
|
||||
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end(); ++pI, i++)
|
||||
for (std::set<PointIndex>::iterator pI = _aclResult.begin(); pI != _aclResult.end();
|
||||
++pI, i++) {
|
||||
raclResultPoints[i] = _rclPAry[*pI];
|
||||
}
|
||||
|
||||
// copy facets in result container
|
||||
raclResultFacets.insert(raclResultFacets.begin(), aulFacetSet.begin(), aulFacetSet.end());
|
||||
|
||||
Reference in New Issue
Block a user