From e8928898a80bcddb821e8b2a2f99fab7ec481e54 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 19 Sep 2019 19:43:10 +0200 Subject: [PATCH] avoid several implicit conversions, replace several old C-casts with static_cast --- src/Mod/Mesh/App/Core/Elements.cpp | 2 +- src/Mod/Mesh/App/Core/Evaluation.cpp | 12 +- src/Mod/Mesh/App/Core/Grid.cpp | 190 ++++++++++++++++-------- src/Mod/Mesh/App/Core/MeshKernel.cpp | 30 ++-- src/Mod/Mesh/App/Core/MeshKernel.h | 8 +- src/Mod/Mesh/App/Core/SetOperations.cpp | 2 +- src/Mod/Mesh/App/Core/TopoAlgorithm.cpp | 11 +- 7 files changed, 158 insertions(+), 97 deletions(-) diff --git a/src/Mod/Mesh/App/Core/Elements.cpp b/src/Mod/Mesh/App/Core/Elements.cpp index 23765a8d7b..93f9e3dad0 100644 --- a/src/Mod/Mesh/App/Core/Elements.cpp +++ b/src/Mod/Mesh/App/Core/Elements.cpp @@ -56,7 +56,7 @@ unsigned long MeshPointArray::GetOrAddIndex (const MeshPoint &rclPoint) if ((ulIndex = Get(rclPoint)) == ULONG_MAX) { push_back(rclPoint); - return (unsigned long)(size() - 1); + return static_cast(size() - 1); } else return ulIndex; diff --git a/src/Mod/Mesh/App/Core/Evaluation.cpp b/src/Mod/Mesh/App/Core/Evaluation.cpp index e27dd6bce2..0c2c7b50c0 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.cpp +++ b/src/Mod/Mesh/App/Core/Evaluation.cpp @@ -218,7 +218,7 @@ std::vector MeshEvalOrientation::GetIndices() const // In the currently visited component we have found less than 40% as correct // oriented and the rest as false oriented. So, we decide that it should be the other // way round and swap the indices of this component. - if (uComplement.size() < (unsigned long)(0.4f*(float)ulVisited)) { + if (uComplement.size() < static_cast(0.4f*static_cast(ulVisited))) { uIndices.erase(uIndices.begin()+wrongFacets, uIndices.end()); uIndices.insert(uIndices.end(), uComplement.begin(), uComplement.end()); } @@ -1050,16 +1050,16 @@ Base::Matrix4D MeshEigensystem::Transform() const // x = Q * y - Q * c Base::Matrix4D clTMat; // rotation part - clTMat[0][0] = _cU.x; clTMat[0][1] = _cU.y; clTMat[0][2] = _cU.z; clTMat[0][3] = 0.0f; - clTMat[1][0] = _cV.x; clTMat[1][1] = _cV.y; clTMat[1][2] = _cV.z; clTMat[1][3] = 0.0f; - clTMat[2][0] = _cW.x; clTMat[2][1] = _cW.y; clTMat[2][2] = _cW.z; clTMat[2][3] = 0.0f; - clTMat[3][0] = 0.0f; clTMat[3][1] = 0.0f; clTMat[3][2] = 0.0f; clTMat[3][3] = 1.0f; + clTMat[0][0] = double(_cU.x); clTMat[0][1] = double(_cU.y); clTMat[0][2] = double(_cU.z); clTMat[0][3] = 0.0; + clTMat[1][0] = double(_cV.x); clTMat[1][1] = double(_cV.y); clTMat[1][2] = double(_cV.z); clTMat[1][3] = 0.0; + clTMat[2][0] = double(_cW.x); clTMat[2][1] = double(_cW.y); clTMat[2][2] = double(_cW.z); clTMat[2][3] = 0.0; + clTMat[3][0] = 0.0; clTMat[3][1] = 0.0; clTMat[3][2] = 0.0; clTMat[3][3] = 1.0; Base::Vector3f c(_cC); c = clTMat * c; // translation part - clTMat[0][3] = -c.x; clTMat[1][3] = -c.y; clTMat[2][3] = -c.z; + clTMat[0][3] = double(-c.x); clTMat[1][3] = double(-c.y); clTMat[2][3] = double(-c.z); return clTMat; } diff --git a/src/Mod/Mesh/App/Core/Grid.cpp b/src/Mod/Mesh/App/Core/Grid.cpp index 4dd8fdfd57..336f713776 100644 --- a/src/Mod/Mesh/App/Core/Grid.cpp +++ b/src/Mod/Mesh/App/Core/Grid.cpp @@ -231,9 +231,9 @@ unsigned long MeshGrid::Inside (const Base::BoundBox3f &rclBB, std::set((rclPoint.x - _fMinX) / _fGridLenX); + rulY = static_cast((rclPoint.y - _fMinY) / _fGridLenY); + rulZ = static_cast((rclPoint.z - _fMinZ) / _fGridLenZ); if ( (rulX < _ulCtGridsX) && (rulY < _ulCtGridsY) && (rulZ < _ulCtGridsZ) ) return true; @@ -246,17 +246,17 @@ void MeshGrid::Position (const Base::Vector3f &rclPoint, unsigned long &rulX, un if (rclPoint.x <= _fMinX) rulX = 0; else - rulX = std::min((unsigned long)((rclPoint.x - _fMinX) / _fGridLenX), _ulCtGridsX - 1); + rulX = std::min(static_cast((rclPoint.x - _fMinX) / _fGridLenX), _ulCtGridsX - 1); if (rclPoint.y <= _fMinY) rulY = 0; else - rulY = std::min((unsigned long)((rclPoint.y - _fMinY) / _fGridLenY), _ulCtGridsY - 1); + rulY = std::min(static_cast((rclPoint.y - _fMinY) / _fGridLenY), _ulCtGridsY - 1); if (rclPoint.z <= _fMinZ) rulZ = 0; else - rulZ = std::min((unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ), _ulCtGridsZ - 1); + rulZ = std::min(static_cast((rclPoint.z - _fMinZ) / _fGridLenZ), _ulCtGridsZ - 1); } void MeshGrid::CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids) @@ -365,13 +365,13 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis) float fVolumenGrid = (fVolumen * ulGridsFacets) / (fFactorVolumen * _ulCtElements); if ((fVolumenGrid * iMaxGrids) < fVolumen) - fVolumenGrid = fVolumen / (float)iMaxGrids; + fVolumenGrid = fVolumen / static_cast(iMaxGrids); - float fLengthGrid = float(pow((float)fVolumenGrid,(float) 1.0f / 3.0f)); + float fLengthGrid = pow(fVolumenGrid, 1.0f / 3.0f); - _ulCtGridsX = std::max((unsigned long)(fLenghtX / fLengthGrid), 1); - _ulCtGridsY = std::max((unsigned long)(fLenghtY / fLengthGrid), 1); - _ulCtGridsZ = std::max((unsigned long)(fLenghtZ / fLengthGrid), 1); + _ulCtGridsX = std::max(static_cast(fLenghtX / fLengthGrid), 1); + _ulCtGridsY = std::max(static_cast(fLenghtY / fLengthGrid), 1); + _ulCtGridsZ = std::max(static_cast(fLenghtZ / fLengthGrid), 1); } break; case 1: @@ -383,12 +383,12 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis) float fAreaGrid = (fArea * ulGridsFacets) / (fFactorArea * _ulCtElements); if ((fAreaGrid * iMaxGrids) < fArea) - fAreaGrid = fArea / (float)iMaxGrids; + fAreaGrid = fArea / static_cast(iMaxGrids); float fLengthGrid = float(sqrt(fAreaGrid)); - _ulCtGridsY = std::max((unsigned long)(fLenghtY / fLengthGrid), 1); - _ulCtGridsZ = std::max((unsigned long)(fLenghtZ / fLengthGrid), 1); + _ulCtGridsY = std::max(static_cast(fLenghtY / fLengthGrid), 1); + _ulCtGridsZ = std::max(static_cast(fLenghtZ / fLengthGrid), 1); } break; case 2: { @@ -399,18 +399,18 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis) float fAreaGrid = (fArea * ulGridsFacets) / (fFactorArea * _ulCtElements); if ((fAreaGrid * iMaxGrids) < fArea) - fAreaGrid = fArea / (float)iMaxGrids; + fAreaGrid = fArea / static_cast(iMaxGrids); float fLengthGrid = float(sqrt(fAreaGrid)); - _ulCtGridsX = std::max((unsigned long)(fLenghtX / fLengthGrid), 1); - _ulCtGridsZ = std::max((unsigned long)(fLenghtZ / fLengthGrid), 1); + _ulCtGridsX = std::max(static_cast(fLenghtX / fLengthGrid), 1); + _ulCtGridsZ = std::max(static_cast(fLenghtZ / fLengthGrid), 1); } break; case 3: { _ulCtGridsX = 1; // bLenghtXisZero _ulCtGridsY = 1; // bLenghtYisZero - _ulCtGridsZ = iMaxGrids; // bLenghtYisZero + _ulCtGridsZ = static_cast(iMaxGrids); // bLenghtYisZero } break; case 4: { @@ -421,30 +421,30 @@ void MeshGrid::CalculateGridLength (int iCtGridPerAxis) float fAreaGrid = (fArea * ulGridsFacets) / (fFactorArea * _ulCtElements); if ((fAreaGrid * iMaxGrids) < fArea) - fAreaGrid = fArea / (float)iMaxGrids; + fAreaGrid = fArea / static_cast(iMaxGrids); float fLengthGrid = float(sqrt(fAreaGrid)); - _ulCtGridsX = std::max((unsigned long)(fLenghtX / fLengthGrid), 1); - _ulCtGridsY = std::max((unsigned long)(fLenghtY / fLengthGrid), 1); + _ulCtGridsX = std::max(static_cast(fLenghtX / fLengthGrid), 1); + _ulCtGridsY = std::max(static_cast(fLenghtY / fLengthGrid), 1); } break; case 5: { _ulCtGridsX = 1; // bLenghtXisZero _ulCtGridsZ = 1; // bLenghtZisZero - _ulCtGridsY = iMaxGrids; // bLenghtYisZero + _ulCtGridsY = static_cast(iMaxGrids); // bLenghtYisZero } break; case 6: { _ulCtGridsY = 1; // bLenghtYisZero _ulCtGridsZ = 1; // bLenghtZisZero - _ulCtGridsX = iMaxGrids; // bLenghtYisZero + _ulCtGridsX = static_cast(iMaxGrids); // bLenghtYisZero } break; case 7: { - _ulCtGridsX = iMaxGrids; // bLenghtXisZero - _ulCtGridsY = iMaxGrids; // bLenghtYisZero - _ulCtGridsZ = iMaxGrids; // bLenghtZisZero + _ulCtGridsX = static_cast(iMaxGrids); // bLenghtXisZero + _ulCtGridsY = static_cast(iMaxGrids); // bLenghtYisZero + _ulCtGridsZ = static_cast(iMaxGrids); // bLenghtZisZero } break; } } @@ -486,8 +486,8 @@ void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set= 0) + unsigned long nX = _ulCtGridsX - 1; + while (raclInd.empty() && nX < _ulCtGridsX) { for (unsigned long i = 0; i < _ulCtGridsY; i++) { @@ -514,8 +514,8 @@ void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set= 0) + unsigned long nY = _ulCtGridsY - 1; + while (raclInd.empty() && nY < _ulCtGridsY) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -542,8 +542,8 @@ void MeshGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set= 0) + unsigned long nZ = _ulCtGridsZ - 1; + while (raclInd.empty() && nZ < _ulCtGridsZ) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -577,37 +577,67 @@ void MeshGrid::GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, for (i = nX1; i <= nX2; i++) { for (j = nY1; j <= nY2; j++) - GetElements(i, j, nZ1, raclInd); + { + GetElements(static_cast(i), + static_cast(j), + static_cast(nZ1), + raclInd); + } } // bottom plane for (i = nX1; i <= nX2; i++) { for (j = nY1; j <= nY2; j++) - GetElements(i, j, nZ2, raclInd); + { + GetElements(static_cast(i), + static_cast(j), + static_cast(nZ2), + raclInd); + } } // left plane for (i = nY1; i <= nY2; i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - GetElements(nX1, i, j, raclInd); + { + GetElements(static_cast(nX1), + static_cast(i), + static_cast(j), + raclInd); + } } // right plane for (i = nY1; i <= nY2; i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - GetElements(nX2, i, j, raclInd); + { + GetElements(static_cast(nX2), + static_cast(i), + static_cast(j), + raclInd); + } } // front plane for (i = (nX1+1); i <= (nX2-1); i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - GetElements(i, nY1, j, raclInd); + { + GetElements(static_cast(i), + static_cast(nY1), + static_cast(j), + raclInd); + } } // back plane for (i = (nX1+1); i <= (nX2-1); i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - GetElements(i, nY2, j, raclInd); + { + GetElements(static_cast(i), + static_cast(nY2), + static_cast(j), + raclInd); + } } } @@ -684,9 +714,9 @@ MeshFacetGrid::MeshFacetGrid (const MeshKernel &rclM, float fGridLen) : MeshGrid(rclM) { Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox(); - Rebuild(std::max((unsigned long)(clBBMesh.LengthX() / fGridLen), 1), - std::max((unsigned long)(clBBMesh.LengthY() / fGridLen), 1), - std::max((unsigned long)(clBBMesh.LengthZ() / fGridLen), 1)); + Rebuild(std::max(static_cast(clBBMesh.LengthX() / fGridLen), 1), + std::max(static_cast(clBBMesh.LengthY() / fGridLen), 1), + std::max(static_cast(clBBMesh.LengthZ() / fGridLen), 1)); } void MeshFacetGrid::Validate (const MeshKernel &rclMesh) @@ -774,8 +804,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt { case Base::BoundBox3f::RIGHT: { - int nX = 0; - while ((fMinDist > ((clBB.MinX - rclPt.x) + ((float)(nX) * _fGridLenX))) && ((unsigned long)(nX) < _ulCtGridsX)) + unsigned long nX = 0; + while ((fMinDist > ((clBB.MinX - rclPt.x) + (float(nX) * _fGridLenX))) && (nX < _ulCtGridsX)) { for (unsigned long i = 0; i < _ulCtGridsY; i++) { @@ -788,8 +818,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt } case Base::BoundBox3f::LEFT: { - int nX = _ulCtGridsX - 1; - while ((fMinDist > ((rclPt.x - clBB.MinX) + (float(nX) * _fGridLenX))) && (nX >= 0)) + unsigned long nX = _ulCtGridsX - 1; + while ((fMinDist > ((rclPt.x - clBB.MinX) + (float(nX) * _fGridLenX))) && (nX < _ulCtGridsX)) { for (unsigned long i = 0; i < _ulCtGridsY; i++) { @@ -802,8 +832,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt } case Base::BoundBox3f::TOP: { - int nY = 0; - while ((fMinDist > ((clBB.MinY - rclPt.y) + ((float)(nY) * _fGridLenY))) && ((unsigned long)(nY) < _ulCtGridsY)) + unsigned long nY = 0; + while ((fMinDist > ((clBB.MinY - rclPt.y) + (float(nY) * _fGridLenY))) && (nY < _ulCtGridsY)) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -816,8 +846,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt } case Base::BoundBox3f::BOTTOM: { - int nY = _ulCtGridsY - 1; - while ((fMinDist > ((rclPt.y - clBB.MinY) + (float(nY) * _fGridLenY))) && (nY >= 0)) + unsigned long nY = _ulCtGridsY - 1; + while ((fMinDist > ((rclPt.y - clBB.MinY) + (float(nY) * _fGridLenY))) && (nY < _ulCtGridsY)) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -830,8 +860,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt } case Base::BoundBox3f::BACK: { - int nZ = 0; - while ((fMinDist > ((clBB.MinZ - rclPt.z) + ((float)(nZ) * _fGridLenZ))) && ((unsigned long)(nZ) < _ulCtGridsZ)) + unsigned long nZ = 0; + while ((fMinDist > ((clBB.MinZ - rclPt.z) + (float(nZ) * _fGridLenZ))) && (nZ < _ulCtGridsZ)) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -844,8 +874,8 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint (const Base::Vector3f &rclPt } case Base::BoundBox3f::FRONT: { - int nZ = _ulCtGridsZ - 1; - while ((fMinDist > ((rclPt.z - clBB.MinZ) + ((float)(nZ) * _fGridLenZ))) && (nZ >= 0)) + unsigned long nZ = _ulCtGridsZ - 1; + while ((fMinDist > ((rclPt.z - clBB.MinZ) + (float(nZ) * _fGridLenZ))) && (nZ < _ulCtGridsZ)) { for (unsigned long i = 0; i < _ulCtGridsX; i++) { @@ -908,37 +938,67 @@ void MeshFacetGrid::SearchNearestFacetInHull (unsigned long ulX, unsigned long u for (i = nX1; i <= nX2; i++) { for (j = nY1; j <= nY2; j++) - SearchNearestFacetInGrid(i, j, nZ1, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(i), + static_cast(j), + static_cast(nZ1), + rclPt, rfMinDist, rulFacetInd); + } } // bottom plane for (i = nX1; i <= nX2; i++) { for (j = nY1; j <= nY2; j++) - SearchNearestFacetInGrid(i, j, nZ2, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(i), + static_cast(j), + static_cast(nZ2), + rclPt, rfMinDist, rulFacetInd); + } } // left plane for (i = nY1; i <= nY2; i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - SearchNearestFacetInGrid(nX1, i, j, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(nX1), + static_cast(i), + static_cast(j), + rclPt, rfMinDist, rulFacetInd); + } } // right plane for (i = nY1; i <= nY2; i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - SearchNearestFacetInGrid(nX2, i, j, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(nX2), + static_cast(i), + static_cast(j), + rclPt, rfMinDist, rulFacetInd); + } } // front plane for (i = (nX1+1); i <= (nX2-1); i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - SearchNearestFacetInGrid(i, nY1, j, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(i), + static_cast(nY1), + static_cast(j), + rclPt, rfMinDist, rulFacetInd); + } } // back plane for (i = (nX1+1); i <= (nX2-1); i++) { for (j = (nZ1+1); j <= (nZ2-1); j++) - SearchNearestFacetInGrid(i, nY2, j, rclPt, rfMinDist, rulFacetInd); + { + SearchNearestFacetInGrid(static_cast(i), + static_cast(nY2), + static_cast(j), + rclPt, rfMinDist, rulFacetInd); + } } } @@ -987,9 +1047,9 @@ MeshPointGrid::MeshPointGrid (const MeshKernel &rclM, float fGridLen) : MeshGrid(rclM) { Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox(); - Rebuild(std::max((unsigned long)(clBBMesh.LengthX() / fGridLen), 1), - std::max((unsigned long)(clBBMesh.LengthY() / fGridLen), 1), - std::max((unsigned long)(clBBMesh.LengthZ() / fGridLen), 1)); + Rebuild(std::max(static_cast(clBBMesh.LengthX() / fGridLen), 1), + std::max(static_cast(clBBMesh.LengthY() / fGridLen), 1), + std::max(static_cast(clBBMesh.LengthZ() / fGridLen), 1)); } void MeshPointGrid::AddPoint (const MeshPoint &rclPt, unsigned long ulPtIndex, float fEpsilon) @@ -1061,9 +1121,9 @@ void MeshPointGrid::RebuildGrid (void) void MeshPointGrid::Pos (const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const { - rulX = (unsigned long)((rclPoint.x - _fMinX) / _fGridLenX); - rulY = (unsigned long)((rclPoint.y - _fMinY) / _fGridLenY); - rulZ = (unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ); + rulX = static_cast((rclPoint.x - _fMinX) / _fGridLenX); + rulY = static_cast((rclPoint.y - _fMinY) / _fGridLenY); + rulZ = static_cast((rclPoint.z - _fMinZ) / _fGridLenZ); } unsigned long MeshPointGrid::FindElements (const Base::Vector3f &rclPoint, std::set& aulElements) const diff --git a/src/Mod/Mesh/App/Core/MeshKernel.cpp b/src/Mod/Mesh/App/Core/MeshKernel.cpp index 9c2e363876..8fe9b5f359 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.cpp +++ b/src/Mod/Mesh/App/Core/MeshKernel.cpp @@ -519,7 +519,7 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter) { MeshFacetIterator pFIter(*this), pFEnd(*this); std::vector clToDel; - unsigned long i, ulInd; + unsigned long ulInd; // index of the point to delete ulInd = rclIter._clIter - _aclPointArray.begin(); @@ -529,7 +529,7 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter) // check corner points of all facets while (pFIter < pFEnd) { - for (i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { if (ulInd == pFIter._clIter->_aulPoints[i]) clToDel.push_back(pFIter); } @@ -541,7 +541,7 @@ bool MeshKernel::DeletePoint (const MeshPointIterator &rclIter) // delete each facet separately (from back to front to avoid to // invalidate the iterators) - for (i = clToDel.size(); i > 0; i--) + for (size_t i = clToDel.size(); i > 0; i--) DeleteFacet(clToDel[i-1]); return true; } @@ -799,8 +799,8 @@ void MeshKernel::Write (std::ostream &rclOut) const Base::OutputStream str(rclOut); // Write a header with a "magic number" and a version - str << (uint32_t)0xA0B0C0D0; - str << (uint32_t)0x010000; + str << static_cast(0xA0B0C0D0); + str << static_cast(0x010000); char szInfo[257]; // needs an additional byte for zero-termination strcpy(szInfo, "MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-" @@ -810,7 +810,7 @@ void MeshKernel::Write (std::ostream &rclOut) const rclOut.write(szInfo, 256); // write the number of points and facets - str << (uint32_t)CountPoints() << (uint32_t)CountFacets(); + str << static_cast(CountPoints()) << static_cast(CountFacets()); // write the data for (MeshPointArray::_TConstIterator it = _aclPointArray.begin(); it != _aclPointArray.end(); ++it) { @@ -818,12 +818,12 @@ void MeshKernel::Write (std::ostream &rclOut) const } for (MeshFacetArray::_TConstIterator it = _aclFacetArray.begin(); it != _aclFacetArray.end(); ++it) { - str << (uint32_t)it->_aulPoints[0] - << (uint32_t)it->_aulPoints[1] - << (uint32_t)it->_aulPoints[2]; - str << (uint32_t)it->_aulNeighbours[0] - << (uint32_t)it->_aulNeighbours[1] - << (uint32_t)it->_aulNeighbours[2]; + str << static_cast(it->_aulPoints[0]) + << static_cast(it->_aulPoints[1]) + << static_cast(it->_aulPoints[2]); + str << static_cast(it->_aulNeighbours[0]) + << static_cast(it->_aulNeighbours[1]) + << static_cast(it->_aulNeighbours[2]); } str << _clBoundBox.MinX << _clBoundBox.MaxX; @@ -942,7 +942,7 @@ void MeshKernel::Read (std::istream &rclIn) } // without edge array - if (ratio < 2.5) { + if (ratio < 2.5f) { // the stored mesh kernel might be empty if (uCtPts > 0) { pointArray.resize(uCtPts); @@ -1096,8 +1096,8 @@ float MeshKernel::GetVolume() const fVolume += (-p3.x*p2.y*p1.z + p2.x*p3.y*p1.z + p3.x*p1.y*p2.z - p1.x*p3.y*p2.z - p2.x*p1.y*p3.z + p1.x*p2.y*p3.z); } - fVolume /= 6.0; - fVolume = (float)fabs(fVolume); + fVolume /= 6.0f; + fVolume = fabs(fVolume); return fVolume; } diff --git a/src/Mod/Mesh/App/Core/MeshKernel.h b/src/Mod/Mesh/App/Core/MeshKernel.h index ba271fc19a..3972d6b719 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.h +++ b/src/Mod/Mesh/App/Core/MeshKernel.h @@ -83,16 +83,16 @@ public: //@{ /// Returns the number of facets unsigned long CountFacets (void) const - { return (unsigned long)(_aclFacetArray.size()); } + { return static_cast(_aclFacetArray.size()); } /// Returns the number of edge unsigned long CountEdges (void) const; // Returns the number of points unsigned long CountPoints (void) const - { return (unsigned long)(_aclPointArray.size()); } + { return static_cast(_aclPointArray.size()); } /// Returns the number of required memory in bytes unsigned int GetMemSize (void) const - { return _aclPointArray.size() * sizeof(MeshPoint) + - _aclFacetArray.size() * sizeof(MeshFacet); } + { return static_cast(_aclPointArray.size() * sizeof(MeshPoint) + + _aclFacetArray.size() * sizeof(MeshFacet)); } /// Determines the bounding box const Base::BoundBox3f& GetBoundBox (void) const { return _clBoundBox; } diff --git a/src/Mod/Mesh/App/Core/SetOperations.cpp b/src/Mod/Mesh/App/Core/SetOperations.cpp index e2a2d9f441..ab9f011e13 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.cpp +++ b/src/Mod/Mesh/App/Core/SetOperations.cpp @@ -458,7 +458,7 @@ void SetOperations::CollectFacets (int side, float mult) mb.Finish(); MeshAlgorithm algo(mesh); - algo.ResetFacetFlag((MeshFacet::TFlagType)(MeshFacet::VISIT | MeshFacet::TMP0)); + algo.ResetFacetFlag(static_cast(MeshFacet::VISIT | MeshFacet::TMP0)); // bool hasFacetsNotVisited = true; // until facets not visited // search for facet not visited diff --git a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp index e5a15d34e3..e5fc620158 100644 --- a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp +++ b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp @@ -107,7 +107,7 @@ bool MeshTopoAlgorithm::SnapVertex(unsigned long ulFacetPos, const Base::Vector3 if (!rFace.HasOpenEdge()) return false; Base::Vector3f cNo1 = _rclMesh.GetNormal(rFace); - for (short i=0; i<3; i++) + for (unsigned short i=0; i<3; i++) { if (rFace._aulNeighbours[i]==ULONG_MAX) { @@ -383,7 +383,7 @@ int MeshTopoAlgorithm::DelaunayFlip() { int cnt_swap=0; _rclMesh._aclFacetArray.ResetFlag(MeshFacet::TMP0); - unsigned long cnt_facets = _rclMesh._aclFacetArray.size(); + size_t cnt_facets = _rclMesh._aclFacetArray.size(); for (unsigned long i=0;i(ulT0, ulT1); unsigned long ulP1 = std::max(ulT0, ulT1); aclEdgeMap[std::make_pair(ulP0, ulP1)].push_front(k); - aIdx.push_back( (int)jt->_aulPoints[i] ); + aIdx.push_back( static_cast(jt->_aulPoints[i]) ); } } // compute vertex based curvatures - Wm4::MeshCurvature meshCurv(_rclMesh.CountPoints(), &(aPnts[0]), _rclMesh.CountFacets(), &(aIdx[0])); + Wm4::MeshCurvature meshCurv(static_cast(_rclMesh.CountPoints()), &(aPnts[0]), + static_cast(_rclMesh.CountFacets()), &(aIdx[0])); // get curvature information now const Wm4::Vector3* aMaxCurvDir = meshCurv.GetMaxDirections(); @@ -1496,7 +1497,7 @@ void MeshTopoAlgorithm::FindComponents(unsigned long count, std::vector >::iterator it = segments.begin(); it != segments.end(); ++it) { - if (it->size() <= (unsigned long)count) + if (it->size() <= count) findIndices.insert(findIndices.end(), it->begin(), it->end()); } }