Mesh: define the typenames FacetIndex and PointIndex to distinguish between facet and point related indexes

This commit is contained in:
wmayer
2021-09-14 23:01:29 +02:00
parent ce285ea265
commit 33f3fa6865
91 changed files with 2057 additions and 2254 deletions

View File

@@ -38,12 +38,12 @@
using namespace MeshCore;
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(0), _ptIdx(0)
MeshBuilder::MeshBuilder (MeshKernel& kernel) : _meshKernel(kernel), _seq(nullptr), _ptIdx(0)
{
_fSaveTolerance = MeshDefinitions::_fMinPointDistanceD1;
}
MeshBuilder::~MeshBuilder (void)
MeshBuilder::~MeshBuilder ()
{
MeshDefinitions::_fMinPointDistanceD1 = _fSaveTolerance;
delete this->_seq;
@@ -156,7 +156,7 @@ void MeshBuilder::AddFacet (Base::Vector3f* facetPoints, unsigned char flag, uns
void MeshBuilder::SetNeighbourhood ()
{
std::set<Edge> edges;
unsigned long facetIdx = 0;
FacetIndex facetIdx = 0;
for (MeshFacetArray::_TIterator it = _meshKernel._aclFacetArray.begin(); it != _meshKernel._aclFacetArray.end(); ++it)
{
@@ -218,7 +218,7 @@ void MeshBuilder::RemoveUnreferencedPoints()
void MeshBuilder::Finish (bool freeMemory)
{
// now we can resize the vertex array to the exact size and copy the vertices with their correct positions in the array
unsigned long i=0;
PointIndex i=0;
_meshKernel._aclPointArray.resize(_pointsIterator.size());
for ( std::vector<MeshPointIterator>::iterator it = _pointsIterator.begin(); it != _pointsIterator.end(); ++it)
_meshKernel._aclPointArray[i++] = *(it->first);
@@ -244,7 +244,7 @@ void MeshBuilder::Finish (bool freeMemory)
if ( cap > siz+siz/20 )
{
try {
unsigned long i=0;
FacetIndex i=0;
MeshFacetArray faces(siz);
for ( MeshFacetArray::_TIterator it = _meshKernel._aclFacetArray.begin(); it != _meshKernel._aclFacetArray.end(); ++it )
faces[i++]=*it;
@@ -290,7 +290,7 @@ MeshFastBuilder::MeshFastBuilder(MeshKernel &rclM) : _meshKernel(rclM), p(new Pr
{
}
MeshFastBuilder::~MeshFastBuilder(void)
MeshFastBuilder::~MeshFastBuilder()
{
delete p;
}
@@ -335,18 +335,18 @@ void MeshFastBuilder::Finish ()
int threads = std::max(1, QThread::idealThreadCount());
MeshCore::parallel_sort(verts.begin(), verts.end(), std::less<Private::Vertex>(), threads);
QVector<unsigned long> indices(ulCtPts);
QVector<FacetIndex> indices(ulCtPts);
size_type vertex_count = 0;
for (QVector<Private::Vertex>::iterator v = verts.begin(); v != verts.end(); ++v) {
if (!vertex_count || *v != verts[vertex_count-1])
verts[vertex_count++] = *v;
indices[v->i] = static_cast<unsigned long>(vertex_count - 1);
indices[v->i] = static_cast<FacetIndex>(vertex_count - 1);
}
size_type ulCt = verts.size()/3;
MeshFacetArray rFacets(static_cast<unsigned long>(ulCt));
MeshFacetArray rFacets(static_cast<FacetIndex>(ulCt));
for (size_type i=0; i < ulCt; ++i) {
rFacets[static_cast<size_t>(i)]._aulPoints[0] = indices[3*i];
rFacets[static_cast<size_t>(i)]._aulPoints[1] = indices[3*i + 1];